@slidev/client 0.48.0-beta.4 → 0.48.0-beta.6
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.
- package/builtin/CodeBlockWrapper.vue +4 -3
- package/builtin/KaTexBlockWrapper.vue +4 -3
- package/builtin/RenderWhen.vue +3 -3
- package/builtin/SlideCurrentNo.vue +2 -3
- package/builtin/SlidesTotal.vue +3 -4
- package/builtin/SlidevVideo.vue +8 -6
- package/builtin/Toc.vue +3 -3
- package/builtin/VClickGap.vue +3 -5
- package/composables/useClicks.ts +16 -13
- package/constants.ts +12 -18
- package/context.ts +70 -0
- package/internals/DrawingLayer.vue +3 -2
- package/internals/Editor.vue +5 -0
- package/internals/PrintContainer.vue +3 -2
- package/internals/PrintSlideClick.vue +3 -2
- package/internals/SlideContainer.vue +3 -3
- package/internals/SlideWrapper.ts +7 -6
- package/logic/note.ts +4 -4
- package/modules/context.ts +3 -2
- package/package.json +10 -3
- package/state/index.ts +10 -10
|
@@ -14,11 +14,12 @@ Learn more: https://sli.dev/guide/syntax.html#line-highlighting
|
|
|
14
14
|
<script setup lang="ts">
|
|
15
15
|
import { parseRangeString } from '@slidev/parser/core'
|
|
16
16
|
import { useClipboard } from '@vueuse/core'
|
|
17
|
-
import { computed,
|
|
17
|
+
import { computed, onMounted, onUnmounted, ref, watchEffect } from 'vue'
|
|
18
18
|
import type { PropType } from 'vue'
|
|
19
19
|
import { configs } from '../env'
|
|
20
20
|
import { makeId } from '../logic/utils'
|
|
21
|
-
import { CLASS_VCLICK_HIDDEN, CLASS_VCLICK_TARGET
|
|
21
|
+
import { CLASS_VCLICK_HIDDEN, CLASS_VCLICK_TARGET } from '../constants'
|
|
22
|
+
import { useSlideContext } from '../context'
|
|
22
23
|
|
|
23
24
|
const props = defineProps({
|
|
24
25
|
ranges: {
|
|
@@ -47,7 +48,7 @@ const props = defineProps({
|
|
|
47
48
|
},
|
|
48
49
|
})
|
|
49
50
|
|
|
50
|
-
const clicks =
|
|
51
|
+
const { $clicksContext: clicks } = useSlideContext()
|
|
51
52
|
const el = ref<HTMLDivElement>()
|
|
52
53
|
const id = makeId()
|
|
53
54
|
|
|
@@ -20,11 +20,12 @@ Learn more: https://sli.dev/guide/syntax.html#latex-line-highlighting
|
|
|
20
20
|
-->
|
|
21
21
|
|
|
22
22
|
<script setup lang="ts">
|
|
23
|
-
import { computed,
|
|
23
|
+
import { computed, onMounted, onUnmounted, ref, watchEffect } from 'vue'
|
|
24
24
|
import type { PropType } from 'vue'
|
|
25
25
|
import { parseRangeString } from '@slidev/parser'
|
|
26
|
-
import { CLASS_VCLICK_HIDDEN, CLASS_VCLICK_TARGET
|
|
26
|
+
import { CLASS_VCLICK_HIDDEN, CLASS_VCLICK_TARGET } from '../constants'
|
|
27
27
|
import { makeId } from '../logic/utils'
|
|
28
|
+
import { useSlideContext } from '../context'
|
|
28
29
|
|
|
29
30
|
const props = defineProps({
|
|
30
31
|
ranges: {
|
|
@@ -45,7 +46,7 @@ const props = defineProps({
|
|
|
45
46
|
},
|
|
46
47
|
})
|
|
47
48
|
|
|
48
|
-
const clicks =
|
|
49
|
+
const { $clicksContext: clicks } = useSlideContext()
|
|
49
50
|
const el = ref<HTMLDivElement>()
|
|
50
51
|
const id = makeId()
|
|
51
52
|
|
package/builtin/RenderWhen.vue
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import type { RenderContext } from '@slidev/types'
|
|
3
|
-
import { computed,
|
|
3
|
+
import { computed, ref } from 'vue'
|
|
4
4
|
import { useElementVisibility } from '@vueuse/core'
|
|
5
|
-
import {
|
|
5
|
+
import { useSlideContext } from '../context'
|
|
6
6
|
|
|
7
7
|
type Context = 'main' | 'visible' | RenderContext
|
|
8
8
|
|
|
@@ -16,7 +16,7 @@ const targetVisible = useElementVisibility(target)
|
|
|
16
16
|
// When context has `visible`, we need to wrap the content with a div to track the visibility
|
|
17
17
|
const needsDomWrapper = Array.isArray(context) ? context.includes('visible') : context === 'visible'
|
|
18
18
|
|
|
19
|
-
const currentContext =
|
|
19
|
+
const { $renderContext: currentContext } = useSlideContext()
|
|
20
20
|
const shouldRender = computed(() => {
|
|
21
21
|
const anyContext = Array.isArray(context) ? context.some(contextMatch) : contextMatch(context)
|
|
22
22
|
const allConditions = Array.isArray(context) ? context.every(conditionsMatch) : conditionsMatch(context)
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
import { injectionCurrentPage } from '../constants'
|
|
2
|
+
import { useSlideContext } from '../context'
|
|
4
3
|
|
|
5
|
-
const $page =
|
|
4
|
+
const { $page } = useSlideContext()
|
|
6
5
|
</script>
|
|
7
6
|
|
|
8
7
|
<template>
|
package/builtin/SlidesTotal.vue
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
import { injectionSlidevContext } from '../constants'
|
|
2
|
+
import { useSlideContext } from '../context'
|
|
4
3
|
|
|
5
|
-
const $
|
|
4
|
+
const { $nav } = useSlideContext()
|
|
6
5
|
</script>
|
|
7
6
|
|
|
8
7
|
<template>
|
|
9
|
-
<span>{{ $
|
|
8
|
+
<span>{{ $nav.total }}</span>
|
|
10
9
|
</template>
|
package/builtin/SlidevVideo.vue
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { computed,
|
|
3
|
-
import {
|
|
2
|
+
import { computed, onMounted, onUnmounted, ref, watch } from 'vue'
|
|
3
|
+
import { useSlideContext } from '../context'
|
|
4
4
|
|
|
5
5
|
const props = defineProps<{
|
|
6
6
|
autoPlay?: boolean | 'once' | 'resume' | 'resumeOnce'
|
|
@@ -8,10 +8,12 @@ const props = defineProps<{
|
|
|
8
8
|
autoReset?: 'slide' | 'click'
|
|
9
9
|
}>()
|
|
10
10
|
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
const {
|
|
12
|
+
$slidev,
|
|
13
|
+
$clicksContext: clicks,
|
|
14
|
+
$renderContext: currentContext,
|
|
15
|
+
$route: route,
|
|
16
|
+
} = useSlideContext()
|
|
15
17
|
|
|
16
18
|
const video = ref<HTMLMediaElement>()
|
|
17
19
|
const played = ref(false)
|
package/builtin/Toc.vue
CHANGED
|
@@ -8,9 +8,9 @@ Usage:
|
|
|
8
8
|
<Toc columns='2' maxDepth='3' mode='onlySiblings'/>
|
|
9
9
|
-->
|
|
10
10
|
<script setup lang='ts'>
|
|
11
|
-
import { computed
|
|
11
|
+
import { computed } from 'vue'
|
|
12
12
|
import type { TocItem } from '@slidev/types'
|
|
13
|
-
import {
|
|
13
|
+
import { useSlideContext } from '../context'
|
|
14
14
|
|
|
15
15
|
const props = withDefaults(
|
|
16
16
|
defineProps<{
|
|
@@ -33,7 +33,7 @@ const props = withDefaults(
|
|
|
33
33
|
},
|
|
34
34
|
)
|
|
35
35
|
|
|
36
|
-
const $slidev =
|
|
36
|
+
const { $slidev } = useSlideContext()
|
|
37
37
|
|
|
38
38
|
function filterTreeDepth(tree: TocItem[], level = 1): TocItem[] {
|
|
39
39
|
if (level > Number(props.maxDepth)) {
|
package/builtin/VClickGap.vue
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { Fragment,
|
|
3
|
-
import { injectionClicksContext } from '../constants'
|
|
2
|
+
import { Fragment, onMounted, watchEffect } from 'vue'
|
|
4
3
|
import { makeId } from '../logic/utils'
|
|
4
|
+
import { useSlideContext } from '../context'
|
|
5
5
|
|
|
6
6
|
const props = defineProps({
|
|
7
7
|
size: {
|
|
@@ -10,12 +10,10 @@ const props = defineProps({
|
|
|
10
10
|
},
|
|
11
11
|
})
|
|
12
12
|
|
|
13
|
-
const
|
|
13
|
+
const { $clicksContext: clicks } = useSlideContext()
|
|
14
14
|
|
|
15
15
|
onMounted(() => {
|
|
16
16
|
watchEffect((onCleanup) => {
|
|
17
|
-
const clicks = clicksRef?.value
|
|
18
|
-
|
|
19
17
|
if (!clicks || clicks.disabled)
|
|
20
18
|
return
|
|
21
19
|
|
package/composables/useClicks.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type { RouteRecordRaw } from 'vue-router'
|
|
|
6
6
|
import { currentRoute, isPrintMode, isPrintWithClicks, queryClicks, routeForceRefresh } from '../logic/nav'
|
|
7
7
|
import { normalizeAtProp } from '../logic/utils'
|
|
8
8
|
|
|
9
|
-
function useClicksContextBase(
|
|
9
|
+
function useClicksContextBase(getCurrent: () => number, clicksOverrides?: number): ClicksContext {
|
|
10
10
|
const relativeOffsets: ClicksContext['relativeOffsets'] = new Map()
|
|
11
11
|
const map: ClicksContext['map'] = shallowReactive(new Map())
|
|
12
12
|
|
|
@@ -53,7 +53,7 @@ function useClicksContextBase(route: RouteRecordRaw | undefined, getCurrent: ()
|
|
|
53
53
|
get total() {
|
|
54
54
|
// eslint-disable-next-line no-unused-expressions
|
|
55
55
|
routeForceRefresh.value
|
|
56
|
-
return
|
|
56
|
+
return clicksOverrides
|
|
57
57
|
?? Math.max(0, ...[...map.values()].map(v => v.max || 0))
|
|
58
58
|
},
|
|
59
59
|
}
|
|
@@ -63,21 +63,24 @@ export function usePrimaryClicks(route: RouteRecordRaw | undefined): ClicksConte
|
|
|
63
63
|
if (route?.meta?.__clicksContext)
|
|
64
64
|
return route.meta.__clicksContext
|
|
65
65
|
const thisPath = +(route?.path ?? 99999)
|
|
66
|
-
const context = useClicksContextBase(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
66
|
+
const context = useClicksContextBase(
|
|
67
|
+
() => {
|
|
68
|
+
const currentPath = +(currentRoute.value?.path ?? 99999)
|
|
69
|
+
if (currentPath === thisPath)
|
|
70
|
+
return queryClicks.value
|
|
71
|
+
else if (currentPath > thisPath)
|
|
72
|
+
return 99999
|
|
73
|
+
else
|
|
74
|
+
return 0
|
|
75
|
+
},
|
|
76
|
+
route?.meta?.clicks,
|
|
77
|
+
)
|
|
75
78
|
if (route?.meta)
|
|
76
79
|
route.meta.__clicksContext = context
|
|
77
80
|
return context
|
|
78
81
|
}
|
|
79
82
|
|
|
80
|
-
export function useFixedClicks(route
|
|
83
|
+
export function useFixedClicks(route?: RouteRecordRaw | undefined, currentInit = 0): [Ref<number>, ClicksContext] {
|
|
81
84
|
const current = ref(currentInit)
|
|
82
|
-
return [current, useClicksContextBase(
|
|
85
|
+
return [current, useClicksContextBase(() => current.value, route?.meta?.clicks)]
|
|
83
86
|
}
|
package/constants.ts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import type { ComputedRef, InjectionKey, Ref, UnwrapNestedRefs } from 'vue'
|
|
2
2
|
import type { RouteRecordRaw } from 'vue-router'
|
|
3
3
|
import type { ClicksContext, RenderContext } from '@slidev/types'
|
|
4
|
-
import { objectOmit } from '@vueuse/core'
|
|
5
4
|
import type { SlidevContext } from './modules/context'
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export const
|
|
10
|
-
export const
|
|
11
|
-
export const
|
|
12
|
-
export const
|
|
13
|
-
export const
|
|
14
|
-
export const
|
|
6
|
+
// Here we use string literal instead of symbols to make HMR more stable
|
|
7
|
+
// The value of the injections keys are implementation details, you should always use them with the reference to the constant instead of the value
|
|
8
|
+
export const injectionClicksContext = '$$slidev-clicks-context' as unknown as InjectionKey<Ref<ClicksContext>>
|
|
9
|
+
export const injectionCurrentPage = '$$slidev-page' as unknown as InjectionKey<Ref<number>>
|
|
10
|
+
export const injectionSlideScale = '$$slidev-slide-scale' as unknown as InjectionKey<ComputedRef<number>>
|
|
11
|
+
export const injectionSlidevContext = '$$slidev-context' as unknown as InjectionKey<UnwrapNestedRefs<SlidevContext>>
|
|
12
|
+
export const injectionRoute = '$$slidev-route' as unknown as InjectionKey<RouteRecordRaw>
|
|
13
|
+
export const injectionRenderContext = '$$slidev-render-context' as unknown as InjectionKey<Ref<RenderContext>>
|
|
14
|
+
export const injectionActive = '$$slidev-active' as unknown as InjectionKey<Ref<boolean>>
|
|
15
|
+
export const injectionFrontmatter = '$$slidev-fontmatter' as unknown as InjectionKey<Record<string, any>>
|
|
15
16
|
|
|
16
17
|
export const CLASS_VCLICK_TARGET = 'slidev-vclick-target'
|
|
17
18
|
export const CLASS_VCLICK_HIDDEN = 'slidev-vclick-hidden'
|
|
@@ -26,7 +27,7 @@ export const TRUST_ORIGINS = [
|
|
|
26
27
|
'127.0.0.1',
|
|
27
28
|
]
|
|
28
29
|
|
|
29
|
-
const FRONTMATTER_FIELDS = [
|
|
30
|
+
export const FRONTMATTER_FIELDS = [
|
|
30
31
|
'clicks',
|
|
31
32
|
'disabled',
|
|
32
33
|
'hide',
|
|
@@ -41,7 +42,7 @@ const FRONTMATTER_FIELDS = [
|
|
|
41
42
|
'zoom',
|
|
42
43
|
]
|
|
43
44
|
|
|
44
|
-
const HEADMATTER_FIELDS = [
|
|
45
|
+
export const HEADMATTER_FIELDS = [
|
|
45
46
|
...FRONTMATTER_FIELDS,
|
|
46
47
|
'theme',
|
|
47
48
|
'titleTemplate',
|
|
@@ -71,10 +72,3 @@ const HEADMATTER_FIELDS = [
|
|
|
71
72
|
'htmlAttrs',
|
|
72
73
|
'mdc',
|
|
73
74
|
]
|
|
74
|
-
|
|
75
|
-
export function filterFrontmatter(frontmatter: Record<string, any>, pageNo: number) {
|
|
76
|
-
return {
|
|
77
|
-
...objectOmit(frontmatter, pageNo === 0 ? HEADMATTER_FIELDS : FRONTMATTER_FIELDS),
|
|
78
|
-
frontmatter,
|
|
79
|
-
}
|
|
80
|
-
}
|
package/context.ts
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { shallowRef, toRef } from 'vue'
|
|
2
|
+
import { injectLocal, objectOmit, provideLocal } from '@vueuse/core'
|
|
3
|
+
import { useFixedClicks } from './composables/useClicks'
|
|
4
|
+
import {
|
|
5
|
+
FRONTMATTER_FIELDS,
|
|
6
|
+
HEADMATTER_FIELDS,
|
|
7
|
+
injectionClicksContext,
|
|
8
|
+
injectionCurrentPage,
|
|
9
|
+
injectionFrontmatter,
|
|
10
|
+
injectionRenderContext,
|
|
11
|
+
injectionRoute,
|
|
12
|
+
injectionSlidevContext,
|
|
13
|
+
} from './constants'
|
|
14
|
+
|
|
15
|
+
const clicksContextFallback = shallowRef(useFixedClicks()[1])
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Get the current slide context, should be called inside the setup function of a component inside slide
|
|
19
|
+
*/
|
|
20
|
+
export function useSlideContext() {
|
|
21
|
+
const $slidev = injectLocal(injectionSlidevContext)!
|
|
22
|
+
const $nav = toRef($slidev, 'nav')
|
|
23
|
+
const $clicksContext = injectLocal(injectionClicksContext, clicksContextFallback)!.value
|
|
24
|
+
const $clicks = toRef($clicksContext, 'current')
|
|
25
|
+
const $page = injectLocal(injectionCurrentPage)!
|
|
26
|
+
const $renderContext = injectLocal(injectionRenderContext)!
|
|
27
|
+
const $frontmatter = injectLocal(injectionFrontmatter, {})
|
|
28
|
+
const $route = injectLocal(injectionRoute, undefined)
|
|
29
|
+
|
|
30
|
+
return {
|
|
31
|
+
$slidev,
|
|
32
|
+
$nav,
|
|
33
|
+
$clicksContext,
|
|
34
|
+
$clicks,
|
|
35
|
+
$page,
|
|
36
|
+
$route,
|
|
37
|
+
$renderContext,
|
|
38
|
+
$frontmatter,
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function provideFrontmatter(frontmatter: Record<string, any>) {
|
|
43
|
+
provideLocal(injectionFrontmatter, frontmatter)
|
|
44
|
+
|
|
45
|
+
const {
|
|
46
|
+
$slidev,
|
|
47
|
+
$page,
|
|
48
|
+
} = useSlideContext()
|
|
49
|
+
|
|
50
|
+
// update frontmatter in router to make HMR work better
|
|
51
|
+
const route = $slidev.nav.rawRoutes.find(i => i.path === String($page.value))
|
|
52
|
+
if (route?.meta?.slide?.frontmatter) {
|
|
53
|
+
for (const key of Object.keys(route.meta.slide.frontmatter)) {
|
|
54
|
+
if (!(key in frontmatter))
|
|
55
|
+
delete route.meta.slide.frontmatter[key]
|
|
56
|
+
}
|
|
57
|
+
Object.assign(route.meta.slide.frontmatter, frontmatter)
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Convert frontmatter options to props for v-bind
|
|
63
|
+
* It removes known options fields, and expose an extra `frontmatter` field that contains full frontmatter
|
|
64
|
+
*/
|
|
65
|
+
export function frontmatterToProps(frontmatter: Record<string, any>, pageNo: number) {
|
|
66
|
+
return {
|
|
67
|
+
...objectOmit(frontmatter, pageNo === 0 ? HEADMATTER_FIELDS : FRONTMATTER_FIELDS),
|
|
68
|
+
frontmatter,
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import {
|
|
2
|
+
import { onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
|
3
|
+
import { injectLocal } from '@vueuse/core'
|
|
3
4
|
import { drauu, drawingEnabled, loadCanvas } from '../logic/drawings'
|
|
4
5
|
import { injectionSlideScale } from '../constants'
|
|
5
6
|
|
|
6
|
-
const scale =
|
|
7
|
+
const scale = injectLocal(injectionSlideScale)!
|
|
7
8
|
const svg = ref<SVGSVGElement>()
|
|
8
9
|
|
|
9
10
|
onMounted(() => {
|
package/internals/Editor.vue
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { parseRangeString } from '@slidev/parser/core'
|
|
3
|
-
import { computed
|
|
3
|
+
import { computed } from 'vue'
|
|
4
|
+
import { provideLocal } from '@vueuse/core'
|
|
4
5
|
import { configs, slideAspect, slideWidth } from '../env'
|
|
5
6
|
import { injectionSlideScale } from '../constants'
|
|
6
7
|
import { route as currentRoute, rawRoutes } from '../logic/nav'
|
|
@@ -31,7 +32,7 @@ const className = computed(() => ({
|
|
|
31
32
|
'select-none': !configs.selectable,
|
|
32
33
|
}))
|
|
33
34
|
|
|
34
|
-
|
|
35
|
+
provideLocal(injectionSlideScale, scale)
|
|
35
36
|
</script>
|
|
36
37
|
|
|
37
38
|
<template>
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import type { RouteRecordRaw } from 'vue-router'
|
|
3
|
-
import { computed,
|
|
3
|
+
import { computed, reactive, shallowRef } from 'vue'
|
|
4
4
|
import type { ClicksContext } from '@slidev/types'
|
|
5
|
+
import { provideLocal } from '@vueuse/core'
|
|
5
6
|
import { injectionSlidevContext } from '../constants'
|
|
6
7
|
import { configs, slideHeight, slideWidth } from '../env'
|
|
7
8
|
import { getSlideClass } from '../utils'
|
|
@@ -33,7 +34,7 @@ const id = computed(() =>
|
|
|
33
34
|
`${props.route.path.toString().padStart(3, '0')}-${(props.nav.clicks.value + 1).toString().padStart(2, '0')}`,
|
|
34
35
|
)
|
|
35
36
|
|
|
36
|
-
|
|
37
|
+
provideLocal(injectionSlidevContext, reactive({
|
|
37
38
|
nav: props.nav,
|
|
38
39
|
configs,
|
|
39
40
|
themeConfigs: computed(() => configs.themeConfig),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { useElementSize, useStyleTag } from '@vueuse/core'
|
|
3
|
-
import { computed,
|
|
2
|
+
import { provideLocal, useElementSize, useStyleTag } from '@vueuse/core'
|
|
3
|
+
import { computed, ref, watchEffect } from 'vue'
|
|
4
4
|
import { configs, slideAspect, slideHeight, slideWidth } from '../env'
|
|
5
5
|
import { injectionSlideScale } from '../constants'
|
|
6
6
|
import { isPrintMode } from '../logic/nav'
|
|
@@ -64,7 +64,7 @@ if (props.isMain) {
|
|
|
64
64
|
`))
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
provideLocal(injectionSlideScale, scale as any)
|
|
68
68
|
</script>
|
|
69
69
|
|
|
70
70
|
<template>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { computed, defineComponent, h,
|
|
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'
|
|
4
5
|
import type { RouteRecordRaw } from 'vue-router'
|
|
5
6
|
import { injectionActive, injectionClicksContext, injectionCurrentPage, injectionRenderContext, injectionRoute } from '../constants'
|
|
@@ -29,11 +30,11 @@ export default defineComponent({
|
|
|
29
30
|
},
|
|
30
31
|
},
|
|
31
32
|
setup(props) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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'))
|
|
37
38
|
|
|
38
39
|
const style = computed(() => {
|
|
39
40
|
const zoom = props.route.meta?.slide?.frontmatter.zoom ?? 1
|
package/logic/note.ts
CHANGED
|
@@ -2,11 +2,11 @@ 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 } from '@slidev/types'
|
|
5
|
+
import type { SlideInfo, SlidePatch } from '@slidev/types'
|
|
6
6
|
|
|
7
7
|
export interface UseSlideInfo {
|
|
8
8
|
info: Ref<SlideInfo | undefined>
|
|
9
|
-
update: (data:
|
|
9
|
+
update: (data: SlidePatch) => Promise<SlideInfo | void>
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export function useSlideInfo(id: number | undefined): UseSlideInfo {
|
|
@@ -21,7 +21,7 @@ export function useSlideInfo(id: number | undefined): UseSlideInfo {
|
|
|
21
21
|
|
|
22
22
|
execute()
|
|
23
23
|
|
|
24
|
-
const update = async (data:
|
|
24
|
+
const update = async (data: SlidePatch) => {
|
|
25
25
|
return await fetch(
|
|
26
26
|
url,
|
|
27
27
|
{
|
|
@@ -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:
|
|
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/modules/context.ts
CHANGED
|
@@ -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'
|
|
@@ -25,6 +25,7 @@ export default 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
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slidev/client",
|
|
3
|
-
"
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.48.0-beta.6",
|
|
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": {
|
|
@@ -46,8 +53,8 @@
|
|
|
46
53
|
"unocss": "^0.58.5",
|
|
47
54
|
"vue": "^3.4.19",
|
|
48
55
|
"vue-router": "^4.2.5",
|
|
49
|
-
"@slidev/parser": "0.48.0-beta.
|
|
50
|
-
"@slidev/types": "0.48.0-beta.
|
|
56
|
+
"@slidev/parser": "0.48.0-beta.6",
|
|
57
|
+
"@slidev/types": "0.48.0-beta.6"
|
|
51
58
|
},
|
|
52
59
|
"devDependencies": {
|
|
53
60
|
"vite": "^5.1.3"
|
package/state/index.ts
CHANGED
|
@@ -20,19 +20,19 @@ export const activeElement = useActiveElement()
|
|
|
20
20
|
export const isInputting = computed(() => ['INPUT', 'TEXTAREA'].includes(activeElement.value?.tagName || '') || activeElement.value?.classList.contains('CodeMirror-code'))
|
|
21
21
|
export const isOnFocus = computed(() => ['BUTTON', 'A'].includes(activeElement.value?.tagName || ''))
|
|
22
22
|
|
|
23
|
-
export const currentCamera = useLocalStorage<string>('slidev-camera', 'default')
|
|
24
|
-
export const currentMic = useLocalStorage<string>('slidev-mic', 'default')
|
|
23
|
+
export const currentCamera = useLocalStorage<string>('slidev-camera', 'default', { listenToStorageChanges: false })
|
|
24
|
+
export const currentMic = useLocalStorage<string>('slidev-mic', 'default', { listenToStorageChanges: false })
|
|
25
25
|
export const slideScale = useLocalStorage<number>('slidev-scale', 0)
|
|
26
26
|
|
|
27
|
-
export const showOverview = useLocalStorage('slidev-show-overview', false)
|
|
28
|
-
export const showPresenterCursor = useLocalStorage('slidev-presenter-cursor', true)
|
|
29
|
-
export const showEditor = useLocalStorage('slidev-show-editor', false)
|
|
30
|
-
export const isEditorVertical = useLocalStorage('slidev-editor-vertical', false)
|
|
31
|
-
export const editorWidth = useLocalStorage('slidev-editor-width', isClient ? window.innerWidth * 0.4 : 318)
|
|
32
|
-
export const editorHeight = useLocalStorage('slidev-editor-height', isClient ? window.innerHeight * 0.4 : 300)
|
|
27
|
+
export const showOverview = useLocalStorage('slidev-show-overview', false, { listenToStorageChanges: false })
|
|
28
|
+
export const showPresenterCursor = useLocalStorage('slidev-presenter-cursor', true, { listenToStorageChanges: false })
|
|
29
|
+
export const showEditor = useLocalStorage('slidev-show-editor', false, { listenToStorageChanges: false })
|
|
30
|
+
export const isEditorVertical = useLocalStorage('slidev-editor-vertical', false, { listenToStorageChanges: false })
|
|
31
|
+
export const editorWidth = useLocalStorage('slidev-editor-width', isClient ? window.innerWidth * 0.4 : 318, { listenToStorageChanges: false })
|
|
32
|
+
export const editorHeight = useLocalStorage('slidev-editor-height', isClient ? window.innerHeight * 0.4 : 300, { listenToStorageChanges: false })
|
|
33
33
|
|
|
34
|
-
export const presenterNotesFontSize = useLocalStorage('slidev-presenter-font-size', 1)
|
|
35
|
-
export const presenterLayout = useLocalStorage('slidev-presenter-layout', 1)
|
|
34
|
+
export const presenterNotesFontSize = useLocalStorage('slidev-presenter-font-size', 1, { listenToStorageChanges: false })
|
|
35
|
+
export const presenterLayout = useLocalStorage('slidev-presenter-layout', 1, { listenToStorageChanges: false })
|
|
36
36
|
|
|
37
37
|
export function togglePresenterLayout() {
|
|
38
38
|
presenterLayout.value = presenterLayout.value + 1
|