vuepress-plugin-md-power 1.0.0-rc.153 → 1.0.0-rc.154
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/Plot.vue +47 -49
- package/lib/node/index.d.ts +9 -19
- package/lib/node/index.js +65 -17
- package/lib/shared/index.d.ts +9 -19
- package/package.json +26 -14
|
@@ -1,61 +1,46 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import type { PlotOptions } from '../../shared/index.js'
|
|
3
3
|
import { onClickOutside, useMediaQuery } from '@vueuse/core'
|
|
4
|
-
import { computed, ref,
|
|
4
|
+
import { computed, onMounted, ref, useTemplateRef } from 'vue'
|
|
5
5
|
import { usePageFrontmatter } from 'vuepress/client'
|
|
6
6
|
import { pluginOptions } from '../options.js'
|
|
7
7
|
|
|
8
|
-
const props = defineProps<
|
|
8
|
+
const props = defineProps<PlotOptions>()
|
|
9
9
|
|
|
10
10
|
const matter = usePageFrontmatter()
|
|
11
|
+
const isMobile = useMediaQuery('(max-width: 768px)')
|
|
11
12
|
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
|
|
13
|
+
const plot = computed(() => {
|
|
14
|
+
const global = typeof pluginOptions.plot === 'object' ? pluginOptions.plot : {}
|
|
15
|
+
const current = (typeof matter.value.plot === 'object' ? matter.value.plot : {}) as PlotOptions
|
|
15
16
|
return {
|
|
16
|
-
trigger: props.trigger
|
|
17
|
-
|
|
18
|
-
mask: props.mask || plot.mask,
|
|
17
|
+
trigger: isMobile.value ? 'click' : props.trigger ?? current.trigger ?? global.trigger ?? 'hover',
|
|
18
|
+
effect: props.effect ?? current.effect ?? global.effect ?? 'mask',
|
|
19
19
|
}
|
|
20
20
|
})
|
|
21
|
+
const active = ref(false)
|
|
22
|
+
const el = useTemplateRef<HTMLElement>('el')
|
|
23
|
+
const classes = ref<string[]>([])
|
|
21
24
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (typeof plot.color === 'string') {
|
|
29
|
-
style['--vp-c-plot-light'] = plot.color
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
style['--vp-c-plot-light'] = plot.color.light
|
|
33
|
-
style['--vp-c-plot-dark'] = plot.color.dark
|
|
34
|
-
}
|
|
25
|
+
onMounted(() => {
|
|
26
|
+
if (!el.value)
|
|
27
|
+
return
|
|
28
|
+
const classList = el.value.classList
|
|
29
|
+
if (!classList.contains('hover') && !classList.contains('click')) {
|
|
30
|
+
classes.value.push(plot.value.trigger)
|
|
35
31
|
}
|
|
36
|
-
if (
|
|
37
|
-
|
|
38
|
-
style['--vp-c-bg-plot-light'] = plot.mask
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
style['--vp-c-bg-plot-light'] = plot.mask.light
|
|
42
|
-
style['--vp-c-bg-plot-dark'] = plot.mask.dark
|
|
43
|
-
}
|
|
32
|
+
if (!classList.contains('mask') && !classList.contains('blur')) {
|
|
33
|
+
classes.value.push(plot.value.effect)
|
|
44
34
|
}
|
|
45
|
-
return style
|
|
46
35
|
})
|
|
47
36
|
|
|
48
|
-
const isMobile = useMediaQuery('(max-width: 768px)')
|
|
49
|
-
const active = ref(false)
|
|
50
|
-
const el = shallowRef<HTMLElement>()
|
|
51
|
-
|
|
52
37
|
onClickOutside(el, () => {
|
|
53
|
-
if (
|
|
38
|
+
if (plot.value.trigger === 'click' || el.value?.classList.contains('click'))
|
|
54
39
|
active.value = false
|
|
55
40
|
})
|
|
56
41
|
|
|
57
42
|
function onClick() {
|
|
58
|
-
if (
|
|
43
|
+
if (plot.value.trigger === 'click' || el.value?.classList.contains('click'))
|
|
59
44
|
active.value = !active.value
|
|
60
45
|
}
|
|
61
46
|
</script>
|
|
@@ -64,8 +49,7 @@ function onClick() {
|
|
|
64
49
|
<span
|
|
65
50
|
ref="el"
|
|
66
51
|
class="vp-plot"
|
|
67
|
-
:class="{
|
|
68
|
-
:style="styles"
|
|
52
|
+
:class="[{ active }, ...classes]"
|
|
69
53
|
@click="onClick"
|
|
70
54
|
>
|
|
71
55
|
<slot />
|
|
@@ -73,25 +57,39 @@ function onClick() {
|
|
|
73
57
|
</template>
|
|
74
58
|
|
|
75
59
|
<style>
|
|
60
|
+
:root {
|
|
61
|
+
--vp-plot-bg: var(--vp-c-text-1);
|
|
62
|
+
--vp-plot-c-text: var(--vp-c-neutral-inverse);
|
|
63
|
+
--vp-plot-blur: 0.2rem;
|
|
64
|
+
}
|
|
65
|
+
|
|
76
66
|
.vp-plot {
|
|
77
67
|
padding-right: 2px;
|
|
78
68
|
padding-left: 2px;
|
|
79
|
-
color: transparent;
|
|
80
|
-
background-color: var(--vp-c-bg-plot-light, #000);
|
|
81
|
-
transition: color ease 0.25s, background-color ease 0.25s;
|
|
82
69
|
}
|
|
83
70
|
|
|
84
|
-
|
|
85
|
-
|
|
71
|
+
.vp-plot.click {
|
|
72
|
+
cursor: pointer;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.vp-plot:where(.blur) {
|
|
76
|
+
filter: blur(var(--vp-plot-blur));
|
|
77
|
+
transition: filter var(--vp-t-color);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.vp-plot:where(.mask) {
|
|
81
|
+
color: transparent;
|
|
82
|
+
background-color: var(--vp-plot-bg);
|
|
83
|
+
transition: color var(--vp-t-color), background-color var(--vp-t-color);
|
|
86
84
|
}
|
|
87
85
|
|
|
88
|
-
.vp-plot.hover:hover,
|
|
89
|
-
.vp-plot.active {
|
|
90
|
-
|
|
86
|
+
.vp-plot:where(.blur.hover):hover,
|
|
87
|
+
.vp-plot:where(.blur).active {
|
|
88
|
+
filter: blur(0);
|
|
91
89
|
}
|
|
92
90
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
color: var(--vp-c-
|
|
91
|
+
.vp-plot:where(.mask.hover):hover,
|
|
92
|
+
.vp-plot:where(.mask).active {
|
|
93
|
+
color: var(--vp-plot-c-text);
|
|
96
94
|
}
|
|
97
95
|
</style>
|
package/lib/node/index.d.ts
CHANGED
|
@@ -186,32 +186,22 @@ interface PDFOptions {
|
|
|
186
186
|
}
|
|
187
187
|
//#endregion
|
|
188
188
|
//#region src/shared/plot.d.ts
|
|
189
|
+
/**
|
|
190
|
+
* 是否启用 `!! !!` markdown (该标记为非标准标记,脱离插件将不生效)
|
|
191
|
+
*/
|
|
189
192
|
interface PlotOptions {
|
|
190
|
-
/**
|
|
191
|
-
* 是否启用 `!! !!` markdown (该标记为非标准标记,脱离插件将不生效)
|
|
192
|
-
* @default true
|
|
193
|
-
*/
|
|
194
|
-
tag?: boolean;
|
|
195
|
-
/**
|
|
196
|
-
* 遮罩层颜色
|
|
197
|
-
*/
|
|
198
|
-
mask?: string | {
|
|
199
|
-
light: string;
|
|
200
|
-
dark: string;
|
|
201
|
-
};
|
|
202
|
-
/**
|
|
203
|
-
* 文本颜色
|
|
204
|
-
*/
|
|
205
|
-
color?: string | {
|
|
206
|
-
light: string;
|
|
207
|
-
dark: string;
|
|
208
|
-
};
|
|
209
193
|
/**
|
|
210
194
|
* 触发方式
|
|
211
195
|
*
|
|
212
196
|
* @default 'hover'
|
|
213
197
|
*/
|
|
214
198
|
trigger?: "hover" | "click";
|
|
199
|
+
/**
|
|
200
|
+
* 遮罩层效果
|
|
201
|
+
*
|
|
202
|
+
* @default 'mask'
|
|
203
|
+
*/
|
|
204
|
+
effect?: "mask" | "blur";
|
|
215
205
|
}
|
|
216
206
|
//#endregion
|
|
217
207
|
//#region src/shared/codeTree.d.ts
|
package/lib/node/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import imageSize from "image-size";
|
|
|
9
9
|
import { colors, fs, getDirname, logger, ora, path } from "vuepress/utils";
|
|
10
10
|
import path$1 from "node:path";
|
|
11
11
|
import { globSync } from "tinyglobby";
|
|
12
|
-
import { isLinkHttp as isLinkHttp$1, removeEndingSlash, removeLeadingSlash } from "vuepress/shared";
|
|
12
|
+
import { isLinkHttp as isLinkHttp$1, isLinkWithProtocol, removeEndingSlash, removeLeadingSlash } from "vuepress/shared";
|
|
13
13
|
import fs$1, { promises } from "node:fs";
|
|
14
14
|
import process from "node:process";
|
|
15
15
|
import container from "markdown-it-container";
|
|
@@ -1113,18 +1113,25 @@ function fetchImageSize(src) {
|
|
|
1113
1113
|
for await (const chunk of stream) {
|
|
1114
1114
|
chunks.push(chunk);
|
|
1115
1115
|
try {
|
|
1116
|
-
const { width
|
|
1117
|
-
if (width
|
|
1118
|
-
width
|
|
1119
|
-
height
|
|
1116
|
+
const { width, height } = imageSize(Buffer.concat(chunks));
|
|
1117
|
+
if (width && height) return resolve({
|
|
1118
|
+
width,
|
|
1119
|
+
height
|
|
1120
1120
|
});
|
|
1121
1121
|
} catch {}
|
|
1122
1122
|
}
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1123
|
+
try {
|
|
1124
|
+
const { width, height } = imageSize(Buffer.concat(chunks));
|
|
1125
|
+
resolve({
|
|
1126
|
+
width,
|
|
1127
|
+
height
|
|
1128
|
+
});
|
|
1129
|
+
} catch {
|
|
1130
|
+
resolve({
|
|
1131
|
+
width: 0,
|
|
1132
|
+
height: 0
|
|
1133
|
+
});
|
|
1134
|
+
}
|
|
1128
1135
|
}).on("error", () => resolve({
|
|
1129
1136
|
width: 0,
|
|
1130
1137
|
height: 0
|
|
@@ -3663,6 +3670,46 @@ function parseSource(source) {
|
|
|
3663
3670
|
}
|
|
3664
3671
|
}
|
|
3665
3672
|
|
|
3673
|
+
//#endregion
|
|
3674
|
+
//#region src/node/enhance/links.ts
|
|
3675
|
+
function linksPlugin(md) {
|
|
3676
|
+
const externalAttrs = {
|
|
3677
|
+
target: "_blank",
|
|
3678
|
+
rel: "noopener noreferrer"
|
|
3679
|
+
};
|
|
3680
|
+
let hasOpenInternalLink = false;
|
|
3681
|
+
const internalTag = "VPLink";
|
|
3682
|
+
function handleLinkOpen(tokens, idx) {
|
|
3683
|
+
hasOpenInternalLink = false;
|
|
3684
|
+
const token = tokens[idx];
|
|
3685
|
+
const hrefIndex = token.attrIndex("href");
|
|
3686
|
+
/* istanbul ignore if -- @preserve */
|
|
3687
|
+
if (hrefIndex < 0) return;
|
|
3688
|
+
const hrefAttr = token.attrs[hrefIndex];
|
|
3689
|
+
const hrefLink = hrefAttr[1];
|
|
3690
|
+
if (isLinkWithProtocol(hrefLink)) {
|
|
3691
|
+
Object.entries(externalAttrs).forEach(([key, val]) => {
|
|
3692
|
+
token.attrSet(key, val);
|
|
3693
|
+
});
|
|
3694
|
+
return;
|
|
3695
|
+
}
|
|
3696
|
+
if (hrefLink[0] === "#") return;
|
|
3697
|
+
hasOpenInternalLink = true;
|
|
3698
|
+
token.tag = internalTag;
|
|
3699
|
+
}
|
|
3700
|
+
md.renderer.rules.link_open = (tokens, idx, opts, env, self) => {
|
|
3701
|
+
handleLinkOpen(tokens, idx);
|
|
3702
|
+
return self.renderToken(tokens, idx, opts);
|
|
3703
|
+
};
|
|
3704
|
+
md.renderer.rules.link_close = (tokens, idx, opts, _env, self) => {
|
|
3705
|
+
if (hasOpenInternalLink) {
|
|
3706
|
+
hasOpenInternalLink = false;
|
|
3707
|
+
tokens[idx].tag = internalTag;
|
|
3708
|
+
}
|
|
3709
|
+
return self.renderToken(tokens, idx, opts);
|
|
3710
|
+
};
|
|
3711
|
+
}
|
|
3712
|
+
|
|
3666
3713
|
//#endregion
|
|
3667
3714
|
//#region src/node/icon/createIconRule.ts
|
|
3668
3715
|
function createIconRule([l1, l2, r1, r2], deprecated) {
|
|
@@ -4024,18 +4071,18 @@ const plotDef = (state, silent) => {
|
|
|
4024
4071
|
const content = state.src.slice(start + 2, state.pos);
|
|
4025
4072
|
state.posMax = state.pos;
|
|
4026
4073
|
state.pos = start + 2;
|
|
4027
|
-
const
|
|
4028
|
-
|
|
4029
|
-
|
|
4074
|
+
const openToken = state.push("plot_inline_open", "Plot", 1);
|
|
4075
|
+
openToken.markup = "!!";
|
|
4076
|
+
openToken.content = content;
|
|
4077
|
+
const contentToken = state.push("text", "", 0);
|
|
4078
|
+
contentToken.content = content;
|
|
4079
|
+
const closeToken = state.push("plot_inline_close", "Plot", -1);
|
|
4080
|
+
closeToken.markup = "!!";
|
|
4030
4081
|
state.pos = state.posMax + 2;
|
|
4031
4082
|
state.posMax = max;
|
|
4032
4083
|
return true;
|
|
4033
4084
|
};
|
|
4034
4085
|
const plotPlugin = (md) => {
|
|
4035
|
-
md.renderer.rules.plot_inline = (tokens, idx) => {
|
|
4036
|
-
const token = tokens[idx];
|
|
4037
|
-
return `<Plot>${token.content}</Plot>`;
|
|
4038
|
-
};
|
|
4039
4086
|
md.inline.ruler.before("emphasis", "plot", plotDef);
|
|
4040
4087
|
};
|
|
4041
4088
|
|
|
@@ -4224,6 +4271,7 @@ function markdownPowerPlugin(options = {}) {
|
|
|
4224
4271
|
]);
|
|
4225
4272
|
},
|
|
4226
4273
|
extendsMarkdown: async (md, app) => {
|
|
4274
|
+
linksPlugin(md);
|
|
4227
4275
|
docsTitlePlugin(md);
|
|
4228
4276
|
embedSyntaxPlugin(md, options);
|
|
4229
4277
|
inlineSyntaxPlugin(md, options);
|
package/lib/shared/index.d.ts
CHANGED
|
@@ -184,32 +184,22 @@ interface PDFOptions {
|
|
|
184
184
|
}
|
|
185
185
|
//#endregion
|
|
186
186
|
//#region src/shared/plot.d.ts
|
|
187
|
+
/**
|
|
188
|
+
* 是否启用 `!! !!` markdown (该标记为非标准标记,脱离插件将不生效)
|
|
189
|
+
*/
|
|
187
190
|
interface PlotOptions {
|
|
188
|
-
/**
|
|
189
|
-
* 是否启用 `!! !!` markdown (该标记为非标准标记,脱离插件将不生效)
|
|
190
|
-
* @default true
|
|
191
|
-
*/
|
|
192
|
-
tag?: boolean;
|
|
193
|
-
/**
|
|
194
|
-
* 遮罩层颜色
|
|
195
|
-
*/
|
|
196
|
-
mask?: string | {
|
|
197
|
-
light: string;
|
|
198
|
-
dark: string;
|
|
199
|
-
};
|
|
200
|
-
/**
|
|
201
|
-
* 文本颜色
|
|
202
|
-
*/
|
|
203
|
-
color?: string | {
|
|
204
|
-
light: string;
|
|
205
|
-
dark: string;
|
|
206
|
-
};
|
|
207
191
|
/**
|
|
208
192
|
* 触发方式
|
|
209
193
|
*
|
|
210
194
|
* @default 'hover'
|
|
211
195
|
*/
|
|
212
196
|
trigger?: "hover" | "click";
|
|
197
|
+
/**
|
|
198
|
+
* 遮罩层效果
|
|
199
|
+
*
|
|
200
|
+
* @default 'mask'
|
|
201
|
+
*/
|
|
202
|
+
effect?: "mask" | "blur";
|
|
213
203
|
}
|
|
214
204
|
//#endregion
|
|
215
205
|
//#region src/shared/codeTree.d.ts
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vuepress-plugin-md-power",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.0-rc.
|
|
4
|
+
"version": "1.0.0-rc.154",
|
|
5
5
|
"description": "The Plugin for VuePress 2 - markdown power",
|
|
6
6
|
"author": "pengzhanbo <volodymyr@foxmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"markdown-it": "^14.1.0",
|
|
40
40
|
"mpegts.js": "^1.7.3",
|
|
41
41
|
"pyodide": "^0.27.7",
|
|
42
|
-
"sass": "^1.89.
|
|
43
|
-
"sass-embedded": "^1.89.
|
|
42
|
+
"sass": "^1.89.2",
|
|
43
|
+
"sass-embedded": "^1.89.2",
|
|
44
44
|
"stylus": "^0.64.0",
|
|
45
45
|
"vuepress": "2.0.0-rc.23"
|
|
46
46
|
},
|
|
@@ -54,6 +54,9 @@
|
|
|
54
54
|
"hls.js": {
|
|
55
55
|
"optional": true
|
|
56
56
|
},
|
|
57
|
+
"less": {
|
|
58
|
+
"optional": true
|
|
59
|
+
},
|
|
57
60
|
"markdown-it": {
|
|
58
61
|
"optional": true
|
|
59
62
|
},
|
|
@@ -62,20 +65,29 @@
|
|
|
62
65
|
},
|
|
63
66
|
"pyodide": {
|
|
64
67
|
"optional": true
|
|
68
|
+
},
|
|
69
|
+
"sass": {
|
|
70
|
+
"optional": true
|
|
71
|
+
},
|
|
72
|
+
"sass-embedded": {
|
|
73
|
+
"optional": true
|
|
74
|
+
},
|
|
75
|
+
"stylus": {
|
|
76
|
+
"optional": true
|
|
65
77
|
}
|
|
66
78
|
},
|
|
67
79
|
"dependencies": {
|
|
68
|
-
"@mdit/plugin-attrs": "^0.
|
|
69
|
-
"@mdit/plugin-footnote": "^0.
|
|
70
|
-
"@mdit/plugin-mark": "^0.
|
|
71
|
-
"@mdit/plugin-sub": "^0.
|
|
72
|
-
"@mdit/plugin-sup": "^0.
|
|
73
|
-
"@mdit/plugin-tab": "^0.
|
|
74
|
-
"@mdit/plugin-tasklist": "^0.
|
|
80
|
+
"@mdit/plugin-attrs": "^0.23.1",
|
|
81
|
+
"@mdit/plugin-footnote": "^0.22.2",
|
|
82
|
+
"@mdit/plugin-mark": "^0.22.1",
|
|
83
|
+
"@mdit/plugin-sub": "^0.22.1",
|
|
84
|
+
"@mdit/plugin-sup": "^0.22.1",
|
|
85
|
+
"@mdit/plugin-tab": "^0.22.2",
|
|
86
|
+
"@mdit/plugin-tasklist": "^0.22.1",
|
|
75
87
|
"@pengzhanbo/utils": "^2.1.0",
|
|
76
|
-
"@vuepress/helper": "2.0.0-rc.
|
|
77
|
-
"@vueuse/core": "^13.
|
|
78
|
-
"chokidar": "
|
|
88
|
+
"@vuepress/helper": "2.0.0-rc.110",
|
|
89
|
+
"@vueuse/core": "^13.4.0",
|
|
90
|
+
"chokidar": "4.0.3",
|
|
79
91
|
"image-size": "^2.0.2",
|
|
80
92
|
"local-pkg": "^1.1.1",
|
|
81
93
|
"lru-cache": "^11.1.0",
|
|
@@ -85,7 +97,7 @@
|
|
|
85
97
|
"tinyglobby": "0.2.13",
|
|
86
98
|
"tm-grammars": "^1.23.26",
|
|
87
99
|
"tm-themes": "^1.10.6",
|
|
88
|
-
"vue": "^3.5.
|
|
100
|
+
"vue": "^3.5.17"
|
|
89
101
|
},
|
|
90
102
|
"devDependencies": {
|
|
91
103
|
"@types/markdown-it": "^14.1.2",
|