"use client";
import { useLexicalComposerContext as r } from "./LexicalComposerContext.prod.js";
import { CLEAR_EDITOR_COMMAND as i, $getRoot as s, $getSelection as l, $createParagraphNode as u, $isRangeSelection as c, COMMAND_PRIORITY_EDITOR as d } from "../../lexical/Lexical.prod.js";
import { useLayoutEffect as m, useEffect as f } from "react";
const p = typeof window < "u" && window.document !== void 0 && window.document.createElement !== void 0 ? m : f;
function w({ onClear: e }) {
  const [o] = r();
  return p((() => o.registerCommand(i, ((C) => (o.update((() => {
    if (e == null) {
      const n = s(), t = l(), a = u();
      n.clear(), n.append(a), t !== null && a.select(), c(t) && (t.format = 0);
    } else e();
  })), !0)), d)), [o, e]), null;
}
export {
  w as ClearEditorPlugin
};
