Skip to content

feat(android): add block inserter payload model + JS dispatch fix#463

Draft
jkmassel wants to merge 1 commit intotrunkfrom
jkmassel/block-picker-models
Draft

feat(android): add block inserter payload model + JS dispatch fix#463
jkmassel wants to merge 1 commit intotrunkfrom
jkmassel/block-picker-models

Conversation

@jkmassel
Copy link
Copy Markdown
Contributor

@jkmassel jkmassel commented Apr 22, 2026

Summary

Groundwork for the native block inserter feature on Android. Two independent pieces, both fully tested, with no observable behavior change on either platform.

  • Kotlin payload model@Serializable data classes mirroring the shape produced by BlockInserterBridge in src/components/native-inserter/index.jsx. Parser tests cover full payload, minimal payload, fallback category, explicit nulls on nullable strings, and malformed input.
  • JS dispatch fixbridge.js showBlockInserter no longer routes through dispatchToBridge. Its Android branch flattens args with Object.values and passes them positionally to the @JavascriptInterface, but @JavascriptInterface can't receive arrays or objects — they arrive as "[object Object]". New code stringifies for Android (single String arg) and preserves the structured body for iOS, matching the pattern already used by openMediaLibrary, onNetworkRequest, and logException.

iOS receives the same structured body as before. The Kotlin models aren't referenced from production code yet, and the Android @JavascriptInterface receiving method lands in #461.

Test plan

  • make test-js — passes in CI
  • ./gradlew :Gutenberg:test detekt :Gutenberg:lintDebug — passes in CI

Related

First of three stacked PRs:

@github-actions github-actions Bot added the [Type] Enhancement A suggestion for improvement. label Apr 22, 2026
@jkmassel jkmassel marked this pull request as draft April 22, 2026 23:13
Adds `@Serializable` Kotlin data classes mirroring the shape produced
by `BlockInserterBridge` in `src/components/native-inserter/index.jsx`,
with parser tests covering full/minimal payloads, fallback category,
explicit nulls, and malformed input.

Also switches `bridge.js` `showBlockInserter` from `dispatchToBridge`
to a stringify-for-Android / structured-for-iOS pattern. The
`dispatchToBridge` Android branch flattens args with `Object.values`
and passes them positionally to the `@JavascriptInterface`, but
`@JavascriptInterface` can't receive arrays or objects — they arrive
as `"[object Object]"`. Matches the pattern used by openMediaLibrary,
onNetworkRequest, and logException.

iOS receives the same structured body as before. Android wiring and
feature flag land in follow-up PRs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant