处理 ContentEditable 区域中的图像点击事件
我正在尝试自定义 jwysiwyg jquery RTE。我想构建一个图像属性编辑器,以便一旦将图像插入可编辑区域,用户就会选择它,然后会出现一个模式窗口或属性面板,允许用户编辑宽度/高度等。类似于gmails图像插入用户界面。
问题是我无法找到如何处理必要的图像点击事件。有人知道一些示例代码或一些我可以从哪里开始的信息吗?
I am trying to customize jwysiwyg jquery RTE. I would like to build an image attributes editor so that once an image is inserted into the editable region, the user would select it and then a modal window or properties panel would appear allowing the user to edit the width/height etc. Analogous to gmails image insert UI.
The problem is I am having trouble finding out how to handle the necessary image click event. Anyone know some example code or some info for where I can start?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我刚刚开始做类似的事情。使用 jQuery 的 delegate() 方法,我让它像这样工作:
委托方法的一个很酷的事情是,它将将此事件处理程序附加到正文中的任何 img 标签,无论是现在还是将来。因此,即使是在编辑过程中插入的图像也会被连接起来。
祝你好运。
标记
I am just starting on something similar. Using jQuery's delegate() method, I got it to work like this:
The cool thing about the delegate method is that it will attach this event handler to any img tag in the body, present or future. So even images inserted as part of the editing process with get wired up.
Good luck.
Mark
我在 iOS 10 上的解决方案是向需要可点击的 img 元素添加 contenteditable="false" 属性。
否则 safari 会认为您的意图只是在图像之前/之后移动插入符号(如果它位于 contenteditable 元素内)。
My solution on iOS 10 is to add a contenteditable="false" attribute to the img element which needs to be clickable.
Otherwise safari will think that your intention is to just move the caret before/after the image if it's inside an contenteditable element.