微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何在 CKEditor 5

如何解决如何在 CKEditor 5

我已经注册了以下模型:

const schema = this.editor.model.schema
const conversion = this.editor.conversion

schema.register('cms:gallery',{
    allowWhere: '$block',isObject: true,})

conversion.for('upcast').elementtoElement({
    model: 'cms:gallery',view: {
        name: 'section',classes: 'cms-gallery'
    },})

conversion.for('dataDowncast').elementtoElement({
    model: 'cms:gallery',})
conversion.for('editingDowncast').elementtoElement({
    model: 'cms:gallery',view: (modelElement,{ writer: viewWriter }) => {
        const section = viewWriter.createContainerElement('section',{class: 'cms-gallery'})

        return toWidget(section,viewWriter,{ label: 'gallery widget' })
    }
})

例如,在初始化时,编辑器的内容是:

<section class="cms-gallery"></section>

我可以将模型作为这样的字符串获取

const stringModel = editor.data.processor.toData(editor.data.parse(editor.data.get())) // Result: '<cms:gallery></cms:gallery>'

但是如何从字符串中设置编辑器模型的值?

const stringModel = '<cms:gallery></cms:gallery>' // How convert this in CKeditor view???

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。