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,32 +1,36 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
var
|
|
17
|
-
var
|
|
18
|
-
var
|
|
19
|
-
var
|
|
3
|
+
var chunkA5D2IMOX_cjs = require('./chunk-A5D2IMOX.cjs');
|
|
4
|
+
var chunk4S2WILLW_cjs = require('./chunk-4S2WILLW.cjs');
|
|
5
|
+
var chunkMCFQAUQV_cjs = require('./chunk-MCFQAUQV.cjs');
|
|
6
|
+
var chunkB6INLQBU_cjs = require('./chunk-B6INLQBU.cjs');
|
|
7
|
+
var chunk3YZ6FPQW_cjs = require('./chunk-3YZ6FPQW.cjs');
|
|
8
|
+
var chunkZNOD4VZT_cjs = require('./chunk-ZNOD4VZT.cjs');
|
|
9
|
+
var chunk5AEN2PLB_cjs = require('./chunk-5AEN2PLB.cjs');
|
|
10
|
+
var chunkQSQX77S2_cjs = require('./chunk-QSQX77S2.cjs');
|
|
11
|
+
var chunkZ3DE6S64_cjs = require('./chunk-Z3DE6S64.cjs');
|
|
12
|
+
var chunk6LZJTAA3_cjs = require('./chunk-6LZJTAA3.cjs');
|
|
13
|
+
var chunkE65ITQXV_cjs = require('./chunk-E65ITQXV.cjs');
|
|
14
|
+
var chunkB37IKTI7_cjs = require('./chunk-B37IKTI7.cjs');
|
|
15
|
+
var chunkX7RPFTTR_cjs = require('./chunk-X7RPFTTR.cjs');
|
|
16
|
+
var chunkCOLTVQWR_cjs = require('./chunk-COLTVQWR.cjs');
|
|
17
|
+
var chunk2JDVJRR3_cjs = require('./chunk-2JDVJRR3.cjs');
|
|
18
|
+
var chunkWYFXOXVK_cjs = require('./chunk-WYFXOXVK.cjs');
|
|
19
|
+
var chunkD7EHZFK4_cjs = require('./chunk-D7EHZFK4.cjs');
|
|
20
20
|
var chunkHDKDQAEQ_cjs = require('./chunk-HDKDQAEQ.cjs');
|
|
21
21
|
|
|
22
22
|
// src/diagrams/decisiontree/parser.ts
|
|
23
23
|
var DTreeParseError = class extends Error {
|
|
24
|
-
constructor(message, line2) {
|
|
24
|
+
constructor(message, line2, column, source) {
|
|
25
25
|
super(line2 !== void 0 ? `Line ${line2}: ${message}` : message);
|
|
26
26
|
this.line = line2;
|
|
27
|
+
this.column = column;
|
|
28
|
+
this.source = source;
|
|
27
29
|
this.name = "DTreeParseError";
|
|
28
30
|
}
|
|
29
31
|
line;
|
|
32
|
+
column;
|
|
33
|
+
source;
|
|
30
34
|
};
|
|
31
35
|
function preprocess(src) {
|
|
32
36
|
const out = [];
|
|
@@ -1074,7 +1078,7 @@ function wrapText(text2, maxChars) {
|
|
|
1074
1078
|
return lines.slice(0, 2);
|
|
1075
1079
|
}
|
|
1076
1080
|
function renderDecisionTree(ast, config) {
|
|
1077
|
-
const t =
|
|
1081
|
+
const t = chunkD7EHZFK4_cjs.resolveBaseTheme(config?.theme ?? "default");
|
|
1078
1082
|
const layout = layoutDecisionTree(ast);
|
|
1079
1083
|
const titleOffset = ast.title ? 36 : 10;
|
|
1080
1084
|
const width = Math.ceil(layout.width);
|
|
@@ -1227,12 +1231,16 @@ function formatYear(value, span) {
|
|
|
1227
1231
|
|
|
1228
1232
|
// src/diagrams/timeline/parser.ts
|
|
1229
1233
|
var TimelineParseError = class extends Error {
|
|
1230
|
-
constructor(message, line2) {
|
|
1234
|
+
constructor(message, line2, column, source) {
|
|
1231
1235
|
super(line2 !== void 0 ? `Line ${line2}: ${message}` : message);
|
|
1232
1236
|
this.line = line2;
|
|
1237
|
+
this.column = column;
|
|
1238
|
+
this.source = source;
|
|
1233
1239
|
this.name = "TimelineParseError";
|
|
1234
1240
|
}
|
|
1235
1241
|
line;
|
|
1242
|
+
column;
|
|
1243
|
+
source;
|
|
1236
1244
|
};
|
|
1237
1245
|
function preprocess2(src) {
|
|
1238
1246
|
const out = [];
|
|
@@ -2097,7 +2105,7 @@ var ERA_ROW_GAP = 2;
|
|
|
2097
2105
|
function renderTimeline(src, config) {
|
|
2098
2106
|
const ast = parseTimeline(src);
|
|
2099
2107
|
const layout = layoutTimeline(ast);
|
|
2100
|
-
const theme =
|
|
2108
|
+
const theme = chunkD7EHZFK4_cjs.resolveTimelineTheme(config?.theme ?? "default");
|
|
2101
2109
|
const styleBlock = styleForTheme(theme, config?.fontFamily);
|
|
2102
2110
|
const children = [
|
|
2103
2111
|
chunkHDKDQAEQ_cjs.title(ast.title ? `Timeline \u2014 ${ast.title}` : "Timeline"),
|
|
@@ -2142,7 +2150,7 @@ function renderTimeline(src, config) {
|
|
|
2142
2150
|
function styleForTheme(theme, fontFamily) {
|
|
2143
2151
|
const font = fontFamily ?? "system-ui, -apple-system, sans-serif";
|
|
2144
2152
|
return `
|
|
2145
|
-
.st-timeline { ${
|
|
2153
|
+
.st-timeline { ${chunkD7EHZFK4_cjs.cssCustomProperties(theme)}
|
|
2146
2154
|
--st-axis: ${theme.axis};
|
|
2147
2155
|
--st-axis-label: ${theme.axisLabel};
|
|
2148
2156
|
--st-era-label: ${theme.eraLabel};
|
|
@@ -2620,8 +2628,193 @@ var timeline = {
|
|
|
2620
2628
|
}
|
|
2621
2629
|
};
|
|
2622
2630
|
|
|
2631
|
+
// src/diagrams/mindmap/inline.ts
|
|
2632
|
+
var RE_TASK = /^\[( |x|X)\]\s+(.*)$/;
|
|
2633
|
+
function tokenizeInline(raw) {
|
|
2634
|
+
const tokens = [];
|
|
2635
|
+
let text2 = raw;
|
|
2636
|
+
const task = text2.match(RE_TASK);
|
|
2637
|
+
if (task) {
|
|
2638
|
+
tokens.push({ kind: "checkbox", checked: task[1].toLowerCase() === "x" });
|
|
2639
|
+
text2 = task[2];
|
|
2640
|
+
}
|
|
2641
|
+
parseInto(text2, tokens, { bold: false, italic: false });
|
|
2642
|
+
return tokens;
|
|
2643
|
+
}
|
|
2644
|
+
function parseInto(src, out, style) {
|
|
2645
|
+
let i = 0;
|
|
2646
|
+
let plain = "";
|
|
2647
|
+
const flushPlain = () => {
|
|
2648
|
+
if (plain.length === 0) return;
|
|
2649
|
+
out.push({ kind: "text", value: plain, bold: style.bold || void 0, italic: style.italic || void 0 });
|
|
2650
|
+
plain = "";
|
|
2651
|
+
};
|
|
2652
|
+
while (i < src.length) {
|
|
2653
|
+
const ch = src[i];
|
|
2654
|
+
if (ch === "`") {
|
|
2655
|
+
const end = src.indexOf("`", i + 1);
|
|
2656
|
+
if (end > i) {
|
|
2657
|
+
flushPlain();
|
|
2658
|
+
out.push({ kind: "code", value: src.slice(i + 1, end) });
|
|
2659
|
+
i = end + 1;
|
|
2660
|
+
continue;
|
|
2661
|
+
}
|
|
2662
|
+
}
|
|
2663
|
+
if (ch === "[") {
|
|
2664
|
+
const closeBracket = findUnescaped(src, "]", i + 1);
|
|
2665
|
+
if (closeBracket > 0 && src[closeBracket + 1] === "(") {
|
|
2666
|
+
const closeParen = findUnescaped(src, ")", closeBracket + 2);
|
|
2667
|
+
if (closeParen > 0) {
|
|
2668
|
+
flushPlain();
|
|
2669
|
+
const inner = [];
|
|
2670
|
+
parseInto(src.slice(i + 1, closeBracket), inner, style);
|
|
2671
|
+
out.push({ kind: "link", href: src.slice(closeBracket + 2, closeParen), value: inner });
|
|
2672
|
+
i = closeParen + 1;
|
|
2673
|
+
continue;
|
|
2674
|
+
}
|
|
2675
|
+
}
|
|
2676
|
+
}
|
|
2677
|
+
if (ch === "*" && src[i + 1] === "*") {
|
|
2678
|
+
const end = src.indexOf("**", i + 2);
|
|
2679
|
+
if (end > i) {
|
|
2680
|
+
flushPlain();
|
|
2681
|
+
parseInto(src.slice(i + 2, end), out, { ...style, bold: true });
|
|
2682
|
+
i = end + 2;
|
|
2683
|
+
continue;
|
|
2684
|
+
}
|
|
2685
|
+
}
|
|
2686
|
+
if (ch === "*") {
|
|
2687
|
+
const end = src.indexOf("*", i + 1);
|
|
2688
|
+
if (end > i && src[end + 1] !== "*") {
|
|
2689
|
+
flushPlain();
|
|
2690
|
+
parseInto(src.slice(i + 1, end), out, { ...style, italic: true });
|
|
2691
|
+
i = end + 1;
|
|
2692
|
+
continue;
|
|
2693
|
+
}
|
|
2694
|
+
}
|
|
2695
|
+
plain += ch;
|
|
2696
|
+
i++;
|
|
2697
|
+
}
|
|
2698
|
+
flushPlain();
|
|
2699
|
+
}
|
|
2700
|
+
function findUnescaped(s, ch, from) {
|
|
2701
|
+
for (let i = from; i < s.length; i++) {
|
|
2702
|
+
if (s[i] === "\\") {
|
|
2703
|
+
i++;
|
|
2704
|
+
continue;
|
|
2705
|
+
}
|
|
2706
|
+
if (s[i] === ch) return i;
|
|
2707
|
+
}
|
|
2708
|
+
return -1;
|
|
2709
|
+
}
|
|
2710
|
+
var EM_REGULAR = 0.58;
|
|
2711
|
+
var EM_BOLD = 0.62;
|
|
2712
|
+
var EM_CODE = 0.62;
|
|
2713
|
+
var CHECKBOX_EM = 1.05;
|
|
2714
|
+
function measureTokens(tokens, fontSize) {
|
|
2715
|
+
let w = 0;
|
|
2716
|
+
for (const t of tokens) {
|
|
2717
|
+
w += tokenWidth(t, fontSize);
|
|
2718
|
+
}
|
|
2719
|
+
return w;
|
|
2720
|
+
}
|
|
2721
|
+
function tokenWidth(t, fs) {
|
|
2722
|
+
switch (t.kind) {
|
|
2723
|
+
case "text": {
|
|
2724
|
+
const em = t.bold ? EM_BOLD : EM_REGULAR;
|
|
2725
|
+
return t.value.length * fs * em;
|
|
2726
|
+
}
|
|
2727
|
+
case "code":
|
|
2728
|
+
return t.value.length * fs * EM_CODE + 4;
|
|
2729
|
+
case "link":
|
|
2730
|
+
return measureTokens(t.value, fs);
|
|
2731
|
+
case "checkbox":
|
|
2732
|
+
return fs * CHECKBOX_EM;
|
|
2733
|
+
}
|
|
2734
|
+
}
|
|
2735
|
+
function tokensToPlainText(tokens) {
|
|
2736
|
+
let out = "";
|
|
2737
|
+
for (const t of tokens) {
|
|
2738
|
+
switch (t.kind) {
|
|
2739
|
+
case "text":
|
|
2740
|
+
case "code":
|
|
2741
|
+
out += t.value;
|
|
2742
|
+
break;
|
|
2743
|
+
case "link":
|
|
2744
|
+
out += tokensToPlainText(t.value);
|
|
2745
|
+
break;
|
|
2746
|
+
case "checkbox":
|
|
2747
|
+
out += t.checked ? "[x] " : "[ ] ";
|
|
2748
|
+
break;
|
|
2749
|
+
}
|
|
2750
|
+
}
|
|
2751
|
+
return out;
|
|
2752
|
+
}
|
|
2753
|
+
function wrapTokens(tokens, maxWidth, fontSize) {
|
|
2754
|
+
const lines = [];
|
|
2755
|
+
let line2 = [];
|
|
2756
|
+
let lineW = 0;
|
|
2757
|
+
const pushLine = () => {
|
|
2758
|
+
lines.push({ tokens: line2, width: lineW });
|
|
2759
|
+
line2 = [];
|
|
2760
|
+
lineW = 0;
|
|
2761
|
+
};
|
|
2762
|
+
const pushAtomic = (t, w) => {
|
|
2763
|
+
if (lineW > 0 && lineW + w > maxWidth) pushLine();
|
|
2764
|
+
line2.push(t);
|
|
2765
|
+
lineW += w;
|
|
2766
|
+
};
|
|
2767
|
+
for (const t of tokens) {
|
|
2768
|
+
if (t.kind === "text") {
|
|
2769
|
+
const words = splitWordsWithTrailingSpace(t.value);
|
|
2770
|
+
for (const w of words) {
|
|
2771
|
+
const wt = { kind: "text", value: w, bold: t.bold, italic: t.italic };
|
|
2772
|
+
const ww = tokenWidth(wt, fontSize);
|
|
2773
|
+
if (lineW > 0 && lineW + ww > maxWidth) {
|
|
2774
|
+
pushLine();
|
|
2775
|
+
const trimmed = w.replace(/^ +/, "");
|
|
2776
|
+
if (trimmed.length === 0) continue;
|
|
2777
|
+
const tt = { kind: "text", value: trimmed, bold: t.bold, italic: t.italic };
|
|
2778
|
+
line2.push(tt);
|
|
2779
|
+
lineW = tokenWidth(tt, fontSize);
|
|
2780
|
+
} else {
|
|
2781
|
+
line2.push(wt);
|
|
2782
|
+
lineW += ww;
|
|
2783
|
+
}
|
|
2784
|
+
}
|
|
2785
|
+
} else {
|
|
2786
|
+
pushAtomic(t, tokenWidth(t, fontSize));
|
|
2787
|
+
}
|
|
2788
|
+
}
|
|
2789
|
+
pushLine();
|
|
2790
|
+
return lines;
|
|
2791
|
+
}
|
|
2792
|
+
function splitWordsWithTrailingSpace(s) {
|
|
2793
|
+
if (s.length === 0) return [];
|
|
2794
|
+
const out = [];
|
|
2795
|
+
const re = /(\S+\s*)|(\s+)/g;
|
|
2796
|
+
let m;
|
|
2797
|
+
while ((m = re.exec(s)) !== null) {
|
|
2798
|
+
out.push(m[0]);
|
|
2799
|
+
}
|
|
2800
|
+
return out.length > 0 ? out : [s];
|
|
2801
|
+
}
|
|
2802
|
+
|
|
2623
2803
|
// src/diagrams/mindmap/parser.ts
|
|
2804
|
+
var MindmapParseError = class extends Error {
|
|
2805
|
+
constructor(message, line2, column, source) {
|
|
2806
|
+
super(line2 !== void 0 ? `Line ${line2}: ${message}` : message);
|
|
2807
|
+
this.line = line2;
|
|
2808
|
+
this.column = column;
|
|
2809
|
+
this.source = source;
|
|
2810
|
+
this.name = "MindmapParseError";
|
|
2811
|
+
}
|
|
2812
|
+
line;
|
|
2813
|
+
column;
|
|
2814
|
+
source;
|
|
2815
|
+
};
|
|
2624
2816
|
var VALID_STYLES = ["map", "logic-right"];
|
|
2817
|
+
var DEFAULT_MAX_LABEL_WIDTH = 240;
|
|
2625
2818
|
function parseDirective(line2, out) {
|
|
2626
2819
|
const body = line2.replace(/^%%\s*/, "").trim();
|
|
2627
2820
|
const idx = body.indexOf(":");
|
|
@@ -2632,26 +2825,39 @@ function parseDirective(line2, out) {
|
|
|
2632
2825
|
out.style = val;
|
|
2633
2826
|
} else if (key === "theme") {
|
|
2634
2827
|
out.themeOverride = val;
|
|
2828
|
+
} else if (key === "maxlabelwidth") {
|
|
2829
|
+
const n = Number(val);
|
|
2830
|
+
if (Number.isFinite(n) && n >= 80 && n <= 1e3) out.maxLabelWidth = n;
|
|
2635
2831
|
}
|
|
2636
2832
|
}
|
|
2833
|
+
function makeNode(id, label, depth) {
|
|
2834
|
+
return { id, label, tokens: tokenizeInline(label), depth, children: [] };
|
|
2835
|
+
}
|
|
2637
2836
|
function parseMindmap(text2) {
|
|
2638
|
-
const
|
|
2639
|
-
|
|
2640
|
-
|
|
2837
|
+
const allLines = text2.split(/\r?\n/);
|
|
2838
|
+
let lineOffset = 0;
|
|
2839
|
+
if (allLines[0]?.trim().toLowerCase() === "mindmap") {
|
|
2840
|
+
allLines.shift();
|
|
2841
|
+
lineOffset = 1;
|
|
2842
|
+
}
|
|
2843
|
+
const lines = allLines;
|
|
2844
|
+
const directives = { style: "map", maxLabelWidth: DEFAULT_MAX_LABEL_WIDTH };
|
|
2641
2845
|
let root = null;
|
|
2642
2846
|
let idCounter2 = 0;
|
|
2643
2847
|
const nextId2 = () => `n${idCounter2++}`;
|
|
2644
2848
|
const stack = [];
|
|
2645
2849
|
let lastHeadingDepth = 0;
|
|
2646
|
-
const attach = (node, depth) => {
|
|
2850
|
+
const attach = (node, depth, lineNo, source) => {
|
|
2647
2851
|
while (stack.length && stack[stack.length - 1].depth >= depth) stack.pop();
|
|
2648
2852
|
const parent = stack[stack.length - 1]?.node;
|
|
2649
|
-
if (!parent) throw new
|
|
2853
|
+
if (!parent) throw new MindmapParseError("orphan node \u2014 expected root # heading first", lineNo, void 0, source);
|
|
2650
2854
|
node.depth = parent.depth + 1;
|
|
2651
2855
|
parent.children.push(node);
|
|
2652
2856
|
stack.push({ node, depth });
|
|
2653
2857
|
};
|
|
2654
|
-
for (
|
|
2858
|
+
for (let i = 0; i < lines.length; i++) {
|
|
2859
|
+
const raw = lines[i] ?? "";
|
|
2860
|
+
const lineNo = i + 1 + lineOffset;
|
|
2655
2861
|
const line2 = raw.replace(/\s+$/, "");
|
|
2656
2862
|
const trimmed = line2.trim();
|
|
2657
2863
|
if (!trimmed) continue;
|
|
@@ -2663,14 +2869,14 @@ function parseMindmap(text2) {
|
|
|
2663
2869
|
if (heading) {
|
|
2664
2870
|
const depth = heading[1].length - 1;
|
|
2665
2871
|
const label = heading[2].trim();
|
|
2666
|
-
const node =
|
|
2872
|
+
const node = makeNode(nextId2(), label, depth);
|
|
2667
2873
|
if (depth === 0) {
|
|
2668
|
-
if (root) throw new
|
|
2874
|
+
if (root) throw new MindmapParseError("multiple `#` center nodes not allowed", lineNo, void 0, line2);
|
|
2669
2875
|
root = node;
|
|
2670
2876
|
stack.length = 0;
|
|
2671
2877
|
stack.push({ node, depth: 0 });
|
|
2672
2878
|
} else {
|
|
2673
|
-
attach(node, depth);
|
|
2879
|
+
attach(node, depth, lineNo, line2);
|
|
2674
2880
|
}
|
|
2675
2881
|
lastHeadingDepth = depth;
|
|
2676
2882
|
continue;
|
|
@@ -2680,16 +2886,17 @@ function parseMindmap(text2) {
|
|
|
2680
2886
|
const indent = bullet[1].length;
|
|
2681
2887
|
const depth = lastHeadingDepth + 1 + Math.floor(indent / 2);
|
|
2682
2888
|
const label = bullet[2].trim();
|
|
2683
|
-
const node =
|
|
2684
|
-
attach(node, depth);
|
|
2889
|
+
const node = makeNode(nextId2(), label, depth);
|
|
2890
|
+
attach(node, depth, lineNo, line2);
|
|
2685
2891
|
continue;
|
|
2686
2892
|
}
|
|
2687
2893
|
}
|
|
2688
|
-
if (!root) throw new
|
|
2894
|
+
if (!root) throw new MindmapParseError("missing central topic \u2014 start with `# Title`");
|
|
2689
2895
|
const ast = {
|
|
2690
2896
|
type: "mindmap",
|
|
2691
2897
|
style: directives.style,
|
|
2692
|
-
root
|
|
2898
|
+
root,
|
|
2899
|
+
maxLabelWidth: directives.maxLabelWidth
|
|
2693
2900
|
};
|
|
2694
2901
|
if (directives.themeOverride) ast.themeOverride = directives.themeOverride;
|
|
2695
2902
|
return ast;
|
|
@@ -2697,10 +2904,10 @@ function parseMindmap(text2) {
|
|
|
2697
2904
|
|
|
2698
2905
|
// src/diagrams/mindmap/layout.ts
|
|
2699
2906
|
var PADDING = 40;
|
|
2700
|
-
var SIBLING_GAP =
|
|
2907
|
+
var SIBLING_GAP = 18;
|
|
2701
2908
|
var MAIN_GAP = 44;
|
|
2702
|
-
var
|
|
2703
|
-
var
|
|
2909
|
+
var UNDERLINE_GAP = 4;
|
|
2910
|
+
var LINE_GAP = 4;
|
|
2704
2911
|
function bezierGapFor(childDepth) {
|
|
2705
2912
|
if (childDepth <= 1) return 90;
|
|
2706
2913
|
if (childDepth === 2) return 60;
|
|
@@ -2714,47 +2921,68 @@ function fontSizeOf(depth) {
|
|
|
2714
2921
|
if (depth === 1) return FONT_MAIN;
|
|
2715
2922
|
return FONT_SUB;
|
|
2716
2923
|
}
|
|
2717
|
-
function
|
|
2718
|
-
return
|
|
2924
|
+
function lineHeightOf(fs) {
|
|
2925
|
+
return fs + LINE_GAP;
|
|
2719
2926
|
}
|
|
2720
|
-
function
|
|
2721
|
-
|
|
2927
|
+
function widthBudget(depth, maxLabelWidth) {
|
|
2928
|
+
if (depth === 0) return maxLabelWidth * 1.5;
|
|
2929
|
+
return maxLabelWidth;
|
|
2930
|
+
}
|
|
2931
|
+
function measureLabel(node, maxWidth) {
|
|
2932
|
+
const fs = fontSizeOf(node.depth);
|
|
2933
|
+
const raw = measureTokens(node.tokens, fs);
|
|
2934
|
+
let lines;
|
|
2935
|
+
if (raw <= maxWidth) {
|
|
2936
|
+
lines = [{ tokens: node.tokens.slice(), width: raw }];
|
|
2937
|
+
} else {
|
|
2938
|
+
lines = wrapTokens(node.tokens, maxWidth, fs);
|
|
2939
|
+
}
|
|
2940
|
+
let maxW = 0;
|
|
2941
|
+
for (const ln of lines) if (ln.width > maxW) maxW = ln.width;
|
|
2942
|
+
const lh = lineHeightOf(fs);
|
|
2943
|
+
const height = lines.length * lh + UNDERLINE_GAP;
|
|
2944
|
+
return { lines, width: Math.max(32, maxW), height };
|
|
2722
2945
|
}
|
|
2723
|
-
function
|
|
2946
|
+
function computeMaxLW(subtreeRoots, maxLabelWidth) {
|
|
2724
2947
|
const maxLW = [];
|
|
2725
2948
|
const walk = (n) => {
|
|
2726
|
-
const
|
|
2727
|
-
if (maxLW[n.depth] === void 0 ||
|
|
2949
|
+
const m = measureLabel(n, widthBudget(n.depth, maxLabelWidth));
|
|
2950
|
+
if (maxLW[n.depth] === void 0 || m.width > maxLW[n.depth]) maxLW[n.depth] = m.width;
|
|
2728
2951
|
for (const c of n.children) walk(c);
|
|
2729
2952
|
};
|
|
2730
2953
|
for (const r of subtreeRoots) walk(r);
|
|
2954
|
+
return maxLW;
|
|
2955
|
+
}
|
|
2956
|
+
function buildColumns(maxLW, firstColStartX, rootDepth) {
|
|
2731
2957
|
const center = [];
|
|
2732
|
-
if (
|
|
2733
|
-
const rootDepth = subtreeRoots[0].depth;
|
|
2958
|
+
if (maxLW[rootDepth] === void 0) return { center };
|
|
2734
2959
|
let slotLeft = firstColStartX;
|
|
2735
2960
|
center[rootDepth] = slotLeft + maxLW[rootDepth] / 2;
|
|
2736
2961
|
for (let d = rootDepth + 1; d < maxLW.length; d++) {
|
|
2737
2962
|
slotLeft = slotLeft + maxLW[d - 1] + bezierGapFor(d);
|
|
2738
|
-
center[d] = slotLeft + maxLW[d] / 2;
|
|
2963
|
+
center[d] = slotLeft + (maxLW[d] ?? 0) / 2;
|
|
2739
2964
|
}
|
|
2740
2965
|
return { center };
|
|
2741
2966
|
}
|
|
2742
|
-
function tidyRight(node, yTop, branchIdx, columns, out) {
|
|
2743
|
-
const
|
|
2744
|
-
const lw = estimateLabelWidth2(node.label, node.depth);
|
|
2967
|
+
function tidyRight(node, yTop, branchIdx, columns, maxLabelWidth, maxLW, out) {
|
|
2968
|
+
const m = measureLabel(node, widthBudget(node.depth, maxLabelWidth));
|
|
2745
2969
|
const x = columns.center[node.depth];
|
|
2970
|
+
const fs = fontSizeOf(node.depth);
|
|
2971
|
+
const labelWidth = Math.max(m.width, maxLW[node.depth] ?? m.width);
|
|
2746
2972
|
if (node.children.length === 0) {
|
|
2747
2973
|
const ln2 = {
|
|
2748
2974
|
node,
|
|
2749
2975
|
x,
|
|
2750
|
-
y: yTop +
|
|
2976
|
+
y: yTop + m.height / 2,
|
|
2751
2977
|
side: "right",
|
|
2752
2978
|
branchIndex: branchIdx,
|
|
2753
|
-
labelWidth
|
|
2754
|
-
labelHeight:
|
|
2979
|
+
labelWidth,
|
|
2980
|
+
labelHeight: m.height,
|
|
2981
|
+
fontSize: fs,
|
|
2982
|
+
lines: m.lines
|
|
2755
2983
|
};
|
|
2756
2984
|
out.push(ln2);
|
|
2757
|
-
return { layoutNode: ln2, height:
|
|
2985
|
+
return { layoutNode: ln2, height: m.height };
|
|
2758
2986
|
}
|
|
2759
2987
|
let cursor = yTop;
|
|
2760
2988
|
const childLayouts = [];
|
|
@@ -2765,12 +2993,14 @@ function tidyRight(node, yTop, branchIdx, columns, out) {
|
|
|
2765
2993
|
cursor,
|
|
2766
2994
|
branchIdx,
|
|
2767
2995
|
columns,
|
|
2996
|
+
maxLabelWidth,
|
|
2997
|
+
maxLW,
|
|
2768
2998
|
out
|
|
2769
2999
|
);
|
|
2770
3000
|
childLayouts.push(cln);
|
|
2771
3001
|
cursor += height;
|
|
2772
3002
|
}
|
|
2773
|
-
const totalH = Math.max(
|
|
3003
|
+
const totalH = Math.max(m.height, cursor - yTop);
|
|
2774
3004
|
const firstY = childLayouts[0].y;
|
|
2775
3005
|
const lastY = childLayouts[childLayouts.length - 1].y;
|
|
2776
3006
|
const parentY = (firstY + lastY) / 2;
|
|
@@ -2780,8 +3010,10 @@ function tidyRight(node, yTop, branchIdx, columns, out) {
|
|
|
2780
3010
|
y: parentY,
|
|
2781
3011
|
side: "right",
|
|
2782
3012
|
branchIndex: branchIdx,
|
|
2783
|
-
labelWidth
|
|
2784
|
-
labelHeight:
|
|
3013
|
+
labelWidth,
|
|
3014
|
+
labelHeight: m.height,
|
|
3015
|
+
fontSize: fs,
|
|
3016
|
+
lines: m.lines
|
|
2785
3017
|
};
|
|
2786
3018
|
out.push(ln);
|
|
2787
3019
|
return { layoutNode: ln, height: totalH };
|
|
@@ -2796,7 +3028,15 @@ function bezierH(x1, y1, x2, y2) {
|
|
|
2796
3028
|
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)}`;
|
|
2797
3029
|
}
|
|
2798
3030
|
function edgeWidthFor(depth) {
|
|
2799
|
-
|
|
3031
|
+
if (depth <= 1) return 2.2;
|
|
3032
|
+
if (depth === 2) return 1.6;
|
|
3033
|
+
return 1.2;
|
|
3034
|
+
}
|
|
3035
|
+
function underlineWidthFor(depth) {
|
|
3036
|
+
if (depth === 0) return 2.4;
|
|
3037
|
+
if (depth === 1) return 2.2;
|
|
3038
|
+
if (depth === 2) return 1.6;
|
|
3039
|
+
return 1.2;
|
|
2800
3040
|
}
|
|
2801
3041
|
function normalize(nodes) {
|
|
2802
3042
|
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
@@ -2807,8 +3047,8 @@ function normalize(nodes) {
|
|
|
2807
3047
|
const rightX = n.x + lw / 2;
|
|
2808
3048
|
minX = Math.min(minX, leftX);
|
|
2809
3049
|
maxX = Math.max(maxX, rightX);
|
|
2810
|
-
minY = Math.min(minY, n.y - lh);
|
|
2811
|
-
maxY = Math.max(maxY, n.y + lh);
|
|
3050
|
+
minY = Math.min(minY, n.y - lh / 2);
|
|
3051
|
+
maxY = Math.max(maxY, n.y + lh / 2);
|
|
2812
3052
|
}
|
|
2813
3053
|
const dx = PADDING - minX;
|
|
2814
3054
|
const dy = PADDING - minY;
|
|
@@ -2818,10 +3058,14 @@ function normalize(nodes) {
|
|
|
2818
3058
|
}
|
|
2819
3059
|
return { width: maxX - minX + PADDING * 2, height: maxY - minY + PADDING * 2 };
|
|
2820
3060
|
}
|
|
3061
|
+
function underlineY(n) {
|
|
3062
|
+
return n.y + n.labelHeight / 2 - UNDERLINE_GAP / 2;
|
|
3063
|
+
}
|
|
2821
3064
|
function buildEdges(root, byId) {
|
|
2822
3065
|
const edges = [];
|
|
2823
3066
|
const walk = (parent) => {
|
|
2824
3067
|
const pln = byId.get(parent.id);
|
|
3068
|
+
const pUY = underlineY(pln);
|
|
2825
3069
|
for (const c of parent.children) {
|
|
2826
3070
|
const cln = byId.get(c.id);
|
|
2827
3071
|
let fromX;
|
|
@@ -2835,7 +3079,7 @@ function buildEdges(root, byId) {
|
|
|
2835
3079
|
edges.push({
|
|
2836
3080
|
from: parent.id,
|
|
2837
3081
|
to: c.id,
|
|
2838
|
-
path: bezierH(fromX,
|
|
3082
|
+
path: bezierH(fromX, pUY, toX, underlineY(cln)),
|
|
2839
3083
|
color: "",
|
|
2840
3084
|
width: edgeWidthFor(c.depth)
|
|
2841
3085
|
});
|
|
@@ -2852,24 +3096,23 @@ function layoutMap(ast) {
|
|
|
2852
3096
|
const rightMains = mains.slice(0, rightCount);
|
|
2853
3097
|
const leftMains = mains.slice(rightCount);
|
|
2854
3098
|
const nodes = [];
|
|
2855
|
-
const
|
|
2856
|
-
const
|
|
2857
|
-
const
|
|
2858
|
-
const
|
|
2859
|
-
const
|
|
3099
|
+
const mw = ast.maxLabelWidth;
|
|
3100
|
+
const rootM = measureLabel(root, widthBudget(0, mw));
|
|
3101
|
+
const firstColLeft = rootM.width / 2 + bezierGapFor(1);
|
|
3102
|
+
const maxLW = computeMaxLW([...rightMains, ...leftMains], mw);
|
|
3103
|
+
const cols = buildColumns(maxLW, firstColLeft, 1);
|
|
2860
3104
|
let rightCursor = 0;
|
|
2861
3105
|
for (let i = 0; i < rightMains.length; i++) {
|
|
2862
3106
|
if (i > 0) rightCursor += MAIN_GAP;
|
|
2863
|
-
const { height: height2 } = tidyRight(rightMains[i], rightCursor, i,
|
|
3107
|
+
const { height: height2 } = tidyRight(rightMains[i], rightCursor, i, cols, mw, maxLW, nodes);
|
|
2864
3108
|
rightCursor += height2;
|
|
2865
3109
|
}
|
|
2866
3110
|
const rightHeight = rightCursor;
|
|
2867
|
-
const leftCols = computeColumns(leftMains, firstColLeft);
|
|
2868
3111
|
const leftStart = nodes.length;
|
|
2869
3112
|
let leftCursor = 0;
|
|
2870
3113
|
for (let i = 0; i < leftMains.length; i++) {
|
|
2871
3114
|
if (i > 0) leftCursor += MAIN_GAP;
|
|
2872
|
-
const { height: height2 } = tidyRight(leftMains[i], leftCursor, rightCount + i,
|
|
3115
|
+
const { height: height2 } = tidyRight(leftMains[i], leftCursor, rightCount + i, cols, mw, maxLW, nodes);
|
|
2873
3116
|
leftCursor += height2;
|
|
2874
3117
|
}
|
|
2875
3118
|
const leftHeight = leftCursor;
|
|
@@ -2884,8 +3127,10 @@ function layoutMap(ast) {
|
|
|
2884
3127
|
y: rootY,
|
|
2885
3128
|
side: "center",
|
|
2886
3129
|
branchIndex: -1,
|
|
2887
|
-
labelWidth:
|
|
2888
|
-
labelHeight:
|
|
3130
|
+
labelWidth: rootM.width,
|
|
3131
|
+
labelHeight: rootM.height,
|
|
3132
|
+
fontSize: fontSizeOf(0),
|
|
3133
|
+
lines: rootM.lines
|
|
2889
3134
|
};
|
|
2890
3135
|
nodes.push(rootNode);
|
|
2891
3136
|
const { width, height } = normalize(nodes);
|
|
@@ -2896,15 +3141,15 @@ function layoutMap(ast) {
|
|
|
2896
3141
|
function layoutLogicRight(ast) {
|
|
2897
3142
|
const root = ast.root;
|
|
2898
3143
|
const nodes = [];
|
|
2899
|
-
const
|
|
2900
|
-
const
|
|
2901
|
-
const
|
|
2902
|
-
const
|
|
2903
|
-
const cols =
|
|
3144
|
+
const mw = ast.maxLabelWidth;
|
|
3145
|
+
const rootM = measureLabel(root, widthBudget(0, mw));
|
|
3146
|
+
const firstColLeft = rootM.width / 2 + bezierGapFor(1);
|
|
3147
|
+
const maxLW = computeMaxLW(root.children, mw);
|
|
3148
|
+
const cols = buildColumns(maxLW, firstColLeft, 1);
|
|
2904
3149
|
let cursor = 0;
|
|
2905
3150
|
for (let i = 0; i < root.children.length; i++) {
|
|
2906
3151
|
if (i > 0) cursor += MAIN_GAP;
|
|
2907
|
-
const { height: height2 } = tidyRight(root.children[i], cursor, i, cols, nodes);
|
|
3152
|
+
const { height: height2 } = tidyRight(root.children[i], cursor, i, cols, mw, maxLW, nodes);
|
|
2908
3153
|
cursor += height2;
|
|
2909
3154
|
}
|
|
2910
3155
|
const totalHeight = cursor;
|
|
@@ -2914,8 +3159,10 @@ function layoutLogicRight(ast) {
|
|
|
2914
3159
|
y: totalHeight / 2,
|
|
2915
3160
|
side: "center",
|
|
2916
3161
|
branchIndex: -1,
|
|
2917
|
-
labelWidth:
|
|
2918
|
-
labelHeight:
|
|
3162
|
+
labelWidth: rootM.width,
|
|
3163
|
+
labelHeight: rootM.height,
|
|
3164
|
+
fontSize: fontSizeOf(0),
|
|
3165
|
+
lines: rootM.lines
|
|
2919
3166
|
};
|
|
2920
3167
|
nodes.push(rootNode);
|
|
2921
3168
|
const { width, height } = normalize(nodes);
|
|
@@ -2930,95 +3177,174 @@ function layoutMindmap(ast) {
|
|
|
2930
3177
|
}
|
|
2931
3178
|
|
|
2932
3179
|
// src/diagrams/mindmap/renderer.ts
|
|
2933
|
-
|
|
2934
|
-
|
|
3180
|
+
function strokeScale(theme) {
|
|
3181
|
+
return theme.branchPalette.length <= 1 ? 0.7 : 1;
|
|
3182
|
+
}
|
|
2935
3183
|
function paletteColor(theme, branchIndex) {
|
|
2936
3184
|
if (branchIndex < 0) return theme.centralFill;
|
|
2937
3185
|
return theme.branchPalette[branchIndex % theme.branchPalette.length];
|
|
2938
3186
|
}
|
|
2939
|
-
function
|
|
2940
|
-
|
|
3187
|
+
function renderLine(line2, leftX, cy, fontSize, fontFamily, fontWeight, theme) {
|
|
3188
|
+
const baselineY = cy + fontSize * 0.35;
|
|
3189
|
+
const tspans = [];
|
|
3190
|
+
const decorations = [];
|
|
3191
|
+
let cursor = leftX;
|
|
3192
|
+
const emit = (tok, inheritedHref) => {
|
|
3193
|
+
switch (tok.kind) {
|
|
3194
|
+
case "text": {
|
|
3195
|
+
const w = measureToken(tok, fontSize);
|
|
3196
|
+
tspans.push(
|
|
3197
|
+
tspan({
|
|
3198
|
+
x: cursor,
|
|
3199
|
+
y: baselineY,
|
|
3200
|
+
fill: inheritedHref ? theme.linkColor : theme.text,
|
|
3201
|
+
"font-weight": tok.bold ? 700 : fontWeight,
|
|
3202
|
+
"font-style": tok.italic ? "italic" : void 0,
|
|
3203
|
+
"text-decoration": inheritedHref ? "underline" : void 0
|
|
3204
|
+
}, tok.value)
|
|
3205
|
+
);
|
|
3206
|
+
cursor += w;
|
|
3207
|
+
break;
|
|
3208
|
+
}
|
|
3209
|
+
case "code": {
|
|
3210
|
+
const w = measureToken(tok, fontSize);
|
|
3211
|
+
decorations.push(chunkHDKDQAEQ_cjs.rect({
|
|
3212
|
+
x: cursor,
|
|
3213
|
+
y: cy - fontSize * 0.6,
|
|
3214
|
+
width: w,
|
|
3215
|
+
height: fontSize * 1.2,
|
|
3216
|
+
rx: 3,
|
|
3217
|
+
ry: 3,
|
|
3218
|
+
fill: theme.codeBg
|
|
3219
|
+
}));
|
|
3220
|
+
tspans.push(
|
|
3221
|
+
tspan({
|
|
3222
|
+
x: cursor + 2,
|
|
3223
|
+
y: baselineY,
|
|
3224
|
+
fill: theme.codeFg,
|
|
3225
|
+
"font-family": "ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",
|
|
3226
|
+
"font-size": fontSize * 0.92
|
|
3227
|
+
}, tok.value)
|
|
3228
|
+
);
|
|
3229
|
+
cursor += w;
|
|
3230
|
+
break;
|
|
3231
|
+
}
|
|
3232
|
+
case "link": {
|
|
3233
|
+
const aStart = `<a href="${chunkHDKDQAEQ_cjs.escapeXml(tok.href)}" target="_blank" rel="noopener">`;
|
|
3234
|
+
const innerStart = tspans.length;
|
|
3235
|
+
for (const inner of tok.value) emit(inner, tok.href);
|
|
3236
|
+
const innerTspans = tspans.splice(innerStart).join("");
|
|
3237
|
+
tspans.push(aStart + innerTspans + "</a>");
|
|
3238
|
+
break;
|
|
3239
|
+
}
|
|
3240
|
+
case "checkbox": {
|
|
3241
|
+
const size = fontSize * 0.85;
|
|
3242
|
+
const boxX = cursor;
|
|
3243
|
+
const boxY = cy - size / 2;
|
|
3244
|
+
decorations.push(chunkHDKDQAEQ_cjs.rect({
|
|
3245
|
+
x: boxX,
|
|
3246
|
+
y: boxY,
|
|
3247
|
+
width: size,
|
|
3248
|
+
height: size,
|
|
3249
|
+
rx: 2,
|
|
3250
|
+
ry: 2,
|
|
3251
|
+
fill: tok.checked ? theme.checkboxFill : "none",
|
|
3252
|
+
stroke: tok.checked ? theme.checkboxFill : theme.checkboxStroke,
|
|
3253
|
+
"stroke-width": 1.5
|
|
3254
|
+
}));
|
|
3255
|
+
if (tok.checked) {
|
|
3256
|
+
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)}`;
|
|
3257
|
+
decorations.push(chunkHDKDQAEQ_cjs.path({
|
|
3258
|
+
d: p,
|
|
3259
|
+
fill: "none",
|
|
3260
|
+
stroke: "#ffffff",
|
|
3261
|
+
"stroke-width": 2,
|
|
3262
|
+
"stroke-linecap": "round",
|
|
3263
|
+
"stroke-linejoin": "round"
|
|
3264
|
+
}));
|
|
3265
|
+
}
|
|
3266
|
+
cursor += size + fontSize * 0.25;
|
|
3267
|
+
break;
|
|
3268
|
+
}
|
|
3269
|
+
}
|
|
3270
|
+
};
|
|
3271
|
+
for (const tok of line2.tokens) emit(tok);
|
|
3272
|
+
const textElement = chunkHDKDQAEQ_cjs.el("text", {
|
|
3273
|
+
"font-family": fontFamily,
|
|
3274
|
+
"font-size": fontSize,
|
|
3275
|
+
"font-weight": fontWeight
|
|
3276
|
+
}, tspans.join(""));
|
|
3277
|
+
return { textElement, decorations };
|
|
3278
|
+
}
|
|
3279
|
+
function measureToken(tok, fs) {
|
|
3280
|
+
switch (tok.kind) {
|
|
3281
|
+
case "text":
|
|
3282
|
+
return tok.value.length * fs * (tok.bold ? 0.62 : 0.58);
|
|
3283
|
+
case "code":
|
|
3284
|
+
return tok.value.length * fs * 0.62 + 4;
|
|
3285
|
+
case "link": {
|
|
3286
|
+
let w = 0;
|
|
3287
|
+
for (const t of tok.value) w += measureToken(t, fs);
|
|
3288
|
+
return w;
|
|
3289
|
+
}
|
|
3290
|
+
case "checkbox":
|
|
3291
|
+
return fs * 0.85 + fs * 0.25;
|
|
3292
|
+
}
|
|
2941
3293
|
}
|
|
2942
|
-
function
|
|
2943
|
-
const
|
|
2944
|
-
const
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
chunkHDKDQAEQ_cjs.rect({
|
|
2950
|
-
x: n.x - pillW / 2,
|
|
2951
|
-
y: n.y - pillH / 2,
|
|
2952
|
-
width: pillW,
|
|
2953
|
-
height: pillH,
|
|
2954
|
-
rx: pillH / 2,
|
|
2955
|
-
ry: pillH / 2,
|
|
2956
|
-
fill: "none",
|
|
2957
|
-
stroke: theme.textMuted,
|
|
2958
|
-
"stroke-width": underlineMain(theme)
|
|
2959
|
-
}),
|
|
2960
|
-
chunkHDKDQAEQ_cjs.text(
|
|
2961
|
-
{
|
|
2962
|
-
x: n.x,
|
|
2963
|
-
y: n.y + fs * 0.35,
|
|
2964
|
-
"text-anchor": "middle",
|
|
2965
|
-
"font-family": fontFamily,
|
|
2966
|
-
"font-size": fs,
|
|
2967
|
-
"font-weight": 700,
|
|
2968
|
-
fill: theme.text
|
|
2969
|
-
},
|
|
2970
|
-
n.node.label
|
|
2971
|
-
)
|
|
2972
|
-
]
|
|
2973
|
-
);
|
|
3294
|
+
function tspan(attrs, content) {
|
|
3295
|
+
const pairs = [];
|
|
3296
|
+
for (const [k, v] of Object.entries(attrs)) {
|
|
3297
|
+
if (v === void 0) continue;
|
|
3298
|
+
pairs.push(`${k}="${typeof v === "number" ? String(v) : chunkHDKDQAEQ_cjs.escapeXml(String(v))}"`);
|
|
3299
|
+
}
|
|
3300
|
+
return `<tspan ${pairs.join(" ")}>${chunkHDKDQAEQ_cjs.escapeXml(content)}</tspan>`;
|
|
2974
3301
|
}
|
|
2975
|
-
function
|
|
3302
|
+
function renderNode(n, color, theme, fontFamily) {
|
|
3303
|
+
const isRoot = n.node.depth === 0;
|
|
2976
3304
|
const isMain = n.node.depth === 1;
|
|
2977
|
-
const fs =
|
|
2978
|
-
const
|
|
2979
|
-
const
|
|
3305
|
+
const fs = n.fontSize;
|
|
3306
|
+
const lh = lineHeightOf(fs);
|
|
3307
|
+
const lineCount = n.lines.length;
|
|
3308
|
+
const topY = n.y - n.labelHeight / 2;
|
|
3309
|
+
const underlineY2 = n.y + n.labelHeight / 2 - UNDERLINE_GAP / 2;
|
|
3310
|
+
const children = [];
|
|
3311
|
+
const decorations = [];
|
|
3312
|
+
const weight = isRoot ? 700 : isMain ? 600 : 400;
|
|
3313
|
+
const textLeft = n.x - n.labelWidth / 2;
|
|
3314
|
+
for (let i = 0; i < lineCount; i++) {
|
|
3315
|
+
const line2 = n.lines[i];
|
|
3316
|
+
const cy = topY + (i + 0.5) * lh;
|
|
3317
|
+
const r = renderLine(line2, textLeft, cy, fs, fontFamily, weight, theme);
|
|
3318
|
+
decorations.push(...r.decorations);
|
|
3319
|
+
children.push(r.textElement);
|
|
3320
|
+
}
|
|
2980
3321
|
const ux1 = n.x - n.labelWidth / 2;
|
|
2981
3322
|
const ux2 = n.x + n.labelWidth / 2;
|
|
2982
|
-
const
|
|
2983
|
-
|
|
2984
|
-
chunkHDKDQAEQ_cjs.
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
)
|
|
2996
|
-
];
|
|
2997
|
-
if (isMain) {
|
|
2998
|
-
children.push(
|
|
2999
|
-
chunkHDKDQAEQ_cjs.el("line", {
|
|
3000
|
-
x1: ux1,
|
|
3001
|
-
y1: uy,
|
|
3002
|
-
x2: ux2,
|
|
3003
|
-
y2: uy,
|
|
3004
|
-
stroke: color,
|
|
3005
|
-
"stroke-width": underlineMain(theme),
|
|
3006
|
-
"stroke-linecap": "round"
|
|
3007
|
-
})
|
|
3008
|
-
);
|
|
3009
|
-
}
|
|
3323
|
+
const sw = underlineWidthFor(n.node.depth) * strokeScale(theme);
|
|
3324
|
+
children.push(
|
|
3325
|
+
chunkHDKDQAEQ_cjs.el("line", {
|
|
3326
|
+
x1: ux1,
|
|
3327
|
+
y1: underlineY2,
|
|
3328
|
+
x2: ux2,
|
|
3329
|
+
y2: underlineY2,
|
|
3330
|
+
stroke: color,
|
|
3331
|
+
"stroke-width": sw,
|
|
3332
|
+
"stroke-linecap": "round"
|
|
3333
|
+
})
|
|
3334
|
+
);
|
|
3335
|
+
const cls = isRoot ? "schematex-mindmap-central" : isMain ? "schematex-mindmap-main" : "schematex-mindmap-leaf";
|
|
3010
3336
|
return chunkHDKDQAEQ_cjs.group(
|
|
3011
3337
|
{
|
|
3012
|
-
class:
|
|
3338
|
+
class: cls,
|
|
3013
3339
|
"data-node-id": n.node.id,
|
|
3014
3340
|
"data-depth": n.node.depth,
|
|
3015
3341
|
"data-branch-idx": n.branchIndex
|
|
3016
3342
|
},
|
|
3017
|
-
children
|
|
3343
|
+
[...decorations, ...children]
|
|
3018
3344
|
);
|
|
3019
3345
|
}
|
|
3020
3346
|
function renderMindmapAST(ast, themeName = "default", fontFamily = "system-ui, -apple-system, sans-serif") {
|
|
3021
|
-
const theme =
|
|
3347
|
+
const theme = chunkD7EHZFK4_cjs.resolveMindmapTheme(ast.themeOverride ?? themeName);
|
|
3022
3348
|
const layout = layoutMindmap(ast);
|
|
3023
3349
|
const byId = new Map(layout.nodes.map((n) => [n.node.id, n]));
|
|
3024
3350
|
const edgeSvgs = [];
|
|
@@ -3038,15 +3364,10 @@ function renderMindmapAST(ast, themeName = "default", fontFamily = "system-ui, -
|
|
|
3038
3364
|
}
|
|
3039
3365
|
const nodeSvgs = [];
|
|
3040
3366
|
for (const n of layout.nodes) {
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
} else {
|
|
3044
|
-
nodeSvgs.push(
|
|
3045
|
-
renderBranchNode(n, paletteColor(theme, n.branchIndex), theme, fontFamily)
|
|
3046
|
-
);
|
|
3047
|
-
}
|
|
3367
|
+
const color = n.node.depth === 0 ? theme.centralFill : paletteColor(theme, n.branchIndex);
|
|
3368
|
+
nodeSvgs.push(renderNode(n, color, theme, fontFamily));
|
|
3048
3369
|
}
|
|
3049
|
-
const title2 = ast.title ?? ast.root.
|
|
3370
|
+
const title2 = ast.title ?? tokensToPlainText(ast.root.tokens);
|
|
3050
3371
|
return chunkHDKDQAEQ_cjs.svgRoot(
|
|
3051
3372
|
{
|
|
3052
3373
|
viewBox: `0 0 ${layout.width.toFixed(1)} ${layout.height.toFixed(1)}`,
|
|
@@ -4485,24 +4806,24 @@ var matrix = {
|
|
|
4485
4806
|
|
|
4486
4807
|
// src/core/api.ts
|
|
4487
4808
|
var plugins = [
|
|
4488
|
-
|
|
4489
|
-
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
|
|
4495
|
-
|
|
4496
|
-
|
|
4497
|
-
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
|
|
4501
|
-
|
|
4502
|
-
|
|
4809
|
+
chunk6LZJTAA3_cjs.genogram,
|
|
4810
|
+
chunkE65ITQXV_cjs.ecomap,
|
|
4811
|
+
chunkB37IKTI7_cjs.pedigree,
|
|
4812
|
+
chunkX7RPFTTR_cjs.phylo,
|
|
4813
|
+
chunkCOLTVQWR_cjs.sociogram,
|
|
4814
|
+
chunk2JDVJRR3_cjs.timing,
|
|
4815
|
+
chunkWYFXOXVK_cjs.logic,
|
|
4816
|
+
chunk4S2WILLW_cjs.circuit,
|
|
4817
|
+
chunkMCFQAUQV_cjs.blockdiagram,
|
|
4818
|
+
chunkB6INLQBU_cjs.ladder,
|
|
4819
|
+
chunk3YZ6FPQW_cjs.sld,
|
|
4820
|
+
chunkZNOD4VZT_cjs.entity,
|
|
4821
|
+
chunk5AEN2PLB_cjs.fishbone,
|
|
4822
|
+
chunkQSQX77S2_cjs.venn,
|
|
4823
|
+
chunkZ3DE6S64_cjs.flowchart,
|
|
4503
4824
|
mindmap,
|
|
4504
4825
|
matrix,
|
|
4505
|
-
|
|
4826
|
+
chunkA5D2IMOX_cjs.orgchart,
|
|
4506
4827
|
decisiontree,
|
|
4507
4828
|
timeline
|
|
4508
4829
|
];
|
|
@@ -4540,5 +4861,5 @@ exports.decisiontree = decisiontree;
|
|
|
4540
4861
|
exports.parse = parse;
|
|
4541
4862
|
exports.render = render;
|
|
4542
4863
|
exports.timeline = timeline;
|
|
4543
|
-
//# sourceMappingURL=chunk-
|
|
4544
|
-
//# sourceMappingURL=chunk-
|
|
4864
|
+
//# sourceMappingURL=chunk-QXIGHMH2.cjs.map
|
|
4865
|
+
//# sourceMappingURL=chunk-QXIGHMH2.cjs.map
|