File tree Expand file tree Collapse file tree 2 files changed +15
-11
lines changed Expand file tree Collapse file tree 2 files changed +15
-11
lines changed Original file line number Diff line number Diff line change @@ -30,8 +30,16 @@ export function DocImageClient({
30
30
31
31
// For external images or invalid dimensions, fall back to regular img tag
32
32
if ( src . startsWith ( 'http' ) || ! isValidDimensions ) {
33
+ const handleClick = ( e : React . MouseEvent ) => {
34
+ // If Ctrl/Cmd+click, open image in new tab
35
+ if ( e . ctrlKey || e . metaKey ) {
36
+ window . open ( imgPath , '_blank' , 'noreferrer' ) ;
37
+ return ;
38
+ }
39
+ } ;
40
+
33
41
return (
34
- < a href = { imgPath } target = "_blank" rel = "noreferrer ">
42
+ < div onClick = { handleClick } className = "cursor-pointer ">
35
43
{ /* eslint-disable-next-line @next/next/no-img-element */ }
36
44
< img
37
45
src = { src }
@@ -44,7 +52,7 @@ export function DocImageClient({
44
52
className = { className }
45
53
{ ...props }
46
54
/>
47
- </ a >
55
+ </ div >
48
56
) ;
49
57
}
50
58
Original file line number Diff line number Diff line change @@ -25,28 +25,24 @@ export function ImageLightbox({
25
25
const [ open , setOpen ] = useState ( false ) ;
26
26
27
27
const handleClick = ( e : React . MouseEvent ) => {
28
- // If Ctrl/Cmd+click, let the link handle it naturally (opens in new tab)
28
+ // If Ctrl/Cmd+click, open image in new tab
29
29
if ( e . ctrlKey || e . metaKey ) {
30
- // Allow default link behavior
30
+ window . open ( imgPath , '_blank' , 'noreferrer' ) ;
31
31
return ;
32
32
}
33
- // Normal click - prevent link navigation and open lightbox
34
- e . preventDefault ( ) ;
33
+ // Normal click - open lightbox
35
34
setOpen ( true ) ;
36
35
} ;
37
36
38
37
return (
39
38
< Dialog . Root open = { open } onOpenChange = { setOpen } >
40
39
{ /* Custom trigger that handles modifier keys properly */ }
41
- < a
42
- href = { imgPath }
43
- target = "_blank"
44
- rel = "noreferrer"
40
+ < div
45
41
className = "cursor-pointer border-none bg-transparent p-0 block w-full no-underline"
46
42
onClick = { handleClick }
47
43
>
48
44
{ children }
49
- </ a >
45
+ </ div >
50
46
51
47
< Dialog . Portal >
52
48
< Dialog . Overlay className = "image-lightbox-overlay fixed inset-0 bg-black/80 backdrop-blur-sm z-50" />
You can’t perform that action at this time.
0 commit comments