@wordpress/block-library
Version:
Block library for the WordPress editor.
73 lines (69 loc) • 2.26 kB
JavaScript
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = CommentsLegacy;
var _clsx = _interopRequireDefault(require("clsx"));
var _blockEditor = require("@wordpress/block-editor");
var _i18n = require("@wordpress/i18n");
var _components = require("@wordpress/components");
var _placeholder = _interopRequireDefault(require("./placeholder"));
var _jsxRuntime = require("react/jsx-runtime");
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function CommentsLegacy({
attributes,
setAttributes,
context: {
postType,
postId
}
}) {
const {
textAlign
} = attributes;
const actions = [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
__next40pxDefaultSize: true,
onClick: () => void setAttributes({
legacy: false
}),
variant: "primary",
children: (0, _i18n.__)('Switch to editable mode')
}, "convert")];
const blockProps = (0, _blockEditor.useBlockProps)({
className: (0, _clsx.default)({
[`has-text-align-${textAlign}`]: textAlign
})
});
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_blockEditor.BlockControls, {
group: "block",
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_blockEditor.AlignmentControl, {
value: textAlign,
onChange: nextAlign => {
setAttributes({
textAlign: nextAlign
});
}
})
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
...blockProps,
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_blockEditor.Warning, {
actions: actions,
children: (0, _i18n.__)('Comments block: You’re currently using the legacy version of the block. ' + 'The following is just a placeholder - the final styling will likely look different. ' + 'For a better representation and more customization options, ' + 'switch the block to its editable mode.')
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_placeholder.default, {
postId: postId,
postType: postType
})]
})]
});
}
//# sourceMappingURL=comments-legacy.js.map
;