@wordpress/block-library
Version:
Block library for the WordPress editor.
83 lines (82 loc) • 3.55 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 _wordpress_i18n = require("@wordpress/i18n");
let _wordpress_components = require("@wordpress/components");
let _wordpress_block_editor = require("@wordpress/block-editor");
let _wordpress_deprecated = require("@wordpress/deprecated");
_wordpress_deprecated = __toESM(_wordpress_deprecated);
let react_jsx_runtime = require("react/jsx-runtime");
// packages/block-library/src/text-columns/edit.jsx
function TextColumnsEdit({ attributes, setAttributes }) {
const { width, content, columns } = attributes;
(0, _wordpress_deprecated.default)("The Text Columns block", {
since: "5.3",
alternative: "the Columns block"
});
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_block_editor.BlockControls, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_block_editor.BlockAlignmentToolbar, {
value: width,
onChange: (nextWidth) => setAttributes({ width: nextWidth }),
controls: [
"center",
"wide",
"full"
]
}) }),
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_block_editor.InspectorControls, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.PanelBody, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.RangeControl, {
label: (0, _wordpress_i18n.__)("Columns"),
value: columns,
onChange: (value) => setAttributes({ columns: value }),
min: 2,
max: 4,
required: true
}) }) }),
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
...(0, _wordpress_block_editor.useBlockProps)({ className: `align${width} columns-${columns}` }),
children: Array.from({ length: columns }).map((_, index) => {
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
className: "wp-block-column",
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_block_editor.RichText, {
tagName: "p",
value: content?.[index]?.children,
onChange: (nextContent) => {
setAttributes({ content: [
...content.slice(0, index),
{ children: nextContent },
...content.slice(index + 1)
] });
},
"aria-label": (0, _wordpress_i18n.sprintf)((0, _wordpress_i18n.__)("Column %d text"), index + 1),
placeholder: (0, _wordpress_i18n.__)("New Column")
})
}, `column-${index}`);
})
})
] });
}
exports.default = TextColumnsEdit;
//# sourceMappingURL=edit.cjs.map