/** * @file * * Mock of Obsidian's `Keymap`, which manages the stack of keyboard scopes and reads modifier keys off events. */ import type { Keymap as KeymapOriginal, Modifier as ModifierOriginal, PaneType as PaneTypeOriginal, UserEvent as UserEventOriginal } from 'obsidian'; import type { Scope } from './Scope.cjs'; type ModifierEvent = KeyboardEvent | MouseEvent | TouchEvent; /** * Mock of Obsidian's `Keymap`. * * The scope stack is kept in memory but never dispatches key events; the static modifier helpers read the real * flags off the event, resolving `Mod` through the mocked `Platform.isMacOS`. */ export declare class Keymap { private readonly scopeStack; /** * Creates a keymap with an empty scope stack. Use {@link Keymap.create__} from tests. */ protected constructor(); /** * Mock-only factory: creates a keymap, spyable via `vi.spyOn(Keymap, 'create__')`. * * @returns The new keymap. */ static create__(): Keymap; /** * Mock-only: views a value typed as Obsidian's `Keymap` as this mock. * * @param value - The value typed as the original `Keymap`. * @returns The same object, typed as the mock. */ static fromOriginalType__(value: KeymapOriginal): Keymap; /** * Translates an event into the type of pane a link should open in. * * @param $event - The user event to inspect, if any. * @returns `'tab'` for a middle click or for Cmd/Ctrl, `'split'` for Cmd/Ctrl+Alt, `'window'` for * Cmd/Ctrl+Alt+Shift, and `false` when there is no event or Cmd/Ctrl is not held. */ static isModEvent($event?: null | UserEventOriginal): boolean | PaneTypeOriginal; /** * Checks whether a modifier key was held during an event. * * @param $event - The keyboard, mouse or touch event to inspect. * @param modifier - The modifier to check; `Mod` means Cmd on macOS and Ctrl elsewhere. * @returns Whether the modifier was held. */ static isModifier($event: ModifierEvent, modifier: ModifierOriginal): boolean; /** * Mock-only: views this mock as Obsidian's `Keymap` type. * * @returns The same object, typed as the original `Keymap`. */ asOriginalType__(): KeymapOriginal; /** * Mock-only construction hook, called at the end of the constructor; a no-op meant for * `vi.spyOn(Keymap.prototype, 'constructor__')`. */ constructor__(): void; /** * Removes a scope from the scope stack; when it was the active scope, the next one down becomes active. * Removing a scope that is not on the stack does nothing. * * @param scope - The scope to remove. */ popScope(scope: Scope): void; /** * Pushes a scope onto the scope stack, making it the active scope for key events. * * @param scope - The scope to activate. */ pushScope(scope: Scope): void; } export {};