Javascript CKEditor工具栏配置不工作
我最近开始使用CKEditor,但是工具栏上有一些我们不会使用的功能 我尝试从联机工具栏配置复制代码,但工具栏没有更改 我的config.js文件如下所示:Javascript CKEditor工具栏配置不工作,javascript,ckeditor,ckfinder,Javascript,Ckeditor,Ckfinder,我最近开始使用CKEditor,但是工具栏上有一些我们不会使用的功能 我尝试从联机工具栏配置复制代码,但工具栏没有更改 我的config.js文件如下所示: CKEDITOR.editorConfig = function( config ) { config.toolbarGroups = [ { name: 'document', groups: [ 'mode', 'document', 'doctools' ] }, { name: 'clipbo
CKEDITOR.editorConfig = function( config ) {
config.toolbarGroups = [
{ name: 'document', groups: [ 'mode', 'document', 'doctools' ] },
{ name: 'clipboard', groups: [ 'clipboard', 'undo' ] },
{ name: 'editing', groups: [ 'find', 'selection', 'spellchecker', 'editing' ] },
{ name: 'forms', groups: [ 'forms' ] },
'/',
{ name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
{ name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi', 'paragraph' ] },
{ name: 'links', groups: [ 'links' ] },
{ name: 'insert', groups: [ 'insert' ] },
'/',
{ name: 'styles', groups: [ 'styles' ] },
{ name: 'colors', groups: [ 'colors' ] },
{ name: 'tools', groups: [ 'tools' ] },
{ name: 'others', groups: [ 'others' ] },
{ name: 'about', groups: [ 'about' ] }
];
config.removeButtons = 'Save,NewPage,Preview,Print,Replace,Form,Checkbox,Radio,TextField,Textarea,Select,Button,ImageButton,HiddenField,Superscript,Subscript,Language,Anchor,Flash,PageBreak,About';
};
CKEDITOR.editorConfig = function( config ) {
config.toolbar = [
{ name: 'clipboard', groups: [ 'clipboard', 'undo' ], items: [ 'Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo' ] }
];
// Toolbar groups configuration.
config.toolbarGroups = [
{ name: 'clipboard', groups: [ 'clipboard', 'undo' ] }
];
};
这是直接从配置工具复制的。
在完成上述操作后,我尝试将代码粘贴到初始化函数中,如下所示:
jQuery(function()
{
var editor = CKEDITOR.replace( 'message',
{
extraPlugins : 'stylesheetparser',
extraPlugins : 'filebrowser',
extraPlugins : 'popup',
//contentsCss : '<?= base_url(); ?>css/layout.css',
config.toolbarGroups = [
{ name: 'document', groups: [ 'mode', 'document', 'doctools' ] },
{ name: 'clipboard', groups: [ 'clipboard', 'undo' ] },
{ name: 'editing', groups: [ 'find', 'selection', 'spellchecker', 'editing' ] },
{ name: 'forms', groups: [ 'forms' ] },
'/',
{ name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
{ name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi', 'paragraph' ] },
{ name: 'links', groups: [ 'links' ] },
{ name: 'insert', groups: [ 'insert' ] },
'/',
{ name: 'styles', groups: [ 'styles' ] },
{ name: 'colors', groups: [ 'colors' ] },
{ name: 'tools', groups: [ 'tools' ] },
{ name: 'others', groups: [ 'others' ] },
{ name: 'about', groups: [ 'about' ] }
],
config.removeButtons = 'Save,NewPage,Preview,Print,Replace,Form,Checkbox,Radio,TextField,Textarea,Select,Button,ImageButton,HiddenField,Superscript,Subscript,Language,Anchor,Flash,PageBreak,About'
});
CKFinder.setupCKEditor(editor);
});
以上这些都没有改变工具栏中的任何内容,所以我不确定我是否忽略了某些内容
任何帮助都将不胜感激。请确保正确定义配置-查看文章中的一些代码示例。您正在犯的一些错误:
- 混淆了
和config.optionName
optionName
- 多次声明
您应该将所有额外的插件放在一个声明中:extraPlugins
config.extraPlugins='myplugin,anotherplugin'代码>
包括:
变量组=[
{name:'document',组:['mode','document','doctools']},
{name:'clipboard',组:['clipboard','undo']},
{name:'编辑',组:['查找','选择','拼写检查','编辑']},
{name:'forms',group:['forms']},
'/',
{name:'basicstyles',组:['basicstyles','cleanup']},
{name:'段落',组:['列表','缩进','块','对齐','比迪','段落']},
{name:'links',group:['links']},
{name:'insert',组:['insert']},
'/',
{name:'styles',group:['styles']},
{name:'colors',group:['colors']},
{name:'tools',组:['tools']},
{name:'others',组:['others']},
{name:'about',groups:['about']}
];
var initEditor=函数(){
返回CKEDITOR.replace('user\u message'{
工具栏:“基本”,
uiColor:“#9AB8F3”,
小组,,
});
}
initEditor();
演示
我的CKEditor config.js更改没有反映在我的工具栏中,直到我将匹配的路径与示例的路径匹配。示例:工作样本具有以下路径:
ckeditor\samples\index.html
ckeditor\config.js
因此,我使用ckeditor制作了我的工作网页应用程序:
rootwebfolder/ckeditor/config.js
rootwebfolder/mywebpage.php
以前,我在与root相同的级别上使用了ckeditor,但我将它移到了root中。
当然,我必须更改相对路径语句,现在是这样[并显示使div能够显示CKEditor工具栏的其他代码]:
echo "<script type='text/javascript'> window.CKEDITOR_BASEPATH ='mydomain/mainfolder/rootwebfolder/ckeditor/';</script>";
echo "<script type='text/javascript' src='mydomain/mainfolder/rootwebfolder/ckeditor/ckeditor.js'></script>";
echo "<script type='text/javascript' src='mydomain/mainfolder/rootwebfolder/ckeditor/config.js'></script>";
echo "<div id = 'divname' name = 'divname' class = 'ckeditor' style='visibility:hidden; height:415px'></div>";
echo "<script type='text/javascript'>CKEDITOR.replace('divname');</script>";
echo“window.CKEDITOR_BASEPATH='mydomain/mainfolder/rootwebfolder/CKEDITOR/';”;
回声“;
回声“;
回声“;
echo“CKEDITOR.replace('divname');”;
我希望这对别人有帮助 谢谢你的提示,我更改了上面提到的插件,使代码变得更短…我们下载了臃肿的文件,因为不是所有的实例都有相同的功能,所以目前我们只是想让它工作。为了让它从源代码开始工作,我把代码放在实例创建者而不是配置中,我认为邮件问题在实例中,它必须是
toolbarGroups:[
而不是toolbarGroups=[
echo "<script type='text/javascript'> window.CKEDITOR_BASEPATH ='mydomain/mainfolder/rootwebfolder/ckeditor/';</script>";
echo "<script type='text/javascript' src='mydomain/mainfolder/rootwebfolder/ckeditor/ckeditor.js'></script>";
echo "<script type='text/javascript' src='mydomain/mainfolder/rootwebfolder/ckeditor/config.js'></script>";
echo "<div id = 'divname' name = 'divname' class = 'ckeditor' style='visibility:hidden; height:415px'></div>";
echo "<script type='text/javascript'>CKEDITOR.replace('divname');</script>";