我希望能够从所见即所得切换到纯 HTML,例如插入 IFrame Youtube 视频。到目前为止,对于标准的 CKEditor 5 构建,没有关于如何做到这一点的文档。
有没有等同于Source Editing Area的插件但适用于 CKEditor 5?
最佳答案
是的,可以将 html 插入 CKEditor5:
insertHTML(html:string) {
// See: https://ckeditor.com/docs/ckeditor5/latest/builds/guides/faq.html#where-are-the-editorinserthtml-and-editorinserttext-methods-how-to-insert-some-content
const viewFragment = this.editor.data.processor.toView( html );
const modelFragment = this.editor.data.toModel( viewFragment );
this.editor.model.insertContent(modelFragment);
}
关于javascript - CKEditor 5 - 如何插入一些 HTML(也就是源模式在哪里)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47729450/