File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -24,6 +24,8 @@ import TipTapLink from '@tiptap/extension-link'
2424import { domHref , parseHref } from './../helpers/links.js'
2525import { linkClicking } from '../plugins/links.js'
2626
27+ const PROTOCOLS_TO_LINK_TO = [ 'http:' , 'https:' , 'mailto:' , 'tel:' ]
28+
2729const Link = TipTapLink . extend ( {
2830
2931 addOptions ( ) {
@@ -58,9 +60,13 @@ const Link = TipTapLink.extend({
5860
5961 renderHTML ( options ) {
6062 const { mark } = options
63+ const url = new URL ( mark . attrs . href , window . location )
64+ const href = PROTOCOLS_TO_LINK_TO . includes ( url . protocol )
65+ ? domHref ( mark , this . options . relativePath )
66+ : '#'
6167 return [ 'a' , {
6268 ...mark . attrs ,
63- href : domHref ( mark , this . options . relativePath ) ,
69+ href,
6470 'data-md-href' : mark . attrs . href ,
6571 rel : 'noopener noreferrer nofollow' ,
6672 } , 0 ]
You can’t perform that action at this time.
0 commit comments