import { createDocument } from "../helpers/create-document.js";
const setContent = (content, emitUpdate = false, parseOptions = {}, options = {}) => ({ editor, tr, dispatch, commands }) => {
  const { doc } = tr;
  if (parseOptions.preserveWhitespace !== "full") {
    const document = createDocument(content, editor.schema, parseOptions, {
      errorOnInvalidContent: options.errorOnInvalidContent ?? editor.options.enableContentCheck
    });
    if (dispatch) {
      tr.replaceWith(0, doc.content.size, document).setMeta("preventUpdate", !emitUpdate);
    }
    return true;
  }
  if (dispatch) {
    tr.setMeta("preventUpdate", !emitUpdate);
  }
  return commands.insertContentAt({ from: 0, to: doc.content.size }, content, {
    parseOptions,
    errorOnInvalidContent: options.errorOnInvalidContent ?? editor.options.enableContentCheck
  });
};
export {
  setContent
};
//# sourceMappingURL=set-content.js.map
