-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Custom HTML Block: apply editor-styles to preview mode. #13080
Custom HTML Block: apply editor-styles to preview mode. #13080
Conversation
return { | ||
styles: [], | ||
}; | ||
} ), |
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 code is not the fastest one and the main issue is that it will be executed on each subscribe (on each state change). Should we mirror how it's done in the EditorProvider
component (when mounting the component)?
Also there's some duplication between these two components. Do you think we can extract the logic somehow?
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.
Does it mean you need to cache styles?
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 mean just compute the styles
prop on initial mount of the component, store it as state or something and avoid computing it on each render.
@youknowriad I think fixed problem. Cached computed styles. |
Thanks for the update @torounit This works. I'd prefer if we avoid the global variable though and tie it to the component. Something like this In fact the logic is the same and should probably be extracted to a utility. |
@youknowriad |
Changes are great. I'd still prefer to avoid the I'll add more reviewers here. I'm mostly happy with this change, I think we're very close. |
how about latest update ? |
Hi @torounit I pushed a small update, I hope you don't mind. Let me know what you think. @jasmussen how this looks for you? |
Judging purely by the screenshot, this seems pretty good to me, 👍 👍 |
👍 |
Description
Apply Editor Styles for custom html block preview.
urlRewrite
,traverse
,wrap
in@wordpress/editor
.css
prop to<Sandbox>
Screenshots
before
after
theme: Twenty Nineteen.
Types of changes
Checklist: