npm 模块
slate (opens in a new tab)
-
- 需要同时配置 isInline (opens in a new tab): 不然默认是 block 元素
- 扩展类型定义 (opens in a new tab)
-
清空编辑器
const clearEditor = (editor: BaseEditor & ReactEditor) => {
editor.children.forEach(() => {
Transforms.removeNodes(editor, { at: [0] });
});
};
- 编辑器插入
Transforms.insertNodes(editor, nodes);