mirror of
https://github.com/docmost/docmost.git
synced 2026-08-30 02:25:01 +08:00
fix: link paste handler (#609)
* feat: support pasting markdown * fix link paste handler
This commit is contained in:
@@ -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, {
|
||||
|
||||
Reference in New Issue
Block a user