@slidev/client 0.49.29 → 0.50.0-beta.2

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.
Files changed (86) hide show
  1. package/builtin/Arrow.vue +1 -1
  2. package/builtin/CodeBlockWrapper.vue +3 -3
  3. package/builtin/KaTexBlockWrapper.vue +2 -2
  4. package/builtin/Mermaid.vue +1 -1
  5. package/builtin/Monaco.vue +5 -5
  6. package/builtin/RenderWhen.vue +2 -2
  7. package/builtin/ShikiMagicMove.vue +5 -5
  8. package/builtin/SlidevVideo.vue +2 -2
  9. package/builtin/Toc.vue +1 -1
  10. package/builtin/TocList.vue +2 -2
  11. package/builtin/VAfter.ts +1 -1
  12. package/builtin/VClick.ts +1 -1
  13. package/builtin/VClickGap.vue +1 -1
  14. package/builtin/VClicks.ts +1 -1
  15. package/builtin/VDrag.vue +1 -1
  16. package/builtin/VDragArrow.vue +1 -1
  17. package/builtin/VSwitch.ts +4 -4
  18. package/composables/useClicks.ts +1 -1
  19. package/composables/useDragElements.ts +2 -2
  20. package/composables/useDrawings.ts +3 -3
  21. package/composables/useNav.ts +8 -8
  22. package/composables/useSlideInfo.ts +2 -2
  23. package/composables/useSwipeControls.ts +1 -1
  24. package/composables/useViewTransition.ts +1 -1
  25. package/constants.ts +2 -1
  26. package/context.ts +2 -2
  27. package/env.ts +2 -2
  28. package/index.ts +23 -5
  29. package/internals/CodeRunner.vue +4 -4
  30. package/internals/ContextMenu.vue +2 -2
  31. package/internals/Controls.vue +6 -6
  32. package/internals/DevicesList.vue +2 -2
  33. package/internals/DragControl.vue +2 -2
  34. package/internals/Draggable.vue +1 -1
  35. package/internals/DrawingControls.vue +140 -139
  36. package/internals/DrawingLayer.vue +1 -1
  37. package/internals/Goto.vue +3 -3
  38. package/internals/NavControls.vue +8 -8
  39. package/internals/NoteDisplay.vue +1 -1
  40. package/internals/NoteEditable.vue +2 -2
  41. package/internals/PrintContainer.vue +3 -3
  42. package/internals/PrintSlide.vue +1 -1
  43. package/internals/PrintSlideClick.vue +3 -3
  44. package/internals/QuickOverview.vue +9 -7
  45. package/internals/RecordingControls.vue +1 -1
  46. package/internals/RecordingDialog.vue +1 -1
  47. package/internals/SelectList.vue +1 -1
  48. package/internals/Settings.vue +1 -1
  49. package/internals/ShikiEditor.vue +1 -1
  50. package/internals/SideEditor.vue +1 -1
  51. package/internals/SlideContainer.vue +32 -3
  52. package/internals/SlideWrapper.vue +4 -4
  53. package/internals/SlidesShow.vue +6 -6
  54. package/internals/WebCamera.vue +1 -1
  55. package/logic/contextMenu.ts +3 -3
  56. package/logic/recording.ts +4 -4
  57. package/logic/shortcuts.ts +3 -3
  58. package/logic/slides.ts +2 -2
  59. package/logic/snapshot.ts +86 -0
  60. package/modules/context.ts +1 -1
  61. package/modules/mermaid.ts +3 -3
  62. package/modules/v-click.ts +1 -1
  63. package/modules/v-drag.ts +1 -1
  64. package/modules/v-mark.ts +2 -2
  65. package/modules/v-motion.ts +3 -3
  66. package/package.json +23 -22
  67. package/pages/notes.vue +7 -7
  68. package/pages/overview.vue +24 -11
  69. package/pages/play.vue +10 -10
  70. package/pages/presenter/print.vue +2 -2
  71. package/pages/presenter.vue +18 -18
  72. package/pages/print.vue +3 -3
  73. package/setup/code-runners.ts +4 -4
  74. package/setup/context-menu.ts +11 -11
  75. package/setup/main.ts +4 -4
  76. package/setup/mermaid.ts +1 -1
  77. package/setup/monaco.ts +13 -9
  78. package/setup/root.ts +9 -9
  79. package/setup/shortcuts.ts +5 -5
  80. package/state/drawings.ts +1 -0
  81. package/state/index.ts +1 -1
  82. package/state/shared.ts +2 -1
  83. package/state/snapshot.ts +13 -0
  84. package/state/syncState.ts +76 -24
  85. package/styles/index.css +1 -0
  86. package/uno.config.ts +2 -2
@@ -1,9 +1,9 @@
1
1
  import type { ContextMenuItem } from '@slidev/types'
2
2
  import type { ComputedRef } from 'vue'
3
3
  import { shallowRef } from 'vue'
4
- import setupContextMenu from '../setup/context-menu'
5
- import { configs, mode } from '../env'
6
4
  import { useNav } from '../composables/useNav'
5
+ import { configs, mode } from '../env'
6
+ import setupContextMenu from '../setup/context-menu'
7
7
 
8
8
  export const currentContextMenu = shallowRef<null | {
9
9
  x: number
@@ -24,7 +24,7 @@ export function closeContextMenu() {
24
24
  }
25
25
 
26
26
  export function onContextMenu(ev: MouseEvent) {
27
- if (configs.contextMenu !== true && configs.contextMenu !== undefined && configs.contextMenu !== mode)
27
+ if (configs.contextMenu !== true && configs.contextMenu != null && configs.contextMenu !== mode)
28
28
  return
29
29
  if (ev.shiftKey || ev.defaultPrevented)
30
30
  return
@@ -1,9 +1,9 @@
1
- import type { Ref } from 'vue'
2
- import { nextTick, ref, shallowRef, watch } from 'vue'
3
- import { useDevicesList, useEventListener, useLocalStorage } from '@vueuse/core'
4
- import { isTruthy } from '@antfu/utils'
5
1
  import type RecorderType from 'recordrtc'
6
2
  import type { Options as RecorderOptions } from 'recordrtc'
3
+ import type { Ref } from 'vue'
4
+ import { isTruthy } from '@antfu/utils'
5
+ import { useDevicesList, useEventListener, useLocalStorage } from '@vueuse/core'
6
+ import { nextTick, ref, shallowRef, watch } from 'vue'
7
7
  import { currentCamera, currentMic } from '../state'
8
8
 
9
9
  type Defined<T> = T extends undefined ? never : T
@@ -1,11 +1,11 @@
1
+ import type { ShortcutOptions } from '@slidev/types'
1
2
  import type { Fn, KeyFilter } from '@vueuse/core'
3
+ import type { Ref } from 'vue'
2
4
  import { onKeyStroke } from '@vueuse/core'
3
5
  import { and, not } from '@vueuse/math'
4
- import type { Ref } from 'vue'
5
6
  import { watch } from 'vue'
6
- import type { ShortcutOptions } from '@slidev/types'
7
- import { fullscreen, isInputting, isOnFocus, magicKeys, shortcutsEnabled } from '../state'
8
7
  import setupShortcuts from '../setup/shortcuts'
8
+ import { fullscreen, isInputting, isOnFocus, magicKeys, shortcutsEnabled } from '../state'
9
9
 
10
10
  const _shortcut = and(not(isInputting), not(isOnFocus), shortcutsEnabled)
11
11
 
package/logic/slides.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import type { SlideRoute } from '@slidev/types'
2
+ import { slides } from '#slidev/slides'
2
3
  import { computed, watch, watchEffect } from 'vue'
3
- import { useSlideContext } from '../context'
4
4
  import { useNav } from '../composables/useNav'
5
- import { slides } from '#slidev/slides'
5
+ import { useSlideContext } from '../context'
6
6
 
7
7
  export { slides }
8
8
 
@@ -0,0 +1,86 @@
1
+ import { snapshotState } from '../state/snapshot'
2
+ import { getSlide } from './slides'
3
+
4
+ export class SlideSnapshotManager {
5
+ private _capturePromises = new Map<number, Promise<void>>()
6
+
7
+ getSnapshot(slideNo: number) {
8
+ const data = snapshotState.state[slideNo]
9
+ if (!data) {
10
+ return
11
+ }
12
+ const slide = getSlide(slideNo)
13
+ if (!slide) {
14
+ return
15
+ }
16
+ if (data?.revision === slide?.meta.slide.revision) {
17
+ return data.image
18
+ }
19
+ }
20
+
21
+ async captureSnapshot(slideNo: number, el: HTMLElement, delay = 1000) {
22
+ if (!__DEV__)
23
+ return
24
+ if (this.getSnapshot(slideNo)) {
25
+ return
26
+ }
27
+ if (this._capturePromises.has(slideNo)) {
28
+ await this._capturePromises.get(slideNo)
29
+ }
30
+ const promise = this._captureSnapshot(slideNo, el, delay)
31
+ .finally(() => {
32
+ this._capturePromises.delete(slideNo)
33
+ })
34
+ this._capturePromises.set(slideNo, promise)
35
+ await promise
36
+ }
37
+
38
+ private async _captureSnapshot(slideNo: number, el: HTMLElement, delay: number) {
39
+ if (!__DEV__)
40
+ return
41
+ const slide = getSlide(slideNo)
42
+ if (!slide)
43
+ return
44
+
45
+ const revision = slide.meta.slide.revision
46
+
47
+ // Retry until the slide is loaded
48
+ let retries = 100
49
+ while (retries-- > 0) {
50
+ if (!el.querySelector('.slidev-slide-loading'))
51
+ break
52
+ await new Promise(r => setTimeout(r, 100))
53
+ }
54
+
55
+ // Artificial delay for the content to be loaded
56
+ await new Promise(r => setTimeout(r, delay))
57
+
58
+ // Capture the snapshot
59
+ const toImage = await import('html-to-image')
60
+ try {
61
+ const dataUrl = await toImage.toPng(el, {
62
+ width: el.offsetWidth,
63
+ height: el.offsetHeight,
64
+ skipFonts: true,
65
+ cacheBust: true,
66
+ pixelRatio: 1.5,
67
+ })
68
+ if (revision !== slide.meta.slide.revision) {
69
+ // eslint-disable-next-line no-console
70
+ console.info('[Slidev] Slide', slideNo, 'changed, discarding the snapshot')
71
+ return
72
+ }
73
+ snapshotState.patch(slideNo, {
74
+ revision,
75
+ image: dataUrl,
76
+ })
77
+ // eslint-disable-next-line no-console
78
+ console.info('[Slidev] Snapshot captured for slide', slideNo)
79
+ }
80
+ catch (e) {
81
+ console.error('[Slidev] Failed to capture snapshot for slide', slideNo, e)
82
+ }
83
+ }
84
+ }
85
+
86
+ export const snapshotManager = new SlideSnapshotManager()
@@ -1,6 +1,6 @@
1
1
  import type { ComputedRef } from '@vue/reactivity'
2
- import type { configs } from '../env'
3
2
  import type { SlidevContextNav } from '../composables/useNav'
3
+ import type { configs } from '../env'
4
4
 
5
5
  export interface SlidevContext {
6
6
  nav: SlidevContextNav
@@ -1,8 +1,8 @@
1
- import mermaid from 'mermaid/dist/mermaid.esm.mjs'
2
- import lz from 'lz-string'
3
1
  import { clearUndefined } from '@antfu/utils'
4
- import setupMermaid from '../setup/mermaid'
2
+ import lz from 'lz-string'
3
+ import mermaid from 'mermaid/dist/mermaid.esm.mjs'
5
4
  import { makeId } from '../logic/utils'
5
+ import setupMermaid from '../setup/mermaid'
6
6
 
7
7
  mermaid.startOnLoad = false
8
8
  mermaid.initialize({ startOnLoad: false })
@@ -1,6 +1,6 @@
1
+ import type { ClicksElement, RawAtValue } from '@slidev/types'
1
2
  import type { App, DirectiveBinding } from 'vue'
2
3
  import { computed, watchEffect } from 'vue'
3
- import type { ClicksElement, RawAtValue } from '@slidev/types'
4
4
  import {
5
5
  CLASS_VCLICK_CURRENT,
6
6
  CLASS_VCLICK_FADE,
package/modules/v-drag.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { App } from 'vue'
2
- import { watch } from 'vue'
3
2
  import type { DragElementState } from '../composables/useDragElements'
3
+ import { watch } from 'vue'
4
4
  import { useDragElement } from '../composables/useDragElements'
5
5
 
6
6
  export function createVDragDirective() {
package/modules/v-mark.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import type { RoughAnnotationConfig } from '@slidev/rough-notation'
2
- import { annotate } from '@slidev/rough-notation'
2
+ import type { RawAtValue } from '@slidev/types'
3
3
  import type { App } from 'vue'
4
+ import { annotate } from '@slidev/rough-notation'
4
5
  import { computed, watchEffect } from 'vue'
5
- import type { RawAtValue } from '@slidev/types'
6
6
  import { resolveClick } from './v-click'
7
7
 
8
8
  export interface RoughDirectiveOptions extends Partial<RoughAnnotationConfig> {
@@ -1,9 +1,9 @@
1
+ import type { ClicksInfo } from '@slidev/types'
1
2
  import type { App, ObjectDirective } from 'vue'
2
- import { watch } from 'vue'
3
3
  import { MotionDirective } from '@vueuse/motion'
4
- import type { ClicksInfo } from '@slidev/types'
5
- import { injectionClicksContext, injectionCurrentPage, injectionRenderContext } from '../constants'
4
+ import { watch } from 'vue'
6
5
  import { useNav } from '../composables/useNav'
6
+ import { injectionClicksContext, injectionCurrentPage, injectionRenderContext } from '../constants'
7
7
  import { makeId } from '../logic/utils'
8
8
  import { directiveInject } from '../utils'
9
9
  import { resolvedClickMap } from './v-click'
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@slidev/client",
3
3
  "type": "module",
4
- "version": "0.49.29",
4
+ "version": "0.50.0-beta.2",
5
5
  "description": "Presentation slides for developers",
6
6
  "author": "antfu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -29,39 +29,40 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@antfu/utils": "^0.7.10",
32
- "@iconify-json/carbon": "^1.1.37",
33
- "@iconify-json/ph": "^1.1.14",
34
- "@iconify-json/svg-spinners": "^1.1.3",
35
- "@shikijs/monaco": "^1.14.1",
36
- "@shikijs/vitepress-twoslash": "^1.14.1",
32
+ "@iconify-json/carbon": "^1.2.1",
33
+ "@iconify-json/ph": "^1.2.0",
34
+ "@iconify-json/svg-spinners": "^1.2.0",
35
+ "@shikijs/monaco": "^1.21.0",
36
+ "@shikijs/vitepress-twoslash": "^1.21.0",
37
37
  "@slidev/rough-notation": "^0.1.0",
38
38
  "@typescript/ata": "^0.9.7",
39
- "@unhead/vue": "^1.10.0",
40
- "@unocss/reset": "^0.62.3",
41
- "@vueuse/core": "^11.0.3",
42
- "@vueuse/math": "^11.0.3",
43
- "@vueuse/motion": "^2.2.3",
39
+ "@unhead/vue": "^1.11.6",
40
+ "@unocss/reset": "^0.63.1",
41
+ "@vueuse/core": "^11.1.0",
42
+ "@vueuse/math": "^11.1.0",
43
+ "@vueuse/motion": "^2.2.5",
44
44
  "drauu": "^0.4.1",
45
45
  "file-saver": "^2.0.5",
46
46
  "floating-vue": "^5.2.2",
47
47
  "fuse.js": "^7.0.0",
48
+ "html-to-image": "^1.11.11",
48
49
  "katex": "^0.16.11",
49
50
  "lz-string": "^1.5.0",
50
- "mermaid": "^11.0.2",
51
- "monaco-editor": "^0.51.0",
51
+ "mermaid": "^11.2.1",
52
+ "monaco-editor": "^0.52.0",
52
53
  "prettier": "^3.3.3",
53
54
  "recordrtc": "^5.6.2",
54
- "shiki": "^1.14.1",
55
+ "shiki": "^1.21.0",
55
56
  "shiki-magic-move": "^0.4.4",
56
- "typescript": "^5.5.4",
57
- "unocss": "^0.62.3",
58
- "vue": "^3.4.38",
59
- "vue-router": "^4.4.3",
60
- "yaml": "^2.5.0",
61
- "@slidev/types": "0.49.29",
62
- "@slidev/parser": "0.49.29"
57
+ "typescript": "^5.6.2",
58
+ "unocss": "^0.63.1",
59
+ "vue": "^3.5.10",
60
+ "vue-router": "^4.4.5",
61
+ "yaml": "^2.5.1",
62
+ "@slidev/types": "0.50.0-beta.2",
63
+ "@slidev/parser": "0.50.0-beta.2"
63
64
  },
64
65
  "devDependencies": {
65
- "vite": "^5.4.2"
66
+ "vite": "^5.4.8"
66
67
  }
67
68
  }
package/pages/notes.vue CHANGED
@@ -1,16 +1,16 @@
1
1
  <script setup lang="ts">
2
2
  import { useHead } from '@unhead/vue'
3
- import { computed, ref, watch } from 'vue'
4
3
  import { useLocalStorage } from '@vueuse/core'
4
+ import { computed, ref, watch } from 'vue'
5
+ import { createClicksContextBase } from '../composables/useClicks'
6
+ import { useNav } from '../composables/useNav'
5
7
  import { slidesTitle } from '../env'
6
- import { sharedState } from '../state/shared'
7
- import { fullscreen } from '../state'
8
8
 
9
- import NoteDisplay from '../internals/NoteDisplay.vue'
10
- import IconButton from '../internals/IconButton.vue'
11
9
  import ClicksSlider from '../internals/ClicksSlider.vue'
12
- import { useNav } from '../composables/useNav'
13
- import { createClicksContextBase } from '../composables/useClicks'
10
+ import IconButton from '../internals/IconButton.vue'
11
+ import NoteDisplay from '../internals/NoteDisplay.vue'
12
+ import { fullscreen } from '../state'
13
+ import { sharedState } from '../state/shared'
14
14
 
15
15
  useHead({ title: `Notes - ${slidesTitle}` })
16
16
 
@@ -1,19 +1,19 @@
1
1
  <script setup lang="ts">
2
- import { computed, nextTick, onMounted, reactive, ref, shallowRef } from 'vue'
3
- import { useHead } from '@unhead/vue'
4
2
  import type { ClicksContext, SlideRoute } from '@slidev/types'
5
- import { pathPrefix, slidesTitle } from '../env'
6
- import { getSlidePath } from '../logic/slides'
3
+ import { useHead } from '@unhead/vue'
4
+ import { computed, nextTick, onMounted, reactive, ref, shallowRef } from 'vue'
7
5
  import { createFixedClicks } from '../composables/useClicks'
8
- import { isColorSchemaConfigured, isDark, toggleDark } from '../logic/dark'
9
- import SlideContainer from '../internals/SlideContainer.vue'
10
- import SlideWrapper from '../internals/SlideWrapper.vue'
6
+ import { useNav } from '../composables/useNav'
7
+ import { CLICKS_MAX } from '../constants'
8
+ import { pathPrefix, slidesTitle } from '../env'
9
+ import ClicksSlider from '../internals/ClicksSlider.vue'
11
10
  import DrawingPreview from '../internals/DrawingPreview.vue'
12
11
  import IconButton from '../internals/IconButton.vue'
13
12
  import NoteEditable from '../internals/NoteEditable.vue'
14
- import ClicksSlider from '../internals/ClicksSlider.vue'
15
- import { CLICKS_MAX } from '../constants'
16
- import { useNav } from '../composables/useNav'
13
+ import SlideContainer from '../internals/SlideContainer.vue'
14
+ import SlideWrapper from '../internals/SlideWrapper.vue'
15
+ import { isColorSchemaConfigured, isDark, toggleDark } from '../logic/dark'
16
+ import { getSlidePath } from '../logic/slides'
17
17
 
18
18
  const cardWidth = 450
19
19
 
@@ -49,7 +49,20 @@ function toggleRoute(route: SlideRoute) {
49
49
  }
50
50
 
51
51
  function wordCount(str: string) {
52
- return str.match(/[\w`'\-]+/g)?.length || 0
52
+ const pattern = /[\w`'\-\u0392-\u03C9\u00C0-\u00FF\u0600-\u06FF\u0400-\u04FF]+|[\u4E00-\u9FFF\u3400-\u4DBF\uF900-\uFAFF\u3040-\u309F\uAC00-\uD7AF]+/g
53
+ const m = str.match(pattern)
54
+ let count = 0
55
+ if (!m)
56
+ return 0
57
+ for (let i = 0; i < m.length; i++) {
58
+ if (m[i].charCodeAt(0) >= 0x4E00) {
59
+ count += m[i].length
60
+ }
61
+ else {
62
+ count += 1
63
+ }
64
+ }
65
+ return count
53
66
  }
54
67
 
55
68
  function isElementInViewport(el: HTMLElement) {
package/pages/play.vue CHANGED
@@ -1,19 +1,19 @@
1
1
  <script setup lang="ts">
2
- import { computed, ref, shallowRef } from 'vue'
3
2
  import { useStyleTag } from '@vueuse/core'
4
- import { editorHeight, editorWidth, isEditorVertical, isScreenVertical, showEditor, windowSize } from '../state'
3
+ import { computed, ref, shallowRef } from 'vue'
4
+ import { useDrawings } from '../composables/useDrawings'
5
+ import { useNav } from '../composables/useNav'
5
6
  import { useSwipeControls } from '../composables/useSwipeControls'
6
- import { registerShortcuts } from '../logic/shortcuts'
7
+ import { useWakeLock } from '../composables/useWakeLock'
7
8
  import Controls from '../internals/Controls.vue'
8
- import SlideContainer from '../internals/SlideContainer.vue'
9
9
  import NavControls from '../internals/NavControls.vue'
10
- import SlidesShow from '../internals/SlidesShow.vue'
10
+ import PresenterMouse from '../internals/PresenterMouse.vue'
11
11
  import PrintStyle from '../internals/PrintStyle.vue'
12
+ import SlideContainer from '../internals/SlideContainer.vue'
13
+ import SlidesShow from '../internals/SlidesShow.vue'
12
14
  import { onContextMenu } from '../logic/contextMenu'
13
- import { useNav } from '../composables/useNav'
14
- import { useWakeLock } from '../composables/useWakeLock'
15
- import { useDrawings } from '../composables/useDrawings'
16
- import PresenterMouse from '../internals/PresenterMouse.vue'
15
+ import { registerShortcuts } from '../logic/shortcuts'
16
+ import { editorHeight, editorWidth, isEditorVertical, isScreenVertical, showEditor, windowSize } from '../state'
17
17
 
18
18
  const { next, prev, isPrintMode } = useNav()
19
19
  const { isDrawing } = useDrawings()
@@ -80,7 +80,7 @@ if (__DEV__ && __SLIDEV_FEATURE_EDITOR__)
80
80
  <template #controls>
81
81
  <div
82
82
  v-if="!isPrintMode"
83
- class="absolute bottom-0 left-0 transition duration-300 opacity-0 hover:opacity-100"
83
+ class="absolute bottom-0 left-0 transition duration-300 opacity-0 hover:opacity-100 focus-within:opacity-100 focus-visible:opacity-100"
84
84
  :class="[
85
85
  persistNav ? '!opacity-100 right-0' : 'opacity-0 p-2',
86
86
  isDrawing ? 'pointer-events-none' : '',
@@ -1,7 +1,7 @@
1
1
  <script setup lang="ts">
2
- import { computed } from 'vue'
3
- import { useStyleTag } from '@vueuse/core'
4
2
  import { useHead } from '@unhead/vue'
3
+ import { useStyleTag } from '@vueuse/core'
4
+ import { computed } from 'vue'
5
5
  import { useNav } from '../../composables/useNav'
6
6
  import { configs } from '../../env'
7
7
  import NoteDisplay from '../../internals/NoteDisplay.vue'
@@ -1,30 +1,30 @@
1
1
  <script setup lang="ts">
2
2
  import { useHead } from '@unhead/vue'
3
- import { computed, onMounted, reactive, ref, shallowRef, watch } from 'vue'
4
3
  import { useMouse, useWindowFocus } from '@vueuse/core'
4
+ import { computed, onMounted, reactive, ref, shallowRef, watch } from 'vue'
5
+ import { createFixedClicks } from '../composables/useClicks'
6
+ import { useDrawings } from '../composables/useDrawings'
7
+ import { useNav } from '../composables/useNav'
5
8
  import { useSwipeControls } from '../composables/useSwipeControls'
6
- import { decreasePresenterFontSize, increasePresenterFontSize, presenterLayout, presenterNotesFontSize, showEditor, showPresenterCursor } from '../state'
9
+ import { useWakeLock } from '../composables/useWakeLock'
7
10
  import { slidesTitle } from '../env'
8
- import { sharedState } from '../state/shared'
9
- import { registerShortcuts } from '../logic/shortcuts'
10
- import { onContextMenu } from '../logic/contextMenu'
11
- import { useTimer } from '../logic/utils'
12
- import { createFixedClicks } from '../composables/useClicks'
13
- import SlideWrapper from '../internals/SlideWrapper.vue'
14
- import SlideContainer from '../internals/SlideContainer.vue'
11
+ import ClicksSlider from '../internals/ClicksSlider.vue'
12
+ import ContextMenu from '../internals/ContextMenu.vue'
13
+ import DrawingControls from '../internals/DrawingControls.vue'
14
+ import Goto from '../internals/Goto.vue'
15
+ import IconButton from '../internals/IconButton.vue'
15
16
  import NavControls from '../internals/NavControls.vue'
16
- import QuickOverview from '../internals/QuickOverview.vue'
17
17
  import NoteEditable from '../internals/NoteEditable.vue'
18
18
  import NoteStatic from '../internals/NoteStatic.vue'
19
- import Goto from '../internals/Goto.vue'
19
+ import QuickOverview from '../internals/QuickOverview.vue'
20
+ import SlideContainer from '../internals/SlideContainer.vue'
20
21
  import SlidesShow from '../internals/SlidesShow.vue'
21
- import DrawingControls from '../internals/DrawingControls.vue'
22
- import IconButton from '../internals/IconButton.vue'
23
- import ClicksSlider from '../internals/ClicksSlider.vue'
24
- import ContextMenu from '../internals/ContextMenu.vue'
25
- import { useNav } from '../composables/useNav'
26
- import { useDrawings } from '../composables/useDrawings'
27
- import { useWakeLock } from '../composables/useWakeLock'
22
+ import SlideWrapper from '../internals/SlideWrapper.vue'
23
+ import { onContextMenu } from '../logic/contextMenu'
24
+ import { registerShortcuts } from '../logic/shortcuts'
25
+ import { useTimer } from '../logic/utils'
26
+ import { decreasePresenterFontSize, increasePresenterFontSize, presenterLayout, presenterNotesFontSize, showEditor, showPresenterCursor } from '../state'
27
+ import { sharedState } from '../state/shared'
28
28
 
29
29
  const main = ref<HTMLDivElement>()
30
30
 
package/pages/print.vue CHANGED
@@ -1,10 +1,10 @@
1
1
  <script setup lang="ts">
2
- import { onMounted, watchEffect } from 'vue'
3
2
  import { recomputeAllPoppers } from 'floating-vue'
4
- import { windowSize } from '../state'
3
+ import { onMounted, watchEffect } from 'vue'
4
+ import { useNav } from '../composables/useNav'
5
5
  import PrintContainer from '../internals/PrintContainer.vue'
6
6
  import PrintStyle from '../internals/PrintStyle.vue'
7
- import { useNav } from '../composables/useNav'
7
+ import { windowSize } from '../state'
8
8
 
9
9
  const { isPrintMode } = useNav()
10
10
 
@@ -1,10 +1,10 @@
1
- import { createSingletonPromise } from '@antfu/utils'
2
- import type { CodeRunner, CodeRunnerOutput, CodeRunnerOutputText, CodeRunnerOutputs } from '@slidev/types'
3
-
1
+ import type { CodeRunner, CodeRunnerOutput, CodeRunnerOutputs, CodeRunnerOutputText } from '@slidev/types'
4
2
  import type ts from 'typescript'
5
- import { ref } from 'vue'
3
+
6
4
  import deps from '#slidev/monaco-run-deps'
7
5
  import setups from '#slidev/setups/code-runners'
6
+ import { createSingletonPromise } from '@antfu/utils'
7
+ import { ref } from 'vue'
8
8
 
9
9
  export default createSingletonPromise(async () => {
10
10
  const runners: Record<string, CodeRunner> = {
@@ -1,23 +1,23 @@
1
1
  /// <reference types="unplugin-icons/types/vue3" />
2
- import type { ComputedRef } from 'vue'
3
- import { computed } from 'vue'
2
+
4
3
  import type { ContextMenuItem } from '@slidev/types'
5
- import { useNav } from '../composables/useNav'
6
- import { useDrawings } from '../composables/useDrawings'
7
- import { fullscreen, showEditor, toggleOverview } from '../state'
4
+ import type { ComputedRef } from 'vue'
8
5
  import setups from '#slidev/setups/context-menu'
9
-
6
+ import IconApps from '~icons/carbon/apps'
7
+ import IconArrowDown from '~icons/carbon/arrow-down'
10
8
  import IconArrowLeft from '~icons/carbon/arrow-left'
11
9
  import IconArrowRight from '~icons/carbon/arrow-right'
12
10
  import IconArrowUp from '~icons/carbon/arrow-up'
13
- import IconArrowDown from '~icons/carbon/arrow-down'
11
+ import IconMaximize from '~icons/carbon/maximize'
12
+ import IconMinimize from '~icons/carbon/minimize'
14
13
  import IconPen from '~icons/carbon/pen'
15
- import IconTextNotationToggle from '~icons/carbon/text-annotation-toggle'
16
- import IconApps from '~icons/carbon/apps'
17
14
  import IconPresentationFile from '~icons/carbon/presentation-file'
15
+ import IconTextNotationToggle from '~icons/carbon/text-annotation-toggle'
18
16
  import IconUserSpeaker from '~icons/carbon/user-speaker'
19
- import IconMaximize from '~icons/carbon/maximize'
20
- import IconMinimize from '~icons/carbon/minimize'
17
+ import { computed } from 'vue'
18
+ import { useDrawings } from '../composables/useDrawings'
19
+ import { useNav } from '../composables/useNav'
20
+ import { fullscreen, showEditor, toggleOverview } from '../state'
21
21
 
22
22
  let items: ComputedRef<ContextMenuItem[]> | undefined
23
23
 
package/setup/main.ts CHANGED
@@ -1,14 +1,14 @@
1
1
  import type { AppContext } from '@slidev/types'
2
- import TwoSlashFloatingVue from '@shikijs/vitepress-twoslash/client'
3
2
  import type { App } from 'vue'
4
- import { createRouter, createWebHashHistory, createWebHistory } from 'vue-router'
3
+ import setups from '#slidev/setups/main'
4
+ import TwoSlashFloatingVue from '@shikijs/vitepress-twoslash/client'
5
5
  import { createHead } from '@unhead/vue'
6
+ import { createRouter, createWebHashHistory, createWebHistory } from 'vue-router'
6
7
  import { createVClickDirectives } from '../modules/v-click'
7
- import { createVMarkDirective } from '../modules/v-mark'
8
8
  import { createVDragDirective } from '../modules/v-drag'
9
+ import { createVMarkDirective } from '../modules/v-mark'
9
10
  import { createVMotionDirectives } from '../modules/v-motion'
10
11
  import setupRoutes from '../setup/routes'
11
- import setups from '#slidev/setups/main'
12
12
 
13
13
  import '#slidev/styles'
14
14
 
package/setup/mermaid.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { MermaidConfig } from 'mermaid'
2
- import { createSingletonPromise } from '@antfu/utils'
3
2
  import setups from '#slidev/setups/mermaid'
3
+ import { createSingletonPromise } from '@antfu/utils'
4
4
 
5
5
  export default createSingletonPromise(async () => {
6
6
  const setupReturn: MermaidConfig = {
package/setup/monaco.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { createSingletonPromise } from '@antfu/utils'
2
1
  import type { MonacoSetupReturn } from '@slidev/types'
3
- import * as monaco from 'monaco-editor'
4
- import { watchEffect } from 'vue'
2
+ import configs from '#slidev/configs'
3
+ import setups from '#slidev/setups/monaco'
4
+ import { createSingletonPromise } from '@antfu/utils'
5
5
  import { setupTypeAcquisition } from '@typescript/ata'
6
- import ts from 'typescript'
6
+ import * as monaco from 'monaco-editor'
7
7
 
8
8
  import EditorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker'
9
9
  import CssWorker from 'monaco-editor/esm/vs/language/css/css.worker?worker'
@@ -11,18 +11,18 @@ import HtmlWorker from 'monaco-editor/esm/vs/language/html/html.worker?worker'
11
11
  import JsonWorker from 'monaco-editor/esm/vs/language/json/json.worker?worker'
12
12
  import TsWorker from 'monaco-editor/esm/vs/language/typescript/ts.worker?worker'
13
13
 
14
+ import ts from 'typescript'
15
+
16
+ import { watchEffect } from 'vue'
17
+
14
18
  // @ts-expect-error missing types
15
19
  import { ContextViewService } from 'monaco-editor/esm/vs/platform/contextview/browser/contextViewService'
16
20
 
17
21
  // @ts-expect-error missing types
18
22
  import { SyncDescriptor } from 'monaco-editor/esm/vs/platform/instantiation/common/descriptors'
19
-
20
23
  // @ts-expect-error missing types
21
24
  import { StandaloneServices } from 'monaco-editor/esm/vs/editor/standalone/browser/standaloneServices'
22
-
23
25
  import { isDark } from '../logic/dark'
24
- import configs from '#slidev/configs'
25
- import setups from '#slidev/setups/monaco'
26
26
 
27
27
  window.MonacoEnvironment = {
28
28
  getWorker(_, label) {
@@ -92,7 +92,7 @@ const setup = createSingletonPromise(async () => {
92
92
  monaco.languages.register({ id: 'typescript' })
93
93
  monaco.languages.register({ id: 'javascript' })
94
94
 
95
- const { shiki, themes, shikiToMonaco } = await import('#slidev/shiki')
95
+ const { shiki, languages, themes, shikiToMonaco } = await import('#slidev/shiki')
96
96
  const highlighter = await shiki
97
97
 
98
98
  const editorOptions: MonacoSetupReturn['editorOptions'] & object = {}
@@ -113,6 +113,10 @@ const setup = createSingletonPromise(async () => {
113
113
  : themes.light || 'vitesse-light')
114
114
  })
115
115
  }
116
+ // Register all languages, otherwise Monaco will not highlight them
117
+ for (const lang of languages) {
118
+ monaco.languages.register({ id: lang })
119
+ }
116
120
 
117
121
  return {
118
122
  monaco,