vuepress-plugin-md-power 1.0.0-rc.104 → 1.0.0-rc.106
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.
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import type { HighlighterCore } from 'shiki/core'
|
|
3
3
|
import editorData from '@internal/md-power/replEditorData'
|
|
4
4
|
import { createHighlighterCore } from 'shiki/core'
|
|
5
|
+
import { createOnigurumaEngine } from 'shiki/engine/oniguruma'
|
|
5
6
|
import { onMounted, onUnmounted, ref, shallowRef, watch } from 'vue'
|
|
6
7
|
import { resolveCodeInfo } from '../composables/codeRepl.js'
|
|
7
8
|
|
|
@@ -20,7 +21,7 @@ async function init() {
|
|
|
20
21
|
highlighter = await createHighlighterCore({
|
|
21
22
|
themes: 'light' in theme && 'dark' in theme ? [theme.light, theme.dark] : [theme],
|
|
22
23
|
langs: Object.keys(grammars).map(key => grammars[key]),
|
|
23
|
-
|
|
24
|
+
engine: createOnigurumaEngine(() => import('shiki/wasm')),
|
|
24
25
|
})
|
|
25
26
|
}
|
|
26
27
|
|
|
@@ -248,30 +248,30 @@ function onTabNavClick(index: number): void {
|
|
|
248
248
|
}
|
|
249
249
|
|
|
250
250
|
.vp-doc .hint-container.info .vp-tabs .vp-tabs-nav {
|
|
251
|
-
|
|
251
|
+
--vp-code-tab-bg: var(--vp-custom-block-info-code-bg);
|
|
252
252
|
}
|
|
253
253
|
|
|
254
254
|
.vp-doc .hint-container.note .vp-tabs .vp-tabs-nav {
|
|
255
|
-
|
|
255
|
+
--vp-code-tab-bg: var(--vp-custom-block-note-code-bg);
|
|
256
256
|
}
|
|
257
257
|
|
|
258
258
|
.vp-doc .hint-container.tip .vp-tabs .vp-tabs-nav {
|
|
259
|
-
|
|
259
|
+
--vp-code-tab-bg: var(--vp-custom-block-tip-code-bg);
|
|
260
260
|
}
|
|
261
261
|
|
|
262
262
|
.vp-doc .hint-container.warning .vp-tabs .vp-tabs-nav {
|
|
263
|
-
|
|
263
|
+
--vp-code-tab-bg: var(--vp-custom-block-warning-code-bg);
|
|
264
264
|
}
|
|
265
265
|
|
|
266
266
|
.vp-doc .hint-container.danger .vp-tabs .vp-tabs-nav {
|
|
267
|
-
|
|
267
|
+
--vp-code-tab-bg: var(--vp-custom-block-danger-code-bg);
|
|
268
268
|
}
|
|
269
269
|
|
|
270
270
|
.vp-doc .hint-container.caution .vp-tabs .vp-tabs-nav {
|
|
271
|
-
|
|
271
|
+
--vp-code-tab-bg: var(--vp-custom-block-caution-code-bg);
|
|
272
272
|
}
|
|
273
273
|
|
|
274
274
|
.vp-doc .hint-container.important .vp-tabs .vp-tabs-nav {
|
|
275
|
-
|
|
275
|
+
--vp-code-tab-bg: var(--vp-custom-block-important-code-bg);
|
|
276
276
|
}
|
|
277
277
|
</style>
|
package/lib/node/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import http from "node:https";
|
|
|
4
4
|
import { URL } from "node:url";
|
|
5
5
|
import { isLinkExternal, isLinkHttp } from "@vuepress/helper";
|
|
6
6
|
import imageSize from "image-size";
|
|
7
|
-
import { fs, path } from "vuepress/utils";
|
|
7
|
+
import { fs, logger, path } from "vuepress/utils";
|
|
8
8
|
|
|
9
9
|
// src/node/utils/resolveAttrs.ts
|
|
10
10
|
var RE_ATTR_VALUE = /(?:^|\s+)(?<attr>[\w-]+)(?:=\s*(?<quote>['"])(?<value>.+?)\k<quote>)?(?:\s+|$)/;
|
|
@@ -52,10 +52,14 @@ async function imageSizePlugin(app, md, type2 = false) {
|
|
|
52
52
|
if (!app.env.isBuild || !type2)
|
|
53
53
|
return;
|
|
54
54
|
if (type2 === "all") {
|
|
55
|
+
const start = performance.now();
|
|
55
56
|
try {
|
|
56
57
|
await scanRemoteImageSize(app);
|
|
57
58
|
} catch {
|
|
58
59
|
}
|
|
60
|
+
if (app.env.isDebug) {
|
|
61
|
+
logger.info(`[vuepress-plugin-md-power] imageSizePlugin: scan all images time spent: ${performance.now() - start}ms`);
|
|
62
|
+
}
|
|
59
63
|
}
|
|
60
64
|
const imageRule = md.renderer.rules.image;
|
|
61
65
|
md.renderer.rules.image = (tokens, idx, options, env, self) => {
|
|
@@ -1164,8 +1168,6 @@ var closeType = `container_${type}_close`;
|
|
|
1164
1168
|
var componentName = "FileTreeItem";
|
|
1165
1169
|
var itemOpen = "file_tree_item_open";
|
|
1166
1170
|
var itemClose = "file_tree_item_close";
|
|
1167
|
-
var RE_SIMPLE_ICON = /:simple-icon\b/;
|
|
1168
|
-
var RE_COLORED_ICON = /:colored-icon\b/;
|
|
1169
1171
|
function fileTreePlugin(md, options = {}) {
|
|
1170
1172
|
const getIcon = (filename, type2, mode) => {
|
|
1171
1173
|
mode ||= options.icon || "colored";
|
|
@@ -1175,7 +1177,7 @@ function fileTreePlugin(md, options = {}) {
|
|
|
1175
1177
|
};
|
|
1176
1178
|
const validate = (info) => info.trim().startsWith(type);
|
|
1177
1179
|
const render = (tokens, idx) => {
|
|
1178
|
-
const
|
|
1180
|
+
const { attrs: attrs2 } = resolveAttrs(tokens[idx].info.slice(type.length - 1));
|
|
1179
1181
|
if (tokens[idx].nesting === 1) {
|
|
1180
1182
|
const hasRes = [];
|
|
1181
1183
|
for (let i = idx + 1; !(tokens[i].nesting === -1 && tokens[i].type === closeType); ++i) {
|
|
@@ -1186,7 +1188,7 @@ function fileTreePlugin(md, options = {}) {
|
|
|
1186
1188
|
hasRes.push(token.level);
|
|
1187
1189
|
const [info, inline] = result;
|
|
1188
1190
|
const { filename, type: type2, expanded, empty } = info;
|
|
1189
|
-
const icon = getIcon(filename, type2,
|
|
1191
|
+
const icon = getIcon(filename, type2, attrs2.icon);
|
|
1190
1192
|
token.type = itemOpen;
|
|
1191
1193
|
token.tag = componentName;
|
|
1192
1194
|
token.attrSet("type", type2);
|
|
@@ -1203,7 +1205,7 @@ function fileTreePlugin(md, options = {}) {
|
|
|
1203
1205
|
}
|
|
1204
1206
|
}
|
|
1205
1207
|
}
|
|
1206
|
-
const title =
|
|
1208
|
+
const title = attrs2.title;
|
|
1207
1209
|
return `<div class="vp-file-tree">${title ? `<p class="vp-file-tree-title">${title}</p>` : ""}`;
|
|
1208
1210
|
} else {
|
|
1209
1211
|
return "</div>";
|
|
@@ -1211,18 +1213,6 @@ function fileTreePlugin(md, options = {}) {
|
|
|
1211
1213
|
};
|
|
1212
1214
|
md.use(container2, type, { validate, render });
|
|
1213
1215
|
}
|
|
1214
|
-
function getFileIconMode(info) {
|
|
1215
|
-
if (RE_SIMPLE_ICON.test(info))
|
|
1216
|
-
return "simple";
|
|
1217
|
-
if (RE_COLORED_ICON.test(info))
|
|
1218
|
-
return "colored";
|
|
1219
|
-
return void 0;
|
|
1220
|
-
}
|
|
1221
|
-
function resolveTitle(info) {
|
|
1222
|
-
info = info.trim().slice(type.length).trim();
|
|
1223
|
-
info = info.replace(RE_SIMPLE_ICON, "").replace(RE_COLORED_ICON, "");
|
|
1224
|
-
return info.trim();
|
|
1225
|
-
}
|
|
1226
1216
|
function resolveTreeNodeInfo(tokens, current, idx) {
|
|
1227
1217
|
let hasInline = false;
|
|
1228
1218
|
let hasChildren = false;
|
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.106",
|
|
5
5
|
"description": "The Plugin for VuePress 2 - markdown power",
|
|
6
6
|
"author": "pengzhanbo <volodymyr@foxmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"lib"
|
|
32
32
|
],
|
|
33
33
|
"peerDependencies": {
|
|
34
|
-
"vuepress": "2.0.0-rc.
|
|
34
|
+
"vuepress": "2.0.0-rc.17"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@mdit/plugin-attrs": "^0.13.1",
|
|
@@ -41,15 +41,15 @@
|
|
|
41
41
|
"@mdit/plugin-sup": "^0.13.1",
|
|
42
42
|
"@mdit/plugin-tab": "^0.13.2",
|
|
43
43
|
"@mdit/plugin-tasklist": "^0.13.1",
|
|
44
|
-
"@vuepress/helper": "2.0.0-rc.
|
|
44
|
+
"@vuepress/helper": "2.0.0-rc.52",
|
|
45
45
|
"@vueuse/core": "^11.1.0",
|
|
46
46
|
"image-size": "^1.1.1",
|
|
47
47
|
"markdown-it-container": "^4.0.0",
|
|
48
48
|
"nanoid": "^5.0.7",
|
|
49
|
-
"shiki": "^1.
|
|
50
|
-
"tm-grammars": "^1.17.
|
|
51
|
-
"tm-themes": "^1.8.
|
|
52
|
-
"vue": "^3.5.
|
|
49
|
+
"shiki": "^1.21.0",
|
|
50
|
+
"tm-grammars": "^1.17.28",
|
|
51
|
+
"tm-themes": "^1.8.6",
|
|
52
|
+
"vue": "^3.5.10"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@types/markdown-it": "^14.1.2"
|