Keep carriage / bookmark position in tiny state when using setContent

I am working on open source to enable collaborative editing in CMS. The use case is as follows: While user A is editing several small node users, he is updating the same node. Everything works fine, updating the user. A tiny editor, except for maintaining the cursor position. I.e

var bookmark = editor.selection.getBookmark(); editor.setContent(content); editor.selection.moveToBookmark(bookmark); 

will not work if the content has changed before the carriage. http://tinymce.moxiecode.com/forum/viewtopic.php?id=20458 mentions that there will be an update to deal with this situation, but is there something I could do now? Thank you in advance!

+6
source share
1 answer

It may be a glimpse of the goal, but there is another way. You can use a formalized bookmark. The code will look like

 var bookmark = editor.selection.getBookmark(2, true); editor.setContent(content); editor.selection.moveToBookmark(bookmark); 
+7
source

Source: https://habr.com/ru/post/886829/


All Articles