小编con*_*sen的帖子

ProseMirror - 将插入符号位置设置为所选节点的末尾

运行命令({ href: url })后,我想取消选择当前选择并将插入符位置设置为所选节点的末尾。注意:我正在使用 TipTap

setLinkUrl(command, url) {
command({ href: url })
this.hideLinkMenu()

// Set cursor position after highlighted link
var tag = document.getElementById("editor")

var setpos = document.createRange()

var set = window.getSelection()

const state = this.editor.state

let sel = state.selection
// TODO: Check if sel range > 0
let resolvedPos = state.doc.resolve(sel.from)
let node = resolvedPos.node(resolvedPos.depth)

// This is where I want to set the caret position to the end of the currently selected node
// Currently, I'm using hardcoded …
Run Code Online (Sandbox Code Playgroud)

javascript text-editor rich-text-editor prose-mirror tiptap

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