我试图在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删除。我该怎么做才能达到这个目标?
您应该配置编辑器以允许其他标记
,你需要html编辑插件(对不起,我忘记了它的真名)
public config = {
placeholder: 'content here',
htmlSupport: {
allow: [
{
name: /.*/,
attributes: true,
classes: true,
styles: true
}
]
}
}