feat: add insertValue method - #409
Conversation
|
@kacperzolkiewski check it out at your convenience please (there are some questions in the end of the description) |
|
Hi @IslamRustamov, To answer your questions:
|
Some misunderstanding here sorry, so just to be sure, we want them to be optional or not? |
|
@IslamRustamov, |
|
i guess its ready for review then, please take a look |
|
On Android if we insert text in paragraph style it does not inherit styling: Screen.Recording.2026-02-02.at.16.33.10.movOn iOS it works properly. |
this problem is also relevant for pasting functionality. Seems like there is something wrong with mergeSpannables which does not correctly set needed span to the inserted text (pasted or inserted) at the end of the string. I currently don't see that mergeSpannables actually merging spans (I mean, not adding a h1 span to the newly inserted text at the end for example). I believe that I should copy code of the handleCustomPaste and use it in insertValue, so it will all come down to modifying mergeSpannables in such a way that this problem is solved for both pasting and inserting texts (suggestions on what should be done inside mergeSpannables are welcome). |
@IslamRustamov, |
kacperzolkiewski
left a comment
There was a problem hiding this comment.
Thanks for your work!
|
Really looking forward to this one! Any indication as to what release we might get this in? |
|
I hope the release comes out soon; I really need this. |
<!-- Thanks for submitting a pull request! We appreciate you spending the time to work on these changes. Please follow the template so that the reviewers can easily understand what the code changes affect --> # Summary This PR fixes applying styles for pasted text at the end of paragraph. It was mentioned here: #409 ## Test Plan 1. Create Heading with text "Hello" 2. Copy some text 3. paste it at the end of "Hello" 4. Heading styles should extend on pasted text ## Screenshots / Videos Before: https://github.com/user-attachments/assets/cad248b8-1674-477f-af45-fae8c0a63538 After: https://github.com/user-attachments/assets/e67b861e-8394-41da-9305-71799ccca072 ## Compatibility | OS | Implemented | | ------- | :---------: | | iOS | ❌ | | Android | ✅ | ---------
There was a problem hiding this comment.
Pull request overview
Adds a new imperative API, insertValue(value, start, end), to let consumers insert/replace text (or HTML-ish input) at a specific range without fully resetting the editor value—addressing feature request #255.
Changes:
- Exposes
insertValueon the publicEnrichedTextInputInstanceAPI and wires it through the native commands layer. - Implements native handling for
insertValueon iOS (handleCommand+ insertion logic) and Android (ViewManager + View insertion logic). - Adds a web ref handle entry for
insertValue(currently implemented as a stub in this PR).
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/web/EnrichedTextInput.tsx | Exposes insertValue on the web imperative ref (currently a no-op). |
| src/types.ts | Extends the public instance interface with insertValue. |
| src/spec/EnrichedTextInputNativeComponent.ts | Adds insertValue to codegen native commands + supportedCommands. |
| src/native/EnrichedTextInput.tsx | Wires JS imperative method to native command Commands.insertValue. |
| ios/EnrichedTextInputView.mm | Adds iOS command dispatch and native insertion implementation. |
| android/src/main/java/com/swmansion/enriched/textinput/EnrichedTextInputViewManager.kt | Exposes insertValue command to the native view. |
| android/src/main/java/com/swmansion/enriched/textinput/EnrichedTextInputView.kt | Implements Android-side insertion/replace logic and selection update. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Fixes: #255
Test Plan
Highly recommend to test this PR manually by adding a new button, which invokes a function that calls insertValue method.
Screenshots / Videos
Not applicable.
Compatibility
Checklist
NOTE:
There are several questions I would like to ask:
Do please share your suggestions, fixes, test cases and everything else that I may have missed. And don't hesitate to push whatever you want to this PR if you feel like it's needed.