Skip to content

feat: add deletion by ref - #726

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

feat: add deletion by ref#726
IslamRustamov wants to merge 2 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 on lines +381 to +387
const { from, to } = editor.state.selection;

if (from !== to) {
return c.deleteSelection();
} else {
return c.deleteRange({ from: from - 1, to });
}
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];
}
Comment on lines +1008 to +1019
fun deleteAtSelection() {
runAsATransaction {
val start = selectionStart
val end = selectionEnd

if (start != end) {
text?.delete(start, end)
} else if (start > 0) {
text?.delete(start - 1, start)
}
}
}
@IslamRustamov
IslamRustamov force-pushed the feature/add-deletion-by-ref branch from ad784bb to 2fd8390 Compare July 26, 2026 14:41
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

2 participants