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

Add document-level controls and instant preview #16641

Closed
mor10 opened this issue Jul 17, 2019 · 2 comments
Closed

Add document-level controls and instant preview #16641

mor10 opened this issue Jul 17, 2019 · 2 comments
Labels
[Feature] Extensibility The ability to extend blocks or the editing experience Needs Technical Feedback Needs testing from a developer perspective. [Type] Enhancement A suggestion for improvement.

Comments

@mor10
Copy link
Contributor

mor10 commented Jul 17, 2019

Feature request

Provide an API / method for manipulating document-level elements and providing instant preview of these manipulations within the block editor and eventually in whatever space document-level controls will live.

Rationale

Theme authors may want to provide the author with document-level controls like color palettes that apply to entire posts/pages/views on an individual basis. This scenario is already relevant (see BinaryMoon/jarvis#11) and will become more relevant as blocks migrate beyond the block editor to the full view.

Example scenario

A theme provides a post/page palette option in the document-level controls. When selected, a new class is appended to a top-level element (.editor-styles-wrapper element in the editor, <body> or other element on the front end) and CSS kicks in to restyle whatever content exists below that element in the DOM tree.

Current challenges

While adding controls for this type of feature can be done using metaboxes or the new SlotFills, and data from such controls can be captured in post meta and used on the front-end, there is (to my knowledge) no straight-forward way to get an instant preview of such DOM manipulations within the block editor. The workaround is to use an EventListener to target elements on setting change, but this is hacky and prone to error.

Proposed solution

Having a similar framework to how blocks are instantly previewed on setting change would be great. Providing one cohesive model for creating controls, capturing their data, and previewing the result in the editor context ensures developers don't come up with a myriad of different hacky ways of doing this which stand in the way of document-level manipulations in the future.

Related

BinaryMoon/jarvis#11 (comment)
https://developer.wordpress.org/block-editor/tutorials/plugin-sidebar-0/

@chrisvanpatten
Copy link
Member

The specific example to add a CSS class to the document wrapper relates to:

I know that doesn't cover the full scope of the issue but I wanted to share some extra context.

@swissspidy swissspidy added [Type] Enhancement A suggestion for improvement. [Feature] Extensibility The ability to extend blocks or the editing experience Needs Technical Feedback Needs testing from a developer perspective. labels Jul 18, 2019
@mtias
Copy link
Member

mtias commented Aug 30, 2020

This is largely the scope of the styling project at #20331 — it should allow most of these interactions but one crucial difference is it doesn't rely on wrapper class names (classes being an implementation detail) to ensure the system can work across platforms, including native mobile.

@mtias mtias closed this as completed Aug 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Extensibility The ability to extend blocks or the editing experience Needs Technical Feedback Needs testing from a developer perspective. [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

4 participants