@slidev/client 0.34.2 → 0.35.1

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.
@@ -27,6 +27,10 @@ const props = defineProps({
27
27
  type: Number,
28
28
  default: undefined,
29
29
  },
30
+ maxHeight: {
31
+ type: String,
32
+ default: undefined,
33
+ },
30
34
  })
31
35
 
32
36
  const clicks = inject(injectionClicks)
@@ -76,6 +80,11 @@ onMounted(() => {
76
80
  line.classList.toggle('highlighted', highlighted)
77
81
  line.classList.toggle('dishonored', !highlighted)
78
82
  })
83
+ if (props.maxHeight) {
84
+ const firstHighlightedEl = target.querySelector('.line.highlighted')
85
+ if (firstHighlightedEl)
86
+ firstHighlightedEl.scrollIntoView({ behavior: 'smooth', block: 'center' })
87
+ }
79
88
  }
80
89
  })
81
90
  })
@@ -90,7 +99,13 @@ function copyCode() {
90
99
  </script>
91
100
 
92
101
  <template>
93
- <div ref="el" class="slidev-code-wrapper relative group">
102
+ <div
103
+ ref="el" class="slidev-code-wrapper relative group"
104
+ :style="{
105
+ 'max-height': props.maxHeight,
106
+ 'overflow-y': props.maxHeight ? 'scroll' : undefined,
107
+ }"
108
+ >
94
109
  <slot />
95
110
  <button
96
111
  v-if="configs.codeCopy"
@@ -94,7 +94,7 @@ onMounted(() => {
94
94
  <carbon:time class="absolute" />
95
95
  <carbon:renew class="absolute opacity-0" />
96
96
  </div>
97
- <div class="text-2xl pl-2 pr-6 my-auto">
97
+ <div class="text-2xl pl-2 pr-6 my-auto tabular-nums">
98
98
  {{ timer }}
99
99
  </div>
100
100
  </div>
package/logic/nav.ts CHANGED
@@ -115,6 +115,14 @@ export async function prevSlide(lastClicks = true) {
115
115
  router.replace({ query: { ...route.value.query, clicks: clicksTotal.value } })
116
116
  }
117
117
 
118
+ export function goFirst() {
119
+ return go(1)
120
+ }
121
+
122
+ export function goLast() {
123
+ return go(total.value)
124
+ }
125
+
118
126
  export function go(page: number | string, clicks?: number) {
119
127
  return router.push({ path: getPath(page), query: { ...route.value.query, clicks } })
120
128
  }
@@ -1,14 +1,11 @@
1
1
  import type { Fn, KeyFilter } from '@vueuse/core'
2
- import { and, not, onKeyStroke } from '@vueuse/core'
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, showGotoDialog, showOverview, toggleOverview } from '../state'
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.34.2",
3
+ "version": "0.35.1",
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.34.2",
20
- "@slidev/types": "0.34.2",
21
- "@unocss/reset": "^0.42.0",
22
- "@vueuse/core": "^8.7.5",
23
- "@vueuse/head": "^0.7.6",
19
+ "@slidev/parser": "0.35.1",
20
+ "@slidev/types": "0.35.1",
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.42.0",
39
- "vite-plugin-windicss": "^1.8.6",
39
+ "unocss": "^0.45.1",
40
+ "vite-plugin-windicss": "^1.8.7",
40
41
  "vue": "^3.2.37",
41
- "vue-router": "^4.0.16",
42
+ "vue-router": "^4.1.3",
42
43
  "vue-starport": "^0.3.0",
43
- "windicss": "^3.5.5"
44
+ "windicss": "^3.5.6"
45
+ },
46
+ "devDependencies": {
47
+ "vite": "^3.0.4"
44
48
  }
45
49
  }
@@ -1,12 +1,15 @@
1
1
  /* __imports__ */
2
-
2
+ import { and, not } from '@vueuse/core'
3
3
  import type { NavOperations, ShortcutOptions } from '@slidev/types'
4
- import { downloadPDF, go, next, nextSlide, prev, prevSlide } from '../logic/nav'
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 = {
@@ -15,6 +18,8 @@ export default function setupShortcuts() {
15
18
  nextSlide,
16
19
  prevSlide,
17
20
  go,
21
+ goFirst,
22
+ goLast,
18
23
  downloadPDF,
19
24
  toggleDark,
20
25
  toggleOverview,
@@ -23,10 +28,32 @@ export default function setupShortcuts() {
23
28
  showGotoDialog: () => showGotoDialog.value = !showGotoDialog.value,
24
29
  }
25
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
+
26
53
  // eslint-disable-next-line prefer-const
27
54
  let injection_return: Array<ShortcutOptions> = []
28
55
 
29
56
  /* __injections__ */
30
57
 
31
- return injection_return
58
+ return { customShortcuts: injection_return, defaultShortcuts: injection_arg_2 }
32
59
  }
package/styles/code.css CHANGED
@@ -6,8 +6,15 @@ html:not(.dark) .shiki-dark {
6
6
  display: none;
7
7
  }
8
8
 
9
+ ::-webkit-scrollbar {
10
+ width: 0px;
11
+ }
12
+
9
13
  .slidev-code-wrapper {
10
14
  margin: var(--slidev-code-margin) !important;
15
+ &:-webkit-scrollbar {
16
+ width: 0px;
17
+ }
11
18
  }
12
19
 
13
20
  .slidev-code {