因此,我添加了这个插件,该代码在我的CKeditor工具栏上提供了一个下拉菜单,该菜单包含我点击时应用的所有样式。见代码:如何使用CKEditor自定义下拉插件添加样式
CKEDITOR.plugins.add('tokens',
{
requires : ['richcombo'], //, 'styles' ],
init : function(editor)
{
var config = editor.config,
lang = editor.lang.format;
// Gets the list of tags from the settings.
var tags = []; //new Array();
//this.add('value', 'drop_text', 'drop_label');
tags[0]=["[contact_name]", "Name", "Name"];
tags[1]=["[contact_email]", "email", "email"];
tags[2]=["[contact_user_name]", "User name", "User name"];
// Create style objects for all defined styles.
editor.ui.addRichCombo('tokens',
{
label : "Insert tokens",
title :"Insert tokens",
voiceLabel : "Insert tokens",
className : 'cke_format',
multiSelect : false,
panel :
{
css : [ config.contentsCss, CKEDITOR.getUrl(editor.skinPath + 'editor.css') ],
voiceLabel : lang.panelVoiceLabel
},
init : function()
{
this.startGroup("Tokens");
//this.add('value', 'drop_text', 'drop_label');
for (var this_tag in tags){
this.add(tags[this_tag][0], tags[this_tag][1], tags[this_tag][2]);
}
},
onClick : function(value)
{
editor.focus();
editor.fire('saveSnapshot');
editor.insertHtml(value);
editor.fire('saveSnapshot');
}
});
}
});
那么这个代码不只是插入无论是在标签[“[CONTACT_NAME”]所以,当你点击“名称”,在下拉菜单中,它只是降低[CONTACT_NAME]文本编辑。我想知道如何让每个标记都是一个特定的函数,它将CSS添加到文本编辑器中选定的任何内容中。例如,有一个名为“红色字体”的函数,无论它存在什么,它都会变成红色。
为你的插件的任何新的发展? – Charlesliam 2014-12-22 17:47:33
你有没有想到这一点 - 需要使我的更宽和风格的字体? – JK36 2015-10-26 21:08:43