@slidev/client 0.48.2 → 0.48.3
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 +2 -6
- package/builtin/KaTexBlockWrapper.vue +2 -6
- package/builtin/RenderWhen.vue +7 -1
- package/builtin/ShikiMagicMove.vue +5 -2
- package/builtin/SlidevVideo.vue +1 -1
- package/builtin/VClickGap.vue +1 -1
- package/composables/useClicks.ts +2 -7
- package/composables/useNav.ts +0 -5
- package/internals/PrintSlide.vue +3 -2
- package/internals/QuickOverview.vue +0 -1
- package/modules/v-click.ts +1 -1
- package/package.json +6 -6
- package/pages/overview.vue +0 -1
|
@@ -60,17 +60,13 @@ watchEffect(() => {
|
|
|
60
60
|
})
|
|
61
61
|
|
|
62
62
|
onMounted(() => {
|
|
63
|
-
if (!clicks ||
|
|
63
|
+
if (!clicks || !props.ranges?.length)
|
|
64
64
|
return
|
|
65
65
|
|
|
66
66
|
const { start, end, delta } = clicks.resolve(props.at, props.ranges.length - 1)
|
|
67
67
|
clicks.register(id, { max: end, delta })
|
|
68
68
|
|
|
69
|
-
const index = computed(() =>
|
|
70
|
-
if (clicks.disabled)
|
|
71
|
-
return props.ranges.length - 1
|
|
72
|
-
return Math.max(0, clicks.current - start + 1)
|
|
73
|
-
})
|
|
69
|
+
const index = computed(() => Math.max(0, clicks.current - start + 1))
|
|
74
70
|
|
|
75
71
|
const finallyRange = computed(() => {
|
|
76
72
|
return props.finally === 'last' ? props.ranges.at(-1) : props.finally.toString()
|
|
@@ -55,17 +55,13 @@ onUnmounted(() => {
|
|
|
55
55
|
})
|
|
56
56
|
|
|
57
57
|
onMounted(() => {
|
|
58
|
-
if (!clicks ||
|
|
58
|
+
if (!clicks || !props.ranges?.length)
|
|
59
59
|
return
|
|
60
60
|
|
|
61
61
|
const { start, end, delta } = clicks.resolve(props.at, props.ranges.length - 1)
|
|
62
62
|
clicks.register(id, { max: end, delta })
|
|
63
63
|
|
|
64
|
-
const index = computed(() =>
|
|
65
|
-
if (clicks.disabled)
|
|
66
|
-
return props.ranges.length - 1
|
|
67
|
-
return Math.max(0, clicks.current - start + 1)
|
|
68
|
-
})
|
|
64
|
+
const index = computed(() => Math.max(0, clicks.current - start + 1))
|
|
69
65
|
|
|
70
66
|
const finallyRange = computed(() => {
|
|
71
67
|
return props.finally === 'last' ? props.ranges.at(-1) : props.finally.toString()
|
package/builtin/RenderWhen.vue
CHANGED
|
@@ -3,8 +3,9 @@ import type { RenderContext } from '@slidev/types'
|
|
|
3
3
|
import { computed, ref } from 'vue'
|
|
4
4
|
import { useElementVisibility } from '@vueuse/core'
|
|
5
5
|
import { useSlideContext } from '../context'
|
|
6
|
+
import { useNav } from '../composables/useNav'
|
|
6
7
|
|
|
7
|
-
type Context = 'main' | 'visible' | RenderContext
|
|
8
|
+
type Context = 'main' | 'visible' | 'print' | RenderContext
|
|
8
9
|
|
|
9
10
|
const props = defineProps<{
|
|
10
11
|
context: Context | Context[]
|
|
@@ -17,6 +18,7 @@ const targetVisible = useElementVisibility(target)
|
|
|
17
18
|
const needsDomWrapper = Array.isArray(context) ? context.includes('visible') : context === 'visible'
|
|
18
19
|
|
|
19
20
|
const { $renderContext: currentContext } = useSlideContext()
|
|
21
|
+
const { isPrintMode } = useNav()
|
|
20
22
|
const shouldRender = computed(() => {
|
|
21
23
|
const anyContext = Array.isArray(context) ? context.some(contextMatch) : contextMatch(context)
|
|
22
24
|
const allConditions = Array.isArray(context) ? context.every(conditionsMatch) : conditionsMatch(context)
|
|
@@ -30,6 +32,8 @@ function contextMatch(context: Context) {
|
|
|
30
32
|
return true
|
|
31
33
|
if (context === 'visible')
|
|
32
34
|
return true
|
|
35
|
+
if (context === 'print' && isPrintMode.value)
|
|
36
|
+
return true
|
|
33
37
|
return false
|
|
34
38
|
}
|
|
35
39
|
|
|
@@ -43,6 +47,8 @@ function conditionsMatch(context: Context) {
|
|
|
43
47
|
<template>
|
|
44
48
|
<div v-if="needsDomWrapper" ref="target">
|
|
45
49
|
<slot v-if="shouldRender" />
|
|
50
|
+
<slot v-else name="fallback" />
|
|
46
51
|
</div>
|
|
47
52
|
<slot v-else-if="shouldRender" />
|
|
53
|
+
<slot v-else name="fallback" />
|
|
48
54
|
</template>
|
|
@@ -5,6 +5,7 @@ import { computed, onMounted, onUnmounted, ref, watch } from 'vue'
|
|
|
5
5
|
import lz from 'lz-string'
|
|
6
6
|
import { useSlideContext } from '../context'
|
|
7
7
|
import { makeId, updateCodeHighlightRange } from '../logic/utils'
|
|
8
|
+
import { useNav } from '../composables/useNav'
|
|
8
9
|
|
|
9
10
|
const props = defineProps<{
|
|
10
11
|
at?: string | number
|
|
@@ -14,6 +15,7 @@ const props = defineProps<{
|
|
|
14
15
|
|
|
15
16
|
const steps = JSON.parse(lz.decompressFromBase64(props.stepsLz)) as KeyedTokensInfo[]
|
|
16
17
|
const { $clicksContext: clicks, $scale: scale } = useSlideContext()
|
|
18
|
+
const { isPrintMode } = useNav()
|
|
17
19
|
const id = makeId()
|
|
18
20
|
|
|
19
21
|
const stepIndex = ref(0)
|
|
@@ -23,11 +25,11 @@ const container = ref<HTMLElement>()
|
|
|
23
25
|
const ranges = computed(() => props.stepRanges.map(i => i.length ? i : ['all']))
|
|
24
26
|
|
|
25
27
|
onUnmounted(() => {
|
|
26
|
-
clicks
|
|
28
|
+
clicks?.unregister(id)
|
|
27
29
|
})
|
|
28
30
|
|
|
29
31
|
onMounted(() => {
|
|
30
|
-
if (!clicks
|
|
32
|
+
if (!clicks)
|
|
31
33
|
return
|
|
32
34
|
|
|
33
35
|
if (ranges.value.length !== steps.length)
|
|
@@ -92,6 +94,7 @@ onMounted(() => {
|
|
|
92
94
|
class="slidev-code relative shiki overflow-visible"
|
|
93
95
|
:steps="steps"
|
|
94
96
|
:step="stepIndex"
|
|
97
|
+
:animate="!isPrintMode"
|
|
95
98
|
:options="{
|
|
96
99
|
globalScale: scale,
|
|
97
100
|
// TODO: make this configurable later
|
package/builtin/SlidevVideo.vue
CHANGED
|
@@ -26,7 +26,7 @@ const matchRoute = computed(() => {
|
|
|
26
26
|
})
|
|
27
27
|
|
|
28
28
|
const matchClick = computed(() => {
|
|
29
|
-
if (!video.value || currentContext?.value !== 'slide' || clicks
|
|
29
|
+
if (!video.value || currentContext?.value !== 'slide' || !clicks)
|
|
30
30
|
return false
|
|
31
31
|
return clicks.map.get(video.value)?.isShown?.value ?? true
|
|
32
32
|
})
|
package/builtin/VClickGap.vue
CHANGED
package/composables/useClicks.ts
CHANGED
|
@@ -8,15 +8,11 @@ import { routeForceRefresh } from '../logic/route'
|
|
|
8
8
|
export function createClicksContextBase(
|
|
9
9
|
current: Ref<number>,
|
|
10
10
|
clicksOverrides?: number,
|
|
11
|
-
isDisabled?: () => boolean,
|
|
12
11
|
): ClicksContext {
|
|
13
12
|
const relativeOffsets: ClicksContext['relativeOffsets'] = new Map()
|
|
14
13
|
const map: ClicksContext['map'] = shallowReactive(new Map())
|
|
15
14
|
|
|
16
15
|
return {
|
|
17
|
-
get disabled() {
|
|
18
|
-
return isDisabled ? isDisabled() : false
|
|
19
|
-
},
|
|
20
16
|
get current() {
|
|
21
17
|
return +current.value
|
|
22
18
|
},
|
|
@@ -25,7 +21,7 @@ export function createClicksContextBase(
|
|
|
25
21
|
},
|
|
26
22
|
relativeOffsets,
|
|
27
23
|
map,
|
|
28
|
-
onMounted() {},
|
|
24
|
+
onMounted() { },
|
|
29
25
|
resolve(at, size = 1) {
|
|
30
26
|
const [isRelative, value] = normalizeAtProp(at)
|
|
31
27
|
if (isRelative) {
|
|
@@ -68,7 +64,6 @@ export function createClicksContextBase(
|
|
|
68
64
|
export function createFixedClicks(
|
|
69
65
|
route?: SlideRoute | undefined,
|
|
70
66
|
currentInit = 0,
|
|
71
|
-
isDisabled?: () => boolean,
|
|
72
67
|
): ClicksContext {
|
|
73
|
-
return createClicksContextBase(ref(currentInit), route?.meta?.clicks
|
|
68
|
+
return createClicksContextBase(ref(currentInit), route?.meta?.clicks)
|
|
74
69
|
}
|
package/composables/useNav.ts
CHANGED
|
@@ -259,8 +259,6 @@ const useNavState = createSharedComposable((): SlidevContextNavState => {
|
|
|
259
259
|
|
|
260
260
|
const queryClicks = computed({
|
|
261
261
|
get() {
|
|
262
|
-
if (clicksContext.value.disabled)
|
|
263
|
-
return CLICKS_MAX
|
|
264
262
|
let v = +(queryClicksRaw.value || 0)
|
|
265
263
|
if (Number.isNaN(v))
|
|
266
264
|
v = 0
|
|
@@ -281,8 +279,6 @@ const useNavState = createSharedComposable((): SlidevContextNavState => {
|
|
|
281
279
|
const context = createClicksContextBase(
|
|
282
280
|
computed({
|
|
283
281
|
get() {
|
|
284
|
-
if (context.disabled)
|
|
285
|
-
return CLICKS_MAX
|
|
286
282
|
if (currentSlideNo.value === thisNo)
|
|
287
283
|
return +(queryClicksRaw.value || 0) || 0
|
|
288
284
|
else if (currentSlideNo.value > thisNo)
|
|
@@ -296,7 +292,6 @@ const useNavState = createSharedComposable((): SlidevContextNavState => {
|
|
|
296
292
|
},
|
|
297
293
|
}),
|
|
298
294
|
route?.meta?.clicks,
|
|
299
|
-
() => isPrintMode.value && !isPrintWithClicks.value,
|
|
300
295
|
)
|
|
301
296
|
|
|
302
297
|
// On slide mounted, make sure the query is not greater than the total
|
package/internals/PrintSlide.vue
CHANGED
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
import type { SlideRoute } from '@slidev/types'
|
|
3
3
|
import { useFixedNav, useNav } from '../composables/useNav'
|
|
4
4
|
import { createFixedClicks } from '../composables/useClicks'
|
|
5
|
+
import { CLICKS_MAX } from '../constants'
|
|
5
6
|
import PrintSlideClick from './PrintSlideClick.vue'
|
|
6
7
|
|
|
7
8
|
const { route } = defineProps<{ route: SlideRoute }>()
|
|
8
9
|
const { isPrintWithClicks } = useNav()
|
|
9
|
-
const clicks0 = createFixedClicks(route, 0
|
|
10
|
+
const clicks0 = createFixedClicks(route, isPrintWithClicks.value ? 0 : CLICKS_MAX)
|
|
10
11
|
</script>
|
|
11
12
|
|
|
12
13
|
<template>
|
|
@@ -14,7 +15,7 @@ const clicks0 = createFixedClicks(route, 0, () => !isPrintWithClicks.value)
|
|
|
14
15
|
:clicks-context="clicks0"
|
|
15
16
|
:nav="useFixedNav(route, clicks0)"
|
|
16
17
|
/>
|
|
17
|
-
<template v-if="
|
|
18
|
+
<template v-if="isPrintWithClicks">
|
|
18
19
|
<PrintSlideClick
|
|
19
20
|
v-for="i of clicks0.total"
|
|
20
21
|
:key="i"
|
package/modules/v-click.ts
CHANGED
|
@@ -132,7 +132,7 @@ function isCurrent(thisClick: number | [number, number], clicks: number) {
|
|
|
132
132
|
export function resolveClick(el: Element, dir: DirectiveBinding<any>, value: VClickValue, clickAfter = false, flagHide = false): ResolvedClicksInfo | null {
|
|
133
133
|
const ctx = dirInject(dir, injectionClicksContext)?.value
|
|
134
134
|
|
|
135
|
-
if (!el || !ctx
|
|
135
|
+
if (!el || !ctx)
|
|
136
136
|
return null
|
|
137
137
|
|
|
138
138
|
if (value === false || value === 'false')
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slidev/client",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.48.
|
|
4
|
+
"version": "0.48.3",
|
|
5
5
|
"description": "Presentation slides for developers",
|
|
6
6
|
"author": "antfu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@shikijs/vitepress-twoslash": "^1.1.7",
|
|
37
37
|
"@slidev/rough-notation": "^0.1.0",
|
|
38
38
|
"@typescript/ata": "^0.9.4",
|
|
39
|
-
"@unhead/vue": "^1.8.
|
|
39
|
+
"@unhead/vue": "^1.8.18",
|
|
40
40
|
"@unocss/reset": "^0.58.5",
|
|
41
41
|
"@vueuse/core": "^10.9.0",
|
|
42
42
|
"@vueuse/math": "^10.9.0",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"katex": "^0.16.9",
|
|
51
51
|
"lz-string": "^1.5.0",
|
|
52
52
|
"mermaid": "^10.9.0",
|
|
53
|
-
"monaco-editor": "^0.
|
|
53
|
+
"monaco-editor": "^0.47.0",
|
|
54
54
|
"prettier": "^3.2.5",
|
|
55
55
|
"recordrtc": "^5.6.2",
|
|
56
56
|
"shiki": "^1.1.7",
|
|
@@ -60,10 +60,10 @@
|
|
|
60
60
|
"vue": "^3.4.21",
|
|
61
61
|
"vue-demi": "^0.14.7",
|
|
62
62
|
"vue-router": "^4.3.0",
|
|
63
|
-
"@slidev/
|
|
64
|
-
"@slidev/
|
|
63
|
+
"@slidev/types": "0.48.3",
|
|
64
|
+
"@slidev/parser": "0.48.3"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
|
-
"vite": "^5.1.
|
|
67
|
+
"vite": "^5.1.6"
|
|
68
68
|
}
|
|
69
69
|
}
|