@bytechain.cn/colamd 2.7.9 → 2.7.12
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 +7 -3
- package/README_CN.md +7 -3
- package/dist/main/chunks/docx-export.js +4 -0
- package/dist/main/chunks/math-export.js +3 -0
- package/dist/main/index.js +2 -1
- package/dist/renderer/assets/{2DXBBFLN-BZbS7Pd1.js → 2DXBBFLN-BJduq_n1.js} +4 -4
- package/dist/renderer/assets/{46IJ22JX-CNFviTsR.js → 46IJ22JX-Dl5oABYC.js} +5 -5
- package/dist/renderer/assets/{4TTDE5I4-C7pizLRz.js → 4TTDE5I4-D0OZH30N.js} +3 -3
- package/dist/renderer/assets/{4UF3HTLV-Bgp6lNzK.js → 4UF3HTLV-B9lH7CBB.js} +4 -4
- package/dist/renderer/assets/{AAXQQPKT-DiRTivQz.js → AAXQQPKT-eq8R1-i0.js} +8 -8
- package/dist/renderer/assets/{AKE5O7KZ-DB0fY69K.js → AKE5O7KZ-BPFFZy5e.js} +5 -5
- package/dist/renderer/assets/{BNMLP6AG-B895CsjY.js → BNMLP6AG-DvupnLHN.js} +7 -7
- package/dist/renderer/assets/{DR6PKOQU-CrswvvVG.js → DR6PKOQU-DXqY3tAL.js} +3 -3
- package/dist/renderer/assets/{E4RJ7UJB-Dgy0Anf4.js → E4RJ7UJB-B3-v1GGn.js} +6 -6
- package/dist/renderer/assets/{ELSXBIJH-Bg-hsqjD.js → ELSXBIJH-W0-fIyGs.js} +1 -1
- package/dist/renderer/assets/{ERTIBQVS-BNxjgPXX.js → ERTIBQVS-Cjo8zCEV.js} +4 -4
- package/dist/renderer/assets/{F653G4FO-Dt3YtuWS.js → F653G4FO-t4kGthl5.js} +8 -8
- package/dist/renderer/assets/{FKCDD66M-CenzCJNz.js → FKCDD66M-CqwX5T9T.js} +1 -1
- package/dist/renderer/assets/{FP7KDXVC-BmH1Qg4f.js → FP7KDXVC-SqJKRKSf.js} +6 -6
- package/dist/renderer/assets/{FT5I3RHX-Dd_6diyz.js → FT5I3RHX-B1_XlJMF.js} +7 -7
- package/dist/renderer/assets/{GY35JXOZ-Cz54qXE9.js → GY35JXOZ-D_hAOI09.js} +4 -4
- package/dist/renderer/assets/{H5EEJPP2-FerEQPg3.js → H5EEJPP2-Dh0ee_t_.js} +9 -9
- package/dist/renderer/assets/{HWDLEDTA-dKG_tB6l.js → HWDLEDTA-BfmnLbys.js} +1 -1
- package/dist/renderer/assets/{JZWSX6AR-DGqy6mhj.js → JZWSX6AR-DibCj0_r.js} +2 -2
- package/dist/renderer/assets/{KQOEJWJY-RpP1RapT.js → KQOEJWJY-CYbDpxpS.js} +1 -1
- package/dist/renderer/assets/{KS3BB3KE-ChYPdbg1.js → KS3BB3KE-BKXN5GEp.js} +5 -5
- package/dist/renderer/assets/{KXJRRZHI-DSLhPV79.js → KXJRRZHI-Dd9nToeE.js} +3 -3
- package/dist/renderer/assets/{MFVI5XKI-C1-R608I.js → MFVI5XKI-yEhNzg_a.js} +1 -1
- package/dist/renderer/assets/{MWY2J62P-CYEJcQI7.js → MWY2J62P-PD0ivp8r.js} +5 -5
- package/dist/renderer/assets/{MXGNCBL2-DEhdb9Po.js → MXGNCBL2-CrYuCAhj.js} +5 -5
- package/dist/renderer/assets/{N6DAJLIZ-Jz5IcMsB.js → N6DAJLIZ-CsI-0Pob.js} +2 -2
- package/dist/renderer/assets/{NU5M23IW-C8k8MpXh.js → NU5M23IW-BRouDTU6.js} +5 -5
- package/dist/renderer/assets/{NV4XNBIS-BCaP1w8q.js → NV4XNBIS-BDKWqPgJ.js} +7 -7
- package/dist/renderer/assets/{OGLU4SIR-OGqdd7qE.js → OGLU4SIR-e03S5CRP.js} +5 -5
- package/dist/renderer/assets/{OUNS5N76-p6wVW2dP.js → OUNS5N76-DXs9fuRM.js} +6 -6
- package/dist/renderer/assets/{PU4ISKXV-D-ZMREMw.js → PU4ISKXV-DHAw3ojo.js} +5 -5
- package/dist/renderer/assets/{PUZGS23X-DsbrgiWg.js → PUZGS23X-BJvqqbjA.js} +1 -1
- package/dist/renderer/assets/{Q3IYVLG5-BpItOJB9.js → Q3IYVLG5-BBP8APVJ.js} +5 -5
- package/dist/renderer/assets/{QYHQDLKZ-Dm9JiJIz.js → QYHQDLKZ-Dk9FA6iI.js} +9 -9
- package/dist/renderer/assets/{RZSVICHU-Chf4nk49.js → RZSVICHU-DQMvf7FW.js} +1 -1
- package/dist/renderer/assets/{UEXXS2NB-Bm2T4HQE.js → UEXXS2NB-pjQFygyK.js} +1 -1
- package/dist/renderer/assets/{UHTQJXKL-Y4ThTfXK.js → UHTQJXKL-BCjkwDC-.js} +5 -5
- package/dist/renderer/assets/{URA2L2QI-DkaJzKIj.js → URA2L2QI-DOqGA-7p.js} +1 -1
- package/dist/renderer/assets/{UXCHDUKG-D6Ae72SJ.js → UXCHDUKG-P-ssqnp6.js} +5 -5
- package/dist/renderer/assets/{VKNV3BUX-CQYQjCVp.js → VKNV3BUX-S-I5Vkej.js} +6 -6
- package/dist/renderer/assets/{VMV7XPHP-CKz3lx9e.js → VMV7XPHP-CBEFwbRj.js} +1 -1
- package/dist/renderer/assets/{WEVWDWVA-DXDXU985.js → WEVWDWVA-NETs7zG0.js} +1 -1
- package/dist/renderer/assets/{XRRJ35LF-C66qdAcN.js → XRRJ35LF-ChlUj7II.js} +4 -4
- package/dist/renderer/assets/{YFKBLVVN-B1JutB4t.js → YFKBLVVN-a23ZlMUZ.js} +4 -4
- package/dist/renderer/assets/{YHRE5QGZ-BoAzNT7K.js → YHRE5QGZ-B4WFiwFa.js} +7 -7
- package/dist/renderer/assets/{ZF3OVT4B-tBhjRApP.js → ZF3OVT4B-D99LRppp.js} +3 -3
- package/dist/renderer/assets/{index-6XszqTLE.js → index-9wJDFDHb.js} +1 -1
- package/dist/renderer/assets/{index-HSHw3F3k.js → index-B-sTajw0.js} +1 -1
- package/dist/renderer/assets/{index-CAuNb95h.js → index-B3xEpmeL.js} +1 -1
- package/dist/renderer/assets/{index-DROMWNcj.js → index-B7a6ecSB.js} +1 -1
- package/dist/renderer/assets/{index-Dg6oPZ5w.js → index-BQRkI4XZ.js} +3 -3
- package/dist/renderer/assets/{index-CxqBaXly.js → index-BUMCX36l.js} +1 -1
- package/dist/renderer/assets/{index-Bz1F6_A_.js → index-BXMm6of_.js} +1 -1
- package/dist/renderer/assets/{index-BHNBF13i.js → index-BgaTyTt4.js} +1 -1
- package/dist/renderer/assets/{index-k6oLH39v.js → index-C5S7E_iS.js} +3 -3
- package/dist/renderer/assets/{index-8VmLWls0.js → index-CBsqa7KF.js} +1 -1
- package/dist/renderer/assets/{index-Coye68JD.js → index-CFd49PzX.js} +1 -1
- package/dist/renderer/assets/{index-DUg0by2F.js → index-CX3eLmnK.js} +1 -1
- package/dist/renderer/assets/{index-CQ2EdLQr.js → index-CizbQ4B2.js} +1 -1
- package/dist/renderer/assets/{index-CZRO_PAZ.js → index-Cl38Mcu3.js} +1 -1
- package/dist/renderer/assets/{index-C1fw6u5V.js → index-CmCG8RWM.js} +1 -1
- package/dist/renderer/assets/{index-KKUqPjEB.js → index-Cr5af8vL.js} +1 -1
- package/dist/renderer/assets/{index-Bk6TVqB_.js → index-DNKeYHeb.js} +1 -1
- package/dist/renderer/assets/{index-Bcx2JMPS.js → index-DShnMzLx.js} +677 -262
- package/dist/renderer/assets/{index-Dl8YooLt.js → index-DurJ4oOc.js} +3 -3
- package/dist/renderer/assets/{index-Dqlv2y9T.js → index-WU2bjQIt.js} +1 -1
- package/dist/renderer/assets/{index-BSrZe3ki.css → index-Xe00ZDVa.css} +32 -14
- package/dist/renderer/assets/{index-UzBrnlvb.js → index-j9IOhwim.js} +1 -1
- package/dist/renderer/assets/{lazy-DVRRTm-q.js → lazy-C5_LqPMG.js} +3 -3
- package/dist/renderer/assets/{web-Ct-G5Yg8.js → web-C4L7HQnE.js} +2 -2
- package/dist/renderer/assets/{web-CAJ9chii.js → web-ClAYTlQS.js} +1 -1
- package/dist/renderer/assets/{web-Y168OUbw.js → web-DJNzGtPV.js} +1 -1
- package/dist/renderer/index.html +2 -2
- package/package.json +3 -1
- package/themes/README.md +30 -0
- package/themes/bear.css +1 -1
- package/themes/contract.json +1 -1
- package/themes/dark.css +9 -1
- package/themes/dracula.css +1 -5
- package/themes/elegant.css +5 -12
- package/themes/gruvbox.css +1 -5
- package/themes/light.css +1 -1
- package/themes/midnight.css +7 -3
- package/themes/nord.css +1 -5
- package/themes/notion.css +9 -11
- package/themes/sepia.css +3 -6
- package/themes/solarized-dark.css +1 -1
- package/themes/writer.css +9 -1
- package/dist/renderer/assets/index-eBhE19Gh.js +0 -110
|
@@ -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-C5_LqPMG.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();
|
|
@@ -33406,7 +33406,14 @@ function pushBlockLines(state, from, to, className, ranges) {
|
|
|
33406
33406
|
ranges.push({ from: lineFrom, to: lineFrom, deco: BLOCK(className) });
|
|
33407
33407
|
}
|
|
33408
33408
|
}
|
|
33409
|
+
const QUOTE_PREFIX_RE$2 = /^(?:[ \t]*> ?)+/;
|
|
33410
|
+
function hasListSpace(state, markTo) {
|
|
33411
|
+
const ch = markTo < state.doc.length ? state.doc.sliceString(markTo, markTo + 1) : "";
|
|
33412
|
+
return ch === " " || ch === " ";
|
|
33413
|
+
}
|
|
33409
33414
|
function pushListItemLines(state, node, ranges) {
|
|
33415
|
+
const selfMark = node.getChild("ListMark");
|
|
33416
|
+
if (!selfMark || !hasListSpace(state, selfMark.to)) return;
|
|
33410
33417
|
const className = `cm-md-li cm-md-li-${Math.min(listDepth$1(node), 6)}`;
|
|
33411
33418
|
const tree = syntaxTree(state);
|
|
33412
33419
|
const path2 = [];
|
|
@@ -33433,12 +33440,19 @@ function pushListItemLines(state, node, ranges) {
|
|
|
33433
33440
|
const last2 = node.nextSibling?.name === "ListItem" ? state.doc.lineAt(node.nextSibling.from).number - 1 : ownLast;
|
|
33434
33441
|
for (let n = first; n <= last2; n++) {
|
|
33435
33442
|
const line = state.doc.line(n);
|
|
33443
|
+
if (n > first && n <= ownLast && line.to <= ownEnd) {
|
|
33444
|
+
const body = line.text.replace(QUOTE_PREFIX_RE$2, "");
|
|
33445
|
+
if (body.trim() !== "" && !/^[ \t]/.test(body)) break;
|
|
33446
|
+
}
|
|
33436
33447
|
if (n <= ownLast && line.to > ownEnd) {
|
|
33437
|
-
const
|
|
33438
|
-
const
|
|
33448
|
+
const quoteLen = QUOTE_PREFIX_RE$2.exec(line.text)?.[0].length ?? 0;
|
|
33449
|
+
const indent = /^[ \t]*/.exec(line.text.slice(quoteLen))?.[0].length ?? 0;
|
|
33450
|
+
const at = Math.min(line.from + quoteLen + indent, line.to);
|
|
33439
33451
|
let owner = tree.resolveInner(at, 1);
|
|
33440
33452
|
while (owner && owner.name !== "ListItem") owner = owner.parent;
|
|
33441
33453
|
if (!owner || owner.from !== node.from) continue;
|
|
33454
|
+
const body = line.text.slice(quoteLen);
|
|
33455
|
+
if (body.trim() !== "" && !/^[ \t]/.test(body)) break;
|
|
33442
33456
|
}
|
|
33443
33457
|
const paragraph = paragraphs.find((block) => block.from <= line.to && block.to > line.from);
|
|
33444
33458
|
ranges.push({ from: line.from, to: line.from, deco: Decoration.line({ class: className, attributes: {
|
|
@@ -33478,6 +33492,25 @@ let documentFileUrl = null;
|
|
|
33478
33492
|
function primeDocumentFileUrl(url) {
|
|
33479
33493
|
documentFileUrl = url;
|
|
33480
33494
|
}
|
|
33495
|
+
let measureHost = null;
|
|
33496
|
+
function setMeasureHost(view) {
|
|
33497
|
+
measureHost = view;
|
|
33498
|
+
}
|
|
33499
|
+
function remeasureAfterDraw() {
|
|
33500
|
+
if (!measureHost) return;
|
|
33501
|
+
const view = measureHost;
|
|
33502
|
+
try {
|
|
33503
|
+
const dom = view.contentDOM;
|
|
33504
|
+
dom.style.minHeight = "0";
|
|
33505
|
+
view.requestMeasure({
|
|
33506
|
+
read: () => null,
|
|
33507
|
+
write: () => {
|
|
33508
|
+
dom.style.minHeight = "";
|
|
33509
|
+
}
|
|
33510
|
+
});
|
|
33511
|
+
} catch {
|
|
33512
|
+
}
|
|
33513
|
+
}
|
|
33481
33514
|
const setDocumentFileUrlEffect = StateEffect.define();
|
|
33482
33515
|
const documentFileUrlField = StateField.define({
|
|
33483
33516
|
create: () => documentFileUrl,
|
|
@@ -33530,9 +33563,13 @@ class ImageWidget extends WidgetType {
|
|
|
33530
33563
|
const img = document.createElement("img");
|
|
33531
33564
|
img.src = this.src;
|
|
33532
33565
|
img.alt = this.alt;
|
|
33566
|
+
img.addEventListener("load", () => {
|
|
33567
|
+
remeasureAfterDraw();
|
|
33568
|
+
});
|
|
33533
33569
|
img.addEventListener("error", () => {
|
|
33534
33570
|
wrap.classList.add("cm-md-image-failed");
|
|
33535
33571
|
wrap.textContent = this.source;
|
|
33572
|
+
remeasureAfterDraw();
|
|
33536
33573
|
});
|
|
33537
33574
|
wrap.appendChild(img);
|
|
33538
33575
|
return wrap;
|
|
@@ -33561,6 +33598,22 @@ function isBlockActive(state, from, to) {
|
|
|
33561
33598
|
const sel = state.selection.main;
|
|
33562
33599
|
return sel.from >= from && sel.to <= to;
|
|
33563
33600
|
}
|
|
33601
|
+
function mathElement(code, block) {
|
|
33602
|
+
const el = document.createElement(block ? "div" : "span");
|
|
33603
|
+
el.className = block ? "cm-md-math cm-md-math-block" : "cm-md-math cm-md-math-inline";
|
|
33604
|
+
try {
|
|
33605
|
+
el.innerHTML = katex.renderToString(code, {
|
|
33606
|
+
displayMode: block,
|
|
33607
|
+
throwOnError: true,
|
|
33608
|
+
// 公式里可能带用户写的 HTML,KaTeX 的 trust 默认关闭,保持关闭
|
|
33609
|
+
trust: false
|
|
33610
|
+
});
|
|
33611
|
+
} catch {
|
|
33612
|
+
el.textContent = (block ? "$$" : "$") + code + (block ? "$$" : "$");
|
|
33613
|
+
el.classList.add("cm-md-math-error");
|
|
33614
|
+
}
|
|
33615
|
+
return el;
|
|
33616
|
+
}
|
|
33564
33617
|
class MathWidget extends WidgetType {
|
|
33565
33618
|
constructor(code, block, from, to) {
|
|
33566
33619
|
super();
|
|
@@ -33573,21 +33626,7 @@ class MathWidget extends WidgetType {
|
|
|
33573
33626
|
return other.code === this.code && other.block === this.block && other.from === this.from && other.to === this.to;
|
|
33574
33627
|
}
|
|
33575
33628
|
toDOM() {
|
|
33576
|
-
|
|
33577
|
-
span.className = this.block ? "cm-md-math cm-md-math-block" : "cm-md-math cm-md-math-inline";
|
|
33578
|
-
withSourceRange(span, this.from, this.to);
|
|
33579
|
-
try {
|
|
33580
|
-
span.innerHTML = katex.renderToString(this.code, {
|
|
33581
|
-
displayMode: this.block,
|
|
33582
|
-
throwOnError: true,
|
|
33583
|
-
// 公式里可能带用户写的 HTML,KaTeX 的 trust 默认关闭,保持关闭
|
|
33584
|
-
trust: false
|
|
33585
|
-
});
|
|
33586
|
-
} catch {
|
|
33587
|
-
span.textContent = (this.block ? "$$" : "$") + this.code + (this.block ? "$$" : "$");
|
|
33588
|
-
span.classList.add("cm-md-math-error");
|
|
33589
|
-
}
|
|
33590
|
-
return span;
|
|
33629
|
+
return withSourceRange(mathElement(this.code, this.block), this.from, this.to);
|
|
33591
33630
|
}
|
|
33592
33631
|
}
|
|
33593
33632
|
class ListBulletWidget extends WidgetType {
|
|
@@ -33607,10 +33646,9 @@ function listDepth$1(node) {
|
|
|
33607
33646
|
}
|
|
33608
33647
|
return depth;
|
|
33609
33648
|
}
|
|
33610
|
-
function collectMath(state, ranges) {
|
|
33611
|
-
const text2 = state.doc.toString();
|
|
33612
|
-
const excluded = excludedRanges(text2, syntaxTree(state));
|
|
33649
|
+
function collectMath(state, text2, excluded, ranges, zones) {
|
|
33613
33650
|
for (const range of scanMath(text2, excluded)) {
|
|
33651
|
+
if (range.block) zones.push({ from: range.from, to: range.to, kind: "block" });
|
|
33614
33652
|
if (isActiveLine(state, range.from) || range.block && isBlockActive(state, range.from, range.to)) {
|
|
33615
33653
|
const delim = range.block ? 2 : 1;
|
|
33616
33654
|
ranges.push({ from: range.from, to: range.from + delim, deco: MARK({ class: "cm-md-marker" }) });
|
|
@@ -33620,13 +33658,18 @@ function collectMath(state, ranges) {
|
|
|
33620
33658
|
ranges.push({
|
|
33621
33659
|
from: range.from,
|
|
33622
33660
|
to: range.to,
|
|
33623
|
-
|
|
33661
|
+
// 跨行 replace 必须是 block 装饰(CM6 约束):inline 跨行 replace 只有初次
|
|
33662
|
+
// 构建能画出来,增量更新(源码退出 → 重新渲染)时 widget 永远不会被重建,
|
|
33663
|
+
// 块级公式表现为「点进去改完再点走,公式整块消失」。只对整行覆盖的范围加。
|
|
33664
|
+
deco: Decoration.replace({
|
|
33665
|
+
widget: new MathWidget(range.code, range.block, range.from, range.to),
|
|
33666
|
+
block: range.block && state.doc.lineAt(range.from).from === range.from && state.doc.lineAt(Math.min(range.to, state.doc.length)).to === range.to
|
|
33667
|
+
})
|
|
33624
33668
|
});
|
|
33625
33669
|
}
|
|
33626
33670
|
}
|
|
33627
33671
|
const HIGHLIGHT_RE = /(?<![=])==(?!=)([^=\n]+?)==(?!=)/g;
|
|
33628
|
-
function collectHighlight(state, ranges, excluded) {
|
|
33629
|
-
const text2 = state.doc.toString();
|
|
33672
|
+
function collectHighlight(state, text2, ranges, excluded) {
|
|
33630
33673
|
const inExcluded = (pos) => excluded.some((e) => pos >= e.from && pos < e.to);
|
|
33631
33674
|
HIGHLIGHT_RE.lastIndex = 0;
|
|
33632
33675
|
let match;
|
|
@@ -33687,9 +33730,11 @@ class MermaidWidget extends WidgetType {
|
|
|
33687
33730
|
wrap.innerHTML = svg;
|
|
33688
33731
|
wrap.classList.add("cm-md-mermaid-ready");
|
|
33689
33732
|
attachDiagramZoom(wrap);
|
|
33733
|
+
remeasureAfterDraw();
|
|
33690
33734
|
}).catch(() => {
|
|
33691
33735
|
wrap.textContent = "```mermaid\n" + this.code + "\n```";
|
|
33692
33736
|
wrap.classList.add("cm-md-mermaid-failed");
|
|
33737
|
+
remeasureAfterDraw();
|
|
33693
33738
|
});
|
|
33694
33739
|
return wrap;
|
|
33695
33740
|
}
|
|
@@ -33715,28 +33760,34 @@ const POINTER_EVENTS = /* @__PURE__ */ new Set([
|
|
|
33715
33760
|
"touchstart",
|
|
33716
33761
|
"touchend"
|
|
33717
33762
|
]);
|
|
33718
|
-
function collectMermaid(state, ranges, front) {
|
|
33719
|
-
const text2 = state.doc.toString();
|
|
33763
|
+
function collectMermaid(state, text2, ranges, front, zones) {
|
|
33720
33764
|
iterateContent(state, front, (node) => {
|
|
33721
33765
|
if (node.name !== "FencedCode") return;
|
|
33722
33766
|
const firstLineEnd = text2.indexOf("\n", node.from);
|
|
33723
33767
|
if (firstLineEnd === -1) return;
|
|
33724
33768
|
const opening = text2.slice(node.from, firstLineEnd).trim();
|
|
33725
33769
|
if (!/^(`{3,}|~{3,})\s*mermaid\s*$/.test(opening)) return;
|
|
33726
|
-
if (isBlockActive(state, node.from, node.to)) return;
|
|
33727
33770
|
const bodyStart2 = firstLineEnd + 1;
|
|
33728
33771
|
const lastLineStart = text2.lastIndexOf("\n", node.to - 1);
|
|
33729
33772
|
const code = text2.slice(bodyStart2, lastLineStart === -1 ? node.to : lastLineStart);
|
|
33730
33773
|
if (!code.trim()) return;
|
|
33774
|
+
zones.push({ from: node.from, to: node.to, kind: "block" });
|
|
33775
|
+
if (isBlockActive(state, node.from, node.to)) return;
|
|
33731
33776
|
ranges.push({
|
|
33732
33777
|
from: node.from,
|
|
33733
33778
|
to: node.to,
|
|
33734
|
-
|
|
33779
|
+
// fence 恒为整行 → 恒为 block 装饰:跨行 inline replace 在增量更新时
|
|
33780
|
+
// widget 不会被重建,「点图进源码、点走再渲染」的图会整块消失(见 collectMath)。
|
|
33781
|
+
deco: Decoration.replace({
|
|
33782
|
+
widget: new MermaidWidget(code, `${node.from}:${code.length}`, node.from, node.to),
|
|
33783
|
+
block: true
|
|
33784
|
+
})
|
|
33735
33785
|
});
|
|
33736
33786
|
});
|
|
33737
33787
|
}
|
|
33738
|
-
function collectFrontmatter(state, ranges, front) {
|
|
33788
|
+
function collectFrontmatter(state, ranges, front, zones) {
|
|
33739
33789
|
if (!front) return;
|
|
33790
|
+
zones.push({ from: front.from, to: front.to, kind: "frontmatter" });
|
|
33740
33791
|
const editing = state.selection.ranges.some(
|
|
33741
33792
|
(range) => range.empty && range.head >= front.from && range.head <= front.to
|
|
33742
33793
|
);
|
|
@@ -33825,21 +33876,49 @@ function alignOf(delimiter) {
|
|
|
33825
33876
|
if (right) return "right";
|
|
33826
33877
|
return "left";
|
|
33827
33878
|
}
|
|
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*\/?>/
|
|
33879
|
+
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;
|
|
33880
|
+
function codeSpanRanges(text2) {
|
|
33881
|
+
const out = [];
|
|
33882
|
+
const re = /`[^`]+`/g;
|
|
33883
|
+
let match;
|
|
33884
|
+
while ((match = re.exec(text2)) !== null) out.push({ from: match.index, to: match.index + match[0].length });
|
|
33885
|
+
return out;
|
|
33886
|
+
}
|
|
33887
|
+
function appendCellText(parent, text2, math2, from, to) {
|
|
33888
|
+
let cursor = from;
|
|
33889
|
+
for (const range of math2) {
|
|
33890
|
+
if (range.from < cursor || range.to > to) continue;
|
|
33891
|
+
if (range.from > cursor) parent.appendChild(document.createTextNode(text2.slice(cursor, range.from)));
|
|
33892
|
+
parent.appendChild(mathElement(range.code, false));
|
|
33893
|
+
cursor = range.to;
|
|
33894
|
+
}
|
|
33895
|
+
if (cursor < to) parent.appendChild(document.createTextNode(text2.slice(cursor, to)));
|
|
33896
|
+
}
|
|
33829
33897
|
function appendInline(parent, text2, base2) {
|
|
33898
|
+
const math2 = scanMath(text2, codeSpanRanges(text2));
|
|
33899
|
+
const write = (target, from, to) => appendCellText(target, text2, math2, from, to);
|
|
33830
33900
|
INLINE_RE.lastIndex = 0;
|
|
33831
33901
|
let last2 = 0;
|
|
33832
33902
|
let match;
|
|
33833
33903
|
while ((match = INLINE_RE.exec(text2)) !== null) {
|
|
33834
|
-
|
|
33904
|
+
const index2 = match.index;
|
|
33905
|
+
const inside = math2.find((range) => range.from <= index2 && index2 < range.to);
|
|
33906
|
+
if (inside) {
|
|
33907
|
+
INLINE_RE.lastIndex = inside.to;
|
|
33908
|
+
continue;
|
|
33909
|
+
}
|
|
33910
|
+
if (match.index > last2) write(parent, last2, match.index);
|
|
33835
33911
|
const g = match.groups ?? {};
|
|
33912
|
+
const at = match.indices?.groups ?? {};
|
|
33836
33913
|
if (g.strong !== void 0 || g.strongU !== void 0) {
|
|
33837
33914
|
const el = document.createElement("strong");
|
|
33838
|
-
|
|
33915
|
+
const [from, to] = at.strong ?? at.strongU ?? [0, 0];
|
|
33916
|
+
write(el, from, to);
|
|
33839
33917
|
parent.appendChild(el);
|
|
33840
33918
|
} else if (g.em !== void 0 || g.emU !== void 0) {
|
|
33841
33919
|
const el = document.createElement("em");
|
|
33842
|
-
|
|
33920
|
+
const [from, to] = at.em ?? at.emU ?? [0, 0];
|
|
33921
|
+
write(el, from, to);
|
|
33843
33922
|
parent.appendChild(el);
|
|
33844
33923
|
} else if (g.code !== void 0) {
|
|
33845
33924
|
const el = document.createElement("code");
|
|
@@ -33847,7 +33926,8 @@ function appendInline(parent, text2, base2) {
|
|
|
33847
33926
|
parent.appendChild(el);
|
|
33848
33927
|
} else if (g.strike !== void 0) {
|
|
33849
33928
|
const el = document.createElement("s");
|
|
33850
|
-
|
|
33929
|
+
const [from, to] = at.strike ?? [0, 0];
|
|
33930
|
+
write(el, from, to);
|
|
33851
33931
|
parent.appendChild(el);
|
|
33852
33932
|
} else if (g.alt !== void 0) {
|
|
33853
33933
|
const img = document.createElement("img");
|
|
@@ -33856,7 +33936,9 @@ function appendInline(parent, text2, base2) {
|
|
|
33856
33936
|
parent.appendChild(img);
|
|
33857
33937
|
} else if (g.linkText !== void 0) {
|
|
33858
33938
|
const el = document.createElement("a");
|
|
33859
|
-
|
|
33939
|
+
const [from, to] = at.linkText ?? [0, 0];
|
|
33940
|
+
if (to > from) write(el, from, to);
|
|
33941
|
+
else el.textContent = g.href ?? "";
|
|
33860
33942
|
const href = (g.href ?? "").trim();
|
|
33861
33943
|
if (/^https?:\/\//i.test(href)) el.setAttribute("href", href);
|
|
33862
33944
|
parent.appendChild(el);
|
|
@@ -33865,11 +33947,12 @@ function appendInline(parent, text2, base2) {
|
|
|
33865
33947
|
}
|
|
33866
33948
|
last2 = match.index + match[0].length;
|
|
33867
33949
|
}
|
|
33868
|
-
if (last2 < text2.length) parent
|
|
33950
|
+
if (last2 < text2.length) write(parent, last2, text2.length);
|
|
33869
33951
|
}
|
|
33870
|
-
function collectTables(state, ranges, front) {
|
|
33952
|
+
function collectTables(state, ranges, front, zones) {
|
|
33871
33953
|
iterateContent(state, front, (node) => {
|
|
33872
33954
|
if (node.name !== "Table") return;
|
|
33955
|
+
zones.push({ from: node.from, to: node.to, kind: "block" });
|
|
33873
33956
|
if (isBlockActive(state, node.from, node.to)) {
|
|
33874
33957
|
pushBlockLines(state, node.from, node.to, "cm-md-table", ranges);
|
|
33875
33958
|
return false;
|
|
@@ -33928,8 +34011,7 @@ class FootnoteRefWidget extends WidgetType {
|
|
|
33928
34011
|
return sup2;
|
|
33929
34012
|
}
|
|
33930
34013
|
}
|
|
33931
|
-
function collectFootnotes(state, ranges, front) {
|
|
33932
|
-
const text2 = state.doc.toString();
|
|
34014
|
+
function collectFootnotes(state, text2, ranges, front) {
|
|
33933
34015
|
const numbers = footnoteNumbers(text2);
|
|
33934
34016
|
const definitions = footnoteDefinitions(text2);
|
|
33935
34017
|
FOOTNOTE_REF_RE.lastIndex = 0;
|
|
@@ -33971,11 +34053,12 @@ class HTMLWidget extends WidgetType {
|
|
|
33971
34053
|
return wrap;
|
|
33972
34054
|
}
|
|
33973
34055
|
}
|
|
33974
|
-
function collectHTML(state, ranges, front) {
|
|
34056
|
+
function collectHTML(state, ranges, front, zones) {
|
|
33975
34057
|
const paired = /* @__PURE__ */ new Set();
|
|
33976
34058
|
iterateContent(state, front, (node) => {
|
|
33977
34059
|
const block = node.name === "HTMLBlock";
|
|
33978
34060
|
if (!block && node.name !== "HTMLTag") return;
|
|
34061
|
+
if (block) zones.push({ from: node.from, to: node.to, kind: "block" });
|
|
33979
34062
|
if (block ? isBlockActive(state, node.from, node.to) : isActiveLine(state, node.from)) return false;
|
|
33980
34063
|
if (!block) {
|
|
33981
34064
|
if (paired.has(node.from)) return false;
|
|
@@ -34072,6 +34155,11 @@ function collectBlocks(state, ranges, front) {
|
|
|
34072
34155
|
break;
|
|
34073
34156
|
}
|
|
34074
34157
|
case "ListMark": {
|
|
34158
|
+
if (!hasListSpace(state, node.to)) break;
|
|
34159
|
+
const line = state.doc.lineAt(node.from);
|
|
34160
|
+
const quoteLen = QUOTE_PREFIX_RE$2.exec(state.doc.sliceString(line.from, node.from))?.[0].length ?? 0;
|
|
34161
|
+
const hideFrom = line.from + quoteLen;
|
|
34162
|
+
if (node.from > hideFrom) ranges.push({ from: hideFrom, to: node.from, deco: hide(hideFrom, node.from) });
|
|
34075
34163
|
const raw = state.doc.sliceString(node.from, node.to).trim();
|
|
34076
34164
|
const after = state.doc.sliceString(node.to, node.to + 4);
|
|
34077
34165
|
if (/^\s+\[[ xX]\]/.test(after)) {
|
|
@@ -34118,8 +34206,10 @@ function collectBlocks(state, ranges, front) {
|
|
|
34118
34206
|
break;
|
|
34119
34207
|
}
|
|
34120
34208
|
case "QuoteMark": {
|
|
34121
|
-
|
|
34122
|
-
|
|
34209
|
+
const rest = state.doc.sliceString(node.to, state.doc.lineAt(node.to).to);
|
|
34210
|
+
if (rest.trim() === "" || isActiveLine(state, node.from)) {
|
|
34211
|
+
ranges.push({ from: node.from, to: node.to, deco: MARK({ class: "cm-md-quotemark" }) });
|
|
34212
|
+
} else {
|
|
34123
34213
|
hideMarker(state, node.from, node.to, ranges);
|
|
34124
34214
|
}
|
|
34125
34215
|
break;
|
|
@@ -34127,6 +34217,7 @@ function collectBlocks(state, ranges, front) {
|
|
|
34127
34217
|
}
|
|
34128
34218
|
});
|
|
34129
34219
|
}
|
|
34220
|
+
const URL_STOP = /[\u2E80-\u30FF\u3400-\u4DBF\u4E00-\u9FFF\uF900-\uFAFF\u3000-\u303F\uFF00-\uFFEF]/;
|
|
34130
34221
|
function collectInline(state, ranges, front) {
|
|
34131
34222
|
iterateContent(state, front, (node) => {
|
|
34132
34223
|
const from = node.from;
|
|
@@ -34139,6 +34230,8 @@ function collectInline(state, ranges, front) {
|
|
|
34139
34230
|
case "ATXHeading4":
|
|
34140
34231
|
case "ATXHeading5":
|
|
34141
34232
|
case "ATXHeading6": {
|
|
34233
|
+
const head = state.doc.sliceString(from, state.doc.lineAt(from).to);
|
|
34234
|
+
if (!/^#{1,6}[ \t]/.test(head)) return false;
|
|
34142
34235
|
pushBlockLines(state, from, to, `cm-md-${node.name.toLowerCase()}`, ranges);
|
|
34143
34236
|
break;
|
|
34144
34237
|
}
|
|
@@ -34175,7 +34268,10 @@ function collectInline(state, ranges, front) {
|
|
|
34175
34268
|
break;
|
|
34176
34269
|
}
|
|
34177
34270
|
case "URL": {
|
|
34178
|
-
|
|
34271
|
+
const raw = state.doc.sliceString(from, to);
|
|
34272
|
+
const stop = raw.search(URL_STOP);
|
|
34273
|
+
const end = stop < 0 ? to : from + stop;
|
|
34274
|
+
if (end > from) ranges.push({ from, to: end, deco: MARK({ class: "cm-md-url" }) });
|
|
34179
34275
|
break;
|
|
34180
34276
|
}
|
|
34181
34277
|
}
|
|
@@ -34207,8 +34303,25 @@ function collectPages(state, ranges, front) {
|
|
|
34207
34303
|
}
|
|
34208
34304
|
const headingFlashEffect = StateEffect.define();
|
|
34209
34305
|
let currentFlash = null;
|
|
34306
|
+
const zonesByDeco = /* @__PURE__ */ new WeakMap();
|
|
34307
|
+
function activeZonesKey(state, zones) {
|
|
34308
|
+
if (zones.length === 0) return "";
|
|
34309
|
+
const main2 = state.selection.main;
|
|
34310
|
+
const parts = [];
|
|
34311
|
+
for (let i = 0; i < zones.length; i++) {
|
|
34312
|
+
const z = zones[i];
|
|
34313
|
+
if (z.kind === "frontmatter") {
|
|
34314
|
+
const hit = state.selection.ranges.some((r) => r.empty && r.head >= z.from && r.head <= z.to);
|
|
34315
|
+
if (hit) parts.push(`f:${z.from}:${z.to}`);
|
|
34316
|
+
} else if (main2.from >= z.from && main2.to <= z.to) {
|
|
34317
|
+
parts.push(`b:${z.from}:${z.to}`);
|
|
34318
|
+
}
|
|
34319
|
+
}
|
|
34320
|
+
return parts.join("|");
|
|
34321
|
+
}
|
|
34210
34322
|
function buildDecorations(state, flash) {
|
|
34211
34323
|
const ranges = [];
|
|
34324
|
+
const zones = [];
|
|
34212
34325
|
const text2 = state.doc.toString();
|
|
34213
34326
|
const excluded = excludedRanges(text2, syntaxTree(state));
|
|
34214
34327
|
const front = frontmatterRange(text2);
|
|
@@ -34217,21 +34330,23 @@ function buildDecorations(state, flash) {
|
|
|
34217
34330
|
}
|
|
34218
34331
|
collectBlocks(state, ranges, front);
|
|
34219
34332
|
collectLinks(state, ranges, front);
|
|
34220
|
-
collectFootnotes(state, ranges, front);
|
|
34221
|
-
collectHTML(state, ranges, front);
|
|
34333
|
+
collectFootnotes(state, text2, ranges, front);
|
|
34334
|
+
collectHTML(state, ranges, front, zones);
|
|
34222
34335
|
collectImages(state, ranges, front);
|
|
34223
34336
|
collectPages(state, ranges, front);
|
|
34224
34337
|
collectInline(state, ranges, front);
|
|
34225
|
-
collectFrontmatter(state, ranges, front);
|
|
34226
|
-
collectTables(state, ranges, front);
|
|
34338
|
+
collectFrontmatter(state, ranges, front, zones);
|
|
34339
|
+
collectTables(state, ranges, front, zones);
|
|
34227
34340
|
collectTaskItems(state, ranges, front);
|
|
34228
|
-
collectMermaid(state, ranges, front);
|
|
34229
|
-
collectHighlight(state, ranges, excluded);
|
|
34230
|
-
collectMath(state, ranges);
|
|
34341
|
+
collectMermaid(state, text2, ranges, front, zones);
|
|
34342
|
+
collectHighlight(state, text2, ranges, excluded);
|
|
34343
|
+
collectMath(state, text2, excluded, ranges, zones);
|
|
34231
34344
|
ranges.sort((a, b) => a.from - b.from || a.deco.startSide - b.deco.startSide || a.to - b.to);
|
|
34232
34345
|
const builder = new RangeSetBuilder();
|
|
34233
34346
|
for (const r of ranges) builder.add(r.from, r.to, r.deco);
|
|
34234
|
-
|
|
34347
|
+
const deco = builder.finish();
|
|
34348
|
+
zonesByDeco.set(deco, zones);
|
|
34349
|
+
return deco;
|
|
34235
34350
|
}
|
|
34236
34351
|
const livePreviewField = StateField.define({
|
|
34237
34352
|
create: (state) => buildDecorations(state, null),
|
|
@@ -34241,11 +34356,15 @@ const livePreviewField = StateField.define({
|
|
|
34241
34356
|
if (flash) currentFlash = flashValue;
|
|
34242
34357
|
const parsed = tr.effects.some((effect) => effect.is(decorationsRefreshEffect));
|
|
34243
34358
|
const rebased = tr.effects.some((effect) => effect.is(setDocumentFileUrlEffect));
|
|
34244
|
-
const focused = tr.state.field(editorFocusField, false) ?? false;
|
|
34245
|
-
const wasFocused = tr.startState.field(editorFocusField, false) ?? false;
|
|
34246
34359
|
const clean = tr.state.field(cleanExportField, false) ?? false;
|
|
34247
34360
|
const wasClean = tr.startState.field(cleanExportField, false) ?? false;
|
|
34248
|
-
if (!tr.docChanged && !
|
|
34361
|
+
if (!tr.docChanged && !flash && !parsed && !rebased && clean === wasClean) {
|
|
34362
|
+
if (!tr.selection) return deco;
|
|
34363
|
+
const zones = zonesByDeco.get(deco) ?? [];
|
|
34364
|
+
if (activeZonesKey(tr.state, zones) === activeZonesKey(tr.startState, zones)) {
|
|
34365
|
+
return deco;
|
|
34366
|
+
}
|
|
34367
|
+
}
|
|
34249
34368
|
return buildDecorations(tr.state, flashValue);
|
|
34250
34369
|
},
|
|
34251
34370
|
provide: (field) => EditorView.decorations.from(field)
|
|
@@ -34269,17 +34388,21 @@ const parseRefresh = ViewPlugin.fromClass(class {
|
|
|
34269
34388
|
}
|
|
34270
34389
|
this.later(update.view, viewportEnd);
|
|
34271
34390
|
}
|
|
34272
|
-
later(view, parseTo) {
|
|
34391
|
+
later(view, parseTo, delay = 0) {
|
|
34273
34392
|
if (this.pending) return;
|
|
34274
34393
|
this.pending = true;
|
|
34275
34394
|
setTimeout(() => {
|
|
34276
34395
|
this.pending = false;
|
|
34277
34396
|
if (!view.dom.isConnected) return;
|
|
34397
|
+
if (view.composing) {
|
|
34398
|
+
this.later(view, parseTo, 120);
|
|
34399
|
+
return;
|
|
34400
|
+
}
|
|
34278
34401
|
if (parseTo !== null) forceParsing(view, parseTo);
|
|
34279
34402
|
view.dispatch({ effects: decorationsRefreshEffect.of(null) });
|
|
34280
34403
|
if (syntaxTree(view.state).length < view.viewport.to && this.attempts < 40) {
|
|
34281
34404
|
this.attempts += 1;
|
|
34282
|
-
this.later(view, view.viewport.to);
|
|
34405
|
+
this.later(view, view.viewport.to, delay);
|
|
34283
34406
|
}
|
|
34284
34407
|
}, 0);
|
|
34285
34408
|
}
|
|
@@ -34291,121 +34414,6 @@ const livePreview = [
|
|
|
34291
34414
|
livePreviewField,
|
|
34292
34415
|
parseRefresh
|
|
34293
34416
|
];
|
|
34294
|
-
const LIST_RE = /^([ \t]*)(?:([-*+])|(\d+)([.)]))([ \t]+)(\[[ xX]\][ \t]+)?/;
|
|
34295
|
-
function continueList(view) {
|
|
34296
|
-
const { state } = view;
|
|
34297
|
-
const range = state.selection.main;
|
|
34298
|
-
if (!range.empty) return false;
|
|
34299
|
-
const line = state.doc.lineAt(range.head);
|
|
34300
|
-
if (range.head !== line.to) return false;
|
|
34301
|
-
const match = LIST_RE.exec(line.text);
|
|
34302
|
-
if (!match) return false;
|
|
34303
|
-
const [, indent, bullet, number2, delimiter, spacing2, task] = match;
|
|
34304
|
-
const content2 = line.text.slice(match[0].length);
|
|
34305
|
-
if (content2.trim() === "") {
|
|
34306
|
-
view.dispatch({
|
|
34307
|
-
changes: { from: line.from, to: line.to, insert: "" },
|
|
34308
|
-
selection: { anchor: line.from },
|
|
34309
|
-
scrollIntoView: true,
|
|
34310
|
-
userEvent: "input"
|
|
34311
|
-
});
|
|
34312
|
-
return true;
|
|
34313
|
-
}
|
|
34314
|
-
const marker = bullet ?? `${Number(number2) + 1}${delimiter}`;
|
|
34315
|
-
const insert2 = `
|
|
34316
|
-
${indent}${marker}${spacing2}${task ? "[ ] " : ""}`;
|
|
34317
|
-
view.dispatch({
|
|
34318
|
-
changes: { from: range.head, insert: insert2 },
|
|
34319
|
-
selection: { anchor: range.head + insert2.length },
|
|
34320
|
-
scrollIntoView: true,
|
|
34321
|
-
userEvent: "input"
|
|
34322
|
-
});
|
|
34323
|
-
return true;
|
|
34324
|
-
}
|
|
34325
|
-
const INDENT = " ";
|
|
34326
|
-
function indentListItem(view, direction) {
|
|
34327
|
-
const { state } = view;
|
|
34328
|
-
const range = state.selection.main;
|
|
34329
|
-
if (!range.empty) return false;
|
|
34330
|
-
const line = state.doc.lineAt(range.head);
|
|
34331
|
-
const self2 = listLine(line.text);
|
|
34332
|
-
if (!self2) return false;
|
|
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) };
|
|
34338
|
-
view.dispatch({
|
|
34339
|
-
changes: change,
|
|
34340
|
-
selection: { anchor: range.head + (lead2 - self2.lead) },
|
|
34341
|
-
scrollIntoView: true,
|
|
34342
|
-
userEvent: "input"
|
|
34343
|
-
});
|
|
34344
|
-
return true;
|
|
34345
|
-
}
|
|
34346
|
-
const parent = parentItem(state, line, self2.lead - 1);
|
|
34347
|
-
const lead = parent ? parent.lead : 0;
|
|
34348
|
-
if (lead >= self2.lead) return false;
|
|
34349
|
-
view.dispatch({
|
|
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)) },
|
|
34352
|
-
scrollIntoView: true,
|
|
34353
|
-
userEvent: "input"
|
|
34354
|
-
});
|
|
34355
|
-
return true;
|
|
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
|
-
}
|
|
34393
|
-
const listInput = Prec.high(keymap.of([
|
|
34394
|
-
{ key: "Enter", run: continueList },
|
|
34395
|
-
{ key: "Tab", run: (view) => indentListItem(view, 1) },
|
|
34396
|
-
{ key: "Shift-Tab", run: (view) => indentListItem(view, -1) }
|
|
34397
|
-
]));
|
|
34398
|
-
const setSearchHighlight = StateEffect.define();
|
|
34399
|
-
const searchHighlightField = StateField.define({
|
|
34400
|
-
create: () => Decoration.none,
|
|
34401
|
-
update(value, tr) {
|
|
34402
|
-
for (const effect of tr.effects) {
|
|
34403
|
-
if (effect.is(setSearchHighlight)) return effect.value;
|
|
34404
|
-
}
|
|
34405
|
-
return value.map(tr.changes);
|
|
34406
|
-
},
|
|
34407
|
-
provide: (field) => EditorView.decorations.from(field)
|
|
34408
|
-
});
|
|
34409
34417
|
class CompletionContext {
|
|
34410
34418
|
/**
|
|
34411
34419
|
Create a new completion context. (Mostly useful for testing
|
|
@@ -41827,11 +41835,234 @@ const index$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePrope
|
|
|
41827
41835
|
markdownLanguage,
|
|
41828
41836
|
pasteURLAsLink
|
|
41829
41837
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
41838
|
+
const QUOTE_PREFIX_RE$1 = /^(?:[ \t]*> ?)+/;
|
|
41839
|
+
const LIST_BODY_RE = /^([ \t]*)(?:([-*+])|(\d+)([.)]))([ \t]+)(\[[ xX]\][ \t]+)?/;
|
|
41840
|
+
const INDENT = " ";
|
|
41841
|
+
function countQuotes(prefix) {
|
|
41842
|
+
let count2 = 0;
|
|
41843
|
+
for (let i = 0; i < prefix.length; i++) {
|
|
41844
|
+
if (prefix[i] === ">") count2++;
|
|
41845
|
+
}
|
|
41846
|
+
return count2;
|
|
41847
|
+
}
|
|
41848
|
+
function parseListLine(text2) {
|
|
41849
|
+
const quotePrefix = QUOTE_PREFIX_RE$1.exec(text2)?.[0] ?? "";
|
|
41850
|
+
const quoteLen = quotePrefix.length;
|
|
41851
|
+
const match = LIST_BODY_RE.exec(text2.slice(quoteLen));
|
|
41852
|
+
if (!match) return null;
|
|
41853
|
+
const lead = match[1].length;
|
|
41854
|
+
const box = match[6] ?? "";
|
|
41855
|
+
const width = match[0].length - lead - box.length;
|
|
41856
|
+
return {
|
|
41857
|
+
quoteLen,
|
|
41858
|
+
quoteDepth: countQuotes(quotePrefix),
|
|
41859
|
+
lead,
|
|
41860
|
+
width,
|
|
41861
|
+
digits: match[3] ?? "",
|
|
41862
|
+
box,
|
|
41863
|
+
contentOffset: quoteLen + match[0].length
|
|
41864
|
+
};
|
|
41865
|
+
}
|
|
41866
|
+
const continueMarkup = insertNewlineContinueMarkupCommand({ nonTightLists: false });
|
|
41867
|
+
function handleEnter(view) {
|
|
41868
|
+
const { state } = view;
|
|
41869
|
+
const range = state.selection.main;
|
|
41870
|
+
if (!range.empty) return false;
|
|
41871
|
+
const line = state.doc.lineAt(range.head);
|
|
41872
|
+
if (/^[ \t]*(?:>[ \t]*)+$/.test(line.text)) {
|
|
41873
|
+
const lastGt = line.text.lastIndexOf(">");
|
|
41874
|
+
if (range.head >= line.from + lastGt + 1) {
|
|
41875
|
+
const depth = countQuotes(line.text);
|
|
41876
|
+
const delFrom = depth <= 1 ? line.from : line.from + line.text.slice(0, lastGt).replace(/[ \t]+$/, "").length;
|
|
41877
|
+
view.dispatch({
|
|
41878
|
+
changes: { from: delFrom, to: line.to, insert: "" },
|
|
41879
|
+
selection: { anchor: delFrom },
|
|
41880
|
+
scrollIntoView: true,
|
|
41881
|
+
userEvent: "input"
|
|
41882
|
+
});
|
|
41883
|
+
return true;
|
|
41884
|
+
}
|
|
41885
|
+
}
|
|
41886
|
+
if (!QUOTE_PREFIX_RE$1.test(line.text) && !parseListLine(line.text) && !/^[ \t]/.test(line.text)) {
|
|
41887
|
+
return false;
|
|
41888
|
+
}
|
|
41889
|
+
return continueMarkup(view);
|
|
41890
|
+
}
|
|
41891
|
+
function deleteTaskBox(view) {
|
|
41892
|
+
const { state } = view;
|
|
41893
|
+
const range = state.selection.main;
|
|
41894
|
+
if (!range.empty) return false;
|
|
41895
|
+
const line = state.doc.lineAt(range.head);
|
|
41896
|
+
const self2 = parseListLine(line.text);
|
|
41897
|
+
if (!self2 || !self2.box) return false;
|
|
41898
|
+
const contentStart = line.from + self2.contentOffset;
|
|
41899
|
+
if (range.head !== contentStart) return false;
|
|
41900
|
+
const boxStart = contentStart - self2.box.length;
|
|
41901
|
+
view.dispatch({
|
|
41902
|
+
changes: { from: boxStart, to: contentStart, insert: "" },
|
|
41903
|
+
selection: { anchor: boxStart },
|
|
41904
|
+
userEvent: "delete"
|
|
41905
|
+
});
|
|
41906
|
+
return true;
|
|
41907
|
+
}
|
|
41908
|
+
function deleteAtLineStart(view) {
|
|
41909
|
+
const { state } = view;
|
|
41910
|
+
const range = state.selection.main;
|
|
41911
|
+
if (!range.empty) return false;
|
|
41912
|
+
const line = state.doc.lineAt(range.head);
|
|
41913
|
+
const self2 = parseListLine(line.text);
|
|
41914
|
+
if (self2 && range.head <= line.from + self2.contentOffset) {
|
|
41915
|
+
if (self2.lead > 0) return indentListItem(view, -1);
|
|
41916
|
+
const from = line.from + self2.quoteLen;
|
|
41917
|
+
const to = line.from + self2.contentOffset;
|
|
41918
|
+
view.dispatch({
|
|
41919
|
+
changes: { from, to, insert: "" },
|
|
41920
|
+
selection: { anchor: from },
|
|
41921
|
+
userEvent: "delete"
|
|
41922
|
+
});
|
|
41923
|
+
return true;
|
|
41924
|
+
}
|
|
41925
|
+
const quotePrefix = QUOTE_PREFIX_RE$1.exec(line.text)?.[0] ?? "";
|
|
41926
|
+
const quoteLen = quotePrefix.length;
|
|
41927
|
+
const head = /^#{1,6}[ \t]?/.exec(line.text.slice(quoteLen));
|
|
41928
|
+
if (head && head[0].length > 0 && range.head >= line.from + quoteLen && range.head <= line.from + quoteLen + head[0].length) {
|
|
41929
|
+
const from = line.from + quoteLen;
|
|
41930
|
+
view.dispatch({
|
|
41931
|
+
changes: { from, to: from + head[0].length, insert: "" },
|
|
41932
|
+
selection: { anchor: from },
|
|
41933
|
+
userEvent: "delete"
|
|
41934
|
+
});
|
|
41935
|
+
return true;
|
|
41936
|
+
}
|
|
41937
|
+
if (quoteLen > 0 && range.head <= line.from + quoteLen) {
|
|
41938
|
+
if (line.text.length > quoteLen || range.head > line.from) {
|
|
41939
|
+
const innerMatch = /[ \t]*> ?$/.exec(quotePrefix);
|
|
41940
|
+
const delFrom = innerMatch ? line.from + quoteLen - innerMatch[0].length : line.from;
|
|
41941
|
+
view.dispatch({
|
|
41942
|
+
changes: { from: delFrom, to: line.from + quoteLen, insert: "" },
|
|
41943
|
+
selection: { anchor: delFrom },
|
|
41944
|
+
userEvent: "delete"
|
|
41945
|
+
});
|
|
41946
|
+
return true;
|
|
41947
|
+
}
|
|
41948
|
+
}
|
|
41949
|
+
return false;
|
|
41950
|
+
}
|
|
41951
|
+
function indentListItem(view, direction) {
|
|
41952
|
+
const { state } = view;
|
|
41953
|
+
const range = state.selection.main;
|
|
41954
|
+
if (!range.empty) return false;
|
|
41955
|
+
const line = state.doc.lineAt(range.head);
|
|
41956
|
+
const self2 = parseListLine(line.text);
|
|
41957
|
+
if (!self2) {
|
|
41958
|
+
const quotePrefix = QUOTE_PREFIX_RE$1.exec(line.text)?.[0];
|
|
41959
|
+
if (!quotePrefix) return false;
|
|
41960
|
+
const bodyFrom2 = line.from + quotePrefix.length;
|
|
41961
|
+
if (direction === 1) {
|
|
41962
|
+
const at = Math.max(range.head, bodyFrom2);
|
|
41963
|
+
view.dispatch({
|
|
41964
|
+
changes: { from: at, to: at, insert: INDENT },
|
|
41965
|
+
selection: { anchor: at + INDENT.length },
|
|
41966
|
+
scrollIntoView: true,
|
|
41967
|
+
userEvent: "input"
|
|
41968
|
+
});
|
|
41969
|
+
return true;
|
|
41970
|
+
}
|
|
41971
|
+
const spaces2 = /^[ \t]+/.exec(line.text.slice(quotePrefix.length))?.[0] ?? "";
|
|
41972
|
+
if (!spaces2) return true;
|
|
41973
|
+
const remove2 = Math.min(spaces2.length, INDENT.length);
|
|
41974
|
+
view.dispatch({
|
|
41975
|
+
changes: { from: bodyFrom2, to: bodyFrom2 + remove2, insert: "" },
|
|
41976
|
+
selection: { anchor: Math.max(bodyFrom2, range.head - remove2) },
|
|
41977
|
+
scrollIntoView: true,
|
|
41978
|
+
userEvent: "input"
|
|
41979
|
+
});
|
|
41980
|
+
return true;
|
|
41981
|
+
}
|
|
41982
|
+
const bodyFrom = line.from + self2.quoteLen;
|
|
41983
|
+
if (direction === 1) {
|
|
41984
|
+
const parent2 = parentItem(state, line, self2.lead, self2.quoteDepth);
|
|
41985
|
+
const target = parent2 ? parent2.lead + parent2.width : self2.lead + self2.width;
|
|
41986
|
+
const lead2 = Math.max(target, self2.lead + INDENT.length);
|
|
41987
|
+
const change = freshSublist(state, line, lead2, self2) ? { from: bodyFrom, to: bodyFrom + self2.lead + self2.digits.length, insert: `${" ".repeat(lead2)}1` } : { from: bodyFrom, insert: " ".repeat(lead2 - self2.lead) };
|
|
41988
|
+
const changes = state.changes(change);
|
|
41989
|
+
view.dispatch({
|
|
41990
|
+
changes,
|
|
41991
|
+
selection: { anchor: changes.mapPos(range.head, 1) },
|
|
41992
|
+
scrollIntoView: true,
|
|
41993
|
+
userEvent: "input"
|
|
41994
|
+
});
|
|
41995
|
+
return true;
|
|
41996
|
+
}
|
|
41997
|
+
const parent = parentItem(state, line, self2.lead - 1, self2.quoteDepth);
|
|
41998
|
+
const lead = parent ? parent.lead : 0;
|
|
41999
|
+
if (lead >= self2.lead) return false;
|
|
42000
|
+
view.dispatch({
|
|
42001
|
+
changes: { from: bodyFrom, to: bodyFrom + self2.lead, insert: " ".repeat(lead) },
|
|
42002
|
+
selection: { anchor: Math.max(bodyFrom + lead, range.head - (self2.lead - lead)) },
|
|
42003
|
+
scrollIntoView: true,
|
|
42004
|
+
userEvent: "input"
|
|
42005
|
+
});
|
|
42006
|
+
return true;
|
|
42007
|
+
}
|
|
42008
|
+
function freshSublist(state, line, depth, self2) {
|
|
42009
|
+
if (!self2.digits) return false;
|
|
42010
|
+
for (let number2 = line.number - 1; number2 >= 1; number2--) {
|
|
42011
|
+
const prev = state.doc.line(number2);
|
|
42012
|
+
const prevQuote = QUOTE_PREFIX_RE$1.exec(prev.text)?.[0] ?? "";
|
|
42013
|
+
if (countQuotes(prevQuote) !== self2.quoteDepth) break;
|
|
42014
|
+
const rest = prev.text.slice(prevQuote.length);
|
|
42015
|
+
if (rest.trim() === "") break;
|
|
42016
|
+
const prevLine = parseListLine(prev.text);
|
|
42017
|
+
if (!prevLine) {
|
|
42018
|
+
if (/^[ \t]*/.exec(rest)[0].length > depth) continue;
|
|
42019
|
+
break;
|
|
42020
|
+
}
|
|
42021
|
+
if (prevLine.lead === depth) return false;
|
|
42022
|
+
if (prevLine.lead < depth) break;
|
|
42023
|
+
}
|
|
42024
|
+
return true;
|
|
42025
|
+
}
|
|
42026
|
+
function parentItem(state, line, lead, quoteDepth) {
|
|
42027
|
+
for (let number2 = line.number - 1; number2 >= 1; number2--) {
|
|
42028
|
+
const prev = state.doc.line(number2);
|
|
42029
|
+
const prevQuote = QUOTE_PREFIX_RE$1.exec(prev.text)?.[0] ?? "";
|
|
42030
|
+
if (countQuotes(prevQuote) !== quoteDepth) return null;
|
|
42031
|
+
const rest = prev.text.slice(prevQuote.length);
|
|
42032
|
+
if (rest.trim() === "") return null;
|
|
42033
|
+
const prevLine = parseListLine(prev.text);
|
|
42034
|
+
if (prevLine) {
|
|
42035
|
+
if (prevLine.lead <= lead) return prevLine;
|
|
42036
|
+
continue;
|
|
42037
|
+
}
|
|
42038
|
+
if (/^[ \t]*/.exec(rest)[0].length <= lead) return null;
|
|
42039
|
+
}
|
|
42040
|
+
return null;
|
|
42041
|
+
}
|
|
42042
|
+
const listInput = Prec.high(keymap.of([
|
|
42043
|
+
{ key: "Enter", run: handleEnter },
|
|
42044
|
+
{ key: "Backspace", run: deleteTaskBox },
|
|
42045
|
+
{ key: "Backspace", run: deleteAtLineStart },
|
|
42046
|
+
{ key: "Backspace", run: deleteMarkupBackward },
|
|
42047
|
+
{ key: "Tab", run: (view) => indentListItem(view, 1) },
|
|
42048
|
+
{ key: "Shift-Tab", run: (view) => indentListItem(view, -1) }
|
|
42049
|
+
]));
|
|
42050
|
+
const setSearchHighlight = StateEffect.define();
|
|
42051
|
+
const searchHighlightField = StateField.define({
|
|
42052
|
+
create: () => Decoration.none,
|
|
42053
|
+
update(value, tr) {
|
|
42054
|
+
for (const effect of tr.effects) {
|
|
42055
|
+
if (effect.is(setSearchHighlight)) return effect.value;
|
|
42056
|
+
}
|
|
42057
|
+
return value.map(tr.changes);
|
|
42058
|
+
},
|
|
42059
|
+
provide: (field) => EditorView.decorations.from(field)
|
|
42060
|
+
});
|
|
41830
42061
|
function legacy(parser2) {
|
|
41831
42062
|
return new LanguageSupport(StreamLanguage.define(parser2));
|
|
41832
42063
|
}
|
|
41833
42064
|
function sql(dialectName) {
|
|
41834
|
-
return __vitePreload(() => import("./index-
|
|
42065
|
+
return __vitePreload(() => import("./index-CBsqa7KF.js"), true ? [] : void 0, import.meta.url).then((m) => m.sql({ dialect: m[dialectName] }));
|
|
41835
42066
|
}
|
|
41836
42067
|
const languages = [
|
|
41837
42068
|
// New-style language modes
|
|
@@ -41839,7 +42070,7 @@ const languages = [
|
|
|
41839
42070
|
name: "C",
|
|
41840
42071
|
extensions: ["c", "h", "ino"],
|
|
41841
42072
|
load() {
|
|
41842
|
-
return __vitePreload(() => import("./index-
|
|
42073
|
+
return __vitePreload(() => import("./index-B7a6ecSB.js"), true ? [] : void 0, import.meta.url).then((m) => m.cpp());
|
|
41843
42074
|
}
|
|
41844
42075
|
}),
|
|
41845
42076
|
/* @__PURE__ */ LanguageDescription.of({
|
|
@@ -41847,7 +42078,7 @@ const languages = [
|
|
|
41847
42078
|
alias: ["cpp"],
|
|
41848
42079
|
extensions: ["cpp", "c++", "cc", "cxx", "hpp", "h++", "hh", "hxx"],
|
|
41849
42080
|
load() {
|
|
41850
|
-
return __vitePreload(() => import("./index-
|
|
42081
|
+
return __vitePreload(() => import("./index-B7a6ecSB.js"), true ? [] : void 0, import.meta.url).then((m) => m.cpp());
|
|
41851
42082
|
}
|
|
41852
42083
|
}),
|
|
41853
42084
|
/* @__PURE__ */ LanguageDescription.of({
|
|
@@ -41869,7 +42100,7 @@ const languages = [
|
|
|
41869
42100
|
name: "Go",
|
|
41870
42101
|
extensions: ["go"],
|
|
41871
42102
|
load() {
|
|
41872
|
-
return __vitePreload(() => import("./index-
|
|
42103
|
+
return __vitePreload(() => import("./index-B3xEpmeL.js"), true ? [] : void 0, import.meta.url).then((m) => m.go());
|
|
41873
42104
|
}
|
|
41874
42105
|
}),
|
|
41875
42106
|
/* @__PURE__ */ LanguageDescription.of({
|
|
@@ -41884,7 +42115,7 @@ const languages = [
|
|
|
41884
42115
|
name: "Java",
|
|
41885
42116
|
extensions: ["java"],
|
|
41886
42117
|
load() {
|
|
41887
|
-
return __vitePreload(() => import("./index-
|
|
42118
|
+
return __vitePreload(() => import("./index-B-sTajw0.js"), true ? [] : void 0, import.meta.url).then((m) => m.java());
|
|
41888
42119
|
}
|
|
41889
42120
|
}),
|
|
41890
42121
|
/* @__PURE__ */ LanguageDescription.of({
|
|
@@ -41899,7 +42130,7 @@ const languages = [
|
|
|
41899
42130
|
name: "Jinja",
|
|
41900
42131
|
extensions: ["j2", "jinja", "jinja2"],
|
|
41901
42132
|
load() {
|
|
41902
|
-
return __vitePreload(() => import("./index-
|
|
42133
|
+
return __vitePreload(() => import("./index-CFd49PzX.js"), true ? [] : void 0, import.meta.url).then((m) => m.jinja());
|
|
41903
42134
|
}
|
|
41904
42135
|
}),
|
|
41905
42136
|
/* @__PURE__ */ LanguageDescription.of({
|
|
@@ -41907,7 +42138,7 @@ const languages = [
|
|
|
41907
42138
|
alias: ["json5"],
|
|
41908
42139
|
extensions: ["json", "map"],
|
|
41909
42140
|
load() {
|
|
41910
|
-
return __vitePreload(() => import("./index-
|
|
42141
|
+
return __vitePreload(() => import("./index-Cl38Mcu3.js"), true ? [] : void 0, import.meta.url).then((m) => m.json());
|
|
41911
42142
|
}
|
|
41912
42143
|
}),
|
|
41913
42144
|
/* @__PURE__ */ LanguageDescription.of({
|
|
@@ -41921,14 +42152,14 @@ const languages = [
|
|
|
41921
42152
|
name: "LESS",
|
|
41922
42153
|
extensions: ["less"],
|
|
41923
42154
|
load() {
|
|
41924
|
-
return __vitePreload(() => import("./index-
|
|
42155
|
+
return __vitePreload(() => import("./index-WU2bjQIt.js"), true ? [] : void 0, import.meta.url).then((m) => m.less());
|
|
41925
42156
|
}
|
|
41926
42157
|
}),
|
|
41927
42158
|
/* @__PURE__ */ LanguageDescription.of({
|
|
41928
42159
|
name: "Liquid",
|
|
41929
42160
|
extensions: ["liquid"],
|
|
41930
42161
|
load() {
|
|
41931
|
-
return __vitePreload(() => import("./index-
|
|
42162
|
+
return __vitePreload(() => import("./index-BXMm6of_.js"), true ? [] : void 0, import.meta.url).then((m) => m.liquid());
|
|
41932
42163
|
}
|
|
41933
42164
|
}),
|
|
41934
42165
|
/* @__PURE__ */ LanguageDescription.of({
|
|
@@ -41960,7 +42191,7 @@ const languages = [
|
|
|
41960
42191
|
name: "PHP",
|
|
41961
42192
|
extensions: ["php", "php3", "php4", "php5", "php7", "phtml"],
|
|
41962
42193
|
load() {
|
|
41963
|
-
return __vitePreload(() => import("./index-
|
|
42194
|
+
return __vitePreload(() => import("./index-BgaTyTt4.js"), true ? [] : void 0, import.meta.url).then((m) => m.php());
|
|
41964
42195
|
}
|
|
41965
42196
|
}),
|
|
41966
42197
|
/* @__PURE__ */ LanguageDescription.of({
|
|
@@ -41981,28 +42212,28 @@ const languages = [
|
|
|
41981
42212
|
extensions: ["BUILD", "bzl", "py", "pyw"],
|
|
41982
42213
|
filename: /^(BUCK|BUILD)$/,
|
|
41983
42214
|
load() {
|
|
41984
|
-
return __vitePreload(() => import("./index-
|
|
42215
|
+
return __vitePreload(() => import("./index-Cr5af8vL.js"), true ? [] : void 0, import.meta.url).then((m) => m.python());
|
|
41985
42216
|
}
|
|
41986
42217
|
}),
|
|
41987
42218
|
/* @__PURE__ */ LanguageDescription.of({
|
|
41988
42219
|
name: "Rust",
|
|
41989
42220
|
extensions: ["rs"],
|
|
41990
42221
|
load() {
|
|
41991
|
-
return __vitePreload(() => import("./index-
|
|
42222
|
+
return __vitePreload(() => import("./index-DNKeYHeb.js"), true ? [] : void 0, import.meta.url).then((m) => m.rust());
|
|
41992
42223
|
}
|
|
41993
42224
|
}),
|
|
41994
42225
|
/* @__PURE__ */ LanguageDescription.of({
|
|
41995
42226
|
name: "Sass",
|
|
41996
42227
|
extensions: ["sass"],
|
|
41997
42228
|
load() {
|
|
41998
|
-
return __vitePreload(() => import("./index-
|
|
42229
|
+
return __vitePreload(() => import("./index-CizbQ4B2.js"), true ? [] : void 0, import.meta.url).then((m) => m.sass({ indented: true }));
|
|
41999
42230
|
}
|
|
42000
42231
|
}),
|
|
42001
42232
|
/* @__PURE__ */ LanguageDescription.of({
|
|
42002
42233
|
name: "SCSS",
|
|
42003
42234
|
extensions: ["scss"],
|
|
42004
42235
|
load() {
|
|
42005
|
-
return __vitePreload(() => import("./index-
|
|
42236
|
+
return __vitePreload(() => import("./index-CizbQ4B2.js"), true ? [] : void 0, import.meta.url).then((m) => m.sass());
|
|
42006
42237
|
}
|
|
42007
42238
|
}),
|
|
42008
42239
|
/* @__PURE__ */ LanguageDescription.of({
|
|
@@ -42037,7 +42268,7 @@ const languages = [
|
|
|
42037
42268
|
name: "WebAssembly",
|
|
42038
42269
|
extensions: ["wat", "wast"],
|
|
42039
42270
|
load() {
|
|
42040
|
-
return __vitePreload(() => import("./index-
|
|
42271
|
+
return __vitePreload(() => import("./index-BUMCX36l.js"), true ? [] : void 0, import.meta.url).then((m) => m.wast());
|
|
42041
42272
|
}
|
|
42042
42273
|
}),
|
|
42043
42274
|
/* @__PURE__ */ LanguageDescription.of({
|
|
@@ -42045,7 +42276,7 @@ const languages = [
|
|
|
42045
42276
|
alias: ["rss", "wsdl", "xsd"],
|
|
42046
42277
|
extensions: ["xml", "xsl", "xsd", "svg"],
|
|
42047
42278
|
load() {
|
|
42048
|
-
return __vitePreload(() => import("./index-
|
|
42279
|
+
return __vitePreload(() => import("./index-9wJDFDHb.js"), true ? [] : void 0, import.meta.url).then((m) => m.xml());
|
|
42049
42280
|
}
|
|
42050
42281
|
}),
|
|
42051
42282
|
/* @__PURE__ */ LanguageDescription.of({
|
|
@@ -42053,7 +42284,7 @@ const languages = [
|
|
|
42053
42284
|
alias: ["yml"],
|
|
42054
42285
|
extensions: ["yaml", "yml"],
|
|
42055
42286
|
load() {
|
|
42056
|
-
return __vitePreload(() => import("./index-
|
|
42287
|
+
return __vitePreload(() => import("./index-j9IOhwim.js"), true ? [] : void 0, import.meta.url).then((m) => m.yaml());
|
|
42057
42288
|
}
|
|
42058
42289
|
}),
|
|
42059
42290
|
// Legacy modes ported from CodeMirror 5
|
|
@@ -42842,13 +43073,13 @@ const languages = [
|
|
|
42842
43073
|
name: "Vue",
|
|
42843
43074
|
extensions: ["vue"],
|
|
42844
43075
|
load() {
|
|
42845
|
-
return __vitePreload(() => import("./index-
|
|
43076
|
+
return __vitePreload(() => import("./index-CmCG8RWM.js"), true ? [] : void 0, import.meta.url).then((m) => m.vue());
|
|
42846
43077
|
}
|
|
42847
43078
|
}),
|
|
42848
43079
|
/* @__PURE__ */ LanguageDescription.of({
|
|
42849
43080
|
name: "Angular Template",
|
|
42850
43081
|
load() {
|
|
42851
|
-
return __vitePreload(() => import("./index-
|
|
43082
|
+
return __vitePreload(() => import("./index-CX3eLmnK.js"), true ? [] : void 0, import.meta.url).then((m) => m.angular());
|
|
42852
43083
|
}
|
|
42853
43084
|
})
|
|
42854
43085
|
];
|
|
@@ -42907,8 +43138,9 @@ const editorTheme = EditorView.theme({
|
|
|
42907
43138
|
".cm-searchMatch": { backgroundColor: "var(--search-match-bg, color-mix(in srgb, var(--text-color) 16%, transparent))" },
|
|
42908
43139
|
".cm-searchMatch-selected": { backgroundColor: "var(--search-current-bg, color-mix(in srgb, var(--text-color) 26%, transparent))" }
|
|
42909
43140
|
});
|
|
42910
|
-
const
|
|
42911
|
-
const
|
|
43141
|
+
const QUOTE_PREFIX_RE = /^(?:[ \t]*> ?)+/;
|
|
43142
|
+
const LIST_LINE = /^(?:[ \t]*> ?)*[ \t]*(?:[-*+]|\d+[.)])[ \t]/;
|
|
43143
|
+
const INDENTED = /^(?:[ \t]*> ?)*[ \t]/;
|
|
42912
43144
|
const MAX_SCAN_LINES = 5e3;
|
|
42913
43145
|
let patching = false;
|
|
42914
43146
|
const renumberLists = EditorState.transactionFilter.of((tr) => {
|
|
@@ -42917,17 +43149,20 @@ const renumberLists = EditorState.transactionFilter.of((tr) => {
|
|
|
42917
43149
|
if (!event || event.startsWith("undo") || event.startsWith("redo")) return tr;
|
|
42918
43150
|
const before = syntaxTree(tr.startState);
|
|
42919
43151
|
if (!touchesOrderedList(before, tr.changes)) return tr;
|
|
42920
|
-
const
|
|
42921
|
-
const
|
|
43152
|
+
const { oldRange, newRange } = affectedRanges(tr, before);
|
|
43153
|
+
const beforeSlice = tr.startState.doc.sliceString(oldRange.from, oldRange.to);
|
|
43154
|
+
const oldLists = orderedLists(markdownParser.parse(beforeSlice), beforeSlice);
|
|
43155
|
+
const slice = tr.newDoc.sliceString(newRange.from, newRange.to);
|
|
42922
43156
|
const changes = [];
|
|
42923
|
-
for (const list of orderedLists(markdownParser.parse(slice))) {
|
|
42924
|
-
|
|
42925
|
-
|
|
43157
|
+
for (const list of orderedLists(markdownParser.parse(slice), slice)) {
|
|
43158
|
+
const plan = renumberPlan(list, oldLists, tr.changes, newRange.from, oldRange.from);
|
|
43159
|
+
if (!plan.run) continue;
|
|
43160
|
+
const start = plan.resetToOne ? 1 : Number.parseInt(slice.slice(list.marks[0].from, list.marks[0].to), 10);
|
|
42926
43161
|
if (!Number.isFinite(start)) continue;
|
|
42927
43162
|
list.marks.forEach((mark, index2) => {
|
|
42928
43163
|
const now = slice.slice(mark.from, mark.to);
|
|
42929
43164
|
const want = `${start + index2}${now.endsWith(")") ? ")" : "."}`;
|
|
42930
|
-
if (now !== want) changes.push({ from:
|
|
43165
|
+
if (now !== want) changes.push({ from: newRange.from + mark.from, to: newRange.from + mark.to, insert: want });
|
|
42931
43166
|
});
|
|
42932
43167
|
}
|
|
42933
43168
|
if (changes.length === 0) return tr;
|
|
@@ -42948,18 +43183,47 @@ const renumberLists = EditorState.transactionFilter.of((tr) => {
|
|
|
42948
43183
|
patching = false;
|
|
42949
43184
|
}
|
|
42950
43185
|
});
|
|
42951
|
-
function
|
|
43186
|
+
function itemHasLazyBreak(item, slice) {
|
|
43187
|
+
let ownEnd = item.to;
|
|
43188
|
+
for (let child = item.firstChild; child; child = child.nextSibling) {
|
|
43189
|
+
if (child.name === "BulletList" || child.name === "OrderedList") {
|
|
43190
|
+
ownEnd = child.from;
|
|
43191
|
+
break;
|
|
43192
|
+
}
|
|
43193
|
+
}
|
|
43194
|
+
const lines = slice.slice(item.from, ownEnd).split("\n");
|
|
43195
|
+
for (let i = 1; i < lines.length; i++) {
|
|
43196
|
+
const body = lines[i].replace(QUOTE_PREFIX_RE, "");
|
|
43197
|
+
if (body.trim() !== "" && !/^[ \t]/.test(body)) return true;
|
|
43198
|
+
}
|
|
43199
|
+
return false;
|
|
43200
|
+
}
|
|
43201
|
+
function orderedLists(tree, slice) {
|
|
42952
43202
|
const lists = [];
|
|
42953
43203
|
tree.iterate({
|
|
42954
43204
|
enter(node) {
|
|
42955
43205
|
if (node.name !== "OrderedList") return;
|
|
42956
|
-
|
|
43206
|
+
let marks = [];
|
|
43207
|
+
let segFrom = node.from;
|
|
43208
|
+
let segTo = node.from;
|
|
43209
|
+
let splitFromAbove = false;
|
|
43210
|
+
const flush = (nextSplit) => {
|
|
43211
|
+
if (marks.length > 0) lists.push({ from: segFrom, to: segTo, splitFromAbove, marks });
|
|
43212
|
+
marks = [];
|
|
43213
|
+
if (nextSplit) splitFromAbove = true;
|
|
43214
|
+
};
|
|
42957
43215
|
for (let item = node.node.firstChild; item; item = item.nextSibling) {
|
|
42958
43216
|
if (item.name !== "ListItem") continue;
|
|
42959
43217
|
const mark = item.getChild("ListMark");
|
|
42960
|
-
if (mark)
|
|
43218
|
+
if (!mark) continue;
|
|
43219
|
+
const after = slice[mark.to];
|
|
43220
|
+
if (after !== " " && after !== " ") continue;
|
|
43221
|
+
if (marks.length === 0) segFrom = item.from;
|
|
43222
|
+
marks.push({ from: mark.from, to: mark.to });
|
|
43223
|
+
segTo = item.to;
|
|
43224
|
+
if (itemHasLazyBreak(item, slice)) flush(true);
|
|
42961
43225
|
}
|
|
42962
|
-
|
|
43226
|
+
flush(false);
|
|
42963
43227
|
}
|
|
42964
43228
|
});
|
|
42965
43229
|
return lists;
|
|
@@ -42986,17 +43250,29 @@ function enclosingOrderedList(tree, pos, side) {
|
|
|
42986
43250
|
}
|
|
42987
43251
|
return null;
|
|
42988
43252
|
}
|
|
42989
|
-
function
|
|
43253
|
+
function affectedRanges(tr, before) {
|
|
42990
43254
|
let first = -1;
|
|
42991
43255
|
tr.changes.iterChangedRanges((fromA) => {
|
|
42992
43256
|
if (first < 0) first = fromA;
|
|
42993
43257
|
});
|
|
42994
|
-
if (first < 0)
|
|
43258
|
+
if (first < 0) {
|
|
43259
|
+
return {
|
|
43260
|
+
oldRange: { from: 0, to: tr.startState.doc.length },
|
|
43261
|
+
newRange: { from: 0, to: tr.newDoc.length }
|
|
43262
|
+
};
|
|
43263
|
+
}
|
|
42995
43264
|
let block = before.resolveInner(first, 1);
|
|
42996
43265
|
while (block && block.parent && block.parent.name !== "Document") block = block.parent;
|
|
42997
|
-
const
|
|
42998
|
-
const
|
|
42999
|
-
|
|
43266
|
+
const oldBase = block ? block.from : first;
|
|
43267
|
+
const oldFrom = tr.startState.doc.lineAt(Math.min(Math.max(oldBase, 0), tr.startState.doc.length)).from;
|
|
43268
|
+
const oldTo = listClusterEnd(tr.startState.doc, oldFrom);
|
|
43269
|
+
const mapped = tr.changes.mapPos(oldBase, -1);
|
|
43270
|
+
const newFrom = tr.newDoc.lineAt(Math.min(Math.max(mapped, 0), tr.newDoc.length)).from;
|
|
43271
|
+
const newTo = listClusterEnd(tr.newDoc, newFrom);
|
|
43272
|
+
return {
|
|
43273
|
+
oldRange: { from: oldFrom, to: oldTo },
|
|
43274
|
+
newRange: { from: newFrom, to: newTo }
|
|
43275
|
+
};
|
|
43000
43276
|
}
|
|
43001
43277
|
function listClusterEnd(doc2, from) {
|
|
43002
43278
|
const first = doc2.lineAt(from);
|
|
@@ -43005,7 +43281,8 @@ function listClusterEnd(doc2, from) {
|
|
|
43005
43281
|
const stop = Math.min(doc2.lines, first.number + MAX_SCAN_LINES);
|
|
43006
43282
|
for (let number2 = first.number + 1; number2 <= stop; number2++) {
|
|
43007
43283
|
const line = doc2.line(number2);
|
|
43008
|
-
|
|
43284
|
+
const stripped = line.text.replace(QUOTE_PREFIX_RE, "");
|
|
43285
|
+
if (stripped.trim() === "") {
|
|
43009
43286
|
blank = true;
|
|
43010
43287
|
end = line.to;
|
|
43011
43288
|
continue;
|
|
@@ -43016,32 +43293,41 @@ function listClusterEnd(doc2, from) {
|
|
|
43016
43293
|
}
|
|
43017
43294
|
return end;
|
|
43018
43295
|
}
|
|
43019
|
-
function
|
|
43020
|
-
const
|
|
43021
|
-
|
|
43022
|
-
|
|
43023
|
-
|
|
43024
|
-
|
|
43025
|
-
|
|
43026
|
-
|
|
43027
|
-
|
|
43028
|
-
|
|
43296
|
+
function renumberPlan(list, oldLists, changes, newOffset, oldOffset) {
|
|
43297
|
+
const listNewFrom = newOffset + list.from;
|
|
43298
|
+
const listNewTo = newOffset + list.to;
|
|
43299
|
+
const old = oldLists.find((item) => {
|
|
43300
|
+
const mappedFrom = changes.mapPos(oldOffset + item.from, 1);
|
|
43301
|
+
const mappedTo = changes.mapPos(oldOffset + item.to, -1);
|
|
43302
|
+
return mappedTo >= listNewFrom && mappedFrom <= listNewTo;
|
|
43303
|
+
});
|
|
43304
|
+
if (list.splitFromAbove && old) {
|
|
43305
|
+
const oldFirstMapped = changes.mapPos(oldOffset + old.marks[0].from, 1);
|
|
43306
|
+
if (oldFirstMapped < newOffset + list.marks[0].from) {
|
|
43307
|
+
return { run: true, resetToOne: true };
|
|
43308
|
+
}
|
|
43029
43309
|
}
|
|
43030
|
-
|
|
43310
|
+
let touchedThisSegment = false;
|
|
43311
|
+
changes.iterChangedRanges((_fromA, _toA, fromB, toB) => {
|
|
43312
|
+
if (toB >= listNewFrom - 1 && fromB <= listNewTo + 1) touchedThisSegment = true;
|
|
43313
|
+
});
|
|
43314
|
+
if (!touchedThisSegment) return { run: false, resetToOne: false };
|
|
43315
|
+
if (!old) return { run: true, resetToOne: false };
|
|
43316
|
+
if (old.marks.length !== list.marks.length) return { run: true, resetToOne: false };
|
|
43317
|
+
return { run: touchedMark(changes, old, oldOffset), resetToOne: false };
|
|
43031
43318
|
}
|
|
43032
|
-
function touchedMark(changes, list) {
|
|
43319
|
+
function touchedMark(changes, list, oldOffset) {
|
|
43033
43320
|
let hit = false;
|
|
43034
43321
|
changes.iterChangedRanges((fromA, toA) => {
|
|
43035
43322
|
if (hit) return;
|
|
43036
|
-
for (
|
|
43037
|
-
|
|
43038
|
-
const
|
|
43039
|
-
if (
|
|
43040
|
-
if (fromA <= mark.from && toA >= mark.from) {
|
|
43323
|
+
for (const raw of list.marks) {
|
|
43324
|
+
const markFrom = oldOffset + raw.from;
|
|
43325
|
+
const markTo = oldOffset + raw.to;
|
|
43326
|
+
if (fromA <= markFrom && toA >= markFrom) {
|
|
43041
43327
|
hit = true;
|
|
43042
43328
|
return;
|
|
43043
43329
|
}
|
|
43044
|
-
if (fromA <
|
|
43330
|
+
if (fromA < markTo && toA > markFrom) {
|
|
43045
43331
|
hit = true;
|
|
43046
43332
|
return;
|
|
43047
43333
|
}
|
|
@@ -43090,9 +43376,11 @@ function bodyStart(doc2) {
|
|
|
43090
43376
|
return lineBreak === -1 ? doc2.length : lineBreak + 1;
|
|
43091
43377
|
}
|
|
43092
43378
|
function inCodeBlock(state, pos) {
|
|
43379
|
+
const decorations2 = state.field(livePreviewField, false);
|
|
43380
|
+
if (!decorations2) return false;
|
|
43093
43381
|
const line = state.doc.lineAt(pos);
|
|
43094
43382
|
let code = false;
|
|
43095
|
-
|
|
43383
|
+
decorations2.between(line.from, line.from, (_from, _to, decoration) => {
|
|
43096
43384
|
if (decoration.spec.class?.split(" ").includes("cm-md-codeblock")) code = true;
|
|
43097
43385
|
});
|
|
43098
43386
|
return code;
|
|
@@ -43140,7 +43428,9 @@ const taskMarkerAtomicRanges = EditorView.atomicRanges.of((view) => {
|
|
|
43140
43428
|
if (node.name !== "TaskMarker") return;
|
|
43141
43429
|
const line = doc2.lineAt(node.from);
|
|
43142
43430
|
const prefix = doc2.sliceString(line.from, node.from);
|
|
43143
|
-
const
|
|
43431
|
+
const quoteLen = /^(?:[ \t]*> ?)+/.exec(prefix)?.[0].length ?? 0;
|
|
43432
|
+
const listPart = prefix.slice(quoteLen);
|
|
43433
|
+
const from = /^[ \t]*(?:[-*+]|\d+[.)])[ \t]+$/.test(listPart) ? line.from + quoteLen : node.from;
|
|
43144
43434
|
const trailing = doc2.sliceString(node.to, Math.min(node.to + 1, line.to)) === " " ? node.to + 1 : node.to;
|
|
43145
43435
|
ranges.push({ from, to: trailing });
|
|
43146
43436
|
}
|
|
@@ -43207,6 +43497,7 @@ function createEditorCore(parent, options2 = {}) {
|
|
|
43207
43497
|
state: EditorState.create({ doc: options2.doc ?? "", extensions: editorExtensions(false, editableAtStart, changeListener) }),
|
|
43208
43498
|
parent
|
|
43209
43499
|
});
|
|
43500
|
+
setMeasureHost(view);
|
|
43210
43501
|
if (view.hasFocus) view.dispatch({ effects: setEditorFocus.of(true) });
|
|
43211
43502
|
const api = {
|
|
43212
43503
|
getText: () => view.state.doc.toString(),
|
|
@@ -43243,6 +43534,7 @@ function createEditorCore(parent, options2 = {}) {
|
|
|
43243
43534
|
},
|
|
43244
43535
|
getView: () => view,
|
|
43245
43536
|
destroy() {
|
|
43537
|
+
setMeasureHost(null);
|
|
43246
43538
|
view.destroy();
|
|
43247
43539
|
handle$1 = null;
|
|
43248
43540
|
}
|
|
@@ -43417,7 +43709,7 @@ function renderGroup(kind, lines, ownerDepth = -1) {
|
|
|
43417
43709
|
if (kind === "code") return renderCode(lines);
|
|
43418
43710
|
if (kind === "mermaid") {
|
|
43419
43711
|
const widget = lines[0].querySelector(".cm-md-mermaid");
|
|
43420
|
-
return widget ? `<div>${widget.innerHTML}</div>` : "";
|
|
43712
|
+
return widget ? `<div class="${widget.className}">${widget.innerHTML}</div>` : "";
|
|
43421
43713
|
}
|
|
43422
43714
|
if (kind === "math") {
|
|
43423
43715
|
const widget = lines[0].querySelector(".cm-md-math-block");
|
|
@@ -43431,7 +43723,16 @@ function renderGroup(kind, lines, ownerDepth = -1) {
|
|
|
43431
43723
|
const table = lines[0].querySelector(".cm-md-table-widget");
|
|
43432
43724
|
if (!table) return "";
|
|
43433
43725
|
const clone = table.cloneNode(true);
|
|
43434
|
-
clone.
|
|
43726
|
+
for (const shell of Array.from(clone.querySelectorAll(".cm-md-math, .cm-md-mermaid-ready"))) {
|
|
43727
|
+
shell.replaceWith(...Array.from(shell.childNodes));
|
|
43728
|
+
}
|
|
43729
|
+
for (const element of [clone, ...Array.from(clone.querySelectorAll("*"))]) {
|
|
43730
|
+
element.classList.remove(...Array.from(element.classList).filter((name2) => name2.startsWith("cm-md-")));
|
|
43731
|
+
element.removeAttribute("contenteditable");
|
|
43732
|
+
for (const attribute of ["data-source-from", "data-source-to", "data-list-path", "data-line"]) {
|
|
43733
|
+
element.removeAttribute(attribute);
|
|
43734
|
+
}
|
|
43735
|
+
}
|
|
43435
43736
|
return clone.outerHTML;
|
|
43436
43737
|
}
|
|
43437
43738
|
if (kind === "hr") return "<hr>";
|
|
@@ -43534,6 +43835,11 @@ const PAPER_RULES = `
|
|
|
43534
43835
|
body.${PAPER_CLASS} #editor { height: auto !important; overflow: visible !important; }
|
|
43535
43836
|
body.${PAPER_CLASS} #editor .cm-editor { height: auto !important; }
|
|
43536
43837
|
body.${PAPER_CLASS} #editor .cm-scroller { display: block !important; height: auto !important; overflow: visible !important; }
|
|
43838
|
+
/* 放不下的图带一排缩放控件(#129)。打印时 Chromium 不执行脚本,pele 没机会把它们
|
|
43839
|
+
收回去,控件就叠在图上进了 PDF。它是编辑器的东西,不是文档的内容——纸面上藏掉
|
|
43840
|
+
(图片/HTML 导出另有 withDiagramZoomPaused 在序列化时兜着;Word 导出重新画图,
|
|
43841
|
+
天生没有控件)。内联样式是 pele 自己写的,!important 才压得过。 */
|
|
43842
|
+
body.${PAPER_CLASS} .pele-zoom { display: none !important; }
|
|
43537
43843
|
`;
|
|
43538
43844
|
function nextFrame() {
|
|
43539
43845
|
return new Promise((resolve) => {
|
|
@@ -43928,7 +44234,6 @@ async function copyText(text2) {
|
|
|
43928
44234
|
const FOOTNOTE_PREVIEW_DELAY = 300;
|
|
43929
44235
|
const FOOTNOTE_HIDE_GRACE = 120;
|
|
43930
44236
|
function selectionRendered(view) {
|
|
43931
|
-
if (view.contentDOM.querySelector(".cm-gap")) return false;
|
|
43932
44237
|
const viewport = view.viewport;
|
|
43933
44238
|
return view.state.selection.ranges.every(
|
|
43934
44239
|
(range) => range.empty || range.from >= viewport.from && range.to <= viewport.to
|
|
@@ -43942,6 +44247,7 @@ function selectionRange(view, ranges) {
|
|
|
43942
44247
|
range.setEnd(end.node, end.offset);
|
|
43943
44248
|
return range;
|
|
43944
44249
|
}
|
|
44250
|
+
const MAX_RICH_COPY_CHARS = 2e5;
|
|
43945
44251
|
function selectionHTML(view, ranges) {
|
|
43946
44252
|
return selectionHTMLFrom(selectionRange(view, ranges).cloneContents());
|
|
43947
44253
|
}
|
|
@@ -43974,6 +44280,11 @@ function setupRichCopy(root) {
|
|
|
43974
44280
|
if (selectionRendered(view)) {
|
|
43975
44281
|
const html2 = selectionHTML(view, ranges);
|
|
43976
44282
|
if (html2) event.clipboardData?.setData("text/html", html2);
|
|
44283
|
+
event.preventDefault();
|
|
44284
|
+
return;
|
|
44285
|
+
}
|
|
44286
|
+
if (view.state.doc.length > MAX_RICH_COPY_CHARS) {
|
|
44287
|
+
event.preventDefault();
|
|
43977
44288
|
return;
|
|
43978
44289
|
}
|
|
43979
44290
|
event.preventDefault();
|
|
@@ -44062,7 +44373,7 @@ function setupFootnotePreview(root) {
|
|
|
44062
44373
|
}, { passive: true });
|
|
44063
44374
|
window.addEventListener("resize", hide2);
|
|
44064
44375
|
}
|
|
44065
|
-
const TASK_RE = /^([ \t]*(?:[-*+]|\d+[.)])[ \t]+\[)([ xX])(\])/;
|
|
44376
|
+
const TASK_RE = /^((?:[ \t]*> ?)*[ \t]*(?:[-*+]|\d+[.)])[ \t]+\[)([ xX])(\])/;
|
|
44066
44377
|
function sourceFromTaskClick(view, e) {
|
|
44067
44378
|
if (!(e.target instanceof HTMLElement)) return null;
|
|
44068
44379
|
if (!e.target.closest(".cm-md-task")) return null;
|
|
@@ -44136,8 +44447,29 @@ function jumpToLine(line) {
|
|
|
44136
44447
|
flashLine(view, target.from, target.to);
|
|
44137
44448
|
}
|
|
44138
44449
|
const MERMAID_FENCE = /^([ \t]*)```[ \t]*mermaid[ \t]*\r?\n([\s\S]*?)^\1```[ \t]*$/gm;
|
|
44139
|
-
|
|
44140
|
-
const
|
|
44450
|
+
function mixSrgb(a, b, weightA) {
|
|
44451
|
+
const parse = (hex) => [0, 2, 4].map((index2) => Number.parseInt(hex.slice(index2, index2 + 2), 16) || 0);
|
|
44452
|
+
const [ra, ga, ba] = parse(a);
|
|
44453
|
+
const [rb, gb, bb] = parse(b);
|
|
44454
|
+
const mix = (x, y) => Math.max(0, Math.min(255, Math.round(x * weightA + y * (1 - weightA))));
|
|
44455
|
+
return [mix(ra, rb), mix(ga, gb), mix(ba, bb)].map((value) => value.toString(16).padStart(2, "0")).join("").toUpperCase();
|
|
44456
|
+
}
|
|
44457
|
+
function diagramPrintPalette(style) {
|
|
44458
|
+
const bg = style.codeBlockBackground;
|
|
44459
|
+
const fg = style.codeBlockText;
|
|
44460
|
+
return {
|
|
44461
|
+
"--pele-bg": `#${bg}`,
|
|
44462
|
+
"--pele-fg": `#${fg}`,
|
|
44463
|
+
"--pele-muted": `#${mixSrgb(fg, bg, 0.7)}`,
|
|
44464
|
+
"--pele-line": `#${fg}`,
|
|
44465
|
+
"--pele-surface": `#${mixSrgb(fg, bg, 0.18)}`,
|
|
44466
|
+
"--pele-surface-alt": `#${mixSrgb(fg, bg, 0.28)}`,
|
|
44467
|
+
"--pele-border": `#${mixSrgb(fg, bg, 0.45)}`,
|
|
44468
|
+
"--pele-accent": `#${style.link}`
|
|
44469
|
+
};
|
|
44470
|
+
}
|
|
44471
|
+
async function diagramPNG(code, palette) {
|
|
44472
|
+
const svg = await renderMermaid(code, { print: true, palette });
|
|
44141
44473
|
const root = new DOMParser().parseFromString(svg, "image/svg+xml").documentElement;
|
|
44142
44474
|
if (!root || root.nodeName !== "svg") return null;
|
|
44143
44475
|
const viewBox = (root.getAttribute("viewBox") ?? "").trim().split(/[\s,]+/).map(Number);
|
|
@@ -44166,7 +44498,12 @@ async function diagramPNG(code) {
|
|
|
44166
44498
|
context.drawImage(image, 0, 0, canvas.width, canvas.height);
|
|
44167
44499
|
return canvas.toDataURL("image/png");
|
|
44168
44500
|
}
|
|
44169
|
-
async function markdownForWord(markdown2, chinese
|
|
44501
|
+
async function markdownForWord(markdown2, chinese, palette = diagramPrintPalette({
|
|
44502
|
+
// 与 docx-style.ts 的 LIGHT 常量同源:没有样式令牌时(脚本/兜底场景)按浅色画。
|
|
44503
|
+
codeBlockBackground: "F6F8FA",
|
|
44504
|
+
codeBlockText: "24292F",
|
|
44505
|
+
link: "0969DA"
|
|
44506
|
+
})) {
|
|
44170
44507
|
const fences = [];
|
|
44171
44508
|
MERMAID_FENCE.lastIndex = 0;
|
|
44172
44509
|
for (let match = MERMAID_FENCE.exec(markdown2); match; match = MERMAID_FENCE.exec(markdown2)) {
|
|
@@ -44186,7 +44523,7 @@ async function markdownForWord(markdown2, chinese) {
|
|
|
44186
44523
|
for (const fence of fences) {
|
|
44187
44524
|
index2 += 1;
|
|
44188
44525
|
const name2 = `colamd-diagram-${index2}.png`;
|
|
44189
|
-
const png = await diagramPNG(fence.code).catch(() => null);
|
|
44526
|
+
const png = await diagramPNG(fence.code, palette).catch(() => null);
|
|
44190
44527
|
pieces.push(markdown2.slice(cursor, fence.start));
|
|
44191
44528
|
if (png) {
|
|
44192
44529
|
images[name2] = png;
|
|
@@ -45769,6 +46106,24 @@ window.__colamdNativeResult = (tag, payload) => {
|
|
|
45769
46106
|
function callNative(tag) {
|
|
45770
46107
|
return new Promise((resolve) => nativeResolvers.set(tag, resolve));
|
|
45771
46108
|
}
|
|
46109
|
+
window.__colamdIntentFile = (json) => {
|
|
46110
|
+
try {
|
|
46111
|
+
const parsed = JSON.parse(json);
|
|
46112
|
+
if (typeof parsed?.name === "string" && typeof parsed.content === "string") {
|
|
46113
|
+
nativeLog(`intent file received: ${parsed.name} (${parsed.content.length} chars)`);
|
|
46114
|
+
emitFileOpened(parsed.name, parsed.content);
|
|
46115
|
+
return true;
|
|
46116
|
+
}
|
|
46117
|
+
nativeLog(`intent file payload incomplete: ${JSON.stringify(parsed).slice(0, 200)}`);
|
|
46118
|
+
return false;
|
|
46119
|
+
} catch (e) {
|
|
46120
|
+
nativeLog(`intent file JSON parse failed: ${String(e)}`);
|
|
46121
|
+
return false;
|
|
46122
|
+
}
|
|
46123
|
+
};
|
|
46124
|
+
window.__colamdIntentError = (reason) => {
|
|
46125
|
+
nativeLog(`intent read failed: ${reason}`);
|
|
46126
|
+
};
|
|
45772
46127
|
function nativeBridge() {
|
|
45773
46128
|
const bridge = window.ColaMDNative;
|
|
45774
46129
|
if (!bridge || typeof bridge.printDocument !== "function") return null;
|
|
@@ -45830,13 +46185,11 @@ async function capModule(name2) {
|
|
|
45830
46185
|
try {
|
|
45831
46186
|
switch (name2) {
|
|
45832
46187
|
case "@capacitor/filesystem":
|
|
45833
|
-
return await __vitePreload(() => import("./index-
|
|
46188
|
+
return await __vitePreload(() => import("./index-C5S7E_iS.js"), true ? [] : void 0, import.meta.url);
|
|
45834
46189
|
case "@capacitor/share":
|
|
45835
|
-
return await __vitePreload(() => import("./index-
|
|
46190
|
+
return await __vitePreload(() => import("./index-DurJ4oOc.js"), true ? [] : void 0, import.meta.url);
|
|
45836
46191
|
case "@capacitor/app":
|
|
45837
|
-
return await __vitePreload(() => import("./index-
|
|
45838
|
-
case "@capawesome/capacitor-file-picker":
|
|
45839
|
-
return await __vitePreload(() => import("./index-eBhE19Gh.js"), true ? [] : void 0, import.meta.url);
|
|
46192
|
+
return await __vitePreload(() => import("./index-BQRkI4XZ.js"), true ? [] : void 0, import.meta.url);
|
|
45840
46193
|
default:
|
|
45841
46194
|
return null;
|
|
45842
46195
|
}
|
|
@@ -45857,21 +46210,13 @@ function createCapacitorAPI() {
|
|
|
45857
46210
|
const api = {
|
|
45858
46211
|
// ── 文件通道(真实现:Documents/colamd/ 虚拟路径) ──
|
|
45859
46212
|
openFile: async () => {
|
|
45860
|
-
const
|
|
45861
|
-
if (
|
|
45862
|
-
|
|
45863
|
-
|
|
45864
|
-
|
|
45865
|
-
|
|
45866
|
-
|
|
45867
|
-
else if (file.path) {
|
|
45868
|
-
const f = await fs();
|
|
45869
|
-
if (!f) return null;
|
|
45870
|
-
content2 = (await f.Filesystem.readFile({ path: file.path, directory: f.Directory.Cache })).data;
|
|
45871
|
-
}
|
|
45872
|
-
const name2 = file.name || "document.md";
|
|
45873
|
-
emitFileOpened(name2, content2);
|
|
45874
|
-
return { path: `${DOCS_DIR}/${name2}`, content: content2 };
|
|
46213
|
+
const bridge = window.ColaMDNative;
|
|
46214
|
+
if (bridge?.openFilePicker) {
|
|
46215
|
+
bridge.openFilePicker();
|
|
46216
|
+
} else {
|
|
46217
|
+
nativeLog("openFile: openFilePicker bridge unavailable");
|
|
46218
|
+
}
|
|
46219
|
+
return null;
|
|
45875
46220
|
},
|
|
45876
46221
|
openFilePath: async (path2) => {
|
|
45877
46222
|
const f = await fs();
|
|
@@ -45886,7 +46231,7 @@ function createCapacitorAPI() {
|
|
|
45886
46231
|
getFileManagerName: async () => "system",
|
|
45887
46232
|
revealFile: noopTrue,
|
|
45888
46233
|
showEntryContextMenu: noopVoid,
|
|
45889
|
-
showTabContextMenu:
|
|
46234
|
+
showTabContextMenu: async (menu) => showTabMenu(menu),
|
|
45890
46235
|
onTabMenuAction: (cb) => onEvent("tab-menu-action", cb),
|
|
45891
46236
|
listSiblings: async () => {
|
|
45892
46237
|
const f = await fs();
|
|
@@ -46255,6 +46600,70 @@ function closeMenu() {
|
|
|
46255
46600
|
if (panel) panel.classList.remove("open");
|
|
46256
46601
|
window.setTimeout(() => root.remove(), 200);
|
|
46257
46602
|
}
|
|
46603
|
+
const TAB_MENU_STYLE_ID = "cola-tab-menu-style";
|
|
46604
|
+
function ensureTabMenuStyle() {
|
|
46605
|
+
if (document.getElementById(TAB_MENU_STYLE_ID)) return;
|
|
46606
|
+
const style = document.createElement("style");
|
|
46607
|
+
style.id = TAB_MENU_STYLE_ID;
|
|
46608
|
+
style.textContent = `
|
|
46609
|
+
.cola-tcm-root { position: fixed; inset: 0; z-index: 2147483000; }
|
|
46610
|
+
.cola-tcm-panel { position: absolute; min-width: 168px; padding: 6px;
|
|
46611
|
+
background: var(--bg-color, #fff); color: var(--text-color, #222);
|
|
46612
|
+
border: 1px solid var(--border-color, #e0e0e0); border-radius: 12px;
|
|
46613
|
+
box-shadow: 0 8px 28px rgba(0, 0, 0, 0.22); font-size: 15px; }
|
|
46614
|
+
.cola-tcm-item { display: block; width: 100%; min-height: 44px; padding: 8px 14px; border: 0; border-radius: 9px;
|
|
46615
|
+
background: transparent; color: inherit; font: inherit; text-align: left; }
|
|
46616
|
+
.cola-tcm-item:active { background: color-mix(in srgb, var(--text-color) 10%, transparent); }
|
|
46617
|
+
.cola-tcm-item[disabled] { opacity: 0.4; }
|
|
46618
|
+
`;
|
|
46619
|
+
document.head.appendChild(style);
|
|
46620
|
+
}
|
|
46621
|
+
let tabMenuEl = null;
|
|
46622
|
+
function closeTabMenu() {
|
|
46623
|
+
tabMenuEl?.remove();
|
|
46624
|
+
tabMenuEl = null;
|
|
46625
|
+
}
|
|
46626
|
+
function showTabMenu(menu) {
|
|
46627
|
+
closeTabMenu();
|
|
46628
|
+
ensureTabMenuStyle();
|
|
46629
|
+
const zh = isChinese();
|
|
46630
|
+
const root = document.createElement("div");
|
|
46631
|
+
root.className = "cola-tcm-root";
|
|
46632
|
+
const panel = document.createElement("div");
|
|
46633
|
+
panel.className = "cola-tcm-panel";
|
|
46634
|
+
const items = [
|
|
46635
|
+
{ label: zh ? "关闭" : "Close", action: "close", disabled: false },
|
|
46636
|
+
{ label: zh ? "关闭其他" : "Close others", action: "close-others", disabled: !menu.canCloseOthers },
|
|
46637
|
+
{ label: zh ? "关闭右侧" : "Close to the right", action: "close-right", disabled: !menu.canCloseRight }
|
|
46638
|
+
];
|
|
46639
|
+
for (const item of items) {
|
|
46640
|
+
const btn = document.createElement("button");
|
|
46641
|
+
btn.type = "button";
|
|
46642
|
+
btn.className = "cola-tcm-item";
|
|
46643
|
+
btn.textContent = item.label;
|
|
46644
|
+
if (item.disabled) btn.disabled = true;
|
|
46645
|
+
btn.addEventListener("click", () => {
|
|
46646
|
+
closeTabMenu();
|
|
46647
|
+
emitEvent("tab-menu-action", { action: item.action, tabId: menu.tabId });
|
|
46648
|
+
});
|
|
46649
|
+
panel.appendChild(btn);
|
|
46650
|
+
}
|
|
46651
|
+
panel.addEventListener("click", (e) => e.stopPropagation());
|
|
46652
|
+
root.addEventListener("click", closeTabMenu);
|
|
46653
|
+
root.appendChild(panel);
|
|
46654
|
+
document.body.appendChild(root);
|
|
46655
|
+
tabMenuEl = root;
|
|
46656
|
+
const entry = document.querySelector(`.tab-entry[data-tab-id="${menu.tabId}"]`);
|
|
46657
|
+
const rect = entry?.getBoundingClientRect();
|
|
46658
|
+
const pw = panel.offsetWidth;
|
|
46659
|
+
if (rect) {
|
|
46660
|
+
panel.style.left = `${Math.round(Math.min(Math.max(8, rect.left + rect.width / 2 - pw / 2), window.innerWidth - pw - 8))}px`;
|
|
46661
|
+
panel.style.top = `${Math.round(rect.bottom + 4)}px`;
|
|
46662
|
+
} else {
|
|
46663
|
+
panel.style.left = `${Math.round((window.innerWidth - pw) / 2)}px`;
|
|
46664
|
+
panel.style.top = "80px";
|
|
46665
|
+
}
|
|
46666
|
+
}
|
|
46258
46667
|
installCapacitorAPI();
|
|
46259
46668
|
startIntentPolling();
|
|
46260
46669
|
if (isAndroidApp()) {
|
|
@@ -46545,10 +46954,16 @@ function plusGlyph() {
|
|
|
46545
46954
|
return svg;
|
|
46546
46955
|
}
|
|
46547
46956
|
function renderTabBar() {
|
|
46957
|
+
if (isAndroidApp()) {
|
|
46958
|
+
tabBarEl().hidden = true;
|
|
46959
|
+
return;
|
|
46960
|
+
}
|
|
46548
46961
|
captureActiveTab();
|
|
46549
46962
|
const bar = tabBarEl();
|
|
46550
46963
|
bar.hidden = false;
|
|
46551
|
-
|
|
46964
|
+
if (!isAndroidApp()) {
|
|
46965
|
+
document.documentElement.style.setProperty("--tab-bar-height", "0px");
|
|
46966
|
+
}
|
|
46552
46967
|
document.documentElement.style.setProperty("--editor-top-gap", "0px");
|
|
46553
46968
|
bar.innerHTML = "";
|
|
46554
46969
|
hideTabTip();
|
|
@@ -47637,7 +48052,7 @@ async function init() {
|
|
|
47637
48052
|
const style = readDocxStyle();
|
|
47638
48053
|
const html2 = await markdownWithHtmlImages(getContent(), `#${style.text}`);
|
|
47639
48054
|
const math2 = await markdownWithMathImages(html2.content, isChinese$1(), `#${style.text}`);
|
|
47640
|
-
const payload = await markdownForWord(math2.content, isChinese$1());
|
|
48055
|
+
const payload = await markdownForWord(math2.content, isChinese$1(), diagramPrintPalette(style));
|
|
47641
48056
|
await api.exportDOCX({
|
|
47642
48057
|
content: payload.content,
|
|
47643
48058
|
images: { ...html2.images, ...math2.images, ...payload.images },
|