@slidev/client 0.43.0 → 0.43.1
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.
|
@@ -18,6 +18,7 @@ import { useClipboard } from '@vueuse/core'
|
|
|
18
18
|
import { computed, getCurrentInstance, inject, onMounted, onUnmounted, ref, watchEffect } from 'vue'
|
|
19
19
|
import { configs } from '../env'
|
|
20
20
|
import { CLASS_VCLICK_TARGET, injectionClicks, injectionClicksDisabled, injectionClicksElements } from '../constants'
|
|
21
|
+
import { makeId } from '../logic/utils'
|
|
21
22
|
|
|
22
23
|
const props = defineProps({
|
|
23
24
|
ranges: {
|
|
@@ -45,15 +46,6 @@ const clicks = inject(injectionClicks)
|
|
|
45
46
|
const elements = inject(injectionClicksElements)
|
|
46
47
|
const disabled = inject(injectionClicksDisabled)
|
|
47
48
|
|
|
48
|
-
function makeId(length = 5) {
|
|
49
|
-
const result = []
|
|
50
|
-
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
|
|
51
|
-
const charactersLength = characters.length
|
|
52
|
-
for (let i = 0; i < length; i++)
|
|
53
|
-
result.push(characters.charAt(Math.floor(Math.random() * charactersLength)))
|
|
54
|
-
return result.join('')
|
|
55
|
-
}
|
|
56
|
-
|
|
57
49
|
const el = ref<HTMLDivElement>()
|
|
58
50
|
const vm = getCurrentInstance()
|
|
59
51
|
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Line highlighting for KaTex blocks/
|
|
3
|
+
(auto transformed, you don't need to use this component directly)
|
|
4
|
+
|
|
5
|
+
Usage:
|
|
6
|
+
$$ {1|3|all}
|
|
7
|
+
\begin{array}{c}
|
|
8
|
+
|
|
9
|
+
\nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} &
|
|
10
|
+
= \frac{4\pi}{c}\vec{\mathbf{j}} \nabla \cdot \vec{\mathbf{E}} & = 4 \pi \rho \\
|
|
11
|
+
|
|
12
|
+
\nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} & = \vec{\mathbf{0}} \\
|
|
13
|
+
|
|
14
|
+
\nabla \cdot \vec{\mathbf{B}} & = 0
|
|
15
|
+
|
|
16
|
+
\end{array}
|
|
17
|
+
$$
|
|
18
|
+
|
|
19
|
+
Learn more: https://sli.dev/guide/syntax.html#latex-line-highlighting
|
|
20
|
+
-->
|
|
21
|
+
|
|
22
|
+
<script setup lang="ts">
|
|
23
|
+
import { range, remove } from '@antfu/utils'
|
|
24
|
+
import { computed, getCurrentInstance, inject, onMounted, onUnmounted, ref, watchEffect } from 'vue'
|
|
25
|
+
import { parseRangeString } from '@slidev/parser'
|
|
26
|
+
import { CLASS_VCLICK_TARGET, injectionClicks, injectionClicksDisabled, injectionClicksElements } from '../constants'
|
|
27
|
+
import { makeId } from '../logic/utils'
|
|
28
|
+
|
|
29
|
+
const props = defineProps({
|
|
30
|
+
ranges: {
|
|
31
|
+
default: () => [],
|
|
32
|
+
},
|
|
33
|
+
startLine: {
|
|
34
|
+
type: Number,
|
|
35
|
+
default: 1,
|
|
36
|
+
},
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
const clicks = inject(injectionClicks)
|
|
40
|
+
const elements = inject(injectionClicksElements)
|
|
41
|
+
const disabled = inject(injectionClicksDisabled)
|
|
42
|
+
|
|
43
|
+
const el = ref<HTMLDivElement>()
|
|
44
|
+
const vm = getCurrentInstance()
|
|
45
|
+
|
|
46
|
+
onMounted(() => {
|
|
47
|
+
const prev = elements?.value.length
|
|
48
|
+
const index = computed(() => {
|
|
49
|
+
if (disabled?.value)
|
|
50
|
+
return props.ranges.length - 1
|
|
51
|
+
return Math.min(Math.max(0, (clicks?.value || 0) - (prev || 0)), props.ranges.length - 1)
|
|
52
|
+
})
|
|
53
|
+
const rangeStr = computed(() => props.ranges[index.value] || '')
|
|
54
|
+
if (props.ranges.length >= 2 && !disabled?.value) {
|
|
55
|
+
const id = makeId()
|
|
56
|
+
const ids = range(props.ranges.length - 1).map(i => id + i)
|
|
57
|
+
if (elements?.value) {
|
|
58
|
+
elements.value.push(...ids)
|
|
59
|
+
onUnmounted(() => ids.forEach(i => remove(elements.value, i)), vm)
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
watchEffect(() => {
|
|
64
|
+
if (!el.value)
|
|
65
|
+
return
|
|
66
|
+
const baseTargets = Array.from(el.value.querySelectorAll('.col-align-c > .vlist-t > .vlist-r > .vlist'))
|
|
67
|
+
const lines: Element[][] = []
|
|
68
|
+
baseTargets.forEach((baseTarget) => {
|
|
69
|
+
Array.from(baseTarget.children).forEach((childNode, idx) => {
|
|
70
|
+
const realNode = childNode.querySelector('.mord')
|
|
71
|
+
if (!realNode)
|
|
72
|
+
return
|
|
73
|
+
if (Array.isArray(lines[idx]))
|
|
74
|
+
lines[idx].push(realNode)
|
|
75
|
+
else
|
|
76
|
+
lines[idx] = [realNode]
|
|
77
|
+
})
|
|
78
|
+
})
|
|
79
|
+
const startLine = props.startLine
|
|
80
|
+
const highlights: number[] = parseRangeString(lines.length + startLine - 1, rangeStr.value)
|
|
81
|
+
lines.forEach((line, idx) => {
|
|
82
|
+
const highlighted = highlights.includes(idx + startLine)
|
|
83
|
+
line.forEach((node) => {
|
|
84
|
+
node.classList.toggle(CLASS_VCLICK_TARGET, true)
|
|
85
|
+
node.classList.toggle('highlighted', highlighted)
|
|
86
|
+
node.classList.toggle('dishonored', !highlighted)
|
|
87
|
+
})
|
|
88
|
+
})
|
|
89
|
+
})
|
|
90
|
+
})
|
|
91
|
+
</script>
|
|
92
|
+
|
|
93
|
+
<template>
|
|
94
|
+
<div
|
|
95
|
+
ref="el" class="slidev-katex-wrapper"
|
|
96
|
+
>
|
|
97
|
+
<slot />
|
|
98
|
+
</div>
|
|
99
|
+
</template>
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { inject } from 'vue'
|
|
3
|
+
import { injectionCurrentPage } from '../constants'
|
|
4
|
+
|
|
5
|
+
const $page = inject(injectionCurrentPage)
|
|
6
|
+
</script>
|
|
7
|
+
|
|
1
8
|
<template>
|
|
2
|
-
<span>{{ $
|
|
9
|
+
<span>{{ $page }}</span>
|
|
3
10
|
</template>
|
package/builtin/SlidesTotal.vue
CHANGED
package/logic/utils.ts
CHANGED
|
@@ -21,3 +21,12 @@ export function useTimer() {
|
|
|
21
21
|
resetTimer,
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
+
|
|
25
|
+
export function makeId(length = 5) {
|
|
26
|
+
const result = []
|
|
27
|
+
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
|
|
28
|
+
const charactersLength = characters.length
|
|
29
|
+
for (let i = 0; i < length; i++)
|
|
30
|
+
result.push(characters.charAt(Math.floor(Math.random() * charactersLength)))
|
|
31
|
+
return result.join('')
|
|
32
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slidev/client",
|
|
3
|
-
"version": "0.43.
|
|
3
|
+
"version": "0.43.1",
|
|
4
4
|
"description": "Presentation slides for developers",
|
|
5
5
|
"author": "antfu <anthonyfu117@hotmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@antfu/utils": "^0.7.6",
|
|
19
|
-
"@unocss/reset": "^0.55.
|
|
19
|
+
"@unocss/reset": "^0.55.7",
|
|
20
20
|
"@vueuse/core": "^10.4.1",
|
|
21
21
|
"@vueuse/head": "^1.3.1",
|
|
22
22
|
"@vueuse/math": "^10.4.1",
|
|
@@ -35,14 +35,14 @@
|
|
|
35
35
|
"prettier": "^3.0.3",
|
|
36
36
|
"recordrtc": "^5.6.2",
|
|
37
37
|
"resolve": "^1.22.4",
|
|
38
|
-
"unocss": "^0.55.
|
|
38
|
+
"unocss": "^0.55.7",
|
|
39
39
|
"vite-plugin-windicss": "^1.9.1",
|
|
40
40
|
"vue": "^3.3.4",
|
|
41
41
|
"vue-router": "^4.2.4",
|
|
42
42
|
"vue-starport": "^0.3.0",
|
|
43
43
|
"windicss": "^3.5.6",
|
|
44
|
-
"@slidev/parser": "0.43.
|
|
45
|
-
"@slidev/types": "0.43.
|
|
44
|
+
"@slidev/parser": "0.43.1",
|
|
45
|
+
"@slidev/types": "0.43.1"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"vite": "^4.4.9"
|