vuepress-plugin-md-power 1.0.0-rc.125 → 1.0.0-rc.127
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/lib/client/components/ArtPlayer.vue +40 -0
- package/lib/client/components/Tabs.vue +2 -2
- package/lib/client/components/VPDemoBasic.vue +39 -0
- package/lib/client/components/VPDemoNormal.vue +193 -0
- package/lib/client/styles/demo.css +157 -0
- package/lib/client/utils/shared.d.ts +4 -0
- package/lib/client/utils/shared.js +36 -0
- package/lib/node/index.d.ts +31 -2
- package/lib/node/index.js +717 -59
- package/lib/shared/index.d.ts +31 -1
- package/package.json +16 -9
|
@@ -157,4 +157,44 @@ onUnmounted(() => {
|
|
|
157
157
|
transition: box-shadow var(--vp-t-color);
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
|
+
|
|
161
|
+
.vp-artplayer .art-video-player .art-subtitle {
|
|
162
|
+
z-index: 12;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.vp-artplayer .art-video-player .art-danmuku {
|
|
166
|
+
z-index: 13;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.vp-artplayer .art-video-player .art-layers {
|
|
170
|
+
z-index: 14;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.vp-artplayer .art-video-player .art-mask {
|
|
174
|
+
z-index: 15;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.vp-artplayer .art-video-player .art-bottom {
|
|
178
|
+
z-index: 16;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.vp-artplayer .art-video-player .art-loading {
|
|
182
|
+
z-index: 17;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
.vp-artplayer .art-video-player .art-notice {
|
|
186
|
+
z-index: 18;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.vp-artplayer .art-video-player .art-settings {
|
|
190
|
+
z-index: 19;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
.vp-artplayer .art-video-player .art-info {
|
|
194
|
+
z-index: 20;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
.vp-artplayer .art-video-player .art-contextmenu {
|
|
198
|
+
z-index: 21;
|
|
199
|
+
}
|
|
160
200
|
</style>
|
|
@@ -202,11 +202,11 @@ function onTabNavClick(index: number): void {
|
|
|
202
202
|
padding: 16px;
|
|
203
203
|
}
|
|
204
204
|
|
|
205
|
-
.vp-doc .vp-tab :nth-child(2) {
|
|
205
|
+
.vp-doc .vp-tab > :nth-child(2) {
|
|
206
206
|
margin-top: 0;
|
|
207
207
|
}
|
|
208
208
|
|
|
209
|
-
.vp-doc .vp-tab :last-child {
|
|
209
|
+
.vp-doc .vp-tab > :last-child {
|
|
210
210
|
margin-bottom: 0;
|
|
211
211
|
}
|
|
212
212
|
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { ref } from 'vue'
|
|
3
|
+
|
|
4
|
+
import '../styles/demo.css'
|
|
5
|
+
|
|
6
|
+
const props = defineProps<{
|
|
7
|
+
type?: 'vue' | 'markdown'
|
|
8
|
+
title?: string
|
|
9
|
+
desc?: string
|
|
10
|
+
expanded?: boolean
|
|
11
|
+
}>()
|
|
12
|
+
|
|
13
|
+
const showCode = ref(props.expanded ?? true)
|
|
14
|
+
function toggleCode() {
|
|
15
|
+
showCode.value = !showCode.value
|
|
16
|
+
}
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<template>
|
|
20
|
+
<div class="vp-demo-wrapper">
|
|
21
|
+
<div class="demo-draw">
|
|
22
|
+
<slot />
|
|
23
|
+
</div>
|
|
24
|
+
<div v-if="title || desc" class="demo-info">
|
|
25
|
+
<p v-if="title" class="title">
|
|
26
|
+
{{ title }}
|
|
27
|
+
</p>
|
|
28
|
+
<p v-if="desc" class="desc">
|
|
29
|
+
{{ desc }}
|
|
30
|
+
</p>
|
|
31
|
+
</div>
|
|
32
|
+
<div class="demo-ctrl">
|
|
33
|
+
<span class="vpi-demo-code" @click="toggleCode" />
|
|
34
|
+
</div>
|
|
35
|
+
<div v-show="showCode" class="demo-code">
|
|
36
|
+
<slot name="code" />
|
|
37
|
+
</div>
|
|
38
|
+
</div>
|
|
39
|
+
</template>
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { onClickOutside } from '@vueuse/core'
|
|
3
|
+
import { computed, onMounted, ref, useId, useTemplateRef, watch } from 'vue'
|
|
4
|
+
import { loadScript, loadStyle } from '../utils/shared.js'
|
|
5
|
+
import Loading from './icons/Loading.vue'
|
|
6
|
+
|
|
7
|
+
import '../styles/demo.css'
|
|
8
|
+
|
|
9
|
+
const props = defineProps<{
|
|
10
|
+
title?: string
|
|
11
|
+
desc?: string
|
|
12
|
+
expanded?: boolean
|
|
13
|
+
config?: {
|
|
14
|
+
html: string
|
|
15
|
+
css: string
|
|
16
|
+
script: string
|
|
17
|
+
jsLib: string[]
|
|
18
|
+
cssLib: string[]
|
|
19
|
+
}
|
|
20
|
+
}>()
|
|
21
|
+
|
|
22
|
+
const draw = useTemplateRef<HTMLDivElement>('draw')
|
|
23
|
+
const id = useId()
|
|
24
|
+
const loaded = ref(true)
|
|
25
|
+
|
|
26
|
+
const resourcesEl = useTemplateRef<HTMLDivElement>('resourcesEl')
|
|
27
|
+
const resources = computed<{
|
|
28
|
+
name: string
|
|
29
|
+
items: { name: string, url: string }[]
|
|
30
|
+
}[]>(() => {
|
|
31
|
+
if (!props.config)
|
|
32
|
+
return []
|
|
33
|
+
return [
|
|
34
|
+
{ name: 'JavaScript', items: props.config.jsLib.map(url => ({ name: normalizeName(url), url })) },
|
|
35
|
+
{ name: 'CSS', items: props.config.cssLib.map(url => ({ name: normalizeName(url), url })) },
|
|
36
|
+
].filter(i => i.items.length)
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
function normalizeName(url: string) {
|
|
40
|
+
return url.slice(url.lastIndexOf('/') + 1)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const showResources = ref(false)
|
|
44
|
+
|
|
45
|
+
function toggleResources() {
|
|
46
|
+
showResources.value = !showResources.value
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
onClickOutside(resourcesEl, () => {
|
|
50
|
+
showResources.value = false
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
onMounted(() => {
|
|
54
|
+
if (!draw.value)
|
|
55
|
+
return
|
|
56
|
+
const root = draw.value.attachShadow({ mode: 'open' })
|
|
57
|
+
|
|
58
|
+
watch(() => props.config, async () => {
|
|
59
|
+
root.innerHTML = props.config?.html ?? ''
|
|
60
|
+
|
|
61
|
+
props.config?.cssLib?.forEach(url => loadStyle(url, root))
|
|
62
|
+
if (props.config?.css) {
|
|
63
|
+
const style = document.createElement('style')
|
|
64
|
+
style.innerHTML = props.config?.css ?? ''
|
|
65
|
+
root.appendChild(style)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (props.config?.jsLib?.length) {
|
|
69
|
+
loaded.value = false
|
|
70
|
+
await Promise.all(props.config.jsLib.map(url => loadScript(url)))
|
|
71
|
+
.catch(e => console.warn(e))
|
|
72
|
+
loaded.value = true
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (props.config?.script) {
|
|
76
|
+
const script = document.createElement('script')
|
|
77
|
+
script.type = 'text/javascript'
|
|
78
|
+
script.innerHTML = `;(function(document){\n${props.config.script}\n})(document.querySelector('#VPDemoNormalDraw${id}').shadowRoot);`
|
|
79
|
+
root.appendChild(script)
|
|
80
|
+
}
|
|
81
|
+
}, { immediate: true })
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
const fence = useTemplateRef<HTMLDivElement>('fence')
|
|
85
|
+
const data = ref<{
|
|
86
|
+
js: string
|
|
87
|
+
css: string
|
|
88
|
+
html: string
|
|
89
|
+
jsType: string
|
|
90
|
+
cssType: string
|
|
91
|
+
}>({ js: '', css: '', html: '', jsType: '', cssType: '' })
|
|
92
|
+
|
|
93
|
+
onMounted(() => {
|
|
94
|
+
if (!fence.value)
|
|
95
|
+
return
|
|
96
|
+
|
|
97
|
+
data.value.html = props.config?.html ?? ''
|
|
98
|
+
const els = Array.from(fence.value.querySelectorAll('div[class*="language-"]'))
|
|
99
|
+
for (const el of els) {
|
|
100
|
+
const lang = el.className.match(/language-(\w+)/)?.[1] ?? ''
|
|
101
|
+
const content = el.querySelector('pre')?.textContent ?? ''
|
|
102
|
+
if (lang === 'js' || lang === 'javascript') {
|
|
103
|
+
data.value.js = content
|
|
104
|
+
data.value.jsType = 'js'
|
|
105
|
+
}
|
|
106
|
+
if (lang === 'ts' || lang === 'typescript') {
|
|
107
|
+
data.value.js = content
|
|
108
|
+
data.value.jsType = 'ts'
|
|
109
|
+
}
|
|
110
|
+
if (lang === 'css' || lang === 'scss' || lang === 'less' || lang === 'stylus' || lang === 'styl') {
|
|
111
|
+
data.value.css = content
|
|
112
|
+
data.value.cssType = lang === 'styl' ? 'stylus' : lang
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
const showCode = ref(props.expanded ?? false)
|
|
118
|
+
function toggleCode() {
|
|
119
|
+
showCode.value = !showCode.value
|
|
120
|
+
}
|
|
121
|
+
</script>
|
|
122
|
+
|
|
123
|
+
<template>
|
|
124
|
+
<div class="vp-demo-wrapper normal">
|
|
125
|
+
<div class="demo-draw">
|
|
126
|
+
<Loading v-if="!loaded" />
|
|
127
|
+
<div :id="`VPDemoNormalDraw${id}`" ref="draw" />
|
|
128
|
+
</div>
|
|
129
|
+
<div v-if="title || desc" class="demo-info">
|
|
130
|
+
<p v-if="title" class="title">
|
|
131
|
+
{{ title }}
|
|
132
|
+
</p>
|
|
133
|
+
<p v-if="desc" class="desc">
|
|
134
|
+
{{ desc }}
|
|
135
|
+
</p>
|
|
136
|
+
</div>
|
|
137
|
+
<div class="demo-ctrl">
|
|
138
|
+
<div class="extra">
|
|
139
|
+
<form action="https://codepen.io/pen/define" method="POST" target="_blank" enctype="application/x-www-form-urlencoded;charset=utf-8">
|
|
140
|
+
<input
|
|
141
|
+
type="hidden" name="data" :value="JSON.stringify({
|
|
142
|
+
title: title || 'Demo',
|
|
143
|
+
description: desc || '',
|
|
144
|
+
html: data.html,
|
|
145
|
+
css: data.css,
|
|
146
|
+
js: data.js,
|
|
147
|
+
js_pre_processor: data.jsType === 'ts' ? 'typescript' : 'none',
|
|
148
|
+
css_pre_processor: data.cssType,
|
|
149
|
+
css_external: config?.cssLib?.join(';'),
|
|
150
|
+
js_external: config?.jsLib?.join(';'),
|
|
151
|
+
})"
|
|
152
|
+
>
|
|
153
|
+
<button type="submit" title="CodePen" aria-label="CodePen">
|
|
154
|
+
<span class="vpi-demo-codepen" />
|
|
155
|
+
</button>
|
|
156
|
+
</form>
|
|
157
|
+
<form action="https://jsfiddle.net/api/post/library/pure/" method="POST" target="_blank" enctype="application/x-www-form-urlencoded;charset=UTF-8" accept-charset="UTF-8">
|
|
158
|
+
<button type="submit" title="jsFiddle" aria-label="jsFiddle">
|
|
159
|
+
<span class="vpi-demo-jsfiddle bg" />
|
|
160
|
+
</button>
|
|
161
|
+
<input type="hidden" name="wrap" value="b">
|
|
162
|
+
<input type="hidden" name="html" :value="data.html">
|
|
163
|
+
<input type="hidden" name="js" :value="data.js">
|
|
164
|
+
<input type="hidden" name="css" :value="data.cssType === 'scss' || data.cssType === 'css' ? data.css : config?.css || ''">
|
|
165
|
+
<input type="hidden" name="panel_css" :value="data.cssType === 'scss' ? 1 : 0">
|
|
166
|
+
<input type="hidden" name="panel_js" :value="data.jsType === 'ts' ? 4 : 0">
|
|
167
|
+
<input type="hidden" name="title" :value="title || 'Demo'">
|
|
168
|
+
<input type="hidden" name="description" :value="desc || ''">
|
|
169
|
+
<input type="hidden" name="resources" :value="[...(config?.jsLib || []), ...(config?.cssLib || [])].join(',')">
|
|
170
|
+
</form>
|
|
171
|
+
</div>
|
|
172
|
+
<div v-if="resources.length" class="demo-resources">
|
|
173
|
+
<span ref="resourcesEl" class="vpi-demo-resources" title="Resources" aria-label="Resources" @click="toggleResources" />
|
|
174
|
+
<Transition name="fade">
|
|
175
|
+
<div v-show="showResources" class="demo-resources-container">
|
|
176
|
+
<div v-for="{ name, items } in resources" :key="name" class="demo-resources-list">
|
|
177
|
+
<p>{{ name }}</p>
|
|
178
|
+
<ul v-for="item in items" :key="item.url">
|
|
179
|
+
<li>
|
|
180
|
+
<a :href="item.url" target="_blank" rel="noopener noreferrer" class="no-icon" aria-label="{{ item.name }}">{{ item.name }}</a>
|
|
181
|
+
</li>
|
|
182
|
+
</ul>
|
|
183
|
+
</div>
|
|
184
|
+
</div>
|
|
185
|
+
</Transition>
|
|
186
|
+
</div>
|
|
187
|
+
<span class="vpi-demo-code" @click="toggleCode" />
|
|
188
|
+
</div>
|
|
189
|
+
<div v-show="showCode" ref="fence" class="demo-code">
|
|
190
|
+
<slot />
|
|
191
|
+
</div>
|
|
192
|
+
</div>
|
|
193
|
+
</template>
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
.vp-demo-wrapper {
|
|
2
|
+
margin: 16px 0;
|
|
3
|
+
border: 1px solid var(--vp-c-divider);
|
|
4
|
+
border-radius: 8px;
|
|
5
|
+
transition: border-color var(--vp-t-color);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.vp-demo-wrapper .demo-draw {
|
|
9
|
+
padding: 24px;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.vp-demo-wrapper .demo-info .title {
|
|
13
|
+
display: flex;
|
|
14
|
+
align-items: center;
|
|
15
|
+
margin-top: 0;
|
|
16
|
+
margin-bottom: 8px;
|
|
17
|
+
font-size: 18px;
|
|
18
|
+
font-weight: bolder;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.vp-demo-wrapper .demo-info .title::before {
|
|
22
|
+
display: inline-block;
|
|
23
|
+
width: 16px;
|
|
24
|
+
height: 0;
|
|
25
|
+
margin-right: 8px;
|
|
26
|
+
content: "";
|
|
27
|
+
border-top: 1px solid var(--vp-c-divider);
|
|
28
|
+
transition: border-color var(--vp-t-color);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.vp-demo-wrapper .demo-info .title::after {
|
|
32
|
+
display: inline-block;
|
|
33
|
+
flex: 1;
|
|
34
|
+
height: 0;
|
|
35
|
+
margin-left: 8px;
|
|
36
|
+
content: "";
|
|
37
|
+
border-top: 1px solid var(--vp-c-divider);
|
|
38
|
+
transition: border-color var(--vp-t-color);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.vp-demo-wrapper .demo-info .desc {
|
|
42
|
+
padding: 0 24px;
|
|
43
|
+
margin-top: 8px;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.vp-demo-wrapper .demo-info p:last-child {
|
|
47
|
+
margin-bottom: 16px;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.vp-demo-wrapper .demo-ctrl {
|
|
51
|
+
display: flex;
|
|
52
|
+
gap: 16px;
|
|
53
|
+
justify-content: flex-end;
|
|
54
|
+
padding: 8px 24px;
|
|
55
|
+
border-top: 1px dotted var(--vp-c-divider);
|
|
56
|
+
transition: border-color var(--vp-t-color);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.vp-demo-wrapper .demo-ctrl .extra {
|
|
60
|
+
display: flex;
|
|
61
|
+
flex: 1;
|
|
62
|
+
gap: 16px;
|
|
63
|
+
align-items: center;
|
|
64
|
+
justify-content: flex-start;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.vp-demo-wrapper .demo-ctrl [class*="vpi-"] {
|
|
68
|
+
font-size: 20px;
|
|
69
|
+
color: var(--vp-c-text-2);
|
|
70
|
+
cursor: pointer;
|
|
71
|
+
transition: color var(--vp-t-color);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.vp-demo-wrapper .demo-ctrl [class*="vpi-"]:hover {
|
|
75
|
+
color: var(--vp-c-text-1);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.vp-demo-wrapper .demo-ctrl form,
|
|
79
|
+
.vp-demo-wrapper .demo-ctrl button {
|
|
80
|
+
padding: 0;
|
|
81
|
+
margin: 0;
|
|
82
|
+
line-height: 1;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.vp-demo-wrapper .demo-resources {
|
|
86
|
+
position: relative;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.vp-demo-wrapper .demo-code {
|
|
90
|
+
border-top: 1px solid var(--vp-c-divider);
|
|
91
|
+
transition: border-color var(--vp-t-color);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.vp-demo-wrapper .demo-code div[class*="language-"],
|
|
95
|
+
.vp-demo-wrapper .demo-code .vp-code-tabs-nav {
|
|
96
|
+
margin: 0;
|
|
97
|
+
border-top-left-radius: 0;
|
|
98
|
+
border-top-right-radius: 0;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.vp-demo-wrapper .demo-code > div[class*="language-"]:not(:last-of-type) {
|
|
102
|
+
border-bottom: 2px dotted var(--vp-c-divider);
|
|
103
|
+
border-radius: 0;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.vp-demo-wrapper .demo-code > div[class*="language-"] + div[class*="language-"] {
|
|
107
|
+
margin-top: 0;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.vp-demo-wrapper .demo-resources-container {
|
|
111
|
+
position: absolute;
|
|
112
|
+
top: 100%;
|
|
113
|
+
right: -24px;
|
|
114
|
+
z-index: 10;
|
|
115
|
+
width: max-content;
|
|
116
|
+
padding: 8px 12px;
|
|
117
|
+
font-size: 14px;
|
|
118
|
+
background-color: var(--vp-c-bg);
|
|
119
|
+
border: solid 1px var(--vp-c-divider);
|
|
120
|
+
border-radius: 8px;
|
|
121
|
+
box-shadow: var(--vp-shadow-2);
|
|
122
|
+
transition: var(--vp-t-color);
|
|
123
|
+
transition-property: border, box-shadow, background-color;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.vp-demo-wrapper .demo-resources-container .demo-resources-list > p {
|
|
127
|
+
margin: 0;
|
|
128
|
+
line-height: 20px;
|
|
129
|
+
color: var(--vp-c-text-3);
|
|
130
|
+
transition: color var(--vp-t-color);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.vp-demo-wrapper .demo-resources-container .demo-resources-list:not(:first-of-type) {
|
|
134
|
+
margin-top: 8px;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.vp-demo-wrapper .demo-resources-container .demo-resources-list ul {
|
|
138
|
+
padding: 0;
|
|
139
|
+
margin: 0;
|
|
140
|
+
list-style: none;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.vpi-demo-code {
|
|
144
|
+
--icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M14.18 4.276a.75.75 0 0 1 .531.918l-3.973 14.83a.75.75 0 0 1-1.45-.389l3.974-14.83a.75.75 0 0 1 .919-.53m2.262 3.053a.75.75 0 0 1 1.059-.056l1.737 1.564c.737.662 1.347 1.212 1.767 1.71c.44.525.754 1.088.754 1.784c0 .695-.313 1.258-.754 1.782c-.42.499-1.03 1.049-1.767 1.711l-1.737 1.564a.75.75 0 0 1-1.004-1.115l1.697-1.527c.788-.709 1.319-1.19 1.663-1.598c.33-.393.402-.622.402-.818s-.072-.424-.402-.817c-.344-.409-.875-.89-1.663-1.598l-1.697-1.527a.75.75 0 0 1-.056-1.06m-8.94 1.06a.75.75 0 1 0-1.004-1.115L4.761 8.836c-.737.662-1.347 1.212-1.767 1.71c-.44.525-.754 1.088-.754 1.784c0 .695.313 1.258.754 1.782c.42.499 1.03 1.049 1.767 1.711l1.737 1.564a.75.75 0 0 0 1.004-1.115l-1.697-1.527c-.788-.709-1.319-1.19-1.663-1.598c-.33-.393-.402-.622-.402-.818s.072-.424.402-.817c.344-.409.875-.89 1.663-1.598z'/%3E%3C/svg%3E");
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.vpi-demo-codepen {
|
|
148
|
+
--icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1024' height='1024' viewBox='0 0 1024 1024'%3E%3Cpath fill='%23000' d='m911.7 385.3l-.3-1.5c-.2-1-.3-1.9-.6-2.9c-.2-.6-.4-1.1-.5-1.7c-.3-.8-.5-1.7-.9-2.5c-.2-.6-.5-1.1-.8-1.7c-.4-.8-.8-1.5-1.2-2.3c-.3-.5-.6-1.1-1-1.6c-.8-1.2-1.7-2.4-2.6-3.6c-.5-.6-1.1-1.3-1.7-1.9c-.4-.5-.9-.9-1.4-1.3c-.6-.6-1.3-1.1-1.9-1.6c-.5-.4-1-.8-1.6-1.2c-.2-.1-.4-.3-.6-.4L531.1 117.8a34.3 34.3 0 0 0-38.1 0L127.3 361.3c-.2.1-.4.3-.6.4c-.5.4-1 .8-1.6 1.2c-.7.5-1.3 1.1-1.9 1.6c-.5.4-.9.9-1.4 1.3c-.6.6-1.2 1.2-1.7 1.9c-1 1.1-1.8 2.3-2.6 3.6c-.3.5-.7 1-1 1.6c-.4.7-.8 1.5-1.2 2.3c-.3.5-.5 1.1-.8 1.7c-.3.8-.6 1.7-.9 2.5c-.2.6-.4 1.1-.5 1.7c-.2.9-.4 1.9-.6 2.9l-.3 1.5q-.3 2.25-.3 4.5v243.5q0 2.25.3 4.5l.3 1.5l.6 2.9c.2.6.3 1.1.5 1.7c.3.9.6 1.7.9 2.5c.2.6.5 1.1.8 1.7c.4.8.7 1.5 1.2 2.3c.3.5.6 1.1 1 1.6c.5.7.9 1.4 1.5 2.1l1.2 1.5c.5.6 1.1 1.3 1.7 1.9c.4.5.9.9 1.4 1.3c.6.6 1.3 1.1 1.9 1.6c.5.4 1 .8 1.6 1.2c.2.1.4.3.6.4L493 905.7c5.6 3.8 12.3 5.8 19.1 5.8c6.6 0 13.3-1.9 19.1-5.8l365.6-243.5c.2-.1.4-.3.6-.4c.5-.4 1-.8 1.6-1.2c.7-.5 1.3-1.1 1.9-1.6c.5-.4.9-.9 1.4-1.3c.6-.6 1.2-1.2 1.7-1.9l1.2-1.5l1.5-2.1c.3-.5.7-1 1-1.6c.4-.8.8-1.5 1.2-2.3c.3-.5.5-1.1.8-1.7c.3-.8.6-1.7.9-2.5c.2-.5.4-1.1.5-1.7c.3-.9.4-1.9.6-2.9l.3-1.5q.3-2.25.3-4.5V389.8c-.3-1.5-.4-3-.6-4.5M546.4 210.5l269.4 179.4l-120.3 80.4l-149-99.6V210.5zm-68.8 0v160.2l-149 99.6l-120.3-80.4zM180.7 454.1l86 57.5l-86 57.5zm296.9 358.5L208.3 633.2l120.3-80.4l149 99.6zM512 592.8l-121.6-81.2L512 430.3l121.6 81.2zm34.4 219.8V652.4l149-99.6l120.3 80.4zM843.3 569l-86-57.5l86-57.5z'/%3E%3C/svg%3E");
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.vpi-demo-jsfiddle {
|
|
152
|
+
--icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='256' height='180' viewBox='0 0 256 180'%3E%3Cpath fill='%230084ff' d='M148.1 0c42.8 0 77.598 34.087 78.393 76.452l.014 1.481l-.011.866l1.46.76c16.183 8.773 26.938 25.332 27.964 44.018l.061 1.52l.019 1.418c0 29.117-23.397 52.75-52.428 53.295l-1.365.008H54.053C24.094 179.357 0 155.102 0 125.276c0-17.387 8.273-33.328 21.838-43.511l1.287-.938l.271-.19l-.135-.684a39 39 0 0 1-.438-3.347l-.11-1.694l-.037-1.705c0-21.519 17.547-38.95 39.173-38.95a39 39 0 0 1 16.063 3.445l1.483.706l.915.478l.978-1.623A78.37 78.37 0 0 1 144.718.072l1.721-.055zm0 11.13a67.24 67.24 0 0 0-60.69 38.113c-1.53 3.187-5.607 4.157-8.41 2c-4.908-3.776-10.875-5.856-17.151-5.856c-15.495 0-28.043 12.465-28.043 27.82c0 2.852.43 5.638 1.261 8.27a5.565 5.565 0 0 1-2.473 6.468c-13.215 7.815-21.464 21.854-21.464 37.33c0 23.308 18.526 42.367 41.76 43.376l1.249.038h148.103c23.526.144 42.628-18.783 42.628-42.174c0-17.244-10.49-32.572-26.266-39.1a5.57 5.57 0 0 1-3.43-4.87l.002-.586l.15-2.415l.047-1.246l-.012-1.798c-.768-36.225-30.578-65.37-67.262-65.37m16.167 70.493c17.519 0 31.876 13.362 31.876 30.052s-14.357 30.053-31.876 30.053c-10.548 0-19.386-5.284-31.203-16.729l-2.58-2.547l-3.436-3.525q-6.525-6.955-6.774-7.468l-1.321-1.363l-2.384-2.395a140 140 0 0 0-4.457-4.226l-2.087-1.835c-7.155-6.106-12.769-8.886-18.292-8.886c-11.543 0-20.746 8.564-20.746 18.921c0 10.358 9.203 18.922 20.746 18.922c6.002 0 10.482-1.965 14.584-5.612a35 35 0 0 0 1.57-1.491l2.941-3.133a5.565 5.565 0 0 1 8.5 7.161l-.51.591l-2.033 2.191a50 50 0 0 1-3.072 2.998c-6.013 5.348-13.03 8.426-21.98 8.426c-17.519 0-31.876-13.362-31.876-30.053c0-16.69 14.357-30.052 31.876-30.052c11.678 0 21.26 6.476 35.11 20.62q8.632 9.135 8.88 9.644l2.53 2.59c11.124 11.178 18.65 16.12 26.014 16.12c11.543 0 20.746-8.564 20.746-18.922c0-10.357-9.203-18.921-20.746-18.921c-6.002 0-10.482 1.965-14.584 5.612a35 35 0 0 0-1.57 1.49l-1.311 1.373l-1.63 1.76a5.565 5.565 0 0 1-8.108-7.625l2.15-2.318a50 50 0 0 1 3.073-2.998c6.013-5.347 13.03-8.425 21.98-8.425'/%3E%3C/svg%3E");
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.vpi-demo-resources {
|
|
156
|
+
--icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='%23000' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m21 14l-9 6l-9-6m18-4l-9 6l-9-6l9-6z'/%3E%3C/svg%3E");
|
|
157
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// src/client/utils/shared.ts
|
|
2
|
+
var cache = {};
|
|
3
|
+
function loadScript(src) {
|
|
4
|
+
if (__VUEPRESS_SSR__)
|
|
5
|
+
return Promise.resolve();
|
|
6
|
+
if (document.querySelector(`script[src="${src}"]`)) {
|
|
7
|
+
if (cache[src])
|
|
8
|
+
return cache[src];
|
|
9
|
+
return Promise.resolve();
|
|
10
|
+
}
|
|
11
|
+
const script = document.createElement("script");
|
|
12
|
+
script.src = src;
|
|
13
|
+
document.body.appendChild(script);
|
|
14
|
+
cache[src] = new Promise((resolve, reject) => {
|
|
15
|
+
script.onload = () => {
|
|
16
|
+
resolve();
|
|
17
|
+
delete cache[src];
|
|
18
|
+
};
|
|
19
|
+
script.onerror = reject;
|
|
20
|
+
});
|
|
21
|
+
return cache[src];
|
|
22
|
+
}
|
|
23
|
+
function loadStyle(href, target) {
|
|
24
|
+
if (__VUEPRESS_SSR__)
|
|
25
|
+
return;
|
|
26
|
+
if (target.querySelector(`link[href="${href}"]`))
|
|
27
|
+
return;
|
|
28
|
+
const link = document.createElement("link");
|
|
29
|
+
link.rel = "stylesheet";
|
|
30
|
+
link.href = href;
|
|
31
|
+
target.appendChild(link);
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
loadScript,
|
|
35
|
+
loadStyle
|
|
36
|
+
};
|
package/lib/node/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Token from 'markdown-it/lib/token.mjs';
|
|
2
2
|
import { App } from 'vuepress';
|
|
3
|
+
import { MarkdownEnv, Markdown } from 'vuepress/markdown';
|
|
4
|
+
import { BuiltinTheme, ThemeRegistration } from 'shiki';
|
|
3
5
|
import { Plugin } from 'vuepress/core';
|
|
4
6
|
|
|
5
7
|
type CanIUseMode = 'embed' | 'image';
|
|
@@ -55,6 +57,29 @@ interface CodeTabsOptions {
|
|
|
55
57
|
};
|
|
56
58
|
}
|
|
57
59
|
|
|
60
|
+
interface DemoFile {
|
|
61
|
+
type: 'vue' | 'normal' | 'css' | 'markdown';
|
|
62
|
+
export?: string;
|
|
63
|
+
path: string;
|
|
64
|
+
gitignore?: boolean;
|
|
65
|
+
}
|
|
66
|
+
interface MarkdownDemoEnv extends MarkdownEnv {
|
|
67
|
+
demoFiles?: DemoFile[];
|
|
68
|
+
}
|
|
69
|
+
interface DemoMeta {
|
|
70
|
+
type: 'vue' | 'normal' | 'markdown';
|
|
71
|
+
url: string;
|
|
72
|
+
title?: string;
|
|
73
|
+
desc?: string;
|
|
74
|
+
codeSetting?: string;
|
|
75
|
+
expanded?: boolean;
|
|
76
|
+
}
|
|
77
|
+
interface DemoContainerRender {
|
|
78
|
+
before: (app: App, md: Markdown, env: MarkdownDemoEnv, meta: DemoMeta, codeMap: Record<string, string>) => string;
|
|
79
|
+
after: () => string;
|
|
80
|
+
token?: (token: Token, tokens: Token[], index: number) => void;
|
|
81
|
+
}
|
|
82
|
+
|
|
58
83
|
type FileTreeIconMode = 'simple' | 'colored';
|
|
59
84
|
interface FileTreeOptions {
|
|
60
85
|
icon?: FileTreeIconMode;
|
|
@@ -252,6 +277,10 @@ interface MarkdownPowerPluginOptions {
|
|
|
252
277
|
* @default false
|
|
253
278
|
*/
|
|
254
279
|
fileTree?: boolean | FileTreeOptions;
|
|
280
|
+
/**
|
|
281
|
+
* 是否启用 demo 语法
|
|
282
|
+
*/
|
|
283
|
+
demo?: boolean;
|
|
255
284
|
/**
|
|
256
285
|
* 是否启用 caniuse 嵌入语法
|
|
257
286
|
*
|
|
@@ -326,4 +355,4 @@ declare function resolveImageSize(app: App, url: string, remote?: boolean): Prom
|
|
|
326
355
|
|
|
327
356
|
declare function markdownPowerPlugin(options?: MarkdownPowerPluginOptions): Plugin;
|
|
328
357
|
|
|
329
|
-
export { type ArtPlayerTokenMeta, type BilibiliTokenMeta, type CanIUseMode, type CanIUseOptions, type CanIUseTokenMeta, type CodeSandboxTokenMeta, type CodeTabsOptions, type CodepenTokenMeta, type FileTreeIconMode, type FileTreeOptions, type IconsOptions, type JSFiddleTokenMeta, type MarkdownPowerPluginOptions, type NpmToOptions, type NpmToPackageManager, type PDFEmbedType, type PDFOptions, type PDFTokenMeta, type PlotOptions, type ReplEditorData, type ReplOptions, type ReplitTokenMeta, type SizeOptions, type ThemeOptions, type VideoOptions, type YoutubeTokenMeta, markdownPowerPlugin, resolveImageSize };
|
|
358
|
+
export { type ArtPlayerTokenMeta, type BilibiliTokenMeta, type CanIUseMode, type CanIUseOptions, type CanIUseTokenMeta, type CodeSandboxTokenMeta, type CodeTabsOptions, type CodepenTokenMeta, type DemoContainerRender, type DemoFile, type DemoMeta, type FileTreeIconMode, type FileTreeOptions, type IconsOptions, type JSFiddleTokenMeta, type MarkdownDemoEnv, type MarkdownPowerPluginOptions, type NpmToOptions, type NpmToPackageManager, type PDFEmbedType, type PDFOptions, type PDFTokenMeta, type PlotOptions, type ReplEditorData, type ReplOptions, type ReplitTokenMeta, type SizeOptions, type ThemeOptions, type VideoOptions, type YoutubeTokenMeta, markdownPowerPlugin, resolveImageSize };
|