feat: add onImagePress event to EnrichedText#681
Open
kacperzolkiewski wants to merge 5 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new cross-platform (iOS/Android) onImagePress event to EnrichedText, allowing consumers to react to presses on inline <img> elements and receive the pressed image’s URI and dimensions.
Changes:
- Extend the public TS API (
EnrichedTextProps) withonImagePressand a newOnImagePressEventtype, and re-export it from the package entrypoints. - Wire the event through the React Native codegen spec and JS wrapper, then emit it from native iOS + Android implementations.
- Document the new prop, update the example app to demonstrate it, and add an E2E Maestro flow covering image press.
Reviewed changes
Copilot reviewed 15 out of 17 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/types.ts | Adds onImagePress prop and OnImagePressEvent type to the public TS API. |
| src/spec/EnrichedTextNativeComponent.ts | Adds codegen event type + onImagePress to native component props. |
| src/native/EnrichedText.tsx | Plumbs the native onImagePress event through to the JS EnrichedText prop. |
| src/index.tsx | Re-exports OnImagePressEvent from the library entrypoint. |
| src/index.native.tsx | Re-exports OnImagePressEvent for native entrypoint parity. |
| ios/utils/EnrichedTextTouchHandler.mm | Detects presses on EnrichedImage attributes and dispatches image-press events. |
| ios/EnrichedTextView.mm | Emits onImagePress via the Fabric event emitter with URI + dimensions. |
| ios/EnrichedTextView.h | Declares emitOnImagePressEvent: on the view interface. |
| docs/TEXT_API_REFERENCE.md | Documents onImagePress, its payload shape, and lack of visual feedback. |
| apps/example/src/screens/EnrichedTextScreen.tsx | Demonstrates handling onImagePress in the example screen. |
| apps/example/src/components/TextRenderer.tsx | Demonstrates handling onImagePress in the renderer component. |
| android/src/main/java/com/swmansion/enriched/text/spans/EnrichedTextImageSpan.kt | Makes image spans clickable and dispatches OnImagePressEvent. |
| android/src/main/java/com/swmansion/enriched/text/events/OnImagePressEvent.kt | Adds the native Android event payload for onImagePress. |
| android/src/main/java/com/swmansion/enriched/text/EnrichedTextViewManager.kt | Registers onImagePress as a direct event for the view manager. |
| .maestro/enrichedText/flows/image_press.yaml | Adds an E2E flow to validate image press event behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Summary
Add
OnImagePresseventTest Plan
EnrichedTextin example app.OnImagePressevent is emittedScreenshots / Videos
Screen.Recording.2026-07-06.at.17.13.49.mov
Compatibility
Checklist