@diagrammo/dgmo 0.94.0 → 0.95.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/advanced.d.ts +72 -3
- package/dist/advanced.js +49 -32
- package/dist/block.d.ts +6 -0
- package/dist/block.js +17 -14
- package/dist/chart-meta.js +7 -7
- package/dist/{chunk-TDAGJJPZ.js → chunk-2J2CWWWK.js} +1 -1
- package/dist/{chunk-2XMTZ5JR.js → chunk-4UVCTLRH.js} +1 -1
- package/dist/{chunk-DLJJOCIT.js → chunk-5XBYLYYI.js} +1 -1
- package/dist/{chunk-XKCRKD2B.js → chunk-62GLKE6Q.js} +3 -3
- package/dist/{chunk-VDY2GR6U.js → chunk-67N26CER.js} +2 -2
- package/dist/{chunk-I37S3EZE.js → chunk-6EFCOES2.js} +366 -281
- package/dist/{chunk-HI6R27YA.js → chunk-7IALGIOI.js} +2 -2
- package/dist/{chunk-RESEJSCV.js → chunk-BCV2VJTM.js} +2 -2
- package/dist/{chunk-2HSHWPTO.js → chunk-BTP2BMWN.js} +4 -4
- package/dist/{chunk-KBHT5XEY.js → chunk-E7F76M3U.js} +138 -31
- package/dist/{chunk-JT2BG7LM.js → chunk-EXHXTMVR.js} +3 -3
- package/dist/{chunk-7IOZ6JE4.js → chunk-IQN2NGEU.js} +3 -3
- package/dist/{chunk-DNM3XZCK.js → chunk-IY62DXT2.js} +1 -1
- package/dist/{chunk-B25IWGDH.js → chunk-JJ7RGTAU.js} +2 -2
- package/dist/{chunk-7SXV7NUS.js → chunk-KLBTJEIK.js} +1 -1
- package/dist/{chunk-DDIOWNHS.js → chunk-L5S32VZJ.js} +3 -3
- package/dist/{chunk-AYUSD4Z6.js → chunk-LAXMUSGW.js} +3 -3
- package/dist/{chunk-2MS623GW.js → chunk-LJGE43SG.js} +1 -1
- package/dist/{chunk-5ZUZZDW5.js → chunk-P5XA627W.js} +7 -7
- package/dist/{chunk-DRQSB72S.js → chunk-PGBTUGDB.js} +2 -2
- package/dist/{chunk-P7TRFL4P.js → chunk-R46N5KR4.js} +2 -0
- package/dist/{chunk-4TEPDQHJ.js → chunk-RQTDUZUH.js} +1 -1
- package/dist/{chunk-CIHHTS5B.js → chunk-S4SJ4LLY.js} +1 -1
- package/dist/{chunk-5HAYT43L.js → chunk-U6VS3T2M.js} +19 -3
- package/dist/{chunk-4SP6OUO7.js → chunk-USE6HIOZ.js} +32 -32
- package/dist/{chunk-2FDQEQID.js → chunk-USZLHYEQ.js} +1 -1
- package/dist/{chunk-NOQB4KMV.js → chunk-V5D6GDNK.js} +1 -1
- package/dist/{chunk-6JCTW74W.js → chunk-VB4VMB2I.js} +1 -1
- package/dist/{chunk-G3HZ4PGE.js → chunk-VF7IKIRS.js} +1 -1
- package/dist/{chunk-3ZP3QC47.js → chunk-VTESGA5F.js} +2 -2
- package/dist/{chunk-3TWBMU7K.js → chunk-XOMIYMQ3.js} +5 -5
- package/dist/completion-registry.js +3 -0
- package/dist/copy-image.d.ts +34 -0
- package/dist/copy-image.js +96 -0
- package/dist/{dgmo-router-E5O7RJSW.js → dgmo-router-6YLKM6WU.js} +11 -11
- package/dist/{flowchart-parser-NZXASOZG.js → flowchart-parser-J3VWIFWB.js} +3 -3
- package/dist/{flowchart-renderer-PTCRIANF.js → flowchart-renderer-FECH5KK5.js} +8 -8
- package/dist/index.js +13 -13
- package/dist/{layout-IT4ZTV6C.js → layout-5SZ5A64I.js} +6 -6
- package/dist/{layout-VC3MXRB4.js → layout-EWXHEXNS.js} +6 -6
- package/dist/{layout-U3AH6M7J.js → layout-TIBRMWHL.js} +3 -3
- package/dist/{layout-ISSBWBH7.js → layout-YBMT74MG.js} +6 -6
- package/dist/{layout-search-BBX2BMEF.js → layout-search-AWPJWBKT.js} +4 -4
- package/dist/{parser-R3LPEQIT.js → parser-AR2GON37.js} +2 -2
- package/dist/{parser-4RFY7D52.js → parser-BTSTKY5G.js} +3 -3
- package/dist/{parser-TAYRTCPR.js → parser-MA7L3XND.js} +3 -3
- package/dist/{parser-7QKQ4P4P.js → parser-ZRIZFDZY.js} +3 -3
- package/dist/{renderer-LNP23NSM.js → renderer-2QPHDBZY.js} +2 -2
- package/dist/{renderer-J3GPDK73.js → renderer-4VGO27EE.js} +8 -8
- package/dist/{renderer-JJ4QW3SK.js → renderer-6BDK47V6.js} +1 -1
- package/dist/{renderer-FMTLSOCX.js → renderer-ACQQ2JXA.js} +1 -1
- package/dist/{renderer-M5DUMITP.js → renderer-IGSHD3OT.js} +2 -2
- package/dist/{renderer-53B523PM.js → renderer-IVHD7ENY.js} +2 -2
- package/dist/{renderer-OUDHH5MV.js → renderer-P3WR7TKD.js} +8 -8
- package/dist/{renderer-XOWDERU2.js → renderer-UGW4N2W5.js} +1 -1
- package/dist/{renderer-PHLCYVSN.js → renderer-XDX6S7OV.js} +1 -1
- package/dist/{renderer-J7ZSTJUE.js → renderer-Y47EM337.js} +1 -1
- package/dist/{renderer-4SE7R22T.js → renderer-ZV6KCLCL.js} +12 -12
- package/dist/{state-parser-KPVW5CRI.js → state-parser-PMNHLHLE.js} +3 -3
- package/dist/{state-renderer-ZVEI265C.js → state-renderer-JQ5DS66J.js} +8 -8
- package/docs/language-reference.md +2 -2
- package/package.json +5 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
searchPlacement
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-2J2CWWWK.js";
|
|
4
4
|
import {
|
|
5
5
|
buildPlacedNotes,
|
|
6
6
|
noteCanvasShift,
|
|
7
7
|
resolveNotes
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-KLBTJEIK.js";
|
|
9
9
|
import {
|
|
10
10
|
measureText
|
|
11
11
|
} from "./chunk-KAO7JL4I.js";
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
searchPlacement
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-2J2CWWWK.js";
|
|
4
4
|
import {
|
|
5
5
|
buildPlacedNotes,
|
|
6
6
|
noteCanvasShift,
|
|
7
7
|
resolveNotes
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-KLBTJEIK.js";
|
|
9
9
|
import {
|
|
10
10
|
measureText
|
|
11
11
|
} from "./chunk-KAO7JL4I.js";
|
|
@@ -15,16 +15,16 @@ import {
|
|
|
15
15
|
} from "./chunk-CDM6XMOT.js";
|
|
16
16
|
import {
|
|
17
17
|
looksLikeFlowchart
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-IY62DXT2.js";
|
|
19
19
|
import {
|
|
20
20
|
looksLikeState
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-LJGE43SG.js";
|
|
22
22
|
import {
|
|
23
23
|
looksLikeERDiagram
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-S4SJ4LLY.js";
|
|
25
25
|
import {
|
|
26
26
|
looksLikeClassDiagram
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-5XBYLYYI.js";
|
|
28
28
|
import {
|
|
29
29
|
parseFirstLine
|
|
30
30
|
} from "./chunk-TIIZIAGS.js";
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
import {
|
|
10
10
|
WHITEBOARD_COLORS,
|
|
11
11
|
WHITEBOARD_NOTE_COLOR
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-R46N5KR4.js";
|
|
13
13
|
import {
|
|
14
14
|
renderChartTitle
|
|
15
15
|
} from "./chunk-6XLMTAEX.js";
|
|
@@ -132,6 +132,17 @@ function pieceContains(p, px, py) {
|
|
|
132
132
|
function whiteboardShapeContains(shape, point) {
|
|
133
133
|
return piecesOf(shape).some((p) => pieceContains(p, point.x, point.y));
|
|
134
134
|
}
|
|
135
|
+
function whiteboardLabelPosition(shape, elements) {
|
|
136
|
+
if (shape.labelPosition) return shape.labelPosition;
|
|
137
|
+
return shape.shape === "rectangle" && whiteboardEnclosesAny(shape, elements) ? "top" : "middle";
|
|
138
|
+
}
|
|
139
|
+
function whiteboardEnclosesAny(outer, elements) {
|
|
140
|
+
const x1 = outer.x + outer.width;
|
|
141
|
+
const y1 = outer.y + outer.height;
|
|
142
|
+
return elements.some(
|
|
143
|
+
(el) => el !== outer && (el.kind === "shape" || el.kind === "note" || el.kind === "image") && el.x >= outer.x && el.y >= outer.y && el.x + el.width <= x1 && el.y + el.height <= y1 && !(el.x === outer.x && el.y === outer.y && el.width === outer.width && el.height === outer.height)
|
|
144
|
+
);
|
|
145
|
+
}
|
|
135
146
|
function whiteboardShapeAt(point, elements) {
|
|
136
147
|
for (let i = elements.length - 1; i >= 0; i--) {
|
|
137
148
|
const el = elements[i];
|
|
@@ -331,9 +342,35 @@ function whiteboardSegmentMidpoint(s) {
|
|
|
331
342
|
y: (s.y1 + 2 * s.cy + s.y2) / 4
|
|
332
343
|
};
|
|
333
344
|
}
|
|
345
|
+
var DRAW_BAND = {
|
|
346
|
+
image: 0,
|
|
347
|
+
shape: 1,
|
|
348
|
+
note: 1,
|
|
349
|
+
arrow: 1,
|
|
350
|
+
line: 1,
|
|
351
|
+
text: 2,
|
|
352
|
+
ink: 3
|
|
353
|
+
};
|
|
354
|
+
function whiteboardDrawBand(el) {
|
|
355
|
+
return DRAW_BAND[el.kind];
|
|
356
|
+
}
|
|
357
|
+
function whiteboardDrawOrder(elements) {
|
|
358
|
+
const key = elements.map((el, i) => {
|
|
359
|
+
if (el.kind !== "arrow" && el.kind !== "line") return i;
|
|
360
|
+
const { from, to } = whiteboardConnectorAttachments(el, elements);
|
|
361
|
+
const last = Math.max(from, to);
|
|
362
|
+
return last > i ? last + 0.5 : i;
|
|
363
|
+
});
|
|
364
|
+
return elements.map((_, i) => i).sort(
|
|
365
|
+
(a, b) => DRAW_BAND[elements[a].kind] - DRAW_BAND[elements[b].kind] || key[a] - key[b] || a - b
|
|
366
|
+
);
|
|
367
|
+
}
|
|
334
368
|
|
|
335
369
|
// src/whiteboard/label.ts
|
|
336
370
|
var WHITEBOARD_LABEL_FONT = 14;
|
|
371
|
+
var WHITEBOARD_CONTAINER_FONT = 16;
|
|
372
|
+
var WHITEBOARD_CONTAINER_WEIGHT = 600;
|
|
373
|
+
var CONTAINER_GAP = 4;
|
|
337
374
|
var WHITEBOARD_NOTE_FONT = 12;
|
|
338
375
|
var WHITEBOARD_LABEL_LINE = 1.25;
|
|
339
376
|
var LABEL_PAD = 8;
|
|
@@ -370,20 +407,22 @@ function wrapWhiteboardLabel(label, box) {
|
|
|
370
407
|
const font = "kind" in box && box.kind === "note" ? WHITEBOARD_NOTE_FONT : WHITEBOARD_LABEL_FONT;
|
|
371
408
|
return label.split("\n").flatMap((line) => line ? wrapTextToWidth(line, font, width) : [""]);
|
|
372
409
|
}
|
|
373
|
-
function fitWhiteboardLabel(label, box) {
|
|
410
|
+
function fitWhiteboardLabel(label, box, opts = {}) {
|
|
374
411
|
const isNote = "kind" in box && box.kind === "note";
|
|
375
|
-
const full = isNote ? WHITEBOARD_NOTE_FONT : WHITEBOARD_LABEL_FONT;
|
|
412
|
+
const full = opts.font ?? (isNote ? WHITEBOARD_NOTE_FONT : WHITEBOARD_LABEL_FONT);
|
|
376
413
|
const pad = isNote ? WHITEBOARD_NOTE_PAD : LABEL_PAD;
|
|
377
414
|
if (!label) return { lines: [], font: full, top: pad };
|
|
415
|
+
const bold = opts.bold ?? false;
|
|
378
416
|
const width = whiteboardLabelWidth(box);
|
|
379
|
-
const height = whiteboardLabelHeight(box);
|
|
417
|
+
const height = opts.height ?? whiteboardLabelHeight(box);
|
|
418
|
+
const measure = (l, font2) => measureText(l, font2, { bold });
|
|
380
419
|
const wrap = (font2, hardBreak) => label.split("\n").flatMap(
|
|
381
|
-
(line) => line ? wrapTextToWidth(line, font2, width, { hardBreak }) : [""]
|
|
420
|
+
(line) => line ? wrapTextToWidth(line, font2, width, { hardBreak, bold }) : [""]
|
|
382
421
|
);
|
|
383
422
|
const tall = (n, font2) => n * font2 * WHITEBOARD_LABEL_LINE > height;
|
|
384
423
|
for (let font2 = full; font2 >= WHITEBOARD_LABEL_MIN_FONT; font2--) {
|
|
385
424
|
const lines2 = wrap(font2, false);
|
|
386
|
-
if (!tall(lines2.length, font2) && lines2.every((l) =>
|
|
425
|
+
if (!tall(lines2.length, font2) && lines2.every((l) => measure(l, font2) <= width))
|
|
387
426
|
return { lines: lines2, font: font2, top: pad };
|
|
388
427
|
}
|
|
389
428
|
const font = WHITEBOARD_LABEL_MIN_FONT;
|
|
@@ -399,11 +438,76 @@ function fitWhiteboardLabel(label, box) {
|
|
|
399
438
|
if (lines.length <= room) return { lines, font, top };
|
|
400
439
|
const kept = lines.slice(0, room);
|
|
401
440
|
let last = kept[room - 1];
|
|
402
|
-
while (last &&
|
|
441
|
+
while (last && measure(`${last}\u2026`, font) > width)
|
|
403
442
|
last = [...last].slice(0, -1).join("");
|
|
404
443
|
kept[room - 1] = `${last.trimEnd()}\u2026`;
|
|
405
444
|
return { lines: kept, font, top };
|
|
406
445
|
}
|
|
446
|
+
function whiteboardLabelCentreY(box, position, blockHeight) {
|
|
447
|
+
if (position === "middle") return box.y + box.height / 2;
|
|
448
|
+
const innerTop = box.y + (box.height - whiteboardLabelHeight(box)) / 2;
|
|
449
|
+
return innerTop + blockHeight / 2;
|
|
450
|
+
}
|
|
451
|
+
function whiteboardShapeLabel(el, elements, text = el.label) {
|
|
452
|
+
const block = (n, font2) => n * font2 * WHITEBOARD_LABEL_LINE;
|
|
453
|
+
const top = whiteboardLabelPosition(el, elements) === "top";
|
|
454
|
+
const inset = (el.height - whiteboardLabelHeight(el)) / 2;
|
|
455
|
+
const innerTop = el.y + inset;
|
|
456
|
+
const innerBottom = el.y + el.height - inset;
|
|
457
|
+
const spans = [];
|
|
458
|
+
for (const o of elements) {
|
|
459
|
+
if (o === el) continue;
|
|
460
|
+
if (o.kind !== "shape" && o.kind !== "note" && o.kind !== "image") continue;
|
|
461
|
+
const ox1 = o.x + o.width;
|
|
462
|
+
const oy1 = o.y + o.height;
|
|
463
|
+
const overlaps = o.x < el.x + el.width && ox1 > el.x && o.y < el.y + el.height && oy1 > el.y;
|
|
464
|
+
const encloses = o.x <= el.x && o.y <= el.y && ox1 >= el.x + el.width && oy1 >= el.y + el.height;
|
|
465
|
+
if (overlaps && !encloses)
|
|
466
|
+
spans.push([o.y - CONTAINER_GAP, oy1 + CONTAINER_GAP]);
|
|
467
|
+
}
|
|
468
|
+
spans.sort((a, b) => a[0] - b[0]);
|
|
469
|
+
const strips = [];
|
|
470
|
+
let from = innerTop;
|
|
471
|
+
for (const [y0, y1] of spans) {
|
|
472
|
+
if (y0 > from) strips.push([from, Math.min(y0, innerBottom)]);
|
|
473
|
+
from = Math.max(from, y1);
|
|
474
|
+
}
|
|
475
|
+
if (from < innerBottom) strips.push([from, innerBottom]);
|
|
476
|
+
const floorLine = block(1, WHITEBOARD_LABEL_MIN_FONT);
|
|
477
|
+
const roomy = strips.filter(([a, b]) => b - a >= floorLine);
|
|
478
|
+
const font = top ? WHITEBOARD_CONTAINER_FONT : WHITEBOARD_LABEL_FONT;
|
|
479
|
+
const opts = top ? { font, bold: true } : {};
|
|
480
|
+
const into = ([a, b], centre) => {
|
|
481
|
+
const fit2 = fitWhiteboardLabel(text, el, { ...opts, height: b - a });
|
|
482
|
+
const h = block(fit2.lines.length, fit2.font);
|
|
483
|
+
const cy = Math.min(Math.max(centre, a + h / 2), b - h / 2);
|
|
484
|
+
return { lines: fit2.lines, font: fit2.font, bold: top, cy, onEdge: false };
|
|
485
|
+
};
|
|
486
|
+
if (top) {
|
|
487
|
+
const first = roomy[0];
|
|
488
|
+
if (first?.[0] === innerTop) return into(first, -Infinity);
|
|
489
|
+
const last = roomy.at(-1);
|
|
490
|
+
if (last?.[1] === innerBottom) return into(last, Infinity);
|
|
491
|
+
} else {
|
|
492
|
+
const mid = el.y + el.height / 2;
|
|
493
|
+
const strip = roomy.find(([a, b]) => a <= mid && mid <= b) ?? roomy.reduce(
|
|
494
|
+
(best, s) => !best || s[1] - s[0] > best[1] - best[0] ? s : best,
|
|
495
|
+
void 0
|
|
496
|
+
);
|
|
497
|
+
if (strip) return into(strip, mid);
|
|
498
|
+
}
|
|
499
|
+
const fit = fitWhiteboardLabel(text.replace(/\n/g, " "), el, {
|
|
500
|
+
...opts,
|
|
501
|
+
height: block(1, font)
|
|
502
|
+
});
|
|
503
|
+
return {
|
|
504
|
+
lines: fit.lines.slice(0, 1),
|
|
505
|
+
font: fit.font,
|
|
506
|
+
bold: top,
|
|
507
|
+
cy: el.y,
|
|
508
|
+
onEdge: true
|
|
509
|
+
};
|
|
510
|
+
}
|
|
407
511
|
|
|
408
512
|
// src/whiteboard/renderer.ts
|
|
409
513
|
function visibleWhiteboardIndices(parsed, options = {}) {
|
|
@@ -477,8 +581,8 @@ var SAFE_IMAGE_HREF_RE = /^(https?:|blob:|data:image\/)/i;
|
|
|
477
581
|
function labelLines(label) {
|
|
478
582
|
return label.split("\n");
|
|
479
583
|
}
|
|
480
|
-
function widest(lines, font) {
|
|
481
|
-
return Math.max(0, ...lines.map((l) => measureText(l, font)));
|
|
584
|
+
function widest(lines, font, bold = false) {
|
|
585
|
+
return Math.max(0, ...lines.map((l) => measureText(l, font, { bold })));
|
|
482
586
|
}
|
|
483
587
|
function grow(b, x0, y0, x1, y1) {
|
|
484
588
|
b.minX = Math.min(b.minX, x0, x1);
|
|
@@ -498,7 +602,7 @@ function whiteboardBounds(parsed, options = {}) {
|
|
|
498
602
|
maxY: -Infinity
|
|
499
603
|
};
|
|
500
604
|
const elements = visibleWhiteboardElements(parsed, options);
|
|
501
|
-
const labelAt = placeConnectorLabels(elements);
|
|
605
|
+
const labelAt = placeConnectorLabels(elements, parsed.elements);
|
|
502
606
|
for (const el of elements) {
|
|
503
607
|
switch (el.kind) {
|
|
504
608
|
case "shape":
|
|
@@ -590,7 +694,7 @@ function connectorLabelBox(lines, x, y) {
|
|
|
590
694
|
const hh = lines.length * WHITEBOARD_LABEL_FONT * WHITEBOARD_LABEL_LINE / 2 + LABEL_CLEAR;
|
|
591
695
|
return { x0: x - hw, y0: y - hh, x1: x + hw, y1: y + hh };
|
|
592
696
|
}
|
|
593
|
-
function authoredTextBoxes(elements) {
|
|
697
|
+
function authoredTextBoxes(elements, all) {
|
|
594
698
|
const boxes = [];
|
|
595
699
|
for (const el of elements) {
|
|
596
700
|
if (el.kind === "text") {
|
|
@@ -609,20 +713,19 @@ function authoredTextBoxes(elements) {
|
|
|
609
713
|
y1: el.y + Math.max(el.height, noteTextHeight(el))
|
|
610
714
|
});
|
|
611
715
|
} else if (el.kind === "shape" && el.label) {
|
|
612
|
-
const { lines, font } =
|
|
716
|
+
const { lines, font, bold, cy } = whiteboardShapeLabel(el, all);
|
|
613
717
|
if (lines.length === 0) continue;
|
|
614
718
|
const cx = el.x + el.width / 2 + whiteboardLabelShift(el);
|
|
615
|
-
const cy = el.y + el.height / 2;
|
|
616
|
-
const hw = widest(lines, font) / 2;
|
|
617
719
|
const hh = lines.length * font * WHITEBOARD_LABEL_LINE / 2;
|
|
720
|
+
const hw = widest(lines, font, bold) / 2;
|
|
618
721
|
boxes.push({ x0: cx - hw, y0: cy - hh, x1: cx + hw, y1: cy + hh });
|
|
619
722
|
}
|
|
620
723
|
}
|
|
621
724
|
return boxes;
|
|
622
725
|
}
|
|
623
|
-
function placeConnectorLabels(elements) {
|
|
726
|
+
function placeConnectorLabels(elements, all) {
|
|
624
727
|
const placed = /* @__PURE__ */ new Map();
|
|
625
|
-
const taken = authoredTextBoxes(elements);
|
|
728
|
+
const taken = authoredTextBoxes(elements, all);
|
|
626
729
|
for (const el of elements) {
|
|
627
730
|
if (el.kind !== "arrow" && el.kind !== "line" || !el.label) continue;
|
|
628
731
|
const lines = labelLines(el.label);
|
|
@@ -739,7 +842,7 @@ function renderWhiteboard(container, parsed, palette, isDark, options = {}) {
|
|
|
739
842
|
const titleOffset = showTitle ? TITLE_BAND : 0;
|
|
740
843
|
const elements = visibleWhiteboardElements(parsed, options);
|
|
741
844
|
const b = whiteboardBounds(parsed, options);
|
|
742
|
-
const labelAt = placeConnectorLabels(elements);
|
|
845
|
+
const labelAt = placeConnectorLabels(elements, parsed.elements);
|
|
743
846
|
const contentW = b.maxX - b.minX;
|
|
744
847
|
const contentH = b.maxY - b.minY;
|
|
745
848
|
const titleW = showTitle ? measureText(parsed.title, TITLE_FONT_SIZE, { bold: true }) : 0;
|
|
@@ -783,11 +886,16 @@ function renderWhiteboard(container, parsed, palette, isDark, options = {}) {
|
|
|
783
886
|
}
|
|
784
887
|
const canvas = svg.append("g").attr("class", "whiteboard-canvas").attr("transform", `translate(${round2(tx)},${round2(ty)})`);
|
|
785
888
|
const halo = palette.bg;
|
|
786
|
-
const centredLabel = (g, {
|
|
889
|
+
const centredLabel = (g, {
|
|
890
|
+
lines,
|
|
891
|
+
font,
|
|
892
|
+
bold
|
|
893
|
+
}, cx, cy, color, ground) => {
|
|
787
894
|
if (lines.length === 0) return;
|
|
788
895
|
const lh = font * WHITEBOARD_LABEL_LINE;
|
|
789
896
|
const top = cy - lines.length * lh / 2 + lh * BASELINE;
|
|
790
897
|
const t = g.append("text").attr("class", "whiteboard-label").attr("text-anchor", "middle").attr("font-size", font).attr("fill", color).attr("stroke", ground).attr("stroke-width", LABEL_HALO).attr("stroke-linejoin", "round").attr("paint-order", "stroke");
|
|
898
|
+
if (bold) t.attr("font-weight", WHITEBOARD_CONTAINER_WEIGHT);
|
|
791
899
|
appendLines(t, lines, cx, top, lh);
|
|
792
900
|
};
|
|
793
901
|
const drawImage = (g, el) => {
|
|
@@ -828,13 +936,14 @@ function renderWhiteboard(container, parsed, palette, isDark, options = {}) {
|
|
|
828
936
|
drawQueueCard(inner, el.width, el.height, fill, stroke);
|
|
829
937
|
}
|
|
830
938
|
}
|
|
939
|
+
const label = whiteboardShapeLabel(el, parsed.elements);
|
|
831
940
|
centredLabel(
|
|
832
941
|
g,
|
|
833
|
-
|
|
942
|
+
label,
|
|
834
943
|
cx + whiteboardLabelShift(el),
|
|
835
|
-
cy,
|
|
944
|
+
label.cy,
|
|
836
945
|
labelColor,
|
|
837
|
-
fill === "none" ? halo : fill
|
|
946
|
+
label.onEdge || fill === "none" ? halo : fill
|
|
838
947
|
);
|
|
839
948
|
break;
|
|
840
949
|
}
|
|
@@ -926,17 +1035,8 @@ function renderWhiteboard(container, parsed, palette, isDark, options = {}) {
|
|
|
926
1035
|
};
|
|
927
1036
|
for (const el of inDrawOrder(elements)) drawElement(el);
|
|
928
1037
|
}
|
|
929
|
-
var DRAW_BAND = {
|
|
930
|
-
image: 0,
|
|
931
|
-
shape: 1,
|
|
932
|
-
note: 2,
|
|
933
|
-
arrow: 3,
|
|
934
|
-
line: 3,
|
|
935
|
-
text: 4,
|
|
936
|
-
ink: 5
|
|
937
|
-
};
|
|
938
1038
|
function inDrawOrder(elements) {
|
|
939
|
-
return elements.map((
|
|
1039
|
+
return whiteboardDrawOrder(elements).map((i) => elements[i]);
|
|
940
1040
|
}
|
|
941
1041
|
function appendLines(t, lines, x, firstY, lh) {
|
|
942
1042
|
lines.forEach((ln, i) => {
|
|
@@ -951,12 +1051,17 @@ function round2(n) {
|
|
|
951
1051
|
export {
|
|
952
1052
|
whiteboardNoteFold,
|
|
953
1053
|
whiteboardShapeContains,
|
|
1054
|
+
whiteboardLabelPosition,
|
|
954
1055
|
whiteboardShapeAt,
|
|
955
1056
|
whiteboardConnectorAttachments,
|
|
956
1057
|
clipWhiteboardConnector,
|
|
957
1058
|
whiteboardBendHandle,
|
|
958
1059
|
whiteboardBendFor,
|
|
959
1060
|
whiteboardSegmentMidpoint,
|
|
1061
|
+
whiteboardDrawBand,
|
|
1062
|
+
whiteboardDrawOrder,
|
|
1063
|
+
WHITEBOARD_CONTAINER_FONT,
|
|
1064
|
+
WHITEBOARD_CONTAINER_WEIGHT,
|
|
960
1065
|
WHITEBOARD_NOTE_FONT,
|
|
961
1066
|
WHITEBOARD_LABEL_MIN_FONT,
|
|
962
1067
|
whiteboardLabelWidth,
|
|
@@ -964,6 +1069,8 @@ export {
|
|
|
964
1069
|
whiteboardLabelHeight,
|
|
965
1070
|
wrapWhiteboardLabel,
|
|
966
1071
|
fitWhiteboardLabel,
|
|
1072
|
+
whiteboardLabelCentreY,
|
|
1073
|
+
whiteboardShapeLabel,
|
|
967
1074
|
visibleWhiteboardIndices,
|
|
968
1075
|
visibleWhiteboardElements,
|
|
969
1076
|
IMAGE_NOT_UPLOADED,
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
searchPlacement
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-2J2CWWWK.js";
|
|
4
4
|
import {
|
|
5
5
|
noteCanvasShift,
|
|
6
6
|
placeNotes,
|
|
7
7
|
resolveNotes
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-KLBTJEIK.js";
|
|
9
9
|
import {
|
|
10
10
|
noteBoxSize
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-67N26CER.js";
|
|
12
12
|
|
|
13
13
|
// src/graph/layout.ts
|
|
14
14
|
import dagre from "@dagrejs/dagre";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
layoutERDiagram
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-7IALGIOI.js";
|
|
4
4
|
import {
|
|
5
5
|
serializeSvg
|
|
6
6
|
} from "./chunk-CYRB2JTN.js";
|
|
@@ -28,14 +28,14 @@ import {
|
|
|
28
28
|
} from "./chunk-JILEYZ2V.js";
|
|
29
29
|
import {
|
|
30
30
|
parseERDiagram
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-S4SJ4LLY.js";
|
|
32
32
|
import {
|
|
33
33
|
NOTE_BADGE_RADIUS,
|
|
34
34
|
noteConnectorPoints,
|
|
35
35
|
renderNoteBadge,
|
|
36
36
|
renderNoteBox,
|
|
37
37
|
renderNoteConnector
|
|
38
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-67N26CER.js";
|
|
39
39
|
import {
|
|
40
40
|
FONT_FAMILY
|
|
41
41
|
} from "./chunk-ICLB27PZ.js";
|
|
@@ -280,7 +280,7 @@ function renderSitemap(container, parsed, layout, palette, isDark, onClickItem,
|
|
|
280
280
|
for (const c of layout.containers) {
|
|
281
281
|
const cG = contentG.append("g").attr("transform", `translate(${c.x}, ${c.y})`).attr("class", "sitemap-container").attr("data-line-number", String(c.lineNumber));
|
|
282
282
|
if (c.hasChildren) {
|
|
283
|
-
cG.attr("data-node-toggle", c.nodeId).attr("
|
|
283
|
+
cG.attr("data-node-toggle", c.nodeId).attr("role", "button").attr("aria-expanded", String(!c.hiddenCount)).attr("aria-label", c.label);
|
|
284
284
|
}
|
|
285
285
|
if (onClickItem) {
|
|
286
286
|
cG.style("cursor", "pointer").on(
|
|
@@ -347,7 +347,7 @@ function renderSitemap(container, parsed, layout, palette, isDark, onClickItem,
|
|
|
347
347
|
for (const node of layout.nodes) {
|
|
348
348
|
const nodeG = contentG.append("g").attr("transform", `translate(${node.x - node.width / 2}, ${node.y})`).attr("class", "sitemap-node").attr("data-line-number", String(node.lineNumber)).attr("data-node-id", node.id);
|
|
349
349
|
if (node.hasChildren) {
|
|
350
|
-
nodeG.attr("data-node-toggle", node.id).attr("
|
|
350
|
+
nodeG.attr("data-node-toggle", node.id).attr("role", "button").attr("aria-expanded", String(!node.hiddenCount));
|
|
351
351
|
}
|
|
352
352
|
if (onClickItem) {
|
|
353
353
|
nodeG.style("cursor", "pointer").on("click", () => onClickItem(node.lineNumber));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
layoutClassDiagram
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-BCV2VJTM.js";
|
|
4
4
|
import {
|
|
5
5
|
extractExportSvg,
|
|
6
6
|
runInExportContainer
|
|
@@ -32,14 +32,14 @@ import {
|
|
|
32
32
|
} from "./chunk-JILEYZ2V.js";
|
|
33
33
|
import {
|
|
34
34
|
parseClassDiagram
|
|
35
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-5XBYLYYI.js";
|
|
36
36
|
import {
|
|
37
37
|
NOTE_BADGE_RADIUS,
|
|
38
38
|
noteConnectorPoints,
|
|
39
39
|
renderNoteBadge,
|
|
40
40
|
renderNoteBox,
|
|
41
41
|
renderNoteConnector
|
|
42
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-67N26CER.js";
|
|
43
43
|
import {
|
|
44
44
|
FONT_FAMILY
|
|
45
45
|
} from "./chunk-ICLB27PZ.js";
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
NODE_LABEL_LINE_HEIGHT,
|
|
6
6
|
layoutGraph,
|
|
7
7
|
wrapNodeLabel
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-EXHXTMVR.js";
|
|
9
9
|
import {
|
|
10
10
|
appendArrowheadMarkers
|
|
11
11
|
} from "./chunk-XBJJP2HN.js";
|
|
@@ -37,14 +37,14 @@ import {
|
|
|
37
37
|
} from "./chunk-XCKNFFKM.js";
|
|
38
38
|
import {
|
|
39
39
|
parseFlowchart
|
|
40
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-IY62DXT2.js";
|
|
41
41
|
import {
|
|
42
42
|
NOTE_BADGE_RADIUS,
|
|
43
43
|
noteConnectorPoints,
|
|
44
44
|
renderNoteBadge,
|
|
45
45
|
renderNoteBox,
|
|
46
46
|
renderNoteConnector
|
|
47
|
-
} from "./chunk-
|
|
47
|
+
} from "./chunk-67N26CER.js";
|
|
48
48
|
import {
|
|
49
49
|
FONT_FAMILY
|
|
50
50
|
} from "./chunk-ICLB27PZ.js";
|
|
@@ -36,7 +36,7 @@ import {
|
|
|
36
36
|
import {
|
|
37
37
|
WHITEBOARD_DIAGNOSTICS,
|
|
38
38
|
parseWhiteboard
|
|
39
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-U6VS3T2M.js";
|
|
40
40
|
import {
|
|
41
41
|
SWIMLANE_DIAGNOSTICS,
|
|
42
42
|
parseSwimlane
|
|
@@ -97,10 +97,10 @@ import {
|
|
|
97
97
|
} from "./chunk-JXGSTBW6.js";
|
|
98
98
|
import {
|
|
99
99
|
parseBoxesAndLines
|
|
100
|
-
} from "./chunk-
|
|
100
|
+
} from "./chunk-4UVCTLRH.js";
|
|
101
101
|
import {
|
|
102
102
|
parseDgmoChartType
|
|
103
|
-
} from "./chunk-
|
|
103
|
+
} from "./chunk-BTP2BMWN.js";
|
|
104
104
|
import {
|
|
105
105
|
parseRaci
|
|
106
106
|
} from "./chunk-KRPLP5LP.js";
|
|
@@ -123,13 +123,13 @@ import {
|
|
|
123
123
|
} from "./chunk-CDM6XMOT.js";
|
|
124
124
|
import {
|
|
125
125
|
parseFlowchart
|
|
126
|
-
} from "./chunk-
|
|
126
|
+
} from "./chunk-IY62DXT2.js";
|
|
127
127
|
import {
|
|
128
128
|
GRAPH_DIAGNOSTICS
|
|
129
129
|
} from "./chunk-TIVMAITN.js";
|
|
130
130
|
import {
|
|
131
131
|
parseState
|
|
132
|
-
} from "./chunk-
|
|
132
|
+
} from "./chunk-LJGE43SG.js";
|
|
133
133
|
import {
|
|
134
134
|
makeYearContext,
|
|
135
135
|
parseDateToken,
|
|
@@ -141,10 +141,10 @@ import {
|
|
|
141
141
|
} from "./chunk-CYTFO2LF.js";
|
|
142
142
|
import {
|
|
143
143
|
parseERDiagram
|
|
144
|
-
} from "./chunk-
|
|
144
|
+
} from "./chunk-S4SJ4LLY.js";
|
|
145
145
|
import {
|
|
146
146
|
parseClassDiagram
|
|
147
|
-
} from "./chunk-
|
|
147
|
+
} from "./chunk-5XBYLYYI.js";
|
|
148
148
|
import {
|
|
149
149
|
ARROW_DIAGNOSTIC_CODES
|
|
150
150
|
} from "./chunk-N7VMGZCU.js";
|
|
@@ -205,7 +205,7 @@ function renderOrg(container, parsed, layout, palette, isDark, onClickItem, expo
|
|
|
205
205
|
}
|
|
206
206
|
}
|
|
207
207
|
if (c.hasChildren) {
|
|
208
|
-
cG.attr("data-node-toggle", c.nodeId).attr("
|
|
208
|
+
cG.attr("data-node-toggle", c.nodeId).attr("role", "button").attr("aria-expanded", String(!c.hiddenCount)).attr("aria-label", c.label);
|
|
209
209
|
}
|
|
210
210
|
if (onClickItem) {
|
|
211
211
|
cG.style("cursor", "pointer").on("click", () => {
|
|
@@ -287,7 +287,7 @@ function renderOrg(container, parsed, layout, palette, isDark, onClickItem, expo
|
|
|
287
287
|
}
|
|
288
288
|
}
|
|
289
289
|
if (node.hasChildren) {
|
|
290
|
-
nodeG.attr("data-node-toggle", node.id).attr("
|
|
290
|
+
nodeG.attr("data-node-toggle", node.id).attr("role", "button").attr("aria-expanded", String(!node.hiddenCount)).attr("aria-label", node.label);
|
|
291
291
|
}
|
|
292
292
|
if (onClickItem) {
|
|
293
293
|
nodeG.style("cursor", "pointer").on("click", () => {
|
|
@@ -28,6 +28,7 @@ var WHITEBOARD_ELEMENT_KEYWORDS = [
|
|
|
28
28
|
];
|
|
29
29
|
var WHITEBOARD_STROKE_STYLES = ["solid", "dashed"];
|
|
30
30
|
var WHITEBOARD_FILLS = ["tint", "solid", "outline"];
|
|
31
|
+
var WHITEBOARD_LABEL_POSITIONS = ["top", "middle"];
|
|
31
32
|
var WHITEBOARD_HEADS = ["end", "both"];
|
|
32
33
|
var WHITEBOARD_NOTE_WIDTH = 160;
|
|
33
34
|
var WHITEBOARD_NOTE_HEIGHT = 99;
|
|
@@ -45,6 +46,7 @@ export {
|
|
|
45
46
|
WHITEBOARD_ELEMENT_KEYWORDS,
|
|
46
47
|
WHITEBOARD_STROKE_STYLES,
|
|
47
48
|
WHITEBOARD_FILLS,
|
|
49
|
+
WHITEBOARD_LABEL_POSITIONS,
|
|
48
50
|
WHITEBOARD_HEADS,
|
|
49
51
|
WHITEBOARD_NOTE_WIDTH,
|
|
50
52
|
WHITEBOARD_NOTE_HEIGHT,
|
|
@@ -318,7 +318,7 @@ function renderMindmap(container, parsed, layout, palette, isDark, onClickItem,
|
|
|
318
318
|
}
|
|
319
319
|
}
|
|
320
320
|
if (node.hasChildren) {
|
|
321
|
-
nodeG.attr("data-node-toggle", node.id).attr("
|
|
321
|
+
nodeG.attr("data-node-toggle", node.id).attr("role", "button").attr(
|
|
322
322
|
"aria-expanded",
|
|
323
323
|
node.hiddenCount != null && node.hiddenCount > 0 ? "false" : "true"
|
|
324
324
|
).attr("aria-label", node.label);
|