@bytechain.cn/colamd 2.7.8-rc.1 → 2.7.9
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/main/chunks/docx-export.js +657 -116
- package/dist/main/chunks/math-export.js +161 -0
- package/dist/main/index.js +35 -1
- package/dist/preload/index.js +2 -0
- package/dist/renderer/assets/{2DXBBFLN-ocNdN1uw.js → 2DXBBFLN-BZbS7Pd1.js} +4 -4
- package/dist/renderer/assets/{46IJ22JX-CW4U2qxX.js → 46IJ22JX-CNFviTsR.js} +5 -5
- package/dist/renderer/assets/{4TTDE5I4-D8ms4N1R.js → 4TTDE5I4-C7pizLRz.js} +3 -3
- package/dist/renderer/assets/{4UF3HTLV-BzqW54nj.js → 4UF3HTLV-Bgp6lNzK.js} +4 -4
- package/dist/renderer/assets/{AAXQQPKT-ZKol9lXb.js → AAXQQPKT-DiRTivQz.js} +8 -8
- package/dist/renderer/assets/{AKE5O7KZ-H-pe0TLq.js → AKE5O7KZ-DB0fY69K.js} +5 -5
- package/dist/renderer/assets/{BNMLP6AG-CozSAPVO.js → BNMLP6AG-B895CsjY.js} +7 -7
- package/dist/renderer/assets/{DR6PKOQU-BT2uwVtN.js → DR6PKOQU-CrswvvVG.js} +3 -3
- package/dist/renderer/assets/{E4RJ7UJB-DJpjg8i0.js → E4RJ7UJB-Dgy0Anf4.js} +6 -6
- package/dist/renderer/assets/{ELSXBIJH-ByLiLwVh.js → ELSXBIJH-Bg-hsqjD.js} +1 -1
- package/dist/renderer/assets/{ERTIBQVS-DtgkV5Er.js → ERTIBQVS-BNxjgPXX.js} +4 -4
- package/dist/renderer/assets/{F653G4FO-D3eJtPrn.js → F653G4FO-Dt3YtuWS.js} +8 -8
- package/dist/renderer/assets/{FKCDD66M-CCYmJoGO.js → FKCDD66M-CenzCJNz.js} +1 -1
- package/dist/renderer/assets/{FP7KDXVC-vZ0TYC0r.js → FP7KDXVC-BmH1Qg4f.js} +6 -6
- package/dist/renderer/assets/{FT5I3RHX-Brm3_Qt0.js → FT5I3RHX-Dd_6diyz.js} +7 -7
- package/dist/renderer/assets/{GY35JXOZ-BeQu6w03.js → GY35JXOZ-Cz54qXE9.js} +4 -4
- package/dist/renderer/assets/{H5EEJPP2-BWYooK0Y.js → H5EEJPP2-FerEQPg3.js} +9 -9
- package/dist/renderer/assets/{HWDLEDTA-Dsh9L_sn.js → HWDLEDTA-dKG_tB6l.js} +1 -1
- package/dist/renderer/assets/{JZWSX6AR-C70mE9_I.js → JZWSX6AR-DGqy6mhj.js} +2 -2
- package/dist/renderer/assets/{KQOEJWJY-B5PiIUbK.js → KQOEJWJY-RpP1RapT.js} +1 -1
- package/dist/renderer/assets/{KS3BB3KE-DS5zytZe.js → KS3BB3KE-ChYPdbg1.js} +5 -5
- package/dist/renderer/assets/{KXJRRZHI-h3IoWNmT.js → KXJRRZHI-DSLhPV79.js} +3 -3
- package/dist/renderer/assets/{MFVI5XKI-DBluxjPi.js → MFVI5XKI-C1-R608I.js} +1 -1
- package/dist/renderer/assets/{MWY2J62P-BhNMmpkI.js → MWY2J62P-CYEJcQI7.js} +5 -5
- package/dist/renderer/assets/{MXGNCBL2-ERnAcXsb.js → MXGNCBL2-DEhdb9Po.js} +5 -5
- package/dist/renderer/assets/{N6DAJLIZ-CCw9Llff.js → N6DAJLIZ-Jz5IcMsB.js} +2 -2
- package/dist/renderer/assets/{NU5M23IW-BiuqBfD9.js → NU5M23IW-C8k8MpXh.js} +5 -5
- package/dist/renderer/assets/{NV4XNBIS-eb9rHXjC.js → NV4XNBIS-BCaP1w8q.js} +7 -7
- package/dist/renderer/assets/{OGLU4SIR-wmQFiy7F.js → OGLU4SIR-OGqdd7qE.js} +5 -5
- package/dist/renderer/assets/{OUNS5N76-C60GppNV.js → OUNS5N76-p6wVW2dP.js} +6 -6
- package/dist/renderer/assets/{PU4ISKXV-CkkIdjfm.js → PU4ISKXV-D-ZMREMw.js} +5 -5
- package/dist/renderer/assets/{PUZGS23X-D8xumSyi.js → PUZGS23X-DsbrgiWg.js} +1 -1
- package/dist/renderer/assets/{Q3IYVLG5-DeTmPOTn.js → Q3IYVLG5-BpItOJB9.js} +5 -5
- package/dist/renderer/assets/{QYHQDLKZ-DqOBYl5L.js → QYHQDLKZ-Dm9JiJIz.js} +9 -9
- package/dist/renderer/assets/{RZSVICHU-DIzmobkX.js → RZSVICHU-Chf4nk49.js} +1 -1
- package/dist/renderer/assets/{UEXXS2NB-CYDWJ2KO.js → UEXXS2NB-Bm2T4HQE.js} +1 -1
- package/dist/renderer/assets/{UHTQJXKL-HX94GYaC.js → UHTQJXKL-Y4ThTfXK.js} +5 -5
- package/dist/renderer/assets/{URA2L2QI-khybz_tg.js → URA2L2QI-DkaJzKIj.js} +1 -1
- package/dist/renderer/assets/{UXCHDUKG-QXpNrHim.js → UXCHDUKG-D6Ae72SJ.js} +5 -5
- package/dist/renderer/assets/{VKNV3BUX-C2O2Bs2U.js → VKNV3BUX-CQYQjCVp.js} +6 -6
- package/dist/renderer/assets/{VMV7XPHP-D1gPv1dO.js → VMV7XPHP-CKz3lx9e.js} +1 -1
- package/dist/renderer/assets/{WEVWDWVA-DG15XyXu.js → WEVWDWVA-DXDXU985.js} +1 -1
- package/dist/renderer/assets/{XRRJ35LF-DmN6YDeJ.js → XRRJ35LF-C66qdAcN.js} +4 -4
- package/dist/renderer/assets/{YFKBLVVN-DeryBzcE.js → YFKBLVVN-B1JutB4t.js} +4 -4
- package/dist/renderer/assets/{YHRE5QGZ-DwPShfQy.js → YHRE5QGZ-BoAzNT7K.js} +7 -7
- package/dist/renderer/assets/{ZF3OVT4B-DHBhtnZM.js → ZF3OVT4B-tBhjRApP.js} +3 -3
- package/dist/renderer/assets/{index-BouhGB9m.js → index-6XszqTLE.js} +1 -1
- package/dist/renderer/assets/{index-BF0P_ZMG.js → index-8VmLWls0.js} +1 -1
- package/dist/renderer/assets/{index-D1MMw9tV.js → index-BHNBF13i.js} +1 -1
- package/dist/renderer/assets/{index-bx07CRyn.css → index-BSrZe3ki.css} +54 -17
- package/dist/renderer/assets/{index-CGuZJqP1.js → index-Bcx2JMPS.js} +513 -104
- package/dist/renderer/assets/{index-Ur2F7eWX.js → index-Bk6TVqB_.js} +1 -1
- package/dist/renderer/assets/{index-xTPwwfve.js → index-Bz1F6_A_.js} +1 -1
- package/dist/renderer/assets/{index-JyyTb9ao.js → index-C1fw6u5V.js} +1 -1
- package/dist/renderer/assets/{index-DEcNnx9-.js → index-CAuNb95h.js} +1 -1
- package/dist/renderer/assets/{index-DvMk4oid.js → index-CQ2EdLQr.js} +1 -1
- package/dist/renderer/assets/{index-CgES-9Rd.js → index-CZRO_PAZ.js} +1 -1
- package/dist/renderer/assets/{index-toqSlBnN.js → index-Coye68JD.js} +1 -1
- package/dist/renderer/assets/{index-BbOLrTvz.js → index-CxqBaXly.js} +1 -1
- package/dist/renderer/assets/{index-m-tHhRHA.js → index-DROMWNcj.js} +1 -1
- package/dist/renderer/assets/{index-CVN17YgJ.js → index-DUg0by2F.js} +1 -1
- package/dist/renderer/assets/{index-B06HNuaq.js → index-Dg6oPZ5w.js} +3 -3
- package/dist/renderer/assets/{index-B9Bbyah6.js → index-Dl8YooLt.js} +3 -3
- package/dist/renderer/assets/{index-DqNxG-Ug.js → index-Dqlv2y9T.js} +1 -1
- package/dist/renderer/assets/{index-DpKK1T1J.js → index-HSHw3F3k.js} +1 -1
- package/dist/renderer/assets/{index-CY9PQWw8.js → index-KKUqPjEB.js} +1 -1
- package/dist/renderer/assets/{index-DZhqeNYh.js → index-UzBrnlvb.js} +1 -1
- package/dist/renderer/assets/{index-CHTW9ZSi.js → index-eBhE19Gh.js} +1 -1
- package/dist/renderer/assets/{index-sM1jjx0F.js → index-k6oLH39v.js} +3 -3
- package/dist/renderer/assets/{lazy-BH99YeD2.js → lazy-DVRRTm-q.js} +3 -3
- package/dist/renderer/assets/{web-CXfy2WqP.js → web-CAJ9chii.js} +1 -1
- package/dist/renderer/assets/{web-B00tb1nG.js → web-Ct-G5Yg8.js} +2 -2
- package/dist/renderer/assets/{web-CTn_ehbD.js → web-Y168OUbw.js} +1 -1
- package/dist/renderer/index.html +2 -2
- package/package.json +1 -1
- package/scripts/theme-verify-core.mjs +345 -345
- package/scripts/verify-themes-cli.mjs +95 -95
- package/themes/contract.json +128 -127
- package/themes/elegant.css +0 -1
- package/themes/sepia.css +0 -1
- package/themes/template.css +1 -1
|
@@ -18588,7 +18588,7 @@ var SETTINGS_SCHEMA = {
|
|
|
18588
18588
|
default: "#cc0000",
|
|
18589
18589
|
cli: "-c, --error-color <color>",
|
|
18590
18590
|
cliDescription: "A color string given in the format 'rgb' or 'rrggbb' (no #). This option determines the color of errors rendered by the -t option.",
|
|
18591
|
-
cliProcessor: (
|
|
18591
|
+
cliProcessor: (color2) => "#" + color2
|
|
18592
18592
|
},
|
|
18593
18593
|
macros: {
|
|
18594
18594
|
type: "object",
|
|
@@ -19251,9 +19251,9 @@ var initNode = function initNode2(classes, options2, style) {
|
|
|
19251
19251
|
if (options2.style.isTight()) {
|
|
19252
19252
|
this.classes.push("mtight");
|
|
19253
19253
|
}
|
|
19254
|
-
var
|
|
19255
|
-
if (
|
|
19256
|
-
this.style.color =
|
|
19254
|
+
var color2 = options2.getColor();
|
|
19255
|
+
if (color2) {
|
|
19256
|
+
this.style.color = color2;
|
|
19257
19257
|
}
|
|
19258
19258
|
}
|
|
19259
19259
|
};
|
|
@@ -22749,9 +22749,9 @@ var makeSymbol = function makeSymbol2(value, fontName, mode, options2, classes)
|
|
|
22749
22749
|
if (options2.style.isTight()) {
|
|
22750
22750
|
symbolNode.classes.push("mtight");
|
|
22751
22751
|
}
|
|
22752
|
-
var
|
|
22753
|
-
if (
|
|
22754
|
-
symbolNode.style.color =
|
|
22752
|
+
var color2 = options2.getColor();
|
|
22753
|
+
if (color2) {
|
|
22754
|
+
symbolNode.style.color = color2;
|
|
22755
22755
|
}
|
|
22756
22756
|
}
|
|
22757
22757
|
return symbolNode;
|
|
@@ -24042,9 +24042,9 @@ class Options {
|
|
|
24042
24042
|
/**
|
|
24043
24043
|
* Create a new options object with the given color.
|
|
24044
24044
|
*/
|
|
24045
|
-
withColor(
|
|
24045
|
+
withColor(color2) {
|
|
24046
24046
|
return this.extend({
|
|
24047
|
-
color
|
|
24047
|
+
color: color2
|
|
24048
24048
|
});
|
|
24049
24049
|
}
|
|
24050
24050
|
/**
|
|
@@ -24397,9 +24397,9 @@ var stretchyEnclose = function stretchyEnclose2(inner2, label, topPad, bottomPad
|
|
|
24397
24397
|
if (/fbox|color|angl/.test(label)) {
|
|
24398
24398
|
img = makeSpan(["stretchy", label], [], options2);
|
|
24399
24399
|
if (label === "fbox") {
|
|
24400
|
-
var
|
|
24401
|
-
if (
|
|
24402
|
-
img.style.borderColor =
|
|
24400
|
+
var color2 = options2.color && options2.getColor();
|
|
24401
|
+
if (color2) {
|
|
24402
|
+
img.style.borderColor = color2;
|
|
24403
24403
|
}
|
|
24404
24404
|
}
|
|
24405
24405
|
} else {
|
|
@@ -25280,12 +25280,12 @@ defineFunction({
|
|
|
25280
25280
|
var {
|
|
25281
25281
|
parser: parser2
|
|
25282
25282
|
} = _ref;
|
|
25283
|
-
var
|
|
25283
|
+
var color2 = assertNodeType(args[0], "color-token").color;
|
|
25284
25284
|
var body = args[1];
|
|
25285
25285
|
return {
|
|
25286
25286
|
type: "color",
|
|
25287
25287
|
mode: parser2.mode,
|
|
25288
|
-
color,
|
|
25288
|
+
color: color2,
|
|
25289
25289
|
body: ordargument(body)
|
|
25290
25290
|
};
|
|
25291
25291
|
},
|
|
@@ -25305,13 +25305,13 @@ defineFunction({
|
|
|
25305
25305
|
parser: parser2,
|
|
25306
25306
|
breakOnTokenText
|
|
25307
25307
|
} = _ref2;
|
|
25308
|
-
var
|
|
25309
|
-
parser2.gullet.macros.set("\\current@color",
|
|
25308
|
+
var color2 = assertNodeType(args[0], "color-token").color;
|
|
25309
|
+
parser2.gullet.macros.set("\\current@color", color2);
|
|
25310
25310
|
var body = parser2.parseExpression(true, breakOnTokenText);
|
|
25311
25311
|
return {
|
|
25312
25312
|
type: "color",
|
|
25313
25313
|
mode: parser2.mode,
|
|
25314
|
-
color,
|
|
25314
|
+
color: color2,
|
|
25315
25315
|
body
|
|
25316
25316
|
};
|
|
25317
25317
|
},
|
|
@@ -26169,15 +26169,15 @@ defineFunction({
|
|
|
26169
26169
|
primitive: true
|
|
26170
26170
|
},
|
|
26171
26171
|
handler: (context, args) => {
|
|
26172
|
-
var
|
|
26173
|
-
if (
|
|
26172
|
+
var color2 = context.parser.gullet.macros.get("\\current@color");
|
|
26173
|
+
if (color2 && typeof color2 !== "string") {
|
|
26174
26174
|
throw new ParseError("\\current@color set to non-string in \\right");
|
|
26175
26175
|
}
|
|
26176
26176
|
return {
|
|
26177
26177
|
type: "leftright-right",
|
|
26178
26178
|
mode: context.parser.mode,
|
|
26179
26179
|
delim: checkDelimiter(args[0], context).text,
|
|
26180
|
-
color
|
|
26180
|
+
color: color2
|
|
26181
26181
|
// undefined if not set via \color
|
|
26182
26182
|
};
|
|
26183
26183
|
}
|
|
@@ -26496,13 +26496,13 @@ defineFunction({
|
|
|
26496
26496
|
parser: parser2,
|
|
26497
26497
|
funcName
|
|
26498
26498
|
} = _ref;
|
|
26499
|
-
var
|
|
26499
|
+
var color2 = assertNodeType(args[0], "color-token").color;
|
|
26500
26500
|
var body = args[1];
|
|
26501
26501
|
return {
|
|
26502
26502
|
type: "enclose",
|
|
26503
26503
|
mode: parser2.mode,
|
|
26504
26504
|
label: funcName,
|
|
26505
|
-
backgroundColor:
|
|
26505
|
+
backgroundColor: color2,
|
|
26506
26506
|
body
|
|
26507
26507
|
};
|
|
26508
26508
|
},
|
|
@@ -29455,9 +29455,9 @@ defineFunction({
|
|
|
29455
29455
|
var width = calculateSize(group.width, options2);
|
|
29456
29456
|
var height = calculateSize(group.height, options2);
|
|
29457
29457
|
var shift2 = group.shift ? calculateSize(group.shift, options2) : 0;
|
|
29458
|
-
var
|
|
29458
|
+
var color2 = options2.color && options2.getColor() || "black";
|
|
29459
29459
|
var rule = new MathNode("mspace");
|
|
29460
|
-
rule.setAttribute("mathbackground",
|
|
29460
|
+
rule.setAttribute("mathbackground", color2);
|
|
29461
29461
|
rule.setAttribute("width", makeEm(width));
|
|
29462
29462
|
rule.setAttribute("height", makeEm(height));
|
|
29463
29463
|
var wrapper = new MathNode("mpadded", [rule]);
|
|
@@ -32498,14 +32498,14 @@ class Parser2 {
|
|
|
32498
32498
|
if (!match) {
|
|
32499
32499
|
throw new ParseError("Invalid color: '" + res.text + "'", res);
|
|
32500
32500
|
}
|
|
32501
|
-
var
|
|
32502
|
-
if (/^[0-9a-f]{6}$/i.test(
|
|
32503
|
-
|
|
32501
|
+
var color2 = match[0];
|
|
32502
|
+
if (/^[0-9a-f]{6}$/i.test(color2)) {
|
|
32503
|
+
color2 = "#" + color2;
|
|
32504
32504
|
}
|
|
32505
32505
|
return {
|
|
32506
32506
|
type: "color-token",
|
|
32507
32507
|
mode: this.mode,
|
|
32508
|
-
color
|
|
32508
|
+
color: color2
|
|
32509
32509
|
};
|
|
32510
32510
|
}
|
|
32511
32511
|
/**
|
|
@@ -33237,7 +33237,7 @@ const PRINT_PALETTE = {
|
|
|
33237
33237
|
};
|
|
33238
33238
|
let pele = null;
|
|
33239
33239
|
function loadPele() {
|
|
33240
|
-
pele ??= __vitePreload(() => import("./lazy-
|
|
33240
|
+
pele ??= __vitePreload(() => import("./lazy-DVRRTm-q.js").then((n) => n.l), true ? [] : void 0, import.meta.url);
|
|
33241
33241
|
return pele;
|
|
33242
33242
|
}
|
|
33243
33243
|
function withPrintPalette(svg) {
|
|
@@ -33409,6 +33409,18 @@ function pushBlockLines(state, from, to, className, ranges) {
|
|
|
33409
33409
|
function pushListItemLines(state, node, ranges) {
|
|
33410
33410
|
const className = `cm-md-li cm-md-li-${Math.min(listDepth$1(node), 6)}`;
|
|
33411
33411
|
const tree = syntaxTree(state);
|
|
33412
|
+
const path2 = [];
|
|
33413
|
+
let quoted = false;
|
|
33414
|
+
for (let ancestor = node; ancestor; ancestor = ancestor.parent) {
|
|
33415
|
+
if (ancestor.name === "Blockquote") quoted = true;
|
|
33416
|
+
if (ancestor.name !== "ListItem") continue;
|
|
33417
|
+
const list = ancestor.parent;
|
|
33418
|
+
const mark = ancestor.getChild("ListMark");
|
|
33419
|
+
const start = list.name === "OrderedList" && mark ? Number.parseInt(state.sliceDoc(mark.from, mark.to), 10) : void 0;
|
|
33420
|
+
path2.unshift({ list: list.from, item: ancestor.from, ...start === void 0 ? {} : { start } });
|
|
33421
|
+
}
|
|
33422
|
+
const attributes = { "data-list-path": JSON.stringify(path2), "data-list-quoted": String(quoted) };
|
|
33423
|
+
const paragraphs = node.getChildren("Paragraph");
|
|
33412
33424
|
let ownEnd = node.to;
|
|
33413
33425
|
for (let child = node.firstChild; child; child = child.nextSibling) {
|
|
33414
33426
|
if (child.name === "BulletList" || child.name === "OrderedList") {
|
|
@@ -33417,17 +33429,22 @@ function pushListItemLines(state, node, ranges) {
|
|
|
33417
33429
|
}
|
|
33418
33430
|
}
|
|
33419
33431
|
const first = state.doc.lineAt(node.from).number;
|
|
33420
|
-
const
|
|
33432
|
+
const ownLast = state.doc.lineAt(node.to).number;
|
|
33433
|
+
const last2 = node.nextSibling?.name === "ListItem" ? state.doc.lineAt(node.nextSibling.from).number - 1 : ownLast;
|
|
33421
33434
|
for (let n = first; n <= last2; n++) {
|
|
33422
33435
|
const line = state.doc.line(n);
|
|
33423
|
-
if (line.to > ownEnd) {
|
|
33436
|
+
if (n <= ownLast && line.to > ownEnd) {
|
|
33424
33437
|
const indent = /^[ \t]*/.exec(line.text)?.[0].length ?? 0;
|
|
33425
33438
|
const at = Math.min(line.from + indent, line.to);
|
|
33426
33439
|
let owner = tree.resolveInner(at, 1);
|
|
33427
33440
|
while (owner && owner.name !== "ListItem") owner = owner.parent;
|
|
33428
33441
|
if (!owner || owner.from !== node.from) continue;
|
|
33429
33442
|
}
|
|
33430
|
-
|
|
33443
|
+
const paragraph = paragraphs.find((block) => block.from <= line.to && block.to > line.from);
|
|
33444
|
+
ranges.push({ from: line.from, to: line.from, deco: Decoration.line({ class: className, attributes: {
|
|
33445
|
+
...attributes,
|
|
33446
|
+
...paragraph ? { "data-list-paragraph": String(paragraph.from) } : {}
|
|
33447
|
+
} }) });
|
|
33431
33448
|
}
|
|
33432
33449
|
}
|
|
33433
33450
|
const hide = (from, to) => Decoration.replace({});
|
|
@@ -33808,38 +33825,39 @@ function alignOf(delimiter) {
|
|
|
33808
33825
|
if (right) return "right";
|
|
33809
33826
|
return "left";
|
|
33810
33827
|
}
|
|
33811
|
-
const INLINE_RE =
|
|
33828
|
+
const INLINE_RE = /\*\*(?<strong>.+?)\*\*|(?<![\p{L}\p{N}_])__(?<strongU>(?=\S).+?(?<=\S))__(?![\p{L}\p{N}_])|\*(?<em>.+?)\*|(?<![\p{L}\p{N}_])_(?<emU>(?=\S).+?(?<=\S))_(?![\p{L}\p{N}_])|`(?<code>[^`]+)`|~~(?<strike>.+?)~~|!\[(?<alt>[^\]]*)\]\(\s*(?<src><[^>]*>|[^)\s]+)[^)]*\)|\[(?<linkText>[^\]]*)\]\((?<href>[^)]*)\)|<br\s*\/?>/giu;
|
|
33812
33829
|
function appendInline(parent, text2, base2) {
|
|
33813
33830
|
INLINE_RE.lastIndex = 0;
|
|
33814
33831
|
let last2 = 0;
|
|
33815
33832
|
let match;
|
|
33816
33833
|
while ((match = INLINE_RE.exec(text2)) !== null) {
|
|
33817
33834
|
if (match.index > last2) parent.appendChild(document.createTextNode(text2.slice(last2, match.index)));
|
|
33818
|
-
|
|
33835
|
+
const g = match.groups ?? {};
|
|
33836
|
+
if (g.strong !== void 0 || g.strongU !== void 0) {
|
|
33819
33837
|
const el = document.createElement("strong");
|
|
33820
|
-
el.textContent =
|
|
33838
|
+
el.textContent = g.strong ?? g.strongU ?? "";
|
|
33821
33839
|
parent.appendChild(el);
|
|
33822
|
-
} else if (
|
|
33840
|
+
} else if (g.em !== void 0 || g.emU !== void 0) {
|
|
33823
33841
|
const el = document.createElement("em");
|
|
33824
|
-
el.textContent =
|
|
33842
|
+
el.textContent = g.em ?? g.emU ?? "";
|
|
33825
33843
|
parent.appendChild(el);
|
|
33826
|
-
} else if (
|
|
33844
|
+
} else if (g.code !== void 0) {
|
|
33827
33845
|
const el = document.createElement("code");
|
|
33828
|
-
el.textContent =
|
|
33846
|
+
el.textContent = g.code;
|
|
33829
33847
|
parent.appendChild(el);
|
|
33830
|
-
} else if (
|
|
33848
|
+
} else if (g.strike !== void 0) {
|
|
33831
33849
|
const el = document.createElement("s");
|
|
33832
|
-
el.textContent =
|
|
33850
|
+
el.textContent = g.strike;
|
|
33833
33851
|
parent.appendChild(el);
|
|
33834
|
-
} else if (
|
|
33852
|
+
} else if (g.alt !== void 0) {
|
|
33835
33853
|
const img = document.createElement("img");
|
|
33836
|
-
img.src = resolveImageSrc(
|
|
33837
|
-
img.alt =
|
|
33854
|
+
img.src = resolveImageSrc(g.src ?? "", base2);
|
|
33855
|
+
img.alt = g.alt;
|
|
33838
33856
|
parent.appendChild(img);
|
|
33839
|
-
} else if (
|
|
33857
|
+
} else if (g.linkText !== void 0) {
|
|
33840
33858
|
const el = document.createElement("a");
|
|
33841
|
-
el.textContent =
|
|
33842
|
-
const href = (
|
|
33859
|
+
el.textContent = g.linkText || g.href || "";
|
|
33860
|
+
const href = (g.href ?? "").trim();
|
|
33843
33861
|
if (/^https?:\/\//i.test(href)) el.setAttribute("href", href);
|
|
33844
33862
|
parent.appendChild(el);
|
|
33845
33863
|
} else if (/^<br/i.test(match[0])) {
|
|
@@ -34127,6 +34145,8 @@ function collectInline(state, ranges, front) {
|
|
|
34127
34145
|
case "EmphasisMark":
|
|
34128
34146
|
case "StrikethroughMark":
|
|
34129
34147
|
case "CodeMark": {
|
|
34148
|
+
const fence = node.node.parent;
|
|
34149
|
+
if (node.name === "CodeMark" && fence?.name === "FencedCode" && !isBlockActive(state, fence.from, fence.to) && /^(`{3,}|~{3,})\s*mermaid\s*$/.test(state.doc.sliceString(fence.from, state.doc.lineAt(fence.from).to).trim()) && codeInsideFence(state, fence).trim()) break;
|
|
34130
34150
|
ranges.push({ from, to, deco: hide() });
|
|
34131
34151
|
break;
|
|
34132
34152
|
}
|
|
@@ -34308,27 +34328,68 @@ function indentListItem(view, direction) {
|
|
|
34308
34328
|
const range = state.selection.main;
|
|
34309
34329
|
if (!range.empty) return false;
|
|
34310
34330
|
const line = state.doc.lineAt(range.head);
|
|
34311
|
-
|
|
34331
|
+
const self2 = listLine(line.text);
|
|
34332
|
+
if (!self2) return false;
|
|
34312
34333
|
if (direction === 1) {
|
|
34334
|
+
const parent2 = parentItem(state, line, self2.lead);
|
|
34335
|
+
const target = parent2 ? parent2.lead + parent2.width : self2.lead + self2.width;
|
|
34336
|
+
const lead2 = Math.max(target, self2.lead + INDENT.length);
|
|
34337
|
+
const change = freshSublist(state, line, lead2) ? { from: line.from, to: line.from + self2.lead + self2.digits.length, insert: `${" ".repeat(lead2)}1` } : { from: line.from, insert: " ".repeat(lead2 - self2.lead) };
|
|
34313
34338
|
view.dispatch({
|
|
34314
|
-
changes:
|
|
34315
|
-
selection: { anchor: range.head +
|
|
34339
|
+
changes: change,
|
|
34340
|
+
selection: { anchor: range.head + (lead2 - self2.lead) },
|
|
34316
34341
|
scrollIntoView: true,
|
|
34317
34342
|
userEvent: "input"
|
|
34318
34343
|
});
|
|
34319
34344
|
return true;
|
|
34320
34345
|
}
|
|
34321
|
-
const
|
|
34322
|
-
|
|
34323
|
-
|
|
34346
|
+
const parent = parentItem(state, line, self2.lead - 1);
|
|
34347
|
+
const lead = parent ? parent.lead : 0;
|
|
34348
|
+
if (lead >= self2.lead) return false;
|
|
34324
34349
|
view.dispatch({
|
|
34325
|
-
changes: { from: line.from, to: line.from +
|
|
34326
|
-
selection: { anchor: Math.max(line.from, range.head -
|
|
34350
|
+
changes: { from: line.from, to: line.from + self2.lead, insert: " ".repeat(lead) },
|
|
34351
|
+
selection: { anchor: Math.max(line.from + lead, range.head - (self2.lead - lead)) },
|
|
34327
34352
|
scrollIntoView: true,
|
|
34328
34353
|
userEvent: "input"
|
|
34329
34354
|
});
|
|
34330
34355
|
return true;
|
|
34331
34356
|
}
|
|
34357
|
+
function freshSublist(state, line, depth) {
|
|
34358
|
+
const self2 = listLine(line.text);
|
|
34359
|
+
if (!self2 || !self2.digits) return false;
|
|
34360
|
+
for (let number2 = line.number - 1; number2 >= 1; number2--) {
|
|
34361
|
+
const prev = state.doc.line(number2);
|
|
34362
|
+
if (prev.text.trim() === "") break;
|
|
34363
|
+
const prevLine = listLine(prev.text);
|
|
34364
|
+
if (!prevLine) {
|
|
34365
|
+
if (/^[ \t]*/.exec(prev.text)[0].length > depth) continue;
|
|
34366
|
+
break;
|
|
34367
|
+
}
|
|
34368
|
+
if (prevLine.lead === depth) return false;
|
|
34369
|
+
if (prevLine.lead < depth) break;
|
|
34370
|
+
}
|
|
34371
|
+
return true;
|
|
34372
|
+
}
|
|
34373
|
+
function listLine(text2) {
|
|
34374
|
+
const match = LIST_RE.exec(text2);
|
|
34375
|
+
if (!match) return null;
|
|
34376
|
+
const lead = match[1].length;
|
|
34377
|
+
const width = match[0].length - lead - (match[6]?.length ?? 0);
|
|
34378
|
+
return { lead, width, digits: match[3] ?? "" };
|
|
34379
|
+
}
|
|
34380
|
+
function parentItem(state, line, lead) {
|
|
34381
|
+
for (let number2 = line.number - 1; number2 >= 1; number2--) {
|
|
34382
|
+
const prev = state.doc.line(number2);
|
|
34383
|
+
if (prev.text.trim() === "") return null;
|
|
34384
|
+
const prevLine = listLine(prev.text);
|
|
34385
|
+
if (prevLine) {
|
|
34386
|
+
if (prevLine.lead <= lead) return prevLine;
|
|
34387
|
+
continue;
|
|
34388
|
+
}
|
|
34389
|
+
if (/^[ \t]*/.exec(prev.text)[0].length <= lead) return null;
|
|
34390
|
+
}
|
|
34391
|
+
return null;
|
|
34392
|
+
}
|
|
34332
34393
|
const listInput = Prec.high(keymap.of([
|
|
34333
34394
|
{ key: "Enter", run: continueList },
|
|
34334
34395
|
{ key: "Tab", run: (view) => indentListItem(view, 1) },
|
|
@@ -41770,7 +41831,7 @@ function legacy(parser2) {
|
|
|
41770
41831
|
return new LanguageSupport(StreamLanguage.define(parser2));
|
|
41771
41832
|
}
|
|
41772
41833
|
function sql(dialectName) {
|
|
41773
|
-
return __vitePreload(() => import("./index-
|
|
41834
|
+
return __vitePreload(() => import("./index-8VmLWls0.js"), true ? [] : void 0, import.meta.url).then((m) => m.sql({ dialect: m[dialectName] }));
|
|
41774
41835
|
}
|
|
41775
41836
|
const languages = [
|
|
41776
41837
|
// New-style language modes
|
|
@@ -41778,7 +41839,7 @@ const languages = [
|
|
|
41778
41839
|
name: "C",
|
|
41779
41840
|
extensions: ["c", "h", "ino"],
|
|
41780
41841
|
load() {
|
|
41781
|
-
return __vitePreload(() => import("./index-
|
|
41842
|
+
return __vitePreload(() => import("./index-DROMWNcj.js"), true ? [] : void 0, import.meta.url).then((m) => m.cpp());
|
|
41782
41843
|
}
|
|
41783
41844
|
}),
|
|
41784
41845
|
/* @__PURE__ */ LanguageDescription.of({
|
|
@@ -41786,7 +41847,7 @@ const languages = [
|
|
|
41786
41847
|
alias: ["cpp"],
|
|
41787
41848
|
extensions: ["cpp", "c++", "cc", "cxx", "hpp", "h++", "hh", "hxx"],
|
|
41788
41849
|
load() {
|
|
41789
|
-
return __vitePreload(() => import("./index-
|
|
41850
|
+
return __vitePreload(() => import("./index-DROMWNcj.js"), true ? [] : void 0, import.meta.url).then((m) => m.cpp());
|
|
41790
41851
|
}
|
|
41791
41852
|
}),
|
|
41792
41853
|
/* @__PURE__ */ LanguageDescription.of({
|
|
@@ -41808,7 +41869,7 @@ const languages = [
|
|
|
41808
41869
|
name: "Go",
|
|
41809
41870
|
extensions: ["go"],
|
|
41810
41871
|
load() {
|
|
41811
|
-
return __vitePreload(() => import("./index-
|
|
41872
|
+
return __vitePreload(() => import("./index-CAuNb95h.js"), true ? [] : void 0, import.meta.url).then((m) => m.go());
|
|
41812
41873
|
}
|
|
41813
41874
|
}),
|
|
41814
41875
|
/* @__PURE__ */ LanguageDescription.of({
|
|
@@ -41823,7 +41884,7 @@ const languages = [
|
|
|
41823
41884
|
name: "Java",
|
|
41824
41885
|
extensions: ["java"],
|
|
41825
41886
|
load() {
|
|
41826
|
-
return __vitePreload(() => import("./index-
|
|
41887
|
+
return __vitePreload(() => import("./index-HSHw3F3k.js"), true ? [] : void 0, import.meta.url).then((m) => m.java());
|
|
41827
41888
|
}
|
|
41828
41889
|
}),
|
|
41829
41890
|
/* @__PURE__ */ LanguageDescription.of({
|
|
@@ -41838,7 +41899,7 @@ const languages = [
|
|
|
41838
41899
|
name: "Jinja",
|
|
41839
41900
|
extensions: ["j2", "jinja", "jinja2"],
|
|
41840
41901
|
load() {
|
|
41841
|
-
return __vitePreload(() => import("./index-
|
|
41902
|
+
return __vitePreload(() => import("./index-Coye68JD.js"), true ? [] : void 0, import.meta.url).then((m) => m.jinja());
|
|
41842
41903
|
}
|
|
41843
41904
|
}),
|
|
41844
41905
|
/* @__PURE__ */ LanguageDescription.of({
|
|
@@ -41846,7 +41907,7 @@ const languages = [
|
|
|
41846
41907
|
alias: ["json5"],
|
|
41847
41908
|
extensions: ["json", "map"],
|
|
41848
41909
|
load() {
|
|
41849
|
-
return __vitePreload(() => import("./index-
|
|
41910
|
+
return __vitePreload(() => import("./index-CZRO_PAZ.js"), true ? [] : void 0, import.meta.url).then((m) => m.json());
|
|
41850
41911
|
}
|
|
41851
41912
|
}),
|
|
41852
41913
|
/* @__PURE__ */ LanguageDescription.of({
|
|
@@ -41860,14 +41921,14 @@ const languages = [
|
|
|
41860
41921
|
name: "LESS",
|
|
41861
41922
|
extensions: ["less"],
|
|
41862
41923
|
load() {
|
|
41863
|
-
return __vitePreload(() => import("./index-
|
|
41924
|
+
return __vitePreload(() => import("./index-Dqlv2y9T.js"), true ? [] : void 0, import.meta.url).then((m) => m.less());
|
|
41864
41925
|
}
|
|
41865
41926
|
}),
|
|
41866
41927
|
/* @__PURE__ */ LanguageDescription.of({
|
|
41867
41928
|
name: "Liquid",
|
|
41868
41929
|
extensions: ["liquid"],
|
|
41869
41930
|
load() {
|
|
41870
|
-
return __vitePreload(() => import("./index-
|
|
41931
|
+
return __vitePreload(() => import("./index-Bz1F6_A_.js"), true ? [] : void 0, import.meta.url).then((m) => m.liquid());
|
|
41871
41932
|
}
|
|
41872
41933
|
}),
|
|
41873
41934
|
/* @__PURE__ */ LanguageDescription.of({
|
|
@@ -41899,7 +41960,7 @@ const languages = [
|
|
|
41899
41960
|
name: "PHP",
|
|
41900
41961
|
extensions: ["php", "php3", "php4", "php5", "php7", "phtml"],
|
|
41901
41962
|
load() {
|
|
41902
|
-
return __vitePreload(() => import("./index-
|
|
41963
|
+
return __vitePreload(() => import("./index-BHNBF13i.js"), true ? [] : void 0, import.meta.url).then((m) => m.php());
|
|
41903
41964
|
}
|
|
41904
41965
|
}),
|
|
41905
41966
|
/* @__PURE__ */ LanguageDescription.of({
|
|
@@ -41920,28 +41981,28 @@ const languages = [
|
|
|
41920
41981
|
extensions: ["BUILD", "bzl", "py", "pyw"],
|
|
41921
41982
|
filename: /^(BUCK|BUILD)$/,
|
|
41922
41983
|
load() {
|
|
41923
|
-
return __vitePreload(() => import("./index-
|
|
41984
|
+
return __vitePreload(() => import("./index-KKUqPjEB.js"), true ? [] : void 0, import.meta.url).then((m) => m.python());
|
|
41924
41985
|
}
|
|
41925
41986
|
}),
|
|
41926
41987
|
/* @__PURE__ */ LanguageDescription.of({
|
|
41927
41988
|
name: "Rust",
|
|
41928
41989
|
extensions: ["rs"],
|
|
41929
41990
|
load() {
|
|
41930
|
-
return __vitePreload(() => import("./index-
|
|
41991
|
+
return __vitePreload(() => import("./index-Bk6TVqB_.js"), true ? [] : void 0, import.meta.url).then((m) => m.rust());
|
|
41931
41992
|
}
|
|
41932
41993
|
}),
|
|
41933
41994
|
/* @__PURE__ */ LanguageDescription.of({
|
|
41934
41995
|
name: "Sass",
|
|
41935
41996
|
extensions: ["sass"],
|
|
41936
41997
|
load() {
|
|
41937
|
-
return __vitePreload(() => import("./index-
|
|
41998
|
+
return __vitePreload(() => import("./index-CQ2EdLQr.js"), true ? [] : void 0, import.meta.url).then((m) => m.sass({ indented: true }));
|
|
41938
41999
|
}
|
|
41939
42000
|
}),
|
|
41940
42001
|
/* @__PURE__ */ LanguageDescription.of({
|
|
41941
42002
|
name: "SCSS",
|
|
41942
42003
|
extensions: ["scss"],
|
|
41943
42004
|
load() {
|
|
41944
|
-
return __vitePreload(() => import("./index-
|
|
42005
|
+
return __vitePreload(() => import("./index-CQ2EdLQr.js"), true ? [] : void 0, import.meta.url).then((m) => m.sass());
|
|
41945
42006
|
}
|
|
41946
42007
|
}),
|
|
41947
42008
|
/* @__PURE__ */ LanguageDescription.of({
|
|
@@ -41976,7 +42037,7 @@ const languages = [
|
|
|
41976
42037
|
name: "WebAssembly",
|
|
41977
42038
|
extensions: ["wat", "wast"],
|
|
41978
42039
|
load() {
|
|
41979
|
-
return __vitePreload(() => import("./index-
|
|
42040
|
+
return __vitePreload(() => import("./index-CxqBaXly.js"), true ? [] : void 0, import.meta.url).then((m) => m.wast());
|
|
41980
42041
|
}
|
|
41981
42042
|
}),
|
|
41982
42043
|
/* @__PURE__ */ LanguageDescription.of({
|
|
@@ -41984,7 +42045,7 @@ const languages = [
|
|
|
41984
42045
|
alias: ["rss", "wsdl", "xsd"],
|
|
41985
42046
|
extensions: ["xml", "xsl", "xsd", "svg"],
|
|
41986
42047
|
load() {
|
|
41987
|
-
return __vitePreload(() => import("./index-
|
|
42048
|
+
return __vitePreload(() => import("./index-6XszqTLE.js"), true ? [] : void 0, import.meta.url).then((m) => m.xml());
|
|
41988
42049
|
}
|
|
41989
42050
|
}),
|
|
41990
42051
|
/* @__PURE__ */ LanguageDescription.of({
|
|
@@ -41992,7 +42053,7 @@ const languages = [
|
|
|
41992
42053
|
alias: ["yml"],
|
|
41993
42054
|
extensions: ["yaml", "yml"],
|
|
41994
42055
|
load() {
|
|
41995
|
-
return __vitePreload(() => import("./index-
|
|
42056
|
+
return __vitePreload(() => import("./index-UzBrnlvb.js"), true ? [] : void 0, import.meta.url).then((m) => m.yaml());
|
|
41996
42057
|
}
|
|
41997
42058
|
}),
|
|
41998
42059
|
// Legacy modes ported from CodeMirror 5
|
|
@@ -42781,13 +42842,13 @@ const languages = [
|
|
|
42781
42842
|
name: "Vue",
|
|
42782
42843
|
extensions: ["vue"],
|
|
42783
42844
|
load() {
|
|
42784
|
-
return __vitePreload(() => import("./index-
|
|
42845
|
+
return __vitePreload(() => import("./index-C1fw6u5V.js"), true ? [] : void 0, import.meta.url).then((m) => m.vue());
|
|
42785
42846
|
}
|
|
42786
42847
|
}),
|
|
42787
42848
|
/* @__PURE__ */ LanguageDescription.of({
|
|
42788
42849
|
name: "Angular Template",
|
|
42789
42850
|
load() {
|
|
42790
|
-
return __vitePreload(() => import("./index-
|
|
42851
|
+
return __vitePreload(() => import("./index-DUg0by2F.js"), true ? [] : void 0, import.meta.url).then((m) => m.angular());
|
|
42791
42852
|
}
|
|
42792
42853
|
})
|
|
42793
42854
|
];
|
|
@@ -42800,7 +42861,10 @@ const markdownHighlightStyle = HighlightStyle.define([
|
|
|
42800
42861
|
{ tag: tags$1.emphasis, fontStyle: "italic" },
|
|
42801
42862
|
{ tag: tags$1.strikethrough, textDecoration: "line-through" },
|
|
42802
42863
|
{ tag: tags$1.link, color: "var(--link-color)" },
|
|
42803
|
-
|
|
42864
|
+
// 标记字符(`#`、`>`、`***`、围栏)压淡;**正文不许跟着淡**。
|
|
42865
|
+
// `t.list` 曾经也在这条里,它盖住的是列表项里的文字,不只是 `-`、`1.` 那两个字符:
|
|
42866
|
+
// 整个列表都发灰(2026-10-25 报的)。列表的圆点与序号由 editor-preview.css 单独管。
|
|
42867
|
+
{ tag: [tags$1.processingInstruction, tags$1.contentSeparator], color: "var(--text-muted)" },
|
|
42804
42868
|
/* 代码块里的语法着色。解析器在 state.ts 里通过 `codeLanguages` 接进来(装了哪些
|
|
42805
42869
|
语言就认哪些),这里只决定怎么画。
|
|
42806
42870
|
颜色是变量,不是字面值:--code-* 由主题按代码块底色的明暗给两套(见 base.css),
|
|
@@ -42832,6 +42896,8 @@ const editorTheme = EditorView.theme({
|
|
|
42832
42896
|
一旦在这里写 padding,引用块、列表、代码块的内边距会被整片吃掉(实测全为 0px)。
|
|
42833
42897
|
归零与块级内边距都写在 editor-preview.css 里,用同样两个类的选择器,靠文件顺序决胜。 */
|
|
42834
42898
|
".cm-cursor, .cm-dropCursor": { borderLeftColor: "var(--text-color)" },
|
|
42899
|
+
/* 代码块可能是深底(雅致、熊红),光标在里面要跟代码文字同色才看得见。类由 cursor-colors 挂。 */
|
|
42900
|
+
"&.cm-cursor-in-code .cm-cursor-primary, &.cm-drop-in-code .cm-dropCursor": { borderLeftColor: "var(--code-block-text, var(--text-color))" },
|
|
42835
42901
|
/* 选中色只在这里管原生选区。真正画出来的那条色带(.cm-selectionBackground)写在
|
|
42836
42902
|
themes/editor-preview.css:baseTheme 给它的选择器有四个类,这里写不进去;
|
|
42837
42903
|
同优先级时 baseTheme 总在后面。 */
|
|
@@ -43011,7 +43077,7 @@ function stateExtensions() {
|
|
|
43011
43077
|
// 一起。查找是应用级功能,入口在菜单的「查找」上(Cmd+F 由菜单的快捷键发
|
|
43012
43078
|
// `editor:search`),面板在 editor/search-panel.ts。
|
|
43013
43079
|
keymap.of([
|
|
43014
|
-
...defaultKeymap,
|
|
43080
|
+
...defaultKeymap.filter((binding) => binding.key !== "Mod-/"),
|
|
43015
43081
|
...historyKeymap,
|
|
43016
43082
|
indentWithTab
|
|
43017
43083
|
])
|
|
@@ -43023,11 +43089,65 @@ function bodyStart(doc2) {
|
|
|
43023
43089
|
const lineBreak = doc2.indexOf("\n", front.to);
|
|
43024
43090
|
return lineBreak === -1 ? doc2.length : lineBreak + 1;
|
|
43025
43091
|
}
|
|
43092
|
+
function inCodeBlock(state, pos) {
|
|
43093
|
+
const line = state.doc.lineAt(pos);
|
|
43094
|
+
let code = false;
|
|
43095
|
+
state.field(livePreviewField).between(line.from, line.from, (_from, _to, decoration) => {
|
|
43096
|
+
if (decoration.spec.class?.split(" ").includes("cm-md-codeblock")) code = true;
|
|
43097
|
+
});
|
|
43098
|
+
return code;
|
|
43099
|
+
}
|
|
43100
|
+
const setDropInCode = StateEffect.define();
|
|
43101
|
+
const dropInCode = StateField.define({
|
|
43102
|
+
create: () => false,
|
|
43103
|
+
update: (value, tr) => tr.effects.reduce((next, effect) => effect.is(setDropInCode) ? effect.value : next, value)
|
|
43104
|
+
});
|
|
43105
|
+
function setDrop(view, code) {
|
|
43106
|
+
if (view.state.field(dropInCode) !== code) view.dispatch({ effects: setDropInCode.of(code) });
|
|
43107
|
+
}
|
|
43108
|
+
const cursorColors = [
|
|
43109
|
+
dropInCode,
|
|
43110
|
+
EditorView.domEventObservers({
|
|
43111
|
+
dragover(event, view) {
|
|
43112
|
+
const pos = view.posAtCoords({ x: event.clientX, y: event.clientY });
|
|
43113
|
+
setDrop(view, pos !== null && inCodeBlock(view.state, pos));
|
|
43114
|
+
},
|
|
43115
|
+
// 判据与 CodeMirror 的 dropCursor 一致:真的离开了编辑区才算
|
|
43116
|
+
dragleave(event, view) {
|
|
43117
|
+
if (event.target === view.contentDOM || !view.contentDOM.contains(event.relatedTarget)) setDrop(view, false);
|
|
43118
|
+
},
|
|
43119
|
+
dragend: (_event, view) => setDrop(view, false),
|
|
43120
|
+
drop: (_event, view) => setDrop(view, false)
|
|
43121
|
+
}),
|
|
43122
|
+
EditorView.editorAttributes.compute(["selection", livePreviewField, dropInCode], (state) => {
|
|
43123
|
+
const classes = [
|
|
43124
|
+
inCodeBlock(state, state.selection.main.head) ? "cm-cursor-in-code" : "",
|
|
43125
|
+
state.field(dropInCode) ? "cm-drop-in-code" : ""
|
|
43126
|
+
].filter(Boolean);
|
|
43127
|
+
return classes.length ? { class: classes.join(" ") } : {};
|
|
43128
|
+
})
|
|
43129
|
+
];
|
|
43026
43130
|
let handle$1 = null;
|
|
43027
43131
|
function getEditorHandle() {
|
|
43028
43132
|
return handle$1;
|
|
43029
43133
|
}
|
|
43030
43134
|
const livePreviewCompartment = new Compartment();
|
|
43135
|
+
const taskMarkerAtomicRanges = EditorView.atomicRanges.of((view) => {
|
|
43136
|
+
const doc2 = view.state.doc;
|
|
43137
|
+
const ranges = [];
|
|
43138
|
+
syntaxTree(view.state).iterate({
|
|
43139
|
+
enter: (node) => {
|
|
43140
|
+
if (node.name !== "TaskMarker") return;
|
|
43141
|
+
const line = doc2.lineAt(node.from);
|
|
43142
|
+
const prefix = doc2.sliceString(line.from, node.from);
|
|
43143
|
+
const from = /^[ \t]*(?:[-*+]|\d+[.)])[ \t]+$/.test(prefix) ? line.from : node.from;
|
|
43144
|
+
const trailing = doc2.sliceString(node.to, Math.min(node.to + 1, line.to)) === " " ? node.to + 1 : node.to;
|
|
43145
|
+
ranges.push({ from, to: trailing });
|
|
43146
|
+
}
|
|
43147
|
+
});
|
|
43148
|
+
return RangeSet.of(ranges.map((r) => ATOMIC_MARK.range(r.from, r.to)), true);
|
|
43149
|
+
});
|
|
43150
|
+
const ATOMIC_MARK = Decoration.replace({});
|
|
43031
43151
|
function isSourceMode(state) {
|
|
43032
43152
|
return state.field(livePreviewField, false) === void 0;
|
|
43033
43153
|
}
|
|
@@ -43037,6 +43157,7 @@ function editorExtensions(sourceMode, editable2, onChange) {
|
|
|
43037
43157
|
stateExtensions(),
|
|
43038
43158
|
// 以下是 view 层:选区绘制、拖放光标、特殊字符、主题
|
|
43039
43159
|
drawSelection(),
|
|
43160
|
+
cursorColors,
|
|
43040
43161
|
// 自动换行。CodeMirror 默认**不换行**,长行会横向滚动;markdown 正文必须换行。
|
|
43041
43162
|
EditorView.lineWrapping,
|
|
43042
43163
|
dropCursor(),
|
|
@@ -43066,6 +43187,10 @@ function editorExtensions(sourceMode, editable2, onChange) {
|
|
|
43066
43187
|
// 检索高亮。面板靠 effect 改它,而 effect 得有 StateField 接住;
|
|
43067
43188
|
// 不装这一条,检索面板会以为高亮画上了,实际什么也没发生。
|
|
43068
43189
|
searchHighlightField,
|
|
43190
|
+
// 任务项的复选框是一个 replace widget,但没声明成原子区间时,光标能停在
|
|
43191
|
+
// `[ ]` 两个方框之间那一格里:左右键要一格一格挪过去,停在里面打字又把
|
|
43192
|
+
// `- [ ]` 敲成 `- [x]` 之类的残骸(#164)。声明成原子区间后,光标一次跨过它。
|
|
43193
|
+
taskMarkerAtomicRanges,
|
|
43069
43194
|
editableCompartment.of(EditorView.editable.of(editable2)),
|
|
43070
43195
|
// 文档变化的唯一出口:把新文本交给外壳
|
|
43071
43196
|
EditorView.updateListener.of((update) => {
|
|
@@ -43149,7 +43274,7 @@ function escapeText(value) {
|
|
|
43149
43274
|
function escapeAttribute(value) {
|
|
43150
43275
|
return escapeText(value).replace(/"/g, """);
|
|
43151
43276
|
}
|
|
43152
|
-
function lineKind(line) {
|
|
43277
|
+
function lineKind(line, includeList = true) {
|
|
43153
43278
|
const classes = line.classList;
|
|
43154
43279
|
for (let level = 1; level <= 6; level++) {
|
|
43155
43280
|
if (classes.contains(`cm-md-atxheading${level}`)) return `h${level}`;
|
|
@@ -43161,7 +43286,7 @@ function lineKind(line) {
|
|
|
43161
43286
|
if (classes.contains("cm-md-hr")) return "hr";
|
|
43162
43287
|
if (line.querySelector(".cm-md-table-widget")) return "table";
|
|
43163
43288
|
if (classes.contains("cm-md-frontmatter")) return "empty";
|
|
43164
|
-
for (let depth = 0; depth <= 6; depth++) {
|
|
43289
|
+
if (includeList) for (let depth = 0; depth <= 6; depth++) {
|
|
43165
43290
|
if (classes.contains(`cm-md-li-${depth}`)) return "li";
|
|
43166
43291
|
}
|
|
43167
43292
|
if ((line.textContent ?? "").trim() === "" && line.querySelector("img") === null) return "empty";
|
|
@@ -43243,6 +43368,34 @@ function renderList(lines) {
|
|
|
43243
43368
|
while (open2.length > 0) html2 += `</li></${tagOf(open2.pop().ordered)}>`;
|
|
43244
43369
|
return html2;
|
|
43245
43370
|
}
|
|
43371
|
+
function listContext(node) {
|
|
43372
|
+
if (!(node instanceof HTMLElement)) return null;
|
|
43373
|
+
const line = node.classList.contains("cm-line") ? node : node.querySelector(".cm-line");
|
|
43374
|
+
if (!line?.classList.contains("cm-md-li") || !line.dataset.listPath) return null;
|
|
43375
|
+
return { path: JSON.parse(line.dataset.listPath), quoted: line.dataset.listQuoted === "true" };
|
|
43376
|
+
}
|
|
43377
|
+
function renderOwnedList(nodes, depth) {
|
|
43378
|
+
let html2 = "", index2 = 0;
|
|
43379
|
+
while (index2 < nodes.length) {
|
|
43380
|
+
const first = listContext(nodes[index2]).path[depth];
|
|
43381
|
+
const tag = first.start === void 0 ? "ul" : "ol";
|
|
43382
|
+
html2 += first.start !== void 0 && first.start !== 1 ? `<ol start="${first.start}">` : `<${tag}>`;
|
|
43383
|
+
while (index2 < nodes.length && listContext(nodes[index2]).path[depth].list === first.list) {
|
|
43384
|
+
const item = listContext(nodes[index2]).path[depth].item;
|
|
43385
|
+
const group = [];
|
|
43386
|
+
while (index2 < nodes.length) {
|
|
43387
|
+
const path2 = listContext(nodes[index2]).path[depth];
|
|
43388
|
+
if (path2.list !== first.list || path2.item !== item) break;
|
|
43389
|
+
group.push(nodes[index2++]);
|
|
43390
|
+
}
|
|
43391
|
+
const body = blocksHTML(group, depth);
|
|
43392
|
+
const singleParagraph = body.startsWith("<p>") && body.indexOf("</p>") === body.length - 4;
|
|
43393
|
+
html2 += `<li>${singleParagraph ? body.slice(3, -4).trimStart() : body}</li>`;
|
|
43394
|
+
}
|
|
43395
|
+
html2 += `</${tag}>`;
|
|
43396
|
+
}
|
|
43397
|
+
return html2;
|
|
43398
|
+
}
|
|
43246
43399
|
function isCodeFenceStart(line) {
|
|
43247
43400
|
return line.classList.contains("cm-md-codeblock-first") || /^(`{3,}|~{3,})/.test((line.textContent ?? "").trimStart());
|
|
43248
43401
|
}
|
|
@@ -43260,7 +43413,7 @@ function renderCode(lines) {
|
|
|
43260
43413
|
const code = body.map((line) => line.textContent ?? "").join("\n");
|
|
43261
43414
|
return `<pre><code>${escapeText(code)}</code></pre>`;
|
|
43262
43415
|
}
|
|
43263
|
-
function renderGroup(kind, lines) {
|
|
43416
|
+
function renderGroup(kind, lines, ownerDepth = -1) {
|
|
43264
43417
|
if (kind === "code") return renderCode(lines);
|
|
43265
43418
|
if (kind === "mermaid") {
|
|
43266
43419
|
const widget = lines[0].querySelector(".cm-md-mermaid");
|
|
@@ -43287,16 +43440,53 @@ function renderGroup(kind, lines) {
|
|
|
43287
43440
|
const level = kind.slice(1);
|
|
43288
43441
|
return `<h${level}>${lineHTML(lines[0])}</h${level}>`;
|
|
43289
43442
|
}
|
|
43290
|
-
|
|
43443
|
+
const separator = ownerDepth >= 0 && lines.length > 1 ? "<br>" : "\n";
|
|
43444
|
+
return `<p>${lines.map((line) => {
|
|
43445
|
+
const content2 = lineHTML(line);
|
|
43446
|
+
return line.dataset.listPath ? content2.replace(/^[ \t]+/, "") : content2;
|
|
43447
|
+
}).join(separator)}</p>`;
|
|
43291
43448
|
}
|
|
43292
43449
|
function mergeable(kind) {
|
|
43293
43450
|
return kind === "code" || kind === "li" || kind === "quote";
|
|
43294
43451
|
}
|
|
43295
|
-
function blocksHTML(nodes) {
|
|
43452
|
+
function blocksHTML(nodes, ownerDepth = -1) {
|
|
43296
43453
|
let html2 = "";
|
|
43297
43454
|
let index2 = 0;
|
|
43455
|
+
let quoteEnd = 0;
|
|
43298
43456
|
while (index2 < nodes.length) {
|
|
43299
43457
|
const node = nodes[index2];
|
|
43458
|
+
const context = listContext(node);
|
|
43459
|
+
if (index2 >= quoteEnd && node instanceof HTMLElement && node.classList.contains("cm-md-blockquote") && (!context || context.quoted || context.path.length <= ownerDepth + 1)) {
|
|
43460
|
+
const group2 = [node];
|
|
43461
|
+
let next = index2 + 1;
|
|
43462
|
+
while (next < nodes.length) {
|
|
43463
|
+
const candidate = nodes[next];
|
|
43464
|
+
if (!(candidate instanceof HTMLElement) || !candidate.classList.contains("cm-md-blockquote")) break;
|
|
43465
|
+
group2.push(candidate);
|
|
43466
|
+
next += 1;
|
|
43467
|
+
}
|
|
43468
|
+
quoteEnd = next;
|
|
43469
|
+
if (group2.some((line) => listContext(line))) {
|
|
43470
|
+
const inner2 = group2.map((line) => {
|
|
43471
|
+
const clone = line.cloneNode(true);
|
|
43472
|
+
clone.classList.remove("cm-md-blockquote");
|
|
43473
|
+
return clone;
|
|
43474
|
+
});
|
|
43475
|
+
html2 += `<blockquote>${blocksHTML(inner2, ownerDepth)}</blockquote>`;
|
|
43476
|
+
index2 = next;
|
|
43477
|
+
continue;
|
|
43478
|
+
}
|
|
43479
|
+
}
|
|
43480
|
+
if (context && context.path.length > ownerDepth + 1) {
|
|
43481
|
+
const group2 = [node];
|
|
43482
|
+
while (++index2 < nodes.length) {
|
|
43483
|
+
if ((listContext(nodes[index2])?.path.length ?? 0) <= ownerDepth + 1) break;
|
|
43484
|
+
group2.push(nodes[index2]);
|
|
43485
|
+
}
|
|
43486
|
+
const depth = ownerDepth < 0 ? group2.reduce((min, part) => Math.min(min, listContext(part).path.length - 1), context.path.length - 1) : ownerDepth + 1;
|
|
43487
|
+
html2 += renderOwnedList(group2, depth);
|
|
43488
|
+
continue;
|
|
43489
|
+
}
|
|
43300
43490
|
if (!isLineElement(node)) {
|
|
43301
43491
|
const inline = [];
|
|
43302
43492
|
while (index2 < nodes.length && !isLineElement(nodes[index2])) {
|
|
@@ -43307,13 +43497,14 @@ function blocksHTML(nodes) {
|
|
|
43307
43497
|
if (merged.trim() !== "") html2 += `<p>${merged}</p>`;
|
|
43308
43498
|
continue;
|
|
43309
43499
|
}
|
|
43310
|
-
const kind = lineKind(node);
|
|
43500
|
+
const kind = lineKind(node, !context);
|
|
43311
43501
|
const group = [node];
|
|
43312
|
-
|
|
43502
|
+
const paragraph = node.dataset.listParagraph;
|
|
43503
|
+
if (mergeable(kind) || kind === "p" && paragraph) {
|
|
43313
43504
|
let next = index2 + 1;
|
|
43314
43505
|
while (next < nodes.length) {
|
|
43315
43506
|
const candidate = nodes[next];
|
|
43316
|
-
if (!(candidate instanceof HTMLElement) || lineKind(candidate) !== kind) break;
|
|
43507
|
+
if (!(candidate instanceof HTMLElement) || lineKind(candidate, !listContext(candidate)) !== kind || kind === "p" && candidate.dataset.listParagraph !== paragraph) break;
|
|
43317
43508
|
group.push(candidate);
|
|
43318
43509
|
next += 1;
|
|
43319
43510
|
}
|
|
@@ -43321,7 +43512,7 @@ function blocksHTML(nodes) {
|
|
|
43321
43512
|
} else {
|
|
43322
43513
|
index2 += 1;
|
|
43323
43514
|
}
|
|
43324
|
-
html2 += renderGroup(kind, group);
|
|
43515
|
+
html2 += renderGroup(kind, group, ownerDepth);
|
|
43325
43516
|
}
|
|
43326
43517
|
return html2;
|
|
43327
43518
|
}
|
|
@@ -43873,12 +44064,12 @@ function setupFootnotePreview(root) {
|
|
|
43873
44064
|
}
|
|
43874
44065
|
const TASK_RE = /^([ \t]*(?:[-*+]|\d+[.)])[ \t]+\[)([ xX])(\])/;
|
|
43875
44066
|
function sourceFromTaskClick(view, e) {
|
|
44067
|
+
if (!(e.target instanceof HTMLElement)) return null;
|
|
44068
|
+
if (!e.target.closest(".cm-md-task")) return null;
|
|
43876
44069
|
const pos = view.posAtCoords({ x: e.clientX, y: e.clientY });
|
|
43877
44070
|
if (pos === null) return null;
|
|
43878
44071
|
const line = view.state.doc.lineAt(pos);
|
|
43879
44072
|
if (!TASK_RE.test(line.text)) return null;
|
|
43880
|
-
const rect = e.target.getBoundingClientRect();
|
|
43881
|
-
if (e.clientX - rect.left > 24) return null;
|
|
43882
44073
|
return line.from;
|
|
43883
44074
|
}
|
|
43884
44075
|
function toggleTaskAt(view, pos) {
|
|
@@ -44008,6 +44199,211 @@ async function markdownForWord(markdown2, chinese) {
|
|
|
44008
44199
|
pieces.push(markdown2.slice(cursor));
|
|
44009
44200
|
return { content: pieces.join(""), images };
|
|
44010
44201
|
}
|
|
44202
|
+
const EMPTY$1 = { images: {}, sizes: {} };
|
|
44203
|
+
const CSS_URL = /url\(\s*(?:'([^']*)'|"([^"]*)"|([^'")]+))\s*\)/g;
|
|
44204
|
+
function absolutize(css2, base2) {
|
|
44205
|
+
return css2.replace(CSS_URL, (match, single, double, plain) => {
|
|
44206
|
+
const value = (single ?? double ?? plain ?? "").trim();
|
|
44207
|
+
if (!value || /^(data:|https?:|file:|#|\/\/)/i.test(value)) return match;
|
|
44208
|
+
try {
|
|
44209
|
+
return `url("${new URL(value, base2).href}")`;
|
|
44210
|
+
} catch {
|
|
44211
|
+
return match;
|
|
44212
|
+
}
|
|
44213
|
+
});
|
|
44214
|
+
}
|
|
44215
|
+
function wordExportStyles() {
|
|
44216
|
+
let text2 = "";
|
|
44217
|
+
for (const sheet of Array.from(document.styleSheets)) {
|
|
44218
|
+
try {
|
|
44219
|
+
const base2 = sheet.href ?? document.baseURI;
|
|
44220
|
+
for (const rule of Array.from(sheet.cssRules)) text2 += absolutize(rule.cssText, base2) + "\n";
|
|
44221
|
+
} catch {
|
|
44222
|
+
}
|
|
44223
|
+
}
|
|
44224
|
+
return text2;
|
|
44225
|
+
}
|
|
44226
|
+
async function markdownWithMathImages(markdown2, chinese, color2) {
|
|
44227
|
+
const api = window.electronAPI;
|
|
44228
|
+
if (!api?.renderMathImages) return { content: markdown2, ...EMPTY$1 };
|
|
44229
|
+
const ranges = scanMath(markdown2, excludedRanges(markdown2, markdownLanguage.parser.parse(markdown2)));
|
|
44230
|
+
if (ranges.length === 0) return { content: markdown2, ...EMPTY$1 };
|
|
44231
|
+
const items = ranges.flatMap((range) => {
|
|
44232
|
+
try {
|
|
44233
|
+
return [{
|
|
44234
|
+
range,
|
|
44235
|
+
html: katex.renderToString(range.code, {
|
|
44236
|
+
displayMode: range.block,
|
|
44237
|
+
throwOnError: true,
|
|
44238
|
+
trust: false,
|
|
44239
|
+
output: "html"
|
|
44240
|
+
})
|
|
44241
|
+
}];
|
|
44242
|
+
} catch {
|
|
44243
|
+
return [];
|
|
44244
|
+
}
|
|
44245
|
+
});
|
|
44246
|
+
if (items.length === 0) return { content: markdown2, ...EMPTY$1 };
|
|
44247
|
+
const shots = await api.renderMathImages({
|
|
44248
|
+
formulas: items.map((item) => ({ html: item.html, block: item.range.block })),
|
|
44249
|
+
styles: wordExportStyles(),
|
|
44250
|
+
color: color2,
|
|
44251
|
+
background: "#ffffff"
|
|
44252
|
+
});
|
|
44253
|
+
const images = {};
|
|
44254
|
+
const sizes = {};
|
|
44255
|
+
const replacements = [];
|
|
44256
|
+
items.forEach((item, index2) => {
|
|
44257
|
+
const shot = shots[index2];
|
|
44258
|
+
if (!shot) return;
|
|
44259
|
+
const name2 = `colamd-math-${item.range.block ? "block" : "inline"}-${index2 + 1}.png`;
|
|
44260
|
+
images[name2] = shot.dataURL;
|
|
44261
|
+
sizes[name2] = { width: shot.width, height: shot.height };
|
|
44262
|
+
replacements.push({ from: item.range.from, to: item.range.to, name: name2 });
|
|
44263
|
+
});
|
|
44264
|
+
if (replacements.length === 0) return { content: markdown2, ...EMPTY$1 };
|
|
44265
|
+
let content2 = markdown2;
|
|
44266
|
+
for (const replacement of replacements.sort((left, right) => right.from - left.from)) {
|
|
44267
|
+
content2 = content2.slice(0, replacement.from) + `` + content2.slice(replacement.to);
|
|
44268
|
+
}
|
|
44269
|
+
return { content: content2, images, sizes };
|
|
44270
|
+
}
|
|
44271
|
+
const BLOCK_WIDTH = 600;
|
|
44272
|
+
const EMPTY = { images: {}, sizes: {} };
|
|
44273
|
+
async function markdownWithHtmlImages(markdown2, color2) {
|
|
44274
|
+
const api = window.electronAPI;
|
|
44275
|
+
if (!api?.renderHtmlImages) return { content: markdown2, ...EMPTY };
|
|
44276
|
+
const ranges = [];
|
|
44277
|
+
markdownLanguage.parser.parse(markdown2).iterate({
|
|
44278
|
+
enter: (node) => {
|
|
44279
|
+
if (node.name === "HTMLBlock") ranges.push({ from: node.from, to: node.to });
|
|
44280
|
+
}
|
|
44281
|
+
});
|
|
44282
|
+
if (ranges.length === 0) return { content: markdown2, ...EMPTY };
|
|
44283
|
+
const unique = [];
|
|
44284
|
+
for (const range of ranges.sort((left, right) => left.from - right.from)) {
|
|
44285
|
+
const previous = unique[unique.length - 1];
|
|
44286
|
+
if (previous && range.from < previous.to) continue;
|
|
44287
|
+
unique.push(range);
|
|
44288
|
+
}
|
|
44289
|
+
const items = unique.flatMap((range) => {
|
|
44290
|
+
const holder = document.createElement("div");
|
|
44291
|
+
holder.appendChild(sanitizeHTML(markdown2.slice(range.from, range.to)));
|
|
44292
|
+
const inner2 = holder.innerHTML.trim();
|
|
44293
|
+
if (inner2 === "") return [];
|
|
44294
|
+
return [{ range, html: `<div class="colamd-document">${inner2}</div>` }];
|
|
44295
|
+
});
|
|
44296
|
+
if (items.length === 0) return { content: markdown2, ...EMPTY };
|
|
44297
|
+
const shots = await api.renderHtmlImages({
|
|
44298
|
+
items: items.map((item) => ({ html: item.html, width: BLOCK_WIDTH })),
|
|
44299
|
+
styles: wordExportStyles(),
|
|
44300
|
+
color: color2,
|
|
44301
|
+
background: "#ffffff"
|
|
44302
|
+
});
|
|
44303
|
+
const images = {};
|
|
44304
|
+
const sizes = {};
|
|
44305
|
+
const replacements = [];
|
|
44306
|
+
items.forEach((item, index2) => {
|
|
44307
|
+
const shot = shots[index2];
|
|
44308
|
+
if (!shot) return;
|
|
44309
|
+
const name2 = `colamd-html-${index2 + 1}.png`;
|
|
44310
|
+
images[name2] = shot.dataURL;
|
|
44311
|
+
sizes[name2] = { width: shot.width, height: shot.height };
|
|
44312
|
+
replacements.push({ from: item.range.from, to: item.range.to, name: name2 });
|
|
44313
|
+
});
|
|
44314
|
+
if (replacements.length === 0) return { content: markdown2, ...EMPTY };
|
|
44315
|
+
let content2 = markdown2;
|
|
44316
|
+
for (const replacement of replacements.sort((left, right) => right.from - left.from)) {
|
|
44317
|
+
content2 = content2.slice(0, replacement.from) + `` + content2.slice(replacement.to);
|
|
44318
|
+
}
|
|
44319
|
+
return { content: content2, images, sizes };
|
|
44320
|
+
}
|
|
44321
|
+
const LIGHT = {
|
|
44322
|
+
text: "24292F",
|
|
44323
|
+
secondaryText: "656D76",
|
|
44324
|
+
link: "0969DA",
|
|
44325
|
+
inlineCodeBackground: "EFF1F3",
|
|
44326
|
+
codeBlockBackground: "F6F8FA",
|
|
44327
|
+
codeBlockText: "24292F",
|
|
44328
|
+
highlightBackground: "FFF3BF",
|
|
44329
|
+
blockquoteBorder: "D0D7DE",
|
|
44330
|
+
blockquoteBackground: null,
|
|
44331
|
+
border: "D0D7DE",
|
|
44332
|
+
tableHeaderBackground: "F6F8FA"
|
|
44333
|
+
};
|
|
44334
|
+
function painted$1(value) {
|
|
44335
|
+
const trimmed = value.trim();
|
|
44336
|
+
if (!trimmed || trimmed === "transparent") return null;
|
|
44337
|
+
try {
|
|
44338
|
+
const canvas = document.createElement("canvas");
|
|
44339
|
+
canvas.width = 1;
|
|
44340
|
+
canvas.height = 1;
|
|
44341
|
+
const context = canvas.getContext("2d");
|
|
44342
|
+
if (!context) return null;
|
|
44343
|
+
context.fillStyle = "#ffffff";
|
|
44344
|
+
context.fillRect(0, 0, 1, 1);
|
|
44345
|
+
context.fillStyle = "#010203";
|
|
44346
|
+
context.fillStyle = trimmed;
|
|
44347
|
+
if (context.fillStyle === "#010203" && trimmed.toLowerCase() !== "#010203") return null;
|
|
44348
|
+
context.fillRect(0, 0, 1, 1);
|
|
44349
|
+
const [r, g, b] = context.getImageData(0, 0, 1, 1).data;
|
|
44350
|
+
return [r, g, b].map((channel) => channel.toString(16).padStart(2, "0")).join("").toUpperCase();
|
|
44351
|
+
} catch {
|
|
44352
|
+
return null;
|
|
44353
|
+
}
|
|
44354
|
+
}
|
|
44355
|
+
function color(value, fallback) {
|
|
44356
|
+
return painted$1(value) ?? fallback;
|
|
44357
|
+
}
|
|
44358
|
+
function optionalColor(value) {
|
|
44359
|
+
return painted$1(value);
|
|
44360
|
+
}
|
|
44361
|
+
function luminance(value) {
|
|
44362
|
+
const hex = color(value, "FFFFFF");
|
|
44363
|
+
const [r, g, b] = [0, 2, 4].map((index2) => Number.parseInt(hex.slice(index2, index2 + 2), 16));
|
|
44364
|
+
return (0.2126 * r + 0.7152 * g + 0.0722 * b) / 255;
|
|
44365
|
+
}
|
|
44366
|
+
function editorFontStack() {
|
|
44367
|
+
const editor = document.getElementById("editor");
|
|
44368
|
+
if (!editor) return getComputedStyle(document.body).fontFamily;
|
|
44369
|
+
const probe = document.createElement("div");
|
|
44370
|
+
probe.className = "cm-content";
|
|
44371
|
+
probe.setAttribute("aria-hidden", "true");
|
|
44372
|
+
probe.style.cssText = "position:absolute;left:0;top:0;width:0;height:0;visibility:hidden;pointer-events:none";
|
|
44373
|
+
const body = document.body;
|
|
44374
|
+
const sourceMode = body.classList.contains("source-mode");
|
|
44375
|
+
if (sourceMode) body.classList.remove("source-mode");
|
|
44376
|
+
editor.appendChild(probe);
|
|
44377
|
+
const stack = getComputedStyle(probe).fontFamily;
|
|
44378
|
+
probe.remove();
|
|
44379
|
+
if (sourceMode) body.classList.add("source-mode");
|
|
44380
|
+
return stack;
|
|
44381
|
+
}
|
|
44382
|
+
function readDocxStyle() {
|
|
44383
|
+
const computed = getComputedStyle(document.body);
|
|
44384
|
+
const token = (name2) => computed.getPropertyValue(name2).trim();
|
|
44385
|
+
const palette = luminance(token("--bg-color")) < 0.5 ? LIGHT : {
|
|
44386
|
+
text: color(token("--text-color"), LIGHT.text),
|
|
44387
|
+
secondaryText: color(token("--text-secondary") || token("--text-muted"), LIGHT.secondaryText),
|
|
44388
|
+
link: color(token("--link-color"), LIGHT.link),
|
|
44389
|
+
inlineCodeBackground: color(token("--code-bg"), LIGHT.inlineCodeBackground),
|
|
44390
|
+
codeBlockBackground: color(token("--code-block-bg"), LIGHT.codeBlockBackground),
|
|
44391
|
+
codeBlockText: color(token("--code-block-text") || token("--text-color"), LIGHT.codeBlockText),
|
|
44392
|
+
highlightBackground: color(token("--highlight-bg"), LIGHT.highlightBackground),
|
|
44393
|
+
blockquoteBorder: color(token("--blockquote-border"), LIGHT.blockquoteBorder),
|
|
44394
|
+
blockquoteBackground: optionalColor(token("--blockquote-bg")),
|
|
44395
|
+
border: color(token("--border-color"), LIGHT.border),
|
|
44396
|
+
tableHeaderBackground: color(token("--table-header-bg"), LIGHT.tableHeaderBackground)
|
|
44397
|
+
};
|
|
44398
|
+
return {
|
|
44399
|
+
...palette,
|
|
44400
|
+
bodyFontStack: editorFontStack(),
|
|
44401
|
+
monoFontStack: token("--font-mono") || "Menlo, Consolas, monospace",
|
|
44402
|
+
// 与导出 HTML 的 `.colamd-document` 一致:正文 16px、行高 1.75。
|
|
44403
|
+
bodySize: 16,
|
|
44404
|
+
lineHeight: 1.75
|
|
44405
|
+
};
|
|
44406
|
+
}
|
|
44011
44407
|
const PRESENTING_CLASS = "presenting";
|
|
44012
44408
|
const RULE_STYLE_ID = "slideshow-rules";
|
|
44013
44409
|
const DRAG_SLOP = 4;
|
|
@@ -44549,36 +44945,36 @@ function applyTheme(name2, customCSS) {
|
|
|
44549
44945
|
}
|
|
44550
44946
|
window.dispatchEvent(new CustomEvent("colamd:theme-applied"));
|
|
44551
44947
|
}
|
|
44552
|
-
function painted(
|
|
44948
|
+
function painted(color2, background) {
|
|
44553
44949
|
const hex = (value) => value.toString(16).padStart(2, "0");
|
|
44554
44950
|
try {
|
|
44555
44951
|
const canvas = document.createElement("canvas");
|
|
44556
44952
|
canvas.width = 1;
|
|
44557
44953
|
canvas.height = 1;
|
|
44558
44954
|
const ctx = canvas.getContext("2d");
|
|
44559
|
-
if (!ctx) return
|
|
44955
|
+
if (!ctx) return color2;
|
|
44560
44956
|
ctx.fillStyle = background;
|
|
44561
44957
|
ctx.fillRect(0, 0, 1, 1);
|
|
44562
|
-
ctx.fillStyle =
|
|
44958
|
+
ctx.fillStyle = color2;
|
|
44563
44959
|
ctx.fillRect(0, 0, 1, 1);
|
|
44564
44960
|
const [r, g, b] = ctx.getImageData(0, 0, 1, 1).data;
|
|
44565
44961
|
return `#${hex(r)}${hex(g)}${hex(b)}`;
|
|
44566
44962
|
} catch {
|
|
44567
|
-
return
|
|
44963
|
+
return color2;
|
|
44568
44964
|
}
|
|
44569
44965
|
}
|
|
44570
44966
|
function applyCodePalette() {
|
|
44571
44967
|
const bg = getComputedStyle(document.body).getPropertyValue("--code-block-bg").trim();
|
|
44572
44968
|
document.body.classList.toggle("code-palette-light", !isDarkSurface(bg));
|
|
44573
44969
|
}
|
|
44574
|
-
function isDarkSurface(
|
|
44575
|
-
const hex =
|
|
44970
|
+
function isDarkSurface(color2) {
|
|
44971
|
+
const hex = color2.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i);
|
|
44576
44972
|
let channels = null;
|
|
44577
44973
|
if (hex) {
|
|
44578
44974
|
const digits = hex[1].length === 3 ? hex[1].replace(/./g, (c) => c + c) : hex[1];
|
|
44579
44975
|
channels = [0, 2, 4].map((i) => parseInt(digits.slice(i, i + 2), 16));
|
|
44580
44976
|
} else {
|
|
44581
|
-
const rgb =
|
|
44977
|
+
const rgb = color2.match(/^rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)/i);
|
|
44582
44978
|
if (rgb) channels = [rgb[1], rgb[2], rgb[3]].map(Number);
|
|
44583
44979
|
}
|
|
44584
44980
|
if (!channels) return true;
|
|
@@ -45434,13 +45830,13 @@ async function capModule(name2) {
|
|
|
45434
45830
|
try {
|
|
45435
45831
|
switch (name2) {
|
|
45436
45832
|
case "@capacitor/filesystem":
|
|
45437
|
-
return await __vitePreload(() => import("./index-
|
|
45833
|
+
return await __vitePreload(() => import("./index-k6oLH39v.js"), true ? [] : void 0, import.meta.url);
|
|
45438
45834
|
case "@capacitor/share":
|
|
45439
|
-
return await __vitePreload(() => import("./index-
|
|
45835
|
+
return await __vitePreload(() => import("./index-Dl8YooLt.js"), true ? [] : void 0, import.meta.url);
|
|
45440
45836
|
case "@capacitor/app":
|
|
45441
|
-
return await __vitePreload(() => import("./index-
|
|
45837
|
+
return await __vitePreload(() => import("./index-Dg6oPZ5w.js"), true ? [] : void 0, import.meta.url);
|
|
45442
45838
|
case "@capawesome/capacitor-file-picker":
|
|
45443
|
-
return await __vitePreload(() => import("./index-
|
|
45839
|
+
return await __vitePreload(() => import("./index-eBhE19Gh.js"), true ? [] : void 0, import.meta.url);
|
|
45444
45840
|
default:
|
|
45445
45841
|
return null;
|
|
45446
45842
|
}
|
|
@@ -45606,6 +46002,8 @@ function createCapacitorAPI() {
|
|
|
45606
46002
|
},
|
|
45607
46003
|
exportDOCX: async () => false,
|
|
45608
46004
|
// 移动端第一版不做 Word 导出
|
|
46005
|
+
renderMathImages: async () => [],
|
|
46006
|
+
renderHtmlImages: async () => [],
|
|
45609
46007
|
exportImage: async (_snapshot, _preset) => {
|
|
45610
46008
|
const bridge = nativeBridge();
|
|
45611
46009
|
if (!bridge) return false;
|
|
@@ -46605,10 +47003,8 @@ function scrollRatio(el) {
|
|
|
46605
47003
|
return range > 0 ? el.scrollTop / range : 0;
|
|
46606
47004
|
}
|
|
46607
47005
|
function restoreScrollRatio(el, ratio) {
|
|
46608
|
-
|
|
46609
|
-
|
|
46610
|
-
el.scrollTop = Math.max(0, Math.min(range, range * ratio));
|
|
46611
|
-
});
|
|
47006
|
+
const range = el.scrollHeight - el.clientHeight;
|
|
47007
|
+
el.scrollTop = Math.max(0, Math.min(range, range * ratio));
|
|
46612
47008
|
}
|
|
46613
47009
|
function toggleSourceMode() {
|
|
46614
47010
|
const ratio = scrollRatio(editorScroller());
|
|
@@ -47140,6 +47536,11 @@ async function init() {
|
|
|
47140
47536
|
api.onSearch(() => searchPanel.show());
|
|
47141
47537
|
document.addEventListener("keydown", (event) => {
|
|
47142
47538
|
if (!(event.metaKey || event.ctrlKey) || event.shiftKey || event.altKey) return;
|
|
47539
|
+
if (event.key === "/") {
|
|
47540
|
+
event.preventDefault();
|
|
47541
|
+
toggleSourceMode();
|
|
47542
|
+
return;
|
|
47543
|
+
}
|
|
47143
47544
|
if (event.key.toLowerCase() !== "f") return;
|
|
47144
47545
|
event.preventDefault();
|
|
47145
47546
|
searchPanel.show();
|
|
@@ -47233,8 +47634,16 @@ async function init() {
|
|
|
47233
47634
|
void exportCurrentHTML();
|
|
47234
47635
|
});
|
|
47235
47636
|
api.onMenuExportDOCX(async () => {
|
|
47236
|
-
const
|
|
47237
|
-
await
|
|
47637
|
+
const style = readDocxStyle();
|
|
47638
|
+
const html2 = await markdownWithHtmlImages(getContent(), `#${style.text}`);
|
|
47639
|
+
const math2 = await markdownWithMathImages(html2.content, isChinese$1(), `#${style.text}`);
|
|
47640
|
+
const payload = await markdownForWord(math2.content, isChinese$1());
|
|
47641
|
+
await api.exportDOCX({
|
|
47642
|
+
content: payload.content,
|
|
47643
|
+
images: { ...html2.images, ...math2.images, ...payload.images },
|
|
47644
|
+
imageSizes: { ...html2.sizes, ...math2.sizes },
|
|
47645
|
+
style
|
|
47646
|
+
});
|
|
47238
47647
|
});
|
|
47239
47648
|
api.onMenuExportImage((preset) => {
|
|
47240
47649
|
void exportCurrentImage(preset);
|