import React from "react";
import { NodeSelection } from "./../../tiptap/pm/state.js";
import classes from "./overlay-hoc-scss.js";
const OverlayHoc = (Component) => {
  const Overlay = (props) => {
    const { disabled } = props;
    return /* @__PURE__ */ React.createElement(
      "div",
      {
        className: disabled ? void 0 : classes.overlay,
        role: "none",
        onClick: () => {
          if (!disabled) {
            setSelection(props.editor, props.getPos);
          }
        }
      },
      /* @__PURE__ */ React.createElement(Component, { ...props })
    );
  };
  Overlay.displayName = "OverlayHoc";
  return Overlay;
};
const setSelection = (editor, getPos) => {
  const selection = NodeSelection.create(editor.view.state.doc, getPos());
  const transaction = editor.view.state.tr.setSelection(selection);
  editor.view.dispatch(transaction);
};
export {
  OverlayHoc
};
//# sourceMappingURL=overlay-hoc.js.map
