Add block inserter flag and initial infrastructure#193
Conversation
| key = "GUTENBERG_EDITOR_URL" | ||
| value = "http://localhost:5173/" | ||
| isEnabled = "NO"> | ||
| isEnabled = "YES"> |
There was a problem hiding this comment.
Since #191 (comment), should we enable GUTENBERG_EDITOR_URL by default? I keep doing this every time I work on the editor.
There was a problem hiding this comment.
Sounds good to me. However, let's also enable the GUTENBERG_EDITOR_REMOTE_URL environment variable as well.
We should also update the README documentation to match the new default settings. The README recently changed. I suggest rebasing this atop the latest trunk branch and applying the following diff
diff --git a/README.md b/README.md
index 977bcba..9993c75 100644
--- a/README.md
+++ b/README.md
@@ -26,17 +26,19 @@ Once finished, the web app can now be accessed in your browser by visiting the U
### Demo App
-This demo app is useful for quickly testing changes made to the editor. By default, the demo app uses a production build of the web app bundled with the GutenbergKit package—i.e., the output of the project's `make build` command. During development, however, it is more useful to run the web app with a server and provide the server URL as an environment variable for the demo app, so that changes are displayed in the app immediately.
+This demo app is useful for quickly testing changes made to the editor.
#### iOS
+The iOS demo app loads the development server by default.
+
1. Start the development server by running `make dev-server`.
1. Launch Xcode and open the `ios/Demo-iOS/Gutenberg.xcodeproj` project.
1. Select the `Gutenberg` target.
-1. Navigate to _Product_ → _Scheme_ → _Edit Scheme_.
-1. Add an environment variable named `GUTENBERG_EDITOR_URL` with the development server URL.
1. Run the app.
+Alternatively, you can load a production build of the web app bundled with the GutenbergKit package by running `make build` and disabling the `GUTENBERG_EDITOR_URL` environment variable by navigating to _Product_ → _Scheme_ → _Edit Scheme_ in Xcode.
+
<details>
<summary>Example Xcode environment variable</summary>
@@ -46,6 +48,8 @@ This demo app is useful for quickly testing changes made to the editor. By defau
#### Android
+The Android demo app loads the production build of the web app bundled with the GutenbergKit package by default—i.e., the output of the project's `make build` command). It can be configured to load the development server by setting a `GUTENBERG_EDITOR_URL` environment variable in the `android/local.properties` file.
+
1. Start the development server by running `make dev-server`.
1. Launch Android Studio and open the `android` project.
1. Modify the `android/local.properties` file to include an environment variable named `GUTENBERG_EDITOR_URL` with the development server URL.
There was a problem hiding this comment.
Enabled, and I updated the README as well.
| #warning("1. Update the siteURL and authHeader values below") | ||
| #warning("2. Install the Jetpack plugin to the site") | ||
| // Steps: | ||
| // 1. Update the siteURL and authHeader values below |
There was a problem hiding this comment.
These shouldn't be warnings.
| private let configuration: EditorConfiguration | ||
|
|
||
| @State private var viewModel = EditorViewModel() | ||
| @State private var editorViewController: EditorViewController? |
There was a problem hiding this comment.
Follow-up to the previous PR
| } | ||
|
|
||
| // Style the add block button with rounded black background | ||
| .gutenberg-kit-editor-toolbar .gutenberg-kit-add-block-button { |
There was a problem hiding this comment.
I think this is fine for now. Eventually, we need to consideration Android design patterns.
| export function showBlockInserter() { | ||
| const blocks = getBlockTypes().map( ( blockType ) => { | ||
| return { | ||
| name: blockType.name, |
There was a problem hiding this comment.
Only passing the information we need to show the editor (except for the icons – we'll need to figure out how to manage those).
dcalhoun
left a comment
There was a problem hiding this comment.
Looks like a solid start. I left a few suggestions, but approving because this worked as expected for me.
| key = "GUTENBERG_EDITOR_URL" | ||
| value = "http://localhost:5173/" | ||
| isEnabled = "NO"> | ||
| isEnabled = "YES"> |
There was a problem hiding this comment.
Sounds good to me. However, let's also enable the GUTENBERG_EDITOR_REMOTE_URL environment variable as well.
We should also update the README documentation to match the new default settings. The README recently changed. I suggest rebasing this atop the latest trunk branch and applying the following diff
diff --git a/README.md b/README.md
index 977bcba..9993c75 100644
--- a/README.md
+++ b/README.md
@@ -26,17 +26,19 @@ Once finished, the web app can now be accessed in your browser by visiting the U
### Demo App
-This demo app is useful for quickly testing changes made to the editor. By default, the demo app uses a production build of the web app bundled with the GutenbergKit package—i.e., the output of the project's `make build` command. During development, however, it is more useful to run the web app with a server and provide the server URL as an environment variable for the demo app, so that changes are displayed in the app immediately.
+This demo app is useful for quickly testing changes made to the editor.
#### iOS
+The iOS demo app loads the development server by default.
+
1. Start the development server by running `make dev-server`.
1. Launch Xcode and open the `ios/Demo-iOS/Gutenberg.xcodeproj` project.
1. Select the `Gutenberg` target.
-1. Navigate to _Product_ → _Scheme_ → _Edit Scheme_.
-1. Add an environment variable named `GUTENBERG_EDITOR_URL` with the development server URL.
1. Run the app.
+Alternatively, you can load a production build of the web app bundled with the GutenbergKit package by running `make build` and disabling the `GUTENBERG_EDITOR_URL` environment variable by navigating to _Product_ → _Scheme_ → _Edit Scheme_ in Xcode.
+
<details>
<summary>Example Xcode environment variable</summary>
@@ -46,6 +48,8 @@ This demo app is useful for quickly testing changes made to the editor. By defau
#### Android
+The Android demo app loads the production build of the web app bundled with the GutenbergKit package by default—i.e., the output of the project's `make build` command). It can be configured to load the development server by setting a `GUTENBERG_EDITOR_URL` environment variable in the `android/local.properties` file.
+
1. Start the development server by running `make dev-server`.
1. Launch Android Studio and open the `android` project.
1. Modify the `android/local.properties` file to include an environment variable named `GUTENBERG_EDITOR_URL` with the development server URL.
| EditorView(configuration: .default) | ||
| } label: { | ||
| Text("Bundled Editor") | ||
| Button("Show Editor") { |
There was a problem hiding this comment.
I suggest retaining "bundled" somewhere to differentiate from the remote editors and remain aligned with Android's demo app/project documentation.
| if ( isInserterOpened ) { | ||
| setIsInserterOpened( false ); | ||
| } |
There was a problem hiding this comment.
Is this achieving a specific outcome?
There was a problem hiding this comment.
It hides the previously selected sheet. The web-based inserter does the same thing, so I implemented it for the new inserter as well.
<Inserter
popoverProps={ {
'aria-modal': true,
role: 'dialog',
} }
open={ isInserterOpened }
onToggle={ setIsInserterOpened }
/>
Simulator.Screen.Recording.-.iPhone.17.Pro.-.2025-10-20.at.11.00.23.mov
| display: block; | ||
| } | ||
|
|
||
| // width: 50px; |
There was a problem hiding this comment.
This commented code should likely be removed.
| } | ||
|
|
||
| // Style the add block button with rounded black background | ||
| .gutenberg-kit-editor-toolbar .gutenberg-kit-add-block-button { |
There was a problem hiding this comment.
I think this is fine for now. Eventually, we need to consideration Android design patterns.
| svg { | ||
| background: #eae9ec; | ||
| border-radius: 18px; | ||
| color: wordpress.$black; | ||
| padding: 1px; | ||
| width: 32px; | ||
| height: 32px; | ||
| display: block; | ||
| } |
There was a problem hiding this comment.
I suggest we place this after the attributes declared for .gutenberg-kit-editor-toolbar .gutenberg-kit-add-block-button. I.e., move this after the current line 88.
c0b3604 to
7e9157d
Compare
| import { debug } from './logger'; | ||
| import { isDevMode } from './dev-mode'; | ||
| import { basicFetch } from './fetch'; | ||
| import { getBlockTypes } from '@wordpress/blocks'; |
There was a problem hiding this comment.
While rebasing #197, I discovered this import is problematic for the "remote" editor, which currently fails to load. The import results in a reference to window.wp.blocks before this global is defined by scripts loaded from the remote site.
I'll create a PR addressing this, likely by splitting (or "chunking") this bridge method from the rest.

What?
isNativeInserterEnabledflag toEditorConfigurationPart of #162.
Testing Instructions
Screenshots or screencast
Screen.Recording.2025-10-09.at.10.56.08.AM.mov