I am trying to write a plugin for TinyMCE with a feature to add content to the beginning of the content. I know the following command which will insert content at the current location of the cursor. How do I force it to insert it at the beginning of the content?
tinyMCEPopup.editor.execCommand('mceInsertRawHTML', false, "halo world");
tinyMCEPopup.editor.execCommand('mceInsertContent', false, "halo world");
For this you will need to set the cursor location to the beginning of the editor content. you may use the function setCursorLocation:
ed.selection.setCursorLocation(ed.getBody().firstChild, 0); // node to set the cursor to, second param is offset
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With