TinyMCE常用于CMS软件中。当前绑定到 TinyMCE 编辑器的 CSS 文件需要经常交换。
有两点很重要:
这里是解决方案:
function reloadCSS()
{
// remove all previous CSS files
tinymce.activeEditor.dom.styleSheetLoader.unloadAll(tinymce.activeEditor.contentCSS);
// clean up the variable for storing the list of CSS files
tinymce.activeEditor.contentCSS = [];
// add the timestamp to the css to force loading from the server (not from cache)
let new_css = 'editor.css?t=' + Date.now();
// add new CSS files to the variable for storing the list of CSS files
tinymce.activeEditor.contentCSS.push(new_css);
// load new CSS file into the editor
tinymce.activeEditor.dom.styleSheetLoader.load(new_css);
}
我尝试先通过硬重新初始化来做到这一点,但效果不佳。