Skip to content
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

Fix - EditorProvider and private APIs #24

Merged
merged 8 commits into from
Sep 17, 2024
Merged

Fix - EditorProvider and private APIs #24

merged 8 commits into from
Sep 17, 2024

Conversation

geriux
Copy link

@geriux geriux commented Sep 16, 2024

This PR addresses an issue where a removed experimental API breaks the editor in the latest Gutenberg version.

It now uses the EditorProvider exported from @wordpress/editor However, the main issue is that the media library tab no longer loads because the inserterMediaCategories data is missing.

This occurs because the data is marked as private, and the EditorProvider component removes it using the BlockEditorProvider, where the prop stripExperimentalSettings is set to true.

In Gutenberg, the editor uses ExperimentalEditorProvider with ExperimentalBlockEditorProvider, but these are not publicly exported.

For now, we can merge this to have a working editor and then look for a long-term solution, likely by attempting to export the other provider as a private API until it is no longer marked as experimental.

Additionally, this PR updates the WordPress packages to their latest versions, adding support for multi-select.

A new middleware is introduced in the API Fetch setup to avoid fetching post content when the editor loads. We are already passing the data, and fetching it again can slow down the editor on slower connections and cause issues where content might flicker or reload.

Regarding post loading, for empty posts, a post ID is expected when the editor loads. For drafts, the Web editor generates a post ID by auto-saving. Since this functionality is not available, a -1 post ID is set to ensure the editor loads correctly.

To test

Note

You can use the following WordPress iOS build to test these changes
Precondition: Enable the feature flag Experimental Block Editor

Test case 1 - The editor loads an existing post

  • Open the app
  • Go to Posts
  • Tap on an existing post
  • Expect the post to load with both the title and the content

Test case 2 - The editor loads with a new post

  • Open the app
  • Open the editor
  • Expect to see the title and content placeholders

@geriux geriux marked this pull request as ready for review September 17, 2024 12:47
Copy link
Member

@dcalhoun dcalhoun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing succeeded for me. 🚀

ReactApp/src/components/Editor.jsx Show resolved Hide resolved
@geriux geriux merged commit 444de49 into trunk Sep 17, 2024
4 checks passed
@geriux geriux deleted the fix/editor-provider branch September 17, 2024 15:35
dcalhoun added a commit that referenced this pull request Sep 20, 2024
This appears to already be invoked by the `EditorProvider`. The
redundant invocation was likely erroneously left in place when we began
using the `EditorProvider` recently.

#24
https://github.com/WordPress/gutenberg/blob/219065c3be5881a68a8667fda9c04c7b7f546763/packages/editor/src/components/provider/index.js#L178
dcalhoun added a commit that referenced this pull request Sep 23, 2024
* fix: Remove redundant `getEditorSettings` invocation

This appears to already be invoked by the `EditorProvider`. The
redundant invocation was likely erroneously left in place when we began
using the `EditorProvider` recently.

#24
https://github.com/WordPress/gutenberg/blob/219065c3be5881a68a8667fda9c04c7b7f546763/packages/editor/src/components/provider/index.js#L178

* fix: Disable the editor sub-registry

Reinstate the editor singleton registry so that third-party blocks may
query the block editor state.
dcalhoun added a commit that referenced this pull request Dec 17, 2024
This largely reverts
#24, which resulted
in several regressions. Namely, oddities in the block toolbar emptying
and empty Patterns/Media tabs in the block inserter.

The previous changes was implemented to workaround an experimental API
that is no longer exported after
WordPress/gutenberg#64892. That remains an
issue, but the new workaround is to patch Gutenberg itself to export
this necessary API with `patch-package`.
dcalhoun added a commit that referenced this pull request Dec 17, 2024
This largely reverts
#24, which resulted
in several regressions. Namely, oddities in the block toolbar emptying
and empty Patterns/Media tabs in the block inserter.

The previous changes was implemented to workaround an experimental API
that is no longer exported after
WordPress/gutenberg#64892. That remains an
issue, but the new workaround is to patch Gutenberg itself to export
this necessary API with `patch-package`.
dcalhoun added a commit that referenced this pull request Dec 17, 2024
This largely reverts
#24, which resulted
in several regressions. Namely, oddities in the block toolbar emptying
and empty Patterns/Media tabs in the block inserter.

The previous changes was implemented to workaround an experimental API
that is no longer exported after
WordPress/gutenberg#64892. That remains an
issue, but the new workaround is to patch Gutenberg itself to export
this necessary API with `patch-package`.
dcalhoun added a commit that referenced this pull request Dec 17, 2024
This largely reverts
#24, which resulted
in several regressions. Namely, oddities in the block toolbar emptying
and empty Patterns/Media tabs in the block inserter.

The previous changes was implemented to workaround an experimental API
that is no longer exported after
WordPress/gutenberg#64892. That remains an
issue, but the new workaround is to patch Gutenberg itself to export
this necessary API with `patch-package`.
dcalhoun added a commit that referenced this pull request Dec 17, 2024
This largely reverts
#24, which resulted
in several regressions. Namely, oddities in the block toolbar emptying
and empty Patterns/Media tabs in the block inserter.

The previous changes was implemented to workaround an experimental API
that is no longer exported after
WordPress/gutenberg#64892. That remains an
issue, but the new workaround is to patch Gutenberg itself to export
this necessary API with `patch-package`.
dcalhoun added a commit that referenced this pull request Dec 18, 2024
* build: Add patch-package

* build: Configure patch-package

* fix: Replace unsupported editor architecture

This largely reverts
#24, which resulted
in several regressions. Namely, oddities in the block toolbar emptying
and empty Patterns/Media tabs in the block inserter.

The previous changes was implemented to workaround an experimental API
that is no longer exported after
WordPress/gutenberg#64892. That remains an
issue, but the new workaround is to patch Gutenberg itself to export
this necessary API with `patch-package`.

* fix: Disable interception `blob:` URLs leading to an Android crash

While the reason for why the `blob:` requests trigger is unknown, they
originate when utilizing the block inserter's Patterns tab. The requests
seemingly originate from the embedded editor previews rendered for each
pattern.
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.

2 participants