Hi there,
I need use the insertText method to insert template variables in the text in the editor at the position of the users cursor. To use this method I need to provide the correct index to insert it as.
Doing this within a text-change or selection-change event works for the first line of text in the editor...
var sel = editor.root.ownerDocument.getSelection();
cursorPosition = sel.baseOffset;
But when you hit return into the next paragraph it no longer works.
How would I do this to get the current cursor position in the whole editor for use in the insertText method?
Take a look at Quill's getSelection.
Just discovered that! Should have read in more detail... thanks very much.
@jhchen
How to know what content of text I insert in, I should compare with the old text and current text?
Most helpful comment
Take a look at Quill's getSelection.