Skip to content

feat: add insertText command#516

Open
fendent wants to merge 1 commit intosoftware-mansion:mainfrom
fendent:feat/insert-text-command
Open

feat: add insertText command#516
fendent wants to merge 1 commit intosoftware-mansion:mainfrom
fendent:feat/insert-text-command

Conversation

@fendent
Copy link
Copy Markdown

@fendent fendent commented Apr 6, 2026

Summary

Adds a new insertText command that inserts plain text into the input without replacing existing rich content (images, mentions, etc).

Accepts optional start and end position parameters (visible indices, skipping ZWSPs). When omitted or set to -1, inserts at the current selection/cursor position.

setValue replaces the entire content, and setImage replaces the selection with an image, but there's no way to programmatically insert plain text at a position without destroying rich content.

This is intentionally plain-text-only and complements #409 (insertValue), which targets rich/HTML content insertion.

inputRef.current.insertText(' ');           // insert at cursor
inputRef.current.insertText('hello', 5);    // insert at position 5
inputRef.current.insertText('hi', 2, 5);    // replace range 2-5

Test Plan

  1. Insert an inline image via setImage
  2. Call insertText(' ') — a space should appear after the image without destroying it
  3. Call insertText('hello', 0) — text should be inserted at position 0
  4. Call insertText('x', 2, 5) — should replace characters 2-5 with 'x'
  5. Verify cursor moves to the end of inserted text in all cases

Compatibility

OS Implemented
iOS
Android

Checklist

  • E2E tests are passing
  • Required E2E tests have been added (if applicable)

Adds a new `insertText` command that inserts plain text into the
attributed string without replacing existing rich content (images,
mentions, etc).

Accepts optional start/end position parameters (visible indices,
skipping ZWSPs). When omitted, inserts at the current selection.

Implemented for both iOS and Android.
@fendent fendent marked this pull request as ready for review April 6, 2026 03:47
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.

1 participant