I need help with editor.js
Imagine the following scenario, on my page I have the editor.js on the right and a bunch of buttons on the right side of the screen.
The buttons are a collection of phrases, and when click on it, the phrase must be inserted in the editor.js
However, it must be inserted where the cursor was before losing focus, considering it to be anywhere in the editor.js, Example, can be in the first, second or last block, and within a specific block, the cursor can be in the beginning, middle or end of the sentence.
How can I retrieve the block and cursor position to insert the new phrase?
Thanks in advance
You can try to use the below to set the cursor back to the previous position. However, this doesn't work correctly if you have nested elements in your block.
To get last cursor position:
To get current block index:
where editor is your created
editor.js
instance.Reference: https://editorjs.io/caret#settoblock