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

Killing Floor monsters in Counter-Strike
Sorry, I don't have IPs of these servers. 😳 Gorefast (XMAS) in Counter-Strike... Read more
·1 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
How to get GIT repository URL from source folder
There are several ways to get the link to a GIT repository from the directory... Read more
·1 min. read

© geekrainian.com