【问题标题】:How to insert text to CKEditor without styles but preserve semantics如何在没有样式但保留语义的情况下将文本插入 CKEditor
【发布时间】:2014-12-24 21:11:23
【问题描述】:

有没有办法在没有样式和保留语义的情况下将格式化文本粘贴到ckeditor

例如这是它粘贴的内容:

<h1 style="font-family: sans-serif; color: rgb(34, 34, 34); line-height: 18.2000007629395px;">An h1 header</h1>

<p style="color: rgb(34, 34, 34); font-family: sans-serif; font-size: small; line-height: 18.2000007629395px;">Paragraphs are separated by a blank line.</p>

<p style="color: rgb(34, 34, 34); font-family: sans-serif; font-size: small; line-height: 18.2000007629395px;">2nd paragraph.&nbsp;<em>Italic</em>,&nbsp;<strong>bold</strong>, and&nbsp;<code style="white-space: pre; background-color: rgb(238, 238, 238);">monospace</code>. Itemized lists look like:</p>

<ul style="color: rgb(34, 34, 34); font-family: sans-serif; font-size: small; line-height: 18.2000007629395px;">
    <li>this one</li>
    <li>that one</li>
    <li>the other one</li>
</ul>

但我想粘贴这个:

<h1>An h1 header</h1>

<p>Paragraphs are separated by a blank line.</p>

<p>2nd paragraph.&nbsp;<em>Italic</em>,&nbsp;<strong>bold</strong>, and&nbsp;<code>monospace</code>. Itemized lists look like:</p>

<ul>
    <li>this one</li>
    <li>that one</li>
    <li>the other one</li>
</ul>

【问题讨论】:

    标签: ckeditor semantics paste


    【解决方案1】:

    如果您启用了Advanced Content Filter(应该默认启用),那么它将根据您的编辑器配置允许的内容过滤粘贴的内容。在Content Filtering 指南中阅读更多信息。

    但是,如果您出于某些原因禁用了 ACF,或者您想以不同的方式过滤粘贴的内容,那么您可以创建自己的 CKEDITOR.filter 实例并将其应用到 pasted data。阅读Apply CKEditor Advanced Content Filter to a string 中的更多内容,了解如何将过滤器应用于 HTML 字符串。

    【讨论】:

      猜你喜欢
      • 2020-11-19
      • 1970-01-01
      • 1970-01-01
      • 2012-11-08
      • 2017-06-30
      • 1970-01-01
      • 2023-02-08
      • 2014-05-16
      • 1970-01-01
      相关资源
      最近更新 更多