2013-08-25 79 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的人!我和測試,並會在稍後回來。 –