2

Im working with tinyMCE 4.x and would like to remove ANY set format in the whole editor text programmatically. It just should do what the removeFormat command does. So far I came:

tinymce.execCommand('selectAll', true, 'texteditor');
tinymce.execCommand('RemoveFormat', true, 'texteditor');

The removeFormat works only on preselected text so I do a 'SelectAll' before RemoveFormat. That works fine but all stays selected after RemoveFormat. So the question is: Is there a way to remove any format without selecting all before? If no, how do I unselect previously selected text? (I tried to set focus on texteditor after, but selection remains). Im sure there is a simple way just couldn't find it in the net.

Jonny
  • 816
  • 10
  • 24

1 Answers1

6

I guess I found an answer. After using RemoveFormat you can add this line:

tinymce.activeEditor.selection.collapse();
Jonny
  • 816
  • 10
  • 24