@slidev/client 0.43.2 → 0.43.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.
@@ -2,7 +2,7 @@
2
2
  import { computed, inject } from 'vue'
3
3
  import type { RenderContext } from '@slidev/types'
4
4
 
5
- import { injectionSlideContext } from '../constants'
5
+ import { injectionRenderContext } from '../constants'
6
6
 
7
7
  type Context = 'main' | RenderContext
8
8
 
@@ -11,14 +11,14 @@ const props = defineProps<{
11
11
  }>()
12
12
  const { context } = props
13
13
 
14
- const currentContext = inject(injectionSlideContext)
14
+ const currentContext = inject(injectionRenderContext)
15
15
 
16
16
  const shouldRender = computed(() => Array.isArray(context) ? context.some(contextMatch) : contextMatch(context))
17
17
 
18
18
  function contextMatch(context: Context) {
19
- if (context === currentContext)
19
+ if (context === currentContext?.value)
20
20
  return true
21
- if (context === 'main' && (currentContext === 'slide' || currentContext === 'presenter'))
21
+ if (context === 'main' && (currentContext?.value === 'slide' || currentContext?.value === 'presenter'))
22
22
  return true
23
23
  return false
24
24
  }
@@ -1,7 +1,7 @@
1
1
  <script setup lang="ts">
2
2
  import { computed, inject, onMounted, onUnmounted, ref, watch } from 'vue'
3
3
 
4
- import { injectionClicks, injectionClicksDisabled, injectionClicksElements, injectionRoute, injectionSlideContext, injectionSlidevContext } from '../constants'
4
+ import { injectionClicks, injectionClicksDisabled, injectionClicksElements, injectionRenderContext, injectionRoute, injectionSlidevContext } from '../constants'
5
5
 
6
6
  const props = defineProps<{
7
7
  autoPlay?: boolean | 'once' | 'resume' | 'resumeOnce'
@@ -11,7 +11,7 @@ const props = defineProps<{
11
11
 
12
12
  const $slidev = inject(injectionSlidevContext)
13
13
  const route = inject(injectionRoute)
14
- const currentContext = inject(injectionSlideContext)
14
+ const currentContext = inject(injectionRenderContext)
15
15
  const clicks = inject(injectionClicks)
16
16
  const clicksDisabled = inject(injectionClicksDisabled)
17
17
  const clicksElements = inject(injectionClicksElements)
@@ -21,13 +21,13 @@ const played = ref(false)
21
21
  const ended = ref(false)
22
22
 
23
23
  const matchRoute = computed(() => {
24
- if (!video.value || currentContext !== 'slide')
24
+ if (!video.value || currentContext?.value !== 'slide')
25
25
  return false
26
26
  return route === $slidev?.nav.currentRoute
27
27
  })
28
28
 
29
29
  const matchClick = computed(() => {
30
- if (!video.value || currentContext !== 'slide' || clicks?.value === undefined || clicksDisabled?.value)
30
+ if (!video.value || currentContext?.value !== 'slide' || clicks?.value === undefined || clicksDisabled?.value)
31
31
  return false
32
32
  return !clicksElements?.value.includes(video.value) || clicksElements?.value[clicks?.value - 1] === video.value
33
33
  })
@@ -35,7 +35,7 @@ const matchClick = computed(() => {
35
35
  const matchRouteAndClick = computed(() => matchRoute.value && matchClick.value)
36
36
 
37
37
  watch(matchRouteAndClick, () => {
38
- if (!video.value || currentContext !== 'slide')
38
+ if (!video.value || currentContext?.value !== 'slide')
39
39
  return
40
40
 
41
41
  if (matchRouteAndClick.value) {
@@ -50,7 +50,7 @@ watch(matchRouteAndClick, () => {
50
50
  })
51
51
 
52
52
  watch(matchRoute, () => {
53
- if (!video.value || currentContext !== 'slide')
53
+ if (!video.value || currentContext?.value !== 'slide')
54
54
  return
55
55
 
56
56
  if (matchRoute.value && props.autoReset === 'slide')
@@ -66,14 +66,14 @@ function onEnded() {
66
66
  }
67
67
 
68
68
  onMounted(() => {
69
- if (!video.value || currentContext !== 'slide')
69
+ if (!video.value || currentContext?.value !== 'slide')
70
70
  return
71
71
  video.value?.addEventListener('play', onPlay)
72
72
  video.value?.addEventListener('ended', onEnded)
73
73
  })
74
74
 
75
75
  onUnmounted(() => {
76
- if (!video.value || currentContext !== 'slide')
76
+ if (!video.value || currentContext?.value !== 'slide')
77
77
  return
78
78
  video.value?.removeEventListener('play', onPlay)
79
79
  video.value?.removeEventListener('ended', onEnded)
package/builtin/Toc.vue CHANGED
@@ -16,6 +16,8 @@ const props = withDefaults(
16
16
  defineProps<{
17
17
  columns?: string | number
18
18
  listClass?: string | string[]
19
+ start?: string | number
20
+ listStyle?: string | string[]
19
21
  maxDepth?: string | number
20
22
  minDepth?: string | number
21
23
  mode?: 'all' | 'onlyCurrentTree' | 'onlySiblings'
@@ -23,6 +25,8 @@ const props = withDefaults(
23
25
  {
24
26
  columns: 1,
25
27
  listClass: '',
28
+ start: 1,
29
+ listStyle: '',
26
30
  maxDepth: Number.POSITIVE_INFINITY,
27
31
  minDepth: 1,
28
32
  mode: 'all',
@@ -85,6 +89,12 @@ const toc = computed(() => {
85
89
 
86
90
  <template>
87
91
  <div class="slidev-toc" :style="`column-count:${columns}`">
88
- <TocList :level="1" :list="toc" :list-class="listClass" />
92
+ <TocList
93
+ :level="1"
94
+ :start="start"
95
+ :list-style="listStyle"
96
+ :list="toc"
97
+ :list-class="listClass"
98
+ />
89
99
  </div>
90
100
  </template>
@@ -14,6 +14,8 @@ import Titles from '/@slidev/titles.md'
14
14
 
15
15
  const props = withDefaults(defineProps<{
16
16
  level: number
17
+ start?: number
18
+ listStyle?: string | string[]
17
19
  list: TocItem[]
18
20
  listClass?: string | string[]
19
21
  }>(), { level: 1 })
@@ -25,10 +27,21 @@ const classes = computed(() => {
25
27
  `slidev-toc-list-level-${props.level}`,
26
28
  ]
27
29
  })
30
+
31
+ const styles = computed(() => {
32
+ return [
33
+ ...toArray(props.listStyle || []),
34
+ ]
35
+ })
28
36
  </script>
29
37
 
30
38
  <template>
31
- <ol v-if="list && list.length > 0" :class="classes">
39
+ <ol
40
+ v-if="list && list.length > 0"
41
+ :class="classes"
42
+ :start="level === 1 ? start : undefined"
43
+ :style="styles.length >= level ? `list-style:${styles[level - 1]}` : undefined"
44
+ >
32
45
  <li
33
46
  v-for="item of list"
34
47
  :key="item.path" class="slidev-toc-item"
@@ -40,6 +53,7 @@ const classes = computed(() => {
40
53
  <TocList
41
54
  v-if="item.children.length > 0"
42
55
  :level="level + 1"
56
+ :list-style="listStyle"
43
57
  :list="item.children"
44
58
  :list-class="listClass"
45
59
  />
package/constants.ts CHANGED
@@ -7,11 +7,11 @@ export const injectionClicks: InjectionKey<Ref<number>> = Symbol('v-click-clicks
7
7
  export const injectionClicksElements: InjectionKey<Ref<(Element | string)[]>> = Symbol('v-click-clicks-elements')
8
8
  export const injectionClicksDisabled: InjectionKey<Ref<boolean>> = Symbol('v-click-clicks-disabled')
9
9
  export const injectionOrderMap: InjectionKey<Ref<Map<number, HTMLElement[]>>> = Symbol('v-click-clicks-order-map')
10
- export const injectionCurrentPage: InjectionKey<number> = Symbol('slidev-page')
10
+ export const injectionCurrentPage: InjectionKey<Ref<number>> = Symbol('slidev-page')
11
11
  export const injectionSlideScale: InjectionKey<ComputedRef<number>> = Symbol('slidev-slide-scale')
12
12
  export const injectionSlidevContext: InjectionKey<UnwrapNestedRefs<SlidevContext>> = Symbol('slidev-slidev-context')
13
13
  export const injectionRoute: InjectionKey<RouteRecordRaw> = Symbol('slidev-route')
14
- export const injectionSlideContext: InjectionKey<RenderContext> = Symbol('slidev-slide-context')
14
+ export const injectionRenderContext: InjectionKey<Ref<RenderContext>> = Symbol('slidev-render-context')
15
15
  export const injectionActive: InjectionKey<Ref<boolean>> = Symbol('slidev-active')
16
16
  export const injectionFrontmatter: InjectionKey<Record<string, any>> = Symbol('slidev-fontmatter')
17
17
 
@@ -51,7 +51,7 @@ if (__SLIDEV_FEATURE_DRAWINGS__)
51
51
  @pointerdown="onClick"
52
52
  >
53
53
  <template #default>
54
- <SlidesShow context="slide" />
54
+ <SlidesShow render-context="slide" />
55
55
  </template>
56
56
  <template #controls>
57
57
  <div
@@ -108,7 +108,7 @@ onMounted(() => {
108
108
  class="h-full w-full"
109
109
  >
110
110
  <template #default>
111
- <SlidesShow context="presenter" />
111
+ <SlidesShow render-context="presenter" />
112
112
  </template>
113
113
  </SlideContainer>
114
114
  <div class="context">
@@ -128,7 +128,7 @@ onMounted(() => {
128
128
  :clicks-disabled="false"
129
129
  :class="getSlideClass(nextSlide.route)"
130
130
  :route="nextSlide.route"
131
- context="previewNext"
131
+ render-context="previewNext"
132
132
  />
133
133
  </SlideContainer>
134
134
  <div class="context">
@@ -1,8 +1,8 @@
1
1
  import { useVModel } from '@vueuse/core'
2
2
  import type { Ref } from 'vue'
3
- import { defineComponent, h, provide, toRef } from 'vue'
3
+ import { defineComponent, h, provide, ref, toRef } from 'vue'
4
4
  import type { RenderContext } from '@slidev/types'
5
- import { injectionActive, injectionClicks, injectionClicksDisabled, injectionClicksElements, injectionCurrentPage, injectionOrderMap, injectionRoute, injectionSlideContext } from '../constants'
5
+ import { injectionActive, injectionClicks, injectionClicksDisabled, injectionClicksElements, injectionCurrentPage, injectionOrderMap, injectionRenderContext, injectionRoute } from '../constants'
6
6
 
7
7
  export default defineComponent({
8
8
  name: 'SlideWrapper',
@@ -23,7 +23,7 @@ export default defineComponent({
23
23
  type: Boolean,
24
24
  default: false,
25
25
  },
26
- context: {
26
+ renderContext: {
27
27
  type: String,
28
28
  default: 'main',
29
29
  },
@@ -49,8 +49,8 @@ export default defineComponent({
49
49
  clicksElements.value.length = 0
50
50
 
51
51
  provide(injectionRoute, props.route as any)
52
- provide(injectionCurrentPage, +props.route?.path)
53
- provide(injectionSlideContext, props.context as RenderContext)
52
+ provide(injectionCurrentPage, ref(+props.route?.path))
53
+ provide(injectionRenderContext, ref(props.renderContext as RenderContext))
54
54
  provide(injectionActive, toRef(props, 'active'))
55
55
  provide(injectionClicks, clicks as Ref<number>)
56
56
  provide(injectionClicksDisabled, clicksDisabled)
@@ -135,7 +135,7 @@ watchEffect(() => {
135
135
  :clicks-disabled="true"
136
136
  :class="getSlideClass(route)"
137
137
  :route="route"
138
- context="overview"
138
+ render-context="overview"
139
139
  />
140
140
  <DrawingPreview :page="+route.path" />
141
141
  </SlideContainer>
@@ -12,7 +12,9 @@ import GlobalTop from '/@slidev/global-components/top'
12
12
  import GlobalBottom from '/@slidev/global-components/bottom'
13
13
  import PresenterMouse from './PresenterMouse.vue'
14
14
 
15
- defineProps<{ context: 'slide' | 'presenter' }>()
15
+ defineProps<{
16
+ renderContext: 'slide' | 'presenter'
17
+ }>()
16
18
 
17
19
  // preload next route
18
20
  watch(currentRoute, () => {
@@ -56,7 +58,7 @@ const loadedRoutes = computed(() => rawRoutes.filter(r => r.meta?.__preloaded ||
56
58
  :clicks-disabled="false"
57
59
  :class="getSlideClass(route)"
58
60
  :route="route"
59
- :context="context"
61
+ :render-context="renderContext"
60
62
  />
61
63
  </template>
62
64
  </component>
package/logic/nav.ts CHANGED
@@ -146,7 +146,7 @@ export function useSwipeControls(root: Ref<HTMLElement | undefined>) {
146
146
 
147
147
  const x = Math.abs(distanceX.value)
148
148
  const y = Math.abs(distanceY.value)
149
- if (x / window.innerWidth > 0.3 || x > 100) {
149
+ if (x / window.innerWidth > 0.3 || x > 75) {
150
150
  if (direction.value === 'left')
151
151
  next()
152
152
  else
@@ -195,7 +195,7 @@ export function addToTree(tree: TocItem[], route: RouteRecordRaw, level = 1) {
195
195
  children: [],
196
196
  level,
197
197
  path: route.path,
198
- hideInToc: Boolean(route.meta?.hideInToc),
198
+ hideInToc: Boolean(route.meta?.slide?.frontmatter?.hideInToc),
199
199
  title: route.meta?.slide?.title,
200
200
  })
201
201
  }
@@ -1,12 +1,12 @@
1
1
  import type { App } from 'vue'
2
- import { reactive } from 'vue'
2
+ import { computed, reactive } from 'vue'
3
3
  import type { RouteLocationNormalizedLoaded, RouteRecordRaw } from 'vue-router'
4
4
  import type { ComputedRef } from '@vue/reactivity'
5
5
  import type { configs } from '../env'
6
6
  import * as nav from '../logic/nav'
7
7
  import { clicks, route } from '../logic/nav'
8
8
  import { isDark } from '../logic/dark'
9
- import { injectionSlidevContext } from '../constants'
9
+ import { injectionClicks, injectionCurrentPage, injectionSlidevContext } from '../constants'
10
10
  import { useContext } from '../composables/useContext'
11
11
 
12
12
  export type SlidevContextNavKey = 'path' | 'total' | 'currentPage' | 'currentPath' | 'currentRoute' | 'currentSlideId' | 'currentLayout' | 'nextRoute' | 'rawTree' | 'treeWithActiveStatuses' | 'tree' | 'downloadPDF' | 'next' | 'nextSlide' | 'openInEditor' | 'prev' | 'prevSlide' | 'rawRoutes'
@@ -26,8 +26,10 @@ export interface SlidevContext {
26
26
  export default function createSlidevContext() {
27
27
  return {
28
28
  install(app: App) {
29
- const context = useContext(route, clicks)
30
- app.provide(injectionSlidevContext, reactive(context))
29
+ const context = reactive(useContext(route, clicks))
30
+ app.provide(injectionSlidevContext, context)
31
+ app.provide(injectionCurrentPage, computed(() => context.nav.currentPage))
32
+ app.provide(injectionClicks, computed(() => context.nav.clicks))
31
33
 
32
34
  // allows controls from postMessages
33
35
  if (__DEV__) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slidev/client",
3
- "version": "0.43.2",
3
+ "version": "0.43.4",
4
4
  "description": "Presentation slides for developers",
5
5
  "author": "antfu <anthonyfu117@hotmail.com>",
6
6
  "license": "MIT",
@@ -18,12 +18,12 @@
18
18
  "@antfu/utils": "^0.7.6",
19
19
  "@unocss/reset": "^0.55.7",
20
20
  "@vueuse/core": "^10.4.1",
21
- "@vueuse/head": "^1.3.1",
21
+ "@vueuse/head": "^2.0.0",
22
22
  "@vueuse/math": "^10.4.1",
23
23
  "@vueuse/motion": "^2.0.0",
24
24
  "codemirror": "^5.65.5",
25
25
  "defu": "^6.1.2",
26
- "drauu": "^0.3.6",
26
+ "drauu": "^0.3.7",
27
27
  "file-saver": "^2.0.5",
28
28
  "fuse.js": "^6.6.2",
29
29
  "js-base64": "^3.7.5",
@@ -31,18 +31,18 @@
31
31
  "katex": "^0.16.8",
32
32
  "mermaid": "^10.4.0",
33
33
  "monaco-editor": "^0.37.1",
34
- "nanoid": "^4.0.2",
34
+ "nanoid": "^5.0.1",
35
35
  "prettier": "^3.0.3",
36
36
  "recordrtc": "^5.6.2",
37
- "resolve": "^1.22.4",
37
+ "resolve": "^1.22.6",
38
38
  "unocss": "^0.55.7",
39
39
  "vite-plugin-windicss": "^1.9.1",
40
40
  "vue": "^3.3.4",
41
41
  "vue-router": "^4.2.4",
42
42
  "vue-starport": "^0.4.0",
43
43
  "windicss": "^3.5.6",
44
- "@slidev/parser": "0.43.2",
45
- "@slidev/types": "0.43.2"
44
+ "@slidev/parser": "0.43.4",
45
+ "@slidev/types": "0.43.4"
46
46
  },
47
47
  "devDependencies": {
48
48
  "vite": "^4.4.9"