feat(web): onImagePress#690
Open
hejsztynx wants to merge 4 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds Web support for onImagePress on the EnrichedText renderer so consumers can react to inline image clicks (plus docs and an E2E test to validate behavior in the example web app).
Changes:
- Added a Web click-interaction hook to emit
onImagePressevents from rendered HTML images. - Wired
onImagePressintosrc/web/EnrichedText.tsxusing a stable callback ref. - Updated docs + example web app, and added Playwright coverage for image press behavior (including list cases).
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/web/usePressInteractions.ts | New hook to detect image clicks and emit onImagePress. |
| src/web/EnrichedText.tsx | Passes onImagePress into the interaction hook via useStableRef. |
| src/web/EnrichedText.css | Adjusts checkbox-list pointer-events to allow clicks within list items while keeping checkbox non-interactive. |
| docs/WEB.md | Documents that onImagePress is supported on Web. |
| docs/TEXT_API_REFERENCE.md | Updates onImagePress platform support to include Web. |
| apps/example-web/src/testScreens/TestEnrichedText.tsx | Captures and displays the last onImagePress event for E2E assertions. |
| apps/example-web/src/App.tsx | Adds a console-log demo handler for onImagePress in the example app. |
| .playwright/tests/enrichedTextPress.spec.ts | Adds Playwright E2E coverage for image press events (including list scenarios). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
16
to
+17
| import { usePressInteractions } from './usePressInteractions'; | ||
| import { useStableRef } from './useStableRef'; |
Comment on lines
+22
to
+27
| const handleInteraction = (e: MouseEvent) => { | ||
| const target = e.target as HTMLElement; | ||
|
|
||
| const image = target.closest('img'); | ||
|
|
||
| if (image && container.contains(image)) { |
Comment on lines
+45
to
+64
| function parseImageAttributs(image: HTMLElement): ImageAttributes | undefined { | ||
| const uri = image.getAttribute('src'); | ||
| const rawWidth = image.getAttribute('width'); | ||
| const rawHeight = image.getAttribute('height'); | ||
|
|
||
| if (uri && rawWidth && rawHeight) { | ||
| const width = parseInt(rawWidth, 10); | ||
| const height = parseInt(rawHeight, 10); | ||
|
|
||
| if (!isNaN(width) && !isNaN(height)) { | ||
| return { | ||
| uri, | ||
| width, | ||
| height, | ||
| }; | ||
| } | ||
| } | ||
|
|
||
| return undefined; | ||
| } |
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
Implemented
onImagePresscallback functionality on the webEnrichedTextcomponentTest Plan
There is a set
console.logcallback in the main example app, to see the feature works.Compatibility
Checklist