mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-06-11 20:23:36 +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
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
let a = event.target as HTMLElement
|
let link: HTMLAnchorElement | null = null
|
||||||
const els = []
|
|
||||||
|
|
||||||
while (a.nodeName !== 'DIV') {
|
if (event.target instanceof HTMLAnchorElement) {
|
||||||
els.push(a)
|
link = event.target
|
||||||
a = a.parentNode as HTMLElement
|
} 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
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
const attrs = getAttributes(view.state, options.type.name)
|
const attrs = getAttributes(view.state, options.type.name)
|
||||||
const link = (event.target as HTMLAnchorElement)
|
|
||||||
|
|
||||||
const href = link?.href ?? attrs.href
|
const href = link?.href ?? attrs.href
|
||||||
const target = link?.target ?? attrs.target
|
const target = link?.target ?? attrs.target
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user