Skip to content

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

Open
eszlamczyk wants to merge 2 commits into
feat/code-renderers-corefrom
feat/code-renderers-native
Open

eszlamczyk wants to merge 2 commits into
feat/code-renderers-corefrom
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)

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.
@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

This branch has not been deployed

No deployments
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