为 ContentTools 自定义编辑按钮

Customise Edit Button for ContentTools

我很难理解如何更改 ContentTools(所见即所得编辑器)中编辑(点火)按钮的外观 and/or 位置。

我发现我可以使用 editor.start();editor.stop(); 来触发页面的编辑,我想将这些功能映射到我自己的按钮,但我无法摆脱默认设置按钮。

他们网站上的文档和教程没有帮助我理解这一点。

谢谢!

我推荐两种方法,最简单的选择是像这样隐藏点火按钮(正如它的名称)(reference SASS):

.ct-ignition {
    display: none;
}

如果您希望从 DOM 中完全删除按钮,那么您可以像这样从 UI 中卸载按钮 (reference CoffeeScript):

// Once the Editor has been initialized
ContentTools.EditorApp.get()._ignition.unmount();

我的建议是使用 CSS 来隐藏点火并触发针对它的事件以通过您的自定义按钮手动调用功能,如下所示:

var editor = ContentTools.EditorApp.get();

// Starting the editor manually
editor._ignition.trigger('start');

// Stoping the editor manually (save)
editor._iginition.trigger('stop', true);

// Stoping the editor manually (cancel)
editor._iginition.trigger('stop', false);

查看项目 github 问题列表中提出的这些问题可能会有用: