CKEditor div 元素被替换而不是填充
我最近编写了一个 CKEditor 插件来为图像添加标题,除了一件事之外,它一切都很好。
标题的代码如下所示:
<div class="caption_container">
<img src="image.jpg" />
<div class="caption_text">
Caption
</div>
</div>
当我选择“Caption”文本并单击有序列表按钮时,caption_text
div 元素更改为 ul,而不是将 ul 添加到 div
结果:
<div class="caption_container">
<img src="image.jpg" />
<ul class="caption_text">
<li>First item</li>
</ul>
</div>
我想得到的结果是:
<div class="caption_container">
<img src="image.jpg" />
<div class="caption_text">
<ul>
<li>First item</li>
</ul>
</div>
</div>
有办法实现吗?
I recently wrote a CKEditor plugin to add captions to images, it all works pretty good except for one thing.
The code of the caption looks like this:
<div class="caption_container">
<img src="image.jpg" />
<div class="caption_text">
Caption
</div>
</div>
When I select the "Caption" text and click the ordered list button, the caption_text
div element changes into an ul instead of the ul being added to the div
Result:
<div class="caption_container">
<img src="image.jpg" />
<ul class="caption_text">
<li>First item</li>
</ul>
</div>
The result I would like to get is:
<div class="caption_container">
<img src="image.jpg" />
<div class="caption_text">
<ul>
<li>First item</li>
</ul>
</div>
</div>
Is there a way to achieve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您不想接触 CKEditor 源代码,我可以为您提供一个简单的解决方案。您可以添加一个额外的“div”以防止删除“div class="caption_text””,因此它看起来像:
最后您将获得所需的:
If you don't want to touch CKEditor source code I have a simple solution for you. You could add a extra 'div' to prevent deletion of 'div class="caption_text"' so it will look like:
In the end you will have the desired: