ckeditor时间戳自定义插件示例无法正常工作

时间:2017-06-22 20:46:52

标签: javascript plugins ckeditor

我正在尝试使用ckeditor示例自定义插件,但到目前为止,我什么都没有:没有控制台错误,但也没有插件。

这是我正在遵循的例子:

由于我已经逐字复制了他们的代码,我怀疑这个问题与我下面的ckeditor配置有关。

我的插件目录结构(从github复制的所有文件):

$ tree public/javascripts/ckeditor/plugins/timestamp
public/javascripts/ckeditor/plugins/timestamp
├── icons
│   └── timestamp.png
├── plugin.js
└── samples
    └── timestamp.html

我的ckeditor public / javascripts / ckeditor / config.js:

/**
 * @license Copyright (c) 2003-2014, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or http://ckeditor.com/license
 */

CKEDITOR.editorConfig = function( config ) {
    // Define changes to default configuration here.
    // For complete reference see:
    // http://docs.ckeditor.com/#!/api/CKEDITOR.config

    // The toolbar groups arrangement, optimized for two toolbar rows.
    config.toolbarGroups = [
        { name: 'styles', groups: [ 'styles' ] },
        { name: 'paragraph',   groups: [ 'list', 'indent', 'blocks', 'align', 'bidi' ] },
        { name: 'editing',     groups: [ 'find', 'selection', 'spellchecker' ] },
        { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
        { name: 'clipboard',   groups: [ 'clipboard', 'undo' ] },
        { name: 'document',    groups: [ 'mode', 'document', 'doctools' ] },
        { name: 'others' },
        { name: 'forms' },
        { name: 'tools' }
    ];

    // Remove some buttons provided by the standard plugins, which are
    // not needed in the Standard(s) toolbar.
    config.removeButtons = 'Underline,Styles,Strike,Image,Outdent,Indent,Blockquote,Cut,Copy,Paste,PasteFromWord,Undo,Redo';

    // Set the most common block elements.
    config.format_tags = 'p;h1;h2;h3;h4';

    // Simplify the dialog windows.
    config.removeDialogTabs = 'image:advanced;link:advanced';

    // Whether to escape basic HTML entities in the document, including: 
    // (nbsp,gt,lt,amp)
    config.basicEntities = false;
    config.entities_additional = 'lt,gt,amp,quot'
    config.entities_latin = false;
    config.entities_greek = false; 
    config.disableNativeSpellChecker = false;
    config.removePlugins = 'wsc,scayt';
    config.extraPlugins = 'timestamp';
    config.scayt_autoStartup = false;
    config.height = 1000;
};

这就是我所看到的。没有javascript错误:/

enter image description here

1 个答案:

答案 0 :(得分:1)

该插件创建一个工具栏按钮,放在“插入”工具栏组中:

editor.ui.addButton( 'Timestamp', {
    label: 'Insert Timestamp',
    command: 'insertTimestamp',
    toolbar: 'insert'
});

由于您的配置中没有这样的工具栏组,因此不会显示它。