我如何自定义tinymce修复损坏的html的方式?特别列出?

发布于 2024-12-28 13:51:11 字数 748 浏览 4 评论 0原文

我有像这样创建html的最终用户:

<ol>
      <li>some text</li>
      <li>some more text</li>
      <div>a div in the wrong spot</div>
      <li>the last line of text</li>
</ol>

Tinymce将其变成这样的东西:

<ol>
      <li>some text</li>
      <li>some more text</li>
</ol>
      <div>a div in the wrong spot</div>
<ol>
      <li>the last line of text</li>
</ol>

这是一个问题,因为有时它会重新启动编号,有时它不会重新启动编号(start =“3”),但格式始终是搞砸了。

如何强制tinymce将

附加到之前的
  • 内部?
  • 我尝试将 fix_list_elements 设置为 false,但这没有帮助。

    I have end-users who created html like this:

    <ol>
          <li>some text</li>
          <li>some more text</li>
          <div>a div in the wrong spot</div>
          <li>the last line of text</li>
    </ol>
    

    Tinymce turns it into something like this:

    <ol>
          <li>some text</li>
          <li>some more text</li>
    </ol>
          <div>a div in the wrong spot</div>
    <ol>
          <li>the last line of text</li>
    </ol>
    

    This is a problem because sometimes it restarts the numbering, and sometimes it doesn't restart numbering (start="3") but the formatting is always messed up.

    How can I force tinymce to append the <div> inside of the previous <li>?

    I've tried setting fix_list_elements to false, but this doesn't help.

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

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

    发布评论

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

    评论(1

    俯瞰星空 2025-01-04 13:51:11

    仍然没有找到确切的答案,但有足够的解决方法。使用 valid_children TinyMCE 选项。

    {
      valid_children : "+ul[div],+ol[div]"
    }
    

    这允许细粒度地让无效 HTML 保持不固定状态。

    Still have not found an exact answer, but there is a sufficient workaround. Using the valid_children TinyMCE option.

    {
      valid_children : "+ul[div],+ol[div]"
    }
    

    This allows for granularity in letting invalid HTML remain unfixed.

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