@slidev/client 0.34.0 → 0.34.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/{CodeHighlightController.vue → CodeBlockWrapper.vue} +36 -3
- package/internals/NavControls.vue +2 -2
- package/internals/PresenterMouse.vue +1 -1
- package/logic/nav.ts +8 -0
- package/package.json +3 -3
- package/setup/shortcuts.ts +3 -1
- package/styles/code.css +12 -2
- package/styles/index.css +1 -6
|
@@ -14,7 +14,9 @@ Learn more: https://sli.dev/guide/syntax.html#line-highlighting
|
|
|
14
14
|
<script setup lang="ts">
|
|
15
15
|
import { range, remove } from '@antfu/utils'
|
|
16
16
|
import { parseRangeString } from '@slidev/parser/core'
|
|
17
|
+
import { useClipboard } from '@vueuse/core'
|
|
17
18
|
import { computed, getCurrentInstance, inject, onMounted, onUnmounted, ref, watchEffect } from 'vue'
|
|
19
|
+
import { configs } from '../env'
|
|
18
20
|
import { CLASS_VCLICK_TARGET, injectionClicks, injectionClicksDisabled, injectionClicksElements } from '../constants'
|
|
19
21
|
|
|
20
22
|
const props = defineProps({
|
|
@@ -25,13 +27,17 @@ const props = defineProps({
|
|
|
25
27
|
type: Number,
|
|
26
28
|
default: undefined,
|
|
27
29
|
},
|
|
30
|
+
maxHeight: {
|
|
31
|
+
type: String,
|
|
32
|
+
default: undefined,
|
|
33
|
+
},
|
|
28
34
|
})
|
|
29
35
|
|
|
30
36
|
const clicks = inject(injectionClicks)
|
|
31
37
|
const elements = inject(injectionClicksElements)
|
|
32
38
|
const disabled = inject(injectionClicksDisabled)
|
|
33
39
|
|
|
34
|
-
function
|
|
40
|
+
function makeId(length = 5) {
|
|
35
41
|
const result = []
|
|
36
42
|
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
|
|
37
43
|
const charactersLength = characters.length
|
|
@@ -52,7 +58,7 @@ onMounted(() => {
|
|
|
52
58
|
})
|
|
53
59
|
const rangeStr = computed(() => props.ranges[index.value] || '')
|
|
54
60
|
if (props.ranges.length >= 2 && !disabled?.value) {
|
|
55
|
-
const id =
|
|
61
|
+
const id = makeId()
|
|
56
62
|
const ids = range(props.ranges.length - 1).map(i => id + i)
|
|
57
63
|
if (elements?.value) {
|
|
58
64
|
elements.value.push(...ids)
|
|
@@ -74,13 +80,40 @@ onMounted(() => {
|
|
|
74
80
|
line.classList.toggle('highlighted', highlighted)
|
|
75
81
|
line.classList.toggle('dishonored', !highlighted)
|
|
76
82
|
})
|
|
83
|
+
if (props.maxHeight) {
|
|
84
|
+
const firstHighlightedEl = target.querySelector('.line.highlighted')
|
|
85
|
+
if (firstHighlightedEl)
|
|
86
|
+
firstHighlightedEl.scrollIntoView({ behavior: 'smooth', block: 'center' })
|
|
87
|
+
}
|
|
77
88
|
}
|
|
78
89
|
})
|
|
79
90
|
})
|
|
91
|
+
|
|
92
|
+
const { copied, copy } = useClipboard()
|
|
93
|
+
|
|
94
|
+
function copyCode() {
|
|
95
|
+
const code = el.value?.querySelector('.slidev-code')?.textContent
|
|
96
|
+
if (code)
|
|
97
|
+
copy(code)
|
|
98
|
+
}
|
|
80
99
|
</script>
|
|
81
100
|
|
|
82
101
|
<template>
|
|
83
|
-
<div
|
|
102
|
+
<div
|
|
103
|
+
ref="el" class="slidev-code-wrapper relative group"
|
|
104
|
+
:style="{
|
|
105
|
+
'max-height': props.maxHeight,
|
|
106
|
+
'overflow-y': props.maxHeight ? 'scroll' : undefined,
|
|
107
|
+
}"
|
|
108
|
+
>
|
|
84
109
|
<slot />
|
|
110
|
+
<button
|
|
111
|
+
v-if="configs.codeCopy"
|
|
112
|
+
class="slidev-code-copy absolute top-0 right-0 transition opacity-0 group-hover:opacity-20 hover:!opacity-100"
|
|
113
|
+
:title="copied ? 'Copied' : 'Copy'" @click="copyCode()"
|
|
114
|
+
>
|
|
115
|
+
<ph-check-circle v-if="copied" class="p-2 w-8 h-8" />
|
|
116
|
+
<ph-clipboard v-else class="p-2 w-8 h-8" />
|
|
117
|
+
</button>
|
|
85
118
|
</div>
|
|
86
119
|
</template>
|
|
@@ -92,8 +92,8 @@ if (__SLIDEV_FEATURE_DRAWINGS__)
|
|
|
92
92
|
title="Show presenter cursor"
|
|
93
93
|
@click="showPresenterCursor = !showPresenterCursor"
|
|
94
94
|
>
|
|
95
|
-
<ph
|
|
96
|
-
<ph
|
|
95
|
+
<ph-cursor-fill v-if="showPresenterCursor" />
|
|
96
|
+
<ph-cursor-duotone v-else class="opacity-50" />
|
|
97
97
|
</button>
|
|
98
98
|
</template>
|
|
99
99
|
|
|
@@ -7,7 +7,7 @@ import { sharedState } from '../state/shared'
|
|
|
7
7
|
v-if="sharedState.cursor"
|
|
8
8
|
class="absolute top-0 left-0 right-0 bottom-0 pointer-events-none text-xl"
|
|
9
9
|
>
|
|
10
|
-
<ph
|
|
10
|
+
<ph-cursor-fill
|
|
11
11
|
class="absolute"
|
|
12
12
|
:style="{ left: `${sharedState.cursor.x}%`, top: `${sharedState.cursor.y}%` }"
|
|
13
13
|
/>
|
package/logic/nav.ts
CHANGED
|
@@ -115,6 +115,14 @@ export async function prevSlide(lastClicks = true) {
|
|
|
115
115
|
router.replace({ query: { ...route.value.query, clicks: clicksTotal.value } })
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
+
export function goFirst() {
|
|
119
|
+
return go(1)
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export function goLast() {
|
|
123
|
+
return go(total.value)
|
|
124
|
+
}
|
|
125
|
+
|
|
118
126
|
export function go(page: number | string, clicks?: number) {
|
|
119
127
|
return router.push({ path: getPath(page), query: { ...route.value.query, clicks } })
|
|
120
128
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slidev/client",
|
|
3
|
-
"version": "0.34.
|
|
3
|
+
"version": "0.34.3",
|
|
4
4
|
"description": "Presentation slides for developers",
|
|
5
5
|
"author": "antfu <anthonyfu117@hotmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@antfu/utils": "^0.5.2",
|
|
19
|
-
"@slidev/parser": "0.34.
|
|
20
|
-
"@slidev/types": "0.34.
|
|
19
|
+
"@slidev/parser": "0.34.3",
|
|
20
|
+
"@slidev/types": "0.34.3",
|
|
21
21
|
"@unocss/reset": "^0.42.0",
|
|
22
22
|
"@vueuse/core": "^8.7.5",
|
|
23
23
|
"@vueuse/head": "^0.7.6",
|
package/setup/shortcuts.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* __imports__ */
|
|
2
2
|
|
|
3
3
|
import type { NavOperations, ShortcutOptions } from '@slidev/types'
|
|
4
|
-
import { downloadPDF, go, next, nextSlide, prev, prevSlide } from '../logic/nav'
|
|
4
|
+
import { downloadPDF, go, goFirst, goLast, next, nextSlide, prev, prevSlide } from '../logic/nav'
|
|
5
5
|
import { toggleDark } from '../logic/dark'
|
|
6
6
|
import { showGotoDialog, showOverview, toggleOverview } from '../state'
|
|
7
7
|
import { drawingEnabled } from '../logic/drawings'
|
|
@@ -15,6 +15,8 @@ export default function setupShortcuts() {
|
|
|
15
15
|
nextSlide,
|
|
16
16
|
prevSlide,
|
|
17
17
|
go,
|
|
18
|
+
goFirst,
|
|
19
|
+
goLast,
|
|
18
20
|
downloadPDF,
|
|
19
21
|
toggleDark,
|
|
20
22
|
toggleOverview,
|
package/styles/code.css
CHANGED
|
@@ -6,13 +6,23 @@ html:not(.dark) .shiki-dark {
|
|
|
6
6
|
display: none;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
+
::-webkit-scrollbar {
|
|
10
|
+
width: 0px;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.slidev-code-wrapper {
|
|
14
|
+
margin: var(--slidev-code-margin) !important;
|
|
15
|
+
&:-webkit-scrollbar {
|
|
16
|
+
width: 0px;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
9
20
|
.slidev-code {
|
|
10
21
|
font-family: var(--slidev-code-font-family) !important;
|
|
11
22
|
padding: var(--slidev-code-padding) !important;
|
|
12
23
|
font-size: var(--slidev-code-font-size) !important;
|
|
13
24
|
line-height: var(--slidev-code-line-height) !important;
|
|
14
25
|
border-radius: var(--slidev-code-radius) !important;
|
|
15
|
-
margin: var(--slidev-code-margin) !important;
|
|
16
26
|
overflow: auto;
|
|
17
27
|
}
|
|
18
28
|
|
|
@@ -38,7 +48,7 @@ html:not(.dark) .shiki-dark {
|
|
|
38
48
|
.slidev-code-line-numbers .slidev-code code .line::before {
|
|
39
49
|
content: counter(step);
|
|
40
50
|
counter-increment: step;
|
|
41
|
-
@apply w-4 mr-6 inline-block text-right text-gray-400 dark:text-gray-600
|
|
51
|
+
@apply w-4 mr-6 inline-block text-right text-gray-400 dark:text-gray-600;
|
|
42
52
|
}
|
|
43
53
|
|
|
44
54
|
/* revert windicss preflight for katex */
|
package/styles/index.css
CHANGED
|
@@ -19,12 +19,7 @@ html {
|
|
|
19
19
|
@apply inline-block cursor-pointer select-none !outline-none;
|
|
20
20
|
@apply opacity-75 transition duration-200 ease-in-out align-middle rounded p-1;
|
|
21
21
|
@apply hover:(opacity-100 bg-gray-400 bg-opacity-10);
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
@screen md {
|
|
25
|
-
.icon-btn {
|
|
26
|
-
@apply p-2;
|
|
27
|
-
}
|
|
22
|
+
@apply md:p-2;
|
|
28
23
|
}
|
|
29
24
|
|
|
30
25
|
.icon-btn.shallow {
|