vuepress-plugin-md-power 1.0.0-rc.97 → 1.0.0-rc.99
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/CanIUse.vue +1 -1
- package/lib/client/components/CodeEditor.vue +2 -2
- package/lib/client/components/CodeRepl.vue +2 -2
- package/lib/client/components/FileTreeItem.vue +23 -5
- package/lib/client/components/PDFViewer.vue +2 -2
- package/lib/client/components/Plot.vue +2 -2
- package/lib/client/components/Replit.vue +1 -1
- package/lib/client/composables/pdf.js +2 -2
- package/lib/client/utils/link.js +1 -1
- package/lib/node/index.d.ts +181 -83
- package/lib/node/index.js +1029 -900
- package/lib/shared/index.d.ts +172 -81
- package/package.json +6 -6
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { getHighlighterCore } from 'shiki/core'
|
|
3
|
-
import type { HighlighterCore } from 'shiki/core'
|
|
4
2
|
import editorData from '@internal/md-power/replEditorData'
|
|
3
|
+
import { getHighlighterCore } from 'shiki/core'
|
|
5
4
|
import { onMounted, onUnmounted, ref, shallowRef, watch } from 'vue'
|
|
5
|
+
import type { HighlighterCore } from 'shiki/core'
|
|
6
6
|
import { resolveCodeInfo } from '../composables/codeRepl.js'
|
|
7
7
|
|
|
8
8
|
let highlighter: HighlighterCore | null = null
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { defineAsyncComponent, shallowRef } from 'vue'
|
|
3
3
|
import { useCodeRepl } from '../composables/codeRepl.js'
|
|
4
|
+
import IconClose from './IconClose.vue'
|
|
5
|
+
import IconConsole from './IconConsole.vue'
|
|
4
6
|
import IconRun from './IconRun.vue'
|
|
5
7
|
import Loading from './Loading.vue'
|
|
6
|
-
import IconConsole from './IconConsole.vue'
|
|
7
|
-
import IconClose from './IconClose.vue'
|
|
8
8
|
|
|
9
9
|
defineProps<{
|
|
10
10
|
editable?: boolean
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { onMounted, ref } from 'vue'
|
|
2
|
+
import { onMounted, onUnmounted, ref } from 'vue'
|
|
3
3
|
|
|
4
4
|
const props = defineProps<{
|
|
5
5
|
type: 'file' | 'folder'
|
|
@@ -10,13 +10,22 @@ const props = defineProps<{
|
|
|
10
10
|
const active = ref(!!props.expanded)
|
|
11
11
|
const el = ref<HTMLElement>()
|
|
12
12
|
|
|
13
|
+
function toggle() {
|
|
14
|
+
active.value = !active.value
|
|
15
|
+
}
|
|
16
|
+
|
|
13
17
|
onMounted(() => {
|
|
14
18
|
if (!el.value || props.type !== 'folder')
|
|
15
19
|
return
|
|
16
20
|
|
|
17
|
-
el.value.querySelector('.tree-node.folder')?.addEventListener('click',
|
|
18
|
-
|
|
19
|
-
|
|
21
|
+
el.value.querySelector('.tree-node.folder')?.addEventListener('click', toggle)
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
onUnmounted(() => {
|
|
25
|
+
if (!el.value || props.type !== 'folder')
|
|
26
|
+
return
|
|
27
|
+
|
|
28
|
+
el.value.querySelector('.tree-node.folder')?.removeEventListener('click', toggle)
|
|
20
29
|
})
|
|
21
30
|
</script>
|
|
22
31
|
|
|
@@ -45,6 +54,15 @@ onMounted(() => {
|
|
|
45
54
|
transition: border var(--t-color), background-color var(--t-color);
|
|
46
55
|
}
|
|
47
56
|
|
|
57
|
+
.vp-file-tree .vp-file-tree-title {
|
|
58
|
+
padding-left: 16px;
|
|
59
|
+
margin: -16px -16px 0;
|
|
60
|
+
font-weight: bold;
|
|
61
|
+
color: var(--vp-c-text-1);
|
|
62
|
+
border-bottom: solid 1px var(--vp-c-divider);
|
|
63
|
+
transition: color var(--t-color), border-color var(--t-color);
|
|
64
|
+
}
|
|
65
|
+
|
|
48
66
|
.vp-file-tree ul {
|
|
49
67
|
padding: 0 !important;
|
|
50
68
|
margin: 0 !important;
|
|
@@ -105,7 +123,7 @@ onMounted(() => {
|
|
|
105
123
|
transition: color var(--t-color);
|
|
106
124
|
}
|
|
107
125
|
|
|
108
|
-
.file-tree-item .tree-node
|
|
126
|
+
.file-tree-item .tree-node .name.focus {
|
|
109
127
|
font-weight: bold;
|
|
110
128
|
color: var(--vp-c-brand-1);
|
|
111
129
|
transition: color var(--t-color);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { onMounted, toRefs } from 'vue'
|
|
3
|
-
import type { PDFTokenMeta } from '../../shared/index.js'
|
|
4
|
-
import { useSize } from '../composables/size.js'
|
|
5
3
|
import { usePDF } from '../composables/pdf.js'
|
|
4
|
+
import { useSize } from '../composables/size.js'
|
|
5
|
+
import type { PDFTokenMeta } from '../../shared/index.js'
|
|
6
6
|
|
|
7
7
|
const props = defineProps<PDFTokenMeta>()
|
|
8
8
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { computed, ref, shallowRef } from 'vue'
|
|
3
2
|
import { onClickOutside, useMediaQuery } from '@vueuse/core'
|
|
3
|
+
import { computed, ref, shallowRef } from 'vue'
|
|
4
4
|
import { usePageFrontmatter } from 'vuepress/client'
|
|
5
|
-
import type { PlotOptions } from '../../shared/index.js'
|
|
6
5
|
import { pluginOptions } from '../options.js'
|
|
6
|
+
import type { PlotOptions } from '../../shared/index.js'
|
|
7
7
|
|
|
8
8
|
const props = defineProps<Omit<PlotOptions, 'tag'>>()
|
|
9
9
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { computed, getCurrentInstance, ref } from 'vue'
|
|
3
|
-
import type { ReplitTokenMeta } from '../../shared/index.js'
|
|
4
3
|
import Loading from './Loading.vue'
|
|
4
|
+
import type { ReplitTokenMeta } from '../../shared/index.js'
|
|
5
5
|
|
|
6
6
|
const props = defineProps<ReplitTokenMeta>()
|
|
7
7
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// src/client/composables/pdf.ts
|
|
2
|
-
import { ensureEndingSlash, isLinkHttp } from "vuepress/shared";
|
|
3
2
|
import { withBase } from "vuepress/client";
|
|
3
|
+
import { ensureEndingSlash, isLinkHttp } from "vuepress/shared";
|
|
4
4
|
import { pluginOptions } from "../options.js";
|
|
5
|
-
import { checkIsMobile, checkIsSafari
|
|
5
|
+
import { checkIsiPad, checkIsMobile, checkIsSafari } from "../utils/is.js";
|
|
6
6
|
function queryStringify(options) {
|
|
7
7
|
const { page, noToolbar, zoom } = options;
|
|
8
8
|
const params = [
|
package/lib/client/utils/link.js
CHANGED
package/lib/node/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Plugin } from 'vuepress/core';
|
|
2
1
|
import { BuiltinTheme, ThemeRegistration } from 'shiki';
|
|
2
|
+
import { App } from 'vuepress';
|
|
3
|
+
import { Plugin } from 'vuepress/core';
|
|
3
4
|
|
|
4
5
|
type CanIUseMode = 'embed' | 'image';
|
|
5
6
|
interface CanIUseTokenMeta {
|
|
@@ -26,61 +27,6 @@ interface SizeOptions {
|
|
|
26
27
|
ratio?: number | string;
|
|
27
28
|
}
|
|
28
29
|
|
|
29
|
-
type PDFEmbedType = 'iframe' | 'embed' | 'pdfjs';
|
|
30
|
-
interface PDFTokenMeta extends SizeOptions {
|
|
31
|
-
page?: number;
|
|
32
|
-
noToolbar?: boolean;
|
|
33
|
-
zoom?: number;
|
|
34
|
-
src?: string;
|
|
35
|
-
title?: string;
|
|
36
|
-
}
|
|
37
|
-
interface PDFOptions {
|
|
38
|
-
/**
|
|
39
|
-
* pdfjs url
|
|
40
|
-
*/
|
|
41
|
-
pdfjsUrl?: string;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
interface IconsOptions {
|
|
45
|
-
/**
|
|
46
|
-
* The prefix of the icon className
|
|
47
|
-
* @default 'vp-mdi'
|
|
48
|
-
*/
|
|
49
|
-
prefix?: string;
|
|
50
|
-
/**
|
|
51
|
-
* The size of the icon
|
|
52
|
-
* @default '1em'
|
|
53
|
-
*/
|
|
54
|
-
size?: string | number;
|
|
55
|
-
/**
|
|
56
|
-
* The color of the icon
|
|
57
|
-
* @default 'currentColor'
|
|
58
|
-
*/
|
|
59
|
-
color?: string;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
interface VideoOptions {
|
|
63
|
-
bilibili?: boolean;
|
|
64
|
-
youtube?: boolean;
|
|
65
|
-
}
|
|
66
|
-
interface BilibiliTokenMeta extends SizeOptions {
|
|
67
|
-
title?: string;
|
|
68
|
-
bvid?: string;
|
|
69
|
-
aid?: string;
|
|
70
|
-
cid?: string;
|
|
71
|
-
autoplay?: boolean;
|
|
72
|
-
time?: string | number;
|
|
73
|
-
page?: number;
|
|
74
|
-
}
|
|
75
|
-
interface YoutubeTokenMeta extends SizeOptions {
|
|
76
|
-
title?: string;
|
|
77
|
-
id: string;
|
|
78
|
-
autoplay?: boolean;
|
|
79
|
-
loop?: boolean;
|
|
80
|
-
start?: string | number;
|
|
81
|
-
end?: string | number;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
30
|
interface CodepenTokenMeta extends SizeOptions {
|
|
85
31
|
title?: string;
|
|
86
32
|
user?: string;
|
|
@@ -102,32 +48,22 @@ interface CodeSandboxTokenMeta extends SizeOptions {
|
|
|
102
48
|
console?: boolean;
|
|
103
49
|
}
|
|
104
50
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
theme: ThemeRegistration | {
|
|
122
|
-
light: ThemeRegistration;
|
|
123
|
-
dark: ThemeRegistration;
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
interface ReplitTokenMeta extends SizeOptions {
|
|
128
|
-
title?: string;
|
|
129
|
-
source?: string;
|
|
130
|
-
theme?: string;
|
|
51
|
+
interface IconsOptions {
|
|
52
|
+
/**
|
|
53
|
+
* The prefix of the icon className
|
|
54
|
+
* @default 'vp-mdi'
|
|
55
|
+
*/
|
|
56
|
+
prefix?: string;
|
|
57
|
+
/**
|
|
58
|
+
* The size of the icon
|
|
59
|
+
* @default '1em'
|
|
60
|
+
*/
|
|
61
|
+
size?: string | number;
|
|
62
|
+
/**
|
|
63
|
+
* The color of the icon
|
|
64
|
+
* @default 'currentColor'
|
|
65
|
+
*/
|
|
66
|
+
color?: string;
|
|
131
67
|
}
|
|
132
68
|
|
|
133
69
|
interface JSFiddleTokenMeta extends SizeOptions {
|
|
@@ -138,6 +74,21 @@ interface JSFiddleTokenMeta extends SizeOptions {
|
|
|
138
74
|
tab?: string;
|
|
139
75
|
}
|
|
140
76
|
|
|
77
|
+
type PDFEmbedType = 'iframe' | 'embed' | 'pdfjs';
|
|
78
|
+
interface PDFTokenMeta extends SizeOptions {
|
|
79
|
+
page?: number;
|
|
80
|
+
noToolbar?: boolean;
|
|
81
|
+
zoom?: number;
|
|
82
|
+
src?: string;
|
|
83
|
+
title?: string;
|
|
84
|
+
}
|
|
85
|
+
interface PDFOptions {
|
|
86
|
+
/**
|
|
87
|
+
* pdfjs url
|
|
88
|
+
*/
|
|
89
|
+
pdfjsUrl?: string;
|
|
90
|
+
}
|
|
91
|
+
|
|
141
92
|
interface PlotOptions {
|
|
142
93
|
/**
|
|
143
94
|
* 是否启用 `=| |=` markdown (该标记为非标准标记,脱离插件将不生效)
|
|
@@ -166,24 +117,171 @@ interface PlotOptions {
|
|
|
166
117
|
trigger?: 'hover' | 'click';
|
|
167
118
|
}
|
|
168
119
|
|
|
120
|
+
type ThemeOptions = BuiltinTheme | {
|
|
121
|
+
light: BuiltinTheme;
|
|
122
|
+
dark: BuiltinTheme;
|
|
123
|
+
};
|
|
124
|
+
interface ReplOptions {
|
|
125
|
+
theme?: ThemeOptions;
|
|
126
|
+
go?: boolean;
|
|
127
|
+
kotlin?: boolean;
|
|
128
|
+
rust?: boolean;
|
|
129
|
+
}
|
|
130
|
+
interface ReplEditorData {
|
|
131
|
+
grammars: {
|
|
132
|
+
go?: any;
|
|
133
|
+
kotlin?: any;
|
|
134
|
+
rust?: any;
|
|
135
|
+
};
|
|
136
|
+
theme: ThemeRegistration | {
|
|
137
|
+
light: ThemeRegistration;
|
|
138
|
+
dark: ThemeRegistration;
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
|
|
169
142
|
interface MarkdownPowerPluginOptions {
|
|
143
|
+
/**
|
|
144
|
+
* 是否启用 PDF 嵌入语法
|
|
145
|
+
*
|
|
146
|
+
* `@[pdf](pdf_url)`
|
|
147
|
+
*
|
|
148
|
+
* @default false
|
|
149
|
+
*/
|
|
170
150
|
pdf?: boolean | PDFOptions;
|
|
151
|
+
/**
|
|
152
|
+
* 是否启用 iconify 图标嵌入语法
|
|
153
|
+
*
|
|
154
|
+
* `:[collect:icon_name]:`
|
|
155
|
+
*
|
|
156
|
+
* @default false
|
|
157
|
+
*/
|
|
171
158
|
icons?: boolean | IconsOptions;
|
|
159
|
+
/**
|
|
160
|
+
* 是否启用 隐秘文本 语法
|
|
161
|
+
*
|
|
162
|
+
* `!!plot_content!!`
|
|
163
|
+
*
|
|
164
|
+
* @default false
|
|
165
|
+
*/
|
|
172
166
|
plot?: boolean | PlotOptions;
|
|
167
|
+
/**
|
|
168
|
+
* 是否启用 bilibili 视频嵌入
|
|
169
|
+
*
|
|
170
|
+
* `@[bilibili](bid)`
|
|
171
|
+
*
|
|
172
|
+
* @default false
|
|
173
|
+
*/
|
|
173
174
|
bilibili?: boolean;
|
|
175
|
+
/**
|
|
176
|
+
* 是否启用 youtube 视频嵌入
|
|
177
|
+
*
|
|
178
|
+
* `@[youtube](video_id)`
|
|
179
|
+
*
|
|
180
|
+
* @default false
|
|
181
|
+
*/
|
|
174
182
|
youtube?: boolean;
|
|
183
|
+
/**
|
|
184
|
+
* 是否启用 codepen 嵌入
|
|
185
|
+
*
|
|
186
|
+
* `@[codepen](pen_id)`
|
|
187
|
+
*
|
|
188
|
+
* @default false
|
|
189
|
+
*/
|
|
175
190
|
codepen?: boolean;
|
|
176
191
|
/**
|
|
177
192
|
* @deprecated
|
|
178
193
|
*/
|
|
179
194
|
replit?: boolean;
|
|
195
|
+
/**
|
|
196
|
+
* 是否启用 codeSandbox 嵌入
|
|
197
|
+
*
|
|
198
|
+
* `@[codesandbox](codesandbox_id)`
|
|
199
|
+
*
|
|
200
|
+
* @default false
|
|
201
|
+
*/
|
|
180
202
|
codeSandbox?: boolean;
|
|
203
|
+
/**
|
|
204
|
+
* 是否启用 jsfiddle 嵌入
|
|
205
|
+
*
|
|
206
|
+
* `@[jsfiddle](jsfiddle_id)`
|
|
207
|
+
*
|
|
208
|
+
* @default false
|
|
209
|
+
*/
|
|
181
210
|
jsfiddle?: boolean;
|
|
211
|
+
/**
|
|
212
|
+
* 是否启用 REPL 容器语法
|
|
213
|
+
*
|
|
214
|
+
* @default false
|
|
215
|
+
*/
|
|
182
216
|
repl?: false | ReplOptions;
|
|
217
|
+
/**
|
|
218
|
+
* 是否启用 文件树 容器语法
|
|
219
|
+
*
|
|
220
|
+
* @default false
|
|
221
|
+
*/
|
|
183
222
|
fileTree?: boolean;
|
|
223
|
+
/**
|
|
224
|
+
* 是否启用 caniuse 嵌入语法
|
|
225
|
+
*
|
|
226
|
+
* `@[caniuse](feature_name)`
|
|
227
|
+
*
|
|
228
|
+
* @default false
|
|
229
|
+
*/
|
|
184
230
|
caniuse?: boolean | CanIUseOptions;
|
|
231
|
+
/**
|
|
232
|
+
* 是否启用 自动填充 图片宽高属性
|
|
233
|
+
*
|
|
234
|
+
* __请注意,无论是否启用,该功能仅在构建生产包时生效__
|
|
235
|
+
*
|
|
236
|
+
* - 如果为 `true` ,等同于 `'local'`
|
|
237
|
+
* - 如果为 `local`,则仅对本地图片 添加 width 和 height
|
|
238
|
+
* - 如果为 `all`,则对所有图片(即包括 本地 和 远程) 添加 width 和 height
|
|
239
|
+
*
|
|
240
|
+
* 图片在加载过程中如果比较慢,从加载到完成的过程会导致页面布局不稳定,导致内容闪烁等。
|
|
241
|
+
* 此功能通过给图片添加 `width` 和 `height` 属性来解决该问题。
|
|
242
|
+
*
|
|
243
|
+
* 请谨慎使用 `all` 选项,该选项会在构建阶段发起网络请求,尝试加载远程图片以获取图片尺寸信息,
|
|
244
|
+
* 这可能会导致 构建时间变得更长(幸运的是获取尺寸信息只需要加载图片 几 KB 的数据包,因此耗时不会过长)
|
|
245
|
+
*
|
|
246
|
+
* @default false
|
|
247
|
+
*/
|
|
248
|
+
imageSize?: boolean | 'local' | 'all';
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
interface ReplitTokenMeta extends SizeOptions {
|
|
252
|
+
title?: string;
|
|
253
|
+
source?: string;
|
|
254
|
+
theme?: string;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
interface VideoOptions {
|
|
258
|
+
bilibili?: boolean;
|
|
259
|
+
youtube?: boolean;
|
|
260
|
+
}
|
|
261
|
+
interface BilibiliTokenMeta extends SizeOptions {
|
|
262
|
+
title?: string;
|
|
263
|
+
bvid?: string;
|
|
264
|
+
aid?: string;
|
|
265
|
+
cid?: string;
|
|
266
|
+
autoplay?: boolean;
|
|
267
|
+
time?: string | number;
|
|
268
|
+
page?: number;
|
|
269
|
+
}
|
|
270
|
+
interface YoutubeTokenMeta extends SizeOptions {
|
|
271
|
+
title?: string;
|
|
272
|
+
id: string;
|
|
273
|
+
autoplay?: boolean;
|
|
274
|
+
loop?: boolean;
|
|
275
|
+
start?: string | number;
|
|
276
|
+
end?: string | number;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
interface ImgSize {
|
|
280
|
+
width: number;
|
|
281
|
+
height: number;
|
|
185
282
|
}
|
|
283
|
+
declare function resolveImageSize(app: App, url: string, remote?: boolean): Promise<ImgSize>;
|
|
186
284
|
|
|
187
285
|
declare function markdownPowerPlugin(options?: MarkdownPowerPluginOptions): Plugin;
|
|
188
286
|
|
|
189
|
-
export { type BilibiliTokenMeta, type CanIUseMode, type CanIUseOptions, type CanIUseTokenMeta, type CodeSandboxTokenMeta, type CodepenTokenMeta, type IconsOptions, type JSFiddleTokenMeta, type MarkdownPowerPluginOptions, type PDFEmbedType, type PDFOptions, type PDFTokenMeta, type PlotOptions, type ReplEditorData, type ReplOptions, type ReplitTokenMeta, type SizeOptions, type ThemeOptions, type VideoOptions, type YoutubeTokenMeta, markdownPowerPlugin };
|
|
287
|
+
export { type BilibiliTokenMeta, type CanIUseMode, type CanIUseOptions, type CanIUseTokenMeta, type CodeSandboxTokenMeta, type CodepenTokenMeta, type IconsOptions, type JSFiddleTokenMeta, type MarkdownPowerPluginOptions, type PDFEmbedType, type PDFOptions, type PDFTokenMeta, type PlotOptions, type ReplEditorData, type ReplOptions, type ReplitTokenMeta, type SizeOptions, type ThemeOptions, type VideoOptions, type YoutubeTokenMeta, markdownPowerPlugin, resolveImageSize };
|