如何在 TinyMCE 中使 div 表现得像 img
我编写了一个插件,可以将弹出灯箱中的照片/视频插入到 TinyMCE 中。当对齐/换行时,效果很好并且格式非常好。当它像下面这样插入到 HTML 中时:
<img src="blah.png" />
但从那时起,我添加了一个允许添加字幕的功能,它使用包装器 div,例如:
<div class="ImageWrapper" width="x" height="x">
<img src="blah.png" />
Caption here
</div>
现在有几个问题我无法解决。
第一:我如何允许TinyMCE像使用img一样格式化/对齐div?
第二:如何防止用户选择 div 的任何内容?相反,单击应该突出显示整个 div,以便格式化和删除工作更加顺利。
I've written a plugin which inserts photos/video from a popup lightbox into TinyMCE. This worked fine and formatted very well when aligned/wrapped. When it is inserted in HTML like below:
<img src="blah.png" />
But since then I added a feature to allow captioning, which uses a wrapper div such as:
<div class="ImageWrapper" width="x" height="x">
<img src="blah.png" />
Caption here
</div>
There are now a couple of problems I can't fix.
First: How do I allow TinyMCE to format/align the div as it did with img?
Secondly: How do I prevent the user from selecting any of the contents of the div? Instead clicking should highlight the whole div so formatting and deleting works much more smoothly.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是使用
作为包装器,这显然不是 TinyMCE 自然支持的。你必须走得更远,而不仅仅是摆弄一些CSS。 TinyMCE 作为一个流行的编辑器,人们已经尝试并提出了合适的解决方案。这是编写插件的人: http://www.tinymce.com/forum/ viewtopic.php?id=20319
如果您在 google 上搜索“tinymce div 插件”,可以找到更多信息:http ://www.google.com/#q=tinymce+div+plugin
我不知道什么最适合您的情况,所以我想您必须尝试提供的一些解决方案(plpugins)。
The problem is using a
<div>
as a wrapper, which is apparently not naturally supported by TinyMCE. You have to go further than fidgeting with some css. TinyMCE being a popular editor, people have already tried and come up with a proper solution. Here's someone who's written a plugin: http://www.tinymce.com/forum/viewtopic.php?id=20319And there's lots of more info to be found if you google for 'tinymce div plugin': http://www.google.com/#q=tinymce+div+plugin
I don't know what would work best in your situation, so I guess you have to try some of the solutions (plpugins) offered.