Javascript在加载时移除ckeditor插件

Javascript remove ckeditor plugins on load

本文关键字:ckeditor 插件 加载 Javascript      更新时间:2023-09-26

Html:

<textarea name="Editor" class="ckeditor" id="aboutme">@Model.Content</textarea>
Javascript:

<script>
    config.removePlugins = 'elementspath,save,font';
</script>

当页面加载时,我想禁用所有ckeditor插件。我尝试了上面的代码,但是它不适合我。

如何在加载页面时删除javascript插件?

感谢任何帮助。谢谢。

你可以定义一个插件列表来加载(CKEDITOR.config#plugins):

config.plugins = 'wysiwygarea,toolbar,basicstyles,...';

但是你也可以限制现有的(默认的)插件列表(CKEDITOR.config#removePlugins):

config.removePlugins = 'link,...';

这两个选项都可以全局定义(config.js)或为特定的编辑器实例定义,如

CKEDITOR.replace( 'editor1', {
    removePlugins: 'link'
} );

请参考官方设置配置指南了解更多信息。

注意:自CKEditor 4.1以来,插件的存在决定了与该插件相关的某些类型内容是否被允许或不被允许。阅读更多关于高级内容过滤器

在对oleq回答的评论中回答我自己的问题:

我有一个CKEditor实例,我正在使用(jQuery)像这样:

window.onload = function () {
        $ckTarget = $(".pageContentTextBox");
        if ($(".pageContentTextBox").length > 0) {
            $ckEditor = $ckTarget.ckeditor({
                htmlEncodeOutput: true,
                removePlugins: "link"
            });
        }
};

我能够成功地删除"链接"插件的方式。我将设置一个带有公共属性的ASP.net用户控件"extraPlugins"answers"removePlugins",并使用客户端黄色标签("代码块")插入值,以便能够在启用/禁用不同插件的多个页面上使用此控件。

我希望这能帮助到一些人!

你也可以编辑config.js。这个js是从ckeditor.js加载/包含的。Config.js是默认的自定义编辑器js文件。您可以通过包含要删除的元素名称列表来从编辑器中删除按钮或插件。要从编辑器中删除的名称列表请参阅以下链接:https://ckeditor.com/old/forums/CKEditor-3.x/config.js-changes-not-reflected

包括要从编辑器中删除的按钮或插件列表,将它们附加到配置中。并将这行代码包含在config.js

// Remove some buttons provided by the standard plugins, which are
// not needed in the Standard(s) toolbar.
config.removeButtons = 'Underline,Subscript,Superscript,Image,Flash,Table,HorizontalRule,Smiley...';