-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Description
I wanted to raise some concerns I have with the implementation of #13203/#19082 and editor styling in general.
The current implementation partially addresses responsiveness issues by simulating media queries. It seems using an iframe element was briefly on the table, but considered technically too difficult. I’m not sure if those concerns are valid.
Specifically, to maintain interactions in the iframe (modifying blocks), I would imagine there would need to be some communication layer to maintain state between the top-level editor and the iframe'd content.
I don’t think any special communication layer is needed. We can just render the blocks though a portal. I briefly tested this, and moving the blocks, for example, works perfectly fine. See #20797 (comment).
I’m not sure if anyone had any other concerns with iframes. I know iframes are controversial, but they do effectively sandbox all CSS within the editor canvas.
- There would be no admin CSS bleed at all. This is something we’ve been struggling with since the beginning.
- There would be no need to simulate media queries, which is arguably technically more difficult than using an iframe.
- Relative units like
(r)em
andvw
/vh
just work. - For a full site, a theme stylesheet can be just dropped in the editor without any adjustment. I think this is important as it makes the life of theme authors much easier.
- It's possible to have one selection per window, so one in the admin and one in the content. This is useful for e.g. the link UI where the selection in the content can be kept while the selection is also in an input element (for the URL). Maybe be useful in other cases.
I only see a small amount of technical challenges to overcome:
- Loading the correct styles in the iframe should be easy enough.
- We’ll need to adjust positioning of popovers, but I think this is not a big issue.
- We need to make sure can can seamlessly navigate from the edit UI to the editor canvas, but I think this is also not a big deal.
I would love your opinions @jasmussen, @youknowriad, @aduth, @mcsf, @mapk, @ItsJonQ, @kjellr, @tellthemachines, @jorgefilipecosta, and @MichaelArestad.