-
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
Consider iframing the editor canvas/content #20797
Comments
@ellatrix Haii!! I think using iFrames is a creative solution! It definitely addresses all the issues you pointed out. For example, there's a reason why a lot of the embeddable live chat/help apps (e.g. Intercom, Help Scout, etc...) use iFrames 💪 It's a challenge, but I don't think it's impossible. Very interested to hear what others think :) |
Thanks for reading. :) I don't think it's as challenging as we might assume. Trying to solve all the issues we have seems more challenging to me without the use of an iframe. With an iframe all these things will work by itself. |
What happens when you open a modal from a block (Media Library or something else). |
@youknowriad It would open in the main window (thanks to the React portal). Here's a demo. Please ignore the unstyled content. :) |
I approve the gif inserted in the demo 🐻 ❤️ |
I'm not sure what that means exactly? How would that work? |
@youknowriad Something like this: const Iframe = ( { children, ...props } ) => {
const [ contentRef, setContentRef ] = useState();
const mountNode = contentRef && contentRef.contentWindow.document.body;
return (
<iframe { ...props } ref={ setContentRef }>
{ mountNode && createPortal( children, mountNode ) }
</iframe>
);
};
// ... and then:
<Iframe>
<EditorContent />
</Iframe> |
mmm! interesting. I believe we should definitely explore this in a PR and figure out the shortcomings. |
@youknowriad Yes, I think so too! I just wanted to quickly sanity check this with you all so I'm not overlooking some major thing. |
For me, the popovers/modals had always been the main issue here... especially as we don't know how third-party blocks could be creating these. |
This seems too good to be true. I absolutely would love to go this route as it resolves a handful of CSS issues that have been a blocker for progress (or very difficult to work around) on various issues. It also seems less fragile than implementing some of the creative (and brilliant) media query parsing that has been done to simulate media queries for device previews. |
If we can make this transparent while retaining all the UX details we have crafted so far, I'm all for it. |
Echoing this! Assuming this works, and works reliably, this seems like it could be a great path to aligning the edit UI and the front-end styling even further. |
@mtias yes you wouldn’t notice the iframe at all if the editor styles are loaded etc. I’ll work on a proof of concept tomorrow. |
@ellatrix I'm so excited for this 😍 !! Good luck! |
:keanu-whoah: |
Did it work out? :) |
I had unfortunately fallen ill the night after my last comment, so I haven't make any progress. Might have a look today or tomorrow since I'm doing better now. |
@ellatrix ok. Take care! |
If this works, perhaps this could also lead to #9129 being fixed? |
What's the progress on this? And am I right in thinking that if the editor is essentially an iframe then the front-end stylesheet can be loaded as-is with there being minimal overhead in getting the editor canvas to look just like the front-end? |
Any update on this? |
Since FSE now ships with this change, how close are we to implementing this in the post editor? This could be a huge win for theme editors. |
We still need to do a proper evaluation of the stability of the iframe in the site editor and any remaining issues. One difficulty is that — by its nature — the site editor receives a lot less sustained testing in the way the post editor does, particularly with third-party blocks. But hopefully we can enable it soon as an option to cover more ground. |
I may have run into an issue with the iframe in the site editor that was reported by Anne #29457 (comment) |
I'm exploring a fix in #29573. This PR would be great for the iframe in general as we're avoiding the need to access the right document by replacing it with React refs. After that, I'll resume work on iframing the post editor, but it's tough to continually fix the e2e tests on the PR, figure out backward compatibility etc. It will needs some collaboration and communication with plugin authors. |
@ellatrix I work with the Atomic Blocks and Genesis Blocks team. Is there anything we can do to help with this? |
Editing to be more to the point as davidwebca points out i was complaining and not being constructive: i think taking a system that is already in production on many thousands of sites, and then totally overhauling it to use a completely different backbone is a bad idea. i think taking the entire editor and putting it inside an iframe will break a ton of plugins. i think my feelings represent that of many people, and we just wish updates were not forced, or better yet were optional, especially for anything that changes the framework of a page that was literally designed to be built on top of by developers. |
First if you would read about the actual content of the issue and discussion that's been going on, it won't break anything since it's just an iframe wrapper, mostly to guarantee that media queries will be respected correctly. Second, there are plenty of ways to provide feedback and I can guarantee you that the WP core team listens to all, but they also have to make decisions about what's best for most of the people. Not saying they're always right, but this is clearly not the place for that kind of complaint unless you really have something constructive to add to the iframe conversation. Move on. |
this
and this either of these 2 ideas would solve my concerns |
@ellatrix I realized I didn't reply your question, better late than never! 😁 Thanks for patience.
I meant having a filter to turn the content iframe on for good ol' post/page editor, without enabling it for everyone by default. I believe that would allow more controlled testing (think agencies, personal sites, opinionated site-builders on top of WordPress) and ease a bit @mtias' worries:
|
I just learned that iframed content was enabled in mobile & tablet previews already: #33342 —that's fantastic idea that hopefully exposed the iframe to more testing. :-) |
Curious to know if there's an ETA on this? I remember following this issue to get notifications about this conversation and there's still lots of specificity issues with CSS added to the admin, especially with FSE, that makes it very frustrating for theme devs. |
New PR: #46212. |
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.
(#13203 (comment))
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.
(r)em
andvw
/vh
just work.I only see a small amount of technical challenges to overcome:
I would love your opinions @jasmussen, @youknowriad, @aduth, @mcsf, @mapk, @ItsJonQ, @kjellr, @tellthemachines, @jorgefilipecosta, and @MichaelArestad.
The text was updated successfully, but these errors were encountered: