gpt4 book ai didi

javascript - CKEditor 5 - 如何插入一些 HTML(也就是源模式在哪里)?

转载 作者:数据小太阳 更新时间:2023-10-29 04:48:55 30 4
gpt4 key购买 nike

我希望能够从所见即所得切换到纯 HTML,例如插入 IFrameYoutube 视频。到目前为止,对于标准的 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/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com