2017-07-25 137 views
0

使用最新的CKEditor,我試圖從文檔中添加他們的示例插件「timestamp」。我從他們提供的鏈接下載了Github的所有代碼,並將所有內容放在適當的位置。CKEditor:不會出現插件按鈕

文檔:http://docs.ckeditor.com/#!/guide/plugin_sdk_sample GitHub的鏈接:https://github.com/ckeditor/ckeditor-docs-samples/tree/master/tutorial-timestamp

ckeditor/plugins/timestamp/plugin.js 
ckeditor/plugins/timestamp/icons/timestamp.png 
ckeditor/plugins/timestamp/samples/timestamp.html 

在config.js文件,我把這個行:

config.extraPlugins = 'timestamp'; 

我已經關閉了瀏覽器,使用其他我在幾個月內沒有使用過的瀏覽器等等,不管如何,按鈕圖標從不出現。

我已經使用了這個,並在StackOverflow上閱讀了幾個Q.許多人談論過錯誤的圖標或缺失的圖標或其他,但這一次,它就在那裏,而且完全來自Github。

一旦這個工作,我可以嘗試從一個較舊的CKEditor v4.0安裝中移除一些插件。謝謝!

回答

0

您還需要將插件添加到ckeditor.replace中。這是一個簡單的例子。

<!DOCTYPE html> 
<html> 
    <head> 
     <meta charset="utf-8"> 
     <title>A Simple Page with CKEditor</title> 
     <!-- Make sure the path to CKEditor is correct. --> 
     <script src="ckeditor.js"></script> 
    </head> 
    <body> 
     <form> 
      <textarea name="editor1" id="editor1" rows="10" cols="80"> 
       This is my textarea to be replaced with CKEditor. 
      </textarea> 
      <script> 
       // Replace the <textarea id="editor1"> with a CKEditor 
       // instance, using default configuration. 
       CKEDITOR.replace('editor1', { 
        extraPlugins: 'timestamp' 
       } ); 
      </script> 
     </form> 
    </body> 
</html> 

config.js文件。

CKEDITOR.editorConfig = function(config) { 
    // Define changes to default configuration here. For example: 
    // config.language = 'fr'; 
    // config.uiColor = '#AADC6E'; 

    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', 'timestamp'] }, 
     { 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.extraPlugins = 'timestamp'; 
    config.allowedContent = true; 
}; 
+0

謝謝...但可悲的是,你提出的改變也沒有效果。工具欄根本沒有改變你發佈的配置,所以我真的想知道config.js文件是否被讀取。我已打開Chrome開發工具並且控制檯中沒有出現錯誤。 – RobG

+0

也許嘗試再次下載ckeditor。我的配置工作正常http://i.imgur.com/RF0bcfG.png。你肯定在服務器上運行它? – David

+0

下載它新鮮,移動的變化...相同的結果。 config.js肯定被忽略。我知道是因爲我在CKEDITOR.replace代碼中指定了寬度/高度,當我將它移動到配置文件時,它沒有任何作用,並且大小恢復爲「stock」。我感謝您的幫助;看起來像我有更大的問題。 – RobG