我有一个 ckeditor 实例,我使用以下方法向其添加了一个自定义对话框:
CKEDITOR.dialog.add('quicklinkDialog', function(editor) {
return {
title: 'Quick Links',
minWidth: 400,
minHeight: 200,
contents: [
{
id: 'tab1',
label: 'Add a quick link',
elements: [
{
type: 'html',
html: '<p>This is some text and then: <a href="">Click me!</a></p>'
}]
};
});
我想在我的对话框内的链接上添加一个“点击”事件监听器。单击该链接时,内容将被插入到我的 textrea 中(对话框也将关闭)。
有人知道我该怎么做吗?提前致谢!
最佳答案
给你:
{
type: 'html',
html: '<p>This is some text and then: <a href="">Click me!</a></p>',
onLoad: function( a ) {
CKEDITOR.document.getById( this.domId ).on( 'click', function() {
var dialog = this.getDialog();
dialog.hide();
dialog._.editor.insertHtml( this.html );
}, this );
}
}
参见 API了解更多。
关于javascript - 监听 CKEditor 对话框中的点击事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17833291/