@microsoft/teams-js
Version:
Microsoft Client SDK for building app for Microsoft hosts
61 lines (60 loc) • 2.05 kB
TypeScript
/**
* Allows host shortcuts to function in your application by forwarding keyboard shortcuts to the host.
*
* This functionality is in Beta.
* @beta
* @module
*/
/**
* Data passed to the overridable shortcut handler.
*/
export type OverridableShortcutHandlerData = {
/**
* The matched shortcut that triggered the handler.
* This is a canonical form of the shortcut, e.g. "ctrl+shift+x".
*/
matchedShortcut: string;
};
/**
* A handler must return `true` when it wants to **consume** the shortcut
* (i.e. prevent forwarding to host). Any other return value forwards it.
*/
export type OverridableShortcutHandler = (event: KeyboardEvent, data: OverridableShortcutHandlerData) => boolean;
/**
* Replace the current overridable-shortcut handler.
*
* • Pass `undefined` to remove an existing handler.
* • Returns the previous handler so callers can restore it if needed.
*
* @beta
*/
export declare function setOverridableShortcutHandler(handler: OverridableShortcutHandler | undefined): OverridableShortcutHandler | undefined;
/**
* Reset the state of the shortcut relay capability.
* This is useful for tests to ensure a clean state.
*
* @beta
*/
export declare function resetIsShortcutRelayCapabilityEnabled(): void;
/**
* Enable capability to support host shortcuts.
*
* @beta
*/
export declare function enableShortcutRelayCapability(): Promise<void>;
/**
* Checks if shortcutRelay capability is supported by the host
* @returns boolean to represent whether the shortcutRelay capability is supported
*
* @throws Error if {@link app.initialize} has not successfully completed
*
* @beta
*/
export declare function isSupported(): boolean;
/**
* Allow apps to define zones where shortcuts should not be forwarded to the host.
* This is useful for input fields for password where shortcuts should not trigger host actions.
*
* @beta
*/
export declare const DISABLE_SHORTCUT_FORWARDING_ATTRIBUTE = "data-disable-shortcuts-forwarding";