Does anyone know if it's posssible to remove some of the default panels from the core blocks in gutenberg?
I'm thinking specifically of, the color palette panel (only on some blocks, like I don't want the user to be able to change colors on the buttons). or Button border radius... same with core/cover height.
I've tried almost everything I can think of, and wondering if I have to create my own custom blocks just for these small changes.
I tried experimenting with altering the block settings.supports object with some luck... I say some because I wasn't able to completely remove all the panels I wanted but did manage to remove things like color and typography panels like this.
Reference link(s)
import assign from "lodash.assign";
import { addFilter } from "@wordpress/hooks";
const extendOnBlocks = ["core/button"]; // replace with ["core/cover"]
const removeBlockPanels = (settings, name) => {
// Do nothing if it's another block than our defined ones.
if (!extendOnBlocks.includes(name)) {
return settings;
}
// Use Lodash's assign to gracefully handle if attributes are undefined
settings.supports = assign(settings.supports, {
__experimentalBorder: false,
typography: false,
color: false,
});
return settings;
};
addFilter(
"blocks.registerBlockType",
"my-button/attribute/options",
removeBlockPanels
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With