fix(link): ensure text blocks exist before referencing them (#3251)

Fixes #3250
This commit is contained in:
Guy Marriott
2022-09-29 06:03:04 -07:00
committed by GitHub
parent be4cde0e02
commit 539afce4fd

View File

@@ -74,8 +74,9 @@ export function autolink(options: AutolinkOptions): Plugin {
' ',
)
} else if (
nodesInChangedRanges.length
// We want to make sure to include the block seperator argument to treat hard breaks like spaces
newState.doc.textBetween(newRange.from, newRange.to, ' ', ' ').endsWith(' ')
&& newState.doc.textBetween(newRange.from, newRange.to, ' ', ' ').endsWith(' ')
) {
textBlock = nodesInChangedRanges[0]
textBeforeWhitespace = newState.doc.textBetween(