diff --git a/.changeset/link-href-parsing-fix.md b/.changeset/link-href-parsing-fix.md new file mode 100644 index 00000000000..97b2bdb5f0a --- /dev/null +++ b/.changeset/link-href-parsing-fix.md @@ -0,0 +1,5 @@ +--- +"@tiptap/extension-link": fix +--- + +Fixes a bug where link `href` was converted to number or boolean during HTML parsing, leading to a crash in rendering. diff --git a/packages/extension-link/src/link.ts b/packages/extension-link/src/link.ts index a42156e99f6..335cf7c2314 100644 --- a/packages/extension-link/src/link.ts +++ b/packages/extension-link/src/link.ts @@ -164,6 +164,9 @@ export const Link = Mark.create({ return { href: { default: null, + parseHTML(element) { + return element.getAttribute('href') + }, }, target: { default: this.options.HTMLAttributes.target, @@ -187,7 +190,7 @@ export const Link = Mark.create({ if (!href || !isAllowedUri(href)) { return false } - return { href } + return null }, }] },