vuepress-plugin-md-power 1.0.0-rc.136 → 1.0.0-rc.138
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/Abbreviation.vue +33 -4
- package/lib/client/components/Annotation.vue +12 -5
- package/lib/client/components/CodeEditor.vue +1 -0
- package/lib/client/components/VPCollapse.vue +31 -0
- package/lib/client/components/VPCollapseItem.vue +120 -0
- package/lib/client/components/VPDemoBasic.vue +55 -7
- package/lib/client/components/VPDemoNormal.vue +13 -5
- package/lib/client/components/VPTimeline.vue +52 -0
- package/lib/client/components/VPTimelineItem.vue +330 -0
- package/lib/client/options.d.ts +3 -1
- package/lib/client/options.js +8 -0
- package/lib/client/shim.d.ts +7 -0
- package/lib/client/styles/chat.css +129 -0
- package/lib/client/styles/demo.css +11 -0
- package/lib/node/index.d.ts +50 -0
- package/lib/node/index.js +330 -29
- package/lib/shared/index.d.ts +50 -0
- package/package.json +12 -11
package/lib/node/index.js
CHANGED
|
@@ -1158,14 +1158,14 @@ import { isPlainObject as isPlainObject2 } from "@vuepress/helper";
|
|
|
1158
1158
|
|
|
1159
1159
|
// src/node/container/createContainer.ts
|
|
1160
1160
|
import container from "markdown-it-container";
|
|
1161
|
-
function createContainerPlugin(md, type2,
|
|
1162
|
-
const render = (tokens, index) => {
|
|
1161
|
+
function createContainerPlugin(md, type2, { before, after } = {}) {
|
|
1162
|
+
const render = (tokens, index, options, env) => {
|
|
1163
1163
|
const token = tokens[index];
|
|
1164
1164
|
const info = token.info.trim().slice(type2.length).trim() || "";
|
|
1165
1165
|
if (token.nesting === 1) {
|
|
1166
|
-
return
|
|
1166
|
+
return before?.(info, tokens, index, options, env) || `<div class="custom-container ${type2}">`;
|
|
1167
1167
|
} else {
|
|
1168
|
-
return
|
|
1168
|
+
return after?.(info, tokens, index, options, env) || "</div>";
|
|
1169
1169
|
}
|
|
1170
1170
|
};
|
|
1171
1171
|
md.use(container, type2, { render });
|
|
@@ -1209,6 +1209,186 @@ function cardPlugin(md) {
|
|
|
1209
1209
|
});
|
|
1210
1210
|
}
|
|
1211
1211
|
|
|
1212
|
+
// src/node/container/chat.ts
|
|
1213
|
+
var chatPlugin = (md) => {
|
|
1214
|
+
md.block.ruler.before("fence", "chat_def", chatDef);
|
|
1215
|
+
md.renderer.rules.chat_container = (tokens, idx, _, env) => {
|
|
1216
|
+
const { meta, content } = tokens[idx];
|
|
1217
|
+
const { title } = meta;
|
|
1218
|
+
const messages = parseChatContent(content);
|
|
1219
|
+
return `<div class="vp-chat">
|
|
1220
|
+
<div class="vp-chat-header">
|
|
1221
|
+
<p class="vp-chat-title">${title || "Chat"}</p>
|
|
1222
|
+
</div>
|
|
1223
|
+
<div class="vp-chat-content">
|
|
1224
|
+
${chatMessagesRender(md, env, messages)}
|
|
1225
|
+
</div>
|
|
1226
|
+
</div>`;
|
|
1227
|
+
};
|
|
1228
|
+
};
|
|
1229
|
+
function chatDef(state, startLine, endLine, silent) {
|
|
1230
|
+
const start = state.bMarks[startLine] + state.tShift[startLine];
|
|
1231
|
+
const max = state.eMarks[startLine];
|
|
1232
|
+
let pos = start;
|
|
1233
|
+
if (state.src.slice(pos, pos + 3) !== ":::")
|
|
1234
|
+
return false;
|
|
1235
|
+
pos += 3;
|
|
1236
|
+
const info = state.src.slice(start + 3, max).trim();
|
|
1237
|
+
if (!info.startsWith("chat"))
|
|
1238
|
+
return false;
|
|
1239
|
+
if (silent)
|
|
1240
|
+
return true;
|
|
1241
|
+
let line = startLine;
|
|
1242
|
+
let content = "";
|
|
1243
|
+
while (++line < endLine) {
|
|
1244
|
+
if (state.src.slice(state.bMarks[line], state.eMarks[line]).trim() === ":::") {
|
|
1245
|
+
break;
|
|
1246
|
+
}
|
|
1247
|
+
content += `${state.src.slice(state.bMarks[line], state.eMarks[line])}
|
|
1248
|
+
`;
|
|
1249
|
+
}
|
|
1250
|
+
const token = state.push("chat_container", "", 0);
|
|
1251
|
+
token.meta = resolveAttrs(info).attrs;
|
|
1252
|
+
token.content = content;
|
|
1253
|
+
token.markup = "::: chat";
|
|
1254
|
+
token.map = [startLine, line + 1];
|
|
1255
|
+
state.line = line + 1;
|
|
1256
|
+
return true;
|
|
1257
|
+
}
|
|
1258
|
+
function chatMessagesRender(md, env, messages) {
|
|
1259
|
+
let currentDate = "";
|
|
1260
|
+
return messages.map(({ sender, username, date, content }) => {
|
|
1261
|
+
let messageContent = "";
|
|
1262
|
+
if (!currentDate || currentDate !== date) {
|
|
1263
|
+
currentDate = date;
|
|
1264
|
+
messageContent += `<div class="vp-chat-date"><span>${currentDate}</span></div>
|
|
1265
|
+
`;
|
|
1266
|
+
}
|
|
1267
|
+
messageContent += `<div class="vp-chat-message ${sender}">
|
|
1268
|
+
<div class="vp-chat-message-body"> ${sender === "user" ? `
|
|
1269
|
+
<p class="vp-chat-username">${username}</p>` : ""}
|
|
1270
|
+
<div class="message-content">
|
|
1271
|
+
${md.render(content.join("\n"), cleanMarkdownEnv(env)).trim()}
|
|
1272
|
+
</div>
|
|
1273
|
+
</div>
|
|
1274
|
+
</div>`;
|
|
1275
|
+
return messageContent;
|
|
1276
|
+
}).join("\n");
|
|
1277
|
+
}
|
|
1278
|
+
function parseChatContent(content) {
|
|
1279
|
+
const lines = content.split("\n");
|
|
1280
|
+
const messages = [];
|
|
1281
|
+
let currentDate = "";
|
|
1282
|
+
let message;
|
|
1283
|
+
for (const line of lines) {
|
|
1284
|
+
const lineStr = line.trim();
|
|
1285
|
+
if (lineStr.startsWith("{:") && lineStr.endsWith("}")) {
|
|
1286
|
+
currentDate = lineStr.slice(2, -1).trim();
|
|
1287
|
+
continue;
|
|
1288
|
+
}
|
|
1289
|
+
if (lineStr.startsWith("{") && lineStr.endsWith("}")) {
|
|
1290
|
+
const username = lineStr.slice(1, -1).trim();
|
|
1291
|
+
message = {
|
|
1292
|
+
sender: username === "." ? "self" : "user",
|
|
1293
|
+
username,
|
|
1294
|
+
date: currentDate,
|
|
1295
|
+
content: []
|
|
1296
|
+
};
|
|
1297
|
+
messages.push(message);
|
|
1298
|
+
continue;
|
|
1299
|
+
}
|
|
1300
|
+
if (message?.sender) {
|
|
1301
|
+
message.content.push(line);
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1304
|
+
return messages;
|
|
1305
|
+
}
|
|
1306
|
+
|
|
1307
|
+
// src/node/container/collapse.ts
|
|
1308
|
+
function collapsePlugin(md) {
|
|
1309
|
+
createContainerPlugin(md, "collapse", {
|
|
1310
|
+
before: (info, tokens, index) => {
|
|
1311
|
+
const { attrs: attrs2 } = resolveAttrs(info);
|
|
1312
|
+
const idx = parseCollapse(tokens, index, attrs2);
|
|
1313
|
+
const { accordion } = attrs2;
|
|
1314
|
+
return `<VPCollapse${accordion ? " accordion" : ""}${idx !== void 0 ? ` :index="${idx}"` : ""}>`;
|
|
1315
|
+
},
|
|
1316
|
+
after: () => `</VPCollapse>`
|
|
1317
|
+
});
|
|
1318
|
+
md.renderer.rules.collapse_item_open = (tokens, idx) => {
|
|
1319
|
+
const token = tokens[idx];
|
|
1320
|
+
const { expand, index } = token.meta;
|
|
1321
|
+
return `<VPCollapseItem${expand ? " expand" : ""}${` :index="${index}"`}>`;
|
|
1322
|
+
};
|
|
1323
|
+
md.renderer.rules.collapse_item_close = () => "</VPCollapseItem>";
|
|
1324
|
+
md.renderer.rules.collapse_item_title_open = () => "<template #title>";
|
|
1325
|
+
md.renderer.rules.collapse_item_title_close = () => "</template>";
|
|
1326
|
+
}
|
|
1327
|
+
function parseCollapse(tokens, index, attrs2) {
|
|
1328
|
+
const listStack = [];
|
|
1329
|
+
let idx = -1;
|
|
1330
|
+
let defaultIndex;
|
|
1331
|
+
let hashExpand = false;
|
|
1332
|
+
for (let i = index + 1; i < tokens.length; i++) {
|
|
1333
|
+
const token = tokens[i];
|
|
1334
|
+
if (token.type === "container_collapse_close") {
|
|
1335
|
+
break;
|
|
1336
|
+
}
|
|
1337
|
+
if (token.type === "bullet_list_open") {
|
|
1338
|
+
listStack.push(0);
|
|
1339
|
+
if (listStack.length === 1)
|
|
1340
|
+
token.hidden = true;
|
|
1341
|
+
} else if (token.type === "bullet_list_close") {
|
|
1342
|
+
listStack.pop();
|
|
1343
|
+
if (listStack.length === 0)
|
|
1344
|
+
token.hidden = true;
|
|
1345
|
+
} else if (token.type === "list_item_open") {
|
|
1346
|
+
const currentLevel = listStack.length;
|
|
1347
|
+
if (currentLevel === 1) {
|
|
1348
|
+
token.type = "collapse_item_open";
|
|
1349
|
+
tokens[i + 1].type = "collapse_item_title_open";
|
|
1350
|
+
tokens[i + 3].type = "collapse_item_title_close";
|
|
1351
|
+
idx++;
|
|
1352
|
+
const inlineToken = tokens[i + 2];
|
|
1353
|
+
const firstToken = inlineToken.children[0];
|
|
1354
|
+
let flag = "";
|
|
1355
|
+
let expand;
|
|
1356
|
+
if (firstToken.type === "text") {
|
|
1357
|
+
firstToken.content = firstToken.content.trim().replace(/^:[+\-]\s*/, (match) => {
|
|
1358
|
+
flag = match.trim();
|
|
1359
|
+
return "";
|
|
1360
|
+
});
|
|
1361
|
+
}
|
|
1362
|
+
if (attrs2.accordion) {
|
|
1363
|
+
if (!hashExpand && flag === ":+") {
|
|
1364
|
+
expand = hashExpand = true;
|
|
1365
|
+
defaultIndex = idx;
|
|
1366
|
+
}
|
|
1367
|
+
} else if (flag === ":+") {
|
|
1368
|
+
expand = true;
|
|
1369
|
+
} else if (flag === ":-") {
|
|
1370
|
+
expand = false;
|
|
1371
|
+
} else {
|
|
1372
|
+
expand = !!attrs2.expand;
|
|
1373
|
+
}
|
|
1374
|
+
token.meta = {
|
|
1375
|
+
index: idx,
|
|
1376
|
+
expand
|
|
1377
|
+
};
|
|
1378
|
+
}
|
|
1379
|
+
} else if (token.type === "list_item_close") {
|
|
1380
|
+
const currentLevel = listStack.length;
|
|
1381
|
+
if (currentLevel === 1) {
|
|
1382
|
+
token.type = "collapse_item_close";
|
|
1383
|
+
}
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1386
|
+
if (attrs2.accordion && attrs2.expand && !hashExpand) {
|
|
1387
|
+
defaultIndex = 0;
|
|
1388
|
+
}
|
|
1389
|
+
return defaultIndex;
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1212
1392
|
// src/node/container/demoWrapper.ts
|
|
1213
1393
|
function demoWrapperPlugin(md) {
|
|
1214
1394
|
createContainerPlugin(md, "demo-wrapper", {
|
|
@@ -1383,7 +1563,7 @@ function updateInlineToken(inline, info, icon) {
|
|
|
1383
1563
|
import { promises as fs2 } from "node:fs";
|
|
1384
1564
|
import { resolveModule } from "local-pkg";
|
|
1385
1565
|
import container3 from "markdown-it-container";
|
|
1386
|
-
import { path as path2 } from "vuepress/utils";
|
|
1566
|
+
import { colors, logger as logger2, path as path2 } from "vuepress/utils";
|
|
1387
1567
|
var RE_INFO = /^(#editable)?(.*)$/;
|
|
1388
1568
|
function createReplContainer(md, lang) {
|
|
1389
1569
|
const type2 = `${lang}-repl`;
|
|
@@ -1416,24 +1596,28 @@ async function langReplPlugin(app, md, {
|
|
|
1416
1596
|
}
|
|
1417
1597
|
theme ??= { light: "github-light", dark: "github-dark" };
|
|
1418
1598
|
const data = { grammars: {} };
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1599
|
+
try {
|
|
1600
|
+
const themesPath = path2.dirname(resolveModule("tm-themes"));
|
|
1601
|
+
const grammarsPath = path2.dirname(resolveModule("tm-grammars"));
|
|
1602
|
+
const readTheme = (theme2) => read(path2.join(themesPath, "themes", `${theme2}.json`));
|
|
1603
|
+
const readGrammar = (grammar) => read(path2.join(grammarsPath, "grammars", `${grammar}.json`));
|
|
1604
|
+
if (typeof theme === "string") {
|
|
1605
|
+
data.theme = await readTheme(theme);
|
|
1606
|
+
} else {
|
|
1607
|
+
data.theme = await Promise.all([
|
|
1608
|
+
readTheme(theme.light),
|
|
1609
|
+
readTheme(theme.dark)
|
|
1610
|
+
]).then(([light, dark]) => ({ light, dark }));
|
|
1611
|
+
}
|
|
1612
|
+
if (kotlin)
|
|
1613
|
+
data.grammars.kotlin = await readGrammar("kotlin");
|
|
1614
|
+
if (go)
|
|
1615
|
+
data.grammars.go = await readGrammar("go");
|
|
1616
|
+
if (rust)
|
|
1617
|
+
data.grammars.rust = await readGrammar("rust");
|
|
1618
|
+
} catch {
|
|
1619
|
+
logger2.error("[vuepress-plugin-md-power]", `Failed to load packages: ${colors.green("tm-themes")}, ${colors.green("tm-grammars")}, Please install them manually.`);
|
|
1620
|
+
}
|
|
1437
1621
|
await app.writeTemp(
|
|
1438
1622
|
"internal/md-power/replEditorData.js",
|
|
1439
1623
|
`export default ${JSON.stringify(data, null, 2)}`
|
|
@@ -1823,6 +2007,99 @@ ${titles.map(
|
|
|
1823
2007
|
});
|
|
1824
2008
|
};
|
|
1825
2009
|
|
|
2010
|
+
// src/node/container/timeline.ts
|
|
2011
|
+
import { isEmptyObject } from "@pengzhanbo/utils";
|
|
2012
|
+
var RE_KEY = /(\w+)=\s*/;
|
|
2013
|
+
var RE_SEARCH_KEY = /\s+\w+=\s*|$/;
|
|
2014
|
+
var RE_CLEAN_VALUE = /(?<quote>["'])(.*?)(\k<quote>)/;
|
|
2015
|
+
function timelinePlugin(md) {
|
|
2016
|
+
createContainerPlugin(md, "timeline", {
|
|
2017
|
+
before(info, tokens, index) {
|
|
2018
|
+
parseTimeline(tokens, index);
|
|
2019
|
+
const { attrs: attrs2 } = resolveAttrs(info);
|
|
2020
|
+
const { horizontal, card, placement, line } = attrs2;
|
|
2021
|
+
return `<VPTimeline${horizontal ? " horizontal" : ""}${card ? " card" : ' :card="undefined"'}${placement ? ` placement="${placement}"` : ""}${line ? ` line="${line}"` : ""}>`;
|
|
2022
|
+
},
|
|
2023
|
+
after: () => "</VPTimeline>"
|
|
2024
|
+
});
|
|
2025
|
+
md.renderer.rules.timeline_item_open = (tokens, idx) => {
|
|
2026
|
+
const token = tokens[idx];
|
|
2027
|
+
const { time, type: type2, icon, color, line, card, placement } = token.meta;
|
|
2028
|
+
return `<VPTimelineItem${time ? ` time="${time}"` : ""}${type2 ? ` type="${type2}"` : ""}${color ? ` color="${color}"` : ""}${line ? ` line="${line}"` : ""}${icon ? ` icon="${icon}"` : ""}${card === "true" ? " card" : card === "false" ? "" : ' :card="undefined"'}${placement ? ` placement="${placement}"` : ""}>${icon ? `<template #icon><VPIcon name="${icon}"/></template>` : ""}`;
|
|
2029
|
+
};
|
|
2030
|
+
md.renderer.rules.timeline_item_close = () => "</VPTimelineItem>";
|
|
2031
|
+
md.renderer.rules.timeline_item_title_open = () => "<template #title>";
|
|
2032
|
+
md.renderer.rules.timeline_item_title_close = () => "</template>";
|
|
2033
|
+
}
|
|
2034
|
+
function parseTimeline(tokens, index) {
|
|
2035
|
+
const listStack = [];
|
|
2036
|
+
for (let i = index + 1; i < tokens.length; i++) {
|
|
2037
|
+
const token = tokens[i];
|
|
2038
|
+
if (token.type === "container_timeline_close") {
|
|
2039
|
+
break;
|
|
2040
|
+
}
|
|
2041
|
+
if (token.type === "bullet_list_open") {
|
|
2042
|
+
listStack.push(0);
|
|
2043
|
+
if (listStack.length === 1)
|
|
2044
|
+
token.hidden = true;
|
|
2045
|
+
} else if (token.type === "bullet_list_close") {
|
|
2046
|
+
listStack.pop();
|
|
2047
|
+
if (listStack.length === 0)
|
|
2048
|
+
token.hidden = true;
|
|
2049
|
+
} else if (token.type === "list_item_open") {
|
|
2050
|
+
const currentLevel = listStack.length;
|
|
2051
|
+
if (currentLevel === 1) {
|
|
2052
|
+
token.type = "timeline_item_open";
|
|
2053
|
+
tokens[i + 1].type = "timeline_item_title_open";
|
|
2054
|
+
tokens[i + 3].type = "timeline_item_title_close";
|
|
2055
|
+
const inlineToken = tokens[i + 2];
|
|
2056
|
+
const softbreakIndex = inlineToken.children.findLastIndex(
|
|
2057
|
+
(token2) => token2.type === "softbreak"
|
|
2058
|
+
);
|
|
2059
|
+
if (softbreakIndex !== -1) {
|
|
2060
|
+
const lastToken = inlineToken.children[inlineToken.children.length - 1];
|
|
2061
|
+
token.meta = extractTimelineAttributes(lastToken.content.trim());
|
|
2062
|
+
if (!isEmptyObject(token.meta)) {
|
|
2063
|
+
inlineToken.children = inlineToken.children.slice(0, softbreakIndex);
|
|
2064
|
+
}
|
|
2065
|
+
} else {
|
|
2066
|
+
token.meta = {};
|
|
2067
|
+
}
|
|
2068
|
+
}
|
|
2069
|
+
} else if (token.type === "list_item_close") {
|
|
2070
|
+
const currentLevel = listStack.length;
|
|
2071
|
+
if (currentLevel === 1) {
|
|
2072
|
+
token.type = "timeline_item_close";
|
|
2073
|
+
}
|
|
2074
|
+
}
|
|
2075
|
+
}
|
|
2076
|
+
}
|
|
2077
|
+
function extractTimelineAttributes(rawText) {
|
|
2078
|
+
const attrKeys = ["time", "type", "icon", "line", "color", "card", "placement"];
|
|
2079
|
+
const attrs2 = {};
|
|
2080
|
+
let buffer = rawText.trim();
|
|
2081
|
+
while (buffer.length) {
|
|
2082
|
+
const keyMatch = buffer.match(RE_KEY);
|
|
2083
|
+
if (!keyMatch) {
|
|
2084
|
+
break;
|
|
2085
|
+
}
|
|
2086
|
+
const matchedKey = keyMatch[1].toLowerCase();
|
|
2087
|
+
if (!attrKeys.includes(matchedKey)) {
|
|
2088
|
+
break;
|
|
2089
|
+
}
|
|
2090
|
+
const keyStart = keyMatch.index;
|
|
2091
|
+
const keyEnd = keyStart + keyMatch[0].length;
|
|
2092
|
+
buffer = buffer.slice(keyEnd);
|
|
2093
|
+
let valueEnd = buffer.search(RE_SEARCH_KEY);
|
|
2094
|
+
if (valueEnd === -1)
|
|
2095
|
+
valueEnd = buffer.length;
|
|
2096
|
+
const value = buffer.slice(0, valueEnd).trim();
|
|
2097
|
+
attrs2[matchedKey] = value.replace(RE_CLEAN_VALUE, "$2");
|
|
2098
|
+
buffer = buffer.slice(valueEnd);
|
|
2099
|
+
}
|
|
2100
|
+
return attrs2;
|
|
2101
|
+
}
|
|
2102
|
+
|
|
1826
2103
|
// src/node/container/index.ts
|
|
1827
2104
|
async function containerPlugin(app, md, options) {
|
|
1828
2105
|
alignPlugin(md);
|
|
@@ -1839,6 +2116,12 @@ async function containerPlugin(app, md, options) {
|
|
|
1839
2116
|
if (options.fileTree) {
|
|
1840
2117
|
fileTreePlugin(md, isPlainObject2(options.fileTree) ? options.fileTree : {});
|
|
1841
2118
|
}
|
|
2119
|
+
if (options.timeline)
|
|
2120
|
+
timelinePlugin(md);
|
|
2121
|
+
if (options.collapse)
|
|
2122
|
+
collapsePlugin(md);
|
|
2123
|
+
if (options.chat)
|
|
2124
|
+
chatPlugin(md);
|
|
1842
2125
|
}
|
|
1843
2126
|
|
|
1844
2127
|
// src/node/demo/demo.ts
|
|
@@ -2402,7 +2685,7 @@ var vueContainerRender = {
|
|
|
2402
2685
|
insertSetupScript(style, env);
|
|
2403
2686
|
}
|
|
2404
2687
|
}
|
|
2405
|
-
return `<VPDemoBasic${title ? ` title="${title}"` : ""}${desc ? ` desc="${desc}"` : ""}${expanded ? " expanded" : ""}>
|
|
2688
|
+
return `<VPDemoBasic type="vue"${title ? ` title="${title}"` : ""}${desc ? ` desc="${desc}"` : ""}${expanded ? " expanded" : ""}>
|
|
2406
2689
|
<${componentName2} />
|
|
2407
2690
|
<template #code>
|
|
2408
2691
|
`;
|
|
@@ -2785,7 +3068,7 @@ var pdfPlugin = (md) => {
|
|
|
2785
3068
|
|
|
2786
3069
|
// src/node/embed/video/artPlayer.ts
|
|
2787
3070
|
import { isPackageExists as isPackageExists2 } from "local-pkg";
|
|
2788
|
-
import { colors } from "vuepress/utils";
|
|
3071
|
+
import { colors as colors2 } from "vuepress/utils";
|
|
2789
3072
|
var installed = {
|
|
2790
3073
|
dashjs: isPackageExists2("dashjs"),
|
|
2791
3074
|
hlsjs: isPackageExists2("hls.js"),
|
|
@@ -2841,10 +3124,10 @@ function checkSupportType(type2) {
|
|
|
2841
3124
|
break;
|
|
2842
3125
|
}
|
|
2843
3126
|
if (name) {
|
|
2844
|
-
console.warn(`${
|
|
3127
|
+
console.warn(`${colors2.yellow("[vuepress-plugin-md-power] artPlayer: ")} ${colors2.cyan(name)} is not installed, please install it via npm or yarn or pnpm`);
|
|
2845
3128
|
}
|
|
2846
3129
|
} else {
|
|
2847
|
-
console.warn(`${
|
|
3130
|
+
console.warn(`${colors2.yellow("[vuepress-plugin-md-power] artPlayer: ")} unsupported video type: ${colors2.cyan(type2)}`);
|
|
2848
3131
|
}
|
|
2849
3132
|
}
|
|
2850
3133
|
|
|
@@ -2905,6 +3188,7 @@ var bilibiliPlugin = (md) => {
|
|
|
2905
3188
|
params.set("t", meta.time.toString());
|
|
2906
3189
|
}
|
|
2907
3190
|
params.set("autoplay", meta.autoplay ? "1" : "0");
|
|
3191
|
+
params.set("high_quality", "1");
|
|
2908
3192
|
const source = `${BILIBILI_LINK}?${params.toString()}`;
|
|
2909
3193
|
return `<VideoBilibili src="${source}" width="${meta.width}" height="${meta.height}" ratio="${meta.ratio}" title="${meta.title}" />`;
|
|
2910
3194
|
}
|
|
@@ -3132,7 +3416,9 @@ var abbrPlugin = (md) => {
|
|
|
3132
3416
|
md.core.ruler.after("linkify", "abbr_replace", abbrReplace);
|
|
3133
3417
|
md.renderer.rules.abbreviation = (tokens, idx, _, env) => {
|
|
3134
3418
|
const { content, info } = tokens[idx];
|
|
3135
|
-
|
|
3419
|
+
const rendered = md.renderInline(info, cleanMarkdownEnv(env));
|
|
3420
|
+
const label = rendered.replace(/<[^>]*>/g, "");
|
|
3421
|
+
return `<Abbreviation aria-label="${label}">${content}${info ? `<template #tooltip>${rendered}</template>` : ""}</Abbreviation>`;
|
|
3136
3422
|
};
|
|
3137
3423
|
};
|
|
3138
3424
|
|
|
@@ -3428,6 +3714,21 @@ async function prepareConfigFile(app, options) {
|
|
|
3428
3714
|
imports.add(`import Abbreviation from '${CLIENT_FOLDER}components/Abbreviation.vue'`);
|
|
3429
3715
|
enhances.add(`app.component('Abbreviation', Abbreviation)`);
|
|
3430
3716
|
}
|
|
3717
|
+
if (options.timeline) {
|
|
3718
|
+
imports.add(`import VPTimeline from '${CLIENT_FOLDER}components/VPTimeline.vue'`);
|
|
3719
|
+
imports.add(`import VPTimelineItem from '${CLIENT_FOLDER}components/VPTimelineItem.vue'`);
|
|
3720
|
+
enhances.add(`app.component('VPTimeline', VPTimeline)`);
|
|
3721
|
+
enhances.add(`app.component('VPTimelineItem', VPTimelineItem)`);
|
|
3722
|
+
}
|
|
3723
|
+
if (options.collapse) {
|
|
3724
|
+
imports.add(`import VPCollapse from '${CLIENT_FOLDER}components/VPCollapse.vue'`);
|
|
3725
|
+
imports.add(`import VPCollapseItem from '${CLIENT_FOLDER}components/VPCollapseItem.vue'`);
|
|
3726
|
+
enhances.add(`app.component('VPCollapse', VPCollapse)`);
|
|
3727
|
+
enhances.add(`app.component('VPCollapseItem', VPCollapseItem)`);
|
|
3728
|
+
}
|
|
3729
|
+
if (options.chat) {
|
|
3730
|
+
imports.add(`import '${CLIENT_FOLDER}styles/chat.css'`);
|
|
3731
|
+
}
|
|
3431
3732
|
return app.writeTemp(
|
|
3432
3733
|
"md-power/config.js",
|
|
3433
3734
|
`import { defineClientConfig } from 'vuepress/client'
|
|
@@ -3501,5 +3802,5 @@ export {
|
|
|
3501
3802
|
resolveImageSize
|
|
3502
3803
|
};
|
|
3503
3804
|
/* istanbul ignore if -- @preserve */
|
|
3504
|
-
/* istanbul ignore else -- @preserve */
|
|
3505
3805
|
/* istanbul ignore next -- @preserve */
|
|
3806
|
+
/* istanbul ignore else -- @preserve */
|
package/lib/shared/index.d.ts
CHANGED
|
@@ -217,6 +217,56 @@ interface MarkdownPowerPluginOptions {
|
|
|
217
217
|
* @default false
|
|
218
218
|
*/
|
|
219
219
|
plot?: boolean | PlotOptions;
|
|
220
|
+
/**
|
|
221
|
+
* 是否启用 timeline 语法
|
|
222
|
+
*
|
|
223
|
+
* ```md
|
|
224
|
+
* ::: timeline
|
|
225
|
+
* - title
|
|
226
|
+
* time="Q1" icon="ri:clockwise-line" line="dashed" type="warning" color="red"
|
|
227
|
+
*
|
|
228
|
+
* xxx
|
|
229
|
+
* :::
|
|
230
|
+
* ```
|
|
231
|
+
*
|
|
232
|
+
* @default false
|
|
233
|
+
*/
|
|
234
|
+
timeline?: boolean;
|
|
235
|
+
/**
|
|
236
|
+
* 是否启用 collapse 折叠面板 语法
|
|
237
|
+
*
|
|
238
|
+
* ```md
|
|
239
|
+
* ::: collapse accordion
|
|
240
|
+
* - + title
|
|
241
|
+
*
|
|
242
|
+
* content
|
|
243
|
+
*
|
|
244
|
+
* - - title
|
|
245
|
+
*
|
|
246
|
+
* content
|
|
247
|
+
* :::
|
|
248
|
+
* ```
|
|
249
|
+
*
|
|
250
|
+
* @default false
|
|
251
|
+
*/
|
|
252
|
+
collapse?: boolean;
|
|
253
|
+
/**
|
|
254
|
+
* 是否启用 chat 容器 语法
|
|
255
|
+
*
|
|
256
|
+
* ```md
|
|
257
|
+
* ::: chat
|
|
258
|
+
* {:date}
|
|
259
|
+
*
|
|
260
|
+
* {user}
|
|
261
|
+
* message
|
|
262
|
+
*
|
|
263
|
+
* {.}
|
|
264
|
+
* message
|
|
265
|
+
* :::
|
|
266
|
+
* ```
|
|
267
|
+
* @default false
|
|
268
|
+
*/
|
|
269
|
+
chat?: boolean;
|
|
220
270
|
/**
|
|
221
271
|
* 是否启用 bilibili 视频嵌入
|
|
222
272
|
*
|
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.138",
|
|
5
5
|
"description": "The Plugin for VuePress 2 - markdown power",
|
|
6
6
|
"author": "pengzhanbo <volodymyr@foxmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -33,13 +33,13 @@
|
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"artplayer": "^5.2.2",
|
|
35
35
|
"dashjs": "^5.0.0",
|
|
36
|
-
"esbuild": "^0.25.
|
|
37
|
-
"hls.js": "^1.
|
|
36
|
+
"esbuild": "^0.25.2",
|
|
37
|
+
"hls.js": "^1.6.0",
|
|
38
38
|
"less": "^4.2.2",
|
|
39
39
|
"markdown-it": "^14.1.0",
|
|
40
40
|
"mpegts.js": "^1.7.3",
|
|
41
|
-
"sass": "^1.
|
|
42
|
-
"sass-embedded": "^1.
|
|
41
|
+
"sass": "^1.86.1",
|
|
42
|
+
"sass-embedded": "^1.86.1",
|
|
43
43
|
"stylus": "^0.64.0",
|
|
44
44
|
"vuepress": "2.0.0-rc.20"
|
|
45
45
|
},
|
|
@@ -68,24 +68,25 @@
|
|
|
68
68
|
"@mdit/plugin-sup": "^0.16.0",
|
|
69
69
|
"@mdit/plugin-tab": "^0.16.0",
|
|
70
70
|
"@mdit/plugin-tasklist": "^0.16.0",
|
|
71
|
-
"@
|
|
71
|
+
"@pengzhanbo/utils": "^1.2.0",
|
|
72
|
+
"@vuepress/helper": "2.0.0-rc.91",
|
|
72
73
|
"@vueuse/core": "^13.0.0",
|
|
73
74
|
"chokidar": "3.6.0",
|
|
74
75
|
"image-size": "^2.0.1",
|
|
75
76
|
"local-pkg": "^1.1.1",
|
|
76
|
-
"lru-cache": "^11.0
|
|
77
|
+
"lru-cache": "^11.1.0",
|
|
77
78
|
"markdown-it-container": "^4.0.0",
|
|
78
|
-
"nanoid": "^5.1.
|
|
79
|
+
"nanoid": "^5.1.5",
|
|
79
80
|
"shiki": "^3.2.1",
|
|
80
|
-
"tm-grammars": "^1.23.
|
|
81
|
-
"tm-themes": "^1.10.
|
|
81
|
+
"tm-grammars": "^1.23.7",
|
|
82
|
+
"tm-themes": "^1.10.3",
|
|
82
83
|
"vue": "^3.5.13"
|
|
83
84
|
},
|
|
84
85
|
"devDependencies": {
|
|
85
86
|
"@types/markdown-it": "^14.1.2",
|
|
86
87
|
"artplayer": "^5.2.2",
|
|
87
88
|
"dashjs": "^5.0.0",
|
|
88
|
-
"hls.js": "^1.
|
|
89
|
+
"hls.js": "^1.6.0",
|
|
89
90
|
"mpegts.js": "1.7.3"
|
|
90
91
|
},
|
|
91
92
|
"publishConfig": {
|