feat(android): add block inserter payload model + JS dispatch fix#463
Draft
feat(android): add block inserter payload model + JS dispatch fix#463
Conversation
This was referenced Apr 22, 2026
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.
5b56302 to
e0a3843
Compare
1 task
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
Groundwork for the native block inserter feature on Android. Two independent pieces, both fully tested, with no observable behavior change on either platform.
@Serializabledata classes mirroring the shape produced byBlockInserterBridgeinsrc/components/native-inserter/index.jsx. Parser tests cover full payload, minimal payload, fallback category, explicit nulls on nullable strings, and malformed input.bridge.jsshowBlockInserterno longer routes throughdispatchToBridge. Its Android branch flattensargswithObject.valuesand passes them positionally to the@JavascriptInterface, but@JavascriptInterfacecan't receive arrays or objects — they arrive as"[object Object]". New code stringifies for Android (singleStringarg) and preserves the structured body for iOS, matching the pattern already used byopenMediaLibrary,onNetworkRequest, andlogException.iOS receives the same structured body as before. The Kotlin models aren't referenced from production code yet, and the Android
@JavascriptInterfacereceiving method lands in #461.Test plan
make test-js— passes in CI./gradlew :Gutenberg:test detekt :Gutenberg:lintDebug— passes in CIRelated
First of three stacked PRs:
enableNativeBlockInserterfeature flagGutenbergViewwiring