@@ -21,32 +21,13 @@ export function DocImageClient({
21
21
className,
22
22
...props
23
23
} : DocImageClientProps ) {
24
- const handleContextMenu = ( e : React . MouseEvent ) => {
25
- e . preventDefault ( ) ; // Prevent default context menu
26
- // Allow right-click to open in new tab
27
- const link = document . createElement ( 'a' ) ;
28
- link . href = imgPath ;
29
- link . target = '_blank' ;
30
- link . rel = 'noreferrer' ;
31
- link . click ( ) ;
32
- } ;
33
-
34
- const handleClick = ( e : React . MouseEvent ) => {
35
- // If Ctrl/Cmd+click, open in new tab instead of lightbox
36
- if ( e . ctrlKey || e . metaKey ) {
37
- e . preventDefault ( ) ;
38
- e . stopPropagation ( ) ;
39
- window . open ( imgPath , '_blank' , 'noreferrer' ) ;
40
- }
41
- } ;
42
-
43
24
// Check if dimensions are valid (not NaN) for Next.js Image
44
25
const isValidDimensions = ! isNaN ( width ) && ! isNaN ( height ) && width > 0 && height > 0 ;
45
26
46
27
// For external images or invalid dimensions, fall back to regular img tag
47
28
if ( src . startsWith ( 'http' ) || ! isValidDimensions ) {
48
29
return (
49
- < div onContextMenu = { handleContextMenu } onClick = { handleClick } >
30
+ < a href = { imgPath } target = "_blank" rel = "noreferrer" >
50
31
{ /* eslint-disable-next-line @next/next/no-img-element */ }
51
32
< img
52
33
src = { src }
@@ -59,27 +40,25 @@ export function DocImageClient({
59
40
className = { className }
60
41
{ ...props }
61
42
/>
62
- </ div >
43
+ </ a >
63
44
) ;
64
45
}
65
46
66
47
return (
67
- < div onContextMenu = { handleContextMenu } onClick = { handleClick } >
68
- < ImageLightbox src = { src } alt = { alt ?? '' } width = { width } height = { height } >
69
- < Image
70
- src = { src }
71
- width = { width }
72
- height = { height }
73
- style = { {
74
- width : '100%' ,
75
- height : 'auto' ,
76
- ...style ,
77
- } }
78
- className = { className }
79
- alt = { alt ?? '' }
80
- { ...props }
81
- />
82
- </ ImageLightbox >
83
- </ div >
48
+ < ImageLightbox src = { src } alt = { alt ?? '' } width = { width } height = { height } imgPath = { imgPath } >
49
+ < Image
50
+ src = { src }
51
+ width = { width }
52
+ height = { height }
53
+ style = { {
54
+ width : '100%' ,
55
+ height : 'auto' ,
56
+ ...style ,
57
+ } }
58
+ className = { className }
59
+ alt = { alt ?? '' }
60
+ { ...props }
61
+ />
62
+ </ ImageLightbox >
84
63
) ;
85
64
}
0 commit comments