From 7e1154cef03e9b5ed42183986c57de4e3785b3c7 Mon Sep 17 00:00:00 2001 From: Stepan Yurtsiv Date: Wed, 24 Jul 2024 17:48:34 +0200 Subject: [PATCH] fix(link): do not convert link href to number or boolean --- .changeset/link-href-parsing-fix.md | 5 +++++ packages/extension-link/src/link.ts | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 .changeset/link-href-parsing-fix.md 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 }, }] },