自定义ContentTools的编辑按钮

Customise Edit Button for ContentTools

本文关键字:编辑按 按钮 编辑 ContentTools 自定义      更新时间:2023-09-26

我很难理解如何在ContentTools(wysiwyg编辑器)中更改编辑(Ignition)按钮的外观和/或位置。

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

他们网站上的文档和教程对我的理解不够。

谢谢!

我建议有两种方法可以做到这一点,最简单的选择是像这样隐藏点火按钮(如所称)(参考SASS):

.ct-ignition {
    display: none;
}

如果您希望从DOM中完全删除该按钮,那么您可以从UI中卸载该按钮,如下所示(参考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问题列表上提出的这些问题可能会很有用:

  • https://github.com/GetmeUK/ContentTools/issues/77
  • https://github.com/GetmeUK/ContentTools/issues/78