import type { IEventEmitter } from '../../types'; import type { ICommandManager } from './command'; import type { IEditor } from './editor'; import type { Selection } from './selection'; import type { IStateManager } from './state'; /** * Union type of common key codes, using (string & {}) trick to provide completion suggestions without limiting specific strings * Reference: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code/code_values */ export type KeyCode = 'Space' | 'ShiftLeft' | 'ShiftRight' | 'ControlLeft' | 'ControlRight' | 'AltLeft' | 'AltRight' | 'MetaLeft' | 'MetaRight' | 'CapsLock' | 'Tab' | 'Enter' | 'Escape' | 'ArrowUp' | 'ArrowDown' | 'ArrowLeft' | 'ArrowRight' | `Key${string}` | `Digit${number}` | (string & {}); export interface IInteraction { name: string; init(options: InteractionInitOptions): void; destroy(): void; } export type SelectMode = 'replace' | 'add' | 'remove' | 'toggle'; export interface SelectionChangePayload { type: 'selection:change'; previous: Selection; next: Selection; added: Selection; removed: Selection; mode: SelectMode; } export interface viewBoxChangePayload { type: 'viewBox:change'; viewBox: string | undefined; } export interface IInteractionManager { isActive(): boolean; select(items: Selection, mode: SelectMode): void; getSelection(): Selection; isSelected(item: Selection[number]): boolean; clearSelection(): void; executeExclusiveInteraction(instance: IInteraction, callback: () => Promise): Promise; executeConcurrentInteraction(instance: IInteraction, callback: () => Promise): Promise; appendTransientElement(element: T): T; destroy(): void; } export interface InteractionInitOptions { emitter: IEventEmitter; editor: IEditor; commander: ICommandManager; state: IStateManager; interaction: IInteractionManager; } export interface InteractionManagerInitOptions { emitter: IEventEmitter; editor: IEditor; commander: ICommandManager; state: IStateManager; interactions?: IInteraction[]; }