@wordpress/block-library
Version:
Block library for the WordPress editor.
254 lines (253 loc) • 7.81 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 clsx = require("clsx");
clsx = __toESM(clsx);
let _wordpress_block_editor = require("@wordpress/block-editor");
let react_jsx_runtime = require("react/jsx-runtime");
// packages/block-library/src/group/deprecated.jsx
const migrateAttributes = (attributes) => {
if (!attributes.tagName) attributes = {
...attributes,
tagName: "div"
};
if (!attributes.customTextColor && !attributes.customBackgroundColor) return attributes;
const style = { color: {} };
if (attributes.customTextColor) style.color.text = attributes.customTextColor;
if (attributes.customBackgroundColor) style.color.background = attributes.customBackgroundColor;
const { customTextColor, customBackgroundColor, ...restAttributes } = attributes;
return {
...restAttributes,
style
};
};
const deprecated = [
{
attributes: {
tagName: {
type: "string",
default: "div"
},
templateLock: {
type: ["string", "boolean"],
enum: [
"all",
"insert",
false
]
}
},
supports: {
__experimentalOnEnter: true,
__experimentalSettings: true,
align: ["wide", "full"],
anchor: true,
ariaLabel: true,
html: false,
color: {
gradients: true,
link: true,
__experimentalDefaultControls: {
background: true,
text: true
}
},
spacing: {
margin: ["top", "bottom"],
padding: true,
blockGap: true,
__experimentalDefaultControls: {
padding: true,
blockGap: true
}
},
__experimentalBorder: {
color: true,
radius: true,
style: true,
width: true,
__experimentalDefaultControls: {
color: true,
radius: true,
style: true,
width: true
}
},
typography: {
fontSize: true,
lineHeight: true,
__experimentalFontStyle: true,
__experimentalFontWeight: true,
__experimentalLetterSpacing: true,
__experimentalTextTransform: true,
__experimentalDefaultControls: { fontSize: true }
},
layout: true
},
save({ attributes: { tagName: Tag } }) {
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Tag, { ..._wordpress_block_editor.useInnerBlocksProps.save(_wordpress_block_editor.useBlockProps.save()) });
},
isEligible: ({ layout }) => layout?.inherit || layout?.contentSize && layout?.type !== "constrained",
migrate: (attributes) => {
const { layout = null } = attributes;
if (layout?.inherit || layout?.contentSize) return {
...attributes,
layout: {
...layout,
type: "constrained"
}
};
}
},
{
attributes: {
tagName: {
type: "string",
default: "div"
},
templateLock: {
type: ["string", "boolean"],
enum: [
"all",
"insert",
false
]
}
},
supports: {
align: ["wide", "full"],
anchor: true,
color: {
gradients: true,
link: true
},
spacing: { padding: true },
__experimentalBorder: { radius: true }
},
save({ attributes }) {
const { tagName: Tag } = attributes;
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Tag, {
..._wordpress_block_editor.useBlockProps.save(),
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
className: "wp-block-group__inner-container",
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_block_editor.InnerBlocks.Content, {})
})
});
}
},
{
attributes: {
backgroundColor: { type: "string" },
customBackgroundColor: { type: "string" },
textColor: { type: "string" },
customTextColor: { type: "string" }
},
supports: {
align: ["wide", "full"],
anchor: true,
html: false
},
migrate: migrateAttributes,
save({ attributes }) {
const { backgroundColor, customBackgroundColor, textColor, customTextColor } = attributes;
const backgroundClass = (0, _wordpress_block_editor.getColorClassName)("background-color", backgroundColor);
const textClass = (0, _wordpress_block_editor.getColorClassName)("color", textColor);
const className = (0, clsx.default)(backgroundClass, textClass, {
"has-text-color": textColor || customTextColor,
"has-background": backgroundColor || customBackgroundColor
});
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
className,
style: {
backgroundColor: backgroundClass ? void 0 : customBackgroundColor,
color: textClass ? void 0 : customTextColor
},
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
className: "wp-block-group__inner-container",
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_block_editor.InnerBlocks.Content, {})
})
});
}
},
{
attributes: {
backgroundColor: { type: "string" },
customBackgroundColor: { type: "string" },
textColor: { type: "string" },
customTextColor: { type: "string" }
},
migrate: migrateAttributes,
supports: {
align: ["wide", "full"],
anchor: true,
html: false
},
save({ attributes }) {
const { backgroundColor, customBackgroundColor, textColor, customTextColor } = attributes;
const backgroundClass = (0, _wordpress_block_editor.getColorClassName)("background-color", backgroundColor);
const textClass = (0, _wordpress_block_editor.getColorClassName)("color", textColor);
const className = (0, clsx.default)(backgroundClass, {
"has-text-color": textColor || customTextColor,
"has-background": backgroundColor || customBackgroundColor
});
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
className,
style: {
backgroundColor: backgroundClass ? void 0 : customBackgroundColor,
color: textClass ? void 0 : customTextColor
},
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
className: "wp-block-group__inner-container",
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_block_editor.InnerBlocks.Content, {})
})
});
}
},
{
attributes: {
backgroundColor: { type: "string" },
customBackgroundColor: { type: "string" }
},
supports: {
align: ["wide", "full"],
anchor: true,
html: false
},
migrate: migrateAttributes,
save({ attributes }) {
const { backgroundColor, customBackgroundColor } = attributes;
const backgroundClass = (0, _wordpress_block_editor.getColorClassName)("background-color", backgroundColor);
const className = (0, clsx.default)(backgroundClass, { "has-background": backgroundColor || customBackgroundColor });
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
className,
style: { backgroundColor: backgroundClass ? void 0 : customBackgroundColor },
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_block_editor.InnerBlocks.Content, {})
});
}
}
];
exports.default = deprecated;
//# sourceMappingURL=deprecated.cjs.map