2013-08-25 84 views
3

我有一个标准安装(如样品):如何配置CKEditor-4内联编辑器?

<meta charset="utf-8"></meta> 
<script src="../ckeditor.js"></script> 

随着HTML内容与许多<div contenteditable="true">块。我需要通过本地或外部configTypeX.js文件配置每个编辑,

<script> 
    CKEDITOR.on('instanceCreated', function(event) { 
    var editor = event.editor, element = editor.element; 
     if (element.is('h1', 'h2', 'h3')) { 
     editor.on('configLoaded', function() { 
      editor.config.toolbar = [ 
       [ 'Source', '-', 'Bold', 'Italic' ] 
      ]; // BUG: about "Source"?? NOT AT INTERFACE! 
     }); 
     } else { 
      // WHERE PUT THIS ITEM? 
    customConfig: 'configType2.js'; 
     } 
    }); 
    </script> 

所以,我的问题是

  1. 如何做到在这种情况下一个customConfig
  2. 哪里的“最好的完整文档”,关于配置菜单(editor.config.toolbar)没有在线配置工具,在那里我可以理解如何使用正确的名称来放置和删除菜单itens? Here没有关于如何解决完整安装中的“源代码”错误。

我这样做,

git clone git://github.com/ckeditor/ckeditor-releases.git 
cd ckeditor-releases 
cp samples/inlineall.html samples/myinline.html 

和编辑samples/myinline.html与上面的代码。

回答

7
  1. 用于在线编辑的标准Source按钮是隐藏的,因为它是不可能具有比其它wysiwyg不同的模式。因此,对于那些编辑器来说,创建了新的插件 - sourcedialog,但默认情况下它不包含在任何版本中。您可以使用此插件使用online CKBuilder或使用presetsall参数之一来编译此编辑器。例如:./build.sh full all。还请记住加载sourcedialog插件(使用config.extraPlugins = 'sourcedialog')。

  2. 如果你想自由配置内联编辑器,那么你应该看看inlinebycode示例。首先,你需要在编辑元素禁用自动编辑初始化,然后调用CKEDITOR.inline()你想成为编辑元素:

    // We need to turn off the automatic editor creation first. 
    CKEDITOR.disableAutoInline = true; 
    
    CKEDITOR.inline('editable1', { 
        customConfig: 'editableConfig.js' 
    }); 
    CKEDITOR.inline('editable1', { 
        toolbar: [ ... ] 
    }); 
    
+0

非常感谢,你是CKEditor的人!我和测试,并会在稍后回来。 –