-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Description
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 main body (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
- WordPress 6.4
- No plugins.
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