删除元素时的CKEditor事件? [英] CKEditor event when deleting an element?

查看:141
本文介绍了删除元素时的CKEditor事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在JavaScript(或CKEditor)中有一种方法来检测图像从CKEditor中移除的时间。
我需要一个与图片一起插入的字幕元素,但是一旦我删除了图片,该标题也应该删除。

Is there a way in JavaScript (or CKEditor) to detect when an image is removed from CKEditor. I need it for a caption element which is inserted together with the image, but once I delete the image, the caption should be deleted aswell.

任何帮助

推荐答案

没有像 onDelete onImageRemovedFromContent 。但有少数事件可以帮助你。

There are no special event like a onDelete or onImageRemovedFromContent. But there are few events that can help you.

editor.on('afterUndoImage', function( e ){ ... } )

afterUndoImage 仅在上激活 $ c>命令,不会在手动删除元素时触发。

But afterUndoImage fires only on Undo command, does not fires on manual deleting of elements.

editor.on('afterCommandExec', function( e ){ ... } )

CKEditor使用 execCommand (大多数),所以对许多内容的变化,所以你可以检查差异与regex例如。火灾。

CKEditor changes content with execCommand (mostly), so that fires on many content's change, so you can check the diff with regex for example.

也可以使用插件 onchange 检测内容的更改,它将 onUndo onRedo afterCommandExec 等。

Also you can use plugin onchange to detect the changes of contents, it combines onUndo, onRedo, afterCommandExec, etc.

这篇关于删除元素时的CKEditor事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆