@bytechain.cn/colamd 2.7.8-rc.2 → 2.7.11
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/README.md +6 -3
- package/README_CN.md +6 -3
- package/dist/main/chunks/docx-export.js +25 -12
- package/dist/main/chunks/math-export.js +3 -0
- package/dist/renderer/assets/{2DXBBFLN-BQWZeEOZ.js → 2DXBBFLN-BffjYiBQ.js} +4 -4
- package/dist/renderer/assets/{46IJ22JX-CR0BA3Ks.js → 46IJ22JX-Cqs6Q0nk.js} +5 -5
- package/dist/renderer/assets/{4TTDE5I4-BdBL5ywh.js → 4TTDE5I4-Di9dPHLj.js} +3 -3
- package/dist/renderer/assets/{4UF3HTLV-BYMrPeBv.js → 4UF3HTLV-8gLxIs2l.js} +4 -4
- package/dist/renderer/assets/{AAXQQPKT-CTS7qJK7.js → AAXQQPKT-FysWbA2A.js} +8 -8
- package/dist/renderer/assets/{AKE5O7KZ-pEeLbu6F.js → AKE5O7KZ-B3IOPa-c.js} +5 -5
- package/dist/renderer/assets/{BNMLP6AG-CbkwmI8G.js → BNMLP6AG-D0ug7dDI.js} +7 -7
- package/dist/renderer/assets/{DR6PKOQU-C6Iahoa3.js → DR6PKOQU-oitmLyhZ.js} +3 -3
- package/dist/renderer/assets/{E4RJ7UJB-D58gl0M0.js → E4RJ7UJB-B8xlSgyM.js} +6 -6
- package/dist/renderer/assets/{ELSXBIJH-DpS4enQ6.js → ELSXBIJH-6mTmrNHq.js} +1 -1
- package/dist/renderer/assets/{ERTIBQVS-DD8jjKTj.js → ERTIBQVS-Dd68dFC-.js} +4 -4
- package/dist/renderer/assets/{F653G4FO-DoDhFXEy.js → F653G4FO-Bu2Zxw-j.js} +8 -8
- package/dist/renderer/assets/{FKCDD66M-B0wYO26L.js → FKCDD66M-Ba7w0jUC.js} +1 -1
- package/dist/renderer/assets/{FP7KDXVC-B0LUknwq.js → FP7KDXVC-Do8T7Drp.js} +6 -6
- package/dist/renderer/assets/{FT5I3RHX-GdBjTcHf.js → FT5I3RHX-Cw6_nFK5.js} +7 -7
- package/dist/renderer/assets/{GY35JXOZ-Dg2P-i-d.js → GY35JXOZ-BgICGoQK.js} +4 -4
- package/dist/renderer/assets/{H5EEJPP2-C3d8qkta.js → H5EEJPP2-BhAIE8Iv.js} +9 -9
- package/dist/renderer/assets/{HWDLEDTA-Rm5NjB2N.js → HWDLEDTA-LoeArK7M.js} +1 -1
- package/dist/renderer/assets/{JZWSX6AR-qgXs8q-t.js → JZWSX6AR-D32ich7B.js} +2 -2
- package/dist/renderer/assets/{KQOEJWJY-mqwm7WG0.js → KQOEJWJY-BjdpuYRt.js} +1 -1
- package/dist/renderer/assets/{KS3BB3KE-ufj8X6Wa.js → KS3BB3KE-SuIaBOey.js} +5 -5
- package/dist/renderer/assets/{KXJRRZHI-C7vOZ5ie.js → KXJRRZHI-dzerQwX8.js} +3 -3
- package/dist/renderer/assets/{MFVI5XKI-DQ5z-nMh.js → MFVI5XKI-Ccq0m553.js} +1 -1
- package/dist/renderer/assets/{MWY2J62P-DUIamY6F.js → MWY2J62P-BoC73bt9.js} +5 -5
- package/dist/renderer/assets/{MXGNCBL2-DqeFe7Wj.js → MXGNCBL2-BZCuhQ_f.js} +5 -5
- package/dist/renderer/assets/{N6DAJLIZ-CvgcQPUI.js → N6DAJLIZ-D3lshlWR.js} +2 -2
- package/dist/renderer/assets/{NU5M23IW-DpTeCZq5.js → NU5M23IW-D8B7aP1M.js} +5 -5
- package/dist/renderer/assets/{NV4XNBIS-wuvA_U-J.js → NV4XNBIS-CG86dKnS.js} +7 -7
- package/dist/renderer/assets/{OGLU4SIR-CJL7p3WR.js → OGLU4SIR-D-dckdGc.js} +5 -5
- package/dist/renderer/assets/{OUNS5N76-CQVdszCS.js → OUNS5N76-BxpcyMgv.js} +6 -6
- package/dist/renderer/assets/{PU4ISKXV-Bcshpks1.js → PU4ISKXV-2blQCsO8.js} +5 -5
- package/dist/renderer/assets/{PUZGS23X-B8gmR_q3.js → PUZGS23X-pDG4u-84.js} +1 -1
- package/dist/renderer/assets/{Q3IYVLG5-B-qlhAM-.js → Q3IYVLG5-CzhiDBWC.js} +5 -5
- package/dist/renderer/assets/{QYHQDLKZ-EFOsxom5.js → QYHQDLKZ-CPbJy_Nw.js} +9 -9
- package/dist/renderer/assets/{RZSVICHU-B4a4ijU5.js → RZSVICHU-BBonevo2.js} +1 -1
- package/dist/renderer/assets/{UEXXS2NB-BYEZA17b.js → UEXXS2NB-D54VDoFS.js} +1 -1
- package/dist/renderer/assets/{UHTQJXKL-Dr2lF0X7.js → UHTQJXKL-XbjCRArY.js} +5 -5
- package/dist/renderer/assets/{URA2L2QI-CpWV8ZqC.js → URA2L2QI-DWXUka6_.js} +1 -1
- package/dist/renderer/assets/{UXCHDUKG-BhvBbCG9.js → UXCHDUKG-HEug3chN.js} +5 -5
- package/dist/renderer/assets/{VKNV3BUX-BYO3cWfq.js → VKNV3BUX-CgpUwi-P.js} +6 -6
- package/dist/renderer/assets/{VMV7XPHP-Cv3j51G-.js → VMV7XPHP-Bv6BQock.js} +1 -1
- package/dist/renderer/assets/{WEVWDWVA-Bk5T2zs5.js → WEVWDWVA-Cl6MdVFH.js} +1 -1
- package/dist/renderer/assets/{XRRJ35LF-BmKX-UhN.js → XRRJ35LF-DA5B5ZaK.js} +4 -4
- package/dist/renderer/assets/{YFKBLVVN-BsN6JCME.js → YFKBLVVN-CZTsSDev.js} +4 -4
- package/dist/renderer/assets/{YHRE5QGZ-BfqB5qTM.js → YHRE5QGZ-poL0u1Hk.js} +7 -7
- package/dist/renderer/assets/{ZF3OVT4B-71e7gqxT.js → ZF3OVT4B-Csajz0OL.js} +3 -3
- package/dist/renderer/assets/{index-DNjOyVpF.js → index-B2k43UK4.js} +1 -1
- package/dist/renderer/assets/{index-iM3KwPgz.js → index-B90RKaFh.js} +1 -1
- package/dist/renderer/assets/{index-bx07CRyn.css → index-BBpT3mZJ.css} +78 -24
- package/dist/renderer/assets/{index-D3xwJ3eb.js → index-BkfZmH8n.js} +1 -1
- package/dist/renderer/assets/{index-FbcCt5ge.js → index-C6upWLHM.js} +1 -1
- package/dist/renderer/assets/{index-BfRf6YNA.js → index-CDNRUOxY.js} +486 -165
- package/dist/renderer/assets/{index-CeRIIlMp.js → index-CSXoVyN0.js} +1 -1
- package/dist/renderer/assets/{index-Cz6s0BAO.js → index-CZLcUFAS.js} +1 -1
- package/dist/renderer/assets/{index-S_JLIQUn.js → index-D0-6r8OY.js} +1 -1
- package/dist/renderer/assets/{index-7XM2a0Z_.js → index-DHfl2nIi.js} +3 -3
- package/dist/renderer/assets/{index-KXmfqOLZ.js → index-DVUqWypj.js} +1 -1
- package/dist/renderer/assets/{index-VDcE-MZS.js → index-DrTzZcbo.js} +3 -3
- package/dist/renderer/assets/{index-DrX0ymyh.js → index-DtaUmWot.js} +1 -1
- package/dist/renderer/assets/{index-DXBizOwH.js → index-Duagl4VH.js} +1 -1
- package/dist/renderer/assets/{index-eE3MJT-Z.js → index-Dx_w36Cl.js} +1 -1
- package/dist/renderer/assets/{index-CcV4JcXV.js → index-IgLPrOn8.js} +3 -3
- package/dist/renderer/assets/{index-C-S_Yg_y.js → index-Lj__gZ6c.js} +1 -1
- package/dist/renderer/assets/{index-BkXNa75_.js → index-Mp0fGNKU.js} +1 -1
- package/dist/renderer/assets/{index-2bn6g3NY.js → index-OQWi5Igb.js} +1 -1
- package/dist/renderer/assets/{index-fPGCpVWp.js → index-OVUeW-Iw.js} +1 -1
- package/dist/renderer/assets/{index-DwT_NY9Q.js → index-eX6agtDo.js} +1 -1
- package/dist/renderer/assets/{index-CMEBb_j9.js → index-r0CaOFQM.js} +1 -1
- package/dist/renderer/assets/{index-BZI3MrwX.js → index-u6ZCoBKY.js} +1 -1
- package/dist/renderer/assets/{lazy-SjZiJQmj.js → lazy-DNVZaEmQ.js} +3 -3
- package/dist/renderer/assets/{web-raTBZuvw.js → web-BOPg29Xm.js} +2 -2
- package/dist/renderer/assets/{web-BSnrlb26.js → web-C5AimWCG.js} +1 -1
- package/dist/renderer/assets/{web-GpaN5nX1.js → web-nxbmgoyN.js} +1 -1
- package/dist/renderer/index.html +2 -2
- package/package.json +2 -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
|
@@ -33237,11 +33237,11 @@ const PRINT_PALETTE = {
|
|
|
33237
33237
|
};
|
|
33238
33238
|
let pele = null;
|
|
33239
33239
|
function loadPele() {
|
|
33240
|
-
pele ??= __vitePreload(() => import("./lazy-
|
|
33240
|
+
pele ??= __vitePreload(() => import("./lazy-DNVZaEmQ.js").then((n) => n.l), true ? [] : void 0, import.meta.url);
|
|
33241
33241
|
return pele;
|
|
33242
33242
|
}
|
|
33243
|
-
function withPrintPalette(svg) {
|
|
33244
|
-
const declarations = Object.entries(
|
|
33243
|
+
function withPrintPalette(svg, palette) {
|
|
33244
|
+
const declarations = Object.entries(palette).map(([name2, value]) => `${name2}:${value}`).join(";");
|
|
33245
33245
|
const tagEnd = svg.indexOf(">");
|
|
33246
33246
|
if (tagEnd < 0) return svg;
|
|
33247
33247
|
const tag = svg.slice(0, tagEnd);
|
|
@@ -33254,7 +33254,7 @@ async function renderMermaid(code, options2 = {}) {
|
|
|
33254
33254
|
fontFamily: DIAGRAM_FONT,
|
|
33255
33255
|
fontFamilyMono: DIAGRAM_MONO_FONT
|
|
33256
33256
|
});
|
|
33257
|
-
return options2.print ? withPrintPalette(svg) : svg;
|
|
33257
|
+
return options2.print ? withPrintPalette(svg, options2.palette ?? PRINT_PALETTE) : svg;
|
|
33258
33258
|
}
|
|
33259
33259
|
const zooms = /* @__PURE__ */ new WeakMap();
|
|
33260
33260
|
const zoomHosts = /* @__PURE__ */ new Set();
|
|
@@ -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({});
|
|
@@ -33461,6 +33478,24 @@ let documentFileUrl = null;
|
|
|
33461
33478
|
function primeDocumentFileUrl(url) {
|
|
33462
33479
|
documentFileUrl = url;
|
|
33463
33480
|
}
|
|
33481
|
+
let measureHost = null;
|
|
33482
|
+
function setMeasureHost(view) {
|
|
33483
|
+
measureHost = view;
|
|
33484
|
+
}
|
|
33485
|
+
function remeasureAfterDraw() {
|
|
33486
|
+
if (!measureHost) return;
|
|
33487
|
+
const view = measureHost;
|
|
33488
|
+
try {
|
|
33489
|
+
const dom = view.contentDOM;
|
|
33490
|
+
dom.style.minHeight = "0";
|
|
33491
|
+
view.requestMeasure({
|
|
33492
|
+
write: () => {
|
|
33493
|
+
dom.style.minHeight = "";
|
|
33494
|
+
}
|
|
33495
|
+
});
|
|
33496
|
+
} catch {
|
|
33497
|
+
}
|
|
33498
|
+
}
|
|
33464
33499
|
const setDocumentFileUrlEffect = StateEffect.define();
|
|
33465
33500
|
const documentFileUrlField = StateField.define({
|
|
33466
33501
|
create: () => documentFileUrl,
|
|
@@ -33544,6 +33579,22 @@ function isBlockActive(state, from, to) {
|
|
|
33544
33579
|
const sel = state.selection.main;
|
|
33545
33580
|
return sel.from >= from && sel.to <= to;
|
|
33546
33581
|
}
|
|
33582
|
+
function mathElement(code, block) {
|
|
33583
|
+
const el = document.createElement(block ? "div" : "span");
|
|
33584
|
+
el.className = block ? "cm-md-math cm-md-math-block" : "cm-md-math cm-md-math-inline";
|
|
33585
|
+
try {
|
|
33586
|
+
el.innerHTML = katex.renderToString(code, {
|
|
33587
|
+
displayMode: block,
|
|
33588
|
+
throwOnError: true,
|
|
33589
|
+
// 公式里可能带用户写的 HTML,KaTeX 的 trust 默认关闭,保持关闭
|
|
33590
|
+
trust: false
|
|
33591
|
+
});
|
|
33592
|
+
} catch {
|
|
33593
|
+
el.textContent = (block ? "$$" : "$") + code + (block ? "$$" : "$");
|
|
33594
|
+
el.classList.add("cm-md-math-error");
|
|
33595
|
+
}
|
|
33596
|
+
return el;
|
|
33597
|
+
}
|
|
33547
33598
|
class MathWidget extends WidgetType {
|
|
33548
33599
|
constructor(code, block, from, to) {
|
|
33549
33600
|
super();
|
|
@@ -33556,21 +33607,7 @@ class MathWidget extends WidgetType {
|
|
|
33556
33607
|
return other.code === this.code && other.block === this.block && other.from === this.from && other.to === this.to;
|
|
33557
33608
|
}
|
|
33558
33609
|
toDOM() {
|
|
33559
|
-
|
|
33560
|
-
span.className = this.block ? "cm-md-math cm-md-math-block" : "cm-md-math cm-md-math-inline";
|
|
33561
|
-
withSourceRange(span, this.from, this.to);
|
|
33562
|
-
try {
|
|
33563
|
-
span.innerHTML = katex.renderToString(this.code, {
|
|
33564
|
-
displayMode: this.block,
|
|
33565
|
-
throwOnError: true,
|
|
33566
|
-
// 公式里可能带用户写的 HTML,KaTeX 的 trust 默认关闭,保持关闭
|
|
33567
|
-
trust: false
|
|
33568
|
-
});
|
|
33569
|
-
} catch {
|
|
33570
|
-
span.textContent = (this.block ? "$$" : "$") + this.code + (this.block ? "$$" : "$");
|
|
33571
|
-
span.classList.add("cm-md-math-error");
|
|
33572
|
-
}
|
|
33573
|
-
return span;
|
|
33610
|
+
return withSourceRange(mathElement(this.code, this.block), this.from, this.to);
|
|
33574
33611
|
}
|
|
33575
33612
|
}
|
|
33576
33613
|
class ListBulletWidget extends WidgetType {
|
|
@@ -33670,9 +33707,11 @@ class MermaidWidget extends WidgetType {
|
|
|
33670
33707
|
wrap.innerHTML = svg;
|
|
33671
33708
|
wrap.classList.add("cm-md-mermaid-ready");
|
|
33672
33709
|
attachDiagramZoom(wrap);
|
|
33710
|
+
remeasureAfterDraw();
|
|
33673
33711
|
}).catch(() => {
|
|
33674
33712
|
wrap.textContent = "```mermaid\n" + this.code + "\n```";
|
|
33675
33713
|
wrap.classList.add("cm-md-mermaid-failed");
|
|
33714
|
+
remeasureAfterDraw();
|
|
33676
33715
|
});
|
|
33677
33716
|
return wrap;
|
|
33678
33717
|
}
|
|
@@ -33808,38 +33847,70 @@ function alignOf(delimiter) {
|
|
|
33808
33847
|
if (right) return "right";
|
|
33809
33848
|
return "left";
|
|
33810
33849
|
}
|
|
33811
|
-
const INLINE_RE =
|
|
33850
|
+
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*\/?>/giud;
|
|
33851
|
+
function codeSpanRanges(text2) {
|
|
33852
|
+
const out = [];
|
|
33853
|
+
const re = /`[^`]+`/g;
|
|
33854
|
+
let match;
|
|
33855
|
+
while ((match = re.exec(text2)) !== null) out.push({ from: match.index, to: match.index + match[0].length });
|
|
33856
|
+
return out;
|
|
33857
|
+
}
|
|
33858
|
+
function appendCellText(parent, text2, math2, from, to) {
|
|
33859
|
+
let cursor = from;
|
|
33860
|
+
for (const range of math2) {
|
|
33861
|
+
if (range.from < cursor || range.to > to) continue;
|
|
33862
|
+
if (range.from > cursor) parent.appendChild(document.createTextNode(text2.slice(cursor, range.from)));
|
|
33863
|
+
parent.appendChild(mathElement(range.code, false));
|
|
33864
|
+
cursor = range.to;
|
|
33865
|
+
}
|
|
33866
|
+
if (cursor < to) parent.appendChild(document.createTextNode(text2.slice(cursor, to)));
|
|
33867
|
+
}
|
|
33812
33868
|
function appendInline(parent, text2, base2) {
|
|
33869
|
+
const math2 = scanMath(text2, codeSpanRanges(text2));
|
|
33870
|
+
const write = (target, from, to) => appendCellText(target, text2, math2, from, to);
|
|
33813
33871
|
INLINE_RE.lastIndex = 0;
|
|
33814
33872
|
let last2 = 0;
|
|
33815
33873
|
let match;
|
|
33816
33874
|
while ((match = INLINE_RE.exec(text2)) !== null) {
|
|
33817
|
-
|
|
33818
|
-
|
|
33875
|
+
const index2 = match.index;
|
|
33876
|
+
const inside = math2.find((range) => range.from <= index2 && index2 < range.to);
|
|
33877
|
+
if (inside) {
|
|
33878
|
+
INLINE_RE.lastIndex = inside.to;
|
|
33879
|
+
continue;
|
|
33880
|
+
}
|
|
33881
|
+
if (match.index > last2) write(parent, last2, match.index);
|
|
33882
|
+
const g = match.groups ?? {};
|
|
33883
|
+
const at = match.indices?.groups ?? {};
|
|
33884
|
+
if (g.strong !== void 0 || g.strongU !== void 0) {
|
|
33819
33885
|
const el = document.createElement("strong");
|
|
33820
|
-
|
|
33886
|
+
const [from, to] = at.strong ?? at.strongU ?? [0, 0];
|
|
33887
|
+
write(el, from, to);
|
|
33821
33888
|
parent.appendChild(el);
|
|
33822
|
-
} else if (
|
|
33889
|
+
} else if (g.em !== void 0 || g.emU !== void 0) {
|
|
33823
33890
|
const el = document.createElement("em");
|
|
33824
|
-
|
|
33891
|
+
const [from, to] = at.em ?? at.emU ?? [0, 0];
|
|
33892
|
+
write(el, from, to);
|
|
33825
33893
|
parent.appendChild(el);
|
|
33826
|
-
} else if (
|
|
33894
|
+
} else if (g.code !== void 0) {
|
|
33827
33895
|
const el = document.createElement("code");
|
|
33828
|
-
el.textContent =
|
|
33896
|
+
el.textContent = g.code;
|
|
33829
33897
|
parent.appendChild(el);
|
|
33830
|
-
} else if (
|
|
33898
|
+
} else if (g.strike !== void 0) {
|
|
33831
33899
|
const el = document.createElement("s");
|
|
33832
|
-
|
|
33900
|
+
const [from, to] = at.strike ?? [0, 0];
|
|
33901
|
+
write(el, from, to);
|
|
33833
33902
|
parent.appendChild(el);
|
|
33834
|
-
} else if (
|
|
33903
|
+
} else if (g.alt !== void 0) {
|
|
33835
33904
|
const img = document.createElement("img");
|
|
33836
|
-
img.src = resolveImageSrc(
|
|
33837
|
-
img.alt =
|
|
33905
|
+
img.src = resolveImageSrc(g.src ?? "", base2);
|
|
33906
|
+
img.alt = g.alt;
|
|
33838
33907
|
parent.appendChild(img);
|
|
33839
|
-
} else if (
|
|
33908
|
+
} else if (g.linkText !== void 0) {
|
|
33840
33909
|
const el = document.createElement("a");
|
|
33841
|
-
|
|
33842
|
-
|
|
33910
|
+
const [from, to] = at.linkText ?? [0, 0];
|
|
33911
|
+
if (to > from) write(el, from, to);
|
|
33912
|
+
else el.textContent = g.href ?? "";
|
|
33913
|
+
const href = (g.href ?? "").trim();
|
|
33843
33914
|
if (/^https?:\/\//i.test(href)) el.setAttribute("href", href);
|
|
33844
33915
|
parent.appendChild(el);
|
|
33845
33916
|
} else if (/^<br/i.test(match[0])) {
|
|
@@ -33847,7 +33918,7 @@ function appendInline(parent, text2, base2) {
|
|
|
33847
33918
|
}
|
|
33848
33919
|
last2 = match.index + match[0].length;
|
|
33849
33920
|
}
|
|
33850
|
-
if (last2 < text2.length) parent
|
|
33921
|
+
if (last2 < text2.length) write(parent, last2, text2.length);
|
|
33851
33922
|
}
|
|
33852
33923
|
function collectTables(state, ranges, front) {
|
|
33853
33924
|
iterateContent(state, front, (node) => {
|
|
@@ -34054,6 +34125,8 @@ function collectBlocks(state, ranges, front) {
|
|
|
34054
34125
|
break;
|
|
34055
34126
|
}
|
|
34056
34127
|
case "ListMark": {
|
|
34128
|
+
const lead = node.from - state.doc.lineAt(node.from).from;
|
|
34129
|
+
if (lead > 0) ranges.push({ from: node.from - lead, to: node.from, deco: hide(node.from - lead, node.from) });
|
|
34057
34130
|
const raw = state.doc.sliceString(node.from, node.to).trim();
|
|
34058
34131
|
const after = state.doc.sliceString(node.to, node.to + 4);
|
|
34059
34132
|
if (/^\s+\[[ xX]\]/.test(after)) {
|
|
@@ -34100,8 +34173,10 @@ function collectBlocks(state, ranges, front) {
|
|
|
34100
34173
|
break;
|
|
34101
34174
|
}
|
|
34102
34175
|
case "QuoteMark": {
|
|
34103
|
-
|
|
34104
|
-
|
|
34176
|
+
const rest = state.doc.sliceString(node.to, state.doc.lineAt(node.to).to);
|
|
34177
|
+
if (rest.trim() === "" || isActiveLine(state, node.from)) {
|
|
34178
|
+
ranges.push({ from: node.from, to: node.to, deco: MARK({ class: "cm-md-quotemark" }) });
|
|
34179
|
+
} else {
|
|
34105
34180
|
hideMarker(state, node.from, node.to, ranges);
|
|
34106
34181
|
}
|
|
34107
34182
|
break;
|
|
@@ -34109,6 +34184,7 @@ function collectBlocks(state, ranges, front) {
|
|
|
34109
34184
|
}
|
|
34110
34185
|
});
|
|
34111
34186
|
}
|
|
34187
|
+
const URL_STOP = /[\u2E80-\u30FF\u3400-\u4DBF\u4E00-\u9FFF\uF900-\uFAFF\u3000-\u303F\uFF00-\uFFEF]/;
|
|
34112
34188
|
function collectInline(state, ranges, front) {
|
|
34113
34189
|
iterateContent(state, front, (node) => {
|
|
34114
34190
|
const from = node.from;
|
|
@@ -34121,12 +34197,16 @@ function collectInline(state, ranges, front) {
|
|
|
34121
34197
|
case "ATXHeading4":
|
|
34122
34198
|
case "ATXHeading5":
|
|
34123
34199
|
case "ATXHeading6": {
|
|
34200
|
+
const head = state.doc.sliceString(from, state.doc.lineAt(from).to);
|
|
34201
|
+
if (!/^#{1,6}[ \t]/.test(head)) return false;
|
|
34124
34202
|
pushBlockLines(state, from, to, `cm-md-${node.name.toLowerCase()}`, ranges);
|
|
34125
34203
|
break;
|
|
34126
34204
|
}
|
|
34127
34205
|
case "EmphasisMark":
|
|
34128
34206
|
case "StrikethroughMark":
|
|
34129
34207
|
case "CodeMark": {
|
|
34208
|
+
const fence = node.node.parent;
|
|
34209
|
+
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
34210
|
ranges.push({ from, to, deco: hide() });
|
|
34131
34211
|
break;
|
|
34132
34212
|
}
|
|
@@ -34155,7 +34235,10 @@ function collectInline(state, ranges, front) {
|
|
|
34155
34235
|
break;
|
|
34156
34236
|
}
|
|
34157
34237
|
case "URL": {
|
|
34158
|
-
|
|
34238
|
+
const raw = state.doc.sliceString(from, to);
|
|
34239
|
+
const stop = raw.search(URL_STOP);
|
|
34240
|
+
const end = stop < 0 ? to : from + stop;
|
|
34241
|
+
if (end > from) ranges.push({ from, to: end, deco: MARK({ class: "cm-md-url" }) });
|
|
34159
34242
|
break;
|
|
34160
34243
|
}
|
|
34161
34244
|
}
|
|
@@ -34249,17 +34332,21 @@ const parseRefresh = ViewPlugin.fromClass(class {
|
|
|
34249
34332
|
}
|
|
34250
34333
|
this.later(update.view, viewportEnd);
|
|
34251
34334
|
}
|
|
34252
|
-
later(view, parseTo) {
|
|
34335
|
+
later(view, parseTo, delay = 0) {
|
|
34253
34336
|
if (this.pending) return;
|
|
34254
34337
|
this.pending = true;
|
|
34255
34338
|
setTimeout(() => {
|
|
34256
34339
|
this.pending = false;
|
|
34257
34340
|
if (!view.dom.isConnected) return;
|
|
34341
|
+
if (view.composing) {
|
|
34342
|
+
this.later(view, parseTo, 120);
|
|
34343
|
+
return;
|
|
34344
|
+
}
|
|
34258
34345
|
if (parseTo !== null) forceParsing(view, parseTo);
|
|
34259
34346
|
view.dispatch({ effects: decorationsRefreshEffect.of(null) });
|
|
34260
34347
|
if (syntaxTree(view.state).length < view.viewport.to && this.attempts < 40) {
|
|
34261
34348
|
this.attempts += 1;
|
|
34262
|
-
this.later(view, view.viewport.to);
|
|
34349
|
+
this.later(view, view.viewport.to, delay);
|
|
34263
34350
|
}
|
|
34264
34351
|
}, 0);
|
|
34265
34352
|
}
|
|
@@ -34271,80 +34358,6 @@ const livePreview = [
|
|
|
34271
34358
|
livePreviewField,
|
|
34272
34359
|
parseRefresh
|
|
34273
34360
|
];
|
|
34274
|
-
const LIST_RE = /^([ \t]*)(?:([-*+])|(\d+)([.)]))([ \t]+)(\[[ xX]\][ \t]+)?/;
|
|
34275
|
-
function continueList(view) {
|
|
34276
|
-
const { state } = view;
|
|
34277
|
-
const range = state.selection.main;
|
|
34278
|
-
if (!range.empty) return false;
|
|
34279
|
-
const line = state.doc.lineAt(range.head);
|
|
34280
|
-
if (range.head !== line.to) return false;
|
|
34281
|
-
const match = LIST_RE.exec(line.text);
|
|
34282
|
-
if (!match) return false;
|
|
34283
|
-
const [, indent, bullet, number2, delimiter, spacing2, task] = match;
|
|
34284
|
-
const content2 = line.text.slice(match[0].length);
|
|
34285
|
-
if (content2.trim() === "") {
|
|
34286
|
-
view.dispatch({
|
|
34287
|
-
changes: { from: line.from, to: line.to, insert: "" },
|
|
34288
|
-
selection: { anchor: line.from },
|
|
34289
|
-
scrollIntoView: true,
|
|
34290
|
-
userEvent: "input"
|
|
34291
|
-
});
|
|
34292
|
-
return true;
|
|
34293
|
-
}
|
|
34294
|
-
const marker = bullet ?? `${Number(number2) + 1}${delimiter}`;
|
|
34295
|
-
const insert2 = `
|
|
34296
|
-
${indent}${marker}${spacing2}${task ? "[ ] " : ""}`;
|
|
34297
|
-
view.dispatch({
|
|
34298
|
-
changes: { from: range.head, insert: insert2 },
|
|
34299
|
-
selection: { anchor: range.head + insert2.length },
|
|
34300
|
-
scrollIntoView: true,
|
|
34301
|
-
userEvent: "input"
|
|
34302
|
-
});
|
|
34303
|
-
return true;
|
|
34304
|
-
}
|
|
34305
|
-
const INDENT = " ";
|
|
34306
|
-
function indentListItem(view, direction) {
|
|
34307
|
-
const { state } = view;
|
|
34308
|
-
const range = state.selection.main;
|
|
34309
|
-
if (!range.empty) return false;
|
|
34310
|
-
const line = state.doc.lineAt(range.head);
|
|
34311
|
-
if (!LIST_RE.test(line.text)) return false;
|
|
34312
|
-
if (direction === 1) {
|
|
34313
|
-
view.dispatch({
|
|
34314
|
-
changes: { from: line.from, insert: INDENT },
|
|
34315
|
-
selection: { anchor: range.head + INDENT.length },
|
|
34316
|
-
scrollIntoView: true,
|
|
34317
|
-
userEvent: "input"
|
|
34318
|
-
});
|
|
34319
|
-
return true;
|
|
34320
|
-
}
|
|
34321
|
-
const leading = /^[ \t]+/.exec(line.text);
|
|
34322
|
-
if (!leading) return false;
|
|
34323
|
-
const width = Math.min(leading[0].length, INDENT.length);
|
|
34324
|
-
view.dispatch({
|
|
34325
|
-
changes: { from: line.from, to: line.from + width, insert: "" },
|
|
34326
|
-
selection: { anchor: Math.max(line.from, range.head - width) },
|
|
34327
|
-
scrollIntoView: true,
|
|
34328
|
-
userEvent: "input"
|
|
34329
|
-
});
|
|
34330
|
-
return true;
|
|
34331
|
-
}
|
|
34332
|
-
const listInput = Prec.high(keymap.of([
|
|
34333
|
-
{ key: "Enter", run: continueList },
|
|
34334
|
-
{ key: "Tab", run: (view) => indentListItem(view, 1) },
|
|
34335
|
-
{ key: "Shift-Tab", run: (view) => indentListItem(view, -1) }
|
|
34336
|
-
]));
|
|
34337
|
-
const setSearchHighlight = StateEffect.define();
|
|
34338
|
-
const searchHighlightField = StateField.define({
|
|
34339
|
-
create: () => Decoration.none,
|
|
34340
|
-
update(value, tr) {
|
|
34341
|
-
for (const effect of tr.effects) {
|
|
34342
|
-
if (effect.is(setSearchHighlight)) return effect.value;
|
|
34343
|
-
}
|
|
34344
|
-
return value.map(tr.changes);
|
|
34345
|
-
},
|
|
34346
|
-
provide: (field) => EditorView.decorations.from(field)
|
|
34347
|
-
});
|
|
34348
34361
|
class CompletionContext {
|
|
34349
34362
|
/**
|
|
34350
34363
|
Create a new completion context. (Mostly useful for testing
|
|
@@ -41766,11 +41779,140 @@ const index$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePrope
|
|
|
41766
41779
|
markdownLanguage,
|
|
41767
41780
|
pasteURLAsLink
|
|
41768
41781
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
41782
|
+
const LIST_RE = /^([ \t]*)(?:([-*+])|(\d+)([.)]))([ \t]+)(\[[ xX]\][ \t]+)?/;
|
|
41783
|
+
function deleteAtLineStart(view) {
|
|
41784
|
+
const { state } = view;
|
|
41785
|
+
const range = state.selection.main;
|
|
41786
|
+
if (!range.empty) return false;
|
|
41787
|
+
const line = state.doc.lineAt(range.head);
|
|
41788
|
+
if (range.head !== line.from) {
|
|
41789
|
+
if (!/^#{1,6}[ \t]?/.test(line.text) && !/^>[ \t]?/.test(line.text)) return false;
|
|
41790
|
+
}
|
|
41791
|
+
const self2 = listLine(line.text);
|
|
41792
|
+
if (self2) {
|
|
41793
|
+
if (self2.lead > 0) return indentListItem(view, -1);
|
|
41794
|
+
const match = LIST_RE.exec(line.text);
|
|
41795
|
+
const marker = match[0].length;
|
|
41796
|
+
view.dispatch({
|
|
41797
|
+
changes: { from: line.from, to: line.from + marker, insert: "" },
|
|
41798
|
+
selection: { anchor: line.from },
|
|
41799
|
+
userEvent: "delete"
|
|
41800
|
+
});
|
|
41801
|
+
return true;
|
|
41802
|
+
}
|
|
41803
|
+
const head = /^#{1,6}[ \t]?/.exec(line.text);
|
|
41804
|
+
if (head && head[0].length > 0 && range.head <= line.from + head[0].length) {
|
|
41805
|
+
view.dispatch({
|
|
41806
|
+
changes: { from: line.from, to: line.from + head[0].length, insert: "" },
|
|
41807
|
+
selection: { anchor: line.from },
|
|
41808
|
+
userEvent: "delete"
|
|
41809
|
+
});
|
|
41810
|
+
return true;
|
|
41811
|
+
}
|
|
41812
|
+
const quote = /^>[ \t]?/.exec(line.text);
|
|
41813
|
+
if (quote && line.text.length > quote[0].length && range.head <= line.from + quote[0].length) {
|
|
41814
|
+
view.dispatch({
|
|
41815
|
+
changes: { from: line.from, to: line.from + quote[0].length, insert: "" },
|
|
41816
|
+
selection: { anchor: line.from },
|
|
41817
|
+
userEvent: "delete"
|
|
41818
|
+
});
|
|
41819
|
+
return true;
|
|
41820
|
+
}
|
|
41821
|
+
return false;
|
|
41822
|
+
}
|
|
41823
|
+
const INDENT = " ";
|
|
41824
|
+
function indentListItem(view, direction) {
|
|
41825
|
+
const { state } = view;
|
|
41826
|
+
const range = state.selection.main;
|
|
41827
|
+
if (!range.empty) return false;
|
|
41828
|
+
const line = state.doc.lineAt(range.head);
|
|
41829
|
+
const self2 = listLine(line.text);
|
|
41830
|
+
if (!self2) return false;
|
|
41831
|
+
if (direction === 1) {
|
|
41832
|
+
const parent2 = parentItem(state, line, self2.lead);
|
|
41833
|
+
const target = parent2 ? parent2.lead + parent2.width : self2.lead + self2.width;
|
|
41834
|
+
const lead2 = Math.max(target, self2.lead + INDENT.length);
|
|
41835
|
+
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) };
|
|
41836
|
+
const changes = state.changes(change);
|
|
41837
|
+
view.dispatch({
|
|
41838
|
+
changes,
|
|
41839
|
+
// 新子列表会把多位序号改成 1,光标要按整笔替换映射,不能只加缩进宽度。
|
|
41840
|
+
selection: { anchor: changes.mapPos(range.head, 1) },
|
|
41841
|
+
scrollIntoView: true,
|
|
41842
|
+
userEvent: "input"
|
|
41843
|
+
});
|
|
41844
|
+
return true;
|
|
41845
|
+
}
|
|
41846
|
+
const parent = parentItem(state, line, self2.lead - 1);
|
|
41847
|
+
const lead = parent ? parent.lead : 0;
|
|
41848
|
+
if (lead >= self2.lead) return false;
|
|
41849
|
+
view.dispatch({
|
|
41850
|
+
changes: { from: line.from, to: line.from + self2.lead, insert: " ".repeat(lead) },
|
|
41851
|
+
selection: { anchor: Math.max(line.from + lead, range.head - (self2.lead - lead)) },
|
|
41852
|
+
scrollIntoView: true,
|
|
41853
|
+
userEvent: "input"
|
|
41854
|
+
});
|
|
41855
|
+
return true;
|
|
41856
|
+
}
|
|
41857
|
+
function freshSublist(state, line, depth) {
|
|
41858
|
+
const self2 = listLine(line.text);
|
|
41859
|
+
if (!self2 || !self2.digits) return false;
|
|
41860
|
+
for (let number2 = line.number - 1; number2 >= 1; number2--) {
|
|
41861
|
+
const prev = state.doc.line(number2);
|
|
41862
|
+
if (prev.text.trim() === "") break;
|
|
41863
|
+
const prevLine = listLine(prev.text);
|
|
41864
|
+
if (!prevLine) {
|
|
41865
|
+
if (/^[ \t]*/.exec(prev.text)[0].length > depth) continue;
|
|
41866
|
+
break;
|
|
41867
|
+
}
|
|
41868
|
+
if (prevLine.lead === depth) return false;
|
|
41869
|
+
if (prevLine.lead < depth) break;
|
|
41870
|
+
}
|
|
41871
|
+
return true;
|
|
41872
|
+
}
|
|
41873
|
+
function listLine(text2) {
|
|
41874
|
+
const match = LIST_RE.exec(text2);
|
|
41875
|
+
if (!match) return null;
|
|
41876
|
+
const lead = match[1].length;
|
|
41877
|
+
const width = match[0].length - lead - (match[6]?.length ?? 0);
|
|
41878
|
+
return { lead, width, digits: match[3] ?? "" };
|
|
41879
|
+
}
|
|
41880
|
+
function parentItem(state, line, lead) {
|
|
41881
|
+
for (let number2 = line.number - 1; number2 >= 1; number2--) {
|
|
41882
|
+
const prev = state.doc.line(number2);
|
|
41883
|
+
if (prev.text.trim() === "") return null;
|
|
41884
|
+
const prevLine = listLine(prev.text);
|
|
41885
|
+
if (prevLine) {
|
|
41886
|
+
if (prevLine.lead <= lead) return prevLine;
|
|
41887
|
+
continue;
|
|
41888
|
+
}
|
|
41889
|
+
if (/^[ \t]*/.exec(prev.text)[0].length <= lead) return null;
|
|
41890
|
+
}
|
|
41891
|
+
return null;
|
|
41892
|
+
}
|
|
41893
|
+
const listInput = Prec.high(keymap.of([
|
|
41894
|
+
{ key: "Enter", run: insertNewlineContinueMarkupCommand({ nonTightLists: false }) },
|
|
41895
|
+
{ key: "Backspace", run: deleteAtLineStart },
|
|
41896
|
+
{ key: "Backspace", run: deleteMarkupBackward },
|
|
41897
|
+
{ key: "Tab", run: (view) => indentListItem(view, 1) },
|
|
41898
|
+
{ key: "Shift-Tab", run: (view) => indentListItem(view, -1) }
|
|
41899
|
+
]));
|
|
41900
|
+
const setSearchHighlight = StateEffect.define();
|
|
41901
|
+
const searchHighlightField = StateField.define({
|
|
41902
|
+
create: () => Decoration.none,
|
|
41903
|
+
update(value, tr) {
|
|
41904
|
+
for (const effect of tr.effects) {
|
|
41905
|
+
if (effect.is(setSearchHighlight)) return effect.value;
|
|
41906
|
+
}
|
|
41907
|
+
return value.map(tr.changes);
|
|
41908
|
+
},
|
|
41909
|
+
provide: (field) => EditorView.decorations.from(field)
|
|
41910
|
+
});
|
|
41769
41911
|
function legacy(parser2) {
|
|
41770
41912
|
return new LanguageSupport(StreamLanguage.define(parser2));
|
|
41771
41913
|
}
|
|
41772
41914
|
function sql(dialectName) {
|
|
41773
|
-
return __vitePreload(() => import("./index-
|
|
41915
|
+
return __vitePreload(() => import("./index-B90RKaFh.js"), true ? [] : void 0, import.meta.url).then((m) => m.sql({ dialect: m[dialectName] }));
|
|
41774
41916
|
}
|
|
41775
41917
|
const languages = [
|
|
41776
41918
|
// New-style language modes
|
|
@@ -41778,7 +41920,7 @@ const languages = [
|
|
|
41778
41920
|
name: "C",
|
|
41779
41921
|
extensions: ["c", "h", "ino"],
|
|
41780
41922
|
load() {
|
|
41781
|
-
return __vitePreload(() => import("./index-
|
|
41923
|
+
return __vitePreload(() => import("./index-CSXoVyN0.js"), true ? [] : void 0, import.meta.url).then((m) => m.cpp());
|
|
41782
41924
|
}
|
|
41783
41925
|
}),
|
|
41784
41926
|
/* @__PURE__ */ LanguageDescription.of({
|
|
@@ -41786,7 +41928,7 @@ const languages = [
|
|
|
41786
41928
|
alias: ["cpp"],
|
|
41787
41929
|
extensions: ["cpp", "c++", "cc", "cxx", "hpp", "h++", "hh", "hxx"],
|
|
41788
41930
|
load() {
|
|
41789
|
-
return __vitePreload(() => import("./index-
|
|
41931
|
+
return __vitePreload(() => import("./index-CSXoVyN0.js"), true ? [] : void 0, import.meta.url).then((m) => m.cpp());
|
|
41790
41932
|
}
|
|
41791
41933
|
}),
|
|
41792
41934
|
/* @__PURE__ */ LanguageDescription.of({
|
|
@@ -41808,7 +41950,7 @@ const languages = [
|
|
|
41808
41950
|
name: "Go",
|
|
41809
41951
|
extensions: ["go"],
|
|
41810
41952
|
load() {
|
|
41811
|
-
return __vitePreload(() => import("./index-
|
|
41953
|
+
return __vitePreload(() => import("./index-B2k43UK4.js"), true ? [] : void 0, import.meta.url).then((m) => m.go());
|
|
41812
41954
|
}
|
|
41813
41955
|
}),
|
|
41814
41956
|
/* @__PURE__ */ LanguageDescription.of({
|
|
@@ -41823,7 +41965,7 @@ const languages = [
|
|
|
41823
41965
|
name: "Java",
|
|
41824
41966
|
extensions: ["java"],
|
|
41825
41967
|
load() {
|
|
41826
|
-
return __vitePreload(() => import("./index-
|
|
41968
|
+
return __vitePreload(() => import("./index-OQWi5Igb.js"), true ? [] : void 0, import.meta.url).then((m) => m.java());
|
|
41827
41969
|
}
|
|
41828
41970
|
}),
|
|
41829
41971
|
/* @__PURE__ */ LanguageDescription.of({
|
|
@@ -41838,7 +41980,7 @@ const languages = [
|
|
|
41838
41980
|
name: "Jinja",
|
|
41839
41981
|
extensions: ["j2", "jinja", "jinja2"],
|
|
41840
41982
|
load() {
|
|
41841
|
-
return __vitePreload(() => import("./index-
|
|
41983
|
+
return __vitePreload(() => import("./index-DtaUmWot.js"), true ? [] : void 0, import.meta.url).then((m) => m.jinja());
|
|
41842
41984
|
}
|
|
41843
41985
|
}),
|
|
41844
41986
|
/* @__PURE__ */ LanguageDescription.of({
|
|
@@ -41846,7 +41988,7 @@ const languages = [
|
|
|
41846
41988
|
alias: ["json5"],
|
|
41847
41989
|
extensions: ["json", "map"],
|
|
41848
41990
|
load() {
|
|
41849
|
-
return __vitePreload(() => import("./index-
|
|
41991
|
+
return __vitePreload(() => import("./index-Mp0fGNKU.js"), true ? [] : void 0, import.meta.url).then((m) => m.json());
|
|
41850
41992
|
}
|
|
41851
41993
|
}),
|
|
41852
41994
|
/* @__PURE__ */ LanguageDescription.of({
|
|
@@ -41860,14 +42002,14 @@ const languages = [
|
|
|
41860
42002
|
name: "LESS",
|
|
41861
42003
|
extensions: ["less"],
|
|
41862
42004
|
load() {
|
|
41863
|
-
return __vitePreload(() => import("./index-
|
|
42005
|
+
return __vitePreload(() => import("./index-eX6agtDo.js"), true ? [] : void 0, import.meta.url).then((m) => m.less());
|
|
41864
42006
|
}
|
|
41865
42007
|
}),
|
|
41866
42008
|
/* @__PURE__ */ LanguageDescription.of({
|
|
41867
42009
|
name: "Liquid",
|
|
41868
42010
|
extensions: ["liquid"],
|
|
41869
42011
|
load() {
|
|
41870
|
-
return __vitePreload(() => import("./index-
|
|
42012
|
+
return __vitePreload(() => import("./index-Lj__gZ6c.js"), true ? [] : void 0, import.meta.url).then((m) => m.liquid());
|
|
41871
42013
|
}
|
|
41872
42014
|
}),
|
|
41873
42015
|
/* @__PURE__ */ LanguageDescription.of({
|
|
@@ -41899,7 +42041,7 @@ const languages = [
|
|
|
41899
42041
|
name: "PHP",
|
|
41900
42042
|
extensions: ["php", "php3", "php4", "php5", "php7", "phtml"],
|
|
41901
42043
|
load() {
|
|
41902
|
-
return __vitePreload(() => import("./index-
|
|
42044
|
+
return __vitePreload(() => import("./index-u6ZCoBKY.js"), true ? [] : void 0, import.meta.url).then((m) => m.php());
|
|
41903
42045
|
}
|
|
41904
42046
|
}),
|
|
41905
42047
|
/* @__PURE__ */ LanguageDescription.of({
|
|
@@ -41920,28 +42062,28 @@ const languages = [
|
|
|
41920
42062
|
extensions: ["BUILD", "bzl", "py", "pyw"],
|
|
41921
42063
|
filename: /^(BUCK|BUILD)$/,
|
|
41922
42064
|
load() {
|
|
41923
|
-
return __vitePreload(() => import("./index-
|
|
42065
|
+
return __vitePreload(() => import("./index-Duagl4VH.js"), true ? [] : void 0, import.meta.url).then((m) => m.python());
|
|
41924
42066
|
}
|
|
41925
42067
|
}),
|
|
41926
42068
|
/* @__PURE__ */ LanguageDescription.of({
|
|
41927
42069
|
name: "Rust",
|
|
41928
42070
|
extensions: ["rs"],
|
|
41929
42071
|
load() {
|
|
41930
|
-
return __vitePreload(() => import("./index-
|
|
42072
|
+
return __vitePreload(() => import("./index-r0CaOFQM.js"), true ? [] : void 0, import.meta.url).then((m) => m.rust());
|
|
41931
42073
|
}
|
|
41932
42074
|
}),
|
|
41933
42075
|
/* @__PURE__ */ LanguageDescription.of({
|
|
41934
42076
|
name: "Sass",
|
|
41935
42077
|
extensions: ["sass"],
|
|
41936
42078
|
load() {
|
|
41937
|
-
return __vitePreload(() => import("./index-
|
|
42079
|
+
return __vitePreload(() => import("./index-D0-6r8OY.js"), true ? [] : void 0, import.meta.url).then((m) => m.sass({ indented: true }));
|
|
41938
42080
|
}
|
|
41939
42081
|
}),
|
|
41940
42082
|
/* @__PURE__ */ LanguageDescription.of({
|
|
41941
42083
|
name: "SCSS",
|
|
41942
42084
|
extensions: ["scss"],
|
|
41943
42085
|
load() {
|
|
41944
|
-
return __vitePreload(() => import("./index-
|
|
42086
|
+
return __vitePreload(() => import("./index-D0-6r8OY.js"), true ? [] : void 0, import.meta.url).then((m) => m.sass());
|
|
41945
42087
|
}
|
|
41946
42088
|
}),
|
|
41947
42089
|
/* @__PURE__ */ LanguageDescription.of({
|
|
@@ -41976,7 +42118,7 @@ const languages = [
|
|
|
41976
42118
|
name: "WebAssembly",
|
|
41977
42119
|
extensions: ["wat", "wast"],
|
|
41978
42120
|
load() {
|
|
41979
|
-
return __vitePreload(() => import("./index-
|
|
42121
|
+
return __vitePreload(() => import("./index-Dx_w36Cl.js"), true ? [] : void 0, import.meta.url).then((m) => m.wast());
|
|
41980
42122
|
}
|
|
41981
42123
|
}),
|
|
41982
42124
|
/* @__PURE__ */ LanguageDescription.of({
|
|
@@ -41984,7 +42126,7 @@ const languages = [
|
|
|
41984
42126
|
alias: ["rss", "wsdl", "xsd"],
|
|
41985
42127
|
extensions: ["xml", "xsl", "xsd", "svg"],
|
|
41986
42128
|
load() {
|
|
41987
|
-
return __vitePreload(() => import("./index-
|
|
42129
|
+
return __vitePreload(() => import("./index-DVUqWypj.js"), true ? [] : void 0, import.meta.url).then((m) => m.xml());
|
|
41988
42130
|
}
|
|
41989
42131
|
}),
|
|
41990
42132
|
/* @__PURE__ */ LanguageDescription.of({
|
|
@@ -41992,7 +42134,7 @@ const languages = [
|
|
|
41992
42134
|
alias: ["yml"],
|
|
41993
42135
|
extensions: ["yaml", "yml"],
|
|
41994
42136
|
load() {
|
|
41995
|
-
return __vitePreload(() => import("./index-
|
|
42137
|
+
return __vitePreload(() => import("./index-OVUeW-Iw.js"), true ? [] : void 0, import.meta.url).then((m) => m.yaml());
|
|
41996
42138
|
}
|
|
41997
42139
|
}),
|
|
41998
42140
|
// Legacy modes ported from CodeMirror 5
|
|
@@ -42781,13 +42923,13 @@ const languages = [
|
|
|
42781
42923
|
name: "Vue",
|
|
42782
42924
|
extensions: ["vue"],
|
|
42783
42925
|
load() {
|
|
42784
|
-
return __vitePreload(() => import("./index-
|
|
42926
|
+
return __vitePreload(() => import("./index-C6upWLHM.js"), true ? [] : void 0, import.meta.url).then((m) => m.vue());
|
|
42785
42927
|
}
|
|
42786
42928
|
}),
|
|
42787
42929
|
/* @__PURE__ */ LanguageDescription.of({
|
|
42788
42930
|
name: "Angular Template",
|
|
42789
42931
|
load() {
|
|
42790
|
-
return __vitePreload(() => import("./index-
|
|
42932
|
+
return __vitePreload(() => import("./index-CZLcUFAS.js"), true ? [] : void 0, import.meta.url).then((m) => m.angular());
|
|
42791
42933
|
}
|
|
42792
42934
|
})
|
|
42793
42935
|
];
|
|
@@ -42800,7 +42942,10 @@ const markdownHighlightStyle = HighlightStyle.define([
|
|
|
42800
42942
|
{ tag: tags$1.emphasis, fontStyle: "italic" },
|
|
42801
42943
|
{ tag: tags$1.strikethrough, textDecoration: "line-through" },
|
|
42802
42944
|
{ tag: tags$1.link, color: "var(--link-color)" },
|
|
42803
|
-
|
|
42945
|
+
// 标记字符(`#`、`>`、`***`、围栏)压淡;**正文不许跟着淡**。
|
|
42946
|
+
// `t.list` 曾经也在这条里,它盖住的是列表项里的文字,不只是 `-`、`1.` 那两个字符:
|
|
42947
|
+
// 整个列表都发灰(2026-10-25 报的)。列表的圆点与序号由 editor-preview.css 单独管。
|
|
42948
|
+
{ tag: [tags$1.processingInstruction, tags$1.contentSeparator], color: "var(--text-muted)" },
|
|
42804
42949
|
/* 代码块里的语法着色。解析器在 state.ts 里通过 `codeLanguages` 接进来(装了哪些
|
|
42805
42950
|
语言就认哪些),这里只决定怎么画。
|
|
42806
42951
|
颜色是变量,不是字面值:--code-* 由主题按代码块底色的明暗给两套(见 base.css),
|
|
@@ -42832,6 +42977,8 @@ const editorTheme = EditorView.theme({
|
|
|
42832
42977
|
一旦在这里写 padding,引用块、列表、代码块的内边距会被整片吃掉(实测全为 0px)。
|
|
42833
42978
|
归零与块级内边距都写在 editor-preview.css 里,用同样两个类的选择器,靠文件顺序决胜。 */
|
|
42834
42979
|
".cm-cursor, .cm-dropCursor": { borderLeftColor: "var(--text-color)" },
|
|
42980
|
+
/* 代码块可能是深底(雅致、熊红),光标在里面要跟代码文字同色才看得见。类由 cursor-colors 挂。 */
|
|
42981
|
+
"&.cm-cursor-in-code .cm-cursor-primary, &.cm-drop-in-code .cm-dropCursor": { borderLeftColor: "var(--code-block-text, var(--text-color))" },
|
|
42835
42982
|
/* 选中色只在这里管原生选区。真正画出来的那条色带(.cm-selectionBackground)写在
|
|
42836
42983
|
themes/editor-preview.css:baseTheme 给它的选择器有四个类,这里写不进去;
|
|
42837
42984
|
同优先级时 baseTheme 总在后面。 */
|
|
@@ -43011,7 +43158,7 @@ function stateExtensions() {
|
|
|
43011
43158
|
// 一起。查找是应用级功能,入口在菜单的「查找」上(Cmd+F 由菜单的快捷键发
|
|
43012
43159
|
// `editor:search`),面板在 editor/search-panel.ts。
|
|
43013
43160
|
keymap.of([
|
|
43014
|
-
...defaultKeymap,
|
|
43161
|
+
...defaultKeymap.filter((binding) => binding.key !== "Mod-/"),
|
|
43015
43162
|
...historyKeymap,
|
|
43016
43163
|
indentWithTab
|
|
43017
43164
|
])
|
|
@@ -43023,11 +43170,67 @@ function bodyStart(doc2) {
|
|
|
43023
43170
|
const lineBreak = doc2.indexOf("\n", front.to);
|
|
43024
43171
|
return lineBreak === -1 ? doc2.length : lineBreak + 1;
|
|
43025
43172
|
}
|
|
43173
|
+
function inCodeBlock(state, pos) {
|
|
43174
|
+
const decorations2 = state.field(livePreviewField, false);
|
|
43175
|
+
if (!decorations2) return false;
|
|
43176
|
+
const line = state.doc.lineAt(pos);
|
|
43177
|
+
let code = false;
|
|
43178
|
+
decorations2.between(line.from, line.from, (_from, _to, decoration) => {
|
|
43179
|
+
if (decoration.spec.class?.split(" ").includes("cm-md-codeblock")) code = true;
|
|
43180
|
+
});
|
|
43181
|
+
return code;
|
|
43182
|
+
}
|
|
43183
|
+
const setDropInCode = StateEffect.define();
|
|
43184
|
+
const dropInCode = StateField.define({
|
|
43185
|
+
create: () => false,
|
|
43186
|
+
update: (value, tr) => tr.effects.reduce((next, effect) => effect.is(setDropInCode) ? effect.value : next, value)
|
|
43187
|
+
});
|
|
43188
|
+
function setDrop(view, code) {
|
|
43189
|
+
if (view.state.field(dropInCode) !== code) view.dispatch({ effects: setDropInCode.of(code) });
|
|
43190
|
+
}
|
|
43191
|
+
const cursorColors = [
|
|
43192
|
+
dropInCode,
|
|
43193
|
+
EditorView.domEventObservers({
|
|
43194
|
+
dragover(event, view) {
|
|
43195
|
+
const pos = view.posAtCoords({ x: event.clientX, y: event.clientY });
|
|
43196
|
+
setDrop(view, pos !== null && inCodeBlock(view.state, pos));
|
|
43197
|
+
},
|
|
43198
|
+
// 判据与 CodeMirror 的 dropCursor 一致:真的离开了编辑区才算
|
|
43199
|
+
dragleave(event, view) {
|
|
43200
|
+
if (event.target === view.contentDOM || !view.contentDOM.contains(event.relatedTarget)) setDrop(view, false);
|
|
43201
|
+
},
|
|
43202
|
+
dragend: (_event, view) => setDrop(view, false),
|
|
43203
|
+
drop: (_event, view) => setDrop(view, false)
|
|
43204
|
+
}),
|
|
43205
|
+
EditorView.editorAttributes.compute(["selection", livePreviewField, dropInCode], (state) => {
|
|
43206
|
+
const classes = [
|
|
43207
|
+
inCodeBlock(state, state.selection.main.head) ? "cm-cursor-in-code" : "",
|
|
43208
|
+
state.field(dropInCode) ? "cm-drop-in-code" : ""
|
|
43209
|
+
].filter(Boolean);
|
|
43210
|
+
return classes.length ? { class: classes.join(" ") } : {};
|
|
43211
|
+
})
|
|
43212
|
+
];
|
|
43026
43213
|
let handle$1 = null;
|
|
43027
43214
|
function getEditorHandle() {
|
|
43028
43215
|
return handle$1;
|
|
43029
43216
|
}
|
|
43030
43217
|
const livePreviewCompartment = new Compartment();
|
|
43218
|
+
const taskMarkerAtomicRanges = EditorView.atomicRanges.of((view) => {
|
|
43219
|
+
const doc2 = view.state.doc;
|
|
43220
|
+
const ranges = [];
|
|
43221
|
+
syntaxTree(view.state).iterate({
|
|
43222
|
+
enter: (node) => {
|
|
43223
|
+
if (node.name !== "TaskMarker") return;
|
|
43224
|
+
const line = doc2.lineAt(node.from);
|
|
43225
|
+
const prefix = doc2.sliceString(line.from, node.from);
|
|
43226
|
+
const from = /^[ \t]*(?:[-*+]|\d+[.)])[ \t]+$/.test(prefix) ? line.from : node.from;
|
|
43227
|
+
const trailing = doc2.sliceString(node.to, Math.min(node.to + 1, line.to)) === " " ? node.to + 1 : node.to;
|
|
43228
|
+
ranges.push({ from, to: trailing });
|
|
43229
|
+
}
|
|
43230
|
+
});
|
|
43231
|
+
return RangeSet.of(ranges.map((r) => ATOMIC_MARK.range(r.from, r.to)), true);
|
|
43232
|
+
});
|
|
43233
|
+
const ATOMIC_MARK = Decoration.replace({});
|
|
43031
43234
|
function isSourceMode(state) {
|
|
43032
43235
|
return state.field(livePreviewField, false) === void 0;
|
|
43033
43236
|
}
|
|
@@ -43037,6 +43240,7 @@ function editorExtensions(sourceMode, editable2, onChange) {
|
|
|
43037
43240
|
stateExtensions(),
|
|
43038
43241
|
// 以下是 view 层:选区绘制、拖放光标、特殊字符、主题
|
|
43039
43242
|
drawSelection(),
|
|
43243
|
+
cursorColors,
|
|
43040
43244
|
// 自动换行。CodeMirror 默认**不换行**,长行会横向滚动;markdown 正文必须换行。
|
|
43041
43245
|
EditorView.lineWrapping,
|
|
43042
43246
|
dropCursor(),
|
|
@@ -43066,6 +43270,10 @@ function editorExtensions(sourceMode, editable2, onChange) {
|
|
|
43066
43270
|
// 检索高亮。面板靠 effect 改它,而 effect 得有 StateField 接住;
|
|
43067
43271
|
// 不装这一条,检索面板会以为高亮画上了,实际什么也没发生。
|
|
43068
43272
|
searchHighlightField,
|
|
43273
|
+
// 任务项的复选框是一个 replace widget,但没声明成原子区间时,光标能停在
|
|
43274
|
+
// `[ ]` 两个方框之间那一格里:左右键要一格一格挪过去,停在里面打字又把
|
|
43275
|
+
// `- [ ]` 敲成 `- [x]` 之类的残骸(#164)。声明成原子区间后,光标一次跨过它。
|
|
43276
|
+
taskMarkerAtomicRanges,
|
|
43069
43277
|
editableCompartment.of(EditorView.editable.of(editable2)),
|
|
43070
43278
|
// 文档变化的唯一出口:把新文本交给外壳
|
|
43071
43279
|
EditorView.updateListener.of((update) => {
|
|
@@ -43082,6 +43290,7 @@ function createEditorCore(parent, options2 = {}) {
|
|
|
43082
43290
|
state: EditorState.create({ doc: options2.doc ?? "", extensions: editorExtensions(false, editableAtStart, changeListener) }),
|
|
43083
43291
|
parent
|
|
43084
43292
|
});
|
|
43293
|
+
setMeasureHost(view);
|
|
43085
43294
|
if (view.hasFocus) view.dispatch({ effects: setEditorFocus.of(true) });
|
|
43086
43295
|
const api = {
|
|
43087
43296
|
getText: () => view.state.doc.toString(),
|
|
@@ -43118,6 +43327,7 @@ function createEditorCore(parent, options2 = {}) {
|
|
|
43118
43327
|
},
|
|
43119
43328
|
getView: () => view,
|
|
43120
43329
|
destroy() {
|
|
43330
|
+
setMeasureHost(null);
|
|
43121
43331
|
view.destroy();
|
|
43122
43332
|
handle$1 = null;
|
|
43123
43333
|
}
|
|
@@ -43149,7 +43359,7 @@ function escapeText(value) {
|
|
|
43149
43359
|
function escapeAttribute(value) {
|
|
43150
43360
|
return escapeText(value).replace(/"/g, """);
|
|
43151
43361
|
}
|
|
43152
|
-
function lineKind(line) {
|
|
43362
|
+
function lineKind(line, includeList = true) {
|
|
43153
43363
|
const classes = line.classList;
|
|
43154
43364
|
for (let level = 1; level <= 6; level++) {
|
|
43155
43365
|
if (classes.contains(`cm-md-atxheading${level}`)) return `h${level}`;
|
|
@@ -43161,7 +43371,7 @@ function lineKind(line) {
|
|
|
43161
43371
|
if (classes.contains("cm-md-hr")) return "hr";
|
|
43162
43372
|
if (line.querySelector(".cm-md-table-widget")) return "table";
|
|
43163
43373
|
if (classes.contains("cm-md-frontmatter")) return "empty";
|
|
43164
|
-
for (let depth = 0; depth <= 6; depth++) {
|
|
43374
|
+
if (includeList) for (let depth = 0; depth <= 6; depth++) {
|
|
43165
43375
|
if (classes.contains(`cm-md-li-${depth}`)) return "li";
|
|
43166
43376
|
}
|
|
43167
43377
|
if ((line.textContent ?? "").trim() === "" && line.querySelector("img") === null) return "empty";
|
|
@@ -43243,6 +43453,34 @@ function renderList(lines) {
|
|
|
43243
43453
|
while (open2.length > 0) html2 += `</li></${tagOf(open2.pop().ordered)}>`;
|
|
43244
43454
|
return html2;
|
|
43245
43455
|
}
|
|
43456
|
+
function listContext(node) {
|
|
43457
|
+
if (!(node instanceof HTMLElement)) return null;
|
|
43458
|
+
const line = node.classList.contains("cm-line") ? node : node.querySelector(".cm-line");
|
|
43459
|
+
if (!line?.classList.contains("cm-md-li") || !line.dataset.listPath) return null;
|
|
43460
|
+
return { path: JSON.parse(line.dataset.listPath), quoted: line.dataset.listQuoted === "true" };
|
|
43461
|
+
}
|
|
43462
|
+
function renderOwnedList(nodes, depth) {
|
|
43463
|
+
let html2 = "", index2 = 0;
|
|
43464
|
+
while (index2 < nodes.length) {
|
|
43465
|
+
const first = listContext(nodes[index2]).path[depth];
|
|
43466
|
+
const tag = first.start === void 0 ? "ul" : "ol";
|
|
43467
|
+
html2 += first.start !== void 0 && first.start !== 1 ? `<ol start="${first.start}">` : `<${tag}>`;
|
|
43468
|
+
while (index2 < nodes.length && listContext(nodes[index2]).path[depth].list === first.list) {
|
|
43469
|
+
const item = listContext(nodes[index2]).path[depth].item;
|
|
43470
|
+
const group = [];
|
|
43471
|
+
while (index2 < nodes.length) {
|
|
43472
|
+
const path2 = listContext(nodes[index2]).path[depth];
|
|
43473
|
+
if (path2.list !== first.list || path2.item !== item) break;
|
|
43474
|
+
group.push(nodes[index2++]);
|
|
43475
|
+
}
|
|
43476
|
+
const body = blocksHTML(group, depth);
|
|
43477
|
+
const singleParagraph = body.startsWith("<p>") && body.indexOf("</p>") === body.length - 4;
|
|
43478
|
+
html2 += `<li>${singleParagraph ? body.slice(3, -4).trimStart() : body}</li>`;
|
|
43479
|
+
}
|
|
43480
|
+
html2 += `</${tag}>`;
|
|
43481
|
+
}
|
|
43482
|
+
return html2;
|
|
43483
|
+
}
|
|
43246
43484
|
function isCodeFenceStart(line) {
|
|
43247
43485
|
return line.classList.contains("cm-md-codeblock-first") || /^(`{3,}|~{3,})/.test((line.textContent ?? "").trimStart());
|
|
43248
43486
|
}
|
|
@@ -43260,11 +43498,11 @@ function renderCode(lines) {
|
|
|
43260
43498
|
const code = body.map((line) => line.textContent ?? "").join("\n");
|
|
43261
43499
|
return `<pre><code>${escapeText(code)}</code></pre>`;
|
|
43262
43500
|
}
|
|
43263
|
-
function renderGroup(kind, lines) {
|
|
43501
|
+
function renderGroup(kind, lines, ownerDepth = -1) {
|
|
43264
43502
|
if (kind === "code") return renderCode(lines);
|
|
43265
43503
|
if (kind === "mermaid") {
|
|
43266
43504
|
const widget = lines[0].querySelector(".cm-md-mermaid");
|
|
43267
|
-
return widget ? `<div>${widget.innerHTML}</div>` : "";
|
|
43505
|
+
return widget ? `<div class="${widget.className}">${widget.innerHTML}</div>` : "";
|
|
43268
43506
|
}
|
|
43269
43507
|
if (kind === "math") {
|
|
43270
43508
|
const widget = lines[0].querySelector(".cm-md-math-block");
|
|
@@ -43278,7 +43516,16 @@ function renderGroup(kind, lines) {
|
|
|
43278
43516
|
const table = lines[0].querySelector(".cm-md-table-widget");
|
|
43279
43517
|
if (!table) return "";
|
|
43280
43518
|
const clone = table.cloneNode(true);
|
|
43281
|
-
clone.
|
|
43519
|
+
for (const shell of Array.from(clone.querySelectorAll(".cm-md-math, .cm-md-mermaid-ready"))) {
|
|
43520
|
+
shell.replaceWith(...Array.from(shell.childNodes));
|
|
43521
|
+
}
|
|
43522
|
+
for (const element of [clone, ...Array.from(clone.querySelectorAll("*"))]) {
|
|
43523
|
+
element.classList.remove(...Array.from(element.classList).filter((name2) => name2.startsWith("cm-md-")));
|
|
43524
|
+
element.removeAttribute("contenteditable");
|
|
43525
|
+
for (const attribute of ["data-source-from", "data-source-to", "data-list-path", "data-line"]) {
|
|
43526
|
+
element.removeAttribute(attribute);
|
|
43527
|
+
}
|
|
43528
|
+
}
|
|
43282
43529
|
return clone.outerHTML;
|
|
43283
43530
|
}
|
|
43284
43531
|
if (kind === "hr") return "<hr>";
|
|
@@ -43287,16 +43534,53 @@ function renderGroup(kind, lines) {
|
|
|
43287
43534
|
const level = kind.slice(1);
|
|
43288
43535
|
return `<h${level}>${lineHTML(lines[0])}</h${level}>`;
|
|
43289
43536
|
}
|
|
43290
|
-
|
|
43537
|
+
const separator = ownerDepth >= 0 && lines.length > 1 ? "<br>" : "\n";
|
|
43538
|
+
return `<p>${lines.map((line) => {
|
|
43539
|
+
const content2 = lineHTML(line);
|
|
43540
|
+
return line.dataset.listPath ? content2.replace(/^[ \t]+/, "") : content2;
|
|
43541
|
+
}).join(separator)}</p>`;
|
|
43291
43542
|
}
|
|
43292
43543
|
function mergeable(kind) {
|
|
43293
43544
|
return kind === "code" || kind === "li" || kind === "quote";
|
|
43294
43545
|
}
|
|
43295
|
-
function blocksHTML(nodes) {
|
|
43546
|
+
function blocksHTML(nodes, ownerDepth = -1) {
|
|
43296
43547
|
let html2 = "";
|
|
43297
43548
|
let index2 = 0;
|
|
43549
|
+
let quoteEnd = 0;
|
|
43298
43550
|
while (index2 < nodes.length) {
|
|
43299
43551
|
const node = nodes[index2];
|
|
43552
|
+
const context = listContext(node);
|
|
43553
|
+
if (index2 >= quoteEnd && node instanceof HTMLElement && node.classList.contains("cm-md-blockquote") && (!context || context.quoted || context.path.length <= ownerDepth + 1)) {
|
|
43554
|
+
const group2 = [node];
|
|
43555
|
+
let next = index2 + 1;
|
|
43556
|
+
while (next < nodes.length) {
|
|
43557
|
+
const candidate = nodes[next];
|
|
43558
|
+
if (!(candidate instanceof HTMLElement) || !candidate.classList.contains("cm-md-blockquote")) break;
|
|
43559
|
+
group2.push(candidate);
|
|
43560
|
+
next += 1;
|
|
43561
|
+
}
|
|
43562
|
+
quoteEnd = next;
|
|
43563
|
+
if (group2.some((line) => listContext(line))) {
|
|
43564
|
+
const inner2 = group2.map((line) => {
|
|
43565
|
+
const clone = line.cloneNode(true);
|
|
43566
|
+
clone.classList.remove("cm-md-blockquote");
|
|
43567
|
+
return clone;
|
|
43568
|
+
});
|
|
43569
|
+
html2 += `<blockquote>${blocksHTML(inner2, ownerDepth)}</blockquote>`;
|
|
43570
|
+
index2 = next;
|
|
43571
|
+
continue;
|
|
43572
|
+
}
|
|
43573
|
+
}
|
|
43574
|
+
if (context && context.path.length > ownerDepth + 1) {
|
|
43575
|
+
const group2 = [node];
|
|
43576
|
+
while (++index2 < nodes.length) {
|
|
43577
|
+
if ((listContext(nodes[index2])?.path.length ?? 0) <= ownerDepth + 1) break;
|
|
43578
|
+
group2.push(nodes[index2]);
|
|
43579
|
+
}
|
|
43580
|
+
const depth = ownerDepth < 0 ? group2.reduce((min, part) => Math.min(min, listContext(part).path.length - 1), context.path.length - 1) : ownerDepth + 1;
|
|
43581
|
+
html2 += renderOwnedList(group2, depth);
|
|
43582
|
+
continue;
|
|
43583
|
+
}
|
|
43300
43584
|
if (!isLineElement(node)) {
|
|
43301
43585
|
const inline = [];
|
|
43302
43586
|
while (index2 < nodes.length && !isLineElement(nodes[index2])) {
|
|
@@ -43307,13 +43591,14 @@ function blocksHTML(nodes) {
|
|
|
43307
43591
|
if (merged.trim() !== "") html2 += `<p>${merged}</p>`;
|
|
43308
43592
|
continue;
|
|
43309
43593
|
}
|
|
43310
|
-
const kind = lineKind(node);
|
|
43594
|
+
const kind = lineKind(node, !context);
|
|
43311
43595
|
const group = [node];
|
|
43312
|
-
|
|
43596
|
+
const paragraph = node.dataset.listParagraph;
|
|
43597
|
+
if (mergeable(kind) || kind === "p" && paragraph) {
|
|
43313
43598
|
let next = index2 + 1;
|
|
43314
43599
|
while (next < nodes.length) {
|
|
43315
43600
|
const candidate = nodes[next];
|
|
43316
|
-
if (!(candidate instanceof HTMLElement) || lineKind(candidate) !== kind) break;
|
|
43601
|
+
if (!(candidate instanceof HTMLElement) || lineKind(candidate, !listContext(candidate)) !== kind || kind === "p" && candidate.dataset.listParagraph !== paragraph) break;
|
|
43317
43602
|
group.push(candidate);
|
|
43318
43603
|
next += 1;
|
|
43319
43604
|
}
|
|
@@ -43321,7 +43606,7 @@ function blocksHTML(nodes) {
|
|
|
43321
43606
|
} else {
|
|
43322
43607
|
index2 += 1;
|
|
43323
43608
|
}
|
|
43324
|
-
html2 += renderGroup(kind, group);
|
|
43609
|
+
html2 += renderGroup(kind, group, ownerDepth);
|
|
43325
43610
|
}
|
|
43326
43611
|
return html2;
|
|
43327
43612
|
}
|
|
@@ -43343,6 +43628,11 @@ const PAPER_RULES = `
|
|
|
43343
43628
|
body.${PAPER_CLASS} #editor { height: auto !important; overflow: visible !important; }
|
|
43344
43629
|
body.${PAPER_CLASS} #editor .cm-editor { height: auto !important; }
|
|
43345
43630
|
body.${PAPER_CLASS} #editor .cm-scroller { display: block !important; height: auto !important; overflow: visible !important; }
|
|
43631
|
+
/* 放不下的图带一排缩放控件(#129)。打印时 Chromium 不执行脚本,pele 没机会把它们
|
|
43632
|
+
收回去,控件就叠在图上进了 PDF。它是编辑器的东西,不是文档的内容——纸面上藏掉
|
|
43633
|
+
(图片/HTML 导出另有 withDiagramZoomPaused 在序列化时兜着;Word 导出重新画图,
|
|
43634
|
+
天生没有控件)。内联样式是 pele 自己写的,!important 才压得过。 */
|
|
43635
|
+
body.${PAPER_CLASS} .pele-zoom { display: none !important; }
|
|
43346
43636
|
`;
|
|
43347
43637
|
function nextFrame() {
|
|
43348
43638
|
return new Promise((resolve) => {
|
|
@@ -43751,6 +44041,7 @@ function selectionRange(view, ranges) {
|
|
|
43751
44041
|
range.setEnd(end.node, end.offset);
|
|
43752
44042
|
return range;
|
|
43753
44043
|
}
|
|
44044
|
+
const MAX_RICH_COPY_CHARS = 2e5;
|
|
43754
44045
|
function selectionHTML(view, ranges) {
|
|
43755
44046
|
return selectionHTMLFrom(selectionRange(view, ranges).cloneContents());
|
|
43756
44047
|
}
|
|
@@ -43785,6 +44076,7 @@ function setupRichCopy(root) {
|
|
|
43785
44076
|
if (html2) event.clipboardData?.setData("text/html", html2);
|
|
43786
44077
|
return;
|
|
43787
44078
|
}
|
|
44079
|
+
if (view.state.doc.length > MAX_RICH_COPY_CHARS) return;
|
|
43788
44080
|
event.preventDefault();
|
|
43789
44081
|
void writeRichCopy(view, ranges, text2);
|
|
43790
44082
|
});
|
|
@@ -43873,12 +44165,12 @@ function setupFootnotePreview(root) {
|
|
|
43873
44165
|
}
|
|
43874
44166
|
const TASK_RE = /^([ \t]*(?:[-*+]|\d+[.)])[ \t]+\[)([ xX])(\])/;
|
|
43875
44167
|
function sourceFromTaskClick(view, e) {
|
|
44168
|
+
if (!(e.target instanceof HTMLElement)) return null;
|
|
44169
|
+
if (!e.target.closest(".cm-md-task")) return null;
|
|
43876
44170
|
const pos = view.posAtCoords({ x: e.clientX, y: e.clientY });
|
|
43877
44171
|
if (pos === null) return null;
|
|
43878
44172
|
const line = view.state.doc.lineAt(pos);
|
|
43879
44173
|
if (!TASK_RE.test(line.text)) return null;
|
|
43880
|
-
const rect = e.target.getBoundingClientRect();
|
|
43881
|
-
if (e.clientX - rect.left > 24) return null;
|
|
43882
44174
|
return line.from;
|
|
43883
44175
|
}
|
|
43884
44176
|
function toggleTaskAt(view, pos) {
|
|
@@ -43945,8 +44237,29 @@ function jumpToLine(line) {
|
|
|
43945
44237
|
flashLine(view, target.from, target.to);
|
|
43946
44238
|
}
|
|
43947
44239
|
const MERMAID_FENCE = /^([ \t]*)```[ \t]*mermaid[ \t]*\r?\n([\s\S]*?)^\1```[ \t]*$/gm;
|
|
43948
|
-
|
|
43949
|
-
const
|
|
44240
|
+
function mixSrgb(a, b, weightA) {
|
|
44241
|
+
const parse = (hex) => [0, 2, 4].map((index2) => Number.parseInt(hex.slice(index2, index2 + 2), 16) || 0);
|
|
44242
|
+
const [ra, ga, ba] = parse(a);
|
|
44243
|
+
const [rb, gb, bb] = parse(b);
|
|
44244
|
+
const mix = (x, y) => Math.max(0, Math.min(255, Math.round(x * weightA + y * (1 - weightA))));
|
|
44245
|
+
return [mix(ra, rb), mix(ga, gb), mix(ba, bb)].map((value) => value.toString(16).padStart(2, "0")).join("").toUpperCase();
|
|
44246
|
+
}
|
|
44247
|
+
function diagramPrintPalette(style) {
|
|
44248
|
+
const bg = style.codeBlockBackground;
|
|
44249
|
+
const fg = style.codeBlockText;
|
|
44250
|
+
return {
|
|
44251
|
+
"--pele-bg": `#${bg}`,
|
|
44252
|
+
"--pele-fg": `#${fg}`,
|
|
44253
|
+
"--pele-muted": `#${mixSrgb(fg, bg, 0.7)}`,
|
|
44254
|
+
"--pele-line": `#${fg}`,
|
|
44255
|
+
"--pele-surface": `#${mixSrgb(fg, bg, 0.18)}`,
|
|
44256
|
+
"--pele-surface-alt": `#${mixSrgb(fg, bg, 0.28)}`,
|
|
44257
|
+
"--pele-border": `#${mixSrgb(fg, bg, 0.45)}`,
|
|
44258
|
+
"--pele-accent": `#${style.link}`
|
|
44259
|
+
};
|
|
44260
|
+
}
|
|
44261
|
+
async function diagramPNG(code, palette) {
|
|
44262
|
+
const svg = await renderMermaid(code, { print: true, palette });
|
|
43950
44263
|
const root = new DOMParser().parseFromString(svg, "image/svg+xml").documentElement;
|
|
43951
44264
|
if (!root || root.nodeName !== "svg") return null;
|
|
43952
44265
|
const viewBox = (root.getAttribute("viewBox") ?? "").trim().split(/[\s,]+/).map(Number);
|
|
@@ -43975,7 +44288,12 @@ async function diagramPNG(code) {
|
|
|
43975
44288
|
context.drawImage(image, 0, 0, canvas.width, canvas.height);
|
|
43976
44289
|
return canvas.toDataURL("image/png");
|
|
43977
44290
|
}
|
|
43978
|
-
async function markdownForWord(markdown2, chinese
|
|
44291
|
+
async function markdownForWord(markdown2, chinese, palette = diagramPrintPalette({
|
|
44292
|
+
// 与 docx-style.ts 的 LIGHT 常量同源:没有样式令牌时(脚本/兜底场景)按浅色画。
|
|
44293
|
+
codeBlockBackground: "F6F8FA",
|
|
44294
|
+
codeBlockText: "24292F",
|
|
44295
|
+
link: "0969DA"
|
|
44296
|
+
})) {
|
|
43979
44297
|
const fences = [];
|
|
43980
44298
|
MERMAID_FENCE.lastIndex = 0;
|
|
43981
44299
|
for (let match = MERMAID_FENCE.exec(markdown2); match; match = MERMAID_FENCE.exec(markdown2)) {
|
|
@@ -43995,7 +44313,7 @@ async function markdownForWord(markdown2, chinese) {
|
|
|
43995
44313
|
for (const fence of fences) {
|
|
43996
44314
|
index2 += 1;
|
|
43997
44315
|
const name2 = `colamd-diagram-${index2}.png`;
|
|
43998
|
-
const png = await diagramPNG(fence.code).catch(() => null);
|
|
44316
|
+
const png = await diagramPNG(fence.code, palette).catch(() => null);
|
|
43999
44317
|
pieces.push(markdown2.slice(cursor, fence.start));
|
|
44000
44318
|
if (png) {
|
|
44001
44319
|
images[name2] = png;
|
|
@@ -45639,13 +45957,13 @@ async function capModule(name2) {
|
|
|
45639
45957
|
try {
|
|
45640
45958
|
switch (name2) {
|
|
45641
45959
|
case "@capacitor/filesystem":
|
|
45642
|
-
return await __vitePreload(() => import("./index-
|
|
45960
|
+
return await __vitePreload(() => import("./index-DrTzZcbo.js"), true ? [] : void 0, import.meta.url);
|
|
45643
45961
|
case "@capacitor/share":
|
|
45644
|
-
return await __vitePreload(() => import("./index-
|
|
45962
|
+
return await __vitePreload(() => import("./index-DHfl2nIi.js"), true ? [] : void 0, import.meta.url);
|
|
45645
45963
|
case "@capacitor/app":
|
|
45646
|
-
return await __vitePreload(() => import("./index-
|
|
45964
|
+
return await __vitePreload(() => import("./index-IgLPrOn8.js"), true ? [] : void 0, import.meta.url);
|
|
45647
45965
|
case "@capawesome/capacitor-file-picker":
|
|
45648
|
-
return await __vitePreload(() => import("./index-
|
|
45966
|
+
return await __vitePreload(() => import("./index-BkfZmH8n.js"), true ? [] : void 0, import.meta.url);
|
|
45649
45967
|
default:
|
|
45650
45968
|
return null;
|
|
45651
45969
|
}
|
|
@@ -46812,10 +47130,8 @@ function scrollRatio(el) {
|
|
|
46812
47130
|
return range > 0 ? el.scrollTop / range : 0;
|
|
46813
47131
|
}
|
|
46814
47132
|
function restoreScrollRatio(el, ratio) {
|
|
46815
|
-
|
|
46816
|
-
|
|
46817
|
-
el.scrollTop = Math.max(0, Math.min(range, range * ratio));
|
|
46818
|
-
});
|
|
47133
|
+
const range = el.scrollHeight - el.clientHeight;
|
|
47134
|
+
el.scrollTop = Math.max(0, Math.min(range, range * ratio));
|
|
46819
47135
|
}
|
|
46820
47136
|
function toggleSourceMode() {
|
|
46821
47137
|
const ratio = scrollRatio(editorScroller());
|
|
@@ -47347,6 +47663,11 @@ async function init() {
|
|
|
47347
47663
|
api.onSearch(() => searchPanel.show());
|
|
47348
47664
|
document.addEventListener("keydown", (event) => {
|
|
47349
47665
|
if (!(event.metaKey || event.ctrlKey) || event.shiftKey || event.altKey) return;
|
|
47666
|
+
if (event.key === "/") {
|
|
47667
|
+
event.preventDefault();
|
|
47668
|
+
toggleSourceMode();
|
|
47669
|
+
return;
|
|
47670
|
+
}
|
|
47350
47671
|
if (event.key.toLowerCase() !== "f") return;
|
|
47351
47672
|
event.preventDefault();
|
|
47352
47673
|
searchPanel.show();
|
|
@@ -47443,7 +47764,7 @@ async function init() {
|
|
|
47443
47764
|
const style = readDocxStyle();
|
|
47444
47765
|
const html2 = await markdownWithHtmlImages(getContent(), `#${style.text}`);
|
|
47445
47766
|
const math2 = await markdownWithMathImages(html2.content, isChinese$1(), `#${style.text}`);
|
|
47446
|
-
const payload = await markdownForWord(math2.content, isChinese$1());
|
|
47767
|
+
const payload = await markdownForWord(math2.content, isChinese$1(), diagramPrintPalette(style));
|
|
47447
47768
|
await api.exportDOCX({
|
|
47448
47769
|
content: payload.content,
|
|
47449
47770
|
images: { ...html2.images, ...math2.images, ...payload.images },
|