dify/web/app/components/workflow/shortcuts/commands.ts
yyh 88196c186e
refactor(web): workflow hotkeys and history state (#35736)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-04-30 09:43:16 +00:00

20 lines
609 B
TypeScript

export const WorkflowCommand = {
ToggleCanvasMaximize: 'workflow:toggle-canvas-maximize',
} as const
type WorkflowCommandType = typeof WorkflowCommand[keyof typeof WorkflowCommand]
const workflowCommandTarget = new EventTarget()
export const emitWorkflowCommand = (command: WorkflowCommandType) => {
workflowCommandTarget.dispatchEvent(new Event(command))
}
export const subscribeWorkflowCommand = (
command: WorkflowCommandType,
listener: () => void,
) => {
workflowCommandTarget.addEventListener(command, listener)
return () => workflowCommandTarget.removeEventListener(command, listener)
}