Is there a way to replace the content_css in TinyMCE?
I have a single textarea on a page that is being used to edit HTML content that is dynamically loaded from a list of links using content returned from a server call as follows:
tinymce.get('contenteditor').setContent(json.content);
I also need to change the CSS in the TinyMCE editor for the different pages. I'm doing the following just before the setContent:
tinymce.activeEditor.dom.loadCSS("tinyMCECSS?cssid=" + json.cssId);
Unfortunately, this is just adding the provided CSS to what is already loaded. eg. if the first page CSS has
h1 {color: red;}
and the second page has:
h1 {color: blue;}
If I load the first page, the h1's are red. If I then switch to the second page, they turn blue (as expected). However, if I then go back to the first page, they remain blue.
If the pages are loaded the other way round, then the reverse happens and I'm stuck with red.
It appears that it's just appended the CSS with the loadCSS() function.
Is there a way to remove the all of the first CSS before I replace it with the second file?
I've tried clearing the content_css value, but it doesn't work and I don't think that's the right one :-)
tinymce.activeEditor.content_css = []
I've tried a complete reinitialisation (with tinymce.init()) at the time of updating the editor, but I'm still getting the combined CSS as described above.
Thanks for your time :-)