【问题标题】:Tinymce repeats a Template when go new line in contentTinymce 在内容中换行时重复模板
【发布时间】:2021-12-06 12:04:50
【问题描述】:

我正在使用 Tinymce 5.9.1template 插件。

我用特殊的 css 代码制作了一个像这样的代码的新模板:

templates: [
     {title: 'green-box', description: 'box tiny green', content: '<div class="tiny-green-box"> Content </div><div class="p-1"></div></br>'},],

在一行中编辑内容时有效。当我想放多行时出现问题。

Tinymce 为每个新行复制模板。

例如,如果我键入 line1 并按 ENTER,它将创建新的 div,结果将是这样的:

你可以在 html 代码中看到它重复了很多次:

【问题讨论】:

    标签: tinymce tinymce-4 tinymce-5 tinymce-plugins


    【解决方案1】:

    将内容放入一个额外的&lt;p&gt;&lt;/p&gt; 标签 可以解决这个问题。 最终代码必须是这样的:

    templates: [
         {
    title: 'green-box', 
    description: 'box tiny green', 
    content: '<div class="tiny-green-box"><p> Content </p></div><div class="p-1"></div></br>'
    }
    ,],
    

    结果 HTML 代码将如下所示:

    <div class="tiny-green-box">
    <p>line 1</p>
    <p>line 2</p>
    <p>line 3</p>
    <p>line 4</p>
    </div>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-01-16
      • 1970-01-01
      • 2014-08-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-25
      相关资源
      最近更新 更多