Bring the cursor position of the cursor outside of the inserted node
I am using summernote WYSIWYG plugin and add DOM elements (buttons, links, etc.) based on user actions like clicking on a button. The API insertNode
adds a node to the editor area, but leaves the cursor inside that node (i.e., the cursor is inside tags <button></button>
.
How can I ensure that the cursor is outside of this last insert node?
source to share
I had the same problem and the solution I came across was to insert a space character immediately after inserting a node.
editor.insertNode($editable, $(rawHTML)[0]);
editor.insertText($editable, ' ');
This actually solved 2 problems for me as I also wanted there to be a room between the two buttons being added one after the other.
I know this is not exactly what you were looking for, but I thought it was the most elegant solution because changing functionality insertNode
might have different consequences.
source to share