@wordpress/block-library
Version:
Block library for the WordPress editor.
122 lines (121 loc) • 2.69 kB
JavaScript
// packages/block-library/src/latest-posts/deprecated.js
import metadata from "./block.json";
var currentSupports = {
anchor: true,
align: true,
color: {
gradients: true,
link: true,
__experimentalDefaultControls: {
background: true,
text: true,
link: true
}
},
html: false,
layout: true,
spacing: {
margin: true,
padding: true,
blockGap: {
__experimentalDefault: "1.25em"
},
__experimentalDefaultControls: {
blockGap: true
}
},
typography: {
fontSize: true,
lineHeight: true,
__experimentalFontFamily: true,
__experimentalFontWeight: true,
__experimentalFontStyle: true,
__experimentalTextTransform: true,
__experimentalTextDecoration: true,
__experimentalLetterSpacing: true,
__experimentalDefaultControls: {
fontSize: true
}
},
__experimentalBorder: {
radius: true,
color: true,
width: true,
style: true,
__experimentalDefaultControls: {
radius: true,
color: true,
width: true,
style: true
}
},
interactivity: {
clientNavigation: true
}
};
var legacyLayoutAttributes = {
postLayout: {
type: "string",
default: "list"
},
columns: {
type: "number",
default: 3
}
};
var migrateCategories = (oldAttributes) => {
if (!oldAttributes.categories || "string" !== typeof oldAttributes.categories) {
return oldAttributes;
}
return {
...oldAttributes,
categories: [{ id: Number(oldAttributes.categories) }]
};
};
var migratePostLayout = (oldAttributes) => {
const { postLayout, columns, ...attributesWithoutLegacyLayout } = oldAttributes;
if (!postLayout) {
return oldAttributes;
}
return {
...attributesWithoutLegacyLayout,
layout: {
type: postLayout === "grid" ? "grid" : "default",
...postLayout === "grid" && columns && { columnCount: columns }
}
};
};
var deprecated_default = [
{
attributes: {
...metadata.attributes,
...legacyLayoutAttributes,
categories: {
type: ["array", "string"]
}
},
supports: currentSupports,
migrate: (oldAttributes) => migratePostLayout(migrateCategories(oldAttributes)),
isEligible: ({ postLayout }) => postLayout,
save: () => null
},
{
attributes: {
...metadata.attributes,
categories: {
type: "string"
}
},
supports: {
align: true,
html: false
},
migrate: migrateCategories,
isEligible: ({ categories }) => categories && "string" === typeof categories,
save: () => null
}
];
export {
deprecated_default as default
};
//# sourceMappingURL=deprecated.mjs.map