Skip to content

Commit 2dfba92

Browse files
authored
fix(markup): fix pasting image urls to link lines (#738)
1 parent 051a06a commit 2dfba92

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/markup/codemirror/create.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,13 @@ export function createCodemirror(params: CreateCodemirrorParams) {
237237

238238
if (parseInsertedUrlAsImage) {
239239
const linkMatches = currentLine.matchAll(linkRegex);
240+
const cursorPositionInCurrentLine = from - line.from;
240241
const isInsertedInsideLink = linkMatches.some(
241-
(item) => from >= item.index && from <= item.index + (item[0]?.length ?? 0),
242+
(item) =>
243+
cursorPositionInCurrentLine >= item.index &&
244+
cursorPositionInCurrentLine <= item.index + (item[0]?.length ?? 0),
242245
);
246+
243247
if (!isInsertedInsideLink) {
244248
const {imageUrl, title} =
245249
parseInsertedUrlAsImage(

0 commit comments

Comments
 (0)