How to reinitialize multiple TinyMCE editors

·1 min. read·

At some point, there was a need to reload multiple TinyMCE editors on one page, but embedded in different components.

For a project written in AngularJS, we can use the tinymce global object, which contains a nested variable EditorManager.editors. To access each editor, simply iterate through each element of the array of this variable. To reload an editor, you can call the execCommand function with parameters mceRemoveEditor and mceAddEditor adding a small delay (timeout) between each call.

Example code:

tinymce.EditorManager.editors.forEach(function (editor) {
  tinymce.EditorManager.execCommand('mceRemoveEditor', false, editor.id);
  $timeout(() => {
    tinymce.EditorManager.execCommand('mceAddEditor', false, editor.id);
    tinymce.settings = $scope.tinymceOptions;
  });
});

You may also like

Giran Castle Town paper model

Found it on the internet. Author unknown... Read more
·1 min. read

Killing Floor Mutator - Chat Logging

This mutator is based on CorLogMut by Dr_Killjoy. It utilizes the FileLog class... Read more
·3 min. read

Lineage 2 client update history

Lineage 2 is an online role-playing game developed by NCSOFT. The game... Read more
·3 min. read

© geekrainian.com.