File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed
Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -43,12 +43,27 @@ export function activeLinkFromSelection({ selection, doc }) {
4343 const node = resolved . parent . maybeChild ( resolved . index ( ) )
4444 const nodeStart = resolved . pos - resolved . textOffset
4545 const nodeEnd = nodeStart + node ?. nodeSize
46-
4746 if ( to > nodeEnd ) {
4847 // Selection spans further than one text node
49- return
48+ return null
49+ }
50+ const active = activeLink ( node , nodeStart )
51+ if ( active ) {
52+ return active
5053 }
54+ const nodeBefore = resolved . nodeBefore
55+ if ( nodeBefore ) {
56+ return activeLink ( nodeBefore , nodeStart - nodeBefore . nodeSize )
57+ }
58+ return null
59+ }
5160
61+ /**
62+ * Active link object for the given node and nodeStart
63+ * @param {object } node - node to check
64+ * @param {Number } nodeStart - offset in the document
65+ */
66+ function activeLink ( node , nodeStart ) {
5267 const mark = linkMark ( node )
5368 return mark ? { mark, nodeStart } : null
5469}
You can’t perform that action at this time.
0 commit comments