对于链接对话框,我只向用户展示了一个最小的对话框:
config.js
文件中的代码:
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 are interested in (the 'link' dialog)
if (dialogName == 'link') {
// Get a reference to the 'Link Info' tab.
var infoTab = dialogDefinition.getContents('info');
// Remove unnecessary widgets from the 'Link Info' tab.
infoTab.remove('linkType');
infoTab.remove('protocol');
infoTab.remove('browse');
// Get a reference to the "Target" tab and set default to '_blank'
var targetTab = dialogDefinition.getContents('target');
var targetField = targetTab.get('linkTargetType');
targetField['default'] = '_blank';
// focus URL field
// targetTab.focus(); // NOT working, function does not exist
}
}
有人能告诉我如何关注输入字段吗?
PS:我也尝试使用dialogDefinition.onShow = function () { }
但没有成功。
答案 0 :(得分:1)
在对话框定义中覆盖onFocus
方法:
if (dialogName == 'link') {
....
dialogDefinition.onFocus = function() {
this.getContentElement( 'info', 'url' ).focus();
}
}