-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Update image handling #14564
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jaffrepaul
merged 37 commits into
master
from
cursor/analyze-image-display-and-repository-architecture-6c32
Aug 11, 2025
Merged
Update image handling #14564
Changes from 5 commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
76137dd
Add image lightbox with Radix UI Dialog and improved image handling
cursoragent 222fbb2
Refactor DocImage components and improve type ordering
cursoragent 1d4c770
[getsentry/action-github-commit] Auto commit
getsantry[bot] 970049b
remove alt text overlay
jaffrepaul 2e98bdc
fix default browser behavior
jaffrepaul 041b40d
more specific classes
jaffrepaul b5470a6
fix external image bug, update to pass all props, & ensure fallback s…
jaffrepaul 12ca95c
refactor to fix event handling & propagation issues
jaffrepaul a636625
[getsentry/action-github-commit] Auto commit
getsantry[bot] 11227e4
remove anchors
jaffrepaul 528b31a
prevent browser context menu from downloading images instead of openi…
jaffrepaul 0bd0bae
fix window parameter & click behavior cursor bug
jaffrepaul 37fd8ce
[getsentry/action-github-commit] Auto commit
getsantry[bot] 19db25b
cleanup
jaffrepaul 7b781f4
add basic a11y
jaffrepaul 106d776
[getsentry/action-github-commit] Auto commit
getsantry[bot] 50455a3
update button styles
jaffrepaul 6c6b8a1
refactor to simplify logic
jaffrepaul 19e598e
prop and types improvements
jaffrepaul c74e563
[getsentry/action-github-commit] Auto commit
getsantry[bot] 9bffc3c
remove DocImageClient to simplify and scope styles
jaffrepaul 4065b0c
port image logic to imageLightbox
jaffrepaul c68596c
dry things up
jaffrepaul 30c260b
fix alt prop bug
jaffrepaul 5a7c1be
[getsentry/action-github-commit] Auto commit
getsantry[bot] 7ff34e8
fix type narrowing issue
jaffrepaul 19b1e92
extend next config for external images
jaffrepaul 02a849e
[getsentry/action-github-commit] Auto commit
getsantry[bot] ca1f744
gpt5 update 💪
jaffrepaul d6081b0
[getsentry/action-github-commit] Auto commit
getsantry[bot] 896228e
fix image edgecase bug
jaffrepaul 052325c
add PR feedback
jaffrepaul 0770228
better abstraction refactor & cleanup
jaffrepaul 4be0b7e
Update package.json
jaffrepaul 689e57f
bugbot smash
jaffrepaul 5dc9bcd
delegate basic events to radix, keep modifier logic
jaffrepaul b2fecbf
bugbot fix
jaffrepaul File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
'use client'; | ||
|
||
import Image from 'next/image'; | ||
|
||
import {ImageLightbox} from './imageLightbox'; | ||
|
||
interface DocImageClientProps { | ||
alt: string; | ||
height: number; | ||
imgPath: string; | ||
src: string; | ||
width: number; | ||
className?: string; | ||
style?: React.CSSProperties; | ||
} | ||
|
||
export function DocImageClient({ | ||
src, | ||
imgPath, | ||
width, | ||
height, | ||
alt, | ||
style, | ||
className, | ||
}: DocImageClientProps) { | ||
const handleContextMenu = (e: React.MouseEvent) => { | ||
e.preventDefault(); // Prevent default context menu | ||
// Allow right-click to open in new tab | ||
const link = document.createElement('a'); | ||
link.href = imgPath; | ||
link.target = '_blank'; | ||
link.rel = 'noreferrer'; | ||
link.click(); | ||
}; | ||
jaffrepaul marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
const handleClick = (e: React.MouseEvent) => { | ||
// If Ctrl/Cmd+click, open in new tab instead of lightbox | ||
if (e.ctrlKey || e.metaKey) { | ||
e.preventDefault(); | ||
e.stopPropagation(); | ||
window.open(imgPath, '_blank', 'noreferrer'); | ||
} | ||
}; | ||
cursor[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
return ( | ||
<div onContextMenu={handleContextMenu} onClick={handleClick}> | ||
<ImageLightbox src={src} alt={alt} width={width} height={height}> | ||
<Image | ||
src={src} | ||
width={width} | ||
height={height} | ||
style={{ | ||
width: '100%', | ||
height: 'auto', | ||
...style, | ||
}} | ||
className={className} | ||
alt={alt} | ||
/> | ||
</ImageLightbox> | ||
</div> | ||
); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
'use client'; | ||
|
||
import {useState} from 'react'; | ||
import {X} from 'react-feather'; | ||
import * as Dialog from '@radix-ui/react-dialog'; | ||
import Image from 'next/image'; | ||
|
||
interface ImageLightboxProps { | ||
alt: string; | ||
children: React.ReactNode; | ||
height: number; | ||
src: string; | ||
width: number; | ||
} | ||
|
||
export function ImageLightbox({src, alt, width, height, children}: ImageLightboxProps) { | ||
const [open, setOpen] = useState(false); | ||
|
||
return ( | ||
<Dialog.Root open={open} onOpenChange={setOpen}> | ||
<Dialog.Trigger asChild> | ||
<button className="cursor-pointer border-none bg-transparent p-0 block w-full"> | ||
{children} | ||
</button> | ||
</Dialog.Trigger> | ||
|
||
<Dialog.Portal> | ||
<Dialog.Overlay className="dialog-overlay fixed inset-0 bg-black/80 backdrop-blur-sm z-50" /> | ||
|
||
<Dialog.Content className="fixed left-[50%] top-[50%] z-50 max-h-[90vh] max-w-[90vw] translate-x-[-50%] translate-y-[-50%]"> | ||
{/* Close button */} | ||
<Dialog.Close className="absolute right-4 top-4 z-10 rounded-sm bg-black/50 p-2 text-white opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2"> | ||
<X className="h-4 w-4" /> | ||
<span className="sr-only">Close</span> | ||
</Dialog.Close> | ||
|
||
{/* Image container */} | ||
<div className="relative flex items-center justify-center"> | ||
<Image | ||
src={src} | ||
alt={alt} | ||
width={width} | ||
height={height} | ||
className="max-h-[90vh] max-w-[90vw] object-contain" | ||
style={{ | ||
width: 'auto', | ||
height: 'auto', | ||
}} | ||
priority | ||
/> | ||
</div> | ||
</Dialog.Content> | ||
</Dialog.Portal> | ||
</Dialog.Root> | ||
); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.