嗨,我正试图对CKEDITOR 3.6.2 的实现进行一些更改
通过删除链接对话框的目标选项卡中显示的链接目标类型下拉列表中除2个选项外的所有选项。
我试图使用API实现这一点,但我在这一行X=S.lang.dir的dialog()方法中的缩小核心ckeditor.js文件中遇到错误;其中S是编辑器。
在执行CKEDITOR.dialog(editor,'link')时,编辑器实例的.lang属性是未定义的,在查看调试"editor"对象时,我在任何地方都看不到lang对象,所以我不确定为什么缺少它?我没有研究我们最初的实现,但据我所知,我们只添加了2个插件,没有更改ckeditor核心。
这是我的代码:
for (var i in CKEDITOR.instances) {
var editor = CKEDITOR.instances[i];
var dialogObj = CKEDITOR.dialog(editor, 'link');
var linkDialogTargetField = dialogObj.getContentElement('target', 'linkTargetType');
// API didn't seem to have a more efficient approach than clearing all and re-adding the one we want
linkDialogTargetField.clear();
linkDialogTargetField.add('notSet', '<not set>');
linkDialogTargetField.add('_blank', 'New Window (_blank)');
}
我已经设法在没有正确使用API的情况下通过以下操作进行了更改:
CKEDITOR.on('dialogDefinition', function (ev) {
// Take the dialog name and its definition from the event
// data.
var dialogName = ev.data.name;
var dialogDefinition = ev.data.definition;
// Check if the definition is from the dialog we're
// interested on (the "Link" dialog).
if (dialogName == 'link') {
// Get a reference to the "Link target" tab.
var targetTab = dialogDefinition.getContents('target');
var targetField = targetTab.get('linkTargetType');
// removing everything except the 1st (none set) & 3rd (new window) options from the dropdown
targetField['items'].splice(1, 2);
targetField['items'].splice(2, 3); // the array is reduced by splice, so we have to splice from [2] onwards not from [4]
}
});
但我不喜欢这种方法,有人有什么想法吗?或使用API实现相同结果的其他方法?
使用第二种方法并覆盖下拉项,而不是拼接。