import { jsxs, jsx } from "react/jsx-runtime";
import { EditorBlockBoundary } from "@contember/ui";
import { memo } from "react";
import { useSlateStatic, ReactEditor } from "slate-react";
import { useMessageFormatter } from "@contember/react-i18n";
import { ContemberEditor } from "../ContemberEditor/index.js";
import { editorDictionary } from "./editorDictionary.js";
const BlockElement = memo(function BlockElement2({
  element,
  children,
  attributes,
  domElement = "div",
  withBoundaries = false
}) {
  const editor = useSlateStatic();
  const dataAttributes = ContemberEditor.getElementDataAttributes(element);
  const El = domElement;
  const formatter = useMessageFormatter(editorDictionary);
  return /* @__PURE__ */ jsxs(El, { ...dataAttributes, ...attributes, children: [
    withBoundaries && /* @__PURE__ */ jsx(
      EditorBlockBoundary,
      {
        blockEdge: "before",
        newParagraphText: formatter("editorBlock.editorBlockBoundary.newParagraph"),
        onClick: () => {
          const elementPath = ReactEditor.findPath(editor, element);
          editor.insertBetweenBlocks([element, elementPath], "before");
        }
      }
    ),
    children,
    withBoundaries && /* @__PURE__ */ jsx(
      EditorBlockBoundary,
      {
        blockEdge: "after",
        newParagraphText: formatter("editorBlock.editorBlockBoundary.newParagraph"),
        onClick: () => {
          const elementPath = ReactEditor.findPath(editor, element);
          editor.insertBetweenBlocks([element, elementPath], "after");
        }
      }
    )
  ] });
});
export {
  BlockElement
};
//# sourceMappingURL=BlockElement.js.map
