简体   繁体   English

CKEditor自定义工具栏配置

[英]CKEditor Custom Toolbar Configuration

I've looked through several questions in this forum and the CKEditor site about this topic, but nothing's helped so far. 我已经浏览了该论坛和CKEditor网站上有关此主题的几个问题,但到目前为止没有任何帮助。 First of all, I'm running CKEditor 4.3.2 on a SharePoint 2010 site, using inline editors within a jQuery UI modal dialog. 首先,我在SharePoint 2010网站上运行CKEditor 4.3.2,使用jQuery UI模式对话框中的内联编辑器。 Adding CKEditor to the dialog was painless, but I can't say the same for setting up a slimmer toolbar. 将CKEditor添加到对话框很轻松,但是对于设置更苗条的工具栏我不能说同样的话。 Here's what I've done so far: 到目前为止,这是我所做的:

  1. slimConfig.js slimConfig.js

     CKEDITOR.editorConfig = function(config) { config.toolbar = [ {name: "basicstyles", items: ["Bold", "Italic", "Underline", "Strike", "Subscript", "Superscript", "-", "RemoveFormat"]}, {name: "paragraph", items: ["NumberedList", "BulletedList"]} ]; } 
  2. Source JavaScript 源JavaScript

     setToolbar("notes"); setToolbar("access"); //. . .[several other fields]. . . function setToolbar(divName) { CKEDITOR.replace(divName, {customConfig: "/customConfigs/slimConfig.js"}); } 

Additionally, I've set up the target fields as divs using contenteditable set to true, like this: 另外,我使用contenteditable设置为true将目标字段设置为div,如下所示:

<div id="notes" contenteditable="true"></div>

The script seems to run well until it hits an exception on ckeditor.js line 308, where the error text is "The editor instance is already attached to the provided element." 该脚本似乎运行良好,直到它在ckeditor.js第308行遇到异常为止,错误文本为“编辑器实例已附加到所提供的元素上”。 After a few more steps, it returns to the same area on line 308, at which point I get a terminal exception with the message, "Exception thrown and not caught." 再经过几步后,它返回到第308行的同一区域,这时我收到一条终端异常,并显示消息“引发了异常并且未捕获”。

I believe I have everything set up properly right now, but don't know what to make of this error. 我相信我现在已经正确设置了所有内容,但是不知道该怎么做。 Does anyone have experience with getting customized toolbars set up? 有没有人有过设置自定义工具栏的经验?

By default CKEditor replaces all elements of contenteditable="true" with inline editors. 默认情况下,CKEditor用内联编辑器替换contenteditable="true"所有元素。 So when you try to replace it once again, it will throw an error because it doesn't make sense. 因此,当您尝试再次更换它时,它将抛出错误,因为它没有意义。

If you want to take a full control over your editors, set CKEDITOR.disableAutoInline to false and take care of all instances manually. 如果要完全控制编辑器,请将CKEDITOR.disableAutoInline设置为false并手动处理所有实例。 Of course, you can always find your instance in CKEDITOR.instances object and call editor.destroy() if you want to. 当然,您始终可以在CKEDITOR.instances对象中找到您的实例,并根据需要调用editor.destroy()

See http://docs.ckeditor.com/#!/guide/dev_inline 参见http://docs.ckeditor.com/#!/guide/dev_inline

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM