@slidev/client 0.25.2 → 0.25.6

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/constants.ts CHANGED
@@ -8,6 +8,7 @@ export const injectionSlideScale: InjectionKey<ComputedRef<number>> = Symbol('sl
8
8
 
9
9
  export const CLASS_VCLICK_TARGET = 'slidev-vclick-target'
10
10
  export const CLASS_VCLICK_HIDDEN = 'slidev-vclick-hidden'
11
+ export const CLASS_VCLICK_FADE = 'slidev-vclick-fade'
11
12
  export const CLASS_VCLICK_GONE = 'slidev-vclick-gone'
12
13
  export const CLASS_VCLICK_HIDDEN_EXP = 'slidev-vclick-hidden-explicitly'
13
14
  export const CLASS_VCLICK_CURRENT = 'slidev-vclick-current'
@@ -59,15 +59,24 @@ onClickOutside(input, () => {
59
59
  </script>
60
60
 
61
61
  <template>
62
- <div
63
- v-show="!editing && note"
64
- class="prose overflow-auto outline-none"
65
- :class="props.class"
66
- @click="switchNoteEdit"
67
- v-html="info?.notesHTML"
68
- />
62
+ <template v-if="!editing && note">
63
+ <div
64
+ v-if="info?.notesHTML"
65
+ class="prose overflow-auto outline-none"
66
+ :class="props.class"
67
+ @click="switchNoteEdit"
68
+ v-html="info?.notesHTML"
69
+ ></div>
70
+ <div
71
+ v-else
72
+ class="prose overflow-auto outline-none"
73
+ :class="props.class"
74
+ @click="switchNoteEdit"
75
+ v-text="note"
76
+ ></div>
77
+ </template>
69
78
  <textarea
70
- v-show="editing || !note"
79
+ v-else
71
80
  ref="input"
72
81
  v-model="note"
73
82
  class="prose resize-none overflow-auto outline-none bg-transparent block"
@@ -79,7 +79,7 @@ onMounted(() => {
79
79
  </script>
80
80
 
81
81
  <template>
82
- <div class="bg-main h-full">
82
+ <div class="bg-main h-full slidev-presenter">
83
83
  <div class="grid-container">
84
84
  <div class="grid-section top flex">
85
85
  <img src="../assets/logo-title-horizontal.png" class="h-14 ml-2 py-2 my-auto" />
@@ -141,6 +141,10 @@ onMounted(() => {
141
141
  </template>
142
142
 
143
143
  <style lang="postcss" scoped>
144
+ .slidev-presenter {
145
+ --slidev-controls-foreground: current;
146
+ }
147
+
144
148
  .timer-btn:hover {
145
149
  & > :first-child {
146
150
  @apply opacity-0;
@@ -22,15 +22,15 @@ function go(page: number) {
22
22
  close()
23
23
  }
24
24
 
25
+ const xs = breakpoints.smaller('xs')
25
26
  const sm = breakpoints.smaller('sm')
26
- const md = breakpoints.smaller('md')
27
27
 
28
28
  const padding = 4 * 16 * 2
29
29
  const gap = 2 * 16
30
30
  const cardWidth = computed(() => {
31
- if (sm.value)
31
+ if (xs.value)
32
32
  return windowSize.width.value - padding
33
- else if (md.value)
33
+ else if (sm.value)
34
34
  return (windowSize.width.value - padding - gap) / 2
35
35
  return 300
36
36
  })
package/logic/drawings.ts CHANGED
@@ -49,6 +49,7 @@ export const drawingMode = computed({
49
49
  export const drauuOptions: DrauuOptions = reactive({
50
50
  brush,
51
51
  acceptsInputTypes: computed(() => drawingEnabled.value ? undefined : ['pen' as const]),
52
+ coordinateTransform: false,
52
53
  })
53
54
  export const drauu = markRaw(createDrauu(drauuOptions))
54
55
 
package/logic/nav.ts CHANGED
@@ -1,16 +1,19 @@
1
1
  import { computed, Ref, ref, nextTick } from 'vue'
2
- import { isString, SwipeDirection, timestamp, useSwipe } from '@vueuse/core'
2
+ import { isString, SwipeDirection, timestamp, usePointerSwipe } from '@vueuse/core'
3
3
  import { rawRoutes, router } from '../routes'
4
4
  import { configs } from '../env'
5
5
  import { useRouteQuery } from './route'
6
+ import { isDrawing } from './drawings'
6
7
 
7
8
  export { rawRoutes, router }
8
9
 
9
10
  // force update collected elements when the route is fully resolved
10
11
  const routeForceRefresh = ref(0)
11
- router.afterEach(async() => {
12
- await nextTick()
13
- routeForceRefresh.value += 1
12
+ nextTick(() => {
13
+ router.afterEach(async() => {
14
+ await nextTick()
15
+ routeForceRefresh.value += 1
16
+ })
14
17
  })
15
18
 
16
19
  export const route = computed(() => router.currentRoute.value)
@@ -91,15 +94,24 @@ export function go(page: number, clicks?: number) {
91
94
 
92
95
  export function useSwipeControls(root: Ref<HTMLElement | undefined>) {
93
96
  const swipeBegin = ref(0)
94
- const { direction, lengthX, lengthY } = useSwipe(root, {
95
- onSwipeStart() {
97
+ const { direction, distanceX, distanceY } = usePointerSwipe(root, {
98
+ onSwipeStart(e) {
99
+ if (e.pointerType !== 'touch')
100
+ return
101
+ if (isDrawing.value)
102
+ return
96
103
  swipeBegin.value = timestamp()
97
104
  },
98
- onSwipeEnd() {
105
+ onSwipeEnd(e) {
106
+ if (e.pointerType !== 'touch')
107
+ return
99
108
  if (!swipeBegin.value)
100
109
  return
101
- const x = Math.abs(lengthX.value)
102
- const y = Math.abs(lengthY.value)
110
+ if (isDrawing.value)
111
+ return
112
+
113
+ const x = Math.abs(distanceX.value)
114
+ const y = Math.abs(distanceY.value)
103
115
  if (x / window.innerWidth > 0.3 || x > 100) {
104
116
  if (direction.value === SwipeDirection.LEFT)
105
117
  next()
package/logic/note.ts CHANGED
@@ -4,7 +4,7 @@ import type { SlideInfo, SlideInfoExtended } from '@slidev/types'
4
4
 
5
5
  export interface UseSlideInfo{
6
6
  info: Ref<SlideInfoExtended | undefined>
7
- update: (data: Partial<SlideInfo>) => Promise<void>
7
+ update: (data: Partial<SlideInfo>) => Promise<SlideInfoExtended | void>
8
8
  }
9
9
 
10
10
  export function useSlideInfo(id: number | undefined): UseSlideInfo {
@@ -20,7 +20,7 @@ export function useSlideInfo(id: number | undefined): UseSlideInfo {
20
20
  execute()
21
21
 
22
22
  const update = async(data: Partial<SlideInfo>) => {
23
- await fetch(
23
+ return await fetch(
24
24
  url,
25
25
  {
26
26
  method: 'POST',
@@ -30,12 +30,12 @@ export function useSlideInfo(id: number | undefined): UseSlideInfo {
30
30
  },
31
31
  body: JSON.stringify(data),
32
32
  },
33
- )
33
+ ).then(r => r.json())
34
34
  }
35
35
 
36
- import.meta.hot?.on('slidev-update', (playload) => {
37
- if (playload.id === id)
38
- info.value = playload.data
36
+ import.meta.hot?.on('slidev-update', (payload) => {
37
+ if (payload.id === id)
38
+ info.value = payload.data
39
39
  })
40
40
 
41
41
  return {
@@ -56,6 +56,12 @@ export function useDynamicSlideInfo(id: MaybeRef<number | undefined>) {
56
56
 
57
57
  return {
58
58
  info: computed(() => get(unref(id)).info.value),
59
- update: (data: Partial<SlideInfo>, newId?: number) => get(newId ?? unref(id)).update(data),
59
+ update: async(data: Partial<SlideInfo>, newId?: number) => {
60
+ const info = get(newId ?? unref(id))
61
+ const newData = await info.update(data)
62
+ if (newData)
63
+ info.info.value = newData
64
+ return newData
65
+ },
60
66
  }
61
67
  }
@@ -2,8 +2,16 @@ import { App, DirectiveBinding, InjectionKey, watch } from 'vue'
2
2
  import { remove } from '@antfu/utils'
3
3
  import { isPrintMode, isPrintWithClicks } from '../logic/nav'
4
4
  import {
5
- injectionClicksDisabled, injectionClicksElements, injectionClicks, injectionOrderMap,
6
- CLASS_VCLICK_CURRENT, CLASS_VCLICK_HIDDEN, CLASS_VCLICK_HIDDEN_EXP, CLASS_VCLICK_PRIOR, CLASS_VCLICK_TARGET,
5
+ injectionClicksDisabled,
6
+ injectionClicksElements,
7
+ injectionClicks,
8
+ injectionOrderMap,
9
+ CLASS_VCLICK_CURRENT,
10
+ CLASS_VCLICK_HIDDEN,
11
+ CLASS_VCLICK_HIDDEN_EXP,
12
+ CLASS_VCLICK_PRIOR,
13
+ CLASS_VCLICK_TARGET,
14
+ CLASS_VCLICK_FADE,
7
15
  } from '../constants'
8
16
 
9
17
  function dirInject<T = unknown>(dir: DirectiveBinding<any>, key: InjectionKey<T> | string, defaultValue?: T): T | undefined {
@@ -26,9 +34,12 @@ export default function createDirectives() {
26
34
  const orderMap = dirInject(dir, injectionOrderMap)
27
35
 
28
36
  const hide = dir.modifiers.hide
37
+ const fade = dir.modifiers.fade
29
38
 
30
39
  const prev = elements?.value?.length || 0
31
40
 
41
+ const CLASS_HIDE = fade ? CLASS_VCLICK_FADE : CLASS_VCLICK_HIDDEN
42
+
32
43
  if (elements && !elements?.value?.includes(el))
33
44
  elements.value.push(el)
34
45
 
@@ -59,11 +70,12 @@ export default function createDirectives() {
59
70
  const show = dir.value != null
60
71
  ? c >= dir.value
61
72
  : c > prev
73
+
62
74
  if (!el.classList.contains(CLASS_VCLICK_HIDDEN_EXP))
63
- el.classList.toggle(CLASS_VCLICK_HIDDEN, !show)
75
+ el.classList.toggle(CLASS_HIDE, !show)
64
76
 
65
77
  if (hide !== false && hide !== undefined)
66
- el.classList.toggle(CLASS_VCLICK_HIDDEN, show)
78
+ el.classList.toggle(CLASS_HIDE, show)
67
79
 
68
80
  // Reset CLASS_VCLICK_CURRENT to false.
69
81
  el.classList.toggle(CLASS_VCLICK_CURRENT, false)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slidev/client",
3
- "version": "0.25.2",
3
+ "version": "0.25.6",
4
4
  "description": "Presentation slides for developers",
5
5
  "homepage": "https://sli.dev",
6
6
  "bugs": "https://github.com/slidevjs/slidev/issues",
@@ -13,13 +13,13 @@
13
13
  "author": "antfu <anthonyfu117@hotmail.com>",
14
14
  "dependencies": {
15
15
  "@antfu/utils": "^0.3.0",
16
- "@slidev/parser": "0.25.2",
17
- "@slidev/types": "0.25.2",
16
+ "@slidev/parser": "0.25.6",
17
+ "@slidev/types": "0.25.6",
18
18
  "@vueuse/core": "^6.4.0",
19
19
  "@vueuse/head": "^0.6.0",
20
20
  "@vueuse/motion": "^1.6.0",
21
21
  "codemirror": "^5.62.3",
22
- "drauu": "0.1.0",
22
+ "drauu": "^0.2.0",
23
23
  "file-saver": "^2.0.5",
24
24
  "js-base64": "^3.7.1",
25
25
  "js-yaml": "^4.1.0",
@@ -30,7 +30,7 @@
30
30
  "prettier": "^2.4.1",
31
31
  "recordrtc": "^5.6.2",
32
32
  "resolve": "^1.20.0",
33
- "vite-plugin-windicss": "^1.4.3",
33
+ "vite-plugin-windicss": "^1.4.5",
34
34
  "vue": "^3.2.12",
35
35
  "vue-router": "^4.0.11",
36
36
  "windicss": "^3.1.7"
package/state/index.ts CHANGED
@@ -2,13 +2,15 @@ import { useMagicKeys, useActiveElement, useStorage, useBreakpoints, breakpoints
2
2
  import { computed, ref } from 'vue'
3
3
  import { slideAspect } from '../env'
4
4
 
5
- export const showOverview = ref(false)
6
5
  export const showRecordingDialog = ref(false)
7
6
  export const showInfoDialog = ref(false)
8
7
  export const showGotoDialog = ref(false)
9
8
 
10
9
  export const shortcutsEnabled = ref(true)
11
- export const breakpoints = useBreakpoints(breakpointsTailwind)
10
+ export const breakpoints = useBreakpoints({
11
+ xs: 460,
12
+ ...breakpointsTailwind,
13
+ })
12
14
  export const windowSize = useWindowSize()
13
15
  export const magicKeys = useMagicKeys()
14
16
  export const isScreenVertical = computed(() => windowSize.height.value - windowSize.width.value / slideAspect > 180)
@@ -22,6 +24,7 @@ export const currentCamera = useStorage<string>('slidev-camera', 'default')
22
24
  export const currentMic = useStorage<string>('slidev-mic', 'default')
23
25
  export const slideScale = useStorage<number>('slidev-scale', 0)
24
26
 
27
+ export const showOverview = useStorage('slidev-show-overview', false)
25
28
  export const showPresenterCursor = useStorage('slidev-presenter-cursor', true)
26
29
  export const showEditor = useStorage('slidev-show-editor', false)
27
30
  export const editorWidth = useStorage('slidev-editor-width', isClient ? window.innerWidth * 0.4 : 100)
package/styles/index.css CHANGED
@@ -40,6 +40,10 @@ html {
40
40
  @apply !opacity-0 !pointer-events-none;
41
41
  }
42
42
 
43
+ .slidev-vclick-fade {
44
+ @apply opacity-50;
45
+ }
46
+
43
47
  .slidev-icon {
44
48
  display: inline-block;
45
49
  vertical-align: sub;