【发布时间】:2018-12-12 18:02:55
【问题描述】:
我正在为具有多种语言的 ckeditor 使用 SCAYT 插件。我已在启动时自动启用 scayt。通过代码当用户通过代码在下拉菜单中选择语言为中文/日文时,我想禁用拼写检查。我该怎么做?
【问题讨论】:
我正在为具有多种语言的 ckeditor 使用 SCAYT 插件。我已在启动时自动启用 scayt。通过代码当用户通过代码在下拉菜单中选择语言为中文/日文时,我想禁用拼写检查。我该怎么做?
【问题讨论】:
使用editor.execCommand 手动启用/禁用 SCAYT(通过代码):
CKEDITOR.instances.yourInstance.execCommand( 'scaytcheck' );
如果您想在启动时决定是否启用 SCAT,请使用pluginsLoaded 事件覆盖配置选项(请参阅:fiddle):
CKEDITOR.replace( 'editor', {
plugins: 'wysiwygarea,sourcearea,basicstyles,toolbar,scayt',
// Turn on SCAYT automatically
scayt_autoStartup: true,
on: {
configLoaded: function() {
// Disable SCAYT when japanese.
if ( this.config.language == 'ja' )
this.config.scayt_autoStartup = false;
}
}
} );
【讨论】:
我只是想发布我发现的内容,因为我在论坛中没有找到“如何动态启用/禁用 SCAYT?”这个问题的答案。你可以这样做:
CKEDITOR.instances.editorId_1.getCommand('scaytcheck').exec()
这将运行单击“启用/禁用”按钮时调用的命令。
【讨论】:
作为对此答案的更新:我正在运行 CKEditor 4.6,并且只能使用
CKEDITOR.instances[i].execCommand('scaytToggle');
所以要遍历所有编辑器并切换 scyat:
for (var i in CKEDITOR.instances) {
CKEDITOR.instances[i].execCommand('scaytToggle');
}
【讨论】: