Skip to content

feat: add deletion by ref - #726

Open
IslamRustamov wants to merge 3 commits into
software-mansion:mainfrom
IslamRustamov:feature/add-deletion-by-ref
Open

feat: add deletion by ref#726
IslamRustamov wants to merge 3 commits into
software-mansion:mainfrom
IslamRustamov:feature/add-deletion-by-ref

Conversation

@IslamRustamov

Copy link
Copy Markdown
Contributor

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:

  1. Delete character one by one
  2. Delete selected text
  3. Delete image
  4. Any other deletion cases

Screenshots / Videos

output-ezgif com-resize

Compatibility

OS Implemented
iOS
Android
Web

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 public EnrichedTextInputInstance ref 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.

Comment thread src/web/EnrichedTextInput.tsx
Comment on lines +1340 to +1350
- (void)deleteAtSelection {
UITextRange *selectedRange = self.textView.selectedTextRange;

if (selectedRange.empty) {
[self.textView deleteBackward];
} else {
[self.textView replaceRange:selectedRange withText:@""];
}

[self anyTextMayHaveBeenModified];
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it okay if I use selectedTextRange instead of selectedRange?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean self.textView.selectedTextRange?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. It's just that everywhere around the code a textView.selectedRange is being used.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

O ok, yes it would be better to use textView.selectedRange the same like in other places.

@IslamRustamov
IslamRustamov force-pushed the feature/add-deletion-by-ref branch from ad784bb to 2fd8390 Compare July 26, 2026 14:41
@IslamRustamov

Copy link
Copy Markdown
Contributor Author

Do I need to do what copilot suggests?

@kacperzolkiewski

Copy link
Copy Markdown
Collaborator

Do I need to do what copilot suggests?

Hi @IslamRustamov,
Yes, I think that it would be good to apply suggestions from copilot.

@IslamRustamov

Copy link
Copy Markdown
Contributor Author

Do I need to do what copilot suggests?

Hi @IslamRustamov, Yes, I think that it would be good to apply suggestions from copilot.

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 kacperzolkiewski left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

Screen.Recording.2026-08-05.at.14.57.19.mov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] Delete function that can be triggered by ref

3 participants