@slidev/client 0.34.1 → 0.34.2
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.
|
@@ -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({
|
|
@@ -31,7 +33,7 @@ const clicks = inject(injectionClicks)
|
|
|
31
33
|
const elements = inject(injectionClicksElements)
|
|
32
34
|
const disabled = inject(injectionClicksDisabled)
|
|
33
35
|
|
|
34
|
-
function
|
|
36
|
+
function makeId(length = 5) {
|
|
35
37
|
const result = []
|
|
36
38
|
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
|
|
37
39
|
const charactersLength = characters.length
|
|
@@ -52,7 +54,7 @@ onMounted(() => {
|
|
|
52
54
|
})
|
|
53
55
|
const rangeStr = computed(() => props.ranges[index.value] || '')
|
|
54
56
|
if (props.ranges.length >= 2 && !disabled?.value) {
|
|
55
|
-
const id =
|
|
57
|
+
const id = makeId()
|
|
56
58
|
const ids = range(props.ranges.length - 1).map(i => id + i)
|
|
57
59
|
if (elements?.value) {
|
|
58
60
|
elements.value.push(...ids)
|
|
@@ -77,10 +79,26 @@ onMounted(() => {
|
|
|
77
79
|
}
|
|
78
80
|
})
|
|
79
81
|
})
|
|
82
|
+
|
|
83
|
+
const { copied, copy } = useClipboard()
|
|
84
|
+
|
|
85
|
+
function copyCode() {
|
|
86
|
+
const code = el.value?.querySelector('.slidev-code')?.textContent
|
|
87
|
+
if (code)
|
|
88
|
+
copy(code)
|
|
89
|
+
}
|
|
80
90
|
</script>
|
|
81
91
|
|
|
82
92
|
<template>
|
|
83
|
-
<div ref="el">
|
|
93
|
+
<div ref="el" class="slidev-code-wrapper relative group">
|
|
84
94
|
<slot />
|
|
95
|
+
<button
|
|
96
|
+
v-if="configs.codeCopy"
|
|
97
|
+
class="slidev-code-copy absolute top-0 right-0 transition opacity-0 group-hover:opacity-20 hover:!opacity-100"
|
|
98
|
+
:title="copied ? 'Copied' : 'Copy'" @click="copyCode()"
|
|
99
|
+
>
|
|
100
|
+
<ph-check-circle v-if="copied" class="p-2 w-8 h-8" />
|
|
101
|
+
<ph-clipboard v-else class="p-2 w-8 h-8" />
|
|
102
|
+
</button>
|
|
85
103
|
</div>
|
|
86
104
|
</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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slidev/client",
|
|
3
|
-
"version": "0.34.
|
|
3
|
+
"version": "0.34.2",
|
|
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.2",
|
|
20
|
+
"@slidev/types": "0.34.2",
|
|
21
21
|
"@unocss/reset": "^0.42.0",
|
|
22
22
|
"@vueuse/core": "^8.7.5",
|
|
23
23
|
"@vueuse/head": "^0.7.6",
|
package/styles/code.css
CHANGED
|
@@ -6,13 +6,16 @@ html:not(.dark) .shiki-dark {
|
|
|
6
6
|
display: none;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
+
.slidev-code-wrapper {
|
|
10
|
+
margin: var(--slidev-code-margin) !important;
|
|
11
|
+
}
|
|
12
|
+
|
|
9
13
|
.slidev-code {
|
|
10
14
|
font-family: var(--slidev-code-font-family) !important;
|
|
11
15
|
padding: var(--slidev-code-padding) !important;
|
|
12
16
|
font-size: var(--slidev-code-font-size) !important;
|
|
13
17
|
line-height: var(--slidev-code-line-height) !important;
|
|
14
18
|
border-radius: var(--slidev-code-radius) !important;
|
|
15
|
-
margin: var(--slidev-code-margin) !important;
|
|
16
19
|
overflow: auto;
|
|
17
20
|
}
|
|
18
21
|
|
|
@@ -38,7 +41,7 @@ html:not(.dark) .shiki-dark {
|
|
|
38
41
|
.slidev-code-line-numbers .slidev-code code .line::before {
|
|
39
42
|
content: counter(step);
|
|
40
43
|
counter-increment: step;
|
|
41
|
-
@apply w-4 mr-6 inline-block text-right text-gray-400 dark:text-gray-600
|
|
44
|
+
@apply w-4 mr-6 inline-block text-right text-gray-400 dark:text-gray-600;
|
|
42
45
|
}
|
|
43
46
|
|
|
44
47
|
/* 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 {
|