This plugin adds a toolbar button that allows a user to edit the HTML code hidden by the WYSIWYG view. It also adds the menu item
Source code under the
selector: 'textarea', // change this value according to your HTML
The safest assumption is that selection state is not preserved when switching between the rich-text editor (ie, the default TinyMCE editor instance) to the code editor dialog view of a TinyMCE document.
If the current selection in the TinyMCE instance is collapsed (ie, is a flashing insertion point), the insertion point will be in the equivalent place when the code editor is opened.
If the current selection in the rich-text editor is an actual selection, that state is not preserved when switching to the code editor.
Instead, the insertion point in the code editor is placed at the beginning of what was the selection in the rich-text editor.
When switching back from the code-view dialog to the rich-text editor, selection state is almost never preserved.
If you have a selection or a collapsed selection in the rich-text editor and
open the code view dialog;
make no changes; and
exit the code view dialog by clicking Cancel (or pressing the Esc key);
the selection or collapsed selection will likely be preserved in the rich-text editor.
Otherwise, the selection state is not preserved on round-tripping from rich-text to code-view and back.
Instead, the insertion point is placed at the beginning of the editable block closest to the beginning of the TinyMCE document.