Repository navigation
feat: add a line wrap toggle to code block headers - #1
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
|
The T3 Code side, which bumps the vendored archive and turns the prop on, is pingdotgg/t3code#19041. |
|
Taking over this one to land it in the fork and ship it in T3 Code. I'll keep you credited and post what changed here. |
The wrap toggle announced hardcoded English on both platforms while the copy button next to it already read its label from props. Add a `codeBlock.wrap` / `codeBlock.unwrap` group to `accessibilityLabels` (English defaults "Wrap lines" / "Disable line wrap") and route it to the code block view the same way the other label groups reach their segment views. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…eplaced Wrap state is keyed by a code block's position among the top-level code blocks, so it only stays meaningful while the document grows in place. A mounted view that received unrelated markdown (a recycled list cell, an edited message, a block inserted above) kept the old indexes and wrapped the wrong block. Clear the set, and the measure pass's copy of it, when the new markdown does not start with the previous one, and force a re-measure the way the toggle itself does. Android keeps the rule in `keepsCodeBlockWrapState` so it can be unit tested without the JNI parser. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…f skipping it Any wrapped block disabled the props-keyed measurement cache for the whole document, so every Yoga pass re-measured from scratch. Fold an order-independent fingerprint of the wrapped index set into the cache key, as Android folds the sorted list into its props hash, and drop the bypass flag. The set stays an immutable NSSet read through the atomic property, so the measure thread never sees a partial update. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
State belongs to the block's position and resets when the markdown is replaced rather than appended to; blocks inside blockquotes and admonitions have no toggle; the spoken labels come from `accessibilityLabels.codeBlock`. Add the prop to the website API reference, which the PR had skipped. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Checks that measureCodeBlockNodeHeight matches the laid-out CodeBlockContainerView height for wrapped and unwrapped blocks at several widths, and that keepsCodeBlockWrapState keeps wrap state only for in-place growth (streaming appends, identical markdown). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…writes and task toggles Apps that preprocess streaming markdown rewrite its unfinished last line (an HTML tag closing, a link relabeled), which is not a pure append. Only a change before the previous document's last line now resets wrap state. Android task toggles also kept resetting it while iOS applies them in place; they now keep it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Upstreamed as software-mansion#1010 (issue software-mansion#1009), with @Abdullah1738 as the commit author. |
What/Why?
Long lines in GitHub-flavor code blocks only scroll sideways. That's fine on desktop, but on a phone you end up swiping back and forth inside a small box to read a long command or a drafted comment.
This adds an opt-in
enableCodeBlockWrapToggleprop (defaultfalse):text.alignleftSF Symbol. Wrapping bounds the cached TextKit container to the pane width. VoiceOver gets a custom action next to copy.wrap_textglyph. Wrapping caps the code TextView's width at the pane width inside the existing HorizontalScrollView. TalkBack reads the same labels.MeasurementCachekey; on Android they go into the measure hash.Takeover changes (by @juliusmarminge, on top of @Abdullah1738's feature):
accessibilityLabels.codeBlock.wrap/.unwrap, defaulting to "Wrap lines" / "Disable line wrap". Before, they were hardcoded English next to a localized copy button.usedHeight. Updateddocs-md/API_REFERENCE.md, the React Native API reference and the accessibility page.CodeBlockContainerViewTest. It checks that the measured height equals the laid-out view's, wrapped and unwrapped, at three widths, and it checks the reset rule. Both were checked to fail when the code they cover is broken.Upstream: software-mansion#1009 proposes this API. Upstream's guidelines ask for an issue before API changes, and their standalone packages already have a global
codeBlockLayout, so the shape may change there.Testing
typecheck, Jest (20 suites, 128 tests), eslint on the touched TS files, and clang-format on the touched ObjC files all pass.testDebugUnitTestandktlintCheckpass. The iOS library pod builds for the simulator withxcodebuild.Screenshots
Originally built by @Abdullah1738 in this PR.
Note
Add per-code-block line-wrap toggle to EnrichedMarkdown code block headers
enableCodeBlockWrapToggleprop (default false) for GitHub-flavor fenced code blocks on iOS and Android. Each top-level block starts unwrapped and can be toggled independently via a button beside the copy button, with VoiceOver/accessibility custom actionscodeBlock.wrapandcodeBlock.unwrapaccessibility labels with English defaults "Wrap lines" and "Disable line wrap", documented in API_REFERENCE.md and enriched-markdown-text.mdMacroscope summarized 52251d0.