fix: link paste handler (#609)

* feat: support pasting markdown

* fix link paste handler
This commit is contained in:
Philip Okugbe
2025-01-04 20:47:49 +00:00
committed by GitHub
parent 287b833838
commit f5bc99b449
4 changed files with 48 additions and 6 deletions
+24
View File
@@ -10,11 +10,35 @@ export const LinkExtension = TiptapLink.extend({
return [
{
tag: 'a[href]:not([data-type="button"]):not([href *= "javascript:" i])',
getAttrs: (element) => {
if (
element
.getAttribute("href")
?.toLowerCase()
.startsWith("javascript:")
) {
return false;
}
return null;
},
},
];
},
renderHTML({ HTMLAttributes }) {
if (HTMLAttributes.href?.toLowerCase().startsWith("javascript:")) {
return [
"a",
mergeAttributes(
this.options.HTMLAttributes,
{ ...HTMLAttributes, href: "" },
{ class: "link" },
),
0,
];
}
return [
"a",
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, {