6ced8434bd
* Uniformize folder structure * Fix icons * Fix icons * Fix tests * Fix tests
22 lines
784 B
TypeScript
22 lines
784 B
TypeScript
import { useRecoilCallback } from 'recoil';
|
|
|
|
import { currentCellInEditModePositionState } from '../states/currentCellInEditModePositionState';
|
|
import { isCellInEditModeFamilyState } from '../states/isCellInEditModeFamilyState';
|
|
import { CellPosition } from '../types/CellPosition';
|
|
|
|
export function useMoveEditModeToCellPosition() {
|
|
return useRecoilCallback(({ set, snapshot }) => {
|
|
return (newPosition: CellPosition) => {
|
|
const currentCellInEditModePosition = snapshot
|
|
.getLoadable(currentCellInEditModePositionState)
|
|
.valueOrThrow();
|
|
|
|
set(isCellInEditModeFamilyState(currentCellInEditModePosition), false);
|
|
|
|
set(currentCellInEditModePositionState, newPosition);
|
|
|
|
set(isCellInEditModeFamilyState(newPosition), true);
|
|
};
|
|
}, []);
|
|
}
|