mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-06-07 17:43:49 +08:00
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:
parent
d88244d007
commit
9a0af5dfeb
5
.changeset/popular-geckos-pay.md
Normal file
5
.changeset/popular-geckos-pay.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"@tiptap/extension-link": patch
|
||||
---
|
||||
|
||||
Fixed links with marks not registering click events correctly
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user