import { useEffect } from 'react';
import { useBooleanState } from "./hooks.js";
export const useNodeEditing = ({ nodeRef, view }) => {
    const state = useBooleanState(false);
    const [, , unsetEdit, toggleEdit] = state;
    useEffect(() => {
        const { current: anchor } = nodeRef;
        anchor?.addEventListener('dblclick', toggleEdit);
        view.dom.addEventListener('focus', unsetEdit);
        return () => {
            anchor?.removeEventListener('dblclick', toggleEdit);
            view.dom.removeEventListener('focus', unsetEdit);
        };
        // https://github.com/facebook/react/issues/23392#issuecomment-1055610198
        // eslint-disable-next-line react-hooks/exhaustive-deps
    }, [view.dom, toggleEdit, unsetEdit, nodeRef.current]);
    return state;
};
//# sourceMappingURL=useNodeEditing.js.map
