fix(link): fixes links with marks (#6078)

* fixes links with marks

* Create popular-geckos-pay.md

* Update clickHandler.ts

---------

Co-authored-by: bdbch <6538827+bdbch@users.noreply.github.com>
This commit is contained in:
Matt Gorman 2025-03-30 19:14:58 -05:00 committed by GitHub
parent d88244d007
commit 9a0af5dfeb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 8 deletions

View File

@ -0,0 +1,5 @@
---
"@tiptap/extension-link": patch
---
Fixed links with marks not registering click events correctly

View File

@ -19,21 +19,28 @@ export function clickHandler(options: ClickHandlerOptions): Plugin {
return false
}
let a = event.target as HTMLElement
const els = []
let link: HTMLAnchorElement | null = null
while (a.nodeName !== 'DIV') {
els.push(a)
a = a.parentNode as HTMLElement
if (event.target instanceof HTMLAnchorElement) {
link = event.target
} else {
let a = event.target as HTMLElement
const els = []
while (a.nodeName !== 'DIV') {
els.push(a)
a = a.parentNode as HTMLElement
}
link = els.find(
value => value.nodeName === 'A',
) as HTMLAnchorElement
}
if (!els.find(value => value.nodeName === 'A')) {
if (!link) {
return false
}
const attrs = getAttributes(view.state, options.type.name)
const link = (event.target as HTMLAnchorElement)
const href = link?.href ?? attrs.href
const target = link?.target ?? attrs.target