-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Unable to add CSS class names to editor iframe #56831
Comments
See #17854 and gutenberg/packages/block-editor/src/components/iframe/index.js Lines 144 to 152 in cad8fae
The solution is to use the |
Reopening as there should be a more logical way to do this. |
I'm just throwing this out there without much thought, so it might be irrelevant or useless. The comment above says:
I wonder if it'd be okay to inject the return value of body_class() in |
Description
I'm attempting to add CSS class names to the new iframe in the editor using JavaScript. The aim is to apply a user-selected accent colour in the editor.
I've only been able to do so using an overly-complicated combination of MutationObserver (to detect when the iframe becomes available) and a setInterval to repeatedly try to apply the class name until it sticks. This seems to be unnecessarily complex. Is there a better solution?
I've tried to add the class names using the
admin_body_class
hook in PHP, but this doesn't feel right (as it's PHP) and it also only appears to work on the mainbody
(which doesn't help, as it's hidden by the iframe).Step-by-step reproduction instructions
See the code example.
Screenshots, screen recording, code snippet
https://gist.github.com/markhowellsmead/01c8c29937162e93a11e21c8209872d1
Environment info
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
The text was updated successfully, but these errors were encountered: