reactjs - 在 slatejs react 中的编辑器内容末尾添加自定义块
问题描述
我在 react 中使用 Slate js 创建了一个编辑器。我正在尝试在编辑器内容的末尾插入一个块。我遇到了一种在范围内插入块的方法。如何指定文档的范围,以便在内容末尾添加我的自定义块,但焦点停留在当前选择而不是文档末尾。
function insertFile(editor, src, target) {
editor.insertBlock({
type: 'file',
data: { src },
})
}
我的架构看起来像这样
const schema = {
blocks: {
file:{
isVoid: true
}
}
}
解决方案
推荐阅读
- docker - Openwhisk 如何决定创建多少运行时容器?
- r - 使用 R 中的两列合并两个 data.tables
- flutter - 颤振显示裁剪的小部件
- java - 使用 while 循环和 for 循环确定最大素数
- mariadb - MariaDB 总共运行 N 并且行不包括在其计算中
- spring-boot - 如何防止在春季启动应用程序中发布方法后页面刷新?
- typescript - 解构对象时重命名和添加类型
- android - 无法在 androidstudio 中构建
- vue.js - v-for 循环不适用于导入的数组
- python - 通过 Python XML-RPC 手动引发异常