Skip to content

Commit

Permalink
feat: migration message and examples for the new setupShortcuts (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
twitwi committed Sep 12, 2022
1 parent e9156da commit 2b46447
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions custom/config-shortcuts.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@

> Available since v0.20
> Since v0.35.6 (excluded), you decide which base shortcuts to keep (see `...base,` below).
<Environment type="client" />

Create `./setup/shortcuts.ts` with the following content:

```ts
import { defineShortcutsSetup, NavOperations } from '@slidev/types'
import type { NavOperations, ShortcutOptions } from '@slidev/types'
import { defineShortcutsSetup } from '@slidev/types'

export default defineShortcutsSetup((nav: NavOperations) => {
export default defineShortcutsSetup((nav: NavOperations, base: ShortcutOptions[]) => {
return [
...base, // keep the existing shortcuts
{
key: 'enter',
fn: () => nav.next(),
Expand All @@ -32,10 +36,12 @@ The configuration function receives an object with some navigation methods, and
The `key` type only allows for strings, but you can still bind multiple keys by using following convention:

```ts
import { defineShortcutsSetup, NavOperations } from '@slidev/types'
import type { NavOperations, ShortcutOptions } from '@slidev/types'
import { defineShortcutsSetup } from '@slidev/types'

export default defineShortcutsSetup((nav: NavOperations) => {
export default defineShortcutsSetup((nav: NavOperations, base: ShortcutOptions[]) => {
return [
...base,
{
key: 'ShiftLeft+ArrowRight',
fn: () => nav.next(),
Expand Down

0 comments on commit 2b46447

Please sign in to comment.