如何在处于只读模式时启用 CKEDITOR 中的单个按钮

发布于 2024-11-27 18:34:35 字数 239 浏览 1 评论 0原文

我为 CKEDITOR 创建了一个插件,它将打开一个弹出对话框。我希望即使当我的 CKEDITOR 处于只读模式时也能启用它。无论如何我可以做到吗?

我还想知道是否有任何方法可以在只读模式下禁用“源”按钮。

编辑器是禁用还是启用是动态确定的,我希望所有工具栏都存在,但处于禁用模式,因此我无法从工具栏中删除源按钮。

我在过去的三个小时里试图找到一种方法,但我无法找到它。而且很紧急。 :(

提前致谢。

I created a plugin for CKEDITOR which will open a popup dialog. And i want it to be enabled even when my CKEDITOR is in readOnly mode. Is there anyway i can do it?

Also i want to know is there any way to disable the Source button in the readOnly mode.

Whether the editor is disabled or enabled is determined dynamically and i want all the toolbars to be present but in the disabled mode, so i can't remove the source button from the toolbar.

I'm trying to find a way for last 3hours, and i can't get to it. And its urgent. :(

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

メ斷腸人バ 2024-12-04 18:34:35

这个愚蠢可怕的黑客可能会帮助你:)

// Save command after loading editor.
var sourceCommand = CKEDITOR.instances.editor1.ui._.items.Source.args[0].command;

// When disabling editor, unset command
CKEDITOR.instances.editor1.ui._.items.Source.args[0].command = undefined;

// When enabling editor, reset command
CKEDITOR.instances.editor1.ui._.items.Source.args[0].command = sourceCommand;

This stupid horrible hack might help you :)

// Save command after loading editor.
var sourceCommand = CKEDITOR.instances.editor1.ui._.items.Source.args[0].command;

// When disabling editor, unset command
CKEDITOR.instances.editor1.ui._.items.Source.args[0].command = undefined;

// When enabling editor, reset command
CKEDITOR.instances.editor1.ui._.items.Source.args[0].command = sourceCommand;
眼藏柔 2024-12-04 18:34:35

加载编辑器后使用类似的东西并添加/删除您想要和不想要的工具

var editor = CKEDITOR.replace( 'txtarea_name',
{
工具栏:
[ ['新页'],
['剪切','复制','粘贴','PasteText','PasteWord'],
['撤消','重做','粗体','斜体','下划线','删除线'],
['有序列表','无序列表'],
['NumberedList','BulletedList','-','Outdent','Indent'],
['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
['字体','字体大小']]

<前><代码> }

);

Use something like this once the editor is loaded and add/remove the tools you want and don't want

var editor = CKEDITOR.replace( 'txtarea_name',
{
toolbar :
[ ['NewPage'],
['Cut','Copy','Paste','PasteText','PasteWord'],
['Undo','Redo','Bold','Italic','Underline','StrikeThrough'],
['OrderedList','UnorderedList'],
['NumberedList','BulletedList','-','Outdent','Indent'],
['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
['Font','FontSize']]

      }    

);

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文