小编Yuq*_* Xu的帖子

如何在 Slate JS 中的 Transforms.insertNodes() 之后设置选择

我正在尝试在当前选择的正下方添加一个新行,然后将选择放到新行中。

let current_path = props.selection.anchor.path[0]
Transforms.insertNodes(editor, {type:'line', children:[{ text:'' }]},{at: [current_path+1]});
const point = { anchor: { path: [current_path+1, 0], offset: 0 }, focus: { path: [current_path+1, 0], offset: 0 }}
// set focus
ReactEditor.focus(editor);
// set selection
Transforms.select(editor, point);
Run Code Online (Sandbox Code Playgroud)

但这出现了一个错误:错误:无法从 Slate 节点解析 DOM 节点:{"text":""}。有谁知道如何解决它或有其他方法来实现它?谢谢!

slatejs

6
推荐指数
1
解决办法
1553
查看次数

Slatejs如何使一个特定节点不可编辑?

我想将一个特定节点设置为不可编辑

Transforms.setNodes(editor,{at:[1]},{voids:true})
Run Code Online (Sandbox Code Playgroud)

但它似乎不起作用。有谁知道该怎么做?谢谢!

slatejs

3
推荐指数
1
解决办法
1946
查看次数

标签 统计

slatejs ×2