UNPKG

@wordpress/block-library

Version:
62 lines (61 loc) • 1.55 kB
"use strict"; Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } }); // packages/block-library/src/block/deprecated.js const isObject = (obj) => typeof obj === "object" && !Array.isArray(obj) && obj !== null; var deprecated_default = [{ attributes: { ref: { type: "number" }, content: { type: "object" } }, supports: { customClassName: false, html: false, inserter: false, renaming: false }, isEligible({ content }) { return !!content && Object.keys(content).every((contentKey) => content[contentKey].values && isObject(content[contentKey].values)); }, migrate(attributes) { const { content, ...retainedAttributes } = attributes; if (content && Object.keys(content).length) { const updatedContent = { ...content }; for (const contentKey in content) updatedContent[contentKey] = content[contentKey].values; return { ...retainedAttributes, content: updatedContent }; } return attributes; } }, { attributes: { ref: { type: "number" }, overrides: { type: "object" } }, supports: { customClassName: false, html: false, inserter: false, renaming: false }, isEligible({ overrides }) { return !!overrides; }, migrate(attributes) { const { overrides, ...retainedAttributes } = attributes; const content = {}; Object.keys(overrides).forEach((id) => { content[id] = overrides[id]; }); return { ...retainedAttributes, content }; } }]; exports.default = deprecated_default; //# sourceMappingURL=deprecated.cjs.map