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

Update dynamically on post types that use the Block Editor #28

Open
mogmarsh opened this issue Jun 21, 2024 · 2 comments
Open

Update dynamically on post types that use the Block Editor #28

mogmarsh opened this issue Jun 21, 2024 · 2 comments
Labels
enhancement New feature or request gutenberg Requires understanding Gutenberg javascript Requires understanding JavaScript

Comments

@mogmarsh
Copy link

mogmarsh commented Jun 21, 2024

Description

On post types that use the Block Editor (Gutenberg), it would be useful if the inspector reflected the Post Editor's data.

Use Case

Currently in the Block Editor, you must Save the post, then refresh to see the latest meta data.

Acceptance Criteria

  • When displayed in Gutenberg, show using a Gutenberg PluginSidebar instead of a classic metabox.
  • Create the PluginSidebar to display all meta.
  • Each meta field should be in a collapsible panel so it isn't overwhelming.
  • Add a custom REST endpoint to query all post meta, even the meta values that aren't exposed to the Block Editor. This MUST be locked down to only logged in users who have the ability to edit the post for which the data is requested (since they would otherwise be able to see this using the classic editor metabox).
  • The sidebar should use usePostMeta to get a value that has been updated by the Block Editor, and fail back to the value from the REST endpoint. Further, a visual indicator should display whether a value has been modified in the current edit session, indicating what is different between the editor view and what is saved to the server.
  • Add a button to view meta values in a modal in addition to the sidebar, so that large meta values can be viewed more easily.
  • Add JSON Formatter - if a value is JSON, or expressed as JSON because it's a serialized array/object in PHP, pretty-print the JSON to make it easier to read.

Note to implementer: If desired, split out the AC into smaller tickets.

@mogmarsh mogmarsh added enhancement New feature or request gutenberg Requires understanding Gutenberg javascript Requires understanding JavaScript labels Jun 21, 2024
@mogmarsh
Copy link
Author

I've been discussing with @kevinfodness, and here's what we think this would look like:

  • add a PluginSidebar to display all meta. Each meta field can be in a collapsible panel so it isn't overwhelming. If the Block Editor is active, suppress the existing metabox.
  • add a custom REST endpoint to query all post meta, even the meta values that aren't exposed to the Block Editor. This MUST be locked down.
  • The sidebar should use usePostMeta to get a value that has been updated by the Block Editor, and fail back to the value from the REST endpoint.

Bonus points:

  • Add a button to view meta values in a modal in addition to the sidebar, so that large meta values can be viewed easier
  • Add JSON Formatter - if a value is JSON, or expressed as JSON because it's a serialized array/object in PHP, pretty-print the JSON to make it easier to read

@kevinfodness
Copy link
Member

I'd recommend splitting the implementation steps into separate issues so that we can ship something initially that swaps the metabox for a PluginSidebar that shows meta visible to/managed by the editor, then iterates on that solution by adding the hidden meta, adding an open in a modal button, and adding the JSON prettifier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request gutenberg Requires understanding Gutenberg javascript Requires understanding JavaScript
Projects
None yet
Development

No branches or pull requests

2 participants