Is there open “Insert/Edit image” dialog event in Tinymce?

大城市里の小女人 提交于 2019-12-20 05:42:21

问题


I need to get to know when the dialog has already been opened. But I didn't find any decent way for this. The only thing I found in the documentation is editor.on() but it doesn't work with the mceImagecommand and nothing is said about mceImage in the docs. And it supposed to fire before the dialog is shown. All that comes to my mind is to attach the 'click' event on the "Image" button and wait for the dialog through the timer but it wouldn't be a very decent solution. Any better ideas?


回答1:


TinyMCE does not currently fire an event when opening the image dialog. If you wanted to make it do so you can modify the image plugin to include the command when the menu option or toolbar button is triggered. For example you can do this for the menu option:

editor.addMenuItem('image', {
  icon: 'image',
  text: 'Image',
  onclick: Dialog(editor).open,
  context: 'insert',
  cmd: 'mceImage',
  prependToContext: true
}); 

Note the cmd option added to that list. Its not there in the editor code as delivered but you can add it yourself and get that command to be triggered. You can do the same for toolbar buttons by adding the cmd option as well.



来源:https://stackoverflow.com/questions/51927800/is-there-open-insert-edit-image-dialog-event-in-tinymce

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!