'Gutenberg deprecated attribute from because of changed type
I develop blocks with Gutenberg for WordPress. Now I've run into a problem where I needed to change my padding attribute from type string to type array. Before I had both padding_align (to save "top" or "bottom" as alignment options) and padding (padding size). Now we want to use an array with 4 sizes (each size for each alignment).
However now I need to deal with the deprecated padding and padding_align attributes. Does anyone know how I can hook in a function in which I can updates the old padding and padding_aling into the new one.
As soon as I open the page editor the old padding gets overwritten with the default value of the new padding.
Old attributes:
attributes: {
padding: {
type: "string"
},
padding_align: {
type: "string"
},
}
New attributes:
attributes: {
padding: {
type: "array",
default: ["disabled", "disabled", "disabled", "disabled"]
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
