项目

设置文本选中

当你想到编辑器中的选择时,很可能会联想到文本选择。通过setTextSelection,你可以控制这个文本选择,并将其设置为指定的范围或位置。

相关命令:聚焦设置节点选择删除选择全选

参数

position: number | Range

传入一个数字,或者一个范围对象,比如{ from: 5, to: 10 }

使用示例

// 将光标移动到指定的位置
editor.commands.setTextSelection(10)

// 设置文本选择到指定的范围
editor.commands.setTextSelection({ from: 5, to: 10 })
在本文档中