Search code examples
tinymcetinymce-5

TinyMCE - toggle dark-theme after init


after the tinymce.init() i can toggle the readOnly setting like this:

editor.mode.set("design");
editor.mode.set("readonly");

but how can i toggle the dark theme for the editor and the content?

this will not work:

  editor.mode.set.content_css("dark");
  editor.mode.set.skin("dark-oxide");

Solution

  • No, it is not possible. All the settings defined in the tinymce.init() function cannot be changed without reinitialization. However, reinitialization can be done very fast. You will need to perform 4 steps:

    1. Save current content somewhere with getContent()
    2. Destroy the TinyMCE instance with destroy()
    3. Reinitialize
    4. Use setContent() to add the content saved on step 1.