WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.5k stars 4.19k forks source link

Detect iframed editor before enabling Zoom Out feature #65311

Closed getdave closed 1 month ago

getdave commented 1 month ago

We need to detect that the Editor is iframed before we enable/expose the Zoom Out feature to users (even if it's still behind an experiment).


@getdave The easiest step is to enable custom fields, but that might be an issue we already had when the zoom out mode toggle was in a dropdown.

https://github.com/user-attachments/assets/de1237c1-caab-4661-8f13-d44306ee11b8

Originally posted by @t-hamano in https://github.com/WordPress/gutenberg/issues/65183#issuecomment-2348351661

getdave commented 1 month ago

@t-hamano if you know how to detect whether the editor is iframed please do let me know otherwise we'll look into it.

t-hamano commented 1 month ago

I haven't explored this in depth yet, but what about forcing an iframe in zoomed-out mode, just like the mobile and tablet views do?

Perhaps it would be a good idea to add a condition __unstableGetEditorMode() === 'zoom-out' to either:

https://github.com/WordPress/gutenberg/blob/7f5e6b215939d043a247ade9b463ed51c125b5c0/packages/editor/src/components/visual-editor/index.js#L359-L360

https://github.com/WordPress/gutenberg/blob/7f5e6b215939d043a247ade9b463ed51c125b5c0/packages/edit-post/src/components/layout/index.js#L347

t-hamano commented 1 month ago

Update: #64351 has been merged, so the logic that determines whether the editor should run as an iframe has been updated. This means that the presence of custom fields/meta boxes is no longer tied to whether the editor is iframed or not.

One way to reproduce this issue is to have the Classic theme and the Jetpack plugin enabled. The Jetpack plugin has custom blocks that are not version 3, which is what prevents the editor from running as an iframe.

draganescu commented 1 month ago

I wonder if we should just disable the experience if there is no iframe?

getdave commented 1 month ago

I wonder if we should just disable the experience if there is no iframe?

Yes. That's the purpose of the Issue so I say 👍