mirror of
https://github.com/stan-smith/FossFLOW.git
synced 2025-12-24 06:58:48 -05:00
feat: added in esc to get ya out of menus/interactions/connectors Fixes #154
This commit is contained in:
2
packages/fossflow-lib/dist/index.js
vendored
2
packages/fossflow-lib/dist/index.js
vendored
File diff suppressed because one or more lines are too long
@@ -65,6 +65,43 @@ export const useInteractionManager = () => {
|
||||
// Keyboard shortcuts for undo/redo
|
||||
useEffect(() => {
|
||||
const handleKeyDown = (e: KeyboardEvent) => {
|
||||
// ESC key handling - should work even in input fields
|
||||
if (e.key === 'Escape') {
|
||||
e.preventDefault();
|
||||
|
||||
// Priority 1: Close ItemControls (node menus) if open
|
||||
if (uiState.itemControls) {
|
||||
uiState.actions.setItemControls(null);
|
||||
return;
|
||||
}
|
||||
|
||||
// Priority 2: Cancel in-progress connector
|
||||
if (uiState.mode.type === 'CONNECTOR') {
|
||||
const connectorMode = uiState.mode;
|
||||
|
||||
// Check if connection is in progress
|
||||
const isConnectionInProgress =
|
||||
(uiState.connectorInteractionMode === 'click' && connectorMode.isConnecting) ||
|
||||
(uiState.connectorInteractionMode === 'drag' && connectorMode.id !== null);
|
||||
|
||||
if (isConnectionInProgress && connectorMode.id) {
|
||||
// Delete the temporary connector
|
||||
scene.deleteConnector(connectorMode.id);
|
||||
|
||||
// Reset connector mode to initial state
|
||||
uiState.actions.setMode({
|
||||
type: 'CONNECTOR',
|
||||
showCursor: true,
|
||||
id: null,
|
||||
startAnchor: undefined,
|
||||
isConnecting: false
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Don't handle shortcuts when typing in input fields
|
||||
const target = e.target as HTMLElement;
|
||||
if (
|
||||
@@ -190,7 +227,7 @@ export const useInteractionManager = () => {
|
||||
return () => {
|
||||
return window.removeEventListener('keydown', handleKeyDown);
|
||||
};
|
||||
}, [undo, redo, canUndo, canRedo, uiState.hotkeyProfile, uiState.actions, createTextBox, uiState.mouse.position.tile]);
|
||||
}, [undo, redo, canUndo, canRedo, uiState.hotkeyProfile, uiState.actions, createTextBox, uiState.mouse.position.tile, scene, uiState.itemControls, uiState.mode, uiState.connectorInteractionMode]);
|
||||
|
||||
const onMouseEvent = useCallback(
|
||||
(e: SlimMouseEvent) => {
|
||||
|
||||
Reference in New Issue
Block a user