feat(ios): add image support to input - #403
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds first-class image support to EnrichedMarkdownTextInput on iOS by tracking image metadata alongside formatting, rendering images via text attachments, supporting copy/paste round-trips, and exposing new JS APIs/events for inserting and handling pasted images.
Changes:
- Introduces an iOS
ENRMImageStore(plusENRMEditAdjusting) and extends parsing/serialization to round-trip images via ORC placeholders andmarkdown. - Adds a new native command (
insertImage) and event (onPasteImages) surfaced through the TS component API and the example app. - Wires new style props (
markdownStyle.image.borderRadius,markdownStyle.inlineImage.size) through the style normalization + native prop pipeline and into the image attachment rendering.
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/react-native-enriched-markdown/src/normalizeMarkdownTextInputStyle.ts | Adds normalized defaults/props for image border radius and inline image size. |
| packages/react-native-enriched-markdown/src/index.tsx | Re-exports new image-related public types. |
| packages/react-native-enriched-markdown/src/EnrichedMarkdownTextInputNativeComponent.ts | Adds codegen props/events/commands for paste images + insert image and new style fields. |
| packages/react-native-enriched-markdown/src/EnrichedMarkdownTextInput.tsx | Adds insertImage imperative API and onPasteImages callback. |
| packages/react-native-enriched-markdown/ios/utils/ENRMImageDownloader.m | Adds support for downloading/loading file:// image URLs. |
| packages/react-native-enriched-markdown/ios/input/ENRMParseResult.h | Extracts parse result into a shared header and adds imageEntries. |
| packages/react-native-enriched-markdown/ios/input/ENRMMarkdownSerializer.h / .mm | Adds image-aware serialization with validation against ORC positions. |
| packages/react-native-enriched-markdown/ios/input/ENRMInputTextView.mm | Intercepts pasted images and emits onPasteImages instead of pasting text. |
| packages/react-native-enriched-markdown/ios/input/ENRMInputParser.h / .mm | Extracts image markdown into ORCs and produces imageEntries. |
| packages/react-native-enriched-markdown/ios/input/ENRMImageStore.h / .mm | New point-based image metadata store with edit adjustment. |
| packages/react-native-enriched-markdown/ios/input/ENRMFormattingStore.h | Makes formatting store conform to shared edit-adjusting protocol. |
| packages/react-native-enriched-markdown/ios/input/ENRMEditAdjusting.h | New shared edit-adjustment protocol. |
| packages/react-native-enriched-markdown/ios/input/EnrichedMarkdownTextInput.h / .mm | Integrates image store, applies image attachments, emits paste images event, and adds insert image command. |
| packages/react-native-enriched-markdown/ios/attachments/ENRMImageAttachment.h / .m | Adds input-specific attachment construction (explicit sizing + border radius) and associates attachment with text view. |
| apps/example/src/screens/playground/PlaygroundScreen.tsx | Demonstrates inserting images and handling pasted images. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ntry creation logic
|
We're looking at this library for the message composer in Root (chat app, React Native, currently I built a test harness on 0.7.4 today and ran it on both platforms. The Reading through this PR, Is something blocking this, or did it just go quiet? Happy to help move it along. I can:
Let me know! Love the work you've done with this project so far. |
Hi @szt217 ! Sorry for the late reply - I'll get back to this thread soon, but I just wanted to let you know I'm keeping an eye on it. |
@szt217 yes, I've started a proof of concept for supporting images in EnrichedMarkdownTextInput, but we've got other important things on our plate right now. The architecture has changed significantly since we added headings and lists (the current nightly state), so I think this implementation needs to be started from scratch. We're currently preparing for a new release with a lot of new features, so we won't have the bandwidth to work on this this week or next. By the way, are you interested in contributing this feature to our library? Image support can be a bit tricky with plenty of edge cases, but contributions are always welcome! |
Thanks for getting back and for the update. I would love to give this a go. Let me take some time to get familiar with the project and contribution policies. |
What/Why?
Add image support to
EnrichedMarkdownTextInputon iOS — storing image metadata, inserting ORC placeholders, rendering attachments, serializing to, and handling copy/paste round-trips.ENRMFormattingStore, plus duplicate-position guardreplaceTextInRange:now acceptsENRMParseResultdirectlyimageEntries, leaving orphan ORCs; now threads them throughextractImagesFromPasteboard:into focused static helpersmarkdownStyle.image.borderRadiusandinlineImage.sizewired through full prop pipeline, replacing hardcoded valuesTesting
Screenshots
Nagranie.z.ekranu.2026-06-17.o.13.36.49.mov
PR Checklist