feat: add deletion by ref - #726
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new imperative deleteAtSelection API to EnrichedTextInput so consumers can trigger “backspace/delete like the native keyboard” via ref, across iOS, Android, and web (addresses issue #699).
Changes:
- Exposes
deleteAtSelection()on the publicEnrichedTextInputInstanceref API. - Wires the command through the native command/codegen layer and the native iOS/Android view implementations.
- Implements equivalent deletion behavior on the web editor implementation.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/web/EnrichedTextInput.tsx | Adds web implementation of deleteAtSelection via editor command chaining. |
| src/types.ts | Extends the public ref instance type with deleteAtSelection(). |
| src/spec/EnrichedTextInputNativeComponent.ts | Adds deleteAtSelection to the native commands interface and command list. |
| src/native/EnrichedTextInput.tsx | Exposes deleteAtSelection() on the native ref by calling the native command. |
| ios/EnrichedTextInputView.mm | Handles the new command and performs deletion based on the current selectedTextRange. |
| android/src/main/java/com/swmansion/enriched/textinput/EnrichedTextInputViewManager.kt | Routes the new command from the view manager to the view instance. |
| android/src/main/java/com/swmansion/enriched/textinput/EnrichedTextInputView.kt | Implements deletion logic based on current selection indices. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| - (void)deleteAtSelection { | ||
| UITextRange *selectedRange = self.textView.selectedTextRange; | ||
|
|
||
| if (selectedRange.empty) { | ||
| [self.textView deleteBackward]; | ||
| } else { | ||
| [self.textView replaceRange:selectedRange withText:@""]; | ||
| } | ||
|
|
||
| [self anyTextMayHaveBeenModified]; | ||
| } |
There was a problem hiding this comment.
Is it okay if I use selectedTextRange instead of selectedRange?
There was a problem hiding this comment.
You mean self.textView.selectedTextRange?
There was a problem hiding this comment.
Yes. It's just that everywhere around the code a textView.selectedRange is being used.
There was a problem hiding this comment.
O ok, yes it would be better to use textView.selectedRange the same like in other places.
ad784bb to
2fd8390
Compare
|
Do I need to do what copilot suggests? |
Hi @IslamRustamov, |
Please see my comments above, I'm not really sure if there is need to copy absolutely everything that copilot suggests, but if it is required - I will do so. |
kacperzolkiewski
left a comment
There was a problem hiding this comment.
It should behave the same as keyboard backspace but it does not.
Android:
Does not delete heading style and wrongly merges paragraphs.
Screen.Recording.2026-08-05.at.15.00.20.mov
iOS:
Deletes style and newline at once:
Screen.Recording.2026-08-05.at.14.58.51.mov
web:
Cannot make a delete at the beginning of style:
Summary
Explain the motivation for making this change: here are some points to help you:
Test Plan
To test this feature you can add manually new button that is going to call deleteAtSelection method and check it in different test case scenarios:
Screenshots / Videos
Compatibility