"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const react = require("react");
const Slate = require("slate");
const prepareElementForInsertion = require("../utils/prepareElementForInsertion.cjs");
const useInsertElementWithReference = ({ editor, createElementReference }) => {
  return react.useCallback((element, referenceDiscriminant, initialize) => {
    Slate.Editor.withoutNormalizing(editor, () => {
      const preppedPath = prepareElementForInsertion.prepareElementForInsertion(editor, element);
      Slate.Transforms.insertNodes(editor, editor.createDefaultElement([{ text: "" }]), { at: preppedPath });
      const referenceId = createElementReference(editor, preppedPath, referenceDiscriminant, initialize).id;
      const newNode = { ...element, referenceId };
      Slate.Transforms.setNodes(editor, newNode, { at: preppedPath });
    });
  }, [createElementReference, editor]);
};
exports.useInsertElementWithReference = useInsertElementWithReference;
//# sourceMappingURL=useInsertElementWithReference.cjs.map
