Javascript 我可以在没有工具栏的情况下使用 CKEditor 吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13611386/
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
Can I use CKEditor without a toolbar?
提问by Sam Selikoff
(Possible duplicate: CKEditor - No toolbars)
(可能重复:CKEditor - 无工具栏)
I'd like to create a CKEditor instance without a toolbar. I tried defining an empty toolbar to use in the instance's config
我想创建一个没有工具栏的 CKEditor 实例。我尝试定义一个空的工具栏以在实例的配置中使用
oConfigName.toolbar = 'Custom';
oConfigName.toolbar_Custom = [];
but I get a small empty toolbar by my instance, instead of no toolbar.
但是我的实例得到了一个小的空工具栏,而不是没有工具栏。
I am using inline editingwith CKEditor4.
我正在使用CKEditor4进行内联编辑。
回答by Reinmar
Wow :) This is something that we haven't thought of while implementing toolbar. But I've just checked that you can remove toolbar plugin, because it isn't required by any other plugin.
哇 :) 这是我们在实现工具栏时没有想到的。但是我刚刚检查了您是否可以删除工具栏插件,因为任何其他插件都不需要它。
So build your ownCKEditor package without toolbar or use removePluginsconfiguration - e.g.:
因此,在没有工具栏或使用removePlugins配置的情况下构建您自己的CKEditor 包- 例如:
var editor = CKEDITOR.inline( 'editable', {
removePlugins: 'toolbar'
} );
Update:In CKEditor 4.1 the Advanced Content Filterwas introduced. In its automatic modeit is configured by buttons which are loaded to toolbar. Without toolbarplugin ACF is not configured, so one need to do this on his own:
更新:在 CKEditor 4.1中引入了高级内容过滤器。在自动模式下,它由加载到工具栏的按钮配置。没有toolbar插件 ACF 没有配置,所以需要自己做这个:
var editor = CKEDITOR.inline( 'editable', {
removePlugins: 'toolbar',
allowedContent: 'p h1 h2 strong em; a[!href]; img[!src,width,height];'
} );
回答by Arseniy
I've turned off everything except italics, bold and underlined with this config:
我已经关闭了除斜体、粗体和下划线以外的所有配置:
CKEDITOR.editorConfig = function( config ) {
config.autoParagraph = false;
config.toolbarGroups = [
{ name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
];
config.removeButtons = 'Strike,Subscript,Superscript,RemoveFormat';
};
回答by Maniruzzaman Akash
There are two ways I have seen:
我见过的有两种方式:
1) Using the removePluginsoption and just remove the toolbar:
1)使用该removePlugins选项并删除工具栏:
CKEDITOR.inline( 'textarea', {
removePlugins: 'toolbar',
allowedContent: 'p h1 h2 strong em; a[!href]; img[!src,width,height];'
} );
2) Using CSS - Not the standard approach: (little tricky)
2)使用 CSS - 不是标准方法:(有点棘手)
Just make css to display:none the toolbar, like
只需让 css 显示:none 工具栏,例如
.cke_inner {
display: none;
}
In version 4.13, you can hide the entire top bar containing the toolbar:
在 4.13 版本中,您可以隐藏包含工具栏的整个顶部栏:
.cke_inner .cke_top {
display: none;
}
or hide only the toolbar but keep a strip of color at the top:
或者只隐藏工具栏但在顶部保留一条颜色:
.cke_inner .cke_top .cke_toolbox {
display: none;
}
Hope it will help someone.
希望它会帮助某人。
回答by edCoder
Add this this line in to config.jsfile
将此行添加到config.js文件中
config.removePlugins= 'toolbar'
回答by Andrej
I have added new function into my project for hide/show of the toolbar.
我在我的项目中添加了新功能,用于隐藏/显示工具栏。
function onClickToolbarButton() {
var bar = document.getElementById("cke_1_top");
if(bar.style.display == "none"){
bar.style.display = "block";
}else{
bar.style.display = "none";
}
//resize web page
//onresize();
}
Call this function every time, if you want hide/show toolbar.
如果你想隐藏/显示工具栏,每次都调用这个函数。
回答by c-toesca
In CKEditor 4.9.2:
在 CKEditor 4.9.2 中:
When you instanciate the editor, set toolbar option:
当您实例化编辑器时,设置工具栏选项:
CKEDITOR.replace( 'editor1', {
...
toolbar: []
});

