-
Notifications
You must be signed in to change notification settings - Fork 3
Add block inserter flag and initial infrastructure #193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| key = "GUTENBERG_EDITOR_URL" | ||
| value = "http://localhost:5173/" | ||
| isEnabled = "NO"> | ||
| isEnabled = "YES"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only passing the information we need to show the editor (except for the icons – we'll need to figure out how to manage those).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest retaining "bundled" somewhere to differentiate from the remote editors and remain aligned with Android's demo app/project documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good; done.
| if ( isInserterOpened ) { | ||
| setIsInserterOpened( false ); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this achieving a specific outcome?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commented code should likely be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| } | ||
|
|
||
| // 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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