@slidev/client 52.18.1 → 52.19.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.
@@ -51,8 +51,9 @@ const props = defineProps({
51
51
  default: '',
52
52
  },
53
53
  })
54
+ const { $frontmatter, $clicksContext: clicks } = useSlideContext()
55
+ const isCodeCopy = computed(() => $frontmatter?.codeCopy ?? configs.codeCopy)
54
56
 
55
- const { $clicksContext: clicks } = useSlideContext()
56
57
  const el = ref<HTMLDivElement>()
57
58
  const id = makeId()
58
59
 
@@ -152,7 +153,7 @@ const isBlockTitleShow = computed(() => {
152
153
  </div>
153
154
  <slot />
154
155
  <button
155
- v-if="configs.codeCopy"
156
+ v-if="isCodeCopy"
156
157
  class="slidev-code-copy absolute right-0 transition opacity-0 group-hover:opacity-20 hover:!opacity-100"
157
158
  :class="isBlockTitleShow ? 'top-10' : 'top-0'"
158
159
  :title="copied ? 'Copied' : 'Copy'" @click="copyCode()"
@@ -41,7 +41,7 @@ const props = defineProps({
41
41
  })
42
42
 
43
43
  const steps = JSON.parse(lz.decompressFromBase64(props.stepsLz)) as KeyedTokensInfo[]
44
- const { $clicksContext: clicks, $scale: scale, $zoom: zoom } = useSlideContext()
44
+ const { $clicksContext: clicks, $scale: scale, $zoom: zoom, $frontmatter } = useSlideContext()
45
45
  const { isPrintMode } = useNav()
46
46
  const id = makeId()
47
47
 
@@ -51,10 +51,11 @@ const isFirstTick = ref(true)
51
51
  const container = ref<HTMLElement>()
52
52
 
53
53
  const showCopyButton = computed(() => {
54
- if (!configs.codeCopy)
54
+ const codeCopy = $frontmatter?.codeCopy ?? configs.codeCopy
55
+ if (!codeCopy)
55
56
  return false
56
57
 
57
- const magicCopy = configs.magicMoveCopy
58
+ const magicCopy = $frontmatter?.magicMoveCopy ?? configs.magicMoveCopy
58
59
  if (!magicCopy)
59
60
  return false
60
61
 
@@ -127,4 +127,14 @@ describe('useNavBase', () => {
127
127
  expect(observedNav?.currentSlideRoute.value.meta.slide.frontmatter.title).toBe('Second')
128
128
  expect(observedNav?.tocTree.value[1].active).toBe(true)
129
129
  })
130
+
131
+ it('falls back to the shared nav when there is no injection context', () => {
132
+ // Directive hooks such as `v-motion`'s and `v-mark`'s `mounted` call
133
+ // `useNav()` while no component instance is current. There is no
134
+ // slide-local context to read there, so the shared nav is the answer.
135
+ vi.stubGlobal('location', { search: '' })
136
+
137
+ expect(() => useNav()).not.toThrow()
138
+ expect(useNav().currentSlideNo.value).toBe(1)
139
+ })
130
140
  })
@@ -4,7 +4,7 @@ import type { RouteLocationNormalized, Router } from 'vue-router'
4
4
  import { clamp } from '@antfu/utils'
5
5
  import { parseRangeString } from '@slidev/parser/utils'
6
6
  import { createSharedComposable, injectLocal } from '@vueuse/core'
7
- import { computed, ref, toRaw, watch } from 'vue'
7
+ import { computed, hasInjectionContext, ref, toRaw, watch } from 'vue'
8
8
  import { useRoute, useRouter } from 'vue-router'
9
9
  import { slides } from '#slidev/slides'
10
10
  import { CLICKS_MAX, injectionSlidevContext } from '../constants'
@@ -404,7 +404,13 @@ const useSharedNav = createSharedComposable((): SlidevContextNavFull => {
404
404
 
405
405
  export function useNav(): SlidevContextNavFull {
406
406
  const nav = useSharedNav()
407
- const context = injectLocal(injectionSlidevContext, undefined)
407
+ // `useNav()` is also called outside of `setup()`, most notably from the
408
+ // `mounted`/`created` hooks of the `v-motion` and `v-mark` directives.
409
+ // `injectLocal` throws there, and there is no slide-local context to read
410
+ // anyway, so fall back to the shared nav.
411
+ const context = hasInjectionContext()
412
+ ? injectLocal(injectionSlidevContext, undefined)
413
+ : undefined
408
414
  if (!context)
409
415
  return nav
410
416
 
@@ -111,7 +111,7 @@ watch(activeElement, () => {
111
111
  ref="container"
112
112
  class="fixed right-5 transition-all"
113
113
  w-90 max-w-90 min-w-90
114
- :class="showGotoDialog ? 'top-5' : '-top-20'"
114
+ :class="showGotoDialog ? 'top-5' : '-top-20 op0 pointer-events-none'"
115
115
  >
116
116
  <div
117
117
  class="bg-main transform"
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@slidev/client",
3
3
  "type": "module",
4
- "version": "52.18.1",
4
+ "version": "52.19.1",
5
5
  "description": "Presentation slides for developers",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -30,16 +30,16 @@
30
30
  "dependencies": {
31
31
  "@antfu/utils": "^9.3.0",
32
32
  "@fix-webm-duration/fix": "^1.0.1",
33
- "@iconify-json/carbon": "^1.2.24",
33
+ "@iconify-json/carbon": "^1.2.25",
34
34
  "@iconify-json/ph": "^1.2.2",
35
35
  "@iconify-json/svg-spinners": "^1.2.4",
36
- "@shikijs/engine-javascript": "^4.3.1",
37
- "@shikijs/magic-move": "^4.3.1",
38
- "@shikijs/monaco": "^4.3.1",
39
- "@shikijs/vitepress-twoslash": "^4.3.1",
36
+ "@shikijs/engine-javascript": "^4.4.3",
37
+ "@shikijs/magic-move": "^4.4.3",
38
+ "@shikijs/monaco": "^4.4.3",
39
+ "@shikijs/vitepress-twoslash": "^4.4.3",
40
40
  "@slidev/rough-notation": "^0.1.0",
41
41
  "@typescript/ata": "^0.9.8",
42
- "@unhead/vue": "^3.2.3",
42
+ "@unhead/vue": "^3.3.2",
43
43
  "@unocss/extractor-mdc": "^66.7.5",
44
44
  "@unocss/preset-mini": "^66.7.5",
45
45
  "@unocss/reset": "^66.7.5",
@@ -52,23 +52,23 @@
52
52
  "fitty": "^2.4.2",
53
53
  "floating-vue": "^5.2.2",
54
54
  "fuse.js": "^7.5.0",
55
- "katex": "^0.18.1",
55
+ "katex": "^0.18.4",
56
56
  "lz-string": "^1.5.0",
57
- "mermaid": "^11.16.0",
57
+ "mermaid": "^11.16.1",
58
58
  "monaco-editor": "^0.56.0",
59
59
  "nanotar": "^0.3.0",
60
60
  "pptxgenjs": "^4.0.1",
61
61
  "recordrtc": "^5.6.2",
62
- "shiki": "^4.3.1",
62
+ "shiki": "^4.4.3",
63
63
  "typescript": "^6.0.3",
64
64
  "unocss": "^66.7.5",
65
- "vue": "^3.5.40",
65
+ "vue": "^3.5.41",
66
66
  "vue-router": "^5.2.0",
67
67
  "yaml": "^2.9.0",
68
- "@slidev/parser": "52.18.1",
69
- "@slidev/types": "52.18.1"
68
+ "@slidev/parser": "52.19.1",
69
+ "@slidev/types": "52.19.1"
70
70
  },
71
71
  "devDependencies": {
72
- "vite": "^8.1.5"
72
+ "vite": "^8.2.1"
73
73
  }
74
74
  }