Plugin
CKEditor
richcombo

CKeditor: Richcomboプラグイン

More than 3 years have passed since last update.

例:見出しプラグインの作成

Screen Shot 2016-04-03 at 00.07.04.png

コード:

CKEDITOR.plugins.add(PLUGIN_NAME,

{
requires : ['richcombo'],
init : function( editor )
{
var header_strings = [];
header_strings.push(['0', 'なし', 'なし']);
for(var i=2; i<=5 ; i++){
header_strings.push(['h'+i, '<h'+i+'>見出し'+i+'</h'+i+'>', '<h'+i+'>見出し'+i+'</h'+i+'>']);
}

editor.ui.addRichCombo('header',
{
label: '見出し',
title: '見出し',
voiceLabel: '見出し',
className: 'cke_format',
multiSelect:false,
panel:
{
css: [ editor.config.contentsCss, CKEDITOR.skin.getPath('editor') ],
voiceLabel: editor.lang.panelVoiceLabel
},

init: function()
{
this.startGroup( "見出し" );
for (var i in header_strings)
{
this.add(header_strings[i][0], header_strings[i][1], header_strings[i][2]);
}
},

onClick: function( value )
{
// your code: process data
editor.focus();
editor.fire( 'saveSnapshot' );
// your code: save data
editor.fire( 'saveSnapshot' );
}
});
}
});