File tree 2 files changed +21
-9
lines changed
packages/extension-link/src/helpers
2 files changed +21
-9
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " @tiptap/extension-link " : patch
3
+ ---
4
+
5
+ Fixed links with marks not registering click events correctly
Original file line number Diff line number Diff line change @@ -19,21 +19,28 @@ export function clickHandler(options: ClickHandlerOptions): Plugin {
19
19
return false
20
20
}
21
21
22
- let a = event . target as HTMLElement
23
- const els = [ ]
24
-
25
- while ( a . nodeName !== 'DIV' ) {
26
- els . push ( a )
27
- a = a . parentNode as HTMLElement
22
+ let link : HTMLAnchorElement | null = null
23
+
24
+ if ( event . target instanceof HTMLAnchorElement ) {
25
+ link = event . target
26
+ } else {
27
+ let a = event . target as HTMLElement
28
+ const els = [ ]
29
+
30
+ while ( a . nodeName !== 'DIV' ) {
31
+ els . push ( a )
32
+ a = a . parentNode as HTMLElement
33
+ }
34
+ link = els . find (
35
+ value => value . nodeName === 'A' ,
36
+ ) as HTMLAnchorElement
28
37
}
29
38
30
- if ( ! els . find ( value => value . nodeName === 'A' ) ) {
39
+ if ( ! link ) {
31
40
return false
32
41
}
33
42
34
43
const attrs = getAttributes ( view . state , options . type . name )
35
- const link = ( event . target as HTMLAnchorElement )
36
-
37
44
const href = link ?. href ?? attrs . href
38
45
const target = link ?. target ?? attrs . target
39
46
You can’t perform that action at this time.
0 commit comments