Javascript 在加载时删除 ckeditor 插件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24676003/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Javascript remove ckeditor plugins on load
提问by John Elizabeth
Html:
网址:
<textarea name="Editor" class="ckeditor" id="aboutme">@Model.Content</textarea>
Javascript:
Javascript:
<script>
config.removePlugins = 'elementspath,save,font';
</script>
When page load , i want to disable all ckeditor plugins.I tried above code however it did not work for me.
当页面加载时,我想禁用所有 ckeditor 插件。我尝试了上面的代码,但它对我不起作用。
How can i remove plugins by javascript on load of page ?
如何在页面加载时通过 javascript 删除插件?
Any help appreciates. Thanks.
任何帮助表示赞赏。谢谢。
回答by oleq
You can define a list of plugins to load (CKEDITOR.config#plugins
):
您可以定义要加载的插件列表 ( CKEDITOR.config#plugins
):
config.plugins = 'wysiwygarea,toolbar,basicstyles,...';
But you can also restrict existing (default) list of plugins (CKEDITOR.config#removePlugins
):
但您也可以限制现有(默认)插件列表 ( CKEDITOR.config#removePlugins
):
config.removePlugins = 'link,...';
Both options can be defined globally (config.js
) or for a particular editor instance like
这两个选项都可以全局定义 ( config.js
) 或针对特定的编辑器实例,例如
CKEDITOR.replace( 'editor1', {
removePlugins: 'link'
} );
Please refer to official Setting Configurationguide to know more.
请参阅官方设置配置指南以了解更多信息。
Note: Since CKEditor 4.1, the presence of a plugin determines whether certain type content associated with that plugin is allowed or disallowed. Read more about Advanced Content Filter.
注意:从 CKEditor 4.1 开始,插件的存在决定了与该插件关联的某些类型的内容是允许还是不允许。阅读有关高级内容过滤器的更多信息。
回答by Sean Kendle
To answer my own question in the comment to oleq's answer:
在对 oleq 的回答的评论中回答我自己的问题:
I have a CKEditor instance that I'm using (with jQuery) like so:
我有一个我正在使用的 CKEditor 实例(使用 jQuery),如下所示:
window.onload = function () {
$ckTarget = $(".pageContentTextBox");
if ($(".pageContentTextBox").length > 0) {
$ckEditor = $ckTarget.ckeditor({
htmlEncodeOutput: true,
removePlugins: "link"
});
}
};
I was able to successfully remove the "link" plugin that way. I am going to set up an ASP.net User Control with public properties "extraPlugins" and "removePlugins" and insert the values using the client-side yellow tags ("code nuggets") to be able to use this on multiple pages with different plugins enabled/disabled.
我能够以这种方式成功删除“链接”插件。我将使用公共属性“extraPlugins”和“removePlugins”设置一个 ASP.net 用户控件,并使用客户端黄色标签(“代码块”)插入值,以便能够在具有不同启用/禁用插件。
I hope that helps someone!
我希望能帮助别人!
回答by nikhilmeth
You can also edit the config.js. This js is loaded/included from the ckeditor.js. config.js is a default custom editor js file. You can remove buttons or your plugins from the editor by including the list of names of elements to remove. For the list of names to remove from the editor please refer to the below link: https://ckeditor.com/old/forums/CKEditor-3.x/config.js-changes-not-reflected
您还可以编辑 config.js。这个js是从ckeditor.js加载/包含的。config.js 是默认的自定义编辑器 js 文件。您可以通过包含要删除的元素名称列表来从编辑器中删除按钮或插件。要从编辑器中删除的名称列表,请参阅以下链接:https: //ckeditor.com/old/forums/CKEditor-3.x/config.js-changes-not-reflected
Include the list of buttons or plugins to remove from the editor by appending them to the config.removebuttons and include this line of code in config.js
通过将按钮或插件附加到 config.removebuttons 并在 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...';