我发现我可以挂钩onOk
有了这个:
editor.on('dialogShow', function (ev)
{
var name = ev.data.getName();
var definition = ev.data.definition;
if (name == 'image')
{
definition.onOk = function(e)
{
console.log( e );
};
}
});
太棒了,除非现在默认行为被删除,导致没有图像被添加到 CK 内容中。
正在检查CK的来源,我不想破坏默认提供的 74 行功能。
我的目标是在附加图像后通过回调简单地运行图像。
复制/粘贴、修改是保留扩展功能的唯一方法,还是还有其他方法?
maximkou 解决方案的小改进:
var oldImplementation = definition.onOk;
definition.onOk = function( e ) {
oldImplementation.apply( this, [].slice.call( arguments ) );
console.log( e );
};
This solution is ok and AFAIK it's the cleanest one.
Update:我找到了更好的解决方案 - 有dialog#ok我刚刚了解到的事件:)。因此,您不需要更改对话框的定义 - 您可以像这样绑定事件侦听器:
editor.on('dialogShow', function ( evt ) {
if ( evt.data.getName() == 'image' ) {
var listener = evt.data.on( 'ok', function() {
console.log( 'ok!' );
} );
// We need to remove that listener, to avoid duplicating it on
// next dialogShow.
evt.data.on( 'hide', function() {
listener.removeListener();
} );
}
} );
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)