@slidev/client 0.37.0 → 0.38.0
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/Monaco.vue +15 -32
- package/composables/useNav.ts +1 -1
- package/iframes/monaco/index.ts +3 -1
- package/internals/Presenter.vue +1 -1
- package/internals/PrintSlideClick.vue +1 -1
- package/internals/SlidesOverview.vue +2 -0
- package/layouts/iframe-left.vue +17 -6
- package/layouts/iframe-right.vue +14 -3
- package/layouts/iframe.vue +0 -1
- package/modules/mermaid.ts +0 -1
- package/package.json +19 -19
- package/setup/shortcuts.ts +8 -1
package/builtin/Monaco.vue
CHANGED
|
@@ -12,7 +12,7 @@ Learn more: https://sli.dev/guide/syntax.html#monaco-editor
|
|
|
12
12
|
-->
|
|
13
13
|
|
|
14
14
|
<script setup lang="ts">
|
|
15
|
-
import { computed, onMounted, ref
|
|
15
|
+
import { computed, onMounted, ref } from 'vue'
|
|
16
16
|
import { useEventListener } from '@vueuse/core'
|
|
17
17
|
import { decode } from 'js-base64'
|
|
18
18
|
import { nanoid } from 'nanoid'
|
|
@@ -40,7 +40,6 @@ const id = nanoid()
|
|
|
40
40
|
const code = ref(decode(props.code).trimEnd())
|
|
41
41
|
const lineHeight = +(getComputedStyle(document.body).getPropertyValue('--slidev-code-line-height') || '18').replace('px', '') || 18
|
|
42
42
|
const height = computed(() => props.height === 'auto' ? `${code.value.split(/\r?\n/g).length * lineHeight + 20}px` : props.height)
|
|
43
|
-
const isReady = ref(false)
|
|
44
43
|
|
|
45
44
|
const iframe = ref<HTMLIFrameElement>()
|
|
46
45
|
|
|
@@ -79,11 +78,6 @@ onMounted(() => {
|
|
|
79
78
|
: `${import.meta.env.BASE_URL}iframes/monaco/index.html`
|
|
80
79
|
|
|
81
80
|
frame.style.backgroundColor = 'transparent'
|
|
82
|
-
|
|
83
|
-
frame.addEventListener('load', () => {
|
|
84
|
-
postCode()
|
|
85
|
-
isReady.value = true
|
|
86
|
-
}, { once: true })
|
|
87
81
|
})
|
|
88
82
|
|
|
89
83
|
function post(payload: any) {
|
|
@@ -96,38 +90,27 @@ function post(payload: any) {
|
|
|
96
90
|
)
|
|
97
91
|
}
|
|
98
92
|
|
|
99
|
-
function postCode() {
|
|
100
|
-
post({
|
|
101
|
-
code: code.value,
|
|
102
|
-
lang: props.lang,
|
|
103
|
-
})
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
function postStyle() {
|
|
107
|
-
if (!iframe.value)
|
|
108
|
-
return
|
|
109
|
-
post({
|
|
110
|
-
id,
|
|
111
|
-
readonly: props.readonly,
|
|
112
|
-
lineNumbers: props.lineNumbers,
|
|
113
|
-
dark: isDark.value,
|
|
114
|
-
style: Object.entries(getStyleObject(iframe.value)).map(([k, v]) => `${k}: ${v};`).join(''),
|
|
115
|
-
})
|
|
116
|
-
}
|
|
117
|
-
|
|
118
93
|
useEventListener(window, 'message', ({ data: payload }) => {
|
|
94
|
+
if (payload.type === 'slidev-monaco-loaded') {
|
|
95
|
+
if (iframe.value) {
|
|
96
|
+
post({
|
|
97
|
+
code: code.value,
|
|
98
|
+
lang: props.lang,
|
|
99
|
+
id,
|
|
100
|
+
readonly: props.readonly,
|
|
101
|
+
lineNumbers: props.lineNumbers,
|
|
102
|
+
dark: isDark.value,
|
|
103
|
+
style: Object.entries(getStyleObject(iframe.value)).map(([k, v]) => `${k}: ${v};`).join(''),
|
|
104
|
+
})
|
|
105
|
+
}
|
|
106
|
+
return
|
|
107
|
+
}
|
|
119
108
|
if (payload.type !== 'slidev-monaco' || payload.id !== id)
|
|
120
109
|
return
|
|
121
110
|
if (!payload?.data?.code || code.value === payload.data.code)
|
|
122
111
|
return
|
|
123
112
|
code.value = payload.data.code
|
|
124
113
|
})
|
|
125
|
-
|
|
126
|
-
watchEffect(() => {
|
|
127
|
-
if (!isReady.value)
|
|
128
|
-
return
|
|
129
|
-
postStyle()
|
|
130
|
-
})
|
|
131
114
|
</script>
|
|
132
115
|
|
|
133
116
|
<template>
|
package/composables/useNav.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type { TocItem } from '../logic/nav'
|
|
|
5
5
|
import { addToTree, filterTree, getPath, getTreeWithActiveStatuses } from '../logic/nav'
|
|
6
6
|
import { rawRoutes } from '../routes'
|
|
7
7
|
|
|
8
|
-
export function useNav(route: ComputedRef<RouteLocationNormalizedLoaded>) {
|
|
8
|
+
export function useNav(route: ComputedRef<RouteRecordRaw | RouteLocationNormalizedLoaded>) {
|
|
9
9
|
const path = computed(() => route.value.path)
|
|
10
10
|
const total = computed(() => rawRoutes.length - 1)
|
|
11
11
|
|
package/iframes/monaco/index.ts
CHANGED
|
@@ -18,7 +18,7 @@ const props = {
|
|
|
18
18
|
|
|
19
19
|
const styleObject = document.createElement('style')
|
|
20
20
|
let editor: monaco.editor.IStandaloneCodeEditor
|
|
21
|
-
let update: () => void = () => {}
|
|
21
|
+
let update: () => void = () => { }
|
|
22
22
|
|
|
23
23
|
document.body.appendChild(styleObject)
|
|
24
24
|
|
|
@@ -146,4 +146,6 @@ window.addEventListener('message', (payload) => {
|
|
|
146
146
|
}
|
|
147
147
|
})
|
|
148
148
|
|
|
149
|
+
window.parent.postMessage({ type: 'slidev-monaco-loaded' }, location.origin)
|
|
150
|
+
|
|
149
151
|
start()
|
package/internals/Presenter.vue
CHANGED
|
@@ -111,7 +111,7 @@ onMounted(() => {
|
|
|
111
111
|
current
|
|
112
112
|
</div>
|
|
113
113
|
</div>
|
|
114
|
-
<div class="relative grid-section next flex flex-col p-2 lg:p-4">
|
|
114
|
+
<div class="relative grid-section next flex flex-col p-2 lg:p-4" :style="themeVars">
|
|
115
115
|
<SlideContainer
|
|
116
116
|
v-if="nextSlide"
|
|
117
117
|
key="next"
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { useVModel } from '@vueuse/core'
|
|
3
3
|
import { computed, watchEffect } from 'vue'
|
|
4
|
+
import { themeVars } from '../env'
|
|
4
5
|
import { breakpoints, windowSize } from '../state'
|
|
5
6
|
import { currentPage, go as goSlide, rawRoutes } from '../logic/nav'
|
|
6
7
|
import { currentOverviewPage, overviewRowCount } from '../logic/overview'
|
|
@@ -72,6 +73,7 @@ watchEffect(() => {
|
|
|
72
73
|
<div
|
|
73
74
|
class="inline-block border border-gray-400 rounded border-opacity-50 overflow-hidden bg-main hover:border-$slidev-theme-primary"
|
|
74
75
|
:class="{ 'border-$slidev-theme-primary': focus(idx + 1) }"
|
|
76
|
+
:style="themeVars"
|
|
75
77
|
@click="go(+route.path)"
|
|
76
78
|
>
|
|
77
79
|
<SlideContainer
|
package/layouts/iframe-left.vue
CHANGED
|
@@ -1,14 +1,25 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
|
|
2
|
+
import { computed } from '@vue/reactivity'
|
|
3
|
+
|
|
4
|
+
const props = defineProps<{
|
|
5
|
+
url: string
|
|
6
|
+
scale?: number
|
|
7
|
+
}>()
|
|
8
|
+
|
|
9
|
+
const scaleInvertPercent = computed(() => `${(1 / (props.scale || 1)) * 100}%`)
|
|
3
10
|
</script>
|
|
4
11
|
|
|
5
12
|
<template>
|
|
6
13
|
<div class="grid grid-cols-2 w-full h-full">
|
|
7
|
-
<div
|
|
8
|
-
<iframe
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
14
|
+
<div relative :style="{ width: scaleInvertPercent, height: scaleInvertPercent }">
|
|
15
|
+
<iframe
|
|
16
|
+
id="frame" class="w-full h-full"
|
|
17
|
+
:src="url"
|
|
18
|
+
:style="scale ? { transform: `scale(${scale})`, transformOrigin: 'top left' } : {}"
|
|
19
|
+
/>
|
|
20
|
+
<div class="slidev-layout default" :class="props.class">
|
|
21
|
+
<slot />
|
|
22
|
+
</div>
|
|
12
23
|
</div>
|
|
13
24
|
</div>
|
|
14
25
|
</template>
|
package/layouts/iframe-right.vue
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
|
|
2
|
+
import { computed } from '@vue/reactivity'
|
|
3
|
+
|
|
4
|
+
const props = defineProps<{
|
|
5
|
+
url: string
|
|
6
|
+
scale?: number
|
|
7
|
+
}>()
|
|
8
|
+
|
|
9
|
+
const scaleInvertPercent = computed(() => `${(1 / (props.scale || 1)) * 100}%`)
|
|
3
10
|
</script>
|
|
4
11
|
|
|
5
12
|
<template>
|
|
@@ -7,8 +14,12 @@ const props = defineProps<{ class?: string; url: string }>()
|
|
|
7
14
|
<div class="slidev-layout default" :class="props.class">
|
|
8
15
|
<slot />
|
|
9
16
|
</div>
|
|
10
|
-
<div
|
|
11
|
-
<iframe
|
|
17
|
+
<div relative :style="{ width: scaleInvertPercent, height: scaleInvertPercent }">
|
|
18
|
+
<iframe
|
|
19
|
+
id="frame" class="w-full h-full"
|
|
20
|
+
:src="url"
|
|
21
|
+
:style="scale ? { transform: `scale(${scale})`, transformOrigin: 'top left' } : {}"
|
|
22
|
+
/>
|
|
12
23
|
</div>
|
|
13
24
|
</div>
|
|
14
25
|
</template>
|
package/layouts/iframe.vue
CHANGED
package/modules/mermaid.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slidev/client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.38.0",
|
|
4
4
|
"description": "Presentation slides for developers",
|
|
5
5
|
"author": "antfu <anthonyfu117@hotmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -15,35 +15,35 @@
|
|
|
15
15
|
"node": ">=14.0.0"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@antfu/utils": "^0.
|
|
19
|
-
"@
|
|
20
|
-
"@
|
|
21
|
-
"@
|
|
22
|
-
"@vueuse/
|
|
23
|
-
"@vueuse/
|
|
24
|
-
"@vueuse/math": "^9.5.0",
|
|
25
|
-
"@vueuse/motion": "^2.0.0-beta.24",
|
|
18
|
+
"@antfu/utils": "^0.7.2",
|
|
19
|
+
"@unocss/reset": "^0.47.6",
|
|
20
|
+
"@vueuse/core": "^9.6.0",
|
|
21
|
+
"@vueuse/head": "^1.0.22",
|
|
22
|
+
"@vueuse/math": "^9.6.0",
|
|
23
|
+
"@vueuse/motion": "^2.0.0-beta.26",
|
|
26
24
|
"codemirror": "^5.65.5",
|
|
27
|
-
"defu": "^6.1.
|
|
25
|
+
"defu": "^6.1.1",
|
|
28
26
|
"drauu": "^0.3.2",
|
|
29
27
|
"file-saver": "^2.0.5",
|
|
30
|
-
"js-base64": "^3.7.
|
|
28
|
+
"js-base64": "^3.7.3",
|
|
31
29
|
"js-yaml": "^4.1.0",
|
|
32
|
-
"katex": "^0.16.
|
|
33
|
-
"mermaid": "^9.2.
|
|
30
|
+
"katex": "^0.16.4",
|
|
31
|
+
"mermaid": "^9.2.2",
|
|
34
32
|
"monaco-editor": "^0.33.0",
|
|
35
33
|
"nanoid": "^4.0.0",
|
|
36
|
-
"prettier": "^2.
|
|
34
|
+
"prettier": "^2.8.1",
|
|
37
35
|
"recordrtc": "^5.6.2",
|
|
38
36
|
"resolve": "^1.22.1",
|
|
39
|
-
"unocss": "^0.
|
|
40
|
-
"vite-plugin-windicss": "^1.8.
|
|
41
|
-
"vue": "^3.2.
|
|
37
|
+
"unocss": "^0.47.6",
|
|
38
|
+
"vite-plugin-windicss": "^1.8.9",
|
|
39
|
+
"vue": "^3.2.45",
|
|
42
40
|
"vue-router": "^4.1.6",
|
|
43
41
|
"vue-starport": "^0.3.0",
|
|
44
|
-
"windicss": "^3.5.6"
|
|
42
|
+
"windicss": "^3.5.6",
|
|
43
|
+
"@slidev/parser": "0.38.0",
|
|
44
|
+
"@slidev/types": "0.38.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"vite": "^
|
|
47
|
+
"vite": "^4.0.1"
|
|
48
48
|
}
|
|
49
49
|
}
|
package/setup/shortcuts.ts
CHANGED
|
@@ -48,7 +48,14 @@ export default function setupShortcuts() {
|
|
|
48
48
|
{ name: 'prev_overview', key: and(left, showOverview), fn: prevOverviewPage },
|
|
49
49
|
{ name: 'up_overview', key: and(up, showOverview), fn: upOverviewPage },
|
|
50
50
|
{ name: 'down_overview', key: and(down, showOverview), fn: downOverviewPage },
|
|
51
|
-
{
|
|
51
|
+
{
|
|
52
|
+
name: 'goto_from_overview',
|
|
53
|
+
key: and(enter, showOverview),
|
|
54
|
+
fn: () => {
|
|
55
|
+
go(currentOverviewPage.value)
|
|
56
|
+
showOverview.value = false
|
|
57
|
+
},
|
|
58
|
+
},
|
|
52
59
|
]
|
|
53
60
|
|
|
54
61
|
const baseShortcutNames = new Set(injection_return.map(s => s.name))
|