Repository navigation
fix(iOS, Android): ZWS parity fixes - #860
Open
szydlovsky wants to merge 3 commits into
Open
szydlovsky wants to merge 3 commits into
szydlovsky wants to merge 3 commits into
Conversation
szydlovsky
changed the base branch from
main
to
@kacperzolkiewski/fix-onlink-detected
November 10, 2026 11:53
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Linking a selection that spans an empty styled paragraph can replace the selected content instead of only adding link metadata, losing mixed formatting and paragraph styles.
1 open issue
What changed in this PR
Aligns iOS rich-text indices with JavaScript-visible text and Android by excluding internal zero-width spaces from event payloads and converting incoming command ranges.
Changes:
- Adds shared helpers for stripping zero-width spaces and converting indices and ranges.
- Updates selection, link, and context-menu events to report visible text and ranges.
- Applies shared conversion to selection and link commands, and reuses stripping helpers for text-change and submit events.
| File | Description |
|---|---|
| ios/utils/ZeroWidthSpaceUtils.mm | Implements shared text-stripping and index-conversion helpers. |
| ios/utils/ZeroWidthSpaceUtils.h | Declares the new helper APIs. |
| ios/EnrichedTextInputView.mm | Integrates helpers into outgoing events and incoming commands. |
Review effort: Balanced
exploIF
approved these changes
Nov 12, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
iOS stores a zero-width space (
\u200B) in every empty list / quote / code block / checkbox paragraph. JS never sees these characters:onChangeTextstrips them. But most iOS events and commands that take or report a range counted them anyway. With an empty styled line above, iOS indices were shifted by one per empty line and didn't match theonChangeTextvalue or Android.Android already converts everywhere; this PR brings iOS in line and fixes a related
setLinkissue on Android:ZeroWidthSpaceUtilsto strip zero-width spaces and convert between visible (JS) and actual (native side) indices and ranges.onChangeSelection,onLinkDetectedandonContextMenuItemPressnow report visible indices, and their text fields no longer include\u200B.setLinkandremoveLinknow convert visible indices, assetSelectionalready did. All three go through the same helper.onChangeText/onSubmitEditinguse the shared strip helper (no behaviour change).addLinkcompares the given link text with the selected content stripped of zero-width spaces. Text coming from JS never contains them, so before, a selection spanning an empty styled line didn't match and was replaced, losing its formatting, paragraph styles and those spaces. Now only the link is added. The cursor is also placed at the end of the linked range rather thanstart + text.length, which fell short by one character per empty line.setLinkSpanalways replaced the selected text, even when it was identical, with the same result: formatting and paragraph styles were lost. It now replaces the text only when it differs (ignoring zero-width spaces), and otherwise just adds the link.Inputs and outputs are changed together on purpose: iOS was raw on both sides, so flows like
onChangeSelection→setLinkkept working and must keep working.Test Plan
Set the value to
<ul><li></li><li></li></ul><p><a href="https://swmansion.com">foo</a> bar</p>and check on iOS and Android that the values match:foo→onChangeSelection5–5; Select All → 0–9 with text length 9foo→onLinkDetected2–5fooselected → context menu item gets 2–5 and"foo"setLink(6, 9, 'bar', url)links exactlybar;removeLink(2, 5)unlinks the wholefoosetSelection(5, 2)selectsfooScreenshots / Videos
--
Compatibility
Checklist