ckeditor插件strinsert:初始化后如何设置自定义字符串
我正试图通过使用插件和如上所述,将固定占位符实现到ckeditor 不幸的是,我无法动态地改变插件ckeditor插件strinsert:初始化后如何设置自定义字符串,ckeditor,Ckeditor,我正试图通过使用插件和如上所述,将固定占位符实现到ckeditor 不幸的是,我无法动态地改变插件strinsert的字符串 config.js中的这些行应该可以工作,但它不能: CKEDITOR.editorConfig = function( config ) { config.strinsert_strings = [ ['[[foo]]'] ]; }; 也许这个插件不支持在初始化后改变字符串数组 我如何才能在不同的ckeditor实例中为用户提供不同的占
strinsert
的字符串
config.js
中的这些行应该可以工作,但它不能:
CKEDITOR.editorConfig = function( config ) {
config.strinsert_strings = [
['[[foo]]']
];
};
也许这个插件不支持在初始化后改变字符串数组
我如何才能在不同的ckeditor实例中为用户提供不同的占位符,而无需将strinsert插件克隆x次
注意:我正在使用它们的最新版本。建议使用占位符rplugin。只需编辑文件ckedit/plugins/placeholder/dialogs/placeholder.js
。将元素类型更改为选择
,并将所需值添加到项
,如以下示例所示:
contents: [
{
id: 'info',
label: generalLabel,
title: generalLabel,
elements: [
// Dialog window UI elements.
{
id: 'name',
type: 'select',
style: 'width: 100%;',
label: lang.name,
items:[
['ONE'],
['TWO'],
['THREE']
],
// SNIP...
您可以使用dialogDefinition
event动态设置自定义占位符。
我是这样做的(html属性数据占位符
以占位符1的形式指定有效占位符,要显示的不同文本=占位符2,另一个文本=占位符3”
CKEDITOR.on('dialogDefinition',函数(e){
//检查定义是否来自您感兴趣的对话框窗口(“链接”对话框窗口)。
如果(e.data.name==‘占位符’){
var$textarea=$(e.editor.element.$),
占位符=$textarea.attr(“数据占位符”),
tab,ff,i,a;
//占位符=['Placehold1'],['Text to show','PlaceholderValue'];
if(占位符和占位符.length){
//将占位符从desc1=val1、desc2=val2、val3等格式转换为数组(数组(desc,val))
占位符=占位符。拆分(“,”);
//确保占位符是包含2个成员的数组的数组
对于(i=0;i
对于strinsert,我通过编辑它的plugin.js,去掉字符串声明并替换为:
var strings = editor.config.strinsert_strings;
然后在创建编辑器之前,在html中:
CKEDITOR.config.strinsert_strings = [];
CKEDITOR.config.strinsert_strings.push(['myvalue1', 'myname1', 'mylabel1']);
CKEDITOR.config.strinsert_strings.push(['myvalue2', 'myname2', 'mylabel2']);
CKEDITOR.replace('mytextarea');
你找到解决方案了吗?我不再需要这个插件了。它也只适用于占位符
CKEDITOR.config.strinsert_strings = [];
CKEDITOR.config.strinsert_strings.push(['myvalue1', 'myname1', 'mylabel1']);
CKEDITOR.config.strinsert_strings.push(['myvalue2', 'myname2', 'mylabel2']);
CKEDITOR.replace('mytextarea');