/** * @public * A keyboard event definition that can be used to create a keyboard shortcut. * * At least one of `key` or `code` must be provided while the `alt`, `ctrl`, * `meta`, and `shift` modifier configurations are optional. * * The `key` represents a https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key * and is treated as case-insensitive. * * The `code` represents a https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code * and is treated as case-insensitive. * * @example * ```typescript * const boldEvent: KeyboardEventDefinition = { * key: 'B', * alt: false, * ctrl: true, * meta: false, * shift: false, * } * ``` */ type KeyboardEventDefinition = ({ key: KeyboardEvent['key']; code: KeyboardEvent['code']; } | { key: KeyboardEvent['key']; code?: undefined; } | { key?: undefined; code: KeyboardEvent['code']; }) & { alt?: KeyboardEvent['altKey']; ctrl?: KeyboardEvent['ctrlKey']; meta?: KeyboardEvent['metaKey']; shift?: KeyboardEvent['shiftKey']; }; /** * @public * Definition of a keyboard shortcut with platform-specific keyboard event * definitions. * * `default` keyboard event definitions are required while the `apple` * keyboard event definitions are optional. * * @example * ```typescript * const boldShortcut: KeyboardShortcutDefinition = { * default: [{ * key: 'B', * alt: false, * ctrl: true, * meta: false, * shift: false, * }], * apple: [{ * key: 'B', * alt: false, * ctrl: false, * meta: true, * shift: false, * }], * } * ``` */ type KeyboardShortcutDefinition = { default: ReadonlyArray; apple?: ReadonlyArray; }; /** * @public * A resolved keyboard shortcut for the current platform that has been * processed by `createKeyboardShortcut(...)` to select the appropriate * platform-specific key combination. The `guard` function determines if the * shortcut applies to the current `KeyboardEvent`, while `keys` contains the * display-friendly key combination for the current platform. */ type KeyboardShortcut = Pick> = { guard: (event: TKeyboardEvent) => boolean; keys: ReadonlyArray; }; /** * @public * Creates a `KeyboardShortcut` from a `KeyboardShortcutDefinition`. * * `default` keyboard event definitions are required while the `apple` * keyboard event definitions are optional. * * @example * ```typescript * const shortcut = createKeyboardShortcut({ * default: [{ * key: 'B', * alt: false, * ctrl: true, * meta: false, * shift: false, * }], * apple: [{ * key: 'B', * alt: false, * ctrl: false, * meta: true, * shift: false, * }], * }) * ``` */ declare function createKeyboardShortcut = Pick>(definition: KeyboardShortcutDefinition): KeyboardShortcut; /** * @public */ declare const bold: KeyboardShortcut>; /** * @public */ declare const italic: KeyboardShortcut>; /** * @public */ declare const code: KeyboardShortcut>; /** * @public */ declare const underline: KeyboardShortcut>; /** * @public */ declare const strikeThrough: KeyboardShortcut>; /** * @public */ declare const link: KeyboardShortcut>; /** * @public */ declare const normal: KeyboardShortcut>; /** * @public */ declare const h1: KeyboardShortcut>; /** * @public */ declare const h2: KeyboardShortcut>; /** * @public */ declare const h3: KeyboardShortcut>; /** * @public */ declare const h4: KeyboardShortcut>; /** * @public */ declare const h5: KeyboardShortcut>; /** * @public */ declare const h6: KeyboardShortcut>; /** * @public */ declare const blockquote: KeyboardShortcut>; /** * @public */ declare const undo: KeyboardShortcut>; /** * @public */ declare const redo: KeyboardShortcut>; export { KeyboardEventDefinition, KeyboardShortcut, KeyboardShortcutDefinition, blockquote, bold, code, createKeyboardShortcut, h1, h2, h3, h4, h5, h6, italic, link, normal, redo, strikeThrough, underline, undo }; //# sourceMappingURL=index.d.ts.map