"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useEditorFocus = void 0;
const react_1 = require("react");
const LexicalComposerContext_1 = require("@lexical/react/LexicalComposerContext");
const lexical_1 = require("lexical");
const useEditorFocus = () => {
    const [editor] = (0, LexicalComposerContext_1.useLexicalComposerContext)();
    const [hasFocus, setFocus] = (0, react_1.useState)(false);
    (0, react_1.useEffect)(() => editor.registerCommand(lexical_1.BLUR_COMMAND, () => {
        setFocus(false);
        return false;
    }, lexical_1.COMMAND_PRIORITY_LOW), []);
    (0, react_1.useEffect)(() => editor.registerCommand(lexical_1.FOCUS_COMMAND, () => {
        setFocus(true);
        return false;
    }, lexical_1.COMMAND_PRIORITY_LOW), []);
    return hasFocus;
};
exports.useEditorFocus = useEditorFocus;
