Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix(links): adjust the anchor link only in Link.js
Signed-off-by: Max <[email protected]>
  • Loading branch information
max-nextcloud authored and backportbot[bot] committed Oct 2, 2024
commit 1b4df9c57d8befbf0765a5c63f2f983f1d938270
8 changes: 7 additions & 1 deletion src/marks/Link.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import TipTapLink from '@tiptap/extension-link'
import { domHref, parseHref } from './../helpers/links.js'
import { linkClicking } from '../plugins/links.js'

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

const extractHrefFromMatch = (match) => {
return { href: match.groups.href }
}
Expand Down Expand Up @@ -58,9 +60,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,
'data-md-href': mark.attrs.href,
rel: 'noopener noreferrer nofollow',
}, 0]
Expand Down