CKEditor、Jquery - 查找和替换 HTML

发布于 2024-10-03 05:26:49 字数 798 浏览 0 评论 0原文

我对 CKEditor 完全陌生,因此请忍受我的愚蠢问题。我有一个 CMS,它使用 CKEditor 将文章输入数据库。我被要求为编辑器编写一个插件来执行特定任务,如下所示:

我在编辑器中有一个图像。当我单击图像以选择它并单击我编码的按钮时,它会为我提供图像 html,如 。现在我需要查明图像标签是否用另外的 html 包装,例如:


<div class="photo">
    <p class="inner">
        <img src="imageurl" border="0" /><span>some text here</span>
    </p>
</div>

如果是,我需要能够编辑 span 标签中的文本,并能够向 DIV 或 P 添加内联样式,如果不是,我需要换行


<div class="photo">
    <p class="inner">
        <img src="imageurl" border="0" /><span>some text here</span>
    </p>
</div>

PS 我可以坐下来,如果有时间的话可能会想出一个解决方案。但我的截止日期太近了!

有人可以帮我解决这个问题吗?非常感谢您的帮助。

谢谢, 右

I am totally new to CKEditor, hence please bear with my stupid questions. I have a CMS that uses CKEditor to enter articles into a DB. I have been asked to write a plugin to the editor to do a particular task which is as follows:

I have an image in the editor. When I click on the image to select it and click on a button that I coded it gets me the image html like <img src="imageurl" border="0" />. Now I need to find out if the image tag is wrapped with furthermore html like:


<div class="photo">
    <p class="inner">
        <img src="imageurl" border="0" /><span>some text here</span>
    </p>
</div>

if yes, I need to be able to edit the text in the span tag and be able to add inline style to DIV or P, if not I need to wrap <img src="imageurl" border="0" /> with :


<div class="photo">
    <p class="inner">
        <img src="imageurl" border="0" /><span>some text here</span>
    </p>
</div>

P.S. I can sit thru and may be come up with a solution if I has sometime. But my deadline is too close!

Could someone please please help me with this? Your help is much appreciated.

Thanks,
R

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

难以启齿的温柔 2024-10-10 05:26:49

我认为你可以使用 Jquery 函数 parent() 来获取“ html 结构中从 开始的更高级别”

I think you can use the Jquery function parent() to get the "higher levels" in your html structure starting from <img />

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文