From 71946c18accf8a2e8192951de870f84e25f58ed5 Mon Sep 17 00:00:00 2001 From: Dominik <6538827+bdbch@users.noreply.github.com> Date: Thu, 27 Apr 2023 12:02:56 +0200 Subject: [PATCH] fix(link): fix links autolinking when not needed (#3989) --- packages/extension-link/src/helpers/autolink.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/extension-link/src/helpers/autolink.ts b/packages/extension-link/src/helpers/autolink.ts index 643a76f0a61..3e0dfaee547 100644 --- a/packages/extension-link/src/helpers/autolink.ts +++ b/packages/extension-link/src/helpers/autolink.ts @@ -63,10 +63,6 @@ export function autolink(options: AutolinkOptions): Plugin { } }) - if (!needsAutolink) { - return - } - // now let’s see if we can add new links const nodesInChangedRanges = findChildrenInRange( newState.doc, @@ -130,6 +126,10 @@ export function autolink(options: AutolinkOptions): Plugin { })) // add link mark .forEach(link => { + if (getMarksBetween(link.from, link.to, newState.doc).some(item => item.mark.type === options.type)) { + return + } + tr.addMark( link.from, link.to,