From 026c124903affe1290c181505bb5045df37d57c3 Mon Sep 17 00:00:00 2001 From: windingwind <33902321+windingwind@users.noreply.github.com> Date: Sat, 12 Aug 2023 01:29:18 +0800 Subject: [PATCH] fix: #549 --- src/extras/editorScript.ts | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/extras/editorScript.ts b/src/extras/editorScript.ts index e326e3b..21c38c9 100644 --- a/src/extras/editorScript.ts +++ b/src/extras/editorScript.ts @@ -122,17 +122,13 @@ function getMarkRange($pos: ResolvedPos, type: MarkType, attributes = {}) { function getMarkRangeAtCursor(state: EditorState, type: MarkType) { const { selection } = state; - const { $from, empty } = selection; + const { $from } = selection; - if (empty) { - const start = $from.parent.childAfter($from.parentOffset); - if (start.node) { - const mark = start.node.marks.find( - (mark) => mark.type.name === type.name, - ); - if (mark) { - return getMarkRange($from, type, mark.attrs); - } + const start = $from.parent.childAfter($from.parentOffset); + if (start.node) { + const mark = start.node.marks.find((mark) => mark.type.name === type.name); + if (mark) { + return getMarkRange($from, type, mark.attrs); } }