CKEditor5 在编辑器中插入不可编辑的文本

时间:2021-02-25 13:52:17

标签: ckeditor ckeditor5

我正在尝试在 CKEditor5 中插入小块文本,例如

{{ variable name }}

这些变量不得由用户编辑。我试图插入

content = '<span contenteditable="false">' + content + '</span>';

使用以下代码,内容为不可编辑字符串

content = '<span contenteditable="false">' + content + '</span>';
const viewFragment = this.editor.data.processor.toView( content );
const modelFragment = this.editor.data.toModel( viewFragment );
this.editor.model.insertContent( modelFragment );

它不起作用。 CKEditor 总是会移除包装部分。我应该怎么做才能实现这一目标?

0 个答案:

没有答案
相关问题