import type { KeyHandler } from 'hotkeys-js'; export declare const HOTKEY_SCOPE_TYPE: { readonly AFFINE_PAGE: "affine:page"; readonly AFFINE_EDGELESS: "affine:edgeless"; }; export type HOTKEY_SCOPE_TYPE = (typeof HOTKEY_SCOPE_TYPE)[keyof typeof HOTKEY_SCOPE_TYPE]; export type HOTKEY_SCOPE = `affine:page-${number}` | `affine:edgeless-${number}`; /** * Singleton * * When rendering a page or an edgeless view, * `setScope` is called to set a unique scope for each view. * All hotkeys are then bound to this scope. * When a page or an edgeless view is disconnected, * all hotkeys registered during the view's lifetime are destroyed. */ declare class HotkeyManager { private readonly _hotkeys; private _scope; private _disabled; private counter; constructor(); get disabled(): boolean; newScope(type: HOTKEY_SCOPE_TYPE): HOTKEY_SCOPE; setScope(scope: HOTKEY_SCOPE): void; deleteScope(scope: HOTKEY_SCOPE): void; addListener(hotkey: string, listener: KeyHandler, options?: { keyup?: boolean; keydown?: boolean; }): void; removeListener(hotkey: string | Array): void; disableHotkey(): void; enableHotkey(): void; /** * Create a context to shielding against global hotkey. * * The param `fn` will be executed immediately. * @example * ```ts * const ret = await hotkey.withDisableHotkey(async () => { * const result = await createLink(space); * return result; * }); * ``` */ withDisabledHotkey(fn: () => Promise): Promise; /** * Similar to {@link withDisableHotkey}, but return a function instead of execute immediately. * @example * ```ts * const createLinkWithoutHotkey = withDisabledHotkeyFn((space) => createLink(space)); * await createLinkWithoutHotkey(space); * ``` */ withDisabledHotkeyFn Promise = (...args: unknown[]) => Promise>(fn: T): T; withScope(scope: HOTKEY_SCOPE, fn: () => void): void; } export declare const hotkey: HotkeyManager; export {}; //# sourceMappingURL=hotkey.d.ts.map