@wordpress/block-library
Version:
Block library for the WordPress editor.
96 lines (92 loc) • 3.07 kB
JavaScript
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _clsx = _interopRequireDefault(require("clsx"));
var _i18n = require("@wordpress/i18n");
var _blockEditor = require("@wordpress/block-editor");
var _blocks = require("@wordpress/blocks");
var _element = require("@wordpress/element");
var _figure = require("./figure");
var _blockquote = require("./blockquote");
var _jsxRuntime = require("react/jsx-runtime");
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
const isWebPlatform = _element.Platform.OS === 'web';
function PullQuoteEdit({
attributes,
setAttributes,
isSelected,
insertBlocksAfter
}) {
const {
textAlign,
citation,
value
} = attributes;
const blockProps = (0, _blockEditor.useBlockProps)({
className: (0, _clsx.default)({
[`has-text-align-${textAlign}`]: textAlign
})
});
const shouldShowCitation = !_blockEditor.RichText.isEmpty(citation) || isSelected;
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.jsx)(_figure.Figure, {
...blockProps,
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_blockquote.BlockQuote, {
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_blockEditor.RichText, {
identifier: "value",
tagName: "p",
value: value,
onChange: nextValue => setAttributes({
value: nextValue
}),
"aria-label": (0, _i18n.__)('Pullquote text'),
placeholder:
// translators: placeholder text used for the quote
(0, _i18n.__)('Add quote'),
textAlign: "center"
}), shouldShowCitation && /*#__PURE__*/(0, _jsxRuntime.jsx)(_blockEditor.RichText, {
identifier: "citation",
tagName: isWebPlatform ? 'cite' : undefined,
style: {
display: 'block'
},
value: citation,
"aria-label": (0, _i18n.__)('Pullquote citation text'),
placeholder:
// translators: placeholder text used for the citation
(0, _i18n.__)('Add citation'),
onChange: nextCitation => setAttributes({
citation: nextCitation
}),
className: "wp-block-pullquote__citation",
__unstableMobileNoFocusOnMount: true,
textAlign: "center",
__unstableOnSplitAtEnd: () => insertBlocksAfter((0, _blocks.createBlock)((0, _blocks.getDefaultBlockName)()))
})]
})
})]
});
}
var _default = exports.default = PullQuoteEdit;
//# sourceMappingURL=edit.js.map
;