检测用户何时在 CKEditor 中切换编辑模式

发布于 2024-09-06 11:49:19 字数 105 浏览 1 评论 0原文

在CKEditor中,是否有一个事件可以绑定到当用户在所见即所得视图和源视图之间切换时触发的事件?

如果没有,我需要在视图更改时启用/禁用页面上的一些其他控件;我的最佳策略是什么?

In CKEditor, is there an event that can be bound to which fires when the user switches between the WYSIWYG view and the source view?

If not, I need to enable/disable some other controls on the page when the view changes; what's my best strategy?

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

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

发布评论

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

评论(2

莳間冲淡了誓言ζ 2024-09-13 11:49:19

我仍然无法找到任何文档,但在研究 CKEditor 实例的内部结构后,我能够找到我正在寻找的事件:

instance.on('mode ', function() {
     // 当用户切换编辑模式时执行的代码
}

初始化编辑器时该事件会触发一次。每当 source 命令被激活时(通过 instance.execCommand(...) 或用户单击 Source 工具栏按钮)。

I'm still unable to find any documentation, but after poking around the internals of a CKEditor instance, I was able to find the event I'm looking for:

instance.on('mode', function() {
     // Code to execute when the user switches editing modes
}

Easy enough. The event fires once when the editor is initialized and again any time the source command is activated (either through instance.execCommand(...) or the user clicking a Source toolbar button).

为你拒绝所有暧昧 2024-09-13 11:49:19

我有一个旧版本并解决了这个问题

CKEDITOR.instances['terms_and_conditions'].on('mode', function() {
    console.log(this.mode); // outputs: source, wysiwyg
});

I have an older version and solved this with

CKEDITOR.instances['terms_and_conditions'].on('mode', function() {
    console.log(this.mode); // outputs: source, wysiwyg
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文