CKeditor protectedSource车把

Bla*_*son 6 ckeditor

我试图使用带有车把模板的CKeditor来允许用户在我们的应用程序中自定义消息.

CKEditor做了一些奇怪的事情

它变成了这样:

<table>
  <thead>
    <tr>
      <td>Activity</td>
      <td>Quantity</td>
      <td>Rate</td>
      <td>Amount</td>
    </tr>
  </thead>
  <tbody>
    {{line_items}}
  </tbody>
</table>
Run Code Online (Sandbox Code Playgroud)

进入:

{{line_items}}
<table>
  <thead>
    <tr>
      <td>Activity</td>
      <td>Quantity</td>
      <td>Rate</td>
      <td>Amount</td>
    </tr>
  </thead>
  <tbody></tbody>
</table>
Run Code Online (Sandbox Code Playgroud)

然后谷歌搜索引导我config.protectedSource用来保护所有车把.

CKEDITOR.replace('template_body', {
  //... other stuff

  protectedSource: [
    /{{[\s\S]*?}}/g
  ]
}
Run Code Online (Sandbox Code Playgroud)

此设置可以正确保护车把标签不被移动和移除,但是可以防止它们被查看/编辑!

CKEditor在编辑模式下隐藏受保护的源,并在源模式下显示它!那是一个bug吗?我可以{{}}在编辑器的源模式下看到,但不能在常规模式下看到?

Wik*_*alc 1

看看请求的数量,看来这个插件的作者做得很好,试试吧。您应该能够使用它以所见即所得模式编辑受保护的源代码。