【问题标题】:Adding Source button to ngx-quill in angular 6在角度 6 中将 Source 按钮添加到 ngx-quill
【发布时间】:2019-03-07 07:18:36
【问题描述】:

我正在使用 ngx quill 作为文本编辑器,现在我必须添加源按钮以进行编辑。所以我检查了这个链接

https://codepen.io/anon/pen/ZyEjrQ

但是这里如果要添加

<div> Hello </div>

如果我再次点击源,我可以看到像

<p> Hello <p>

所以我需要知道如何在 ngx-quill 中添加源并且输出应该与我输入的相同

任何方式都可以这样做。

【问题讨论】:

    标签: angular editor quill


    【解决方案1】:

    Quill 对块级元素使用&lt;p&gt; 标签。所以如果你粘贴&lt;div&gt;&lt;/div&gt;,它将被转换为&lt;p&gt;&lt;/p&gt;。但是您可以通过使用以下带有 ngx-quill 的代码来更改此默认行为 -

    const parchment = Quill.import('parchment')
    const block = parchment.query('block')
    block.tagName = 'DIV'
    Quill.register(block, true)
    

    这将保留所有&lt;div&gt;&lt;/div&gt; 标签。 希望这会有所帮助:)

    【讨论】:

      猜你喜欢
      • 2023-04-11
      • 2018-05-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多