feat(editor): Allow jumping into sub-workflow with shortkey (#15200)

This commit is contained in:
Ricardo Espinoza
2025-05-12 07:24:36 -04:00
committed by GitHub
parent 8b467e3f56
commit e2b9ada4b5
20 changed files with 523 additions and 51 deletions

View File

@@ -59,7 +59,7 @@ const emit = defineEmits<{
'update:modelValue': [elements: CanvasNode[]];
'update:node:position': [id: string, position: XYPosition];
'update:nodes:position': [events: CanvasNodeMoveEvent[]];
'update:node:activated': [id: string];
'update:node:activated': [id: string, event?: MouseEvent];
'update:node:deactivated': [id: string];
'update:node:enabled': [id: string];
'update:node:selected': [id?: string];
@@ -95,6 +95,7 @@ const emit = defineEmits<{
'create:workflow': [];
'drag-and-drop': [position: XYPosition, event: DragEvent];
'tidy-up': [CanvasLayoutEvent];
'open:sub-workflow': [nodeId: string];
}>();
const props = withDefaults(
@@ -266,6 +267,7 @@ function selectUpstreamNodes(id: string) {
const keyMap = computed(() => {
const readOnlyKeymap = {
ctrl_shift_o: emitWithLastSelectedNode((id) => emit('open:sub-workflow', id)),
ctrl_c: emitWithSelectedNodes((ids) => emit('copy:nodes', ids)),
enter: emitWithLastSelectedNode((id) => onSetNodeActivated(id)),
ctrl_a: () => addSelectedNodes(graphNodes.value),
@@ -368,9 +370,9 @@ function onSelectionEnd() {
}
}
function onSetNodeActivated(id: string) {
function onSetNodeActivated(id: string, event?: MouseEvent) {
props.eventBus.emit('nodes:action', { ids: [id], action: 'update:node:activated' });
emit('update:node:activated', id);
emit('update:node:activated', id, event);
}
function onSetNodeDeactivated(id: string) {
@@ -661,6 +663,9 @@ async function onContextMenuAction(action: ContextMenuAction, nodeIds: string[])
return props.eventBus.emit('nodes:action', { ids: nodeIds, action: 'update:sticky:color' });
case 'tidy_up':
return await onTidyUp({ source: 'context-menu' });
case 'open_sub_workflow': {
return emit('open:sub-workflow', nodeIds[0]);
}
}
}