自定义 richcombo 在未聚焦或在 ckeditor 的文本区域内单击时丢失所选项目
Custom richcombo loses selected item when unfocused or click inside the text area of ckeditor
这是我自定义插件的代码。
CKEDITOR.plugins.add('priority', {
requires: ['richcombo'],
init: function(editor) {
var tags = [];
// ajax call to load the the items
editor.ui.addRichCombo('priority', {
label: "Select Priority",
title: "Select Priority",
voiceLabel: "Select Priority",
className: 'cke_format',
panel: {
css: [editor.config.contentsCss, CKEDITOR.skin.getPath("editor")],
voiceLabel: editor.lang.panelVoiceLabel,
multiSelect: false,
},
init: function() {
this.startGroup("Priority Group1");
//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();
this.setValue(value);
editor.fire('saveSnapshot');
}
});
}
});
意外行为是当我 select 一个元素时,然后在文本区域内单击以写入组合项 select 取消,并显示默认值。
我需要保持显示 selected 项目。
我在 中遇到了同样的问题,但解决方案没有解决
我打开了源文件 ckeditor.js,然后我使用 http://unminify.com/
对其进行了 unminify
调试后我发现调用setValue函数并传递空字符串给它,这导致在运行时间内每次选择后丢失选择的项目。
我停了这条线,问题也解决了,不知道停了这条线会不会影响其他功能; 但我认为没有人需要插件在没有他的意愿的情况下重置控件
我检查了我所有的需求,它不影响他们。
所有你需要在停止在行上方后保持选择,如下处理onlick事件
// add the menu to the editor
editor.ui.addRichCombo('myCombo',
{
label: "DefaultText",
title: "Title",
multiSelect: false,
panel: { css: [CKEDITOR.skin.getPath("editor")].concat(editor.config.contentsCss) },
init: function () {
//add items of the combo
for (var i in strings) {
this.add(strings[i][0], strings[i][1], strings[i][2]);
}
},
onClick: function (value) {
this.setValue(value, this._.items[value]);
// add your code
}
});
这是我自定义插件的代码。
CKEDITOR.plugins.add('priority', {
requires: ['richcombo'],
init: function(editor) {
var tags = [];
// ajax call to load the the items
editor.ui.addRichCombo('priority', {
label: "Select Priority",
title: "Select Priority",
voiceLabel: "Select Priority",
className: 'cke_format',
panel: {
css: [editor.config.contentsCss, CKEDITOR.skin.getPath("editor")],
voiceLabel: editor.lang.panelVoiceLabel,
multiSelect: false,
},
init: function() {
this.startGroup("Priority Group1");
//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();
this.setValue(value);
editor.fire('saveSnapshot');
}
});
}
});
意外行为是当我 select 一个元素时,然后在文本区域内单击以写入组合项 select 取消,并显示默认值。 我需要保持显示 selected 项目。
我在
我打开了源文件 ckeditor.js,然后我使用 http://unminify.com/
对其进行了 unminify调试后我发现调用setValue函数并传递空字符串给它,这导致在运行时间内每次选择后丢失选择的项目。
我停了这条线,问题也解决了,不知道停了这条线会不会影响其他功能; 但我认为没有人需要插件在没有他的意愿的情况下重置控件 我检查了我所有的需求,它不影响他们。
所有你需要在停止在行上方后保持选择,如下处理onlick事件
// add the menu to the editor
editor.ui.addRichCombo('myCombo',
{
label: "DefaultText",
title: "Title",
multiSelect: false,
panel: { css: [CKEDITOR.skin.getPath("editor")].concat(editor.config.contentsCss) },
init: function () {
//add items of the combo
for (var i in strings) {
this.add(strings[i][0], strings[i][1], strings[i][2]);
}
},
onClick: function (value) {
this.setValue(value, this._.items[value]);
// add your code
}
});