schematex 0.2.0 → 0.2.3
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 +1 -1
- package/dist/ai/ai-sdk.cjs +85 -0
- package/dist/ai/ai-sdk.cjs.map +1 -0
- package/dist/ai/ai-sdk.d.cts +30 -0
- package/dist/ai/ai-sdk.d.ts +30 -0
- package/dist/ai/ai-sdk.js +83 -0
- package/dist/ai/ai-sdk.js.map +1 -0
- package/dist/ai/index.cjs +60 -0
- package/dist/ai/index.cjs.map +1 -0
- package/dist/ai/index.d.cts +155 -0
- package/dist/ai/index.d.ts +155 -0
- package/dist/ai/index.js +23 -0
- package/dist/ai/index.js.map +1 -0
- package/dist/browser.cjs +22 -21
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.js +20 -19
- package/dist/browser.js.map +1 -1
- package/dist/{chunk-HLYA4QBB.js → chunk-2BM3HJSK.js} +545 -101
- package/dist/chunk-2BM3HJSK.js.map +1 -0
- package/dist/{chunk-ZO77FHBF.cjs → chunk-2JDVJRR3.cjs} +14 -6
- package/dist/chunk-2JDVJRR3.cjs.map +1 -0
- package/dist/{chunk-TIGP2OEJ.js → chunk-2VNMKOUO.js} +20 -5
- package/dist/chunk-2VNMKOUO.js.map +1 -0
- package/dist/{chunk-ULERCTGS.cjs → chunk-3YZ6FPQW.cjs} +36 -30
- package/dist/chunk-3YZ6FPQW.cjs.map +1 -0
- package/dist/{chunk-GEPBET4L.js → chunk-45KP67RR.js} +14 -6
- package/dist/chunk-45KP67RR.js.map +1 -0
- package/dist/chunk-4QP37LD3.js +1112 -0
- package/dist/chunk-4QP37LD3.js.map +1 -0
- package/dist/{chunk-HKRYKEOV.cjs → chunk-4S2WILLW.cjs} +4 -4
- package/dist/{chunk-HKRYKEOV.cjs.map → chunk-4S2WILLW.cjs.map} +1 -1
- package/dist/{chunk-IMHR3S5H.cjs → chunk-5AEN2PLB.cjs} +17 -9
- package/dist/chunk-5AEN2PLB.cjs.map +1 -0
- package/dist/{chunk-SPIW4VWP.js → chunk-5YYAYW67.js} +3 -3
- package/dist/{chunk-SPIW4VWP.js.map → chunk-5YYAYW67.js.map} +1 -1
- package/dist/{chunk-CEV3GZA3.cjs → chunk-6LZJTAA3.cjs} +552 -108
- package/dist/chunk-6LZJTAA3.cjs.map +1 -0
- package/dist/{chunk-IY52OWPG.cjs → chunk-A5D2IMOX.cjs} +18 -10
- package/dist/chunk-A5D2IMOX.cjs.map +1 -0
- package/dist/{chunk-AMP2FFES.cjs → chunk-B37IKTI7.cjs} +229 -52
- package/dist/chunk-B37IKTI7.cjs.map +1 -0
- package/dist/{chunk-LKHWBDWZ.cjs → chunk-B6INLQBU.cjs} +17 -11
- package/dist/chunk-B6INLQBU.cjs.map +1 -0
- package/dist/{chunk-DTMCQXXC.cjs → chunk-COLTVQWR.cjs} +184 -16
- package/dist/chunk-COLTVQWR.cjs.map +1 -0
- package/dist/{chunk-S6VPECM3.cjs → chunk-D7EHZFK4.cjs} +20 -5
- package/dist/chunk-D7EHZFK4.cjs.map +1 -0
- package/dist/chunk-DNZFOCV7.js +796 -0
- package/dist/chunk-DNZFOCV7.js.map +1 -0
- package/dist/{chunk-ZGKEFVJQ.cjs → chunk-E65ITQXV.cjs} +188 -32
- package/dist/chunk-E65ITQXV.cjs.map +1 -0
- package/dist/{chunk-7WXAAVR3.js → chunk-FCGHV6ZK.js} +17 -9
- package/dist/chunk-FCGHV6ZK.js.map +1 -0
- package/dist/{chunk-A74ZCP5I.js → chunk-FE6GAUNW.js} +36 -30
- package/dist/chunk-FE6GAUNW.js.map +1 -0
- package/dist/{chunk-MXJ6FHSY.js → chunk-JDTB7IKL.js} +3 -3
- package/dist/{chunk-MXJ6FHSY.js.map → chunk-JDTB7IKL.js.map} +1 -1
- package/dist/{chunk-RQX53J6M.js → chunk-LR4X4ZRG.js} +180 -24
- package/dist/chunk-LR4X4ZRG.js.map +1 -0
- package/dist/{chunk-MRGS54WN.js → chunk-M5B2UUNW.js} +3 -3
- package/dist/{chunk-MRGS54WN.js.map → chunk-M5B2UUNW.js.map} +1 -1
- package/dist/{chunk-LXNFVHDT.cjs → chunk-MCFQAUQV.cjs} +21 -13
- package/dist/chunk-MCFQAUQV.cjs.map +1 -0
- package/dist/chunk-MOU5QRZY.cjs +1121 -0
- package/dist/chunk-MOU5QRZY.cjs.map +1 -0
- package/dist/{chunk-TPA36ULU.js → chunk-OC22GGQN.js} +223 -46
- package/dist/chunk-OC22GGQN.js.map +1 -0
- package/dist/{chunk-2OIW3MAE.js → chunk-PGALHQFF.js} +3 -3
- package/dist/{chunk-2OIW3MAE.js.map → chunk-PGALHQFF.js.map} +1 -1
- package/dist/{chunk-3M7QWADF.cjs → chunk-QSQX77S2.cjs} +4 -4
- package/dist/{chunk-3M7QWADF.cjs.map → chunk-QSQX77S2.cjs.map} +1 -1
- package/dist/{chunk-VP54YPOX.cjs → chunk-QXIGHMH2.cjs} +498 -177
- package/dist/chunk-QXIGHMH2.cjs.map +1 -0
- package/dist/{chunk-YO4GU6JX.js → chunk-RP5UATRA.js} +175 -7
- package/dist/chunk-RP5UATRA.js.map +1 -0
- package/dist/{chunk-M6AMNXQ7.js → chunk-S3RBKJM5.js} +478 -157
- package/dist/chunk-S3RBKJM5.js.map +1 -0
- package/dist/{chunk-JZGFSRVT.js → chunk-SN7NTZI6.js} +9 -7
- package/dist/chunk-SN7NTZI6.js.map +1 -0
- package/dist/{chunk-L6IHSTPP.js → chunk-U6L3FAML.js} +16 -10
- package/dist/chunk-U6L3FAML.js.map +1 -0
- package/dist/{chunk-5SH5NUDW.js → chunk-UGCUNADI.js} +21 -13
- package/dist/chunk-UGCUNADI.js.map +1 -0
- package/dist/chunk-ULYRO2KY.cjs +800 -0
- package/dist/chunk-ULYRO2KY.cjs.map +1 -0
- package/dist/{chunk-4HPT4BOI.cjs → chunk-WYFXOXVK.cjs} +4 -4
- package/dist/{chunk-4HPT4BOI.cjs.map → chunk-WYFXOXVK.cjs.map} +1 -1
- package/dist/{chunk-YKO7DY2F.cjs → chunk-X7RPFTTR.cjs} +13 -13
- package/dist/{chunk-YKO7DY2F.cjs.map → chunk-X7RPFTTR.cjs.map} +1 -1
- package/dist/{chunk-4TS5NB7L.js → chunk-YQANC7HQ.js} +3 -3
- package/dist/{chunk-4TS5NB7L.js.map → chunk-YQANC7HQ.js.map} +1 -1
- package/dist/{chunk-HAIBAF6J.cjs → chunk-Z3DE6S64.cjs} +10 -8
- package/dist/chunk-Z3DE6S64.cjs.map +1 -0
- package/dist/{chunk-IQIJ6WW6.js → chunk-ZNDIGQJD.js} +15 -7
- package/dist/chunk-ZNDIGQJD.js.map +1 -0
- package/dist/{chunk-PIQG2Z5N.cjs → chunk-ZNOD4VZT.cjs} +4 -4
- package/dist/{chunk-PIQG2Z5N.cjs.map → chunk-ZNOD4VZT.cjs.map} +1 -1
- package/dist/diagrams/blockdiagram/index.cjs +5 -5
- package/dist/diagrams/blockdiagram/index.d.cts +1 -1
- package/dist/diagrams/blockdiagram/index.d.ts +1 -1
- package/dist/diagrams/blockdiagram/index.js +1 -1
- package/dist/diagrams/circuit/index.cjs +8 -8
- package/dist/diagrams/circuit/index.d.cts +1 -1
- package/dist/diagrams/circuit/index.d.ts +1 -1
- package/dist/diagrams/circuit/index.js +2 -2
- package/dist/diagrams/ecomap/index.cjs +8 -7
- package/dist/diagrams/ecomap/index.d.cts +2 -2
- package/dist/diagrams/ecomap/index.d.ts +2 -2
- package/dist/diagrams/ecomap/index.js +3 -2
- package/dist/diagrams/entity/index.cjs +6 -6
- package/dist/diagrams/entity/index.d.cts +1 -1
- package/dist/diagrams/entity/index.d.ts +1 -1
- package/dist/diagrams/entity/index.js +2 -2
- package/dist/diagrams/fishbone/index.cjs +8 -8
- package/dist/diagrams/fishbone/index.d.cts +1 -1
- package/dist/diagrams/fishbone/index.d.ts +1 -1
- package/dist/diagrams/fishbone/index.js +2 -2
- package/dist/diagrams/flowchart/index.cjs +8 -8
- package/dist/diagrams/flowchart/index.d.cts +2 -2
- package/dist/diagrams/flowchart/index.d.ts +2 -2
- package/dist/diagrams/flowchart/index.js +2 -2
- package/dist/diagrams/genogram/index.cjs +10 -9
- package/dist/diagrams/genogram/index.d.cts +1 -1
- package/dist/diagrams/genogram/index.d.ts +1 -1
- package/dist/diagrams/genogram/index.js +3 -2
- package/dist/diagrams/ladder/index.cjs +6 -6
- package/dist/diagrams/ladder/index.d.cts +1 -1
- package/dist/diagrams/ladder/index.d.ts +1 -1
- package/dist/diagrams/ladder/index.js +2 -2
- package/dist/diagrams/logic/index.cjs +6 -6
- package/dist/diagrams/logic/index.d.cts +1 -1
- package/dist/diagrams/logic/index.d.ts +1 -1
- package/dist/diagrams/logic/index.js +2 -2
- package/dist/diagrams/orgchart/index.cjs +7 -7
- package/dist/diagrams/orgchart/index.d.cts +5 -2
- package/dist/diagrams/orgchart/index.d.ts +5 -2
- package/dist/diagrams/orgchart/index.js +2 -2
- package/dist/diagrams/pedigree/index.cjs +8 -7
- package/dist/diagrams/pedigree/index.d.cts +1 -1
- package/dist/diagrams/pedigree/index.d.ts +1 -1
- package/dist/diagrams/pedigree/index.js +3 -2
- package/dist/diagrams/phylo/index.cjs +7 -7
- package/dist/diagrams/phylo/index.d.cts +1 -1
- package/dist/diagrams/phylo/index.d.ts +1 -1
- package/dist/diagrams/phylo/index.js +2 -2
- package/dist/diagrams/sld/index.cjs +6 -6
- package/dist/diagrams/sld/index.d.cts +1 -1
- package/dist/diagrams/sld/index.d.ts +1 -1
- package/dist/diagrams/sld/index.js +2 -2
- package/dist/diagrams/sociogram/index.cjs +7 -6
- package/dist/diagrams/sociogram/index.d.cts +2 -1
- package/dist/diagrams/sociogram/index.d.ts +2 -1
- package/dist/diagrams/sociogram/index.js +3 -2
- package/dist/diagrams/timing/index.cjs +4 -4
- package/dist/diagrams/timing/index.d.cts +1 -1
- package/dist/diagrams/timing/index.d.ts +1 -1
- package/dist/diagrams/timing/index.js +1 -1
- package/dist/diagrams/venn/index.cjs +9 -9
- package/dist/diagrams/venn/index.d.cts +1 -1
- package/dist/diagrams/venn/index.d.ts +1 -1
- package/dist/diagrams/venn/index.js +2 -2
- package/dist/{index-ga04CTBI.d.ts → index-C97K-kuw.d.ts} +1 -1
- package/dist/{index-SSGpCggE.d.cts → index-lsSaw3E0.d.cts} +1 -1
- package/dist/index.cjs +50 -49
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +19 -18
- package/dist/react.cjs +20 -19
- package/dist/react.cjs.map +1 -1
- package/dist/react.js +19 -18
- package/dist/react.js.map +1 -1
- package/dist/{types-BcPhMdHd.d.cts → types-C4LnMEcB.d.cts} +58 -4
- package/dist/{types-BcPhMdHd.d.ts → types-C4LnMEcB.d.ts} +58 -4
- package/package.json +30 -7
- package/dist/chunk-5SH5NUDW.js.map +0 -1
- package/dist/chunk-7WXAAVR3.js.map +0 -1
- package/dist/chunk-A74ZCP5I.js.map +0 -1
- package/dist/chunk-AMP2FFES.cjs.map +0 -1
- package/dist/chunk-CEV3GZA3.cjs.map +0 -1
- package/dist/chunk-DTMCQXXC.cjs.map +0 -1
- package/dist/chunk-GEPBET4L.js.map +0 -1
- package/dist/chunk-HAIBAF6J.cjs.map +0 -1
- package/dist/chunk-HLYA4QBB.js.map +0 -1
- package/dist/chunk-IMHR3S5H.cjs.map +0 -1
- package/dist/chunk-IQIJ6WW6.js.map +0 -1
- package/dist/chunk-IY52OWPG.cjs.map +0 -1
- package/dist/chunk-JZGFSRVT.js.map +0 -1
- package/dist/chunk-L6IHSTPP.js.map +0 -1
- package/dist/chunk-LKHWBDWZ.cjs.map +0 -1
- package/dist/chunk-LXNFVHDT.cjs.map +0 -1
- package/dist/chunk-M6AMNXQ7.js.map +0 -1
- package/dist/chunk-RQX53J6M.js.map +0 -1
- package/dist/chunk-S6VPECM3.cjs.map +0 -1
- package/dist/chunk-TIGP2OEJ.js.map +0 -1
- package/dist/chunk-TPA36ULU.js.map +0 -1
- package/dist/chunk-ULERCTGS.cjs.map +0 -1
- package/dist/chunk-VP54YPOX.cjs.map +0 -1
- package/dist/chunk-YO4GU6JX.js.map +0 -1
- package/dist/chunk-ZGKEFVJQ.cjs.map +0 -1
- package/dist/chunk-ZO77FHBF.cjs.map +0 -1
|
@@ -1,30 +1,34 @@
|
|
|
1
|
-
import { orgchart } from './chunk-
|
|
2
|
-
import { circuit } from './chunk-
|
|
3
|
-
import { blockdiagram } from './chunk-
|
|
4
|
-
import { ladder } from './chunk-
|
|
5
|
-
import { sld } from './chunk-
|
|
6
|
-
import { entity } from './chunk-
|
|
7
|
-
import { fishbone } from './chunk-
|
|
8
|
-
import { venn } from './chunk-
|
|
9
|
-
import { flowchart } from './chunk-
|
|
10
|
-
import { genogram } from './chunk-
|
|
11
|
-
import { ecomap } from './chunk-
|
|
12
|
-
import { pedigree } from './chunk-
|
|
13
|
-
import { phylo } from './chunk-
|
|
14
|
-
import { sociogram } from './chunk-
|
|
15
|
-
import { timing } from './chunk-
|
|
16
|
-
import { logic } from './chunk-
|
|
17
|
-
import { resolveBaseTheme, resolveTimelineTheme, cssCustomProperties, resolveMindmapTheme } from './chunk-
|
|
1
|
+
import { orgchart } from './chunk-FCGHV6ZK.js';
|
|
2
|
+
import { circuit } from './chunk-PGALHQFF.js';
|
|
3
|
+
import { blockdiagram } from './chunk-UGCUNADI.js';
|
|
4
|
+
import { ladder } from './chunk-U6L3FAML.js';
|
|
5
|
+
import { sld } from './chunk-FE6GAUNW.js';
|
|
6
|
+
import { entity } from './chunk-M5B2UUNW.js';
|
|
7
|
+
import { fishbone } from './chunk-ZNDIGQJD.js';
|
|
8
|
+
import { venn } from './chunk-JDTB7IKL.js';
|
|
9
|
+
import { flowchart } from './chunk-SN7NTZI6.js';
|
|
10
|
+
import { genogram } from './chunk-2BM3HJSK.js';
|
|
11
|
+
import { ecomap } from './chunk-LR4X4ZRG.js';
|
|
12
|
+
import { pedigree } from './chunk-OC22GGQN.js';
|
|
13
|
+
import { phylo } from './chunk-YQANC7HQ.js';
|
|
14
|
+
import { sociogram } from './chunk-RP5UATRA.js';
|
|
15
|
+
import { timing } from './chunk-45KP67RR.js';
|
|
16
|
+
import { logic } from './chunk-5YYAYW67.js';
|
|
17
|
+
import { resolveBaseTheme, resolveTimelineTheme, cssCustomProperties, resolveMindmapTheme } from './chunk-2VNMKOUO.js';
|
|
18
18
|
import { title, desc, el, text, path, rect, group, svgRoot, escapeXml, defs, circle, polygon, line } from './chunk-KLJEK547.js';
|
|
19
19
|
|
|
20
20
|
// src/diagrams/decisiontree/parser.ts
|
|
21
21
|
var DTreeParseError = class extends Error {
|
|
22
|
-
constructor(message, line2) {
|
|
22
|
+
constructor(message, line2, column, source) {
|
|
23
23
|
super(line2 !== void 0 ? `Line ${line2}: ${message}` : message);
|
|
24
24
|
this.line = line2;
|
|
25
|
+
this.column = column;
|
|
26
|
+
this.source = source;
|
|
25
27
|
this.name = "DTreeParseError";
|
|
26
28
|
}
|
|
27
29
|
line;
|
|
30
|
+
column;
|
|
31
|
+
source;
|
|
28
32
|
};
|
|
29
33
|
function preprocess(src) {
|
|
30
34
|
const out = [];
|
|
@@ -1225,12 +1229,16 @@ function formatYear(value, span) {
|
|
|
1225
1229
|
|
|
1226
1230
|
// src/diagrams/timeline/parser.ts
|
|
1227
1231
|
var TimelineParseError = class extends Error {
|
|
1228
|
-
constructor(message, line2) {
|
|
1232
|
+
constructor(message, line2, column, source) {
|
|
1229
1233
|
super(line2 !== void 0 ? `Line ${line2}: ${message}` : message);
|
|
1230
1234
|
this.line = line2;
|
|
1235
|
+
this.column = column;
|
|
1236
|
+
this.source = source;
|
|
1231
1237
|
this.name = "TimelineParseError";
|
|
1232
1238
|
}
|
|
1233
1239
|
line;
|
|
1240
|
+
column;
|
|
1241
|
+
source;
|
|
1234
1242
|
};
|
|
1235
1243
|
function preprocess2(src) {
|
|
1236
1244
|
const out = [];
|
|
@@ -2618,8 +2626,193 @@ var timeline = {
|
|
|
2618
2626
|
}
|
|
2619
2627
|
};
|
|
2620
2628
|
|
|
2629
|
+
// src/diagrams/mindmap/inline.ts
|
|
2630
|
+
var RE_TASK = /^\[( |x|X)\]\s+(.*)$/;
|
|
2631
|
+
function tokenizeInline(raw) {
|
|
2632
|
+
const tokens = [];
|
|
2633
|
+
let text2 = raw;
|
|
2634
|
+
const task = text2.match(RE_TASK);
|
|
2635
|
+
if (task) {
|
|
2636
|
+
tokens.push({ kind: "checkbox", checked: task[1].toLowerCase() === "x" });
|
|
2637
|
+
text2 = task[2];
|
|
2638
|
+
}
|
|
2639
|
+
parseInto(text2, tokens, { bold: false, italic: false });
|
|
2640
|
+
return tokens;
|
|
2641
|
+
}
|
|
2642
|
+
function parseInto(src, out, style) {
|
|
2643
|
+
let i = 0;
|
|
2644
|
+
let plain = "";
|
|
2645
|
+
const flushPlain = () => {
|
|
2646
|
+
if (plain.length === 0) return;
|
|
2647
|
+
out.push({ kind: "text", value: plain, bold: style.bold || void 0, italic: style.italic || void 0 });
|
|
2648
|
+
plain = "";
|
|
2649
|
+
};
|
|
2650
|
+
while (i < src.length) {
|
|
2651
|
+
const ch = src[i];
|
|
2652
|
+
if (ch === "`") {
|
|
2653
|
+
const end = src.indexOf("`", i + 1);
|
|
2654
|
+
if (end > i) {
|
|
2655
|
+
flushPlain();
|
|
2656
|
+
out.push({ kind: "code", value: src.slice(i + 1, end) });
|
|
2657
|
+
i = end + 1;
|
|
2658
|
+
continue;
|
|
2659
|
+
}
|
|
2660
|
+
}
|
|
2661
|
+
if (ch === "[") {
|
|
2662
|
+
const closeBracket = findUnescaped(src, "]", i + 1);
|
|
2663
|
+
if (closeBracket > 0 && src[closeBracket + 1] === "(") {
|
|
2664
|
+
const closeParen = findUnescaped(src, ")", closeBracket + 2);
|
|
2665
|
+
if (closeParen > 0) {
|
|
2666
|
+
flushPlain();
|
|
2667
|
+
const inner = [];
|
|
2668
|
+
parseInto(src.slice(i + 1, closeBracket), inner, style);
|
|
2669
|
+
out.push({ kind: "link", href: src.slice(closeBracket + 2, closeParen), value: inner });
|
|
2670
|
+
i = closeParen + 1;
|
|
2671
|
+
continue;
|
|
2672
|
+
}
|
|
2673
|
+
}
|
|
2674
|
+
}
|
|
2675
|
+
if (ch === "*" && src[i + 1] === "*") {
|
|
2676
|
+
const end = src.indexOf("**", i + 2);
|
|
2677
|
+
if (end > i) {
|
|
2678
|
+
flushPlain();
|
|
2679
|
+
parseInto(src.slice(i + 2, end), out, { ...style, bold: true });
|
|
2680
|
+
i = end + 2;
|
|
2681
|
+
continue;
|
|
2682
|
+
}
|
|
2683
|
+
}
|
|
2684
|
+
if (ch === "*") {
|
|
2685
|
+
const end = src.indexOf("*", i + 1);
|
|
2686
|
+
if (end > i && src[end + 1] !== "*") {
|
|
2687
|
+
flushPlain();
|
|
2688
|
+
parseInto(src.slice(i + 1, end), out, { ...style, italic: true });
|
|
2689
|
+
i = end + 1;
|
|
2690
|
+
continue;
|
|
2691
|
+
}
|
|
2692
|
+
}
|
|
2693
|
+
plain += ch;
|
|
2694
|
+
i++;
|
|
2695
|
+
}
|
|
2696
|
+
flushPlain();
|
|
2697
|
+
}
|
|
2698
|
+
function findUnescaped(s, ch, from) {
|
|
2699
|
+
for (let i = from; i < s.length; i++) {
|
|
2700
|
+
if (s[i] === "\\") {
|
|
2701
|
+
i++;
|
|
2702
|
+
continue;
|
|
2703
|
+
}
|
|
2704
|
+
if (s[i] === ch) return i;
|
|
2705
|
+
}
|
|
2706
|
+
return -1;
|
|
2707
|
+
}
|
|
2708
|
+
var EM_REGULAR = 0.58;
|
|
2709
|
+
var EM_BOLD = 0.62;
|
|
2710
|
+
var EM_CODE = 0.62;
|
|
2711
|
+
var CHECKBOX_EM = 1.05;
|
|
2712
|
+
function measureTokens(tokens, fontSize) {
|
|
2713
|
+
let w = 0;
|
|
2714
|
+
for (const t of tokens) {
|
|
2715
|
+
w += tokenWidth(t, fontSize);
|
|
2716
|
+
}
|
|
2717
|
+
return w;
|
|
2718
|
+
}
|
|
2719
|
+
function tokenWidth(t, fs) {
|
|
2720
|
+
switch (t.kind) {
|
|
2721
|
+
case "text": {
|
|
2722
|
+
const em = t.bold ? EM_BOLD : EM_REGULAR;
|
|
2723
|
+
return t.value.length * fs * em;
|
|
2724
|
+
}
|
|
2725
|
+
case "code":
|
|
2726
|
+
return t.value.length * fs * EM_CODE + 4;
|
|
2727
|
+
case "link":
|
|
2728
|
+
return measureTokens(t.value, fs);
|
|
2729
|
+
case "checkbox":
|
|
2730
|
+
return fs * CHECKBOX_EM;
|
|
2731
|
+
}
|
|
2732
|
+
}
|
|
2733
|
+
function tokensToPlainText(tokens) {
|
|
2734
|
+
let out = "";
|
|
2735
|
+
for (const t of tokens) {
|
|
2736
|
+
switch (t.kind) {
|
|
2737
|
+
case "text":
|
|
2738
|
+
case "code":
|
|
2739
|
+
out += t.value;
|
|
2740
|
+
break;
|
|
2741
|
+
case "link":
|
|
2742
|
+
out += tokensToPlainText(t.value);
|
|
2743
|
+
break;
|
|
2744
|
+
case "checkbox":
|
|
2745
|
+
out += t.checked ? "[x] " : "[ ] ";
|
|
2746
|
+
break;
|
|
2747
|
+
}
|
|
2748
|
+
}
|
|
2749
|
+
return out;
|
|
2750
|
+
}
|
|
2751
|
+
function wrapTokens(tokens, maxWidth, fontSize) {
|
|
2752
|
+
const lines = [];
|
|
2753
|
+
let line2 = [];
|
|
2754
|
+
let lineW = 0;
|
|
2755
|
+
const pushLine = () => {
|
|
2756
|
+
lines.push({ tokens: line2, width: lineW });
|
|
2757
|
+
line2 = [];
|
|
2758
|
+
lineW = 0;
|
|
2759
|
+
};
|
|
2760
|
+
const pushAtomic = (t, w) => {
|
|
2761
|
+
if (lineW > 0 && lineW + w > maxWidth) pushLine();
|
|
2762
|
+
line2.push(t);
|
|
2763
|
+
lineW += w;
|
|
2764
|
+
};
|
|
2765
|
+
for (const t of tokens) {
|
|
2766
|
+
if (t.kind === "text") {
|
|
2767
|
+
const words = splitWordsWithTrailingSpace(t.value);
|
|
2768
|
+
for (const w of words) {
|
|
2769
|
+
const wt = { kind: "text", value: w, bold: t.bold, italic: t.italic };
|
|
2770
|
+
const ww = tokenWidth(wt, fontSize);
|
|
2771
|
+
if (lineW > 0 && lineW + ww > maxWidth) {
|
|
2772
|
+
pushLine();
|
|
2773
|
+
const trimmed = w.replace(/^ +/, "");
|
|
2774
|
+
if (trimmed.length === 0) continue;
|
|
2775
|
+
const tt = { kind: "text", value: trimmed, bold: t.bold, italic: t.italic };
|
|
2776
|
+
line2.push(tt);
|
|
2777
|
+
lineW = tokenWidth(tt, fontSize);
|
|
2778
|
+
} else {
|
|
2779
|
+
line2.push(wt);
|
|
2780
|
+
lineW += ww;
|
|
2781
|
+
}
|
|
2782
|
+
}
|
|
2783
|
+
} else {
|
|
2784
|
+
pushAtomic(t, tokenWidth(t, fontSize));
|
|
2785
|
+
}
|
|
2786
|
+
}
|
|
2787
|
+
pushLine();
|
|
2788
|
+
return lines;
|
|
2789
|
+
}
|
|
2790
|
+
function splitWordsWithTrailingSpace(s) {
|
|
2791
|
+
if (s.length === 0) return [];
|
|
2792
|
+
const out = [];
|
|
2793
|
+
const re = /(\S+\s*)|(\s+)/g;
|
|
2794
|
+
let m;
|
|
2795
|
+
while ((m = re.exec(s)) !== null) {
|
|
2796
|
+
out.push(m[0]);
|
|
2797
|
+
}
|
|
2798
|
+
return out.length > 0 ? out : [s];
|
|
2799
|
+
}
|
|
2800
|
+
|
|
2621
2801
|
// src/diagrams/mindmap/parser.ts
|
|
2802
|
+
var MindmapParseError = class extends Error {
|
|
2803
|
+
constructor(message, line2, column, source) {
|
|
2804
|
+
super(line2 !== void 0 ? `Line ${line2}: ${message}` : message);
|
|
2805
|
+
this.line = line2;
|
|
2806
|
+
this.column = column;
|
|
2807
|
+
this.source = source;
|
|
2808
|
+
this.name = "MindmapParseError";
|
|
2809
|
+
}
|
|
2810
|
+
line;
|
|
2811
|
+
column;
|
|
2812
|
+
source;
|
|
2813
|
+
};
|
|
2622
2814
|
var VALID_STYLES = ["map", "logic-right"];
|
|
2815
|
+
var DEFAULT_MAX_LABEL_WIDTH = 240;
|
|
2623
2816
|
function parseDirective(line2, out) {
|
|
2624
2817
|
const body = line2.replace(/^%%\s*/, "").trim();
|
|
2625
2818
|
const idx = body.indexOf(":");
|
|
@@ -2630,26 +2823,39 @@ function parseDirective(line2, out) {
|
|
|
2630
2823
|
out.style = val;
|
|
2631
2824
|
} else if (key === "theme") {
|
|
2632
2825
|
out.themeOverride = val;
|
|
2826
|
+
} else if (key === "maxlabelwidth") {
|
|
2827
|
+
const n = Number(val);
|
|
2828
|
+
if (Number.isFinite(n) && n >= 80 && n <= 1e3) out.maxLabelWidth = n;
|
|
2633
2829
|
}
|
|
2634
2830
|
}
|
|
2831
|
+
function makeNode(id, label, depth) {
|
|
2832
|
+
return { id, label, tokens: tokenizeInline(label), depth, children: [] };
|
|
2833
|
+
}
|
|
2635
2834
|
function parseMindmap(text2) {
|
|
2636
|
-
const
|
|
2637
|
-
|
|
2638
|
-
|
|
2835
|
+
const allLines = text2.split(/\r?\n/);
|
|
2836
|
+
let lineOffset = 0;
|
|
2837
|
+
if (allLines[0]?.trim().toLowerCase() === "mindmap") {
|
|
2838
|
+
allLines.shift();
|
|
2839
|
+
lineOffset = 1;
|
|
2840
|
+
}
|
|
2841
|
+
const lines = allLines;
|
|
2842
|
+
const directives = { style: "map", maxLabelWidth: DEFAULT_MAX_LABEL_WIDTH };
|
|
2639
2843
|
let root = null;
|
|
2640
2844
|
let idCounter2 = 0;
|
|
2641
2845
|
const nextId2 = () => `n${idCounter2++}`;
|
|
2642
2846
|
const stack = [];
|
|
2643
2847
|
let lastHeadingDepth = 0;
|
|
2644
|
-
const attach = (node, depth) => {
|
|
2848
|
+
const attach = (node, depth, lineNo, source) => {
|
|
2645
2849
|
while (stack.length && stack[stack.length - 1].depth >= depth) stack.pop();
|
|
2646
2850
|
const parent = stack[stack.length - 1]?.node;
|
|
2647
|
-
if (!parent) throw new
|
|
2851
|
+
if (!parent) throw new MindmapParseError("orphan node \u2014 expected root # heading first", lineNo, void 0, source);
|
|
2648
2852
|
node.depth = parent.depth + 1;
|
|
2649
2853
|
parent.children.push(node);
|
|
2650
2854
|
stack.push({ node, depth });
|
|
2651
2855
|
};
|
|
2652
|
-
for (
|
|
2856
|
+
for (let i = 0; i < lines.length; i++) {
|
|
2857
|
+
const raw = lines[i] ?? "";
|
|
2858
|
+
const lineNo = i + 1 + lineOffset;
|
|
2653
2859
|
const line2 = raw.replace(/\s+$/, "");
|
|
2654
2860
|
const trimmed = line2.trim();
|
|
2655
2861
|
if (!trimmed) continue;
|
|
@@ -2661,14 +2867,14 @@ function parseMindmap(text2) {
|
|
|
2661
2867
|
if (heading) {
|
|
2662
2868
|
const depth = heading[1].length - 1;
|
|
2663
2869
|
const label = heading[2].trim();
|
|
2664
|
-
const node =
|
|
2870
|
+
const node = makeNode(nextId2(), label, depth);
|
|
2665
2871
|
if (depth === 0) {
|
|
2666
|
-
if (root) throw new
|
|
2872
|
+
if (root) throw new MindmapParseError("multiple `#` center nodes not allowed", lineNo, void 0, line2);
|
|
2667
2873
|
root = node;
|
|
2668
2874
|
stack.length = 0;
|
|
2669
2875
|
stack.push({ node, depth: 0 });
|
|
2670
2876
|
} else {
|
|
2671
|
-
attach(node, depth);
|
|
2877
|
+
attach(node, depth, lineNo, line2);
|
|
2672
2878
|
}
|
|
2673
2879
|
lastHeadingDepth = depth;
|
|
2674
2880
|
continue;
|
|
@@ -2678,16 +2884,17 @@ function parseMindmap(text2) {
|
|
|
2678
2884
|
const indent = bullet[1].length;
|
|
2679
2885
|
const depth = lastHeadingDepth + 1 + Math.floor(indent / 2);
|
|
2680
2886
|
const label = bullet[2].trim();
|
|
2681
|
-
const node =
|
|
2682
|
-
attach(node, depth);
|
|
2887
|
+
const node = makeNode(nextId2(), label, depth);
|
|
2888
|
+
attach(node, depth, lineNo, line2);
|
|
2683
2889
|
continue;
|
|
2684
2890
|
}
|
|
2685
2891
|
}
|
|
2686
|
-
if (!root) throw new
|
|
2892
|
+
if (!root) throw new MindmapParseError("missing central topic \u2014 start with `# Title`");
|
|
2687
2893
|
const ast = {
|
|
2688
2894
|
type: "mindmap",
|
|
2689
2895
|
style: directives.style,
|
|
2690
|
-
root
|
|
2896
|
+
root,
|
|
2897
|
+
maxLabelWidth: directives.maxLabelWidth
|
|
2691
2898
|
};
|
|
2692
2899
|
if (directives.themeOverride) ast.themeOverride = directives.themeOverride;
|
|
2693
2900
|
return ast;
|
|
@@ -2695,10 +2902,10 @@ function parseMindmap(text2) {
|
|
|
2695
2902
|
|
|
2696
2903
|
// src/diagrams/mindmap/layout.ts
|
|
2697
2904
|
var PADDING = 40;
|
|
2698
|
-
var SIBLING_GAP =
|
|
2905
|
+
var SIBLING_GAP = 18;
|
|
2699
2906
|
var MAIN_GAP = 44;
|
|
2700
|
-
var
|
|
2701
|
-
var
|
|
2907
|
+
var UNDERLINE_GAP = 4;
|
|
2908
|
+
var LINE_GAP = 4;
|
|
2702
2909
|
function bezierGapFor(childDepth) {
|
|
2703
2910
|
if (childDepth <= 1) return 90;
|
|
2704
2911
|
if (childDepth === 2) return 60;
|
|
@@ -2712,47 +2919,68 @@ function fontSizeOf(depth) {
|
|
|
2712
2919
|
if (depth === 1) return FONT_MAIN;
|
|
2713
2920
|
return FONT_SUB;
|
|
2714
2921
|
}
|
|
2715
|
-
function
|
|
2716
|
-
return
|
|
2922
|
+
function lineHeightOf(fs) {
|
|
2923
|
+
return fs + LINE_GAP;
|
|
2717
2924
|
}
|
|
2718
|
-
function
|
|
2719
|
-
|
|
2925
|
+
function widthBudget(depth, maxLabelWidth) {
|
|
2926
|
+
if (depth === 0) return maxLabelWidth * 1.5;
|
|
2927
|
+
return maxLabelWidth;
|
|
2928
|
+
}
|
|
2929
|
+
function measureLabel(node, maxWidth) {
|
|
2930
|
+
const fs = fontSizeOf(node.depth);
|
|
2931
|
+
const raw = measureTokens(node.tokens, fs);
|
|
2932
|
+
let lines;
|
|
2933
|
+
if (raw <= maxWidth) {
|
|
2934
|
+
lines = [{ tokens: node.tokens.slice(), width: raw }];
|
|
2935
|
+
} else {
|
|
2936
|
+
lines = wrapTokens(node.tokens, maxWidth, fs);
|
|
2937
|
+
}
|
|
2938
|
+
let maxW = 0;
|
|
2939
|
+
for (const ln of lines) if (ln.width > maxW) maxW = ln.width;
|
|
2940
|
+
const lh = lineHeightOf(fs);
|
|
2941
|
+
const height = lines.length * lh + UNDERLINE_GAP;
|
|
2942
|
+
return { lines, width: Math.max(32, maxW), height };
|
|
2720
2943
|
}
|
|
2721
|
-
function
|
|
2944
|
+
function computeMaxLW(subtreeRoots, maxLabelWidth) {
|
|
2722
2945
|
const maxLW = [];
|
|
2723
2946
|
const walk = (n) => {
|
|
2724
|
-
const
|
|
2725
|
-
if (maxLW[n.depth] === void 0 ||
|
|
2947
|
+
const m = measureLabel(n, widthBudget(n.depth, maxLabelWidth));
|
|
2948
|
+
if (maxLW[n.depth] === void 0 || m.width > maxLW[n.depth]) maxLW[n.depth] = m.width;
|
|
2726
2949
|
for (const c of n.children) walk(c);
|
|
2727
2950
|
};
|
|
2728
2951
|
for (const r of subtreeRoots) walk(r);
|
|
2952
|
+
return maxLW;
|
|
2953
|
+
}
|
|
2954
|
+
function buildColumns(maxLW, firstColStartX, rootDepth) {
|
|
2729
2955
|
const center = [];
|
|
2730
|
-
if (
|
|
2731
|
-
const rootDepth = subtreeRoots[0].depth;
|
|
2956
|
+
if (maxLW[rootDepth] === void 0) return { center };
|
|
2732
2957
|
let slotLeft = firstColStartX;
|
|
2733
2958
|
center[rootDepth] = slotLeft + maxLW[rootDepth] / 2;
|
|
2734
2959
|
for (let d = rootDepth + 1; d < maxLW.length; d++) {
|
|
2735
2960
|
slotLeft = slotLeft + maxLW[d - 1] + bezierGapFor(d);
|
|
2736
|
-
center[d] = slotLeft + maxLW[d] / 2;
|
|
2961
|
+
center[d] = slotLeft + (maxLW[d] ?? 0) / 2;
|
|
2737
2962
|
}
|
|
2738
2963
|
return { center };
|
|
2739
2964
|
}
|
|
2740
|
-
function tidyRight(node, yTop, branchIdx, columns, out) {
|
|
2741
|
-
const
|
|
2742
|
-
const lw = estimateLabelWidth2(node.label, node.depth);
|
|
2965
|
+
function tidyRight(node, yTop, branchIdx, columns, maxLabelWidth, maxLW, out) {
|
|
2966
|
+
const m = measureLabel(node, widthBudget(node.depth, maxLabelWidth));
|
|
2743
2967
|
const x = columns.center[node.depth];
|
|
2968
|
+
const fs = fontSizeOf(node.depth);
|
|
2969
|
+
const labelWidth = Math.max(m.width, maxLW[node.depth] ?? m.width);
|
|
2744
2970
|
if (node.children.length === 0) {
|
|
2745
2971
|
const ln2 = {
|
|
2746
2972
|
node,
|
|
2747
2973
|
x,
|
|
2748
|
-
y: yTop +
|
|
2974
|
+
y: yTop + m.height / 2,
|
|
2749
2975
|
side: "right",
|
|
2750
2976
|
branchIndex: branchIdx,
|
|
2751
|
-
labelWidth
|
|
2752
|
-
labelHeight:
|
|
2977
|
+
labelWidth,
|
|
2978
|
+
labelHeight: m.height,
|
|
2979
|
+
fontSize: fs,
|
|
2980
|
+
lines: m.lines
|
|
2753
2981
|
};
|
|
2754
2982
|
out.push(ln2);
|
|
2755
|
-
return { layoutNode: ln2, height:
|
|
2983
|
+
return { layoutNode: ln2, height: m.height };
|
|
2756
2984
|
}
|
|
2757
2985
|
let cursor = yTop;
|
|
2758
2986
|
const childLayouts = [];
|
|
@@ -2763,12 +2991,14 @@ function tidyRight(node, yTop, branchIdx, columns, out) {
|
|
|
2763
2991
|
cursor,
|
|
2764
2992
|
branchIdx,
|
|
2765
2993
|
columns,
|
|
2994
|
+
maxLabelWidth,
|
|
2995
|
+
maxLW,
|
|
2766
2996
|
out
|
|
2767
2997
|
);
|
|
2768
2998
|
childLayouts.push(cln);
|
|
2769
2999
|
cursor += height;
|
|
2770
3000
|
}
|
|
2771
|
-
const totalH = Math.max(
|
|
3001
|
+
const totalH = Math.max(m.height, cursor - yTop);
|
|
2772
3002
|
const firstY = childLayouts[0].y;
|
|
2773
3003
|
const lastY = childLayouts[childLayouts.length - 1].y;
|
|
2774
3004
|
const parentY = (firstY + lastY) / 2;
|
|
@@ -2778,8 +3008,10 @@ function tidyRight(node, yTop, branchIdx, columns, out) {
|
|
|
2778
3008
|
y: parentY,
|
|
2779
3009
|
side: "right",
|
|
2780
3010
|
branchIndex: branchIdx,
|
|
2781
|
-
labelWidth
|
|
2782
|
-
labelHeight:
|
|
3011
|
+
labelWidth,
|
|
3012
|
+
labelHeight: m.height,
|
|
3013
|
+
fontSize: fs,
|
|
3014
|
+
lines: m.lines
|
|
2783
3015
|
};
|
|
2784
3016
|
out.push(ln);
|
|
2785
3017
|
return { layoutNode: ln, height: totalH };
|
|
@@ -2794,7 +3026,15 @@ function bezierH(x1, y1, x2, y2) {
|
|
|
2794
3026
|
return `M ${x1.toFixed(1)} ${y1.toFixed(1)} C ${(x1 + k).toFixed(1)} ${y1.toFixed(1)}, ${(x2 - k).toFixed(1)} ${y2.toFixed(1)}, ${x2.toFixed(1)} ${y2.toFixed(1)}`;
|
|
2795
3027
|
}
|
|
2796
3028
|
function edgeWidthFor(depth) {
|
|
2797
|
-
|
|
3029
|
+
if (depth <= 1) return 2.2;
|
|
3030
|
+
if (depth === 2) return 1.6;
|
|
3031
|
+
return 1.2;
|
|
3032
|
+
}
|
|
3033
|
+
function underlineWidthFor(depth) {
|
|
3034
|
+
if (depth === 0) return 2.4;
|
|
3035
|
+
if (depth === 1) return 2.2;
|
|
3036
|
+
if (depth === 2) return 1.6;
|
|
3037
|
+
return 1.2;
|
|
2798
3038
|
}
|
|
2799
3039
|
function normalize(nodes) {
|
|
2800
3040
|
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
@@ -2805,8 +3045,8 @@ function normalize(nodes) {
|
|
|
2805
3045
|
const rightX = n.x + lw / 2;
|
|
2806
3046
|
minX = Math.min(minX, leftX);
|
|
2807
3047
|
maxX = Math.max(maxX, rightX);
|
|
2808
|
-
minY = Math.min(minY, n.y - lh);
|
|
2809
|
-
maxY = Math.max(maxY, n.y + lh);
|
|
3048
|
+
minY = Math.min(minY, n.y - lh / 2);
|
|
3049
|
+
maxY = Math.max(maxY, n.y + lh / 2);
|
|
2810
3050
|
}
|
|
2811
3051
|
const dx = PADDING - minX;
|
|
2812
3052
|
const dy = PADDING - minY;
|
|
@@ -2816,10 +3056,14 @@ function normalize(nodes) {
|
|
|
2816
3056
|
}
|
|
2817
3057
|
return { width: maxX - minX + PADDING * 2, height: maxY - minY + PADDING * 2 };
|
|
2818
3058
|
}
|
|
3059
|
+
function underlineY(n) {
|
|
3060
|
+
return n.y + n.labelHeight / 2 - UNDERLINE_GAP / 2;
|
|
3061
|
+
}
|
|
2819
3062
|
function buildEdges(root, byId) {
|
|
2820
3063
|
const edges = [];
|
|
2821
3064
|
const walk = (parent) => {
|
|
2822
3065
|
const pln = byId.get(parent.id);
|
|
3066
|
+
const pUY = underlineY(pln);
|
|
2823
3067
|
for (const c of parent.children) {
|
|
2824
3068
|
const cln = byId.get(c.id);
|
|
2825
3069
|
let fromX;
|
|
@@ -2833,7 +3077,7 @@ function buildEdges(root, byId) {
|
|
|
2833
3077
|
edges.push({
|
|
2834
3078
|
from: parent.id,
|
|
2835
3079
|
to: c.id,
|
|
2836
|
-
path: bezierH(fromX,
|
|
3080
|
+
path: bezierH(fromX, pUY, toX, underlineY(cln)),
|
|
2837
3081
|
color: "",
|
|
2838
3082
|
width: edgeWidthFor(c.depth)
|
|
2839
3083
|
});
|
|
@@ -2850,24 +3094,23 @@ function layoutMap(ast) {
|
|
|
2850
3094
|
const rightMains = mains.slice(0, rightCount);
|
|
2851
3095
|
const leftMains = mains.slice(rightCount);
|
|
2852
3096
|
const nodes = [];
|
|
2853
|
-
const
|
|
2854
|
-
const
|
|
2855
|
-
const
|
|
2856
|
-
const
|
|
2857
|
-
const
|
|
3097
|
+
const mw = ast.maxLabelWidth;
|
|
3098
|
+
const rootM = measureLabel(root, widthBudget(0, mw));
|
|
3099
|
+
const firstColLeft = rootM.width / 2 + bezierGapFor(1);
|
|
3100
|
+
const maxLW = computeMaxLW([...rightMains, ...leftMains], mw);
|
|
3101
|
+
const cols = buildColumns(maxLW, firstColLeft, 1);
|
|
2858
3102
|
let rightCursor = 0;
|
|
2859
3103
|
for (let i = 0; i < rightMains.length; i++) {
|
|
2860
3104
|
if (i > 0) rightCursor += MAIN_GAP;
|
|
2861
|
-
const { height: height2 } = tidyRight(rightMains[i], rightCursor, i,
|
|
3105
|
+
const { height: height2 } = tidyRight(rightMains[i], rightCursor, i, cols, mw, maxLW, nodes);
|
|
2862
3106
|
rightCursor += height2;
|
|
2863
3107
|
}
|
|
2864
3108
|
const rightHeight = rightCursor;
|
|
2865
|
-
const leftCols = computeColumns(leftMains, firstColLeft);
|
|
2866
3109
|
const leftStart = nodes.length;
|
|
2867
3110
|
let leftCursor = 0;
|
|
2868
3111
|
for (let i = 0; i < leftMains.length; i++) {
|
|
2869
3112
|
if (i > 0) leftCursor += MAIN_GAP;
|
|
2870
|
-
const { height: height2 } = tidyRight(leftMains[i], leftCursor, rightCount + i,
|
|
3113
|
+
const { height: height2 } = tidyRight(leftMains[i], leftCursor, rightCount + i, cols, mw, maxLW, nodes);
|
|
2871
3114
|
leftCursor += height2;
|
|
2872
3115
|
}
|
|
2873
3116
|
const leftHeight = leftCursor;
|
|
@@ -2882,8 +3125,10 @@ function layoutMap(ast) {
|
|
|
2882
3125
|
y: rootY,
|
|
2883
3126
|
side: "center",
|
|
2884
3127
|
branchIndex: -1,
|
|
2885
|
-
labelWidth:
|
|
2886
|
-
labelHeight:
|
|
3128
|
+
labelWidth: rootM.width,
|
|
3129
|
+
labelHeight: rootM.height,
|
|
3130
|
+
fontSize: fontSizeOf(0),
|
|
3131
|
+
lines: rootM.lines
|
|
2887
3132
|
};
|
|
2888
3133
|
nodes.push(rootNode);
|
|
2889
3134
|
const { width, height } = normalize(nodes);
|
|
@@ -2894,15 +3139,15 @@ function layoutMap(ast) {
|
|
|
2894
3139
|
function layoutLogicRight(ast) {
|
|
2895
3140
|
const root = ast.root;
|
|
2896
3141
|
const nodes = [];
|
|
2897
|
-
const
|
|
2898
|
-
const
|
|
2899
|
-
const
|
|
2900
|
-
const
|
|
2901
|
-
const cols =
|
|
3142
|
+
const mw = ast.maxLabelWidth;
|
|
3143
|
+
const rootM = measureLabel(root, widthBudget(0, mw));
|
|
3144
|
+
const firstColLeft = rootM.width / 2 + bezierGapFor(1);
|
|
3145
|
+
const maxLW = computeMaxLW(root.children, mw);
|
|
3146
|
+
const cols = buildColumns(maxLW, firstColLeft, 1);
|
|
2902
3147
|
let cursor = 0;
|
|
2903
3148
|
for (let i = 0; i < root.children.length; i++) {
|
|
2904
3149
|
if (i > 0) cursor += MAIN_GAP;
|
|
2905
|
-
const { height: height2 } = tidyRight(root.children[i], cursor, i, cols, nodes);
|
|
3150
|
+
const { height: height2 } = tidyRight(root.children[i], cursor, i, cols, mw, maxLW, nodes);
|
|
2906
3151
|
cursor += height2;
|
|
2907
3152
|
}
|
|
2908
3153
|
const totalHeight = cursor;
|
|
@@ -2912,8 +3157,10 @@ function layoutLogicRight(ast) {
|
|
|
2912
3157
|
y: totalHeight / 2,
|
|
2913
3158
|
side: "center",
|
|
2914
3159
|
branchIndex: -1,
|
|
2915
|
-
labelWidth:
|
|
2916
|
-
labelHeight:
|
|
3160
|
+
labelWidth: rootM.width,
|
|
3161
|
+
labelHeight: rootM.height,
|
|
3162
|
+
fontSize: fontSizeOf(0),
|
|
3163
|
+
lines: rootM.lines
|
|
2917
3164
|
};
|
|
2918
3165
|
nodes.push(rootNode);
|
|
2919
3166
|
const { width, height } = normalize(nodes);
|
|
@@ -2928,91 +3175,170 @@ function layoutMindmap(ast) {
|
|
|
2928
3175
|
}
|
|
2929
3176
|
|
|
2930
3177
|
// src/diagrams/mindmap/renderer.ts
|
|
2931
|
-
|
|
2932
|
-
|
|
3178
|
+
function strokeScale(theme) {
|
|
3179
|
+
return theme.branchPalette.length <= 1 ? 0.7 : 1;
|
|
3180
|
+
}
|
|
2933
3181
|
function paletteColor(theme, branchIndex) {
|
|
2934
3182
|
if (branchIndex < 0) return theme.centralFill;
|
|
2935
3183
|
return theme.branchPalette[branchIndex % theme.branchPalette.length];
|
|
2936
3184
|
}
|
|
2937
|
-
function
|
|
2938
|
-
|
|
3185
|
+
function renderLine(line2, leftX, cy, fontSize, fontFamily, fontWeight, theme) {
|
|
3186
|
+
const baselineY = cy + fontSize * 0.35;
|
|
3187
|
+
const tspans = [];
|
|
3188
|
+
const decorations = [];
|
|
3189
|
+
let cursor = leftX;
|
|
3190
|
+
const emit = (tok, inheritedHref) => {
|
|
3191
|
+
switch (tok.kind) {
|
|
3192
|
+
case "text": {
|
|
3193
|
+
const w = measureToken(tok, fontSize);
|
|
3194
|
+
tspans.push(
|
|
3195
|
+
tspan({
|
|
3196
|
+
x: cursor,
|
|
3197
|
+
y: baselineY,
|
|
3198
|
+
fill: inheritedHref ? theme.linkColor : theme.text,
|
|
3199
|
+
"font-weight": tok.bold ? 700 : fontWeight,
|
|
3200
|
+
"font-style": tok.italic ? "italic" : void 0,
|
|
3201
|
+
"text-decoration": inheritedHref ? "underline" : void 0
|
|
3202
|
+
}, tok.value)
|
|
3203
|
+
);
|
|
3204
|
+
cursor += w;
|
|
3205
|
+
break;
|
|
3206
|
+
}
|
|
3207
|
+
case "code": {
|
|
3208
|
+
const w = measureToken(tok, fontSize);
|
|
3209
|
+
decorations.push(rect({
|
|
3210
|
+
x: cursor,
|
|
3211
|
+
y: cy - fontSize * 0.6,
|
|
3212
|
+
width: w,
|
|
3213
|
+
height: fontSize * 1.2,
|
|
3214
|
+
rx: 3,
|
|
3215
|
+
ry: 3,
|
|
3216
|
+
fill: theme.codeBg
|
|
3217
|
+
}));
|
|
3218
|
+
tspans.push(
|
|
3219
|
+
tspan({
|
|
3220
|
+
x: cursor + 2,
|
|
3221
|
+
y: baselineY,
|
|
3222
|
+
fill: theme.codeFg,
|
|
3223
|
+
"font-family": "ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",
|
|
3224
|
+
"font-size": fontSize * 0.92
|
|
3225
|
+
}, tok.value)
|
|
3226
|
+
);
|
|
3227
|
+
cursor += w;
|
|
3228
|
+
break;
|
|
3229
|
+
}
|
|
3230
|
+
case "link": {
|
|
3231
|
+
const aStart = `<a href="${escapeXml(tok.href)}" target="_blank" rel="noopener">`;
|
|
3232
|
+
const innerStart = tspans.length;
|
|
3233
|
+
for (const inner of tok.value) emit(inner, tok.href);
|
|
3234
|
+
const innerTspans = tspans.splice(innerStart).join("");
|
|
3235
|
+
tspans.push(aStart + innerTspans + "</a>");
|
|
3236
|
+
break;
|
|
3237
|
+
}
|
|
3238
|
+
case "checkbox": {
|
|
3239
|
+
const size = fontSize * 0.85;
|
|
3240
|
+
const boxX = cursor;
|
|
3241
|
+
const boxY = cy - size / 2;
|
|
3242
|
+
decorations.push(rect({
|
|
3243
|
+
x: boxX,
|
|
3244
|
+
y: boxY,
|
|
3245
|
+
width: size,
|
|
3246
|
+
height: size,
|
|
3247
|
+
rx: 2,
|
|
3248
|
+
ry: 2,
|
|
3249
|
+
fill: tok.checked ? theme.checkboxFill : "none",
|
|
3250
|
+
stroke: tok.checked ? theme.checkboxFill : theme.checkboxStroke,
|
|
3251
|
+
"stroke-width": 1.5
|
|
3252
|
+
}));
|
|
3253
|
+
if (tok.checked) {
|
|
3254
|
+
const p = `M ${(boxX + size * 0.2).toFixed(1)} ${(boxY + size * 0.5).toFixed(1)} L ${(boxX + size * 0.42).toFixed(1)} ${(boxY + size * 0.72).toFixed(1)} L ${(boxX + size * 0.82).toFixed(1)} ${(boxY + size * 0.28).toFixed(1)}`;
|
|
3255
|
+
decorations.push(path({
|
|
3256
|
+
d: p,
|
|
3257
|
+
fill: "none",
|
|
3258
|
+
stroke: "#ffffff",
|
|
3259
|
+
"stroke-width": 2,
|
|
3260
|
+
"stroke-linecap": "round",
|
|
3261
|
+
"stroke-linejoin": "round"
|
|
3262
|
+
}));
|
|
3263
|
+
}
|
|
3264
|
+
cursor += size + fontSize * 0.25;
|
|
3265
|
+
break;
|
|
3266
|
+
}
|
|
3267
|
+
}
|
|
3268
|
+
};
|
|
3269
|
+
for (const tok of line2.tokens) emit(tok);
|
|
3270
|
+
const textElement = el("text", {
|
|
3271
|
+
"font-family": fontFamily,
|
|
3272
|
+
"font-size": fontSize,
|
|
3273
|
+
"font-weight": fontWeight
|
|
3274
|
+
}, tspans.join(""));
|
|
3275
|
+
return { textElement, decorations };
|
|
3276
|
+
}
|
|
3277
|
+
function measureToken(tok, fs) {
|
|
3278
|
+
switch (tok.kind) {
|
|
3279
|
+
case "text":
|
|
3280
|
+
return tok.value.length * fs * (tok.bold ? 0.62 : 0.58);
|
|
3281
|
+
case "code":
|
|
3282
|
+
return tok.value.length * fs * 0.62 + 4;
|
|
3283
|
+
case "link": {
|
|
3284
|
+
let w = 0;
|
|
3285
|
+
for (const t of tok.value) w += measureToken(t, fs);
|
|
3286
|
+
return w;
|
|
3287
|
+
}
|
|
3288
|
+
case "checkbox":
|
|
3289
|
+
return fs * 0.85 + fs * 0.25;
|
|
3290
|
+
}
|
|
2939
3291
|
}
|
|
2940
|
-
function
|
|
2941
|
-
const
|
|
2942
|
-
const
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
rect({
|
|
2948
|
-
x: n.x - pillW / 2,
|
|
2949
|
-
y: n.y - pillH / 2,
|
|
2950
|
-
width: pillW,
|
|
2951
|
-
height: pillH,
|
|
2952
|
-
rx: pillH / 2,
|
|
2953
|
-
ry: pillH / 2,
|
|
2954
|
-
fill: "none",
|
|
2955
|
-
stroke: theme.textMuted,
|
|
2956
|
-
"stroke-width": underlineMain(theme)
|
|
2957
|
-
}),
|
|
2958
|
-
text(
|
|
2959
|
-
{
|
|
2960
|
-
x: n.x,
|
|
2961
|
-
y: n.y + fs * 0.35,
|
|
2962
|
-
"text-anchor": "middle",
|
|
2963
|
-
"font-family": fontFamily,
|
|
2964
|
-
"font-size": fs,
|
|
2965
|
-
"font-weight": 700,
|
|
2966
|
-
fill: theme.text
|
|
2967
|
-
},
|
|
2968
|
-
n.node.label
|
|
2969
|
-
)
|
|
2970
|
-
]
|
|
2971
|
-
);
|
|
3292
|
+
function tspan(attrs, content) {
|
|
3293
|
+
const pairs = [];
|
|
3294
|
+
for (const [k, v] of Object.entries(attrs)) {
|
|
3295
|
+
if (v === void 0) continue;
|
|
3296
|
+
pairs.push(`${k}="${typeof v === "number" ? String(v) : escapeXml(String(v))}"`);
|
|
3297
|
+
}
|
|
3298
|
+
return `<tspan ${pairs.join(" ")}>${escapeXml(content)}</tspan>`;
|
|
2972
3299
|
}
|
|
2973
|
-
function
|
|
3300
|
+
function renderNode(n, color, theme, fontFamily) {
|
|
3301
|
+
const isRoot = n.node.depth === 0;
|
|
2974
3302
|
const isMain = n.node.depth === 1;
|
|
2975
|
-
const fs =
|
|
2976
|
-
const
|
|
2977
|
-
const
|
|
3303
|
+
const fs = n.fontSize;
|
|
3304
|
+
const lh = lineHeightOf(fs);
|
|
3305
|
+
const lineCount = n.lines.length;
|
|
3306
|
+
const topY = n.y - n.labelHeight / 2;
|
|
3307
|
+
const underlineY2 = n.y + n.labelHeight / 2 - UNDERLINE_GAP / 2;
|
|
3308
|
+
const children = [];
|
|
3309
|
+
const decorations = [];
|
|
3310
|
+
const weight = isRoot ? 700 : isMain ? 600 : 400;
|
|
3311
|
+
const textLeft = n.x - n.labelWidth / 2;
|
|
3312
|
+
for (let i = 0; i < lineCount; i++) {
|
|
3313
|
+
const line2 = n.lines[i];
|
|
3314
|
+
const cy = topY + (i + 0.5) * lh;
|
|
3315
|
+
const r = renderLine(line2, textLeft, cy, fs, fontFamily, weight, theme);
|
|
3316
|
+
decorations.push(...r.decorations);
|
|
3317
|
+
children.push(r.textElement);
|
|
3318
|
+
}
|
|
2978
3319
|
const ux1 = n.x - n.labelWidth / 2;
|
|
2979
3320
|
const ux2 = n.x + n.labelWidth / 2;
|
|
2980
|
-
const
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
)
|
|
2994
|
-
];
|
|
2995
|
-
if (isMain) {
|
|
2996
|
-
children.push(
|
|
2997
|
-
el("line", {
|
|
2998
|
-
x1: ux1,
|
|
2999
|
-
y1: uy,
|
|
3000
|
-
x2: ux2,
|
|
3001
|
-
y2: uy,
|
|
3002
|
-
stroke: color,
|
|
3003
|
-
"stroke-width": underlineMain(theme),
|
|
3004
|
-
"stroke-linecap": "round"
|
|
3005
|
-
})
|
|
3006
|
-
);
|
|
3007
|
-
}
|
|
3321
|
+
const sw = underlineWidthFor(n.node.depth) * strokeScale(theme);
|
|
3322
|
+
children.push(
|
|
3323
|
+
el("line", {
|
|
3324
|
+
x1: ux1,
|
|
3325
|
+
y1: underlineY2,
|
|
3326
|
+
x2: ux2,
|
|
3327
|
+
y2: underlineY2,
|
|
3328
|
+
stroke: color,
|
|
3329
|
+
"stroke-width": sw,
|
|
3330
|
+
"stroke-linecap": "round"
|
|
3331
|
+
})
|
|
3332
|
+
);
|
|
3333
|
+
const cls = isRoot ? "schematex-mindmap-central" : isMain ? "schematex-mindmap-main" : "schematex-mindmap-leaf";
|
|
3008
3334
|
return group(
|
|
3009
3335
|
{
|
|
3010
|
-
class:
|
|
3336
|
+
class: cls,
|
|
3011
3337
|
"data-node-id": n.node.id,
|
|
3012
3338
|
"data-depth": n.node.depth,
|
|
3013
3339
|
"data-branch-idx": n.branchIndex
|
|
3014
3340
|
},
|
|
3015
|
-
children
|
|
3341
|
+
[...decorations, ...children]
|
|
3016
3342
|
);
|
|
3017
3343
|
}
|
|
3018
3344
|
function renderMindmapAST(ast, themeName = "default", fontFamily = "system-ui, -apple-system, sans-serif") {
|
|
@@ -3036,15 +3362,10 @@ function renderMindmapAST(ast, themeName = "default", fontFamily = "system-ui, -
|
|
|
3036
3362
|
}
|
|
3037
3363
|
const nodeSvgs = [];
|
|
3038
3364
|
for (const n of layout.nodes) {
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
} else {
|
|
3042
|
-
nodeSvgs.push(
|
|
3043
|
-
renderBranchNode(n, paletteColor(theme, n.branchIndex), theme, fontFamily)
|
|
3044
|
-
);
|
|
3045
|
-
}
|
|
3365
|
+
const color = n.node.depth === 0 ? theme.centralFill : paletteColor(theme, n.branchIndex);
|
|
3366
|
+
nodeSvgs.push(renderNode(n, color, theme, fontFamily));
|
|
3046
3367
|
}
|
|
3047
|
-
const title2 = ast.title ?? ast.root.
|
|
3368
|
+
const title2 = ast.title ?? tokensToPlainText(ast.root.tokens);
|
|
3048
3369
|
return svgRoot(
|
|
3049
3370
|
{
|
|
3050
3371
|
viewBox: `0 0 ${layout.width.toFixed(1)} ${layout.height.toFixed(1)}`,
|
|
@@ -4535,5 +4856,5 @@ function render(text2, config) {
|
|
|
4535
4856
|
}
|
|
4536
4857
|
|
|
4537
4858
|
export { decisiontree, parse, render, timeline };
|
|
4538
|
-
//# sourceMappingURL=chunk-
|
|
4539
|
-
//# sourceMappingURL=chunk-
|
|
4859
|
+
//# sourceMappingURL=chunk-S3RBKJM5.js.map
|
|
4860
|
+
//# sourceMappingURL=chunk-S3RBKJM5.js.map
|