@slidev/client 0.49.12 → 0.49.14

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.
@@ -4,7 +4,7 @@ import { computed } from 'vue'
4
4
  import { getSlidePath } from '../logic/slides'
5
5
 
6
6
  function addToTree(tree: TocItem[], route: SlideRoute, level = 1) {
7
- const titleLevel = route.meta?.slide?.level
7
+ const titleLevel = route.meta.slide.level ?? level
8
8
  if (titleLevel && titleLevel > level && tree.length > 0) {
9
9
  addToTree(tree[tree.length - 1].children, route, level + 1)
10
10
  }
@@ -13,6 +13,7 @@ function addToTree(tree: TocItem[], route: SlideRoute, level = 1) {
13
13
  no: route.no,
14
14
  children: [],
15
15
  level,
16
+ titleLevel,
16
17
  path: getSlidePath(route.meta.slide?.frontmatter?.routeAlias ?? route.no, false),
17
18
  hideInToc: Boolean(route.meta?.slide?.frontmatter?.hideInToc),
18
19
  title: route.meta?.slide?.title,
package/context.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { computed, ref, toRef } from 'vue'
2
- import { injectLocal, objectOmit, provideLocal } from '@vueuse/core'
2
+ import { injectLocal, objectOmit } from '@vueuse/core'
3
3
  import {
4
4
  FRONTMATTER_FIELDS,
5
5
  HEADMATTER_FIELDS,
@@ -44,28 +44,6 @@ export function useSlideContext() {
44
44
 
45
45
  export type SlideContext = ReturnType<typeof useSlideContext>
46
46
 
47
- /**
48
- * @internal
49
- */
50
- export function provideFrontmatter(frontmatter: Record<string, any>) {
51
- provideLocal(injectionFrontmatter, frontmatter)
52
-
53
- const {
54
- $slidev,
55
- $page,
56
- } = useSlideContext()
57
-
58
- // update frontmatter in router to make HMR work better
59
- const route = $slidev.nav.slides.find(i => i.no === $page.value)
60
- if (route?.meta?.slide?.frontmatter) {
61
- for (const key of Object.keys(route.meta.slide.frontmatter)) {
62
- if (!(key in frontmatter))
63
- delete route.meta.slide.frontmatter[key]
64
- }
65
- Object.assign(route.meta.slide.frontmatter, frontmatter)
66
- }
67
- }
68
-
69
47
  /**
70
48
  * Convert frontmatter options to props for v-bind
71
49
  * It removes known options fields, and expose an extra `frontmatter` field that contains full frontmatter
@@ -116,7 +116,7 @@ function processNote() {
116
116
  }
117
117
  : null
118
118
 
119
- if (!enabled && props.autoScroll && clicks === current)
119
+ if (enabled && props.autoScroll && clicks === current)
120
120
  marker.scrollIntoView({ block: 'center', behavior: 'smooth' })
121
121
  }
122
122
  }
@@ -1,5 +1,5 @@
1
1
  <script setup lang="ts">
2
- import { ref, watchEffect } from 'vue'
2
+ import { ref, shallowRef } from 'vue'
3
3
  import { getHighlighter } from '#slidev/shiki'
4
4
 
5
5
  const props = defineProps<{
@@ -9,33 +9,17 @@ const content = defineModel<string>({ required: true })
9
9
 
10
10
  const textareaEl = ref<HTMLTextAreaElement | null>(null)
11
11
 
12
- const html = ref('')
13
-
14
- watchEffect((onCleanup) => {
15
- let canceled = false
16
- onCleanup(() => canceled = true)
17
-
18
- const c = content.value
19
- async function updateHtml() {
20
- const highlight = await getHighlighter()
21
- if (canceled)
22
- return
23
- const h = await highlight(c, 'markdown')
24
- if (canceled)
25
- return
26
- html.value = h
27
- }
28
- updateHtml()
29
- })
12
+ const highlight = shallowRef<Awaited<ReturnType<typeof getHighlighter>> | null>(null)
13
+ getHighlighter().then(h => highlight.value = h)
30
14
  </script>
31
15
 
32
16
  <template>
33
- <div class="absolute inset-x-3 inset-y-2 font-mono overflow-x-hidden overflow-y-auto">
34
- <div class="relative w-full h-max">
35
- <div class="relative w-full h-max" v-html="html" />
17
+ <div class="absolute left-3 right-0 inset-y-2 font-mono overflow-x-hidden overflow-y-auto cursor-text">
18
+ <div v-if="highlight" class="relative w-full h-max min-h-full">
19
+ <div class="relative w-full h-max" v-html="`${highlight(content, 'markdown')}&nbsp;`" />
36
20
  <textarea
37
21
  ref="textareaEl" v-model="content" :placeholder="props.placeholder"
38
- class="absolute inset-0 resize-none text-transparent bg-transparent focus:outline-none caret-white overflow-y-hidden"
22
+ class="absolute inset-0 resize-none text-transparent bg-transparent focus:outline-none caret-black dark:caret-white overflow-y-hidden"
39
23
  />
40
24
  </div>
41
25
  </div>
@@ -58,10 +58,9 @@ useEventListener('keydown', (e) => {
58
58
  const contentRef = computed({
59
59
  get() { return content.value },
60
60
  set(v) {
61
- if (content.value.trim() !== v.trim()) {
62
- content.value = v
61
+ if (content.value.trim() !== v.trim())
63
62
  dirty.value = true
64
- }
63
+ content.value = v
65
64
  },
66
65
  })
67
66
 
@@ -126,7 +125,7 @@ throttledWatch(
126
125
  }" @pointerdown="onHandlerDown"
127
126
  />
128
127
  <div
129
- class="shadow bg-main p-4 grid grid-rows-[max-content_1fr] h-full overflow-hidden"
128
+ class="shadow bg-main p-2 pt-4 grid grid-rows-[max-content_1fr] h-full overflow-hidden"
130
129
  :class="resize ? 'border-l border-gray-400 border-opacity-20' : ''"
131
130
  :style="resize ? {
132
131
  height: vertical ? `${editorHeight}px` : undefined,
@@ -3,7 +3,7 @@ import { computed, defineAsyncComponent, defineComponent, h, ref, toRef } from '
3
3
  import type { CSSProperties, PropType } from 'vue'
4
4
  import { provideLocal } from '@vueuse/core'
5
5
  import type { ClicksContext, RenderContext, SlideRoute } from '@slidev/types'
6
- import { injectionClicksContext, injectionCurrentPage, injectionRenderContext, injectionRoute, injectionSlideZoom } from '../constants'
6
+ import { injectionClicksContext, injectionCurrentPage, injectionFrontmatter, injectionRenderContext, injectionRoute, injectionSlideZoom } from '../constants'
7
7
  import { getSlideClass } from '../utils'
8
8
  import { configs } from '../env'
9
9
  import SlideLoading from './SlideLoading.vue'
@@ -27,6 +27,7 @@ const props = defineProps({
27
27
  const zoom = computed(() => props.route.meta?.slide?.frontmatter.zoom ?? 1)
28
28
 
29
29
  provideLocal(injectionRoute, props.route)
30
+ provideLocal(injectionFrontmatter, props.route.meta.slide.frontmatter)
30
31
  provideLocal(injectionCurrentPage, ref(props.route.no))
31
32
  provideLocal(injectionRenderContext, ref(props.renderContext))
32
33
  provideLocal(injectionClicksContext, toRef(props, 'clicksContext'))
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@slidev/client",
3
3
  "type": "module",
4
- "version": "0.49.12",
4
+ "version": "0.49.14",
5
5
  "description": "Presentation slides for developers",
6
6
  "author": "antfu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -28,18 +28,18 @@
28
28
  "node": ">=18.0.0"
29
29
  },
30
30
  "dependencies": {
31
- "@antfu/utils": "^0.7.8",
31
+ "@antfu/utils": "^0.7.10",
32
32
  "@iconify-json/carbon": "^1.1.36",
33
33
  "@iconify-json/ph": "^1.1.13",
34
34
  "@iconify-json/svg-spinners": "^1.1.2",
35
- "@shikijs/monaco": "^1.9.1",
36
- "@shikijs/vitepress-twoslash": "^1.9.1",
35
+ "@shikijs/monaco": "^1.10.0",
36
+ "@shikijs/vitepress-twoslash": "^1.10.0",
37
37
  "@slidev/rough-notation": "^0.1.0",
38
38
  "@typescript/ata": "^0.9.6",
39
39
  "@unhead/vue": "^1.9.14",
40
- "@unocss/reset": "^0.61.0",
41
- "@vueuse/core": "^10.10.0",
42
- "@vueuse/math": "^10.10.0",
40
+ "@unocss/reset": "^0.61.2",
41
+ "@vueuse/core": "^10.11.0",
42
+ "@vueuse/math": "^10.11.0",
43
43
  "@vueuse/motion": "^2.2.3",
44
44
  "drauu": "^0.4.0",
45
45
  "file-saver": "^2.0.5",
@@ -48,20 +48,20 @@
48
48
  "katex": "^0.16.10",
49
49
  "lz-string": "^1.5.0",
50
50
  "mermaid": "^10.9.1",
51
- "monaco-editor": "^0.49.0",
52
- "prettier": "^3.3.0",
51
+ "monaco-editor": "^0.50.0",
52
+ "prettier": "^3.3.2",
53
53
  "recordrtc": "^5.6.2",
54
- "shiki": "^1.9.1",
54
+ "shiki": "^1.10.0",
55
55
  "shiki-magic-move": "^0.4.2",
56
56
  "typescript": "^5.5.2",
57
- "unocss": "^0.61.0",
58
- "vue": "^3.4.30",
57
+ "unocss": "^0.61.2",
58
+ "vue": "^3.4.31",
59
59
  "vue-router": "^4.4.0",
60
- "yaml": "^2.4.2",
61
- "@slidev/types": "0.49.12",
62
- "@slidev/parser": "0.49.12"
60
+ "yaml": "^2.4.5",
61
+ "@slidev/parser": "0.49.14",
62
+ "@slidev/types": "0.49.14"
63
63
  },
64
64
  "devDependencies": {
65
- "vite": "^5.3.1"
65
+ "vite": "^5.3.2"
66
66
  }
67
67
  }
package/pages/404.vue CHANGED
@@ -1,4 +1,4 @@
1
- <script setup>
1
+ <script setup lang="ts">
2
2
  import { computed } from 'vue'
3
3
  import { useRouter } from 'vue-router'
4
4
  import { useNav } from '../composables/useNav'
package/pages/play.vue CHANGED
@@ -1,6 +1,7 @@
1
1
  <script setup lang="ts">
2
2
  import { computed, ref, shallowRef } from 'vue'
3
- import { isEditorVertical, isScreenVertical, showEditor, windowSize } from '../state'
3
+ import { useStyleTag } from '@vueuse/core'
4
+ import { editorHeight, editorWidth, isEditorVertical, isScreenVertical, showEditor, windowSize } from '../state'
4
5
  import { useSwipeControls } from '../composables/useSwipeControls'
5
6
  import { registerShortcuts } from '../logic/shortcuts'
6
7
  import Controls from '../internals/Controls.vue'
@@ -36,6 +37,19 @@ registerShortcuts()
36
37
  if (__SLIDEV_FEATURE_WAKE_LOCK__)
37
38
  useWakeLock()
38
39
 
40
+ useStyleTag(computed(() => `
41
+ vite-error-overlay {
42
+ --width: calc(100vw - ${isEditorVertical.value ? 0 : editorWidth.value}px);
43
+ --height: calc(100vh - ${isEditorVertical.value ? editorHeight.value : 0}px);
44
+ position: fixed;
45
+ left: 0;
46
+ top: 0;
47
+ width: calc(var(--width) / var(--slidev-slide-scale));
48
+ height: calc(var(--height) / var(--slidev-slide-scale));
49
+ transform-origin: top left;
50
+ transform: scale(var(--slidev-slide-scale));
51
+ }`))
52
+
39
53
  const persistNav = computed(() => isScreenVertical.value || showEditor.value)
40
54
 
41
55
  const SideEditor = shallowRef<any>()
package/setup/main.ts CHANGED
@@ -13,7 +13,6 @@ import setupRoutes from '../setup/routes'
13
13
  import setups from '#slidev/setups/main'
14
14
 
15
15
  import '#slidev/styles'
16
- import 'shiki-magic-move/style.css'
17
16
 
18
17
  export default async function setupMain(app: App) {
19
18
  function setMaxHeight() {
package/setup/root.ts CHANGED
@@ -21,7 +21,7 @@ export default function setupRoot() {
21
21
  configs,
22
22
  themeConfigs: computed(() => configs.themeConfig),
23
23
  })
24
- app.provide(injectionRenderContext, ref('none'))
24
+ app.provide(injectionRenderContext, ref('none' as const))
25
25
  app.provide(injectionSlidevContext, context)
26
26
  app.provide(injectionCurrentPage, computed(() => context.nav.currentSlideNo))
27
27
  app.provide(injectionClicksContext, shallowRef(createFixedClicks()))
package/shim-vue.d.ts CHANGED
@@ -9,7 +9,7 @@ declare module 'vue-router' {
9
9
 
10
10
  interface RouteMeta {
11
11
  // inherited from frontmatter
12
- layout: string
12
+ layout?: string
13
13
  name?: string
14
14
  class?: string
15
15
  clicks?: number
@@ -26,7 +26,7 @@ declare module 'vue-router' {
26
26
  }
27
27
 
28
28
  // private fields
29
- __clicksContext: import('@slidev/types').ClicksContext | undefined
29
+ __clicksContext: import('@slidev/types').ClicksContext | null
30
30
  __preloaded?: boolean
31
31
  }
32
32
  }