@wordpress/block-library
Version:
Block library for the WordPress editor.
128 lines (127 loc) • 3.58 kB
JavaScript
;
Object.defineProperties(exports, {
__esModule: { value: true },
[Symbol.toStringTag]: { value: "Module" }
});
// \0rolldown/runtime.js
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
key = keys[i];
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
get: ((k) => from[k]).bind(null, key),
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
});
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
value: mod,
enumerable: true
}) : target, mod));
let __block_json = require("./block.json");
__block_json = __toESM(__block_json);
// packages/block-library/src/latest-posts/deprecated.js
const 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 }
};
const legacyLayoutAttributes = {
postLayout: {
type: "string",
default: "list"
},
columns: {
type: "number",
default: 3
}
};
const migrateCategories = (oldAttributes) => {
if (!oldAttributes.categories || "string" !== typeof oldAttributes.categories) return oldAttributes;
return {
...oldAttributes,
categories: [{ id: Number(oldAttributes.categories) }]
};
};
const 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: {
...__block_json.default.attributes,
...legacyLayoutAttributes,
categories: { type: ["array", "string"] }
},
supports: currentSupports,
migrate: (oldAttributes) => migratePostLayout(migrateCategories(oldAttributes)),
isEligible: ({ postLayout }) => postLayout,
save: () => null
}, {
attributes: {
...__block_json.default.attributes,
categories: { type: "string" }
},
supports: {
align: true,
html: false
},
migrate: migrateCategories,
isEligible: ({ categories }) => categories && "string" === typeof categories,
save: () => null
}];
exports.default = deprecated_default;
//# sourceMappingURL=deprecated.cjs.map