mirror of
https://github.com/langgenius/dify.git
synced 2026-05-06 18:27:19 +08:00
20 lines
609 B
TypeScript
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)
|
|
}
|