将代码格式添加到工具栏中它自己的按钮

Add the Code Format to its own button in the toolbar

我正在制作我自己的 TinyMCE 工具栏,我想添加与您选择“格式”>“代码”时完全相同的功能,但作为工具栏中自己的按钮。这可能吗?我应该怎么做?

谢谢!

我明白了。您可以添加自己的按钮,然后让它执行命令。

setup: function(editor) {
    editor.ui.registry.addButton('strikeout', {
      icon: 'sourcecode',
      tooltip: "Format as code",
      onAction: function() {
        editor.execCommand('mceToggleFormat', false, 'code');
      }
    });
}