diff --git a/ui/packages/editor/src/extensions/link/index.ts b/ui/packages/editor/src/extensions/link/index.ts index e77b7b8fa4..b47411fc37 100644 --- a/ui/packages/editor/src/extensions/link/index.ts +++ b/ui/packages/editor/src/extensions/link/index.ts @@ -1,6 +1,7 @@ import TiptapLink from "@tiptap/extension-link"; import type { LinkOptions } from "@tiptap/extension-link"; import type { ExtensionOptions } from "@/types"; +import { mergeAttributes } from "@/tiptap/vue-3"; const Link = TiptapLink.extend({ addOptions() { @@ -13,6 +14,28 @@ const Link = TiptapLink.extend({ }, }; }, + + renderHTML({ HTMLAttributes }) { + const href = HTMLAttributes.href; + // False positive; we're explicitly checking for javascript: links to ignore them + // eslint-disable-next-line no-script-url + if (href?.toString().startsWith("javascript:")) { + // strip out the href + return [ + "a", + mergeAttributes(this.options.HTMLAttributes, { + ...HTMLAttributes, + href: "", + }), + 0, + ]; + } + return [ + "a", + mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), + 0, + ]; + }, }); export default Link;