@wordpress/block-library
Version:
Block library for the WordPress editor.
45 lines (44 loc) • 1.24 kB
JavaScript
// packages/block-library/src/verse/edit.js
import { __ } from "@wordpress/i18n";
import { RichText, useBlockProps } from "@wordpress/block-editor";
import { createBlock, getDefaultBlockName } from "@wordpress/blocks";
import useDeprecatedTextAlign from "../utils/deprecated-text-align-attributes.mjs";
import { jsx } from "react/jsx-runtime";
function VerseEdit(props) {
const {
attributes,
setAttributes,
mergeBlocks,
onRemove,
insertBlocksAfter,
style
} = props;
const { content } = attributes;
useDeprecatedTextAlign(props);
const blockProps = useBlockProps({ style });
return /* @__PURE__ */ jsx(
RichText,
{
tagName: "pre",
identifier: "content",
preserveWhiteSpace: true,
value: content,
onChange: (nextContent) => {
setAttributes({
content: nextContent
});
},
"aria-label": __("Verse text"),
placeholder: __("Write verse\u2026"),
onRemove,
onMerge: mergeBlocks,
...blockProps,
__unstablePastePlainText: true,
__unstableOnSplitAtDoubleLineEnd: () => insertBlocksAfter(createBlock(getDefaultBlockName()))
}
);
}
export {
VerseEdit as default
};
//# sourceMappingURL=edit.mjs.map