Skip to content

feat(native): place code block slots in the iOS and Android hosts - #1069

Merged
hryhoriiK97 merged 2 commits into
mainfrom
feat/code-renderers-native
Nov 2, 2026
Merged

hryhoriiK97 merged 2 commits into
mainfrom
feat/code-renderers-native

Conversation

@eszlamczyk

@eszlamczyk eszlamczyk commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

What/Why?

Second step of the code block renderers stack, on top of #1068.

This PR teaches the iOS and Android hosts to place code block slots, so the next PR can turn them on from JS.

  • Both hosts map the code slot kind (ENRMBlockSlotKindCode, BlockSlotKind.CODE). A code block the core stamped becomes a slot segment instead of a native code block, and takes the top and bottom margins of markdownStyle.codeBlock.
  • The TurboModule's NativeBlockSlot gains language, code and isComplete. isComplete is false only for the slot whose fence is still open in the streamed markdown, read from the core's isSlotComplete.
  • The TurboModule still skips code slots, until useBlockSlots maps them in the next PR.
  • The spec change needs a native rebuild for codegen.

Testing

  • New testCodeSlotTakesCodeBlockMargins in BlockSlotStackingTests.mm: a stamped fence is a single slot segment whose height is the code block margins plus the measured height.
  • New BlockSlotKindTest.kt: every core kind name maps to its kind, a code slot takes the code block margins, and only a stamped code block splits into a slot.
  • Updated the renderers.test.tsx fixtures for the new fields.
  • No visible change in the app yet, because code slots are still skipped.

PR Checklist

  • Code compiles and runs on iOS
  • Code compiles and runs on Android
  • Updated documentation/README if applicable
  • Ran example app to verify changes
  • E2E tests are passing
  • Required E2E tests have been added (if applicable)

@eszlamczyk
eszlamczyk added this pull request to stack #1071 October 23, 2026 08:06
@eszlamczyk
eszlamczyk force-pushed the feat/code-renderers-native branch from 48fd94e to 05620c1 Compare October 23, 2026 08:41
@eszlamczyk
eszlamczyk force-pushed the feat/code-renderers-native branch from 05620c1 to 3b09536 Compare October 23, 2026 13:32
@eszlamczyk
eszlamczyk marked this pull request as ready for review October 23, 2026 13:46
@hryhoriiK97
hryhoriiK97 force-pushed the feat/code-renderers-native branch from 3b09536 to 142927e Compare November 2, 2026 15:34
Base automatically changed from feat/code-renderers-core to main November 2, 2026 17:50
The hosts map the `code` slot kind and give its placeholder the code block's
margins. The TurboModule's slots carry `language`, `code` and `isComplete`,
which is false only for the code block an open streamed fence belongs to.

Wrap state and the pending code block need no change: a replaced block is not
a native code block view, so measurement and view collection both skip it,
and a trailing code slot leaves nothing pending.

The TurboModule still skips code slots until useBlockSlots maps them.
@hryhoriiK97
hryhoriiK97 force-pushed the feat/code-renderers-native branch from 142927e to f0f24f0 Compare November 2, 2026 17:50
@hryhoriiK97
hryhoriiK97 merged commit 4b7a7a3 into main Nov 2, 2026
19 checks passed
@hryhoriiK97
hryhoriiK97 deleted the feat/code-renderers-native branch November 2, 2026 17:50
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.

2 participants