@slidev/client 0.48.0-beta.0 → 0.48.0-beta.10

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 (54) hide show
  1. package/builtin/CodeBlockWrapper.vue +4 -3
  2. package/builtin/KaTexBlockWrapper.vue +4 -3
  3. package/builtin/RenderWhen.vue +3 -3
  4. package/builtin/SlideCurrentNo.vue +2 -3
  5. package/builtin/SlidesTotal.vue +3 -4
  6. package/builtin/SlidevVideo.vue +8 -6
  7. package/builtin/Toc.vue +3 -3
  8. package/builtin/Tweet.vue +4 -15
  9. package/builtin/VClickGap.vue +3 -5
  10. package/builtin/VClicks.ts +9 -9
  11. package/composables/useClicks.ts +16 -13
  12. package/composables/useTweetScript.ts +17 -0
  13. package/constants.ts +56 -8
  14. package/context.ts +70 -0
  15. package/internals/DrawingControls.vue +66 -46
  16. package/internals/DrawingLayer.vue +3 -2
  17. package/internals/Editor.vue +68 -34
  18. package/internals/IconButton.vue +15 -0
  19. package/internals/InfoDialog.vue +1 -1
  20. package/internals/Modal.vue +1 -1
  21. package/internals/NavControls.vue +37 -68
  22. package/internals/NoteDisplay.vue +1 -1
  23. package/internals/NoteEditor.vue +10 -6
  24. package/internals/NoteStatic.vue +5 -6
  25. package/internals/PrintContainer.vue +3 -2
  26. package/internals/PrintSlideClick.vue +3 -2
  27. package/internals/RecordingControls.vue +10 -14
  28. package/internals/RecordingDialog.vue +2 -3
  29. package/internals/SlideContainer.vue +7 -6
  30. package/internals/SlideWrapper.ts +28 -12
  31. package/internals/SlidesOverview.vue +19 -9
  32. package/logic/drawings.ts +6 -3
  33. package/logic/nav.ts +6 -6
  34. package/logic/note.ts +7 -7
  35. package/main.ts +5 -3
  36. package/modules/context.ts +4 -3
  37. package/modules/{directives.ts → v-click.ts} +15 -15
  38. package/modules/v-mark.ts +159 -0
  39. package/package.json +21 -13
  40. package/{internals/EntrySelect.vue → pages/entry.vue} +7 -0
  41. package/{internals/NotesView.vue → pages/notes.vue} +9 -12
  42. package/pages/overview.vue +157 -0
  43. package/{internals/Play.vue → pages/play.vue} +10 -10
  44. package/{internals/PresenterPrint.vue → pages/presenter/print.vue} +7 -5
  45. package/{internals/Presenter.vue → pages/presenter.vue} +24 -22
  46. package/{internals/Print.vue → pages/print.vue} +2 -2
  47. package/routes.ts +25 -19
  48. package/setup/codemirror.ts +7 -0
  49. package/state/index.ts +11 -9
  50. package/styles/index.css +5 -0
  51. package/styles/layouts-base.css +6 -4
  52. package/styles/vars.css +1 -0
  53. package/uno.config.ts +6 -2
  54. package/internals/HiddenText.vue +0 -9
@@ -1,6 +1,8 @@
1
- import { defineComponent, h, provide, ref, toRef } from 'vue'
1
+ import { computed, defineComponent, h, ref, toRef } from 'vue'
2
2
  import type { PropType } from 'vue'
3
+ import { provideLocal } from '@vueuse/core'
3
4
  import type { ClicksContext, RenderContext } from '@slidev/types'
5
+ import type { RouteRecordRaw } from 'vue-router'
4
6
  import { injectionActive, injectionClicksContext, injectionCurrentPage, injectionRenderContext, injectionRoute } from '../constants'
5
7
 
6
8
  export default defineComponent({
@@ -20,23 +22,37 @@ export default defineComponent({
20
22
  },
21
23
  is: {
22
24
  type: Object,
23
- default: undefined,
25
+ required: true,
24
26
  },
25
27
  route: {
26
- type: Object,
27
- default: undefined,
28
+ type: Object as PropType<RouteRecordRaw>,
29
+ required: true,
28
30
  },
29
31
  },
30
32
  setup(props) {
31
- provide(injectionRoute, props.route as any)
32
- provide(injectionCurrentPage, ref(+props.route?.path))
33
- provide(injectionRenderContext, ref(props.renderContext as RenderContext))
34
- provide(injectionActive, toRef(props, 'active'))
35
- provide(injectionClicksContext, toRef(props, 'clicksContext'))
33
+ provideLocal(injectionRoute, props.route)
34
+ provideLocal(injectionCurrentPage, ref(+props.route.path))
35
+ provideLocal(injectionRenderContext, ref(props.renderContext as RenderContext))
36
+ provideLocal(injectionActive, toRef(props, 'active'))
37
+ provideLocal(injectionClicksContext, toRef(props, 'clicksContext'))
38
+
39
+ const style = computed(() => {
40
+ const zoom = props.route.meta?.slide?.frontmatter.zoom ?? 1
41
+ return zoom === 1
42
+ ? undefined
43
+ : {
44
+ width: `${100 / zoom}%`,
45
+ height: `${100 / zoom}%`,
46
+ transformOrigin: 'top left',
47
+ transform: `scale(${zoom})`,
48
+ }
49
+ })
50
+
51
+ return {
52
+ style,
53
+ }
36
54
  },
37
55
  render() {
38
- if (this.$props.is)
39
- return h(this.$props.is)
40
- return this.$slots?.default?.()
56
+ return h(this.$props.is, { style: this.style })
41
57
  },
42
58
  })
@@ -10,11 +10,11 @@ import { getSlideClass } from '../utils'
10
10
  import SlideContainer from './SlideContainer.vue'
11
11
  import SlideWrapper from './SlideWrapper'
12
12
  import DrawingPreview from './DrawingPreview.vue'
13
- import HiddenText from './HiddenText.vue'
13
+ import IconButton from './IconButton.vue'
14
14
 
15
15
  const props = defineProps<{ modelValue: boolean }>()
16
16
 
17
- const emit = defineEmits([])
17
+ const emit = defineEmits(['update:modelValue'])
18
18
  const value = useVModel(props, 'modelValue', emit)
19
19
 
20
20
  function close() {
@@ -112,7 +112,7 @@ watchEffect(() => {
112
112
  >
113
113
  <div
114
114
  v-show="value"
115
- class="bg-main !bg-opacity-75 p-16 overflow-y-auto backdrop-blur-5px fixed left-0 right-0 top-0 h-[calc(var(--vh,1vh)*100)]"
115
+ class="bg-main !bg-opacity-75 p-16 py-20 overflow-y-auto backdrop-blur-5px fixed left-0 right-0 top-0 h-[calc(var(--vh,1vh)*100)]"
116
116
  @click="close()"
117
117
  >
118
118
  <div
@@ -125,8 +125,8 @@ watchEffect(() => {
125
125
  class="relative"
126
126
  >
127
127
  <div
128
- class="inline-block border rounded border-opacity-50 overflow-hidden bg-main hover:border-$slidev-theme-primary transition"
129
- :class="(focus(idx + 1) || currentOverviewPage === idx + 1) ? 'border-$slidev-theme-primary' : 'border-gray-400'"
128
+ class="inline-block border rounded overflow-hidden bg-main hover:border-primary transition"
129
+ :class="(focus(idx + 1) || currentOverviewPage === idx + 1) ? 'border-primary' : 'border-main'"
130
130
  :style="themeVars"
131
131
  @click="go(+route.path)"
132
132
  >
@@ -163,8 +163,18 @@ watchEffect(() => {
163
163
  </div>
164
164
  </div>
165
165
  </Transition>
166
- <button v-if="value" class="fixed text-2xl top-4 right-4 slidev-icon-btn text-gray-400" @click="close">
167
- <HiddenText text="Close" />
168
- <carbon:close />
169
- </button>
166
+ <div v-if="value" class="fixed top-4 right-4 text-gray-400 flex items-center gap-4">
167
+ <RouterLink
168
+ v-if="__DEV__"
169
+ target="_blank"
170
+ to="/overview"
171
+ tab-index="-1"
172
+ class="border-main border px3 py1 rounded hover:bg-gray/5 hover:text-primary"
173
+ >
174
+ List overview
175
+ </RouterLink>
176
+ <IconButton title="Close" class="text-2xl" @click="close">
177
+ <carbon:close />
178
+ </IconButton>
179
+ </div>
170
180
  </template>
package/logic/drawings.ts CHANGED
@@ -4,6 +4,7 @@ import { createDrauu } from 'drauu'
4
4
  import { toReactive, useLocalStorage } from '@vueuse/core'
5
5
  import { drawingState, onPatch, patch } from '../state/drawings'
6
6
  import { configs } from '../env'
7
+ import { isInputting } from '../state'
7
8
  import { currentPage, isPresenter } from './nav'
8
9
 
9
10
  export const brushColors = [
@@ -40,11 +41,13 @@ export const drawingMode = computed({
40
41
  set(v: DrawingMode | 'arrow') {
41
42
  _mode.value = v
42
43
  if (v === 'arrow') {
43
- brush.mode = 'line'
44
+ // eslint-disable-next-line ts/no-use-before-define
45
+ drauu.mode = 'line'
44
46
  brush.arrowEnd = true
45
47
  }
46
48
  else {
47
- brush.mode = v
49
+ // eslint-disable-next-line ts/no-use-before-define
50
+ drauu.mode = v
48
51
  brush.arrowEnd = false
49
52
  }
50
53
  },
@@ -110,7 +113,7 @@ drauu.on('start', () => isDrawing.value = true)
110
113
  drauu.on('end', () => isDrawing.value = false)
111
114
 
112
115
  window.addEventListener('keydown', (e) => {
113
- if (!drawingEnabled.value)
116
+ if (!drawingEnabled.value || isInputting.value)
114
117
  return
115
118
 
116
119
  const noModifier = !e.ctrlKey && !e.altKey && !e.shiftKey && !e.metaKey
package/logic/nav.ts CHANGED
@@ -83,9 +83,9 @@ watch(currentRoute, (next, prev) => {
83
83
  navDirection.value = Number(next?.path) - Number(prev?.path)
84
84
  })
85
85
 
86
- export function next() {
86
+ export async function next() {
87
87
  if (clicksTotal.value <= queryClicks.value)
88
- nextSlide()
88
+ await nextSlide()
89
89
  else
90
90
  queryClicks.value += 1
91
91
  }
@@ -101,9 +101,9 @@ export function getPath(no: number | string) {
101
101
  return isPresenter.value ? `/presenter/${no}` : `/${no}`
102
102
  }
103
103
 
104
- export function nextSlide() {
105
- const next = Math.min(rawRoutes.length, currentPage.value + 1)
106
- return go(next)
104
+ export async function nextSlide() {
105
+ if (currentPage.value < rawRoutes.length)
106
+ await go(currentPage.value + 1)
107
107
  }
108
108
 
109
109
  export async function prevSlide(lastClicks = true) {
@@ -177,7 +177,7 @@ export async function downloadPDF() {
177
177
  export async function openInEditor(url?: string) {
178
178
  if (url == null) {
179
179
  const slide = currentRoute.value?.meta?.slide
180
- if (!slide?.filepath)
180
+ if (!slide)
181
181
  return false
182
182
  url = `${slide.filepath}:${slide.start}`
183
183
  }
package/logic/note.ts CHANGED
@@ -2,17 +2,17 @@ import type { MaybeRef } from '@vueuse/core'
2
2
  import { useFetch } from '@vueuse/core'
3
3
  import type { Ref } from 'vue'
4
4
  import { computed, ref, unref } from 'vue'
5
- import type { SlideInfo, SlideInfoExtended } from '@slidev/types'
5
+ import type { SlideInfo, SlidePatch } from '@slidev/types'
6
6
 
7
7
  export interface UseSlideInfo {
8
- info: Ref<SlideInfoExtended | undefined>
9
- update: (data: Partial<SlideInfo>) => Promise<SlideInfoExtended | void>
8
+ info: Ref<SlideInfo | undefined>
9
+ update: (data: SlidePatch) => Promise<SlideInfo | void>
10
10
  }
11
11
 
12
12
  export function useSlideInfo(id: number | undefined): UseSlideInfo {
13
13
  if (id == null) {
14
14
  return {
15
- info: ref() as Ref<SlideInfoExtended | undefined>,
15
+ info: ref() as Ref<SlideInfo | undefined>,
16
16
  update: async () => {},
17
17
  }
18
18
  }
@@ -21,7 +21,7 @@ export function useSlideInfo(id: number | undefined): UseSlideInfo {
21
21
 
22
22
  execute()
23
23
 
24
- const update = async (data: Partial<SlideInfo>) => {
24
+ const update = async (data: SlidePatch) => {
25
25
  return await fetch(
26
26
  url,
27
27
  {
@@ -41,7 +41,7 @@ export function useSlideInfo(id: number | undefined): UseSlideInfo {
41
41
  info.value = payload.data
42
42
  })
43
43
  import.meta.hot?.on('slidev-update-note', (payload) => {
44
- if (payload.id === id && info.value.note.trim() !== payload.note.trim())
44
+ if (payload.id === id && info.value.note?.trim() !== payload.note?.trim())
45
45
  info.value = { ...info.value, ...payload }
46
46
  })
47
47
  }
@@ -64,7 +64,7 @@ export function useDynamicSlideInfo(id: MaybeRef<number | undefined>) {
64
64
 
65
65
  return {
66
66
  info: computed(() => get(unref(id)).info.value),
67
- update: async (data: Partial<SlideInfo>, newId?: number) => {
67
+ update: async (data: SlidePatch, newId?: number) => {
68
68
  const info = get(newId ?? unref(id))
69
69
  const newData = await info.update(data)
70
70
  if (newData)
package/main.ts CHANGED
@@ -3,15 +3,17 @@ import { createHead } from '@unhead/vue'
3
3
  import App from './App.vue'
4
4
  import setupMain from './setup/main'
5
5
  import { router } from './routes'
6
- import createDirectives from './modules/directives'
7
- import createSlidevContext from './modules/context'
6
+ import { createVClickDirectives } from './modules/v-click'
7
+ import { createVMarkDirective } from './modules/v-mark'
8
+ import { createSlidevContext } from './modules/context'
8
9
 
9
10
  import '/@slidev/styles'
10
11
 
11
12
  const app = createApp(App)
12
13
  app.use(router)
13
14
  app.use(createHead())
14
- app.use(createDirectives())
15
+ app.use(createVClickDirectives())
16
+ app.use(createVMarkDirective())
15
17
  app.use(createSlidevContext())
16
18
 
17
19
  setupMain({ app, router })
@@ -1,12 +1,12 @@
1
1
  import type { App } from 'vue'
2
- import { computed, reactive } from 'vue'
2
+ import { computed, reactive, ref } 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 { route } from '../logic/nav'
8
8
  import { isDark } from '../logic/dark'
9
- import { injectionCurrentPage, injectionSlidevContext } from '../constants'
9
+ import { injectionCurrentPage, injectionRenderContext, injectionSlidevContext } from '../constants'
10
10
  import { useContext } from '../composables/useContext'
11
11
 
12
12
  export type SlidevContextNavKey = 'path' | 'total' | 'clicksContext' | 'clicks' | 'clicksTotal' | 'currentPage' | 'currentPath' | 'currentRoute' | 'currentSlideId' | 'currentLayout' | 'nextRoute' | 'rawTree' | 'treeWithActiveStatuses' | 'tree' | 'downloadPDF' | 'next' | 'nextSlide' | 'openInEditor' | 'prev' | 'prevSlide' | 'rawRoutes' | 'go'
@@ -21,10 +21,11 @@ export interface SlidevContext {
21
21
  themeConfigs: ComputedRef<typeof configs['themeConfig']>
22
22
  }
23
23
 
24
- export default function createSlidevContext() {
24
+ export function createSlidevContext() {
25
25
  return {
26
26
  install(app: App) {
27
27
  const context = reactive(useContext(route))
28
+ app.provide(injectionRenderContext, ref('none'))
28
29
  app.provide(injectionSlidevContext, context)
29
30
  app.provide(injectionCurrentPage, computed(() => context.nav.currentPage))
30
31
 
@@ -11,19 +11,21 @@ import {
11
11
  injectionClicksContext,
12
12
  } from '../constants'
13
13
 
14
- function dirInject<T = unknown>(dir: DirectiveBinding<any>, key: InjectionKey<T> | string, defaultValue?: T): T | undefined {
14
+ export type VClickValue = string | [string | number, string | number] | boolean
15
+
16
+ export function dirInject<T = unknown>(dir: DirectiveBinding<any>, key: InjectionKey<T> | string, defaultValue?: T): T | undefined {
15
17
  return (dir.instance?.$ as any).provides[key as any] ?? defaultValue
16
18
  }
17
19
 
18
- export default function createDirectives() {
20
+ export function createVClickDirectives() {
19
21
  return {
20
22
  install(app: App) {
21
- app.directive('click', {
23
+ app.directive<HTMLElement, VClickValue>('click', {
22
24
  // @ts-expect-error extra prop
23
25
  name: 'v-click',
24
26
 
25
- mounted(el: HTMLElement, dir) {
26
- const resolved = resolveClick(el, dir)
27
+ mounted(el, dir) {
28
+ const resolved = resolveClick(el, dir, dir.value)
27
29
  if (resolved == null)
28
30
  return
29
31
 
@@ -55,12 +57,12 @@ export default function createDirectives() {
55
57
  unmounted,
56
58
  })
57
59
 
58
- app.directive('after', {
60
+ app.directive<HTMLElement, VClickValue>('after', {
59
61
  // @ts-expect-error extra prop
60
62
  name: 'v-after',
61
63
 
62
- mounted(el: HTMLElement, dir) {
63
- const resolved = resolveClick(el, dir, true)
64
+ mounted(el, dir) {
65
+ const resolved = resolveClick(el, dir, dir.value, true)
64
66
  if (resolved == null)
65
67
  return
66
68
 
@@ -86,12 +88,12 @@ export default function createDirectives() {
86
88
  unmounted,
87
89
  })
88
90
 
89
- app.directive('click-hide', {
91
+ app.directive<HTMLElement, VClickValue>('click-hide', {
90
92
  // @ts-expect-error extra prop
91
93
  name: 'v-click-hide',
92
94
 
93
- mounted(el: HTMLElement, dir) {
94
- const resolved = resolveClick(el, dir, false, true)
95
+ mounted(el, dir) {
96
+ const resolved = resolveClick(el, dir, dir.value, false, true)
95
97
  if (resolved == null)
96
98
  return
97
99
 
@@ -127,14 +129,12 @@ function isCurrent(thisClick: number | [number, number], clicks: number) {
127
129
  : thisClick === clicks
128
130
  }
129
131
 
130
- function resolveClick(el: Element, dir: DirectiveBinding<any>, clickAfter = false, flagHide = false): ResolvedClicksInfo | null {
132
+ export function resolveClick(el: Element, dir: DirectiveBinding<any>, value: VClickValue, clickAfter = false, flagHide = false): ResolvedClicksInfo | null {
131
133
  const ctx = dirInject(dir, injectionClicksContext)?.value
132
134
 
133
135
  if (!el || !ctx || ctx.disabled)
134
136
  return null
135
137
 
136
- let value = dir.value
137
-
138
138
  if (value === false || value === 'false')
139
139
  return null
140
140
 
@@ -153,7 +153,7 @@ function resolveClick(el: Element, dir: DirectiveBinding<any>, clickAfter = fals
153
153
  // range (absolute)
154
154
  delta = 0
155
155
  thisClick = value as [number, number]
156
- maxClick = value[1]
156
+ maxClick = +value[1]
157
157
  }
158
158
  else {
159
159
  ({ start: thisClick, end: maxClick, delta } = ctx.resolve(value))
@@ -0,0 +1,159 @@
1
+ import type { RoughAnnotationConfig } from '@slidev/rough-notation'
2
+ import { annotate } from '@slidev/rough-notation'
3
+ import type { App } from 'vue'
4
+ import { computed, watchEffect } from 'vue'
5
+ import type { VClickValue } from './v-click'
6
+ import { resolveClick } from './v-click'
7
+
8
+ export interface RoughDirectiveOptions extends Partial<RoughAnnotationConfig> {
9
+ at: VClickValue
10
+ }
11
+
12
+ export type RoughDirectiveValue = VClickValue | RoughDirectiveOptions
13
+
14
+ function addClass(options: RoughDirectiveOptions, cls: string) {
15
+ options.class = [options.class, cls].filter(Boolean).join(' ')
16
+ return options
17
+ }
18
+
19
+ // Definitions of supported modifiers
20
+ const vMarkModifiers: Record<string, (options: RoughDirectiveOptions, value?: any) => RoughDirectiveOptions> = {
21
+ // Types
22
+ 'box': options => Object.assign(options, { type: 'box' }),
23
+ 'circle': options => Object.assign(options, { type: 'circle' }),
24
+ 'underline': options => Object.assign(options, { type: 'underline' }),
25
+ 'highlight': options => Object.assign(options, { type: 'highlight' }),
26
+ 'strike-through': options => Object.assign(options, { type: 'strike-through' }),
27
+ 'crossed-off': options => Object.assign(options, { type: 'crossed-off' }),
28
+ 'bracket': options => Object.assign(options, { type: 'bracket' }),
29
+
30
+ // Type Aliases
31
+ 'strike': options => Object.assign(options, { type: 'strike-through' }),
32
+ 'cross': options => Object.assign(options, { type: 'crossed-off' }),
33
+ 'crossed': options => Object.assign(options, { type: 'crossed-off' }),
34
+ 'linethrough': options => Object.assign(options, { type: 'strike-through' }),
35
+ 'line-through': options => Object.assign(options, { type: 'strike-through' }),
36
+
37
+ // Colors
38
+ // @unocss-include
39
+ 'black': options => addClass(options, 'text-black'),
40
+ 'blue': options => addClass(options, 'text-blue'),
41
+ 'cyan': options => addClass(options, 'text-cyan'),
42
+ 'gray': options => addClass(options, 'text-gray'),
43
+ 'green': options => addClass(options, 'text-green'),
44
+ 'indigo': options => addClass(options, 'text-indigo'),
45
+ 'lime': options => addClass(options, 'text-lime'),
46
+ 'orange': options => addClass(options, 'text-orange'),
47
+ 'pink': options => addClass(options, 'text-pink'),
48
+ 'purple': options => addClass(options, 'text-purple'),
49
+ 'red': options => addClass(options, 'text-red'),
50
+ 'teal': options => addClass(options, 'text-teal'),
51
+ 'white': options => addClass(options, 'text-white'),
52
+ 'yellow': options => addClass(options, 'text-yellow'),
53
+ }
54
+
55
+ const vMarkModifiersDynamic: [RegExp, (match: RegExpMatchArray, options: RoughDirectiveOptions, value?: any) => RoughDirectiveOptions][] = [
56
+ // Support setting delay like `v-mark.delay300="1"`
57
+ [/^delay-?(\d+)?$/, (match, options, value) => {
58
+ const ms = (match[1] ? Number.parseInt(match[1]) : value) || 300
59
+ options.delay = ms
60
+ return options
61
+ }],
62
+ // Support setting opacity like `v-mark.op50="1"`
63
+ [/^(?:op|opacity)-?(\d+)?$/, (match, options, value) => {
64
+ const opacity = (match[1] ? Number.parseInt(match[1]) : value) || 100
65
+ options.opacity = opacity / 100
66
+ return options
67
+ }],
68
+ ]
69
+
70
+ /**
71
+ * This supports v-mark directive to add notations to elements, powered by `rough-notation`.
72
+ */
73
+ export function createVMarkDirective() {
74
+ return {
75
+ install(app: App) {
76
+ app.directive<HTMLElement, RoughDirectiveValue>('mark', {
77
+ // @ts-expect-error extra prop
78
+ name: 'v-mark',
79
+
80
+ mounted: (el, binding) => {
81
+ const options = computed(() => {
82
+ const bindingOptions = (typeof binding.value === 'object' && !Array.isArray(binding.value))
83
+ ? { ...binding.value }
84
+ : { at: binding.value }
85
+
86
+ let modifierOptions: RoughDirectiveOptions = { at: bindingOptions.at }
87
+ const unknownModifiers = Object.entries(binding.modifiers)
88
+ .filter(([k, v]) => {
89
+ if (vMarkModifiers[k]) {
90
+ modifierOptions = vMarkModifiers[k](modifierOptions, v)
91
+ return false
92
+ }
93
+ for (const [re, fn] of vMarkModifiersDynamic) {
94
+ const match = k.match(re)
95
+ if (match) {
96
+ modifierOptions = fn(match, modifierOptions, v)
97
+ return false
98
+ }
99
+ }
100
+ return true
101
+ })
102
+
103
+ if (unknownModifiers.length)
104
+ console.warn('[Slidev] Invalid modifiers for v-mark:', unknownModifiers)
105
+
106
+ const options = {
107
+ ...modifierOptions,
108
+ ...bindingOptions,
109
+ }
110
+ options.type ||= 'underline'
111
+
112
+ return options
113
+ })
114
+
115
+ const annotation = annotate(el, options.value as RoughAnnotationConfig)
116
+
117
+ const resolvedClick = resolveClick(el, binding, options.value.at)
118
+ if (!resolvedClick) {
119
+ console.error('[Slidev] Invalid value for v-mark:', options.value.at)
120
+ return
121
+ }
122
+
123
+ watchEffect(() => {
124
+ let shouldShow: boolean | undefined
125
+
126
+ if (options.value.class)
127
+ annotation.class = options.value.class
128
+ if (options.value.color)
129
+ annotation.color = options.value.color
130
+
131
+ const at = options.value.at
132
+
133
+ if (at === true) {
134
+ shouldShow = true
135
+ }
136
+ else if (at === false) {
137
+ shouldShow = false
138
+ }
139
+ else if (resolvedClick) {
140
+ shouldShow = resolvedClick.isActive.value
141
+ }
142
+ else {
143
+ console.error('[Slidev] Invalid value for v-mark:', at)
144
+ return
145
+ }
146
+
147
+ if (shouldShow == null)
148
+ return
149
+
150
+ if (shouldShow)
151
+ annotation.show()
152
+ else
153
+ annotation.hide()
154
+ })
155
+ },
156
+ })
157
+ },
158
+ }
159
+ }
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@slidev/client",
3
- "version": "0.48.0-beta.0",
3
+ "type": "module",
4
+ "version": "0.48.0-beta.10",
4
5
  "description": "Presentation slides for developers",
5
6
  "author": "antfu <anthonyfu117@hotmail.com>",
6
7
  "license": "MIT",
@@ -13,6 +14,12 @@
13
14
  "bugs": "https://github.com/slidevjs/slidev/issues",
14
15
  "exports": {
15
16
  "./package.json": "./package.json",
17
+ "./constants": "./constants.ts",
18
+ "./context": "./context.ts",
19
+ "./env": "./env.ts",
20
+ "./layoutHelper": "./layoutHelper.ts",
21
+ "./routes": "./routes.ts",
22
+ "./utils": "./utils.ts",
16
23
  "./*": "./*"
17
24
  },
18
25
  "engines": {
@@ -22,34 +29,35 @@
22
29
  "@antfu/utils": "^0.7.7",
23
30
  "@iconify-json/carbon": "^1.1.30",
24
31
  "@iconify-json/ph": "^1.1.11",
25
- "@shikijs/vitepress-twoslash": "^1.1.2",
32
+ "@shikijs/vitepress-twoslash": "^1.1.7",
33
+ "@slidev/rough-notation": "^0.1.0",
26
34
  "@unhead/vue": "^1.8.10",
27
35
  "@unocss/reset": "^0.58.5",
28
- "@vueuse/core": "^10.7.2",
29
- "@vueuse/math": "^10.7.2",
30
- "@vueuse/motion": "^2.0.0",
31
- "codemirror": "^5.65.5",
36
+ "@vueuse/core": "^10.8.0",
37
+ "@vueuse/math": "^10.8.0",
38
+ "@vueuse/motion": "^2.1.0",
39
+ "codemirror": "^5.65.16",
32
40
  "defu": "^6.1.4",
33
- "drauu": "^0.3.7",
41
+ "drauu": "^0.4.0",
34
42
  "file-saver": "^2.0.5",
35
43
  "floating-vue": "^5.2.2",
36
44
  "fuse.js": "^7.0.0",
37
- "js-base64": "^3.7.6",
45
+ "js-base64": "^3.7.7",
38
46
  "js-yaml": "^4.1.0",
39
47
  "katex": "^0.16.9",
40
48
  "mermaid": "^10.8.0",
41
49
  "monaco-editor": "^0.37.1",
42
- "nanoid": "^5.0.5",
50
+ "nanoid": "^5.0.6",
43
51
  "prettier": "^3.2.5",
44
52
  "recordrtc": "^5.6.2",
45
53
  "resolve": "^1.22.8",
46
54
  "unocss": "^0.58.5",
47
55
  "vue": "^3.4.19",
48
- "vue-router": "^4.2.5",
49
- "@slidev/types": "0.48.0-beta.0",
50
- "@slidev/parser": "0.48.0-beta.0"
56
+ "vue-router": "^4.3.0",
57
+ "@slidev/types": "0.48.0-beta.10",
58
+ "@slidev/parser": "0.48.0-beta.10"
51
59
  },
52
60
  "devDependencies": {
53
- "vite": "^5.1.1"
61
+ "vite": "^5.1.4"
54
62
  }
55
63
  }
@@ -21,5 +21,12 @@
21
21
  <carbon:catalog class="text-3em op50" />
22
22
  Notes
23
23
  </RouterLink>
24
+ <RouterLink
25
+ to="/overview"
26
+ class="flex flex-col gap-2 items-center justify-center h-40 min-w-40 rounded bg-gray:10 p4 hover:bg-gray/20"
27
+ >
28
+ <carbon:list-boxes class="text-3em op50" />
29
+ Overview
30
+ </RouterLink>
24
31
  </div>
25
32
  </template>
@@ -7,8 +7,8 @@ import { sharedState } from '../state/shared'
7
7
  import { fullscreen } from '../state'
8
8
  import { total } from '../logic/nav'
9
9
  import { rawRoutes } from '../routes'
10
- import NoteDisplay from './NoteDisplay.vue'
11
- import HiddenText from './HiddenText.vue'
10
+ import NoteDisplay from '../internals/NoteDisplay.vue'
11
+ import IconButton from '../internals/IconButton.vue'
12
12
 
13
13
  const slideTitle = configs.titleTemplate.replace('%s', configs.title || 'Slidev')
14
14
  useHead({
@@ -53,21 +53,18 @@ function decreaseFontSize() {
53
53
  :placeholder="`No notes for Slide ${pageNo}.`"
54
54
  />
55
55
  </div>
56
- <div class="flex-none border-t border-gray-400 border-opacity-20">
56
+ <div class="flex-none border-t border-main">
57
57
  <div class="flex gap-1 items-center px-6 py-3">
58
- <button class="slidev-icon-btn" @click="toggleFullscreen">
59
- <HiddenText :text="isFullscreen ? 'Close fullscreen' : 'Enter fullscreen'" />
58
+ <IconButton :title="isFullscreen ? 'Close fullscreen' : 'Enter fullscreen'" @click="toggleFullscreen">
60
59
  <carbon:minimize v-if="isFullscreen" />
61
60
  <carbon:maximize v-else />
62
- </button>
63
- <button class="slidev-icon-btn" @click="increaseFontSize">
64
- <HiddenText text="Increase font size" />
61
+ </IconButton>
62
+ <IconButton title="Increase font size" @click="increaseFontSize">
65
63
  <carbon:zoom-in />
66
- </button>
67
- <button class="slidev-icon-btn" @click="decreaseFontSize">
68
- <HiddenText text="Decrease font size" />
64
+ </IconButton>
65
+ <IconButton title="Decrease font size" @click="decreaseFontSize">
69
66
  <carbon:zoom-out />
70
- </button>
67
+ </IconButton>
71
68
  <div class="flex-auto" />
72
69
  <div class="p2 text-center">
73
70
  {{ pageNo }} / {{ total }}