vuepress-plugin-md-power 1.0.0-rc.143 → 1.0.0-rc.145
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/README.md +10 -10
- package/lib/client/components/CanIUse.vue +4 -4
- package/lib/client/components/FileTreeNode.vue +229 -0
- package/lib/client/components/VPField.vue +94 -0
- package/lib/client/composables/demo.js +3 -3
- package/lib/node/index.d.ts +7 -1
- package/lib/node/index.js +460 -440
- package/lib/shared/index.d.ts +7 -1
- package/package.json +18 -18
- package/lib/client/components/FileTreeItem.vue +0 -183
package/README.md
CHANGED
|
@@ -95,10 +95,10 @@ pnpm add @iconify/json
|
|
|
95
95
|
#### 语法
|
|
96
96
|
|
|
97
97
|
```md
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
98
|
+
::collect:icon::
|
|
99
|
+
::collect:icon =size::
|
|
100
|
+
::collect:icon /color::
|
|
101
|
+
::collect:icon =size /color::
|
|
102
102
|
```
|
|
103
103
|
|
|
104
104
|
你可以从 [icon-sets.iconify](https://icon-sets.iconify.design/) 获取 图标集。
|
|
@@ -106,25 +106,25 @@ pnpm add @iconify/json
|
|
|
106
106
|
显示 `logos` 图标集合下的 `vue` 图标
|
|
107
107
|
|
|
108
108
|
```md
|
|
109
|
-
|
|
109
|
+
::logos:vue::
|
|
110
110
|
```
|
|
111
111
|
|
|
112
|
-
图标默认大小为 `1em` ,你可以通过
|
|
112
|
+
图标默认大小为 `1em` ,你可以通过 `=size` 设置图标大小
|
|
113
113
|
|
|
114
114
|
```md
|
|
115
|
-
|
|
115
|
+
::logos:vue =1.2em::
|
|
116
116
|
```
|
|
117
117
|
|
|
118
118
|
图标默认颜色为 `currentColor` 你可以通过 `/color` 设置图标颜色
|
|
119
119
|
|
|
120
120
|
```md
|
|
121
|
-
|
|
121
|
+
::logos:vue /blue::
|
|
122
122
|
```
|
|
123
123
|
|
|
124
|
-
也可以通过
|
|
124
|
+
也可以通过 `=size /color` 设置图标大小和颜色
|
|
125
125
|
|
|
126
126
|
```md
|
|
127
|
-
|
|
127
|
+
::logos:vue =1.2em /blue::
|
|
128
128
|
```
|
|
129
129
|
|
|
130
130
|
### bilibili
|
|
@@ -14,12 +14,12 @@ interface MessageData {
|
|
|
14
14
|
|
|
15
15
|
const props = withDefaults(defineProps<{
|
|
16
16
|
feature: string
|
|
17
|
-
past?:
|
|
18
|
-
future?:
|
|
17
|
+
past?: number
|
|
18
|
+
future?: number
|
|
19
19
|
meta?: string
|
|
20
20
|
}>(), {
|
|
21
|
-
past:
|
|
22
|
-
future:
|
|
21
|
+
past: 2,
|
|
22
|
+
future: 1,
|
|
23
23
|
meta: '',
|
|
24
24
|
})
|
|
25
25
|
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { Ref } from 'vue'
|
|
3
|
+
import { inject, ref } from 'vue'
|
|
4
|
+
|
|
5
|
+
const props = defineProps<{
|
|
6
|
+
type: 'file' | 'folder'
|
|
7
|
+
filename: string
|
|
8
|
+
level: number
|
|
9
|
+
diff?: 'add' | 'remove'
|
|
10
|
+
expanded?: boolean
|
|
11
|
+
focus?: boolean
|
|
12
|
+
}>()
|
|
13
|
+
|
|
14
|
+
const activeFileTreeNode = inject<Ref<string>>('active-file-tree-node', ref(''))
|
|
15
|
+
|
|
16
|
+
const onNodeClick = inject<
|
|
17
|
+
(filename: string, type: 'file' | 'folder') => void
|
|
18
|
+
>('on-file-tree-node-click', () => {})
|
|
19
|
+
|
|
20
|
+
const active = ref(props.expanded)
|
|
21
|
+
|
|
22
|
+
function nodeClick() {
|
|
23
|
+
if (props.filename === '…' || props.filename === '...')
|
|
24
|
+
return
|
|
25
|
+
|
|
26
|
+
onNodeClick(props.filename, props.type)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function toggle(ev: MouseEvent) {
|
|
30
|
+
if (props.type === 'folder') {
|
|
31
|
+
const el = ev.target as HTMLElement
|
|
32
|
+
if (!el.matches('.comment, .comment *')) {
|
|
33
|
+
active.value = !active.value
|
|
34
|
+
nodeClick()
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
nodeClick()
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
</script>
|
|
42
|
+
|
|
43
|
+
<template>
|
|
44
|
+
<div class="vp-file-tree-node">
|
|
45
|
+
<p
|
|
46
|
+
class="vp-file-tree-info" :class="{
|
|
47
|
+
[type]: true,
|
|
48
|
+
focus,
|
|
49
|
+
expanded: type === 'folder' ? active : false,
|
|
50
|
+
active: type === 'file' ? activeFileTreeNode === filename : false,
|
|
51
|
+
diff,
|
|
52
|
+
add: diff === 'add',
|
|
53
|
+
remove: diff === 'remove',
|
|
54
|
+
}"
|
|
55
|
+
:style="{ '--file-tree-level': -level }"
|
|
56
|
+
@click="toggle"
|
|
57
|
+
>
|
|
58
|
+
<slot name="icon" />
|
|
59
|
+
<span class="name" :class="[type]">{{ filename }}</span>
|
|
60
|
+
<span v-if="$slots.comment" class="comment"><slot name="comment" /></span>
|
|
61
|
+
</p>
|
|
62
|
+
<div v-if="type === 'folder'" v-show="active" class="group">
|
|
63
|
+
<slot />
|
|
64
|
+
</div>
|
|
65
|
+
</div>
|
|
66
|
+
</template>
|
|
67
|
+
|
|
68
|
+
<style>
|
|
69
|
+
.vp-file-tree {
|
|
70
|
+
max-width: 100%;
|
|
71
|
+
padding: 16px;
|
|
72
|
+
overflow: auto hidden;
|
|
73
|
+
font-size: 14px;
|
|
74
|
+
background-color: var(--vp-c-bg-safe);
|
|
75
|
+
border: solid 1px var(--vp-c-divider);
|
|
76
|
+
border-radius: 8px;
|
|
77
|
+
transition: border var(--vp-t-color), background-color var(--vp-t-color);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.vp-file-tree .vp-file-tree-title {
|
|
81
|
+
padding: 8px 16px;
|
|
82
|
+
margin: -16px -16px 8px;
|
|
83
|
+
font-weight: bold;
|
|
84
|
+
color: var(--vp-c-text-1);
|
|
85
|
+
border-bottom: solid 1px var(--vp-c-divider);
|
|
86
|
+
transition: color var(--vp-t-color), border-color var(--vp-t-color);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.vp-file-tree .vp-file-tree-info {
|
|
90
|
+
position: relative;
|
|
91
|
+
display: flex;
|
|
92
|
+
gap: 8px;
|
|
93
|
+
align-items: center;
|
|
94
|
+
justify-content: flex-start;
|
|
95
|
+
height: 28px;
|
|
96
|
+
padding: 2px 0;
|
|
97
|
+
margin: 0 0 0 16px;
|
|
98
|
+
line-height: 24px;
|
|
99
|
+
text-wrap: nowrap;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.vp-file-tree .vp-file-tree-info::after {
|
|
103
|
+
position: absolute;
|
|
104
|
+
top: 0;
|
|
105
|
+
right: -16px;
|
|
106
|
+
bottom: 0;
|
|
107
|
+
left: calc(var(--file-tree-level) * 28px - 32px);
|
|
108
|
+
z-index: 0;
|
|
109
|
+
display: block;
|
|
110
|
+
pointer-events: none;
|
|
111
|
+
content: "";
|
|
112
|
+
background-color: transparent;
|
|
113
|
+
transition: background-color var(--vp-t-color);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.vp-file-tree .vp-file-tree-info.active::after,
|
|
117
|
+
.vp-file-tree .vp-file-tree-info:not(.diff):hover::after {
|
|
118
|
+
background-color: var(--vp-c-default-soft);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.vp-file-tree .vp-file-tree-info.diff::after {
|
|
122
|
+
padding-left: 4px;
|
|
123
|
+
font-size: 1.25em;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.vp-file-tree .vp-file-tree-info.diff.add::after {
|
|
127
|
+
color: var(--vp-c-success-1);
|
|
128
|
+
content: "+";
|
|
129
|
+
background-color: var(--vp-c-success-soft);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.vp-file-tree .vp-file-tree-info.diff.remove::after {
|
|
133
|
+
color: var(--vp-c-danger-1);
|
|
134
|
+
content: "-";
|
|
135
|
+
background-color: var(--vp-c-danger-soft);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.vp-file-tree .vp-file-tree-info.folder {
|
|
139
|
+
cursor: pointer;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.vp-file-tree .vp-file-tree-info.folder::before {
|
|
143
|
+
--icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath fill='%23000' d='m5.157 13.069l4.611-4.685a.546.546 0 0 0 0-.768L5.158 2.93a.55.55 0 0 1 0-.771a.53.53 0 0 1 .759 0l4.61 4.684a1.65 1.65 0 0 1 0 2.312l-4.61 4.684a.53.53 0 0 1-.76 0a.55.55 0 0 1 0-.771'/%3E%3C/svg%3E");
|
|
144
|
+
|
|
145
|
+
position: absolute;
|
|
146
|
+
top: 8px;
|
|
147
|
+
left: -16px;
|
|
148
|
+
display: block;
|
|
149
|
+
width: 12px;
|
|
150
|
+
height: 12px;
|
|
151
|
+
color: var(--vp-c-text-2);
|
|
152
|
+
cursor: pointer;
|
|
153
|
+
content: "";
|
|
154
|
+
background-color: currentcolor;
|
|
155
|
+
-webkit-mask: var(--icon) no-repeat;
|
|
156
|
+
mask: var(--icon) no-repeat;
|
|
157
|
+
-webkit-mask-size: 100% 100%;
|
|
158
|
+
mask-size: 100% 100%;
|
|
159
|
+
transition: color var(--vp-t-color), transform var(--vp-t-color);
|
|
160
|
+
transform: rotate(0);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.vp-file-tree .vp-file-tree-info.folder.expanded::before {
|
|
164
|
+
transform: rotate(90deg);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.vp-file-tree .vp-file-tree-info .name {
|
|
168
|
+
position: relative;
|
|
169
|
+
font-family: var(--vp-font-family-mono);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.vp-file-tree .vp-file-tree-info.folder .name {
|
|
173
|
+
color: var(--vp-c-text-1);
|
|
174
|
+
transition: color var(--vp-t-color);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.vp-file-tree .vp-file-tree-info.focus .name {
|
|
178
|
+
padding: 0 4px;
|
|
179
|
+
margin: 0 -4px;
|
|
180
|
+
font-weight: bold;
|
|
181
|
+
color: var(--vp-c-bg);
|
|
182
|
+
background-color: var(--vp-c-brand-2);
|
|
183
|
+
border-radius: 4px;
|
|
184
|
+
transition: color var(--vp-t-color), background-color var(--vp-t-color);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.vp-file-tree .vp-file-tree-info.active .name {
|
|
188
|
+
color: var(--vp-c-brand-1);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.vp-file-tree .vp-file-tree-info:not(.focus).folder .name:hover {
|
|
192
|
+
color: var(--vp-c-brand-1);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.vp-file-tree .vp-file-tree-info .comment {
|
|
196
|
+
display: inline-block;
|
|
197
|
+
flex: 1 2;
|
|
198
|
+
height: 28px;
|
|
199
|
+
padding-right: 16px;
|
|
200
|
+
padding-left: 20px;
|
|
201
|
+
margin: -2px 0;
|
|
202
|
+
line-height: 28px;
|
|
203
|
+
color: var(--vp-c-text-3);
|
|
204
|
+
cursor: auto;
|
|
205
|
+
transition: color var(--vp-t-color);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
.vp-file-tree .vp-file-tree-node .group {
|
|
209
|
+
position: relative;
|
|
210
|
+
margin-left: 28px;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
.vp-file-tree .vp-file-tree-node .group::before {
|
|
214
|
+
position: absolute;
|
|
215
|
+
top: 0;
|
|
216
|
+
left: -4px;
|
|
217
|
+
width: 1px;
|
|
218
|
+
height: 100%;
|
|
219
|
+
content: "";
|
|
220
|
+
background-color: var(--vp-c-divider);
|
|
221
|
+
transition: background-color var(--vp-t-color);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
.vp-file-tree [class*="vpi-"] {
|
|
225
|
+
width: 1.2em;
|
|
226
|
+
height: 1.2em;
|
|
227
|
+
margin: 0;
|
|
228
|
+
}
|
|
229
|
+
</style>
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
defineProps<{
|
|
3
|
+
name: string
|
|
4
|
+
type?: string
|
|
5
|
+
required?: boolean
|
|
6
|
+
optional?: boolean
|
|
7
|
+
defaultValue?: string
|
|
8
|
+
}>()
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<template>
|
|
12
|
+
<div class="vp-field">
|
|
13
|
+
<p class="field-meta">
|
|
14
|
+
<span class="name">{{ name }}</span>
|
|
15
|
+
<span v-if="required || optional" :class="{ required, optional }">{{ required ? 'Required' : optional ? 'Optional' : '' }}</span>
|
|
16
|
+
<span v-if="type" class="type"><code>{{ type }}</code></span>
|
|
17
|
+
</p>
|
|
18
|
+
<p v-if="defaultValue" class="default-value">
|
|
19
|
+
<code>{{ defaultValue }}</code>
|
|
20
|
+
</p>
|
|
21
|
+
<div v-if="$slots.default" class="description">
|
|
22
|
+
<slot />
|
|
23
|
+
</div>
|
|
24
|
+
</div>
|
|
25
|
+
</template>
|
|
26
|
+
|
|
27
|
+
<style>
|
|
28
|
+
.vp-field {
|
|
29
|
+
width: 100%;
|
|
30
|
+
margin: 16px 0;
|
|
31
|
+
transition: border-color var(--vp-t-color);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.vp-field + .vp-field {
|
|
35
|
+
padding-top: 8px;
|
|
36
|
+
border-top: solid 1px var(--vp-c-divider);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.vp-field .field-meta {
|
|
40
|
+
display: flex;
|
|
41
|
+
gap: 8px;
|
|
42
|
+
align-items: flex-start;
|
|
43
|
+
margin: 8px 0;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.vp-field .field-meta .name {
|
|
47
|
+
font-size: 18px;
|
|
48
|
+
font-weight: 500;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.vp-field .field-meta .required,
|
|
52
|
+
.vp-field .field-meta .optional {
|
|
53
|
+
display: inline-block;
|
|
54
|
+
padding: 2px 8px;
|
|
55
|
+
font-size: 12px;
|
|
56
|
+
font-style: italic;
|
|
57
|
+
line-height: 1;
|
|
58
|
+
border-radius: 8px;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.vp-field .field-meta .required {
|
|
62
|
+
color: var(--vp-c-success-2);
|
|
63
|
+
border: solid 1px var(--vp-c-success-2);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.vp-field .field-meta .optional {
|
|
67
|
+
color: var(--vp-c-text-3);
|
|
68
|
+
border: solid 1px var(--vp-c-divider);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.vp-field .field-meta .type {
|
|
72
|
+
flex: 1 2;
|
|
73
|
+
text-align: right;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.vp-field .default-value {
|
|
77
|
+
margin: 0;
|
|
78
|
+
font-size: 14px;
|
|
79
|
+
line-height: 1;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.vp-field .description :where(p, ul, ol) {
|
|
83
|
+
margin: 8px 0;
|
|
84
|
+
line-height: 24px;
|
|
85
|
+
color: var(--vp-c-text-2);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.vp-field-group {
|
|
89
|
+
padding: 0 20px;
|
|
90
|
+
margin: 16px 0;
|
|
91
|
+
border: solid 1px var(--vp-c-divider);
|
|
92
|
+
border-radius: 6px;
|
|
93
|
+
}
|
|
94
|
+
</style>
|
|
@@ -15,9 +15,9 @@ function useResources(el, config) {
|
|
|
15
15
|
if (!conf)
|
|
16
16
|
return [];
|
|
17
17
|
return [
|
|
18
|
-
{ name: "JavaScript", items: conf.jsLib
|
|
19
|
-
{ name: "CSS", items: conf.cssLib
|
|
20
|
-
].filter((i) => i.items
|
|
18
|
+
{ name: "JavaScript", items: conf.jsLib?.map((url) => ({ name: normalizeName(url), url })) },
|
|
19
|
+
{ name: "CSS", items: conf.cssLib?.map((url) => ({ name: normalizeName(url), url })) }
|
|
20
|
+
].filter((i) => i.items?.length);
|
|
21
21
|
});
|
|
22
22
|
function normalizeName(url) {
|
|
23
23
|
return url.slice(url.lastIndexOf("/") + 1);
|
package/lib/node/index.d.ts
CHANGED
|
@@ -205,7 +205,7 @@ interface MarkdownPowerPluginOptions {
|
|
|
205
205
|
/**
|
|
206
206
|
* 是否启用 iconify 图标嵌入语法
|
|
207
207
|
*
|
|
208
|
-
*
|
|
208
|
+
* `::collect:icon_name::`
|
|
209
209
|
*
|
|
210
210
|
* @default false
|
|
211
211
|
*/
|
|
@@ -268,6 +268,12 @@ interface MarkdownPowerPluginOptions {
|
|
|
268
268
|
* @default false
|
|
269
269
|
*/
|
|
270
270
|
chat?: boolean;
|
|
271
|
+
/**
|
|
272
|
+
* 是否启用 field / field-group 容器
|
|
273
|
+
*
|
|
274
|
+
* @default false
|
|
275
|
+
*/
|
|
276
|
+
field?: boolean;
|
|
271
277
|
/**
|
|
272
278
|
* 是否启用 bilibili 视频嵌入
|
|
273
279
|
*
|