javascript - Preserve selection after clicking a custom button in tinyMCE issue -


here issue :

i have custom button code onclick. code modify selection's parent node, , selection stays same after code, tinymce disable selection , give me caret instead.

i tried getrng() , setrng tinymce api without success, results pretty odd. works , deactivate selection , give me caret instead. plus, works 2 times , button not respond.

here code not work:

 onclick : function() {                 range_selection = tinymce.activeeditor.selection.getrng();                 //here own code modify parent node                    tinymce.activeeditor.selection.setrng(range_selection);                 } 

problem here range not applicable anymore because of changed dom structure. use bookmark overcome issue:

var bookmark = ed.selection.getbookmark();  // here  ed.selection.`movetobookmark`(bookmark); 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -