@slidev/client 0.32.1 → 0.32.4
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/Mermaid.vue +8 -1
- package/builtin/Monaco.vue +0 -2
- package/builtin/RenderWhen.vue +29 -0
- package/constants.ts +2 -0
- package/internals/Play.vue +2 -2
- package/internals/Presenter.vue +4 -3
- package/internals/SlideWrapper.ts +6 -1
- package/internals/SlidesOverview.vue +23 -2
- package/internals/SlidesShow.vue +3 -0
- package/logic/overview.ts +41 -0
- package/logic/shortcuts.ts +12 -6
- package/package.json +15 -15
- package/shim.d.ts +0 -2
package/builtin/Mermaid.vue
CHANGED
|
@@ -16,6 +16,7 @@ pie
|
|
|
16
16
|
import { computed, getCurrentInstance, ref, watch, watchEffect } from 'vue'
|
|
17
17
|
import { renderMermaid } from '../modules/mermaid'
|
|
18
18
|
import ShadowRoot from '../internals/ShadowRoot.vue'
|
|
19
|
+
import { isDark } from '../logic/dark'
|
|
19
20
|
|
|
20
21
|
const props = defineProps<{
|
|
21
22
|
code: string
|
|
@@ -25,7 +26,13 @@ const props = defineProps<{
|
|
|
25
26
|
|
|
26
27
|
const vm = getCurrentInstance()
|
|
27
28
|
const el = ref<HTMLDivElement>()
|
|
28
|
-
const svgObj = computed(() => renderMermaid(
|
|
29
|
+
const svgObj = computed(() => renderMermaid(
|
|
30
|
+
props.code || '',
|
|
31
|
+
{
|
|
32
|
+
theme: props.theme || (isDark.value ? 'dark' : undefined),
|
|
33
|
+
...vm!.attrs,
|
|
34
|
+
},
|
|
35
|
+
))
|
|
29
36
|
const html = computed(() => svgObj.value)
|
|
30
37
|
const actualHeight = ref<number>()
|
|
31
38
|
|
package/builtin/Monaco.vue
CHANGED
|
@@ -74,11 +74,9 @@ onMounted(() => {
|
|
|
74
74
|
'allow-top-navigation-by-user-activation',
|
|
75
75
|
].join(' '))
|
|
76
76
|
|
|
77
|
-
/* eslint-disable no-undef */
|
|
78
77
|
frame.src = __DEV__
|
|
79
78
|
? `${location.origin}${__SLIDEV_CLIENT_ROOT__}/iframes/monaco/index.html`
|
|
80
79
|
: `${import.meta.env.BASE_URL}iframes/monaco/index.html`
|
|
81
|
-
/* eslint-enable no-undef */
|
|
82
80
|
|
|
83
81
|
frame.style.backgroundColor = 'transparent'
|
|
84
82
|
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, inject } from 'vue'
|
|
3
|
+
import type { RenderContext } from '@slidev/types'
|
|
4
|
+
|
|
5
|
+
import { injectionSlideContext } from '../constants'
|
|
6
|
+
|
|
7
|
+
type Context = 'main' | RenderContext
|
|
8
|
+
|
|
9
|
+
const props = defineProps<{
|
|
10
|
+
context: Context | Context[]
|
|
11
|
+
}>()
|
|
12
|
+
const { context } = props
|
|
13
|
+
|
|
14
|
+
const currentContext = inject(injectionSlideContext)
|
|
15
|
+
|
|
16
|
+
const shouldRender = computed(() => Array.isArray(context) ? context.some(contextMatch) : contextMatch(context))
|
|
17
|
+
|
|
18
|
+
function contextMatch(context: Context) {
|
|
19
|
+
if (context === currentContext)
|
|
20
|
+
return true
|
|
21
|
+
if (context === 'main' && (currentContext === 'slide' || currentContext === 'presenter'))
|
|
22
|
+
return true
|
|
23
|
+
return false
|
|
24
|
+
}
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<template>
|
|
28
|
+
<slot v-if="shouldRender" />
|
|
29
|
+
</template>
|
package/constants.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ComputedRef, InjectionKey, Ref } from 'vue'
|
|
2
2
|
import type { RouteRecordRaw } from 'vue-router'
|
|
3
|
+
import type { RenderContext } from '@slidev/types'
|
|
3
4
|
import type { SlidevContext } from './modules/context'
|
|
4
5
|
|
|
5
6
|
export const injectionClicks: InjectionKey<Ref<number>> = Symbol('v-click-clicks')
|
|
@@ -9,6 +10,7 @@ export const injectionClicksDisabled: InjectionKey<Ref<boolean>> = Symbol('v-cli
|
|
|
9
10
|
export const injectionSlideScale: InjectionKey<ComputedRef<number>> = Symbol('slidev-slide-scale')
|
|
10
11
|
export const injectionSlidevContext: InjectionKey<SlidevContext> = Symbol('slidev-slidev-context')
|
|
11
12
|
export const injectionRoute: InjectionKey<RouteRecordRaw> = Symbol('slidev-route')
|
|
13
|
+
export const injectionSlideContext: InjectionKey<RenderContext> = Symbol('slidev-slide-context')
|
|
12
14
|
|
|
13
15
|
export const CLASS_VCLICK_TARGET = 'slidev-vclick-target'
|
|
14
16
|
export const CLASS_VCLICK_HIDDEN = 'slidev-vclick-hidden'
|
package/internals/Play.vue
CHANGED
package/internals/Presenter.vue
CHANGED
|
@@ -52,7 +52,7 @@ const nextSlide = computed(() => {
|
|
|
52
52
|
}
|
|
53
53
|
})
|
|
54
54
|
|
|
55
|
-
// sync presenter
|
|
55
|
+
// sync presenter cursor
|
|
56
56
|
onMounted(() => {
|
|
57
57
|
const slidesContainer = main.value!.querySelector('#slide-content')!
|
|
58
58
|
const mouse = reactive(useMouse())
|
|
@@ -102,8 +102,8 @@ onMounted(() => {
|
|
|
102
102
|
key="main"
|
|
103
103
|
class="h-full w-full"
|
|
104
104
|
>
|
|
105
|
-
<template
|
|
106
|
-
<SlidesShow />
|
|
105
|
+
<template #default>
|
|
106
|
+
<SlidesShow context="presenter" />
|
|
107
107
|
</template>
|
|
108
108
|
</SlideContainer>
|
|
109
109
|
</div>
|
|
@@ -120,6 +120,7 @@ onMounted(() => {
|
|
|
120
120
|
:clicks-disabled="false"
|
|
121
121
|
:class="getSlideClass(nextSlide.route)"
|
|
122
122
|
:route="nextSlide.route"
|
|
123
|
+
context="previewNext"
|
|
123
124
|
/>
|
|
124
125
|
</SlideContainer>
|
|
125
126
|
</div>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useVModel } from '@vueuse/core'
|
|
2
2
|
import { defineComponent, h, provide } from 'vue'
|
|
3
|
-
import { injectionClicks, injectionClicksDisabled, injectionClicksElements, injectionOrderMap, injectionRoute } from '../constants'
|
|
3
|
+
import { injectionClicks, injectionClicksDisabled, injectionClicksElements, injectionOrderMap, injectionRoute, injectionSlideContext } from '../constants'
|
|
4
4
|
|
|
5
5
|
export default defineComponent({
|
|
6
6
|
props: {
|
|
@@ -20,6 +20,10 @@ export default defineComponent({
|
|
|
20
20
|
type: Boolean,
|
|
21
21
|
default: false,
|
|
22
22
|
},
|
|
23
|
+
context: {
|
|
24
|
+
type: String,
|
|
25
|
+
default: 'main',
|
|
26
|
+
},
|
|
23
27
|
is: {
|
|
24
28
|
type: Object,
|
|
25
29
|
default: undefined,
|
|
@@ -38,6 +42,7 @@ export default defineComponent({
|
|
|
38
42
|
clicksElements.value.length = 0
|
|
39
43
|
|
|
40
44
|
provide(injectionRoute, props.route)
|
|
45
|
+
provide(injectionSlideContext, props.context)
|
|
41
46
|
provide(injectionClicks, clicks)
|
|
42
47
|
provide(injectionClicksDisabled, clicksDisabled)
|
|
43
48
|
provide(injectionClicksElements, clicksElements)
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { useVModel } from '@vueuse/core'
|
|
3
|
-
import { computed } from 'vue'
|
|
3
|
+
import { computed, watchEffect } from 'vue'
|
|
4
4
|
import { breakpoints, windowSize } from '../state'
|
|
5
|
-
import { go as goSlide, rawRoutes } from '../logic/nav'
|
|
5
|
+
import { currentPage, go as goSlide, rawRoutes } from '../logic/nav'
|
|
6
|
+
import { currentOverviewPage, overviewRowCount } from '../logic/overview'
|
|
6
7
|
import { getSlideClass } from '../utils'
|
|
7
8
|
import SlideContainer from './SlideContainer.vue'
|
|
8
9
|
import SlideWrapper from './SlideWrapper'
|
|
@@ -22,6 +23,12 @@ function go(page: number) {
|
|
|
22
23
|
close()
|
|
23
24
|
}
|
|
24
25
|
|
|
26
|
+
function focus(page: number) {
|
|
27
|
+
if (page === currentOverviewPage.value)
|
|
28
|
+
return true
|
|
29
|
+
return false
|
|
30
|
+
}
|
|
31
|
+
|
|
25
32
|
const xs = breakpoints.smaller('xs')
|
|
26
33
|
const sm = breakpoints.smaller('sm')
|
|
27
34
|
|
|
@@ -34,6 +41,18 @@ const cardWidth = computed(() => {
|
|
|
34
41
|
return (windowSize.width.value - padding - gap) / 2
|
|
35
42
|
return 300
|
|
36
43
|
})
|
|
44
|
+
|
|
45
|
+
const rowCount = computed(() => {
|
|
46
|
+
return Math.floor((windowSize.width.value - padding) / (cardWidth.value + gap))
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
watchEffect(() => {
|
|
50
|
+
// Watch currentPage, make sure every time we open overview,
|
|
51
|
+
// we focus on the right page.
|
|
52
|
+
currentOverviewPage.value = currentPage.value
|
|
53
|
+
// Watch rowCount, make sure up and down shortcut work correctly.
|
|
54
|
+
overviewRowCount.value = rowCount.value
|
|
55
|
+
})
|
|
37
56
|
</script>
|
|
38
57
|
|
|
39
58
|
<template>
|
|
@@ -52,6 +71,7 @@ const cardWidth = computed(() => {
|
|
|
52
71
|
>
|
|
53
72
|
<div
|
|
54
73
|
class="inline-block border border-gray-400 rounded border-opacity-50 overflow-hidden bg-main hover:(border-$slidev-theme-primary)"
|
|
74
|
+
:class="{ 'border-$slidev-theme-primary': focus(idx + 1) }"
|
|
55
75
|
@click="go(+route.path)"
|
|
56
76
|
>
|
|
57
77
|
<SlideContainer
|
|
@@ -65,6 +85,7 @@ const cardWidth = computed(() => {
|
|
|
65
85
|
:clicks-disabled="true"
|
|
66
86
|
:class="getSlideClass(route)"
|
|
67
87
|
:route="route"
|
|
88
|
+
context="overview"
|
|
68
89
|
/>
|
|
69
90
|
<DrawingPreview :page="+route.path" />
|
|
70
91
|
</SlideContainer>
|
package/internals/SlidesShow.vue
CHANGED
|
@@ -9,6 +9,8 @@ import GlobalTop from '/@slidev/global-components/top'
|
|
|
9
9
|
import GlobalBottom from '/@slidev/global-components/bottom'
|
|
10
10
|
import PresenterMouse from './PresenterMouse.vue'
|
|
11
11
|
|
|
12
|
+
defineProps<{ context: 'slide' | 'presenter' }>()
|
|
13
|
+
|
|
12
14
|
// preload next route
|
|
13
15
|
watch(currentRoute, () => {
|
|
14
16
|
if (currentRoute.value?.meta && currentRoute.value.meta.preload !== false)
|
|
@@ -37,6 +39,7 @@ if (__SLIDEV_FEATURE_DRAWINGS__ || __SLIDEV_FEATURE_DRAWINGS_PERSIST__)
|
|
|
37
39
|
:clicks-disabled="false"
|
|
38
40
|
:class="getSlideClass(route)"
|
|
39
41
|
:route="route"
|
|
42
|
+
:context="context"
|
|
40
43
|
/>
|
|
41
44
|
</template>
|
|
42
45
|
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { computed, ref } from 'vue'
|
|
2
|
+
import { rawRoutes } from '../routes'
|
|
3
|
+
|
|
4
|
+
// To have same format(.value) as max, wrap it with ref.
|
|
5
|
+
const min = ref(1)
|
|
6
|
+
// The last page is an end page generated by slidev,
|
|
7
|
+
// so we need to subtract 1.
|
|
8
|
+
const max = computed(() => rawRoutes.length - 1)
|
|
9
|
+
|
|
10
|
+
export const currentOverviewPage = ref(0)
|
|
11
|
+
export const overviewRowCount = ref(0)
|
|
12
|
+
|
|
13
|
+
export function prevOverviewPage() {
|
|
14
|
+
if (currentOverviewPage.value > min.value)
|
|
15
|
+
currentOverviewPage.value -= 1
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function nextOverviewPage() {
|
|
19
|
+
if (currentOverviewPage.value < max.value)
|
|
20
|
+
currentOverviewPage.value += 1
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function upOverviewPage() {
|
|
24
|
+
if (currentOverviewPage.value > min.value) {
|
|
25
|
+
let current = currentOverviewPage.value - overviewRowCount.value
|
|
26
|
+
if (current < min.value)
|
|
27
|
+
current = min.value
|
|
28
|
+
|
|
29
|
+
currentOverviewPage.value = current
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function downOverviewPage() {
|
|
34
|
+
if (currentOverviewPage.value < max.value) {
|
|
35
|
+
let current = currentOverviewPage.value + overviewRowCount.value
|
|
36
|
+
if (current > max.value)
|
|
37
|
+
current = max.value
|
|
38
|
+
|
|
39
|
+
currentOverviewPage.value = current
|
|
40
|
+
}
|
|
41
|
+
}
|
package/logic/shortcuts.ts
CHANGED
|
@@ -6,8 +6,9 @@ import type { ShortcutOptions } from '@slidev/types'
|
|
|
6
6
|
import { fullscreen, isInputting, isOnFocus, magicKeys, shortcutsEnabled, showGotoDialog, showOverview, toggleOverview } from '../state'
|
|
7
7
|
import setupShortcuts from '../setup/shortcuts'
|
|
8
8
|
import { toggleDark } from './dark'
|
|
9
|
-
import { next, nextSlide, prev, prevSlide } from './nav'
|
|
9
|
+
import { go, next, nextSlide, prev, prevSlide } from './nav'
|
|
10
10
|
import { drawingEnabled } from './drawings'
|
|
11
|
+
import { currentOverviewPage, downOverviewPage, nextOverviewPage, prevOverviewPage, upOverviewPage } from './overview'
|
|
11
12
|
|
|
12
13
|
const _shortcut = and(not(isInputting), not(isOnFocus), shortcutsEnabled)
|
|
13
14
|
|
|
@@ -46,23 +47,28 @@ export function strokeShortcut(key: KeyFilter, fn: Fn) {
|
|
|
46
47
|
export function registerShortcuts() {
|
|
47
48
|
const customShortcuts = setupShortcuts()
|
|
48
49
|
|
|
49
|
-
const { escape, space, shift, left, right, d, g, o } = magicKeys
|
|
50
|
+
const { escape, space, shift, left, right, up, down, enter, d, g, o } = magicKeys
|
|
50
51
|
const shortcuts = new Map<string | Ref<Boolean>, ShortcutOptions>(
|
|
51
52
|
[
|
|
52
53
|
{ key: and(space, not(shift)), fn: next, autoRepeat: true },
|
|
53
54
|
{ key: and(space, shift), fn: prev, autoRepeat: true },
|
|
54
|
-
{ key: and(right, not(shift)), fn: next, autoRepeat: true },
|
|
55
|
-
{ key: and(left, not(shift)), fn: prev, autoRepeat: true },
|
|
55
|
+
{ key: and(right, not(shift), not(showOverview)), fn: next, autoRepeat: true },
|
|
56
|
+
{ key: and(left, not(shift), not(showOverview)), fn: prev, autoRepeat: true },
|
|
56
57
|
{ key: 'pageDown', fn: next, autoRepeat: true },
|
|
57
58
|
{ key: 'pageUp', fn: prev, autoRepeat: true },
|
|
58
|
-
{ key:
|
|
59
|
-
{ key:
|
|
59
|
+
{ key: and(up, not(showOverview)), fn: () => prevSlide(false), autoRepeat: true },
|
|
60
|
+
{ key: and(down, not(showOverview)), fn: nextSlide, autoRepeat: true },
|
|
60
61
|
{ key: and(left, shift), fn: () => prevSlide(false), autoRepeat: true },
|
|
61
62
|
{ key: and(right, shift), fn: nextSlide, autoRepeat: true },
|
|
62
63
|
{ key: and(d, not(drawingEnabled)), fn: toggleDark },
|
|
63
64
|
{ key: and(o, not(drawingEnabled)), fn: toggleOverview },
|
|
64
65
|
{ key: and(escape, not(drawingEnabled)), fn: () => showOverview.value = false },
|
|
65
66
|
{ key: and(g, not(drawingEnabled)), fn: () => showGotoDialog.value = !showGotoDialog.value },
|
|
67
|
+
{ key: and(left, showOverview), fn: prevOverviewPage },
|
|
68
|
+
{ key: and(right, showOverview), fn: nextOverviewPage },
|
|
69
|
+
{ key: and(up, showOverview), fn: upOverviewPage },
|
|
70
|
+
{ key: and(down, showOverview), fn: downOverviewPage },
|
|
71
|
+
{ key: and(enter, showOverview), fn: () => { go(currentOverviewPage.value); showOverview.value = false } },
|
|
66
72
|
...customShortcuts,
|
|
67
73
|
]
|
|
68
74
|
.map((options: ShortcutOptions) => [options.key, options]),
|
package/package.json
CHANGED
|
@@ -1,30 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slidev/client",
|
|
3
|
-
"version": "0.32.
|
|
3
|
+
"version": "0.32.4",
|
|
4
4
|
"description": "Presentation slides for developers",
|
|
5
|
-
"homepage": "https://sli.dev",
|
|
6
|
-
"bugs": "https://github.com/slidevjs/slidev/issues",
|
|
7
|
-
"license": "MIT",
|
|
8
5
|
"author": "antfu <anthonyfu117@hotmail.com>",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"funding": "https://github.com/sponsors/antfu",
|
|
8
|
+
"homepage": "https://sli.dev",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
11
|
"url": "https://github.com/slidevjs/slidev"
|
|
12
12
|
},
|
|
13
|
-
"
|
|
13
|
+
"bugs": "https://github.com/slidevjs/slidev/issues",
|
|
14
|
+
"engines": {
|
|
15
|
+
"node": ">=14.0.0"
|
|
16
|
+
},
|
|
14
17
|
"dependencies": {
|
|
15
18
|
"@antfu/utils": "^0.5.2",
|
|
16
|
-
"@slidev/parser": "0.32.
|
|
17
|
-
"@slidev/types": "0.32.
|
|
18
|
-
"@vueuse/core": "^8.
|
|
19
|
+
"@slidev/parser": "0.32.4",
|
|
20
|
+
"@slidev/types": "0.32.4",
|
|
21
|
+
"@vueuse/core": "^8.6.0",
|
|
19
22
|
"@vueuse/head": "^0.7.6",
|
|
20
23
|
"@vueuse/motion": "^2.0.0-beta.18",
|
|
21
|
-
"codemirror": "^5.65.
|
|
24
|
+
"codemirror": "^5.65.5",
|
|
22
25
|
"defu": "^6.0.0",
|
|
23
26
|
"drauu": "^0.3.0",
|
|
24
27
|
"file-saver": "^2.0.5",
|
|
25
28
|
"js-base64": "^3.7.2",
|
|
26
29
|
"js-yaml": "^4.1.0",
|
|
27
|
-
"katex": "^0.15.
|
|
30
|
+
"katex": "^0.15.6",
|
|
28
31
|
"mermaid": "^9.1.1",
|
|
29
32
|
"monaco-editor": "^0.33.0",
|
|
30
33
|
"nanoid": "^3.3.4",
|
|
@@ -32,12 +35,9 @@
|
|
|
32
35
|
"recordrtc": "^5.6.2",
|
|
33
36
|
"resolve": "^1.22.0",
|
|
34
37
|
"vite-plugin-windicss": "^1.8.4",
|
|
35
|
-
"vue": "^3.2.
|
|
38
|
+
"vue": "^3.2.36",
|
|
36
39
|
"vue-router": "^4.0.15",
|
|
37
|
-
"vue-starport": "^0.2.
|
|
40
|
+
"vue-starport": "^0.2.11",
|
|
38
41
|
"windicss": "^3.5.4"
|
|
39
|
-
},
|
|
40
|
-
"engines": {
|
|
41
|
-
"node": ">=14.0.0"
|
|
42
42
|
}
|
|
43
43
|
}
|