import { FLOATING_PROMPT_INPUT_MODAL_ID, FloatingPromptInput } from "./floating-prompt-input.js";
const openFloatingPromptInput = ({
  nodeId,
  editor,
  modals,
  getColorPalette
}) => {
  const { view } = editor;
  const rootLevelNodePosition = view.state.selection.$from.before(1);
  const nodeDOM = view.nodeDOM(rootLevelNodePosition);
  const referenceElement = nodeDOM instanceof Element ? nodeDOM : view.dom;
  try {
    if (rootLevelNodePosition > 0) {
      editor.commands.setTextSelection(rootLevelNodePosition - 1);
    }
  } catch (error) {
    console.error("Error selecting text before the node", error);
  }
  modals.openModal({
    id: FLOATING_PROMPT_INPUT_MODAL_ID,
    Component: FloatingPromptInput,
    componentProps: { nodeId, getColorPalette },
    type: "exclusive",
    layout: "manual",
    positioning: {
      placement: "bottom",
      referenceElement: {
        getBoundingClientRect: () => referenceElement.getBoundingClientRect(),
        focus: () => view.focus()
      }
    },
    returnFocusToEditor: true
  });
};
export {
  openFloatingPromptInput
};
//# sourceMappingURL=open-floating-prompt-input.js.map
