@slidev/client 0.25.0 → 0.25.4

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.
@@ -94,7 +94,7 @@ if (__SLIDEV_FEATURE_DRAWINGS__)
94
94
  </button>
95
95
  </template>
96
96
 
97
- <template v-if="__SLIDEV_FEATURE_DRAWINGS__ && !isEmbedded">
97
+ <template v-if="__SLIDEV_FEATURE_DRAWINGS__ && !configs.drawings.presenterOnly && !isEmbedded">
98
98
  <button class="icon-btn relative" title="Drawing" @click="drawingEnabled = !drawingEnabled">
99
99
  <carbon:pen />
100
100
  <div
@@ -4,7 +4,7 @@ import { showEditor, windowSize, isScreenVertical, slideScale } from '../state'
4
4
  import { isPrintMode, next, prev, useSwipeControls, isEmbedded } from '../logic/nav'
5
5
  import { isDrawing } from '../logic/drawings'
6
6
  import { registerShortcuts } from '../logic/shortcuts'
7
- import { themeVars } from '../env'
7
+ import { themeVars, configs } from '../env'
8
8
  import Controls from './Controls.vue'
9
9
  import SlideContainer from './SlideContainer.vue'
10
10
  import NavControls from './NavControls.vue'
@@ -61,7 +61,7 @@ if (__SLIDEV_FEATURE_DRAWINGS__)
61
61
  >
62
62
  <NavControls class="m-auto" :persist="presistNav" />
63
63
  </div>
64
- <template v-if="__SLIDEV_FEATURE_DRAWINGS__ && !isEmbedded && DrawingControls">
64
+ <template v-if="__SLIDEV_FEATURE_DRAWINGS__ && !configs.drawings.presenterOnly && !isEmbedded && DrawingControls">
65
65
  <DrawingControls class="ml-0" />
66
66
  </template>
67
67
  </template>
package/logic/drawings.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { computed, markRaw, nextTick, reactive, ref, watch } from 'vue'
1
+ import { computed, markRaw, nextTick, reactive, ref, watch, watchEffect } from 'vue'
2
2
  import { Brush, createDrauu, DrawingMode, Options as DrauuOptions } from 'drauu'
3
3
  import { useStorage, toReactive } from '@vueuse/core'
4
- import { serverDrawingState as drawingState } from '../env'
5
- import { currentPage } from './nav'
4
+ import { serverDrawingState as drawingState, configs } from '../env'
5
+ import { currentPage, isPresenter } from './nav'
6
6
 
7
7
  export const brushColors = [
8
8
  '#ff595e',
@@ -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
 
@@ -98,6 +99,10 @@ if (__DEV__) {
98
99
  return
99
100
  loadCanvas()
100
101
  }, { immediate: true })
102
+
103
+ watchEffect(() => {
104
+ drawingState.$syncUp = configs.drawings.syncAll || isPresenter.value
105
+ })
101
106
  })
102
107
 
103
108
  drauu.on('start', () => isDrawing.value = true)
package/logic/nav.ts CHANGED
@@ -1,8 +1,9 @@
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
 
@@ -91,15 +92,24 @@ export function go(page: number, clicks?: number) {
91
92
 
92
93
  export function useSwipeControls(root: Ref<HTMLElement | undefined>) {
93
94
  const swipeBegin = ref(0)
94
- const { direction, lengthX, lengthY } = useSwipe(root, {
95
- onSwipeStart() {
95
+ const { direction, distanceX, distanceY } = usePointerSwipe(root, {
96
+ onSwipeStart(e) {
97
+ if (e.pointerType !== 'touch')
98
+ return
99
+ if (isDrawing.value)
100
+ return
96
101
  swipeBegin.value = timestamp()
97
102
  },
98
- onSwipeEnd() {
103
+ onSwipeEnd(e) {
104
+ if (e.pointerType !== 'touch')
105
+ return
99
106
  if (!swipeBegin.value)
100
107
  return
101
- const x = Math.abs(lengthX.value)
102
- const y = Math.abs(lengthY.value)
108
+ if (isDrawing.value)
109
+ return
110
+
111
+ const x = Math.abs(distanceX.value)
112
+ const y = Math.abs(distanceY.value)
103
113
  if (x / window.innerWidth > 0.3 || x > 100) {
104
114
  if (direction.value === SwipeDirection.LEFT)
105
115
  next()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slidev/client",
3
- "version": "0.25.0",
3
+ "version": "0.25.4",
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.0",
17
- "@slidev/types": "0.25.0",
16
+ "@slidev/parser": "0.25.4",
17
+ "@slidev/types": "0.25.4",
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.2",
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",