在初始化时隐藏 TinyMce 工具栏

Hide TinyMce Toolbar on init

我想在设置内容后将我的 tinymce 工具栏设置为只读。所以我在编辑器上订阅了这样的初始化函数

 editor.on('init', () => {
          editor.setContent(this.value);
          if (this.disabled) {
            editor.contentDocument.body.bgColor = '#eeeeee';
            editor.toolbar = this.disabled ? !this.disabled : undefined;
            editor.setMode('readonly');
          }

但是,如果我将编辑器工具栏设置为 false,工具栏将始终显示。我该怎么做?

您可以获得工具栏 DOM 元素并使用 css 隐藏。

var toolbar = editor.getContainer().querySelector('.mce-toolbar-grp');
toolbar.style.display = 'none';