Skip to content

Commit

Permalink
fix(links): adjust the anchor link only in Link.js
Browse files Browse the repository at this point in the history
Signed-off-by: Max <[email protected]>
  • Loading branch information
max-nextcloud committed Nov 14, 2024
1 parent 76d61f8 commit dde09dd
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/marks/Link.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import TipTapLink from '@tiptap/extension-link'
import { domHref, parseHref, openLink } from './../helpers/links.js'
import { clickHandler, clickPreventer } from '../plugins/link.js'

const PROTOCOLS_TO_LINK_TO = ['http:', 'https:', 'mailto:', 'tel:']

const Link = TipTapLink.extend({

addOptions() {
Expand Down Expand Up @@ -59,10 +61,13 @@ const Link = TipTapLink.extend({

renderHTML(options) {
const { mark } = options

const url = new URL(mark.attrs.href, window.location)
const href = PROTOCOLS_TO_LINK_TO.includes(url.protocol)
? domHref(mark, this.options.relativePath)
: '#'
return ['a', {
...mark.attrs,
href: domHref(mark, this.options.relativePath),
href,
rel: 'noopener noreferrer nofollow',
}, 0]
},
Expand Down

0 comments on commit dde09dd

Please sign in to comment.