TinyMCE custom plugin, how to make a word automatically selected based on current cursor position? TinyMCE custom plugin, how to make a word automatically selected based on current cursor position? wordpress wordpress

TinyMCE custom plugin, how to make a word automatically selected based on current cursor position?


You can do it like below

if (editor.selection.isCollapsed()) {    var selRng = editor.selection.getRng();    selRng.expand("word"); //expands the DOM range to the current word    editor.selection.setRng(selRng);}

Below is a JS Fiddle for the same

https://jsfiddle.net/t9qhmguo/

Output