@ant-design/x-markdown-mini 0.1.0-beta.0 → 0.1.0-beta.1
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/dist/components/Markdown/index.acss +65 -7
- package/dist/components/MiniNodeRenderer/index.acss +19 -4
- package/dist/components/MiniNodeRenderer/index.axml +109 -29
- package/dist/components/MiniNodeRenderer/index.js +12 -0
- package/dist/components/MiniNodeRenderer/index.sjs +48 -0
- package/dist/es/Markdown/index.acss +65 -7
- package/dist/es/MiniNodeRenderer/index.acss +19 -4
- package/dist/es/MiniNodeRenderer/index.axml +109 -29
- package/dist/es/MiniNodeRenderer/index.js +12 -0
- package/dist/es/MiniNodeRenderer/index.sjs +48 -0
- package/dist/index.d.mts +39 -1
- package/dist/index.d.ts +39 -1
- package/dist/index.js +134 -56
- package/dist/index.mjs +134 -56
- package/dist/miniprogram_dist/components/Markdown/index.json +1 -1
- package/dist/miniprogram_dist/components/Markdown/index.wxss +65 -7
- package/dist/miniprogram_dist/components/MiniNodeRenderer/index.js +12 -0
- package/dist/miniprogram_dist/components/MiniNodeRenderer/index.json +1 -1
- package/dist/miniprogram_dist/components/MiniNodeRenderer/index.wxml +98 -21
- package/dist/miniprogram_dist/components/MiniNodeRenderer/index.wxs +41 -0
- package/dist/miniprogram_dist/components/MiniNodeRenderer/index.wxss +13 -2
- package/dist/miniprogram_dist/es/Markdown/index.json +1 -1
- package/dist/miniprogram_dist/es/Markdown/index.wxss +65 -7
- package/dist/miniprogram_dist/es/MiniNodeRenderer/index.js +12 -0
- package/dist/miniprogram_dist/es/MiniNodeRenderer/index.json +1 -1
- package/dist/miniprogram_dist/es/MiniNodeRenderer/index.wxml +98 -21
- package/dist/miniprogram_dist/es/MiniNodeRenderer/index.wxs +41 -0
- package/dist/miniprogram_dist/es/MiniNodeRenderer/index.wxss +13 -2
- package/dist/miniprogram_dist/index.js +134 -56
- package/dist/miniprogram_dist/plugins/CodeHighlight/index.js +13 -5
- package/dist/miniprogram_dist/plugins/CodeHighlight/style.wxss +41 -31
- package/dist/miniprogram_dist/plugins/Latex/index.js +44 -23
- package/dist/miniprogram_dist/plugins/Latex/style.wxss +11 -11
- package/dist/miniprogram_dist/shared/flattenInline.js +33 -5
- package/dist/plugins/CodeHighlight/index.d.mts +1 -1
- package/dist/plugins/CodeHighlight/index.d.ts +1 -1
- package/dist/plugins/CodeHighlight/index.js +13 -5
- package/dist/plugins/CodeHighlight/index.mjs +13 -5
- package/dist/plugins/CodeHighlight/style.acss +41 -31
- package/dist/plugins/Latex/index.d.mts +1 -1
- package/dist/plugins/Latex/index.d.ts +1 -1
- package/dist/plugins/Latex/index.js +44 -23
- package/dist/plugins/Latex/index.mjs +47 -23
- package/dist/plugins/Latex/style.acss +11 -6
- package/dist/shared/flattenInline.js +33 -5
- package/dist/{types-CegkonfJ.d.mts → types-BcxGtbQZ.d.mts} +25 -0
- package/dist/{types-CegkonfJ.d.ts → types-BcxGtbQZ.d.ts} +25 -0
- package/package.json +3 -2
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
2
7
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b3) => {
|
|
9
|
+
for (var prop in b3 || (b3 = {}))
|
|
10
|
+
if (__hasOwnProp.call(b3, prop))
|
|
11
|
+
__defNormalProp(a, prop, b3[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b3)) {
|
|
14
|
+
if (__propIsEnum.call(b3, prop))
|
|
15
|
+
__defNormalProp(a, prop, b3[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b3) => __defProps(a, __getOwnPropDescs(b3));
|
|
20
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
3
32
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
33
|
|
|
5
34
|
// node_modules/marked/lib/marked.esm.js
|
|
@@ -47,9 +76,9 @@ var ae = d(j).replace("hr", I).replace("heading", " {0,3}#{1,6}(?:\\s|$)").repla
|
|
|
47
76
|
var Me = d(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", ae).getRegex();
|
|
48
77
|
var K = { blockquote: Me, code: Oe, def: $e, fences: we, heading: ye, hr: I, html: _e, lheading: oe, list: Le, newline: Te, paragraph: ae, table: _, text: Se };
|
|
49
78
|
var re = d("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", I).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", "(?: {4}| {0,3} )[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", v).getRegex();
|
|
50
|
-
var ze = {
|
|
51
|
-
var Ee = {
|
|
52
|
-
]`).replace("lheading", oe).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex() };
|
|
79
|
+
var ze = __spreadProps(__spreadValues({}, K), { lheading: Pe, table: re, paragraph: d(j).replace("hr", I).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", re).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", v).getRegex() });
|
|
80
|
+
var Ee = __spreadProps(__spreadValues({}, K), { html: d(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", U).replace(/tag/g, "(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(), def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/, heading: /^(#{1,6})(.*)(?:\n+|$)/, fences: _, lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/, paragraph: d(j).replace("hr", I).replace("heading", ` *#{1,6} *[^
|
|
81
|
+
]`).replace("lheading", oe).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex() });
|
|
53
82
|
var Ae = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/;
|
|
54
83
|
var Ce = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/;
|
|
55
84
|
var le = /^( {2,}|\\)\n(?!\s*$)/;
|
|
@@ -83,9 +112,9 @@ var ke = d(/^!?\[(ref)\](?:\[\])?/).replace("ref", F).getRegex();
|
|
|
83
112
|
var Ye = d("reflink|nolink(?!\\()", "g").replace("reflink", he).replace("nolink", ke).getRegex();
|
|
84
113
|
var se = /[hH][tT][tT][pP][sS]?|[fF][tT][pP]/;
|
|
85
114
|
var X = { _backpedal: _, anyPunctuation: Ke, autolink: We, blockSkip: ve, br: le, code: Ce, del: _, delLDelim: _, delRDelim: _, emStrongLDelim: He, emStrongRDelimAst: Ge, emStrongRDelimUnd: Qe, escape: Ae, link: Ve, nolink: ke, punctuation: Be, reflink: he, reflinkSearch: Ye, tag: Je, text: Ie, url: _ };
|
|
86
|
-
var et = {
|
|
87
|
-
var N = {
|
|
88
|
-
var tt = {
|
|
115
|
+
var et = __spreadProps(__spreadValues({}, X), { link: d(/^!?\[(label)\]\((.*?)\)/).replace("label", q).getRegex(), reflink: d(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", q).getRegex() });
|
|
116
|
+
var N = __spreadProps(__spreadValues({}, X), { emStrongRDelimAst: Ne, emStrongLDelim: Ze, delLDelim: je, delRDelim: Ue, url: d(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol", se).replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(), _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/, del: /^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/, text: d(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol", se).getRegex() });
|
|
117
|
+
var tt = __spreadProps(__spreadValues({}, N), { br: d(le).replace("{2,}", "*").getRegex(), text: d(N.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex() });
|
|
89
118
|
var B = { normal: K, gfm: ze, pedantic: Ee };
|
|
90
119
|
var A = { normal: X, gfm: N, breaks: tt, pedantic: et };
|
|
91
120
|
var nt = { "&": "&", "<": "<", ">": ">", '"': """, "'": "'" };
|
|
@@ -1089,7 +1118,7 @@ var D = class {
|
|
|
1089
1118
|
use(...e) {
|
|
1090
1119
|
let t = this.defaults.extensions || { renderers: {}, childTokens: {} };
|
|
1091
1120
|
return e.forEach((n) => {
|
|
1092
|
-
let s = {
|
|
1121
|
+
let s = __spreadValues({}, n);
|
|
1093
1122
|
if (s.async = this.defaults.async || s.async || false, n.extensions && (n.extensions.forEach((r) => {
|
|
1094
1123
|
if (!r.name) throw new Error("extension name required");
|
|
1095
1124
|
if ("renderer" in r) {
|
|
@@ -1162,11 +1191,11 @@ var D = class {
|
|
|
1162
1191
|
return u2.push(i.call(this, o)), r && (u2 = u2.concat(r.call(this, o))), u2;
|
|
1163
1192
|
};
|
|
1164
1193
|
}
|
|
1165
|
-
this.defaults = {
|
|
1194
|
+
this.defaults = __spreadValues(__spreadValues({}, this.defaults), s);
|
|
1166
1195
|
}), this;
|
|
1167
1196
|
}
|
|
1168
1197
|
setOptions(e) {
|
|
1169
|
-
return this.defaults = {
|
|
1198
|
+
return this.defaults = __spreadValues(__spreadValues({}, this.defaults), e), this;
|
|
1170
1199
|
}
|
|
1171
1200
|
lexer(e, t) {
|
|
1172
1201
|
return x.lex(e, t != null ? t : this.defaults);
|
|
@@ -1176,7 +1205,7 @@ var D = class {
|
|
|
1176
1205
|
}
|
|
1177
1206
|
parseMarkdown(e) {
|
|
1178
1207
|
return (n, s) => {
|
|
1179
|
-
let r = {
|
|
1208
|
+
let r = __spreadValues({}, s), i = __spreadValues(__spreadValues({}, this.defaults), r), o = this.onError(!!i.silent, !!i.async);
|
|
1180
1209
|
if (this.defaults.async === true && r.async === false) return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));
|
|
1181
1210
|
if (typeof n > "u" || n === null) return o(new Error("marked(): input parameter is undefined or null"));
|
|
1182
1211
|
if (typeof n != "string") return o(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(n) + ", string expected"));
|
|
@@ -1243,6 +1272,10 @@ var Jt = b.parse;
|
|
|
1243
1272
|
var Vt = x.lex;
|
|
1244
1273
|
|
|
1245
1274
|
// src/plugins/shared/htmlToMiniNodes.ts
|
|
1275
|
+
var CLOSE_TAG_RE = /<\/(\w+)\s*>/y;
|
|
1276
|
+
var OPEN_TAG_RE = /<(\w+)((?:\s+[^>]*?)?)(\/?)>/y;
|
|
1277
|
+
var KATEX_CLOSE_SPAN_RE = /<\/span\s*>/iy;
|
|
1278
|
+
var KATEX_OPEN_SPAN_RE = /<span[\s>]/iy;
|
|
1246
1279
|
function htmlToMiniNodes(html, escapeText) {
|
|
1247
1280
|
var _a2;
|
|
1248
1281
|
const root = { name: "root", children: [] };
|
|
@@ -1280,7 +1313,8 @@ function htmlToMiniNodes(html, escapeText) {
|
|
|
1280
1313
|
}
|
|
1281
1314
|
while (i < html.length) {
|
|
1282
1315
|
if (html[i] === "<") {
|
|
1283
|
-
|
|
1316
|
+
CLOSE_TAG_RE.lastIndex = i;
|
|
1317
|
+
const closeMatch = CLOSE_TAG_RE.exec(html);
|
|
1284
1318
|
if (closeMatch) {
|
|
1285
1319
|
const closeTag = closeMatch[1].toLowerCase();
|
|
1286
1320
|
for (let j3 = stack.length - 1; j3 > 0; j3--) {
|
|
@@ -1292,7 +1326,8 @@ function htmlToMiniNodes(html, escapeText) {
|
|
|
1292
1326
|
i += closeMatch[0].length;
|
|
1293
1327
|
continue;
|
|
1294
1328
|
}
|
|
1295
|
-
|
|
1329
|
+
OPEN_TAG_RE.lastIndex = i;
|
|
1330
|
+
const tagMatch = OPEN_TAG_RE.exec(html);
|
|
1296
1331
|
if (tagMatch) {
|
|
1297
1332
|
const rawTag = tagMatch[1].toLowerCase();
|
|
1298
1333
|
const attrStr = tagMatch[2];
|
|
@@ -1303,8 +1338,10 @@ function htmlToMiniNodes(html, escapeText) {
|
|
|
1303
1338
|
while (si < html.length && depth > 0) {
|
|
1304
1339
|
const next = html.indexOf("<", si);
|
|
1305
1340
|
if (next === -1) break;
|
|
1306
|
-
|
|
1307
|
-
const
|
|
1341
|
+
KATEX_CLOSE_SPAN_RE.lastIndex = next;
|
|
1342
|
+
const csm = KATEX_CLOSE_SPAN_RE.exec(html);
|
|
1343
|
+
KATEX_OPEN_SPAN_RE.lastIndex = next;
|
|
1344
|
+
const osm = KATEX_OPEN_SPAN_RE.exec(html);
|
|
1308
1345
|
if (csm) {
|
|
1309
1346
|
depth--;
|
|
1310
1347
|
si = next + csm[0].length;
|
|
@@ -1419,7 +1456,7 @@ function inlineNode(adapter, node, token) {
|
|
|
1419
1456
|
}
|
|
1420
1457
|
function compactNode(node) {
|
|
1421
1458
|
if (node.attrs && Object.keys(node.attrs).length === 0) {
|
|
1422
|
-
const { attrs: _attrs,
|
|
1459
|
+
const _a2 = node, { attrs: _attrs } = _a2, rest = __objRest(_a2, ["attrs"]);
|
|
1423
1460
|
return rest;
|
|
1424
1461
|
}
|
|
1425
1462
|
return node;
|
|
@@ -1446,10 +1483,41 @@ function collectText(nodes) {
|
|
|
1446
1483
|
}
|
|
1447
1484
|
return out;
|
|
1448
1485
|
}
|
|
1486
|
+
function copyButton(text) {
|
|
1487
|
+
return { name: "copy-button", attrs: { "data-copy": text, class: "md-copy-icon" } };
|
|
1488
|
+
}
|
|
1489
|
+
function asNodeArray(x3) {
|
|
1490
|
+
if (!x3) return [];
|
|
1491
|
+
return Array.isArray(x3) ? x3 : [x3];
|
|
1492
|
+
}
|
|
1493
|
+
function buildCodeHeader(ctx, lang, text, token) {
|
|
1494
|
+
const cfg = ctx.codeHeader;
|
|
1495
|
+
if (cfg === false) return [];
|
|
1496
|
+
if (typeof cfg === "function") return asNodeArray(cfg({ lang, text, token }));
|
|
1497
|
+
return [
|
|
1498
|
+
{ name: "text", attrs: { class: "md-codeblock-lang", value: lang || "code" } },
|
|
1499
|
+
copyButton(text)
|
|
1500
|
+
];
|
|
1501
|
+
}
|
|
1502
|
+
function buildTableHeader(ctx, token) {
|
|
1503
|
+
var _a2;
|
|
1504
|
+
const cfg = ctx.tableHeader;
|
|
1505
|
+
if (cfg === false) return [];
|
|
1506
|
+
const markdown = (_a2 = token.raw) != null ? _a2 : "";
|
|
1507
|
+
if (typeof cfg === "function") return asNodeArray(cfg({ markdown, token }));
|
|
1508
|
+
return [
|
|
1509
|
+
{ name: "text", attrs: { class: "md-tableblock-title", value: "\u8868\u683C" } },
|
|
1510
|
+
copyButton(markdown)
|
|
1511
|
+
];
|
|
1512
|
+
}
|
|
1513
|
+
function withHeader(node, header) {
|
|
1514
|
+
if (header.length) node.header = header;
|
|
1515
|
+
return node;
|
|
1516
|
+
}
|
|
1449
1517
|
function renderTokensToMiniNodes(tokens, adapter, ctx = {}) {
|
|
1450
1518
|
const animate = ctx.animation === true;
|
|
1451
1519
|
const enc = ctx.escapeText === false ? (s) => s : escapeHtml;
|
|
1452
|
-
const localCtx = {
|
|
1520
|
+
const localCtx = __spreadValues({}, ctx);
|
|
1453
1521
|
localCtx.renderInlineTokens = (inner) => inlineTokens(inner, adapter, enc, localCtx);
|
|
1454
1522
|
return blockTokens(tokens, adapter, animate, enc, localCtx);
|
|
1455
1523
|
}
|
|
@@ -1462,7 +1530,7 @@ function blockTokens(tokens, adapter, animate, enc, ctx) {
|
|
|
1462
1530
|
return out;
|
|
1463
1531
|
}
|
|
1464
1532
|
function blockTok(tok, adapter, animate, enc, ctx) {
|
|
1465
|
-
var _a2, _b, _c, _d, _e2, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
1533
|
+
var _a2, _b, _c, _d, _e2, _f, _g, _h, _i, _j, _k, _l, _m, _n2, _o, _p;
|
|
1466
1534
|
switch (tok.type) {
|
|
1467
1535
|
case "space":
|
|
1468
1536
|
return null;
|
|
@@ -1476,23 +1544,26 @@ function blockTok(tok, adapter, animate, enc, ctx) {
|
|
|
1476
1544
|
return block("p", inlineTokens((_c = t.tokens) != null ? _c : [], adapter, enc, ctx), animate, adapter, tok);
|
|
1477
1545
|
}
|
|
1478
1546
|
case "code": {
|
|
1479
|
-
const custom = renderCustomToken(tok, ctx);
|
|
1480
|
-
if (custom.length) return block("pre", custom, animate, adapter, tok);
|
|
1481
1547
|
const t = tok;
|
|
1548
|
+
const lang = (_e2 = ((_d = t.lang) != null ? _d : "").trim().split(/\s+/)[0]) != null ? _e2 : "";
|
|
1549
|
+
const preAttrs = lang ? { class: "md-code-block", lang } : { class: "md-code-block" };
|
|
1550
|
+
const header = buildCodeHeader(ctx, lang, (_f = t.text) != null ? _f : "", t);
|
|
1551
|
+
const custom = renderCustomToken(tok, ctx);
|
|
1552
|
+
if (custom.length) return withHeader(block("pre", custom, animate, adapter, tok, preAttrs), header);
|
|
1482
1553
|
if (!supports(adapter, "supportsPre")) {
|
|
1483
|
-
return textBlock(enc((
|
|
1554
|
+
return textBlock(enc((_g = t.text) != null ? _g : ""), animate, adapter, tok);
|
|
1484
1555
|
}
|
|
1485
1556
|
const codeChild = {
|
|
1486
1557
|
name: "code",
|
|
1487
|
-
children: [{ name: "text", attrs: { value: enc((
|
|
1558
|
+
children: [{ name: "text", attrs: { value: enc((_h = t.text) != null ? _h : "") } }]
|
|
1488
1559
|
};
|
|
1489
|
-
return block("pre", [codeChild], animate, adapter, tok);
|
|
1560
|
+
return withHeader(block("pre", [codeChild], animate, adapter, tok, preAttrs), header);
|
|
1490
1561
|
}
|
|
1491
1562
|
case "hr":
|
|
1492
1563
|
return block("hr", [], animate, adapter, tok);
|
|
1493
1564
|
case "blockquote": {
|
|
1494
1565
|
const t = tok;
|
|
1495
|
-
const children = blockTokens((
|
|
1566
|
+
const children = blockTokens((_i = t.tokens) != null ? _i : [], adapter, animate, enc, ctx);
|
|
1496
1567
|
if (!supports(adapter, "supportsBlockquote")) {
|
|
1497
1568
|
return textBlock(collectText(children), animate, adapter, tok);
|
|
1498
1569
|
}
|
|
@@ -1508,15 +1579,15 @@ function blockTok(tok, adapter, animate, enc, ctx) {
|
|
|
1508
1579
|
}
|
|
1509
1580
|
case "html": {
|
|
1510
1581
|
const t = tok;
|
|
1511
|
-
const raw = ((
|
|
1582
|
+
const raw = ((_k = (_j = t.text) != null ? _j : t.raw) != null ? _k : "").replace(/\s+$/, "");
|
|
1512
1583
|
return block("div", raw ? [{ name: "text", attrs: { value: raw } }] : [], animate, adapter, tok);
|
|
1513
1584
|
}
|
|
1514
1585
|
case "table": {
|
|
1515
1586
|
const t = tok;
|
|
1516
1587
|
if (!supports(adapter, "supportsTable")) {
|
|
1517
1588
|
const rows = [
|
|
1518
|
-
(
|
|
1519
|
-
...(
|
|
1589
|
+
(_l = t.header) != null ? _l : [],
|
|
1590
|
+
...(_m = t.rows) != null ? _m : []
|
|
1520
1591
|
];
|
|
1521
1592
|
const value = rows.map((row) => row.map((cell) => {
|
|
1522
1593
|
var _a3;
|
|
@@ -1524,33 +1595,35 @@ function blockTok(tok, adapter, animate, enc, ctx) {
|
|
|
1524
1595
|
}).join(" ")).join("\n");
|
|
1525
1596
|
return textBlock(value, animate, adapter, tok);
|
|
1526
1597
|
}
|
|
1527
|
-
const headCells = ((
|
|
1598
|
+
const headCells = ((_n2 = t.header) != null ? _n2 : []).map((cell) => {
|
|
1528
1599
|
var _a3;
|
|
1529
1600
|
return {
|
|
1530
1601
|
name: "th",
|
|
1602
|
+
attrs: { class: "md-th" },
|
|
1531
1603
|
children: inlineTokens((_a3 = cell.tokens) != null ? _a3 : [], adapter, enc, ctx)
|
|
1532
1604
|
};
|
|
1533
1605
|
});
|
|
1534
|
-
const rowNodes = ((
|
|
1606
|
+
const rowNodes = ((_o = t.rows) != null ? _o : []).map((row) => ({
|
|
1535
1607
|
name: "tr",
|
|
1608
|
+
attrs: { class: "md-tr" },
|
|
1536
1609
|
children: row.map((cell) => {
|
|
1537
1610
|
var _a3;
|
|
1538
1611
|
return {
|
|
1539
1612
|
name: "td",
|
|
1613
|
+
attrs: { class: "md-td" },
|
|
1540
1614
|
children: inlineTokens((_a3 = cell.tokens) != null ? _a3 : [], adapter, enc, ctx)
|
|
1541
1615
|
};
|
|
1542
1616
|
})
|
|
1543
1617
|
}));
|
|
1544
|
-
const
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
return block("table", [compactNode(thead), compactNode(tbody)], animate, adapter, tok);
|
|
1618
|
+
const headerRow = { name: "tr", attrs: { class: "md-tr" }, children: headCells };
|
|
1619
|
+
return withHeader(
|
|
1620
|
+
block("table", [headerRow, ...rowNodes], animate, adapter, tok, { class: "md-table" }),
|
|
1621
|
+
buildTableHeader(ctx, t)
|
|
1622
|
+
);
|
|
1550
1623
|
}
|
|
1551
1624
|
case "text": {
|
|
1552
1625
|
const t = tok;
|
|
1553
|
-
const inline = t.tokens ? inlineTokens(t.tokens, adapter, enc, ctx) : [{ name: "text", attrs: { value: enc((
|
|
1626
|
+
const inline = t.tokens ? inlineTokens(t.tokens, adapter, enc, ctx) : [{ name: "text", attrs: { value: enc((_p = t.text) != null ? _p : "") } }];
|
|
1554
1627
|
return block("p", inline, animate, adapter, tok);
|
|
1555
1628
|
}
|
|
1556
1629
|
case "def":
|
|
@@ -1639,6 +1712,7 @@ function inlineTok(tok, adapter, enc, out, ctx) {
|
|
|
1639
1712
|
const t = tok;
|
|
1640
1713
|
const node = inlineNode(adapter, {
|
|
1641
1714
|
name: "code",
|
|
1715
|
+
attrs: { class: "md-inline-code" },
|
|
1642
1716
|
children: [{ name: "text", attrs: { value: enc((_f = t.text) != null ? _f : "") } }]
|
|
1643
1717
|
}, tok);
|
|
1644
1718
|
if (node) out.push(node);
|
|
@@ -1705,7 +1779,7 @@ var alipayAdapter = {
|
|
|
1705
1779
|
olAttrs: () => ({})
|
|
1706
1780
|
};
|
|
1707
1781
|
function tokensToAlipay(content, opts = {}) {
|
|
1708
|
-
const { options,
|
|
1782
|
+
const _a2 = opts, { options } = _a2, ctx = __objRest(_a2, ["options"]);
|
|
1709
1783
|
const tokens = x.lex(content, buildMarkedOptions(options != null ? options : {}));
|
|
1710
1784
|
return tokensToAlipayNodes(tokens, ctx);
|
|
1711
1785
|
}
|
|
@@ -1743,7 +1817,7 @@ var wechatAdapter = {
|
|
|
1743
1817
|
}
|
|
1744
1818
|
};
|
|
1745
1819
|
function tokensToWechat(content, opts = {}) {
|
|
1746
|
-
const { options,
|
|
1820
|
+
const _a2 = opts, { options } = _a2, ctx = __objRest(_a2, ["options"]);
|
|
1747
1821
|
const tokens = x.lex(content, buildMarkedOptions2(options != null ? options : {}));
|
|
1748
1822
|
return tokensToWechatNodes(tokens, ctx);
|
|
1749
1823
|
}
|
|
@@ -1933,6 +2007,7 @@ var StreamingProcessor = class {
|
|
|
1933
2007
|
// --- 内部 ---
|
|
1934
2008
|
/** 按 delimiters + maxChunkSize 把 buffer 切成 chunk 序列;hasNext=false 时 flush 末尾。 */
|
|
1935
2009
|
splitIntoChunks(hasNextChunk) {
|
|
2010
|
+
var _a2;
|
|
1936
2011
|
const { semanticEnabled, delimiters = DEFAULT_DELIMITERS, maxChunkSize = DEFAULT_MAX_CHUNK_SIZE } = this.config;
|
|
1937
2012
|
const pending = [];
|
|
1938
2013
|
let remaining = this.buffer;
|
|
@@ -1940,7 +2015,7 @@ var StreamingProcessor = class {
|
|
|
1940
2015
|
let chunk = "";
|
|
1941
2016
|
if (semanticEnabled) {
|
|
1942
2017
|
const m3 = remaining.match(delimiters);
|
|
1943
|
-
const cut = m3 ?
|
|
2018
|
+
const cut = m3 ? ((_a2 = m3.index) != null ? _a2 : 0) + 1 : -1;
|
|
1944
2019
|
if (cut > 0) {
|
|
1945
2020
|
chunk = remaining.slice(0, cut);
|
|
1946
2021
|
remaining = remaining.slice(cut);
|
|
@@ -2700,12 +2775,14 @@ var XMarkdownMini = class {
|
|
|
2700
2775
|
this.nodeStreamProcessor = null;
|
|
2701
2776
|
this.activeTokenStreamDefaults = null;
|
|
2702
2777
|
this.activeNodeStreamDefaults = null;
|
|
2703
|
-
var _a2, _b, _c;
|
|
2778
|
+
var _a2, _b, _c, _d, _e2;
|
|
2704
2779
|
this.escapeText = (_a2 = opts.escapeText) != null ? _a2 : true;
|
|
2705
2780
|
this.fixup = resolveStreamingFixup((_b = opts.streamingFixup) != null ? _b : "remend");
|
|
2706
2781
|
this.gfm = opts.gfm;
|
|
2707
2782
|
this.breaks = opts.breaks;
|
|
2708
|
-
|
|
2783
|
+
this.codeHeader = (_c = opts.codeBlock) == null ? void 0 : _c.header;
|
|
2784
|
+
this.tableHeader = (_d = opts.table) == null ? void 0 : _d.header;
|
|
2785
|
+
const directExtensions = (_e2 = opts.extensions) != null ? _e2 : [];
|
|
2709
2786
|
this.componentsExtension = opts.components && opts.components.length > 0 ? synthesizeComponentsExtension(opts.components) : void 0;
|
|
2710
2787
|
const allMarkedExtensions = [
|
|
2711
2788
|
...directExtensions,
|
|
@@ -2739,7 +2816,7 @@ var XMarkdownMini = class {
|
|
|
2739
2816
|
*/
|
|
2740
2817
|
applyPerCallExtensions(perCall) {
|
|
2741
2818
|
if (!perCall || perCall.length === 0) return null;
|
|
2742
|
-
const saved = {
|
|
2819
|
+
const saved = __spreadValues({}, this.marked.defaults);
|
|
2743
2820
|
this.marked.use(...perCall);
|
|
2744
2821
|
return saved;
|
|
2745
2822
|
}
|
|
@@ -2750,11 +2827,7 @@ var XMarkdownMini = class {
|
|
|
2750
2827
|
var _a2, _b;
|
|
2751
2828
|
const gfm = (_a2 = perCall == null ? void 0 : perCall.gfm) != null ? _a2 : this.gfm;
|
|
2752
2829
|
const breaks = (_b = perCall == null ? void 0 : perCall.breaks) != null ? _b : this.breaks;
|
|
2753
|
-
return {
|
|
2754
|
-
...this.marked.defaults,
|
|
2755
|
-
...gfm !== void 0 ? { gfm: gfm !== false } : {},
|
|
2756
|
-
...breaks !== void 0 ? { breaks: !!breaks } : {}
|
|
2757
|
-
};
|
|
2830
|
+
return __spreadValues(__spreadValues(__spreadValues({}, this.marked.defaults), gfm !== void 0 ? { gfm: gfm !== false } : {}), breaks !== void 0 ? { breaks: !!breaks } : {});
|
|
2758
2831
|
}
|
|
2759
2832
|
lex(content, opts) {
|
|
2760
2833
|
const tokens = this.marked.lexer(content, opts != null ? opts : this.buildMarkedOptions());
|
|
@@ -2801,11 +2874,11 @@ var XMarkdownMini = class {
|
|
|
2801
2874
|
this.activeTokenStreamDefaults = this.applyPerCallExtensions(perCallExts);
|
|
2802
2875
|
const markedOpts = this.buildMarkedOptions({ gfm, breaks });
|
|
2803
2876
|
const transform = (md) => this.lex(md, markedOpts);
|
|
2804
|
-
this.tokenStreamProcessor = new StreamingProcessor({
|
|
2877
|
+
this.tokenStreamProcessor = new StreamingProcessor(__spreadProps(__spreadValues({
|
|
2805
2878
|
transform,
|
|
2806
2879
|
fixup: this.fixup,
|
|
2807
|
-
semanticEnabled: stream.semanticEnabled
|
|
2808
|
-
|
|
2880
|
+
semanticEnabled: stream.semanticEnabled
|
|
2881
|
+
}, stream.semanticConfig), {
|
|
2809
2882
|
onUpdate: (markdown) => {
|
|
2810
2883
|
var _a3;
|
|
2811
2884
|
return (_a3 = props.onRenderProgress) == null ? void 0 : _a3.call(props, { markdown });
|
|
@@ -2821,7 +2894,7 @@ var XMarkdownMini = class {
|
|
|
2821
2894
|
this.restoreDefaults(this.activeTokenStreamDefaults);
|
|
2822
2895
|
this.activeTokenStreamDefaults = null;
|
|
2823
2896
|
}
|
|
2824
|
-
});
|
|
2897
|
+
}));
|
|
2825
2898
|
(_d = props.onRenderStart) == null ? void 0 : _d.call(props);
|
|
2826
2899
|
}
|
|
2827
2900
|
this.tokenStreamProcessor.handleContentUpdate(content);
|
|
@@ -2850,7 +2923,9 @@ var XMarkdownMini = class {
|
|
|
2850
2923
|
animation: false,
|
|
2851
2924
|
selectable,
|
|
2852
2925
|
escapeText: this.escapeText,
|
|
2853
|
-
extensions: ctxExtensions
|
|
2926
|
+
extensions: ctxExtensions,
|
|
2927
|
+
codeHeader: this.codeHeader,
|
|
2928
|
+
tableHeader: this.tableHeader
|
|
2854
2929
|
};
|
|
2855
2930
|
const tokens = this.lex(content, markedOpts);
|
|
2856
2931
|
const nodes = renderer.renderTokens(tokens, ctx);
|
|
@@ -2868,14 +2943,16 @@ var XMarkdownMini = class {
|
|
|
2868
2943
|
animation: stream.enableAnimation,
|
|
2869
2944
|
selectable,
|
|
2870
2945
|
escapeText: this.escapeText,
|
|
2871
|
-
extensions: ctxExtensions
|
|
2946
|
+
extensions: ctxExtensions,
|
|
2947
|
+
codeHeader: this.codeHeader,
|
|
2948
|
+
tableHeader: this.tableHeader
|
|
2872
2949
|
};
|
|
2873
2950
|
const transform = (md) => renderer.renderTokens(this.lex(md, markedOpts), ctx);
|
|
2874
|
-
this.nodeStreamProcessor = new StreamingProcessor({
|
|
2951
|
+
this.nodeStreamProcessor = new StreamingProcessor(__spreadProps(__spreadValues({
|
|
2875
2952
|
transform,
|
|
2876
2953
|
fixup: this.fixup,
|
|
2877
|
-
semanticEnabled: stream.semanticEnabled
|
|
2878
|
-
|
|
2954
|
+
semanticEnabled: stream.semanticEnabled
|
|
2955
|
+
}, stream.semanticConfig), {
|
|
2879
2956
|
onUpdate: (markdown) => {
|
|
2880
2957
|
var _a3;
|
|
2881
2958
|
return (_a3 = props.onRenderProgress) == null ? void 0 : _a3.call(props, { markdown });
|
|
@@ -2891,7 +2968,7 @@ var XMarkdownMini = class {
|
|
|
2891
2968
|
this.restoreDefaults(this.activeNodeStreamDefaults);
|
|
2892
2969
|
this.activeNodeStreamDefaults = null;
|
|
2893
2970
|
}
|
|
2894
|
-
});
|
|
2971
|
+
}));
|
|
2895
2972
|
(_d = props.onRenderStart) == null ? void 0 : _d.call(props);
|
|
2896
2973
|
}
|
|
2897
2974
|
this.nodeStreamProcessor.handleContentUpdate(content);
|
|
@@ -3096,6 +3173,7 @@ export {
|
|
|
3096
3173
|
StreamingProcessor,
|
|
3097
3174
|
XMarkdownMini,
|
|
3098
3175
|
alipayRenderer,
|
|
3176
|
+
copyButton,
|
|
3099
3177
|
flattenInlineTokens,
|
|
3100
3178
|
getPlatformRenderer,
|
|
3101
3179
|
parse,
|
|
@@ -45,11 +45,47 @@
|
|
|
45
45
|
|
|
46
46
|
.md-code-block {
|
|
47
47
|
display: block;
|
|
48
|
-
margin: 12rpx 0;
|
|
49
48
|
padding: 16rpx;
|
|
50
49
|
background: #f6f8fa;
|
|
51
|
-
border-radius: 8rpx;
|
|
52
50
|
overflow-x: auto;
|
|
51
|
+
font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
|
|
52
|
+
font-size: 26rpx;
|
|
53
|
+
line-height: 1.6;
|
|
54
|
+
white-space: pre;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/* code & table cards share a captioned header bar with an icon copy button */
|
|
58
|
+
.md-codeblock,
|
|
59
|
+
.md-tableblock {
|
|
60
|
+
margin: 16rpx 0;
|
|
61
|
+
border: 2rpx solid #eceef1;
|
|
62
|
+
border-radius: 16rpx;
|
|
63
|
+
overflow: hidden;
|
|
64
|
+
}
|
|
65
|
+
.md-codeblock-bar,
|
|
66
|
+
.md-tableblock-bar {
|
|
67
|
+
display: flex;
|
|
68
|
+
align-items: center;
|
|
69
|
+
justify-content: space-between;
|
|
70
|
+
height: 64rpx;
|
|
71
|
+
padding: 0 24rpx;
|
|
72
|
+
background: #eceef2;
|
|
73
|
+
font-size: 24rpx;
|
|
74
|
+
color: #4e5969;
|
|
75
|
+
}
|
|
76
|
+
.md-codeblock-lang {
|
|
77
|
+
text-transform: uppercase;
|
|
78
|
+
letter-spacing: 1rpx;
|
|
79
|
+
font-weight: 600;
|
|
80
|
+
color: #1d2129;
|
|
81
|
+
}
|
|
82
|
+
.md-tableblock-title {
|
|
83
|
+
font-weight: 600;
|
|
84
|
+
color: #1d2129;
|
|
85
|
+
}
|
|
86
|
+
.md-copy-icon {
|
|
87
|
+
width: 32rpx;
|
|
88
|
+
height: 32rpx;
|
|
53
89
|
}
|
|
54
90
|
|
|
55
91
|
.md-code {
|
|
@@ -78,6 +114,8 @@
|
|
|
78
114
|
.md-img {
|
|
79
115
|
display: block;
|
|
80
116
|
max-width: 100%;
|
|
117
|
+
margin: 16rpx 0;
|
|
118
|
+
border-radius: 12rpx;
|
|
81
119
|
}
|
|
82
120
|
|
|
83
121
|
.md-hr {
|
|
@@ -87,17 +125,37 @@
|
|
|
87
125
|
margin: 16rpx 0;
|
|
88
126
|
}
|
|
89
127
|
|
|
90
|
-
.md-
|
|
128
|
+
/* table body scrolls horizontally inside the .md-tableblock card */
|
|
129
|
+
.md-table-scroll {
|
|
91
130
|
display: block;
|
|
92
131
|
width: 100%;
|
|
93
|
-
|
|
94
|
-
|
|
132
|
+
overflow: hidden;
|
|
133
|
+
white-space: nowrap;
|
|
95
134
|
}
|
|
135
|
+
.md-table {
|
|
136
|
+
display: table;
|
|
137
|
+
table-layout: auto;
|
|
138
|
+
width: max-content;
|
|
139
|
+
min-width: 100%;
|
|
140
|
+
border-collapse: separate;
|
|
141
|
+
border-spacing: 0;
|
|
142
|
+
font-size: 26rpx;
|
|
143
|
+
}
|
|
144
|
+
.md-tr { display: table-row; }
|
|
96
145
|
.md-th, .md-td {
|
|
97
146
|
display: table-cell;
|
|
98
|
-
padding:
|
|
99
|
-
|
|
147
|
+
padding: 12rpx 20rpx;
|
|
148
|
+
max-width: 480rpx;
|
|
149
|
+
border-right: 2rpx solid #e5e5e5;
|
|
150
|
+
border-bottom: 2rpx solid #e5e5e5;
|
|
151
|
+
text-align: left;
|
|
152
|
+
vertical-align: top;
|
|
153
|
+
word-break: break-word;
|
|
154
|
+
white-space: normal;
|
|
100
155
|
}
|
|
101
156
|
.md-th { background: #fafafa; font-weight: 600; }
|
|
157
|
+
.md-tr .md-th:last-child,
|
|
158
|
+
.md-tr .md-td:last-child { border-right: none; }
|
|
159
|
+
.md-table .md-tr:last-child .md-td { border-bottom: none; }
|
|
102
160
|
|
|
103
161
|
.md-html { display: block; }
|
|
@@ -16,6 +16,14 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
16
16
|
// src/components/wechat/MiniNodeRenderer/index.ts
|
|
17
17
|
var MiniNodeRenderer_exports = {};
|
|
18
18
|
module.exports = __toCommonJS(MiniNodeRenderer_exports);
|
|
19
|
+
function copyToClipboard(text) {
|
|
20
|
+
if (!text) return;
|
|
21
|
+
wx.setClipboardData({
|
|
22
|
+
data: text,
|
|
23
|
+
success: () => wx.showToast({ title: "\u5DF2\u590D\u5236", icon: "none", duration: 1200 }),
|
|
24
|
+
fail: () => wx.showToast({ title: "\u590D\u5236\u5931\u8D25", icon: "none" })
|
|
25
|
+
});
|
|
26
|
+
}
|
|
19
27
|
Component({
|
|
20
28
|
options: {
|
|
21
29
|
multipleSlots: true,
|
|
@@ -34,6 +42,10 @@ Component({
|
|
|
34
42
|
},
|
|
35
43
|
_appear(e) {
|
|
36
44
|
this.triggerEvent("appear", e, { bubbles: true, composed: true });
|
|
45
|
+
},
|
|
46
|
+
_copy(e) {
|
|
47
|
+
const ds = e && e.currentTarget && e.currentTarget.dataset;
|
|
48
|
+
copyToClipboard(ds && ds.copy || "");
|
|
37
49
|
}
|
|
38
50
|
}
|
|
39
51
|
});
|