首页 > 解决方案 > 在 slatejs react 中的编辑器内容末尾添加自定义块

问题描述

我在 react 中使用 Slate js 创建了一个编辑器。我正在尝试在编辑器内容的末尾插入一个块。我遇到了一种在范围内插入块的方法。如何指定文档的范围,以便在内容末尾添加我的自定义块,但焦点停留在当前选择而不是文档末尾。

function insertFile(editor, src, target) {
  editor.insertBlock({
    type: 'file',
    data: { src },
  })
}

我的架构看起来像这样

const schema = {
  blocks: {
    file:{
      isVoid: true
    }
  }
}

标签: reactjswysiwygslatejs

解决方案


推荐阅读