How to change activeEditor in TinyMCE?

Viewed 357

How can I change activeEditor programetically in tinyMCE. Ex: Like if I have two editors in same page, How can I switch between them programetically?

2 Answers

The activeEditor will switch when you focus a different editor so the method is to call focus on the editor you want to be active. You can choose to not actually focus the editor by passing false.
https://www.tiny.cloud/docs/api/tinymce/tinymce.editor/#focus

Extract from that page:

focus

focus(skipFocus:Boolean)

Focuses/activates the editor. This will set this editor as the activeEditor in the tinymce collection it will also place DOM focus inside the editor.

Parameters

  • skipFocus (Boolean) - Skip DOM focus. Just set is as the active editor.

We can get any instance of TinyMCE by tinyMCE.get('field-name') or by tinyMCE['field-name'] here field name will be the field TinyMCE is associated with.

Related