@senad-d/drawme 0.1.6 → 0.1.9
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/CHANGELOG.md +45 -1
- package/README.md +34 -18
- package/assets/references/diagram-types.md +1 -1
- package/assets/references/style-presets.md +94 -0
- package/assets/references/xml-authoring.md +101 -8
- package/docs/reference.md +96 -12
- package/example/README.md +37 -0
- package/example/drawme-architecture.drawio +62 -0
- package/example/drawme-how-it-works.drawio +79 -122
- package/example/drawme-installation-guide.drawio +63 -97
- package/example/drawme-validation-decision-tree.drawio +79 -73
- package/example/event-driven-orders.drawio +119 -0
- package/example/git-graph-example.drawio +77 -69
- package/package.json +7 -7
- package/src/animate.ts +177 -0
- package/src/animation.ts +637 -0
- package/src/drawio.ts +130 -34
- package/src/fitcanvas.ts +1 -1
- package/src/geometry.ts +30 -14
- package/src/index.ts +120 -17
- package/src/motion.ts +839 -0
- package/src/storyboard.ts +161 -0
- package/src/svgexport.ts +124 -0
- package/src/validate.ts +448 -6
- package/src/workflow.ts +8 -5
- package/example/drawme-extension-waterfall-overview.drawio +0 -72
package/src/validate.ts
CHANGED
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
import { readFile } from "node:fs/promises";
|
|
8
8
|
import { DOMParser } from "@xmldom/xmldom";
|
|
9
9
|
import { type DomEl, attr, childrenByTag, directText, firstByTag } from "./dom";
|
|
10
|
+
import { analyzeAnimationPage } from "./animation";
|
|
11
|
+
import { analyzeStoredMotion } from "./motion";
|
|
10
12
|
import {
|
|
11
13
|
type ById,
|
|
12
14
|
type ContentBounds,
|
|
@@ -16,12 +18,16 @@ import {
|
|
|
16
18
|
collectCells,
|
|
17
19
|
contentBounds,
|
|
18
20
|
edgeRoute,
|
|
21
|
+
edgeWaypoints,
|
|
22
|
+
endpoint,
|
|
19
23
|
geometryIsRelative,
|
|
20
24
|
hasInvalidNumber,
|
|
25
|
+
explicitEdgeLabelRect,
|
|
21
26
|
isEdgeLabel,
|
|
22
27
|
isVisible,
|
|
23
28
|
pyFloat,
|
|
24
29
|
rect,
|
|
30
|
+
routePointAt,
|
|
25
31
|
styleNum,
|
|
26
32
|
} from "./geometry";
|
|
27
33
|
|
|
@@ -36,7 +42,7 @@ export interface ValidateResult {
|
|
|
36
42
|
/** Informational limitations/settings that do not require a source correction. */
|
|
37
43
|
observations: string[];
|
|
38
44
|
/** Readability score (lower is better); comparable only across variants of the same graph. */
|
|
39
|
-
score: { total: number; through: number; crossings: number; overlaps: number };
|
|
45
|
+
score: { total: number; through: number; crossings: number; overlaps: number; anchors: number };
|
|
40
46
|
}
|
|
41
47
|
|
|
42
48
|
/** Quote an optional attribute consistently in diagnostic messages. */
|
|
@@ -155,10 +161,219 @@ function routeCrossWarnings(routed: RoutedEdge[]): string[] {
|
|
|
155
161
|
return warnings;
|
|
156
162
|
}
|
|
157
163
|
|
|
164
|
+
type Side = "top" | "bottom" | "left" | "right";
|
|
165
|
+
|
|
166
|
+
/** Side containing a pinned connection point, or null for an interior, corner, or unpinned point. */
|
|
167
|
+
function pinnedSide(style: string, end: "source" | "target"): Side | null {
|
|
168
|
+
const x = styleNum(style, end === "source" ? "exitX" : "entryX");
|
|
169
|
+
const y = styleNum(style, end === "source" ? "exitY" : "entryY");
|
|
170
|
+
if (x === undefined && y === undefined) return null;
|
|
171
|
+
const xBorder = x === 0 || x === 1;
|
|
172
|
+
const yBorder = y === 0 || y === 1;
|
|
173
|
+
if (xBorder && !yBorder) return x === 0 ? "left" : "right";
|
|
174
|
+
if (yBorder && !xBorder) return y === 0 ? "top" : "bottom";
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function directionDescription(dx: number, dy: number): string {
|
|
179
|
+
if (Math.abs(dx) >= Math.abs(dy)) return dx > 0 ? "to the right" : "to the left";
|
|
180
|
+
return dy > 0 ? "below" : "above";
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function facingSide(dx: number, dy: number): Side {
|
|
184
|
+
if (Math.abs(dx) >= Math.abs(dy)) return dx > 0 ? "right" : "left";
|
|
185
|
+
return dy > 0 ? "bottom" : "top";
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function sideStyleHint(side: Side, end: "source" | "target"): string {
|
|
189
|
+
const prefix = end === "source" ? "exit" : "entry";
|
|
190
|
+
switch (side) {
|
|
191
|
+
case "top":
|
|
192
|
+
return `${prefix}X=0.5;${prefix}Y=0`;
|
|
193
|
+
case "bottom":
|
|
194
|
+
return `${prefix}X=0.5;${prefix}Y=1`;
|
|
195
|
+
case "left":
|
|
196
|
+
return `${prefix}X=0;${prefix}Y=0.5`;
|
|
197
|
+
case "right":
|
|
198
|
+
return `${prefix}X=1;${prefix}Y=0.5`;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function sideFacesAway(side: Side, dx: number, dy: number, tolerance: number): boolean {
|
|
203
|
+
return (
|
|
204
|
+
(side === "top" && dy > tolerance) ||
|
|
205
|
+
(side === "bottom" && dy < -tolerance) ||
|
|
206
|
+
(side === "left" && dx > tolerance) ||
|
|
207
|
+
(side === "right" && dx < -tolerance)
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
interface AnchorDirection {
|
|
212
|
+
end: "source" | "target";
|
|
213
|
+
reference: Point;
|
|
214
|
+
center: Point;
|
|
215
|
+
subject: string;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function rectCenter(box: Rect): Point {
|
|
219
|
+
return [box[0] + box[2] / 2, box[1] + box[3] / 2];
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
function anchorDirectionWarning(
|
|
223
|
+
cell: DomEl,
|
|
224
|
+
style: string,
|
|
225
|
+
tolerance: number,
|
|
226
|
+
direction: AnchorDirection,
|
|
227
|
+
): string | null {
|
|
228
|
+
const dx = direction.reference[0] - direction.center[0];
|
|
229
|
+
const dy = direction.reference[1] - direction.center[1];
|
|
230
|
+
const side = pinnedSide(style, direction.end);
|
|
231
|
+
if (!side || !sideFacesAway(side, dx, dy, tolerance)) return null;
|
|
232
|
+
const suggested = facingSide(dx, dy);
|
|
233
|
+
const endLabel = direction.end === "source" ? "source exit" : "target entry";
|
|
234
|
+
return `edge ${repr(attr(cell, "id"))}: ${endLabel} pinned to ${side} but ${direction.subject} is ${directionDescription(dx, dy)}; re-pin to ${suggested} (${sideStyleHint(suggested, direction.end)}) to shorten the route and reduce bends`;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/** Warn when a pinned border anchor faces away from its adjacent waypoint, or its peer when auto-routed. */
|
|
238
|
+
function edgeAnchorFacingWarnings(cell: DomEl, ids: ById): string[] {
|
|
239
|
+
if (cell.getAttribute("edge") !== "1" || !isVisible(cell, ids)) return [];
|
|
240
|
+
const sourceId = attr(cell, "source");
|
|
241
|
+
const targetId = attr(cell, "target");
|
|
242
|
+
if (!sourceId || !targetId) return [];
|
|
243
|
+
const source = ids.get(sourceId);
|
|
244
|
+
const target = ids.get(targetId);
|
|
245
|
+
if (!source || !target || geometryIsRelative(source) || geometryIsRelative(target)) return [];
|
|
246
|
+
const sourceBox = absRect(source, ids);
|
|
247
|
+
const targetBox = absRect(target, ids);
|
|
248
|
+
if (!sourceBox || !targetBox) return [];
|
|
249
|
+
|
|
250
|
+
const sourceCenter = rectCenter(sourceBox);
|
|
251
|
+
const targetCenter = rectCenter(targetBox);
|
|
252
|
+
const route = edgeRoute(cell, ids);
|
|
253
|
+
const directions: AnchorDirection[] = [
|
|
254
|
+
{
|
|
255
|
+
end: "source",
|
|
256
|
+
reference: route?.[1] ?? targetCenter,
|
|
257
|
+
center: sourceCenter,
|
|
258
|
+
subject: route ? "first waypoint" : "target",
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
end: "target",
|
|
262
|
+
reference: route?.at(-2) ?? sourceCenter,
|
|
263
|
+
center: targetCenter,
|
|
264
|
+
subject: route ? "last waypoint" : "source",
|
|
265
|
+
},
|
|
266
|
+
];
|
|
267
|
+
const tolerance = Math.max(sourceBox[2], sourceBox[3], targetBox[2], targetBox[3]) * 0.15;
|
|
268
|
+
const style = attr(cell, "style") ?? "";
|
|
269
|
+
return directions
|
|
270
|
+
.map((direction) => anchorDirectionWarning(cell, style, tolerance, direction))
|
|
271
|
+
.filter((warning): warning is string => warning !== null);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
function anchorFacingWarnings(cells: DomEl[], ids: ById): string[] {
|
|
275
|
+
return cells.flatMap((cell) => edgeAnchorFacingWarnings(cell, ids));
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/** A segment that enters and exits a rectangle rather than merely touching its boundary. */
|
|
279
|
+
function segmentPiercesRect(start: Point, end: Point, box: Rect): boolean {
|
|
280
|
+
const [x, y, width, height] = box;
|
|
281
|
+
const corners: Point[] = [
|
|
282
|
+
[x, y],
|
|
283
|
+
[x + width, y],
|
|
284
|
+
[x + width, y + height],
|
|
285
|
+
[x, y + height],
|
|
286
|
+
];
|
|
287
|
+
const borders: [Point, Point][] = corners.map((corner, index) => [corner, corners[(index + 1) % 4]]);
|
|
288
|
+
let crossings = 0;
|
|
289
|
+
for (const [a, b] of borders) if (segmentsCross(start, end, a, b)) crossings++;
|
|
290
|
+
if (crossings >= 2) return true;
|
|
291
|
+
return crossings === 1 && (pointInRect(start, box) || pointInRect(end, box));
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
function isDescendantOf(cell: DomEl, ancestorId: string | null, ids: ById): boolean {
|
|
295
|
+
const seen = new Set<string>();
|
|
296
|
+
let parent = attr(cell, "parent");
|
|
297
|
+
while (parent && ids.has(parent) && !seen.has(parent)) {
|
|
298
|
+
if (parent === ancestorId) return true;
|
|
299
|
+
seen.add(parent);
|
|
300
|
+
parent = attr(ids.get(parent)!, "parent");
|
|
301
|
+
}
|
|
302
|
+
return false;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
function isTextAnnotation(cell: DomEl): boolean {
|
|
306
|
+
return (attr(cell, "style") ?? "").split(";").some((token) => token.trim() === "text");
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
interface AutoRouteContext {
|
|
310
|
+
edgeId: string | null;
|
|
311
|
+
sourceId: string;
|
|
312
|
+
targetId: string;
|
|
313
|
+
sourcePoint: Point;
|
|
314
|
+
targetPoint: Point;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
function autoRouteContext(cell: DomEl, ids: ById): AutoRouteContext | null {
|
|
318
|
+
if (cell.getAttribute("edge") !== "1" || !isVisible(cell, ids) || edgeWaypoints(cell).length > 0) return null;
|
|
319
|
+
const sourceId = attr(cell, "source");
|
|
320
|
+
const targetId = attr(cell, "target");
|
|
321
|
+
if (!sourceId || !targetId) return null;
|
|
322
|
+
const source = ids.get(sourceId);
|
|
323
|
+
const target = ids.get(targetId);
|
|
324
|
+
if (!source || !target || geometryIsRelative(source) || geometryIsRelative(target)) return null;
|
|
325
|
+
const sourcePoint = endpoint(cell, "source", ids);
|
|
326
|
+
const targetPoint = endpoint(cell, "target", ids);
|
|
327
|
+
if (!sourcePoint || !targetPoint) return null;
|
|
328
|
+
return { edgeId: attr(cell, "id"), sourceId, targetId, sourcePoint, targetPoint };
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
function routeThroughObservation(context: AutoRouteContext, leaf: LeafBox, ids: ById): string | null {
|
|
332
|
+
const [vertexId, box] = leaf;
|
|
333
|
+
if (vertexId === null || vertexId === context.sourceId || vertexId === context.targetId) return null;
|
|
334
|
+
const vertex = ids.get(vertexId);
|
|
335
|
+
if (!vertex || isTextAnnotation(vertex)) return null;
|
|
336
|
+
if (isDescendantOf(vertex, context.sourceId, ids) || isDescendantOf(vertex, context.targetId, ids)) return null;
|
|
337
|
+
if (!segmentPiercesRect(context.sourcePoint, context.targetPoint, box)) return null;
|
|
338
|
+
return `edge ${repr(context.edgeId)} may pass over vertex ${repr(vertexId)} (predicted from the direct line; verify in the preview, then add waypoints or move the shape if needed)`;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
function edgeRouteThroughObservations(cell: DomEl, ids: ById, leaves: LeafBox[]): string[] {
|
|
342
|
+
const context = autoRouteContext(cell, ids);
|
|
343
|
+
if (!context) return [];
|
|
344
|
+
return leaves
|
|
345
|
+
.map((leaf) => routeThroughObservation(context, leaf, ids))
|
|
346
|
+
.filter((observation): observation is string => observation !== null);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* Identify auto-routed edges whose direct connection line pierces an unrelated
|
|
351
|
+
* leaf vertex. This is only a preview-review hint because draw.io may route the
|
|
352
|
+
* actual orthogonal connector around the shape.
|
|
353
|
+
*/
|
|
354
|
+
function predictedRouteThroughObservations(cells: DomEl[], ids: ById, leaves: LeafBox[]): string[] {
|
|
355
|
+
return cells.flatMap((cell) => edgeRouteThroughObservations(cell, ids, leaves));
|
|
356
|
+
}
|
|
357
|
+
|
|
158
358
|
function geometryWarnings(cells: DomEl[], ids: ById, parents: Set<string | null>): string[] {
|
|
159
359
|
const routed = collectRoutedEdges(cells, ids);
|
|
160
360
|
const leaves = collectLeafBoxes(cells, ids, parents);
|
|
161
|
-
return [...routeThroughWarnings(routed, leaves), ...routeCrossWarnings(routed)];
|
|
361
|
+
return [...routeThroughWarnings(routed, leaves), ...routeCrossWarnings(routed), ...anchorFacingWarnings(cells, ids)];
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
/** Edges the route checks above cannot see: no explicit waypoints, so the renderer routes them blindly. */
|
|
365
|
+
function autoRoutedEdgeWarning(cells: DomEl[], ids: ById): string | null {
|
|
366
|
+
const unrouted: string[] = [];
|
|
367
|
+
for (const cell of cells) {
|
|
368
|
+
if (cell.getAttribute("edge") === "1" && isVisible(cell, ids) && edgeRoute(cell, ids) === null) {
|
|
369
|
+
unrouted.push(repr(attr(cell, "id")));
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
if (unrouted.length === 0) return null;
|
|
373
|
+
return (
|
|
374
|
+
`${unrouted.length} auto-routed edge(s) cannot be route-checked (no explicit waypoints): ${unrouted.join(", ")}; ` +
|
|
375
|
+
"add waypoints and pinned anchors, or verify their routing visually"
|
|
376
|
+
);
|
|
162
377
|
}
|
|
163
378
|
|
|
164
379
|
/** Map every cell by id (blank key for id-less cells); report duplicate ids as errors. */
|
|
@@ -410,6 +625,211 @@ function labelText(cell: DomEl): string {
|
|
|
410
625
|
return stripLabelMarkup(attr(cell, "value") ?? "").replaceAll(" ", " ").trim();
|
|
411
626
|
}
|
|
412
627
|
|
|
628
|
+
const DEFAULT_FONT_SIZE = 11;
|
|
629
|
+
const CHAR_WIDTH_FACTOR = 0.6;
|
|
630
|
+
const LINE_HEIGHT_FACTOR = 1.4;
|
|
631
|
+
|
|
632
|
+
function labelOffset(cell: DomEl): Point | null {
|
|
633
|
+
const geometry = firstByTag(cell, "mxGeometry");
|
|
634
|
+
const offset = geometry
|
|
635
|
+
? childrenByTag(geometry, "mxPoint").find((point) => attr(point, "as") === "offset")
|
|
636
|
+
: undefined;
|
|
637
|
+
if (!offset) return null;
|
|
638
|
+
const x = pyFloat(attr(offset, "x") ?? "0");
|
|
639
|
+
const y = pyFloat(attr(offset, "y") ?? "0");
|
|
640
|
+
if (x === undefined || y === undefined || !Number.isFinite(x) || !Number.isFinite(y)) return null;
|
|
641
|
+
return [x, y];
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
/** Where an inline edge label is anchored along its route, as a 0..1 fraction (geometry x runs -1..1). */
|
|
645
|
+
function labelFraction(edge: DomEl): number {
|
|
646
|
+
const geometry = firstByTag(edge, "mxGeometry");
|
|
647
|
+
const along = geometry ? pyFloat(attr(geometry, "x") ?? "0") : 0;
|
|
648
|
+
return along !== undefined && Number.isFinite(along) ? Math.min(1, Math.max(0, (along + 1) / 2)) : 0.5;
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
/** Estimated box of an edge's inline label, centered on its explicit route like draw.io renders it. */
|
|
652
|
+
function inlineEdgeLabelRect(edge: DomEl, ids: ById): Rect | null {
|
|
653
|
+
const route = labelText(edge) ? edgeRoute(edge, ids) : null;
|
|
654
|
+
return route ? labelBox(edge, route) : null;
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
/** Estimated label box for an edge along a given route. */
|
|
658
|
+
function labelBox(edge: DomEl, route: Point[]): Rect {
|
|
659
|
+
const label = labelText(edge);
|
|
660
|
+
const [centerX, centerY] = routePointAt(route, labelFraction(edge));
|
|
661
|
+
const [offsetX, offsetY] = labelOffset(edge) ?? [0, 0];
|
|
662
|
+
const fontSize = styleNum(attr(edge, "style"), "fontSize") ?? DEFAULT_FONT_SIZE;
|
|
663
|
+
const lines = label.split("\n");
|
|
664
|
+
const width = Math.max(...lines.map((line) => line.length)) * fontSize * CHAR_WIDTH_FACTOR;
|
|
665
|
+
const height = lines.length * fontSize * LINE_HEIGHT_FACTOR;
|
|
666
|
+
return [centerX + offsetX - width / 2, centerY + offsetY - height / 2, width, height];
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
function edgeLabelBox(cell: DomEl, ids: ById): [string | null, Rect] | null {
|
|
670
|
+
if (cell.getAttribute("edge") === "1") {
|
|
671
|
+
const box = inlineEdgeLabelRect(cell, ids);
|
|
672
|
+
return box ? [attr(cell, "id"), box] : null;
|
|
673
|
+
}
|
|
674
|
+
if (isEdgeLabel(cell) && labelText(cell)) {
|
|
675
|
+
const box = explicitEdgeLabelRect(cell, ids);
|
|
676
|
+
return box ? [attr(cell, "id"), box] : null;
|
|
677
|
+
}
|
|
678
|
+
return null;
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
/** Edge-label text lying on top of a shape; sizes are estimated, so phrased as "likely". */
|
|
682
|
+
function labelOverlapWarnings(cells: DomEl[], ids: ById, parents: Set<string | null>): string[] {
|
|
683
|
+
const leaves = collectLeafBoxes(cells, ids, parents);
|
|
684
|
+
const warnings: string[] = [];
|
|
685
|
+
for (const cell of cells) {
|
|
686
|
+
if (!isVisible(cell, ids)) continue;
|
|
687
|
+
const labeled = edgeLabelBox(cell, ids);
|
|
688
|
+
if (!labeled || hasInvalidNumber(labeled[1])) continue;
|
|
689
|
+
const [id, box] = labeled;
|
|
690
|
+
for (const [vertexId, vertexBox] of leaves) {
|
|
691
|
+
if (overlap(box, vertexBox)) warnings.push(`edge label ${repr(id)} likely overlaps vertex ${repr(vertexId)}`);
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
return warnings;
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
/** Drop waypoints on a straight run and sub-2px jogs (not real bends), keeping the route's shape. */
|
|
698
|
+
function straightenRoute(points: Point[]): Point[] {
|
|
699
|
+
const near = (a: number, b: number): boolean => Math.abs(a - b) < 2;
|
|
700
|
+
const within = (value: number, a: number, b: number): boolean =>
|
|
701
|
+
Math.min(a, b) - 2 <= value && value <= Math.max(a, b) + 2;
|
|
702
|
+
const result: Point[] = [points[0]];
|
|
703
|
+
for (let i = 1; i < points.length - 1; i++) {
|
|
704
|
+
const previous = result.at(-1)!;
|
|
705
|
+
const [point, next] = [points[i], points[i + 1]];
|
|
706
|
+
const jog = near(point[0], previous[0]) && near(point[1], previous[1]);
|
|
707
|
+
const between = within(point[0], previous[0], next[0]) && within(point[1], previous[1], next[1]);
|
|
708
|
+
const run =
|
|
709
|
+
between &&
|
|
710
|
+
((near(previous[1], point[1]) && near(point[1], next[1])) ||
|
|
711
|
+
(near(previous[0], point[0]) && near(point[0], next[0])) ||
|
|
712
|
+
orient(previous, point, next) === 0);
|
|
713
|
+
if (!jog && !run) result.push(point);
|
|
714
|
+
}
|
|
715
|
+
result.push(points.at(-1)!);
|
|
716
|
+
return result;
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
/** True for a horizontal or vertical segment, the only kind whose rendered path is known for orthogonal routing. */
|
|
720
|
+
function axisAligned(a: Point, b: Point): boolean {
|
|
721
|
+
return Math.abs(a[0] - b[0]) < 2 || Math.abs(a[1] - b[1]) < 2;
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
function isOrthogonal(edge: DomEl): boolean {
|
|
725
|
+
const style = attr(edge, "style") ?? "";
|
|
726
|
+
return /(?:^|;)edgeStyle=(?:orthogonalEdgeStyle|elbowEdgeStyle)(?:;|$)/.test(style);
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
/**
|
|
730
|
+
* Rebuild the corners draw.io adds to a diagonal first or last segment of an
|
|
731
|
+
* orthogonal edge: it leaves a top/bottom exit vertically and a left/right exit
|
|
732
|
+
* horizontally, and mirrors that at the entry. Returns null when a diagonal
|
|
733
|
+
* remains whose rendered path cannot be inferred.
|
|
734
|
+
*/
|
|
735
|
+
function orthogonalRoute(edge: DomEl, route: Point[]): Point[] | null {
|
|
736
|
+
if (!isOrthogonal(edge)) return route;
|
|
737
|
+
const style = attr(edge, "style");
|
|
738
|
+
const side = (x: string, y: string): "vertical" | "horizontal" | null => {
|
|
739
|
+
const fy = styleNum(style, y);
|
|
740
|
+
const fx = styleNum(style, x);
|
|
741
|
+
if (fy === 0 || fy === 1) return "vertical";
|
|
742
|
+
if (fx === 0 || fx === 1) return "horizontal";
|
|
743
|
+
return null;
|
|
744
|
+
};
|
|
745
|
+
const points = [...route];
|
|
746
|
+
const last = points.length - 1;
|
|
747
|
+
if (!axisAligned(points[last - 1], points[last])) {
|
|
748
|
+
const entry = side("entryX", "entryY");
|
|
749
|
+
const [prev, end] = [points[last - 1], points[last]];
|
|
750
|
+
if (entry === "horizontal") points.splice(last, 0, [prev[0], end[1]]);
|
|
751
|
+
else if (entry === "vertical") points.splice(last, 0, [end[0], prev[1]]);
|
|
752
|
+
}
|
|
753
|
+
if (!axisAligned(points[0], points[1])) {
|
|
754
|
+
const exit = side("exitX", "exitY");
|
|
755
|
+
const [start, next] = [points[0], points[1]];
|
|
756
|
+
if (exit === "vertical") points.splice(1, 0, [start[0], next[1]]);
|
|
757
|
+
else if (exit === "horizontal") points.splice(1, 0, [next[0], start[1]]);
|
|
758
|
+
}
|
|
759
|
+
return points.slice(1).every((point, i) => axisAligned(points[i], point)) ? points : null;
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
/** Index of the route segment that holds the point at `fraction` of the route's length. */
|
|
763
|
+
function anchorSegment(points: Point[], fraction: number): number {
|
|
764
|
+
const lengths = points.slice(1).map((point, i) => Math.hypot(point[0] - points[i][0], point[1] - points[i][1]));
|
|
765
|
+
let remaining = lengths.reduce((sum, length) => sum + length, 0) * fraction;
|
|
766
|
+
for (let i = 0; i < lengths.length; i++) {
|
|
767
|
+
if (remaining <= lengths[i]) return i;
|
|
768
|
+
remaining -= lengths[i];
|
|
769
|
+
}
|
|
770
|
+
return Math.max(0, lengths.length - 1);
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
/**
|
|
774
|
+
* Inline labels whose estimated box lands on a bend or another segment of
|
|
775
|
+
* their own connector (typically after an offset pushes them sideways), or on
|
|
776
|
+
* another explicitly routed connector. A background color cannot fix these:
|
|
777
|
+
* the line visibly runs into the text.
|
|
778
|
+
*/
|
|
779
|
+
function labelRouteWarnings(cells: DomEl[], ids: ById): string[] {
|
|
780
|
+
const routes: [string | null, Point[]][] = [];
|
|
781
|
+
for (const cell of cells) {
|
|
782
|
+
const route = visibleEdgeRoute(cell, ids);
|
|
783
|
+
if (route) routes.push([attr(cell, "id"), route]);
|
|
784
|
+
}
|
|
785
|
+
const warnings: string[] = [];
|
|
786
|
+
for (const cell of cells) {
|
|
787
|
+
const route = labelText(cell) ? visibleEdgeRoute(cell, ids) : null;
|
|
788
|
+
if (!route) continue;
|
|
789
|
+
const box = labelBox(cell, route);
|
|
790
|
+
if (hasInvalidNumber(box)) continue;
|
|
791
|
+
const id = attr(cell, "id");
|
|
792
|
+
warnings.push(...labelRouteIntersections(id, route, box, labelFraction(cell), routes));
|
|
793
|
+
}
|
|
794
|
+
return warnings;
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
function visibleEdgeRoute(cell: DomEl, ids: ById): Point[] | null {
|
|
798
|
+
if (cell.getAttribute("edge") !== "1" || !isVisible(cell, ids)) return null;
|
|
799
|
+
const explicit = edgeRoute(cell, ids);
|
|
800
|
+
return explicit ? orthogonalRoute(cell, straightenRoute(explicit)) : null;
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
function labelRouteIntersections(
|
|
804
|
+
id: string | null,
|
|
805
|
+
route: Point[],
|
|
806
|
+
box: Rect,
|
|
807
|
+
fraction: number,
|
|
808
|
+
routes: [string | null, Point[]][],
|
|
809
|
+
): string[] {
|
|
810
|
+
const warnings: string[] = [];
|
|
811
|
+
const anchor = anchorSegment(route, fraction);
|
|
812
|
+
const hitsOwnRoute = route.slice(1).some((point, i) => i !== anchor && routeHitsRect([route[i], point], box));
|
|
813
|
+
if (hitsOwnRoute) {
|
|
814
|
+
warnings.push(
|
|
815
|
+
`edge label ${repr(id)} likely sits on a bend or another segment of its own connector; move it along the edge (geometry x) or change its offset so the text clears every segment`,
|
|
816
|
+
);
|
|
817
|
+
}
|
|
818
|
+
for (const [otherId, otherRoute] of routes) {
|
|
819
|
+
if (otherId !== id && routeHitsRect(otherRoute, box)) {
|
|
820
|
+
warnings.push(`edge label ${repr(id)} likely overlaps edge ${repr(otherId)}`);
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
return warnings;
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
function labelOnLineWarning(cell: DomEl): string | null {
|
|
827
|
+
if (cell.getAttribute("edge") !== "1" || !labelText(cell)) return null;
|
|
828
|
+
if ((attr(cell, "style") ?? "").includes("labelBackgroundColor=")) return null;
|
|
829
|
+
if (labelOffset(cell)) return null;
|
|
830
|
+
return `edge ${repr(attr(cell, "id"))} label sits directly on its line; add an offset or labelBackgroundColor`;
|
|
831
|
+
}
|
|
832
|
+
|
|
413
833
|
function isCompactBorderPort(cell: DomEl, box: Rect | null): boolean {
|
|
414
834
|
return (
|
|
415
835
|
cell.getAttribute("vertex") === "1" &&
|
|
@@ -425,7 +845,7 @@ function isCompactBorderPort(cell: DomEl, box: Rect | null): boolean {
|
|
|
425
845
|
function smallFontWarning(cell: DomEl, box: Rect | null): string | null {
|
|
426
846
|
const fontSize = styleNum(attr(cell, "style"), "fontSize");
|
|
427
847
|
const isEdgeText = cell.getAttribute("edge") === "1" || isEdgeLabel(cell);
|
|
428
|
-
const minimum = isEdgeText ?
|
|
848
|
+
const minimum = isEdgeText ? 10 : 11;
|
|
429
849
|
if (
|
|
430
850
|
isCompactBorderPort(cell, box) ||
|
|
431
851
|
fontSize === undefined ||
|
|
@@ -457,7 +877,7 @@ function cellReadabilityWarnings(cell: DomEl): string[] {
|
|
|
457
877
|
const label = labelText(cell);
|
|
458
878
|
if (!label) return [];
|
|
459
879
|
const box = rect(cell);
|
|
460
|
-
return [smallFontWarning(cell, box), longLabelWarning(cell, label, box)].filter(
|
|
880
|
+
return [smallFontWarning(cell, box), longLabelWarning(cell, label, box), labelOnLineWarning(cell)].filter(
|
|
461
881
|
(warning): warning is string => warning !== null,
|
|
462
882
|
);
|
|
463
883
|
}
|
|
@@ -483,7 +903,23 @@ function checkPage(diagram: DomEl): [string[], string[], string[]] {
|
|
|
483
903
|
const errors: string[] = [];
|
|
484
904
|
const warnings: string[] = [];
|
|
485
905
|
const observations: string[] = [];
|
|
906
|
+
const motion = analyzeStoredMotion(model);
|
|
486
907
|
const ids = buildIds(cells, errors);
|
|
908
|
+
const animation = analyzeAnimationPage(diagram);
|
|
909
|
+
errors.push(...animation.errors);
|
|
910
|
+
warnings.push(...animation.warnings);
|
|
911
|
+
observations.push(...animation.observations);
|
|
912
|
+
if (motion) {
|
|
913
|
+
errors.push(...motion.errors);
|
|
914
|
+
if (motion.compiled) {
|
|
915
|
+
observations.push(
|
|
916
|
+
`stored motion has ${motion.spec!.steps.length} step(s) lasting ${Math.round(motion.compiled.sequenceMs)}ms; export it with drawio_animate`,
|
|
917
|
+
);
|
|
918
|
+
}
|
|
919
|
+
if (animation.sequence?.enabled) {
|
|
920
|
+
errors.push("page has both stored motion and an enabled native page animation; keep only one timeline");
|
|
921
|
+
}
|
|
922
|
+
}
|
|
487
923
|
const parents = new Set<string | null>();
|
|
488
924
|
for (const cell of cells) parents.add(attr(cell, "parent"));
|
|
489
925
|
|
|
@@ -491,9 +927,14 @@ function checkPage(diagram: DomEl): [string[], string[], string[]] {
|
|
|
491
927
|
warnings.push(
|
|
492
928
|
...overlapWarnings(cells, ids, parents),
|
|
493
929
|
...geometryWarnings(cells, ids, parents),
|
|
930
|
+
...labelOverlapWarnings(cells, ids, parents),
|
|
931
|
+
...labelRouteWarnings(cells, ids),
|
|
494
932
|
...containmentWarnings(cells, ids),
|
|
495
933
|
...readabilityWarnings(cells),
|
|
496
934
|
);
|
|
935
|
+
observations.push(...predictedRouteThroughObservations(cells, ids, collectLeafBoxes(cells, ids, parents)));
|
|
936
|
+
const autoRouted = autoRoutedEdgeWarning(cells, ids);
|
|
937
|
+
if (autoRouted) warnings.push(autoRouted);
|
|
497
938
|
const settings = pageSettings(model, warnings, observations);
|
|
498
939
|
warnings.push(...canvasWarnings(contentBounds(cells, ids), settings));
|
|
499
940
|
return [withPage(name, errors), withPage(name, warnings), withPage(name, observations)];
|
|
@@ -519,16 +960,17 @@ export function validateXml(xml: string): ValidateResult {
|
|
|
519
960
|
const through = warnings.filter((warning) => warning.includes("routes through")).length;
|
|
520
961
|
const crossings = warnings.filter((warning) => warning.endsWith(" cross")).length;
|
|
521
962
|
const overlaps = warnings.filter((warning) => warning.endsWith(" overlap")).length;
|
|
963
|
+
const anchors = warnings.filter((warning) => warning.endsWith("reduce bends")).length;
|
|
522
964
|
return {
|
|
523
965
|
errors,
|
|
524
966
|
warnings,
|
|
525
967
|
observations,
|
|
526
|
-
score: { total: 20 * through + 10 * crossings + 5 * overlaps, through, crossings, overlaps },
|
|
968
|
+
score: { total: 20 * through + 10 * crossings + 5 * overlaps + 8 * anchors, through, crossings, overlaps, anchors },
|
|
527
969
|
};
|
|
528
970
|
}
|
|
529
971
|
|
|
530
972
|
function emptyScore(): ValidateResult["score"] {
|
|
531
|
-
return { total: 0, through: 0, crossings: 0, overlaps: 0 };
|
|
973
|
+
return { total: 0, through: 0, crossings: 0, overlaps: 0, anchors: 0 };
|
|
532
974
|
}
|
|
533
975
|
|
|
534
976
|
/** Read and lint a `.drawio` file. Read/parse failures are returned as errors, never thrown. */
|
package/src/workflow.ts
CHANGED
|
@@ -17,6 +17,7 @@ export const AUTOMATIC_CORRECTION_LIMIT = 8;
|
|
|
17
17
|
export interface WorkflowReferences {
|
|
18
18
|
diagramTypes: string | null;
|
|
19
19
|
xmlAuthoring: string | null;
|
|
20
|
+
stylePresets: string | null;
|
|
20
21
|
/** Only provided when the CLI supports Mermaid conversion (v30+). */
|
|
21
22
|
mermaidAuthoring: string | null;
|
|
22
23
|
}
|
|
@@ -76,21 +77,22 @@ export function drawmeWorkflow(description: string, refDir: string, cli: DrawioI
|
|
|
76
77
|
"Produce a `.drawio` file and export it, following the workflow below. For anything that touches the draw.io CLI, use the DrawMe tools — do NOT shell out to `drawio` yourself. The references at the end of this message are already loaded: do not re-read those files.",
|
|
77
78
|
"",
|
|
78
79
|
cliStatus(cli),
|
|
79
|
-
"2. **Plan** — choose the diagram type, shapes, relationships, and layout direction (LR or TB). Plan generous spacing (200–350px between shapes) and do NOT fix page dimensions up front: the canvas is fitted to the finished content later with `drawio_fit_canvas`. For a specific type (ERD, UML class, sequence, C4, architecture, ML/DL, flowchart, SysML, BPMN, network, swimlane), follow the diagram-types reference below." +
|
|
80
|
+
"2. **Plan** — choose the diagram type, shapes, relationships, and layout direction (LR or TB). Plan generous spacing (200–350px between shapes) and do NOT fix page dimensions up front: the canvas is fitted to the finished content later with `drawio_fit_canvas`. For a specific type (ERD, UML class, sequence, C4, architecture, ML/DL, flowchart, SysML, BPMN, network, swimlane), follow the diagram-types reference below. Pick one style preset from the style presets reference below: Light unless the user explicitly asks for a dark theme or for multiple colors (Dark, Multi-color, or both). Never choose Dark or Multi-color on your own. Set the theme's page background and use its colors, edge styles, and typography for every cell; take only structural style keys from the diagram-types reference, not its colors. If the request asks for movement, plan an animated SVG: a `drawio_animate` motion story (entrances, connector draw-ins, travelling dots, highlights, dimming) following the preset reference's motion design section, persistent connector flow for continuous direction, or both; use a portable page sequence only when draw.io's own viewer must play the animation. Also plan a static PNG fallback unless the user explicitly asks for SVG only." +
|
|
80
81
|
mermaidPlanning,
|
|
81
|
-
"3. **Author** — for hand-written XML, follow the XML authoring reference below. Keep XML uncompressed; never reuse ids `0`/`1`; give every edge `<mxGeometry relative=\"1\" as=\"geometry\"/>`; use `drawio_shapesearch` rather than guessing exact vendor/UML/BPMN/cloud styles. For large graphs (>~15 nodes) on v30+, hand-write nodes and use `drawio_layout`. Space elements generously rather than packing them, then run `drawio_fit_canvas` after authoring — and again after any Mermaid conversion or layout — so the page wraps the content with a comfortable margin. Treat every write, edit, Mermaid conversion, layout, and canvas-fit result as a source edit.",
|
|
82
|
-
"4. **Validate after every source edit** — call `drawio_validate` immediately after authoring and after every later XML edit, Mermaid conversion, or layout operation. Fix all errors before previewing. Every warning must be either fixed or recorded explicitly as reviewed and acceptable with a reason; unresolved or unreviewed warnings block final export.",
|
|
82
|
+
"3. **Author** — for hand-written XML, follow the XML authoring reference below. Keep XML uncompressed; never reuse ids `0`/`1`; give every edge `<mxGeometry relative=\"1\" as=\"geometry\"/>`; use `drawio_shapesearch` rather than guessing exact vendor/UML/BPMN/cloud styles. For animation, author the complete static diagram first and add motion afterwards with `drawio_animate`; do not hand-write page animation JSON for effects it covers. Connector flow stays in edge styles. Never hide a cell with `visible=0` when the animation needs to reveal it. For large graphs (>~15 nodes) on v30+, hand-write nodes and use `drawio_layout`. Space elements generously rather than packing them, then run `drawio_fit_canvas` after authoring — and again after any Mermaid conversion or layout — so the page wraps the content with a comfortable margin. Treat every write, edit, Mermaid conversion, layout, and canvas-fit result as a source edit.",
|
|
83
|
+
"4. **Validate after every source edit** — call `drawio_validate` immediately after authoring and after every later XML edit, Mermaid conversion, or layout operation. Fix all errors before previewing. Every warning must be either fixed or recorded explicitly as reviewed and acceptable with a reason; unresolved or unreviewed warnings block final export. For animated SVG, unsupported page effects are blocking rather than acceptable because final animation verification will reject them.",
|
|
83
84
|
"5. **Visual review — three focused passes, then a holistic confirmation** — run this once authoring and validation are clean. Export previews with `drawio_export` mode `\"preview\"`; every preview renders a single page, so for a multi-page file, export one preview per page with `pageIndex` and review every page (page-suffixed names, e.g. `<name>.review-p2-fit.png`). The result text states whether the preview image is attached; follow the matching path:",
|
|
84
85
|
" - **Image attached** — run the four passes below in order. Do not start the next pass until every finding of the current one is verified **fixed** in a fresh render or explicitly accepted with a reason. For each pass: export its preview, write a structured critique that hunts for defects — do not summarize or admire the diagram — answer the pass's questions explicitly (a bare \"yes\" is not an answer; point at the evidence in the image), and record findings in one numbered ledger kept for the rest of the run: `F1, F2, …: pass / severity / affected cell ids / what is visibly wrong and where in the image / planned fix` (pick fixes from the defect→fix recipes in the XML authoring reference). The critique's job is to narrow every problem down to specific cells so the fix step can be surgical.",
|
|
85
86
|
" 1. **Pass 1 — fit and sizing** (`<name>.review-fit.png`) answers: does the diagram fit its page, and does the canvas or any element need resizing? Hunt: content touching or crossing a page edge; one outer margin visibly thinner than the others; large empty regions or a page far larger than its content; elements too small for their labels — text touching or crossing its own shape border, clipped or mid-word truncated; a smallest label you cannot comfortably read at full-diagram scale (tighten the canvas with `drawio_fit_canvas`, split content across pages, or simplify the layout — never judge what you cannot read, and never treat \"too small to tell\" as a pass).",
|
|
86
87
|
" 2. **Pass 2 — element placement** (`<name>.review-layout.png`) answers: is every element positioned correctly, and is there a visibly better arrangement? Hunt: shapes whose borders touch or overlap; two labels touching or overlapping each other; label text lying on top of any line or unrelated shape; rows/columns that drift out of alignment; uneven gaps between peers; children poking out of their container or crowding its title; related elements far apart while unrelated ones sit adjacent. Improve, not only repair: if moving an element would shorten edges, remove crossings, or make the arrangement symmetric, record that as a finding too.",
|
|
87
88
|
" 3. **Pass 3 — connections** (`<name>.review-connectors.png`) answers: is every connection correct, cleanly routed, symmetric where the layout is symmetric, and anchored to the middle of the element side it faces wherever possible? Trace every edge from source to target and check it against the plan — right source, right target, right direction, right label. Hunt: an endpoint floating off its shape or plunging deep into it; an edge entering at an odd corner when a side-center anchor is available (pin `exitX`/`exitY`/`entryX`/`entryY` to the facing side's center, spreading evenly only when several edges share one side); mirrored branches routed asymmetrically; an arrowhead hidden by a shape or crushed into a bend; an edge passing through a shape it does not connect; parallel edges stacked on top of each other; an edge label sitting on its line so the text is struck through, or closer than about half a text-height to any line; crossings a reroute through a free corridor would remove.",
|
|
88
|
-
"
|
|
89
|
+
" Heed `drawio_validate` anchor warnings literally: re-pin an exit or entry to the suggested facing side before adding waypoints. Treat predicted route-through observations as focused preview-review hints, not proof of draw.io's rendered route; add waypoints or move a shape only when the preview confirms the obstruction.",
|
|
90
|
+
" 4. **Pass 4 — typography, semantics, and regression** (`<name>.review.png`) is the holistic confirmation. Read every label word for word — a label you cannot fully read is itself a finding; check text contrast against fills; confirm every requested component and relationship is present, pointing the right way, with the right label; check hierarchy, grouping, and that legend entries match the colors actually used; apply the type's `Review:` checklist from the diagram-types reference; and re-check passes 1–3 for regressions. For animation, cross-check the sequence order, cell ids, durations, direction, loop setting, and reduced-motion/static fallback structurally; the PNG preview is intentionally static and must not be presented as temporal playback proof. Review the motion itself on the `drawio_animate` storyboard after this pass. Retain this image (every page, for a multi-page file) for the final report.",
|
|
89
91
|
" - **Image NOT attached** — the current model cannot view images. Skip the visual passes: do not describe or judge renders; review structurally instead by cross-checking `drawio_validate` findings and a `drawio_explain` read-back against the user's request. Keep the latest `<name>.review.png` on disk so the user can view it, and state plainly in the summary that rendered inspection was skipped.",
|
|
90
92
|
"6. **Fix and verify before the next pass** — resolve a pass's findings with targeted source edits: after each edit, validate, then re-export the same pass preview (for a multi-page file, the page the finding is on). The superseded preview file is deleted from disk, but its image is still visible earlier in this conversation: compare the new image against it at each addressed finding's location and record a verdict — **fixed** (the defect is gone in the new render), **not fixed** (still visible), or **regressed** (the edit introduced a new defect; log it as a new numbered finding). Never mark a finding fixed because the XML changed — only because the new image shows it fixed. When elements overlap, are cramped, clipped, or short on margin, never shrink or squeeze elements to fit the page — move them apart, then run `drawio_fit_canvas` to enlarge the canvas around them. A pass is complete only when all of its findings are fixed or explicitly accepted, and every pass must be complete before final export. If the correction limit is reached mid-pass, finish the remaining passes as inspection-only and report their findings as unresolved. Each successful preview export automatically removes the previous preview file for the same source, so only the latest review image remains.",
|
|
91
93
|
`7. **Correction limit** — pass inspection previews (the first preview of each pass) do not count against the limit. Across the whole review, allow at most ${AUTOMATIC_CORRECTION_LIMIT} correction retries; one retry is one targeted source-edit → \`drawio_validate\` → replacement-preview cycle, whatever its verdict. Count retries explicitly. If the limit is reached with a finding unresolved, stop automatic editing, keep the best validated state, and continue to final export — name the unresolved finding, its pass, and its last verdict plainly in the final report instead of looping or waiting for input.`,
|
|
92
94
|
"8. **No human gate** — the run is fully autonomous: once started, never pause to ask for approval, confirmation, or feedback. When pass 4 is clean (or the correction limit was reached), proceed directly to final export. If the user interrupts with feedback mid-run, append it to the ledger as new numbered findings: targeted edit, validate, before/after confirmation on the relevant pass preview, a fresh pass-4 holistic preview, then continue to export.",
|
|
93
|
-
"9. **Final export** — immediately after pass 4 is clean (or the correction limit was reached), call `drawio_export` with `mode: \"final\"` for each requested format (default PNG; SVG/PDF/JPG on request). A final export
|
|
95
|
+
"9. **Final export** — immediately after pass 4 is clean (or the correction limit was reached), call `drawio_export` with `mode: \"final\"` for each requested format (default PNG; SVG/PDF/JPG on request). When motion was requested, the primary deliverable is a `drawio_animate` call with the planned steps. Check its storyboard frame by frame against the planned story; when a frame shows the wrong order or visibility, fix the steps and call it again (each call counts as one correction retry). For a page whose only motion is connector flow or a native page sequence, call `drawio_export` with `animated: true` and `format: \"svg\"` instead. Read the result and report animation as successful only when it says `Animation verified`. Also export the planned static PNG fallback unless the user requested SVG only. Animated mode never supports preview, PNG, PDF, or JPG. A final export renders a single page: for a multi-page file, export each page with `pageIndex` and a distinct `output` per page and format. The first successful final export removes the one remaining latest preview for the same source; do not delete previews yourself or report it as a retained output. Report the `.drawio` source and every final path, whether animation verification passed, retained reviewed warnings, any unresolved finding from the correction limit, and cleanup warnings. Offer `drawio_open` for fine-tuning afterwards.",
|
|
94
96
|
"",
|
|
95
97
|
"Failure handling: several DrawMe tools report failures as a text result beginning with `Export failed`, `Layout failed`, `Mermaid conversion failed`, `Fit canvas failed`, `Explain failed`, or `Open failed` rather than a tool error — always read the result text and treat those as failures. If export fails, read `" +
|
|
96
98
|
refDir +
|
|
@@ -102,6 +104,7 @@ export function drawmeWorkflow(description: string, refDir: string, cli: DrawioI
|
|
|
102
104
|
"",
|
|
103
105
|
...referenceSection("diagram types", `${refDir}/diagram-types.md`, refs.diagramTypes),
|
|
104
106
|
...referenceSection("XML authoring", `${refDir}/xml-authoring.md`, refs.xmlAuthoring),
|
|
107
|
+
...referenceSection("style presets", `${refDir}/style-presets.md`, refs.stylePresets),
|
|
105
108
|
...(refs.mermaidAuthoring !== null || cli.supportsMermaid
|
|
106
109
|
? referenceSection("Mermaid authoring", `${refDir}/mermaid-authoring.md`, refs.mermaidAuthoring)
|
|
107
110
|
: []),
|