"use client";
import { jsx } from "react/jsx-runtime";
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
import { COMMAND_PRIORITY_NORMAL, createCommand } from "lexical";
import { TableModal } from "./table-modal.js";
import * as __rspack_external_react from "react";
const OPEN_TABLE_MODAL_COMMAND = createCommand('OPEN_TABLE_MODAL_COMMAND');
function TablePlugin() {
    const [editor] = useLexicalComposerContext();
    const [open, setOpen] = __rspack_external_react.useState(false);
    (0, __rspack_external_react.useEffect)(()=>editor.registerCommand(OPEN_TABLE_MODAL_COMMAND, ()=>{
            setOpen((prev)=>prev ? prev : true);
            return true;
        }, COMMAND_PRIORITY_NORMAL), [
        editor
    ]);
    const handleOnClose = ()=>{
        setOpen(false);
    };
    return /*#__PURE__*/ jsx(TableModal, {
        open: open,
        onClose: handleOnClose
    });
}
export { OPEN_TABLE_MODAL_COMMAND, TablePlugin };
