如何在 TinyMCE 代码中包含方括号和等号

How to include square brackets and equals symbols in TinyMCE code

我想保存代码如

<app-element [item] = "item"></app-element>

但是,每次我保存此代码时,TinyMCE 都会将标记更改为:

<app-element item "" item""></app-element>.

有办法吗?我的有效元素是“[]”。

您可以使用保护配置选项告诉 TinyMCE 保留您想要的代码:

https://www.tiny.cloud/docs/configure/content-filtering/#protect

来自文档:

This configuration option enables you to control what contents should be protected from editing while it gets passed into the editor. This could, for example, be control codes in the HTML. It’s recommended not to use inline control contents since it breaks the WYSIWYG editing concept, but sometimes they can’t be avoided.

The option takes an array of regular expression that it will match the contents against and these will be invisible while editing.