import { NodeSelection } from "./../../tiptap/pm/state.js";
import { findNodeById } from "../helpers/index.js";
const replaceNode = (node) => ({ tr, editor, commands }) => {
  const id = node?.attrs?.id;
  const nodesWithPos = findNodeById(tr, id);
  if (nodesWithPos.length > 0) {
    const { pos } = nodesWithPos[0];
    const { from, to } = NodeSelection.create(editor.view.state.doc, pos);
    return commands.insertContentAt({ from, to }, node, {
      updateSelection: false
    });
  } else {
    console.error("Failed to find node by id");
    return false;
  }
};
export {
  replaceNode
};
//# sourceMappingURL=replace-node.js.map
