@slidev/client 0.34.3 → 0.35.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/internals/Presenter.vue +1 -1
- package/logic/shortcuts.ts +5 -31
- package/package.json +14 -10
- package/setup/shortcuts.ts +28 -3
package/internals/Presenter.vue
CHANGED
package/logic/shortcuts.ts
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import type { Fn, KeyFilter } from '@vueuse/core'
|
|
2
|
-
import {
|
|
2
|
+
import { onKeyStroke } from '@vueuse/core'
|
|
3
|
+
import { and, not } from '@vueuse/math'
|
|
3
4
|
import type { Ref } from 'vue'
|
|
4
5
|
import { watch } from 'vue'
|
|
5
6
|
import type { ShortcutOptions } from '@slidev/types'
|
|
6
|
-
import { fullscreen, isInputting, isOnFocus, magicKeys, shortcutsEnabled
|
|
7
|
+
import { fullscreen, isInputting, isOnFocus, magicKeys, shortcutsEnabled } from '../state'
|
|
7
8
|
import setupShortcuts from '../setup/shortcuts'
|
|
8
|
-
import { toggleDark } from './dark'
|
|
9
|
-
import { go, next, nextSlide, prev, prevSlide } from './nav'
|
|
10
|
-
import { drawingEnabled } from './drawings'
|
|
11
|
-
import { currentOverviewPage, downOverviewPage, nextOverviewPage, prevOverviewPage, upOverviewPage } from './overview'
|
|
12
9
|
|
|
13
10
|
const _shortcut = and(not(isInputting), not(isOnFocus), shortcutsEnabled)
|
|
14
11
|
|
|
@@ -45,33 +42,10 @@ export function strokeShortcut(key: KeyFilter, fn: Fn) {
|
|
|
45
42
|
}
|
|
46
43
|
|
|
47
44
|
export function registerShortcuts() {
|
|
48
|
-
const customShortcuts = setupShortcuts()
|
|
45
|
+
const { customShortcuts, defaultShortcuts } = setupShortcuts()
|
|
49
46
|
|
|
50
|
-
const { escape, space, shift, left, right, up, down, enter, d, g, o } = magicKeys
|
|
51
47
|
const shortcuts = new Map<string | Ref<Boolean>, ShortcutOptions>(
|
|
52
|
-
[
|
|
53
|
-
{ key: and(space, not(shift)), fn: next, autoRepeat: true },
|
|
54
|
-
{ key: and(space, shift), fn: prev, autoRepeat: true },
|
|
55
|
-
{ key: and(right, not(shift), not(showOverview)), fn: next, autoRepeat: true },
|
|
56
|
-
{ key: and(left, not(shift), not(showOverview)), fn: prev, autoRepeat: true },
|
|
57
|
-
{ key: 'pageDown', fn: next, autoRepeat: true },
|
|
58
|
-
{ key: 'pageUp', fn: prev, autoRepeat: true },
|
|
59
|
-
{ key: and(up, not(showOverview)), fn: () => prevSlide(false), autoRepeat: true },
|
|
60
|
-
{ key: and(down, not(showOverview)), fn: nextSlide, autoRepeat: true },
|
|
61
|
-
{ key: and(left, shift), fn: () => prevSlide(false), autoRepeat: true },
|
|
62
|
-
{ key: and(right, shift), fn: nextSlide, autoRepeat: true },
|
|
63
|
-
{ key: and(d, not(drawingEnabled)), fn: toggleDark },
|
|
64
|
-
{ key: and(o, not(drawingEnabled)), fn: toggleOverview },
|
|
65
|
-
{ key: and(escape, not(drawingEnabled)), fn: () => showOverview.value = false },
|
|
66
|
-
{ key: and(g, not(drawingEnabled)), fn: () => showGotoDialog.value = !showGotoDialog.value },
|
|
67
|
-
{ key: and(left, showOverview), fn: prevOverviewPage },
|
|
68
|
-
{ key: and(right, showOverview), fn: nextOverviewPage },
|
|
69
|
-
{ key: and(up, showOverview), fn: upOverviewPage },
|
|
70
|
-
{ key: and(down, showOverview), fn: downOverviewPage },
|
|
71
|
-
{ key: and(enter, showOverview), fn: () => { go(currentOverviewPage.value); showOverview.value = false } },
|
|
72
|
-
...customShortcuts,
|
|
73
|
-
]
|
|
74
|
-
.map((options: ShortcutOptions) => [options.key, options]),
|
|
48
|
+
[...defaultShortcuts, ...customShortcuts].map((options: ShortcutOptions) => [options.key, options]),
|
|
75
49
|
)
|
|
76
50
|
|
|
77
51
|
shortcuts.forEach((options) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slidev/client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.35.2",
|
|
4
4
|
"description": "Presentation slides for developers",
|
|
5
5
|
"author": "antfu <anthonyfu117@hotmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -16,11 +16,12 @@
|
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@antfu/utils": "^0.5.2",
|
|
19
|
-
"@slidev/parser": "0.
|
|
20
|
-
"@slidev/types": "0.
|
|
21
|
-
"@unocss/reset": "^0.
|
|
22
|
-
"@vueuse/core": "^
|
|
23
|
-
"@vueuse/head": "^0.7.
|
|
19
|
+
"@slidev/parser": "0.35.2",
|
|
20
|
+
"@slidev/types": "0.35.2",
|
|
21
|
+
"@unocss/reset": "^0.45.1",
|
|
22
|
+
"@vueuse/core": "^9.0.1",
|
|
23
|
+
"@vueuse/head": "^0.7.8",
|
|
24
|
+
"@vueuse/math": "^9.0.1",
|
|
24
25
|
"@vueuse/motion": "^2.0.0-beta.18",
|
|
25
26
|
"codemirror": "^5.65.5",
|
|
26
27
|
"defu": "^6.0.0",
|
|
@@ -35,11 +36,14 @@
|
|
|
35
36
|
"prettier": "^2.7.1",
|
|
36
37
|
"recordrtc": "^5.6.2",
|
|
37
38
|
"resolve": "^1.22.1",
|
|
38
|
-
"unocss": "^0.
|
|
39
|
-
"vite-plugin-windicss": "^1.8.
|
|
39
|
+
"unocss": "^0.45.1",
|
|
40
|
+
"vite-plugin-windicss": "^1.8.7",
|
|
40
41
|
"vue": "^3.2.37",
|
|
41
|
-
"vue-router": "^4.
|
|
42
|
+
"vue-router": "^4.1.3",
|
|
42
43
|
"vue-starport": "^0.3.0",
|
|
43
|
-
"windicss": "^3.5.
|
|
44
|
+
"windicss": "^3.5.6"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"vite": "^3.0.4"
|
|
44
48
|
}
|
|
45
49
|
}
|
package/setup/shortcuts.ts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
/* __imports__ */
|
|
2
|
-
|
|
2
|
+
import { and, not } from '@vueuse/math'
|
|
3
3
|
import type { NavOperations, ShortcutOptions } from '@slidev/types'
|
|
4
4
|
import { downloadPDF, go, goFirst, goLast, next, nextSlide, prev, prevSlide } from '../logic/nav'
|
|
5
5
|
import { toggleDark } from '../logic/dark'
|
|
6
|
-
import { showGotoDialog, showOverview, toggleOverview } from '../state'
|
|
6
|
+
import { magicKeys, showGotoDialog, showOverview, toggleOverview } from '../state'
|
|
7
7
|
import { drawingEnabled } from '../logic/drawings'
|
|
8
|
+
import { currentOverviewPage, downOverviewPage, nextOverviewPage, prevOverviewPage, upOverviewPage } from './../logic/overview'
|
|
8
9
|
|
|
9
10
|
export default function setupShortcuts() {
|
|
11
|
+
const { escape, space, shift, left, right, up, down, enter, d, g, o } = magicKeys
|
|
12
|
+
|
|
10
13
|
// @ts-expect-error injected in runtime
|
|
11
14
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
12
15
|
const injection_arg: NavOperations = {
|
|
@@ -25,10 +28,32 @@ export default function setupShortcuts() {
|
|
|
25
28
|
showGotoDialog: () => showGotoDialog.value = !showGotoDialog.value,
|
|
26
29
|
}
|
|
27
30
|
|
|
31
|
+
const injection_arg_2: ShortcutOptions[] = [
|
|
32
|
+
{ name: 'next_space', key: and(space, not(shift)), fn: next, autoRepeat: true },
|
|
33
|
+
{ name: 'prev_space', key: and(space, shift), fn: prev, autoRepeat: true },
|
|
34
|
+
{ name: 'next_right', key: and(right, not(shift), not(showOverview)), fn: next, autoRepeat: true },
|
|
35
|
+
{ name: 'prev_left', key: and(left, not(shift), not(showOverview)), fn: prev, autoRepeat: true },
|
|
36
|
+
{ name: 'next_page_key', key: 'pageDown', fn: next, autoRepeat: true },
|
|
37
|
+
{ name: 'prev_page_key', key: 'pageUp', fn: prev, autoRepeat: true },
|
|
38
|
+
{ name: 'next_down', key: and(down, not(showOverview)), fn: nextSlide, autoRepeat: true },
|
|
39
|
+
{ name: 'prev_up', key: and(up, not(showOverview)), fn: () => prevSlide(false), autoRepeat: true },
|
|
40
|
+
{ name: 'next_shift', key: and(right, shift), fn: nextSlide, autoRepeat: true },
|
|
41
|
+
{ name: 'prev_shift', key: and(left, shift), fn: () => prevSlide(false), autoRepeat: true },
|
|
42
|
+
{ name: 'toggle_dark', key: and(d, not(drawingEnabled)), fn: toggleDark },
|
|
43
|
+
{ name: 'toggle_overview', key: and(o, not(drawingEnabled)), fn: toggleOverview },
|
|
44
|
+
{ name: 'hide_overview', key: and(escape, not(drawingEnabled)), fn: () => showOverview.value = false },
|
|
45
|
+
{ name: 'goto', key: and(g, not(drawingEnabled)), fn: () => showGotoDialog.value = !showGotoDialog.value },
|
|
46
|
+
{ name: 'next_overview', key: and(right, showOverview), fn: nextOverviewPage },
|
|
47
|
+
{ name: 'prev_overview', key: and(left, showOverview), fn: prevOverviewPage },
|
|
48
|
+
{ name: 'up_overview', key: and(up, showOverview), fn: upOverviewPage },
|
|
49
|
+
{ name: 'down_overview', key: and(down, showOverview), fn: downOverviewPage },
|
|
50
|
+
{ name: 'goto_from_overview', key: and(enter, showOverview), fn: () => { go(currentOverviewPage.value); showOverview.value = false } },
|
|
51
|
+
]
|
|
52
|
+
|
|
28
53
|
// eslint-disable-next-line prefer-const
|
|
29
54
|
let injection_return: Array<ShortcutOptions> = []
|
|
30
55
|
|
|
31
56
|
/* __injections__ */
|
|
32
57
|
|
|
33
|
-
return injection_return
|
|
58
|
+
return { customShortcuts: injection_return, defaultShortcuts: injection_arg_2 }
|
|
34
59
|
}
|