我在ckeditor的图像上下文菜单中添加了链接,使用以下代码:
CKEditor - Add Context Menu Item to Images
当用户点击图像时,如何获取有关图像的信息?
例如图像的id或路径。以便处理所选的图像。
$('body').on('contextmenu','img',function(){
var imgid = $(this).attr('id');
alert(imgid);
})
您可以使用编辑器的函数getSelection()来了解上下文菜单中所点击的元素:
exec: function (editor) {
var selection = editor.getSelection();
var selectedElement = selection.getStartElement();
// Use it as jquery object to get id or more ...
$(selectedElement.$);
}