Insert text at cursor position in tinyMCE text editor

I have several drop-down boxes that should insert dynamic text (as selected) at the cursor position in a tinyMCE-enabled text editor.

I found a lot of posts related to the above problem, as shown below, and it does not currently work with my code, and also does not give any errors in the console.

tinyMCE.execInstanceCommand('text',"mceInsertContent",false,"This is the text to be inserted");
// here 'text' is id of textarea on which TinyMCE is rendered

I assume that when I click on the drop-down list, I lose focus in a text editor, but still I can’t fix it.

Any help would be appreciated.

+4
source share
1 answer

You must use execCommandinsted execInstanceCommandbelow

tinyMCE.execCommand('mceInsertContent',false,"This is the text to be inserted");

, tinyMCE (2X), API.

+4

All Articles