feat(view): support gallery preview for custom file types beyond images and videos#1110
Merged
feat(view): support gallery preview for custom file types beyond images and videos#1110
Conversation
Reviewer's GuideExtends the useFilesGallery hook to support gallery items for arbitrary file links via a new resolveCustomItem option, refactors item construction to be reusable for all item types, and widens FilesGalleryItemType to include a new 'file' type with corresponding documentation updates. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- In
buildItem, you overwrite theactionsfield onbasePropsinstead of merging with any actions a customresolveCustomItemmight provide; consider combiningbaseProps.actionswith the generated download/copy actions so consumers can still inject their own item-level actions. resolveCustomItemis only ever called withtype: 'file', but its signature exposes the fullFilesGalleryItemTypeunion; consider narrowing this parameter to'file'(and reflecting that consistently in README examples) to avoid suggesting it will be invoked for images/videos.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `buildItem`, you overwrite the `actions` field on `baseProps` instead of merging with any actions a custom `resolveCustomItem` might provide; consider combining `baseProps.actions` with the generated download/copy actions so consumers can still inject their own item-level actions.
- `resolveCustomItem` is only ever called with `type: 'file'`, but its signature exposes the full `FilesGalleryItemType` union; consider narrowing this parameter to `'file'` (and reflecting that consistently in README examples) to avoid suggesting it will be invoked for images/videos.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
makhnatkin
approved these changes
Apr 29, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Added
resolveCustomItemoption touseFilesGalleryhook. Previously the hook only opened the gallery for images and videos with known extensions — all other file links (<a class="yfm-file">with PDF, archives, etc.) were silently ignored. Now callers can handle these files themselves.New option:
resolveCustomItemGalleryItemPropsto include the element in the galleryundefinedto skip it (preserves current behavior)download/copyUrl/overrideItemPropspipeline as built-in image/video itemsFilesGalleryItemTypeis widened from'image' | 'video'to'image' | 'video' | 'file'. This is a non-breaking runtime change, but callers doing an exhaustiveswitchontypeindownload,copyUrl, oroverrideItemPropscallbacks may now get a TypeScript warning about the unhandled'file'case.Usage example
Summary by Sourcery
Add support in useFilesGallery for including non-image/video file links in the gallery via a new customization hook and extend item type handling to cover generic files.
New Features:
Enhancements:
Documentation: