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.2k forks source link

Image block: Add the ability to disable resizing from external #60690

Open jasperck opened 7 months ago

jasperck commented 7 months ago

What problem does this address?

It seems like it is impossible to remove ResizeBox from the Image block from external, I tried allowResize in provideContext which is the pattern in Gutenberg Gallery block, however, it requires me to wrap the Image block with another layer of component, otherwise, it won't work. I think it’s overkill in this case because now we need an extra custom block to wrap the Image block just for the context.

What is your proposed solution?

I'm thinking of adding a new attribute so we can enable/disable resizing from external.

disableResize: {
    "type": "boolean",
    "default": false,
}
youknowriad commented 7 months ago

Thanks for the issue.

I don't think you need an extra custom block to wrap the image block to define that context. You can probably wrap your whole editor with BlockContextProvider and provide the context value to disable resizing globally.

traed commented 5 months ago

@youknowriad Can you provide an example of how this could be done?