// packages/block-library/src/verse/edit.js
import clsx from "clsx";
import { __ } from "@wordpress/i18n";
import {
  RichText,
  BlockControls,
  AlignmentToolbar,
  useBlockProps
} from "@wordpress/block-editor";
import { createBlock, getDefaultBlockName } from "@wordpress/blocks";
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
function VerseEdit({
  attributes,
  setAttributes,
  mergeBlocks,
  onRemove,
  insertBlocksAfter,
  style
}) {
  const { textAlign, content } = attributes;
  const blockProps = useBlockProps({
    className: clsx({
      [`has-text-align-${textAlign}`]: textAlign
    }),
    style
  });
  return /* @__PURE__ */ jsxs(Fragment, { children: [
    /* @__PURE__ */ jsx(BlockControls, { children: /* @__PURE__ */ jsx(
      AlignmentToolbar,
      {
        value: textAlign,
        onChange: (nextAlign) => {
          setAttributes({ textAlign: nextAlign });
        }
      }
    ) }),
    /* @__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,
        textAlign,
        ...blockProps,
        __unstablePastePlainText: true,
        __unstableOnSplitAtDoubleLineEnd: () => insertBlocksAfter(createBlock(getDefaultBlockName()))
      }
    )
  ] });
}
export {
  VerseEdit as default
};
//# sourceMappingURL=edit.js.map
