import { memo, createElement } from "react";
import { EditorBlockBoundary } from "@contember/ui";
import { useSlateStatic, ReactEditor } from "slate-react";
import { ContemberEditor } from "../ContemberEditor/index.js";
import { editorDictionary } from "./editorDictionary.js";
import { useMessageFormatter } from "../../../../i18n/useMessageFormatter.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__ */ createElement(El, {
    ...dataAttributes,
    ...attributes
  }, withBoundaries && /* @__PURE__ */ createElement(EditorBlockBoundary, {
    blockEdge: "before",
    newParagraphText: formatter("editorBlock.editorBlockBoundary.newParagraph"),
    onClick: () => {
      const elementPath = ReactEditor.findPath(editor, element);
      editor.insertBetweenBlocks([element, elementPath], "before");
    }
  }), children, withBoundaries && /* @__PURE__ */ createElement(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
