diff --git a/.changeset/unlucky-ravens-build.md b/.changeset/unlucky-ravens-build.md new file mode 100644 index 000000000..49d1ec100 --- /dev/null +++ b/.changeset/unlucky-ravens-build.md @@ -0,0 +1,5 @@ +--- +"@tiptap/extension-link": patch +--- + +fix: #5679 - perform string sanitization to remove unwanted "object replacement characters" from the before performing link detection diff --git a/packages/extension-link/src/link.ts b/packages/extension-link/src/link.ts index b9b882995..bb8ead872 100644 --- a/packages/extension-link/src/link.ts +++ b/packages/extension-link/src/link.ts @@ -351,7 +351,12 @@ export const Link = Mark.create({ if (text) { const { protocols, defaultProtocol } = this.options - const links = find(text).filter( + // Prosemirror replaces zero-width non-joiner characters + // with Object Replacement Character from unicode. + // Therefore, linkifyjs does not recognize the + // link properly. We replace these characters + // with regular spaces to fix this issue. + const links = find(text.replaceAll('\uFFFC', ' ')).filter( item => item.isLink && this.options.isAllowedUri(item.value, { defaultValidate: href => !!isAllowedUri(href, protocols),