@markdy/renderer-dom 1.3.1 → 1.3.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/dist/index.d.ts +32 -1
- package/dist/index.js +470 -209
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -116,6 +116,8 @@ interface DiagramOptions {
|
|
|
116
116
|
playbackRate?: number;
|
|
117
117
|
/** Host interaction override. `true` enables default gestures; `false` suppresses script interaction. */
|
|
118
118
|
interactiveViewport?: boolean;
|
|
119
|
+
/** Host click-to-play override. `false` disables toggling playback on viewport click. */
|
|
120
|
+
clickToPlay?: boolean;
|
|
119
121
|
/** Base URL for the Share control. Defaults to the Markdy playground. */
|
|
120
122
|
shareUrl?: string;
|
|
121
123
|
/** Host controls override. `true` enables the legacy default set; `false` suppresses script controls; or pass a granular controls configuration object. */
|
|
@@ -126,6 +128,24 @@ interface DiagramOptions {
|
|
|
126
128
|
onTimeUpdate?: (seconds: number, durationSeconds: number) => void;
|
|
127
129
|
onPlayStateChange?: (playing: boolean) => void;
|
|
128
130
|
onEnded?: () => void;
|
|
131
|
+
/**
|
|
132
|
+
* Adaptive orientation & responsive layout mode.
|
|
133
|
+
* When true or "auto", switches to vertical Top-to-Bottom (TB) on mobile / portrait viewports,
|
|
134
|
+
* and horizontal Left-to-Right (LR) on desktop / landscape viewports.
|
|
135
|
+
* Defaults to true.
|
|
136
|
+
*/
|
|
137
|
+
responsiveLayout?: boolean;
|
|
138
|
+
/**
|
|
139
|
+
* Auto-scaling mode for diagram framing:
|
|
140
|
+
* - "width" (default): Width-First Responsiveness (scale factor = containerWidth / contentWidth, filling 95% - 100% width).
|
|
141
|
+
* - "contain": Scales to fit both width and height within container bounds.
|
|
142
|
+
*/
|
|
143
|
+
fitMode?: "width" | "contain";
|
|
144
|
+
/**
|
|
145
|
+
* Target container width fill fraction (0.95 - 1.0) when fitMode is "width".
|
|
146
|
+
* Defaults to 0.98 (edge-to-edge with 1% clean margins).
|
|
147
|
+
*/
|
|
148
|
+
targetWidthRatio?: number;
|
|
129
149
|
}
|
|
130
150
|
interface Diagram {
|
|
131
151
|
play(): void;
|
|
@@ -153,6 +173,17 @@ interface Diagram {
|
|
|
153
173
|
* Default light mode is "paper", default dark mode is "nebula".
|
|
154
174
|
*/
|
|
155
175
|
declare function detectHostTheme(container?: HTMLElement): "nebula" | "paper";
|
|
176
|
+
declare function computeDiagramContentBounds(plan: RenderPlan, options?: {
|
|
177
|
+
tight?: boolean;
|
|
178
|
+
padding?: number;
|
|
179
|
+
}): {
|
|
180
|
+
minX: number;
|
|
181
|
+
minY: number;
|
|
182
|
+
maxX: number;
|
|
183
|
+
maxY: number;
|
|
184
|
+
width: number;
|
|
185
|
+
height: number;
|
|
186
|
+
};
|
|
156
187
|
declare function createDiagram(opts: DiagramOptions): Diagram;
|
|
157
188
|
|
|
158
189
|
type SvgSpec = Array<[string, Record<string, string>]>;
|
|
@@ -275,4 +306,4 @@ declare function exportRouteShareCard(containerEl: HTMLElement, route: RouteCard
|
|
|
275
306
|
*/
|
|
276
307
|
declare function exportReachShareCard(containerEl: HTMLElement, reach: ReachCardOptions, options?: ShareCardOptions): Promise<Blob>;
|
|
277
308
|
|
|
278
|
-
export { type AnimationRecordFrame, type BlastRadiusResult, type ControllerOptions, type Diagram, type DiagramOptions, DiagramPresentationController, type GifDiagramExportOptions, type GifExportOptions, ICON_REGISTRY, type IconSpec, type PngExportOptions, type ReachCardOptions, type RouteCardOptions, type ShareCardOptions, type SvgExportOptions, type TimelineController, applyImpactHighlight, calculateBlastRadius, clearImpactHighlight, createDiagram, detectHostTheme, encodeGifSequence, exportDiagramAsGif, exportDiagramAsPng, exportDiagramAsShareCard, exportDiagramAsVectorSvg, exportLiveSceneAsPureVectorSvg, exportReachShareCard, exportRouteShareCard, findShortestRoute, iconKeyForNode, renderPureVectorSvg, renderShareCardSvg };
|
|
309
|
+
export { type AnimationRecordFrame, type BlastRadiusResult, type ControllerOptions, type Diagram, type DiagramOptions, DiagramPresentationController, type GifDiagramExportOptions, type GifExportOptions, ICON_REGISTRY, type IconSpec, type PngExportOptions, type ReachCardOptions, type RouteCardOptions, type ShareCardOptions, type SvgExportOptions, type TimelineController, applyImpactHighlight, calculateBlastRadius, clearImpactHighlight, computeDiagramContentBounds, createDiagram, detectHostTheme, encodeGifSequence, exportDiagramAsGif, exportDiagramAsPng, exportDiagramAsShareCard, exportDiagramAsVectorSvg, exportLiveSceneAsPureVectorSvg, exportReachShareCard, exportRouteShareCard, findShortestRoute, iconKeyForNode, renderPureVectorSvg, renderShareCardSvg };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
// src/diagram.ts
|
|
2
2
|
import {
|
|
3
3
|
compressMarkdyToUrlHash,
|
|
4
|
-
|
|
4
|
+
computeAdaptiveDimensions,
|
|
5
|
+
compilePlan,
|
|
6
|
+
parse,
|
|
5
7
|
resolvePlayer,
|
|
6
8
|
resolveTheme as resolveTheme2
|
|
7
9
|
} from "@markdy/core";
|
|
@@ -690,7 +692,7 @@ function circleBoundaryRoute(from, to) {
|
|
|
690
692
|
{ x: toCenter.x - ux * toRadius, y: toCenter.y - uy * toRadius }
|
|
691
693
|
]);
|
|
692
694
|
}
|
|
693
|
-
function snapPortToNodeShape(node, port, neighbor,
|
|
695
|
+
function snapPortToNodeShape(node, port, neighbor, _isSource) {
|
|
694
696
|
if (!node.shape || node.shape === "card" || node.shape === "rounded" || node.shape === "terminal" || node.shape === "container") {
|
|
695
697
|
return port;
|
|
696
698
|
}
|
|
@@ -698,45 +700,40 @@ function snapPortToNodeShape(node, port, neighbor, isSource) {
|
|
|
698
700
|
const cy = node.y + node.height / 2;
|
|
699
701
|
const hw = node.width / 2;
|
|
700
702
|
const hh = node.height / 2;
|
|
703
|
+
const facingRight = neighbor.x > port.x;
|
|
704
|
+
const facingDown = neighbor.y > port.y;
|
|
705
|
+
const isHoriz = Math.abs(port.y - neighbor.y) <= Math.abs(port.x - neighbor.x);
|
|
701
706
|
if (node.shape === "diamond") {
|
|
702
|
-
const isVert = Math.abs(port.x - neighbor.x) < 0.01;
|
|
703
|
-
const isHoriz = Math.abs(port.y - neighbor.y) < 0.01;
|
|
704
|
-
if (isVert) {
|
|
705
|
-
const goingDown = isSource ? neighbor.y > port.y : port.y > neighbor.y;
|
|
706
|
-
const boundaryY = goingDown ? cy + hh * (1 - Math.min(1, Math.abs(port.x - cx) / hw)) : cy - hh * (1 - Math.min(1, Math.abs(port.x - cx) / hw));
|
|
707
|
-
return { x: port.x, y: Math.round(boundaryY * 10) / 10 };
|
|
708
|
-
}
|
|
709
707
|
if (isHoriz) {
|
|
710
|
-
const
|
|
711
|
-
const boundaryX = goingRight ? cx + hw * (1 - Math.min(1, Math.abs(port.y - cy) / hh)) : cx - hw * (1 - Math.min(1, Math.abs(port.y - cy) / hh));
|
|
708
|
+
const boundaryX = facingRight ? cx + hw * (1 - Math.min(1, Math.abs(port.y - cy) / hh)) : cx - hw * (1 - Math.min(1, Math.abs(port.y - cy) / hh));
|
|
712
709
|
return { x: Math.round(boundaryX * 10) / 10, y: port.y };
|
|
710
|
+
} else {
|
|
711
|
+
const boundaryY = facingDown ? cy + hh * (1 - Math.min(1, Math.abs(port.x - cx) / hw)) : cy - hh * (1 - Math.min(1, Math.abs(port.x - cx) / hw));
|
|
712
|
+
return { x: port.x, y: Math.round(boundaryY * 10) / 10 };
|
|
713
713
|
}
|
|
714
714
|
}
|
|
715
715
|
if (node.shape === "circle") {
|
|
716
716
|
const r = Math.min(node.width, node.height) / 2;
|
|
717
|
-
const isVert = Math.abs(port.x - neighbor.x) < 0.01;
|
|
718
|
-
const isHoriz = Math.abs(port.y - neighbor.y) < 0.01;
|
|
719
|
-
if (isVert) {
|
|
720
|
-
const goingDown = isSource ? neighbor.y > port.y : port.y > neighbor.y;
|
|
721
|
-
return { x: cx, y: goingDown ? cy + r : cy - r };
|
|
722
|
-
}
|
|
723
717
|
if (isHoriz) {
|
|
724
|
-
const
|
|
725
|
-
|
|
718
|
+
const dy = Math.abs(port.y - cy);
|
|
719
|
+
const dx = dy <= r ? Math.sqrt(Math.max(0, r * r - dy * dy)) : 0;
|
|
720
|
+
return { x: Math.round((facingRight ? cx + dx : cx - dx) * 10) / 10, y: port.y };
|
|
721
|
+
} else {
|
|
722
|
+
const dx = Math.abs(port.x - cx);
|
|
723
|
+
const dy = dx <= r ? Math.sqrt(Math.max(0, r * r - dx * dx)) : 0;
|
|
724
|
+
return { x: port.x, y: Math.round((facingDown ? cy + dy : cy - dy) * 10) / 10 };
|
|
726
725
|
}
|
|
727
726
|
}
|
|
728
727
|
if (node.shape === "pill") {
|
|
729
728
|
const r = node.height / 2;
|
|
730
|
-
const isVert = Math.abs(port.x - neighbor.x) < 0.01;
|
|
731
|
-
const isHoriz = Math.abs(port.y - neighbor.y) < 0.01;
|
|
732
729
|
if (isHoriz) {
|
|
733
|
-
const
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
730
|
+
const dy = Math.abs(port.y - cy);
|
|
731
|
+
const dx = dy <= r ? Math.sqrt(Math.max(0, r * r - dy * dy)) : 0;
|
|
732
|
+
const boundaryX = facingRight ? node.x + node.width - r + dx : node.x + r - dx;
|
|
733
|
+
return { x: Math.round(boundaryX * 10) / 10, y: port.y };
|
|
734
|
+
} else {
|
|
738
735
|
const clampedX = Math.max(node.x + r, Math.min(node.x + node.width - r, port.x));
|
|
739
|
-
return { x: clampedX, y:
|
|
736
|
+
return { x: clampedX, y: facingDown ? node.y + node.height : node.y };
|
|
740
737
|
}
|
|
741
738
|
}
|
|
742
739
|
return port;
|
|
@@ -1167,9 +1164,6 @@ function computeFrameTransform(targetIds, nodes, bounds, requestedZoom = DEFAULT
|
|
|
1167
1164
|
const targets = new Set(targetIds);
|
|
1168
1165
|
const selected = nodes.filter((node) => targets.has(node.id));
|
|
1169
1166
|
if (selected.length === 0) return void 0;
|
|
1170
|
-
const framesEveryNode = selected.length === nodes.length && nodes.every((node) => targets.has(node.id));
|
|
1171
|
-
if (framesEveryNode) return INITIAL_CAMERA_TRANSFORM;
|
|
1172
|
-
const zoom = Number.isFinite(requestedZoom) && requestedZoom > 0 ? requestedZoom : DEFAULT_FRAME_ZOOM;
|
|
1173
1167
|
const minX = Math.min(...selected.map((node) => node.x));
|
|
1174
1168
|
const minY = Math.min(...selected.map((node) => node.y));
|
|
1175
1169
|
const maxX = Math.max(...selected.map((node) => node.x + node.width));
|
|
@@ -1177,6 +1171,19 @@ function computeFrameTransform(targetIds, nodes, bounds, requestedZoom = DEFAULT
|
|
|
1177
1171
|
const frameWidth = Math.max(1, maxX - minX + FRAME_PADDING * 2);
|
|
1178
1172
|
const frameHeight = Math.max(1, maxY - minY + FRAME_PADDING * 2);
|
|
1179
1173
|
const fitScale = Math.min(bounds.width / frameWidth, bounds.height / frameHeight);
|
|
1174
|
+
const framesEveryNode = selected.length === nodes.length && nodes.every((node) => targets.has(node.id));
|
|
1175
|
+
if (framesEveryNode) {
|
|
1176
|
+
if (fitScale >= 1 && minX >= 0 && maxX <= bounds.width && minY >= 0 && maxY <= bounds.height) {
|
|
1177
|
+
return INITIAL_CAMERA_TRANSFORM;
|
|
1178
|
+
}
|
|
1179
|
+
const scale2 = Math.min(1, Math.max(0.4, fitScale));
|
|
1180
|
+
const centerX2 = (minX + maxX) / 2;
|
|
1181
|
+
const centerY2 = (minY + maxY) / 2;
|
|
1182
|
+
const tx2 = Math.round((bounds.width / 2 - centerX2 * scale2) * 10) / 10;
|
|
1183
|
+
const ty2 = Math.round((bounds.height / 2 - centerY2 * scale2) * 10) / 10;
|
|
1184
|
+
return `translate(${tx2}px, ${ty2}px) scale(${Math.round(scale2 * 1e3) / 1e3})`;
|
|
1185
|
+
}
|
|
1186
|
+
const zoom = Number.isFinite(requestedZoom) && requestedZoom > 0 ? requestedZoom : DEFAULT_FRAME_ZOOM;
|
|
1180
1187
|
const scale = Math.max(1, Math.min(zoom, fitScale, MAX_FRAME_ZOOM));
|
|
1181
1188
|
const centerX = (minX + maxX) / 2;
|
|
1182
1189
|
const centerY = (minY + maxY) / 2;
|
|
@@ -2122,7 +2129,7 @@ function ensureNodeStyles(doc) {
|
|
|
2122
2129
|
inset 0 0 0 1px var(--md-hairline, color-mix(in srgb, var(--md-border) 50%, transparent)),
|
|
2123
2130
|
inset 0 1px 0 rgba(255, 255, 255, 0.12);
|
|
2124
2131
|
font-family: var(--md-font-node, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif);
|
|
2125
|
-
overflow:
|
|
2132
|
+
overflow: visible;
|
|
2126
2133
|
opacity: 0;
|
|
2127
2134
|
transform: translateY(8px);
|
|
2128
2135
|
transition: box-shadow 0.25s ease, transform 0.25s ease;
|
|
@@ -2157,21 +2164,26 @@ function ensureNodeStyles(doc) {
|
|
|
2157
2164
|
box-sizing: border-box;
|
|
2158
2165
|
}
|
|
2159
2166
|
.markdy-node__icon {
|
|
2160
|
-
flex: 0 0
|
|
2167
|
+
flex: 0 0 28px;
|
|
2161
2168
|
width: 28px;
|
|
2162
2169
|
height: 28px;
|
|
2163
|
-
|
|
2170
|
+
border-radius: 7px;
|
|
2171
|
+
display: inline-flex;
|
|
2164
2172
|
align-items: center;
|
|
2165
2173
|
justify-content: center;
|
|
2174
|
+
background: color-mix(in srgb, var(--md-role-color, var(--md-accent)) 14%, transparent);
|
|
2166
2175
|
color: var(--md-role-color, var(--md-accent));
|
|
2167
|
-
|
|
2168
|
-
|
|
2176
|
+
box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--md-role-color, var(--md-accent)) 35%, transparent);
|
|
2177
|
+
transition: transform 0.2s ease;
|
|
2169
2178
|
}
|
|
2170
2179
|
.markdy-node__icon svg {
|
|
2171
|
-
width:
|
|
2172
|
-
height:
|
|
2173
|
-
display: block;
|
|
2180
|
+
width: 18px;
|
|
2181
|
+
height: 18px;
|
|
2174
2182
|
stroke: currentColor;
|
|
2183
|
+
stroke-width: 1.8;
|
|
2184
|
+
fill: none;
|
|
2185
|
+
stroke-linecap: round;
|
|
2186
|
+
stroke-linejoin: round;
|
|
2175
2187
|
}
|
|
2176
2188
|
.markdy-node__icon[data-media="image"] {
|
|
2177
2189
|
background: transparent;
|
|
@@ -2206,14 +2218,10 @@ function ensureNodeStyles(doc) {
|
|
|
2206
2218
|
letter-spacing: -0.01em;
|
|
2207
2219
|
line-height: 1.24;
|
|
2208
2220
|
color: var(--md-text);
|
|
2209
|
-
display: -webkit-box;
|
|
2210
|
-
-webkit-box-orient: vertical;
|
|
2211
|
-
-webkit-line-clamp: 2;
|
|
2212
|
-
line-clamp: 2;
|
|
2213
|
-
overflow: hidden;
|
|
2214
2221
|
overflow-wrap: anywhere;
|
|
2215
2222
|
word-break: break-word;
|
|
2216
2223
|
text-wrap: pretty;
|
|
2224
|
+
white-space: pre-line;
|
|
2217
2225
|
}
|
|
2218
2226
|
.markdy-node__tech {
|
|
2219
2227
|
align-self: flex-start;
|
|
@@ -2228,9 +2236,8 @@ function ensureNodeStyles(doc) {
|
|
|
2228
2236
|
border-radius: 4px;
|
|
2229
2237
|
letter-spacing: 0.01em;
|
|
2230
2238
|
white-space: nowrap;
|
|
2231
|
-
overflow: hidden;
|
|
2232
|
-
text-overflow: ellipsis;
|
|
2233
2239
|
max-width: 100%;
|
|
2240
|
+
box-sizing: border-box;
|
|
2234
2241
|
}
|
|
2235
2242
|
.markdy-node__value {
|
|
2236
2243
|
flex: 0 0 auto;
|
|
@@ -2292,31 +2299,97 @@ function ensureNodeStyles(doc) {
|
|
|
2292
2299
|
.markdy-scene-root[data-markdy-theme="nebula"] .markdy-node[data-shape="diamond"][data-focal="1"] {
|
|
2293
2300
|
border: none;
|
|
2294
2301
|
box-shadow: none;
|
|
2302
|
+
background: transparent;
|
|
2295
2303
|
}
|
|
2296
2304
|
.markdy-node[data-shape="diamond"] {
|
|
2297
2305
|
border-radius: 0;
|
|
2298
2306
|
transform: rotate(0deg);
|
|
2299
|
-
clip-path:
|
|
2300
|
-
|
|
2307
|
+
clip-path: none;
|
|
2308
|
+
background: transparent;
|
|
2309
|
+
overflow: visible;
|
|
2310
|
+
}
|
|
2311
|
+
.markdy-node[data-shape="diamond"] .markdy-node__shape-svg {
|
|
2312
|
+
position: absolute;
|
|
2313
|
+
inset: 0;
|
|
2314
|
+
width: 100%;
|
|
2315
|
+
height: 100%;
|
|
2316
|
+
pointer-events: none;
|
|
2317
|
+
overflow: visible;
|
|
2318
|
+
filter: drop-shadow(0 4px 16px var(--md-shadow, rgba(2, 6, 23, 0.28)));
|
|
2319
|
+
}
|
|
2320
|
+
.markdy-node[data-shape="diamond"] .markdy-node__diamond-polygon {
|
|
2321
|
+
fill: var(--md-node-surface, var(--md-surface));
|
|
2322
|
+
stroke: var(--md-hairline, rgba(255, 255, 255, 0.18));
|
|
2323
|
+
stroke-width: 1.5;
|
|
2324
|
+
stroke-linejoin: round;
|
|
2325
|
+
transition: stroke 0.2s ease, fill 0.2s ease, filter 0.2s ease;
|
|
2326
|
+
}
|
|
2327
|
+
.markdy-node[data-shape="diamond"] .markdy-node__diamond-facet {
|
|
2328
|
+
fill: none;
|
|
2329
|
+
stroke: rgba(255, 255, 255, 0.08);
|
|
2330
|
+
stroke-width: 1;
|
|
2331
|
+
stroke-linejoin: round;
|
|
2332
|
+
pointer-events: none;
|
|
2301
2333
|
}
|
|
2302
|
-
.markdy-node[data-shape="diamond"][data-focal="1"]
|
|
2303
|
-
|
|
2334
|
+
.markdy-node[data-shape="diamond"][data-focal="1"] .markdy-node__diamond-polygon,
|
|
2335
|
+
.markdy-node[data-shape="diamond"][data-focused="1"] .markdy-node__diamond-polygon {
|
|
2336
|
+
stroke: var(--md-accent);
|
|
2337
|
+
stroke-width: 2;
|
|
2338
|
+
filter: drop-shadow(0 0 6px var(--md-accent));
|
|
2304
2339
|
}
|
|
2305
|
-
.markdy-node[data-shape="diamond"][data-
|
|
2306
|
-
|
|
2340
|
+
.markdy-node[data-shape="diamond"][data-glow="1"] .markdy-node__diamond-polygon {
|
|
2341
|
+
stroke: var(--md-glow-color, var(--md-accent));
|
|
2342
|
+
stroke-width: 2.2;
|
|
2343
|
+
filter: drop-shadow(0 0 10px var(--md-glow-color, var(--md-accent)));
|
|
2307
2344
|
}
|
|
2308
|
-
.markdy-node[data-shape="diamond"]
|
|
2309
|
-
|
|
2345
|
+
.markdy-node[data-shape="diamond"]:hover .markdy-node__diamond-polygon {
|
|
2346
|
+
stroke: var(--md-role-color, var(--md-accent));
|
|
2347
|
+
filter: drop-shadow(0 0 8px color-mix(in srgb, var(--md-role-color, var(--md-accent)) 60%, transparent));
|
|
2310
2348
|
}
|
|
2311
2349
|
.markdy-node[data-shape="diamond"] .markdy-node__body {
|
|
2350
|
+
flex-direction: column;
|
|
2351
|
+
align-items: center;
|
|
2312
2352
|
justify-content: center;
|
|
2313
|
-
padding:
|
|
2353
|
+
padding: 8px 14%;
|
|
2314
2354
|
text-align: center;
|
|
2355
|
+
gap: 3px;
|
|
2356
|
+
position: relative;
|
|
2357
|
+
z-index: 2;
|
|
2358
|
+
}
|
|
2359
|
+
.markdy-node[data-shape="diamond"] .markdy-node__icon {
|
|
2360
|
+
width: 20px;
|
|
2361
|
+
height: 20px;
|
|
2362
|
+
margin-bottom: 2px;
|
|
2363
|
+
display: flex;
|
|
2364
|
+
align-items: center;
|
|
2365
|
+
justify-content: center;
|
|
2366
|
+
color: var(--md-role-color, var(--md-accent));
|
|
2367
|
+
opacity: 0.95;
|
|
2368
|
+
filter: drop-shadow(0 0 4px color-mix(in srgb, var(--md-role-color, var(--md-accent)) 40%, transparent));
|
|
2369
|
+
}
|
|
2370
|
+
.markdy-node[data-shape="diamond"] .markdy-node__icon svg {
|
|
2371
|
+
width: 18px;
|
|
2372
|
+
height: 18px;
|
|
2373
|
+
}
|
|
2374
|
+
.markdy-node[data-shape="diamond"] .markdy-node__content {
|
|
2375
|
+
display: flex;
|
|
2376
|
+
flex-direction: column;
|
|
2377
|
+
align-items: center;
|
|
2378
|
+
justify-content: center;
|
|
2315
2379
|
}
|
|
2316
2380
|
.markdy-node[data-shape="diamond"] .markdy-node__label {
|
|
2317
2381
|
flex: 0 1 auto;
|
|
2318
|
-
|
|
2382
|
+
font-size: 12px;
|
|
2383
|
+
font-weight: 600;
|
|
2384
|
+
line-height: 1.25;
|
|
2319
2385
|
text-align: center;
|
|
2386
|
+
color: var(--md-text);
|
|
2387
|
+
}
|
|
2388
|
+
.markdy-node[data-shape="diamond"] .markdy-node__tech {
|
|
2389
|
+
align-self: center;
|
|
2390
|
+
font-size: 9px;
|
|
2391
|
+
padding: 1px 5px;
|
|
2392
|
+
margin-top: 2px;
|
|
2320
2393
|
}
|
|
2321
2394
|
.markdy-node[data-shape="pill"] {
|
|
2322
2395
|
border-radius: 999px;
|
|
@@ -2353,8 +2426,6 @@ function ensureNodeStyles(doc) {
|
|
|
2353
2426
|
}
|
|
2354
2427
|
.markdy-node[data-shape="circle"] .markdy-node__label {
|
|
2355
2428
|
text-align: center;
|
|
2356
|
-
-webkit-line-clamp: 4;
|
|
2357
|
-
line-clamp: 4;
|
|
2358
2429
|
}
|
|
2359
2430
|
.markdy-node[data-kind="dot"] {
|
|
2360
2431
|
width: 64px;
|
|
@@ -2909,9 +2980,26 @@ function createNodeEl(node, theme, assets) {
|
|
|
2909
2980
|
if (node.shape === "container") el.dataset.isContainer = "1";
|
|
2910
2981
|
el.title = `${node.label} (${typeText})`;
|
|
2911
2982
|
el.setAttribute("aria-label", el.title);
|
|
2983
|
+
if (node.shape === "diamond") {
|
|
2984
|
+
const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
2985
|
+
svg.setAttribute("class", "markdy-node__shape-svg");
|
|
2986
|
+
svg.setAttribute("viewBox", `0 0 ${node.width} ${node.height}`);
|
|
2987
|
+
svg.setAttribute("aria-hidden", "true");
|
|
2988
|
+
const hw = node.width / 2;
|
|
2989
|
+
const hh = node.height / 2;
|
|
2990
|
+
const bg = document.createElementNS("http://www.w3.org/2000/svg", "polygon");
|
|
2991
|
+
bg.setAttribute("points", `${hw},1.5 ${node.width - 1.5},${hh} ${hw},${node.height - 1.5} 1.5,${hh}`);
|
|
2992
|
+
bg.setAttribute("class", "markdy-node__diamond-polygon");
|
|
2993
|
+
svg.appendChild(bg);
|
|
2994
|
+
const facet = document.createElementNS("http://www.w3.org/2000/svg", "polygon");
|
|
2995
|
+
facet.setAttribute("points", `${hw},4 ${node.width - 4},${hh} ${hw},${node.height - 4} 4,${hh}`);
|
|
2996
|
+
facet.setAttribute("class", "markdy-node__diamond-facet");
|
|
2997
|
+
svg.appendChild(facet);
|
|
2998
|
+
el.prepend(svg);
|
|
2999
|
+
}
|
|
2912
3000
|
const body = document.createElement("div");
|
|
2913
3001
|
body.className = "markdy-node__body";
|
|
2914
|
-
|
|
3002
|
+
body.append(createNodeMediaEl(document, node, assets));
|
|
2915
3003
|
const content = document.createElement("div");
|
|
2916
3004
|
content.className = "markdy-node__content";
|
|
2917
3005
|
const label = document.createElement("div");
|
|
@@ -4172,7 +4260,7 @@ function circleBoundaryRoute2(from, to) {
|
|
|
4172
4260
|
{ x: toCenter.x - ux * toRadius, y: toCenter.y - uy * toRadius }
|
|
4173
4261
|
]);
|
|
4174
4262
|
}
|
|
4175
|
-
function snapPortToNodeShape2(node, port, neighbor,
|
|
4263
|
+
function snapPortToNodeShape2(node, port, neighbor, _isSource) {
|
|
4176
4264
|
if (!node.shape || node.shape === "card" || node.shape === "rounded" || node.shape === "terminal" || node.shape === "container") {
|
|
4177
4265
|
return port;
|
|
4178
4266
|
}
|
|
@@ -4180,45 +4268,40 @@ function snapPortToNodeShape2(node, port, neighbor, isSource) {
|
|
|
4180
4268
|
const cy = node.y + node.height / 2;
|
|
4181
4269
|
const hw = node.width / 2;
|
|
4182
4270
|
const hh = node.height / 2;
|
|
4271
|
+
const facingRight = neighbor.x > port.x;
|
|
4272
|
+
const facingDown = neighbor.y > port.y;
|
|
4273
|
+
const isHoriz = Math.abs(port.y - neighbor.y) <= Math.abs(port.x - neighbor.x);
|
|
4183
4274
|
if (node.shape === "diamond") {
|
|
4184
|
-
const isVert = Math.abs(port.x - neighbor.x) < 0.01;
|
|
4185
|
-
const isHoriz = Math.abs(port.y - neighbor.y) < 0.01;
|
|
4186
|
-
if (isVert) {
|
|
4187
|
-
const goingDown = isSource ? neighbor.y > port.y : port.y > neighbor.y;
|
|
4188
|
-
const boundaryY = goingDown ? cy + hh * (1 - Math.min(1, Math.abs(port.x - cx) / hw)) : cy - hh * (1 - Math.min(1, Math.abs(port.x - cx) / hw));
|
|
4189
|
-
return { x: port.x, y: Math.round(boundaryY * 10) / 10 };
|
|
4190
|
-
}
|
|
4191
4275
|
if (isHoriz) {
|
|
4192
|
-
const
|
|
4193
|
-
const boundaryX = goingRight ? cx + hw * (1 - Math.min(1, Math.abs(port.y - cy) / hh)) : cx - hw * (1 - Math.min(1, Math.abs(port.y - cy) / hh));
|
|
4276
|
+
const boundaryX = facingRight ? cx + hw * (1 - Math.min(1, Math.abs(port.y - cy) / hh)) : cx - hw * (1 - Math.min(1, Math.abs(port.y - cy) / hh));
|
|
4194
4277
|
return { x: Math.round(boundaryX * 10) / 10, y: port.y };
|
|
4278
|
+
} else {
|
|
4279
|
+
const boundaryY = facingDown ? cy + hh * (1 - Math.min(1, Math.abs(port.x - cx) / hw)) : cy - hh * (1 - Math.min(1, Math.abs(port.x - cx) / hw));
|
|
4280
|
+
return { x: port.x, y: Math.round(boundaryY * 10) / 10 };
|
|
4195
4281
|
}
|
|
4196
4282
|
}
|
|
4197
4283
|
if (node.shape === "circle") {
|
|
4198
4284
|
const r = Math.min(node.width, node.height) / 2;
|
|
4199
|
-
const isVert = Math.abs(port.x - neighbor.x) < 0.01;
|
|
4200
|
-
const isHoriz = Math.abs(port.y - neighbor.y) < 0.01;
|
|
4201
|
-
if (isVert) {
|
|
4202
|
-
const goingDown = isSource ? neighbor.y > port.y : port.y > neighbor.y;
|
|
4203
|
-
return { x: cx, y: goingDown ? cy + r : cy - r };
|
|
4204
|
-
}
|
|
4205
4285
|
if (isHoriz) {
|
|
4206
|
-
const
|
|
4207
|
-
|
|
4286
|
+
const dy = Math.abs(port.y - cy);
|
|
4287
|
+
const dx = dy <= r ? Math.sqrt(Math.max(0, r * r - dy * dy)) : 0;
|
|
4288
|
+
return { x: Math.round((facingRight ? cx + dx : cx - dx) * 10) / 10, y: port.y };
|
|
4289
|
+
} else {
|
|
4290
|
+
const dx = Math.abs(port.x - cx);
|
|
4291
|
+
const dy = dx <= r ? Math.sqrt(Math.max(0, r * r - dx * dx)) : 0;
|
|
4292
|
+
return { x: port.x, y: Math.round((facingDown ? cy + dy : cy - dy) * 10) / 10 };
|
|
4208
4293
|
}
|
|
4209
4294
|
}
|
|
4210
4295
|
if (node.shape === "pill") {
|
|
4211
4296
|
const r = node.height / 2;
|
|
4212
|
-
const isVert = Math.abs(port.x - neighbor.x) < 0.01;
|
|
4213
|
-
const isHoriz = Math.abs(port.y - neighbor.y) < 0.01;
|
|
4214
4297
|
if (isHoriz) {
|
|
4215
|
-
const
|
|
4216
|
-
|
|
4217
|
-
|
|
4218
|
-
|
|
4219
|
-
|
|
4298
|
+
const dy = Math.abs(port.y - cy);
|
|
4299
|
+
const dx = dy <= r ? Math.sqrt(Math.max(0, r * r - dy * dy)) : 0;
|
|
4300
|
+
const boundaryX = facingRight ? node.x + node.width - r + dx : node.x + r - dx;
|
|
4301
|
+
return { x: Math.round(boundaryX * 10) / 10, y: port.y };
|
|
4302
|
+
} else {
|
|
4220
4303
|
const clampedX = Math.max(node.x + r, Math.min(node.x + node.width - r, port.x));
|
|
4221
|
-
return { x: clampedX, y:
|
|
4304
|
+
return { x: clampedX, y: facingDown ? node.y + node.height : node.y };
|
|
4222
4305
|
}
|
|
4223
4306
|
}
|
|
4224
4307
|
return port;
|
|
@@ -4276,10 +4359,9 @@ function wrapNodeLabel(label, maxWidthPx, fontSize = 13.5) {
|
|
|
4276
4359
|
} else {
|
|
4277
4360
|
lines.push(current);
|
|
4278
4361
|
current = word;
|
|
4279
|
-
if (lines.length === 2) break;
|
|
4280
4362
|
}
|
|
4281
4363
|
}
|
|
4282
|
-
if (current
|
|
4364
|
+
if (current) {
|
|
4283
4365
|
lines.push(current);
|
|
4284
4366
|
}
|
|
4285
4367
|
return lines;
|
|
@@ -4565,7 +4647,8 @@ function renderPureVectorSvg(plan, options = {}) {
|
|
|
4565
4647
|
if (isDiamond) {
|
|
4566
4648
|
const hw = node.width / 2;
|
|
4567
4649
|
const hh = node.height / 2;
|
|
4568
|
-
svg += ` <polygon points="${hw},
|
|
4650
|
+
svg += ` <polygon points="${hw},1.5 ${node.width - 1.5},${hh} ${hw},${node.height - 1.5} 1.5,${hh}" fill="${surface}" stroke="${border}" stroke-width="1.5" stroke-linejoin="round" filter="url(#markdy-node-shadow)"/>
|
|
4651
|
+
<polygon points="${hw},3.5 ${node.width - 3.5},${hh} ${hw},${node.height - 3.5} 3.5,${hh}" fill="none" stroke="rgba(255,255,255,0.1)" stroke-width="1" stroke-linejoin="round"/>
|
|
4569
4652
|
`;
|
|
4570
4653
|
} else if (isCircle) {
|
|
4571
4654
|
const r = Math.min(node.width, node.height) / 2;
|
|
@@ -4587,37 +4670,54 @@ function renderPureVectorSvg(plan, options = {}) {
|
|
|
4587
4670
|
const valWidth = valText ? valText.length * 9.5 + 16 : 0;
|
|
4588
4671
|
const iconSize = 26;
|
|
4589
4672
|
if (isDiamond) {
|
|
4590
|
-
const availTextWidth = Math.max(40, node.width * 0.65);
|
|
4591
|
-
const lines = wrapNodeLabel(node.label, availTextWidth, 12.5);
|
|
4592
4673
|
const centerX = node.width / 2;
|
|
4593
|
-
|
|
4594
|
-
|
|
4595
|
-
|
|
4596
|
-
|
|
4674
|
+
const availTextWidth = Math.max(40, node.width * 0.62);
|
|
4675
|
+
const lines = wrapNodeLabel(node.label, availTextWidth, 12);
|
|
4676
|
+
const diamondIconSize = 18;
|
|
4677
|
+
const iconX = (node.width - diamondIconSize) / 2;
|
|
4678
|
+
const iconY = node.height / 2 - (hasTech ? 26 : lines.length > 1 ? 22 : 18);
|
|
4679
|
+
const symbolKey = typeof node.props?.icon === "string" ? node.props.icon : typeof node.props?.symbol === "string" ? node.props.symbol : void 0;
|
|
4680
|
+
const vectorSymbol = symbolKey ? resolveVectorSymbol2(symbolKey) : null;
|
|
4681
|
+
const rawImage = node.props?.image ?? node.props?.logo;
|
|
4682
|
+
if (typeof rawImage === "string" && rawImage.length > 0) {
|
|
4683
|
+
svg += ` <image href="${escapeXml(rawImage)}" x="${iconX}" y="${iconY}" width="${diamondIconSize}" height="${diamondIconSize}" preserveAspectRatio="xMidYMid meet"/>
|
|
4597
4684
|
`;
|
|
4598
|
-
|
|
4599
|
-
|
|
4600
|
-
|
|
4601
|
-
|
|
4685
|
+
} else if (vectorSymbol) {
|
|
4686
|
+
const symColor = vectorSymbol.brandColor || roleColor;
|
|
4687
|
+
svg += ` <g transform="translate(${iconX}, ${iconY}) scale(${diamondIconSize / 24})" fill="currentColor" color="${symColor}">
|
|
4688
|
+
${vectorSymbol.svgPaths}
|
|
4689
|
+
</g>
|
|
4602
4690
|
`;
|
|
4603
|
-
|
|
4691
|
+
} else {
|
|
4692
|
+
svg += ` <g transform="translate(${iconX}, ${iconY}) scale(${diamondIconSize / 24})" fill="none" stroke="${roleColor}" stroke-width="1.85" stroke-linecap="round" stroke-linejoin="round">
|
|
4693
|
+
`;
|
|
4694
|
+
if (glyphSpec) {
|
|
4695
|
+
for (const [tag, attrs] of glyphSpec) {
|
|
4696
|
+
const attrStr = Object.entries(attrs).map(([k, v]) => `${k}="${escapeXml(v)}"`).join(" ");
|
|
4697
|
+
svg += ` <${tag} ${attrStr} />
|
|
4698
|
+
`;
|
|
4699
|
+
}
|
|
4604
4700
|
}
|
|
4605
|
-
|
|
4606
|
-
|
|
4607
|
-
|
|
4608
|
-
|
|
4701
|
+
svg += ` </g>
|
|
4702
|
+
`;
|
|
4703
|
+
}
|
|
4704
|
+
const textCenterY = node.height / 2 + (hasTech ? 4 : lines.length > 1 ? 8 : 7);
|
|
4705
|
+
if (lines.length === 1) {
|
|
4706
|
+
svg += ` <text x="${centerX}" y="${textCenterY}" class="markdy-svg-text" font-size="12" font-weight="600" fill="${textColor}" text-anchor="middle" dominant-baseline="central">${escapeXml(lines[0])}</text>
|
|
4609
4707
|
`;
|
|
4610
4708
|
} else {
|
|
4611
|
-
|
|
4612
|
-
|
|
4709
|
+
const startY = textCenterY - (lines.length - 1) * 14 / 2;
|
|
4710
|
+
lines.forEach((l, idx) => {
|
|
4711
|
+
svg += ` <text x="${centerX}" y="${startY + idx * 14}" class="markdy-svg-text" font-size="12" font-weight="600" fill="${textColor}" text-anchor="middle" dominant-baseline="central">${escapeXml(l)}</text>
|
|
4613
4712
|
`;
|
|
4614
|
-
}
|
|
4615
|
-
|
|
4616
|
-
|
|
4617
|
-
|
|
4713
|
+
});
|
|
4714
|
+
}
|
|
4715
|
+
if (hasTech) {
|
|
4716
|
+
const techBadgeW = Math.min(availTextWidth, techText.length * 6 + 10);
|
|
4717
|
+
const techBadgeY = textCenterY + lines.length * 7 + 6;
|
|
4718
|
+
svg += ` <rect x="${centerX - techBadgeW / 2}" y="${techBadgeY}" width="${techBadgeW}" height="14" rx="3" fill="${textColor}" fill-opacity="${isDark ? "0.08" : "0.05"}" stroke="${border}" stroke-width="0.75"/>
|
|
4719
|
+
<text x="${centerX}" y="${techBadgeY + 7}" class="markdy-svg-mono" font-size="8.5" font-weight="500" fill="${textMuted}" text-anchor="middle" dominant-baseline="central">${escapeXml(techText)}</text>
|
|
4618
4720
|
`;
|
|
4619
|
-
});
|
|
4620
|
-
}
|
|
4621
4721
|
}
|
|
4622
4722
|
} else if (isCircle) {
|
|
4623
4723
|
const centerX = node.width / 2;
|
|
@@ -4700,25 +4800,27 @@ function renderPureVectorSvg(plan, options = {}) {
|
|
|
4700
4800
|
const availTextWidth = node.width - textStartX - (valWidth > 0 ? valWidth + 14 : 14);
|
|
4701
4801
|
const lines = wrapNodeLabel(node.label, availTextWidth, 13.5);
|
|
4702
4802
|
if (hasTech) {
|
|
4703
|
-
const
|
|
4803
|
+
const lineHeight = 14;
|
|
4804
|
+
const totalTextH = (lines.length - 1) * lineHeight;
|
|
4805
|
+
const totalContentH = totalTextH + 26;
|
|
4806
|
+
const startY = Math.round(node.height / 2 - totalContentH / 2 + 6);
|
|
4704
4807
|
if (lines.length === 1) {
|
|
4705
4808
|
svg += ` <!-- Label -->
|
|
4706
|
-
<text x="${textStartX}" y="${
|
|
4809
|
+
<text x="${textStartX}" y="${startY}" class="markdy-svg-text" font-size="13" font-weight="600" letter-spacing="-0.01em" fill="${textColor}" dominant-baseline="central">${escapeXml(lines[0])}</text>
|
|
4707
4810
|
`;
|
|
4708
4811
|
} else {
|
|
4709
|
-
const startY = Math.round(labelCenterY - (lines.length - 1) * 14 / 2);
|
|
4710
4812
|
svg += ` <!-- Label -->
|
|
4711
4813
|
<text class="markdy-svg-text" font-size="12.5" font-weight="600" letter-spacing="-0.01em" fill="${textColor}">
|
|
4712
4814
|
`;
|
|
4713
4815
|
lines.forEach((l, idx) => {
|
|
4714
|
-
svg += ` <tspan x="${textStartX}" y="${startY + idx *
|
|
4816
|
+
svg += ` <tspan x="${textStartX}" y="${startY + idx * lineHeight}" dominant-baseline="central">${escapeXml(l)}</tspan>
|
|
4715
4817
|
`;
|
|
4716
4818
|
});
|
|
4717
4819
|
svg += ` </text>
|
|
4718
4820
|
`;
|
|
4719
4821
|
}
|
|
4720
4822
|
const techBadgeW = Math.min(availTextWidth, techText.length * 6.2 + 12);
|
|
4721
|
-
const techBadgeY =
|
|
4823
|
+
const techBadgeY = startY + (lines.length - 1) * lineHeight + 12;
|
|
4722
4824
|
svg += ` <!-- Tech Badge -->
|
|
4723
4825
|
<rect x="${textStartX}" y="${techBadgeY}" width="${techBadgeW}" height="16" rx="4" fill="${textColor}" fill-opacity="${isDark ? "0.08" : "0.05"}" stroke="${border}" stroke-width="0.75"/>
|
|
4724
4826
|
<text x="${textStartX + 6}" y="${techBadgeY + 8}" class="markdy-svg-mono" font-size="9.5" font-weight="500" fill="${textMuted}" dominant-baseline="central">${escapeXml(techText)}</text>
|
|
@@ -4727,20 +4829,17 @@ function renderPureVectorSvg(plan, options = {}) {
|
|
|
4727
4829
|
if (lines.length === 1) {
|
|
4728
4830
|
svg += ` <!-- Label -->
|
|
4729
4831
|
<text x="${textStartX}" y="${Math.round(node.height / 2)}" class="markdy-svg-text" font-size="13.5" font-weight="600" letter-spacing="-0.01em" fill="${textColor}" dominant-baseline="central">${escapeXml(lines[0])}</text>
|
|
4730
|
-
`;
|
|
4731
|
-
} else if (lines.length === 2) {
|
|
4732
|
-
const startY = Math.round(node.height / 2 - 8);
|
|
4733
|
-
svg += ` <!-- Label -->
|
|
4734
|
-
<text x="${textStartX}" y="${startY}" class="markdy-svg-text" font-size="13.5" font-weight="600" letter-spacing="-0.01em" fill="${textColor}" dominant-baseline="central">${escapeXml(lines[0])}</text>
|
|
4735
|
-
<text x="${textStartX}" y="${startY + 16}" class="markdy-svg-text" font-size="13.5" font-weight="600" letter-spacing="-0.01em" fill="${textColor}" dominant-baseline="central">${escapeXml(lines[1])}</text>
|
|
4736
4832
|
`;
|
|
4737
4833
|
} else {
|
|
4738
|
-
const
|
|
4834
|
+
const lineHeight = 16;
|
|
4835
|
+
const totalTextH = (lines.length - 1) * lineHeight;
|
|
4836
|
+
const startY = Math.round(node.height / 2 - totalTextH / 2);
|
|
4739
4837
|
svg += ` <!-- Label -->
|
|
4740
|
-
<text x="${textStartX}" y="${startY}" class="markdy-svg-text" font-size="13.5" font-weight="600" letter-spacing="-0.01em" fill="${textColor}" dominant-baseline="central">${escapeXml(lines[0])}</text>
|
|
4741
|
-
<text x="${textStartX}" y="${startY + 15}" class="markdy-svg-text" font-size="13.5" font-weight="600" letter-spacing="-0.01em" fill="${textColor}" dominant-baseline="central">${escapeXml(lines[1])}</text>
|
|
4742
|
-
<text x="${textStartX}" y="${startY + 30}" class="markdy-svg-text" font-size="13.5" font-weight="600" letter-spacing="-0.01em" fill="${textColor}" dominant-baseline="central">${escapeXml(lines[2])}</text>
|
|
4743
4838
|
`;
|
|
4839
|
+
lines.forEach((l, idx) => {
|
|
4840
|
+
svg += ` <text x="${textStartX}" y="${startY + idx * lineHeight}" class="markdy-svg-text" font-size="13.5" font-weight="600" letter-spacing="-0.01em" fill="${textColor}" dominant-baseline="central">${escapeXml(l)}</text>
|
|
4841
|
+
`;
|
|
4842
|
+
});
|
|
4744
4843
|
}
|
|
4745
4844
|
}
|
|
4746
4845
|
}
|
|
@@ -5642,6 +5741,68 @@ function detectHostTheme(container) {
|
|
|
5642
5741
|
}
|
|
5643
5742
|
return "paper";
|
|
5644
5743
|
}
|
|
5744
|
+
function computeDiagramContentBounds(plan, options) {
|
|
5745
|
+
if (!plan.nodes || plan.nodes.length === 0) {
|
|
5746
|
+
return { minX: 0, minY: 0, maxX: plan.meta.width, maxY: plan.meta.height, width: plan.meta.width, height: plan.meta.height };
|
|
5747
|
+
}
|
|
5748
|
+
let minX = Infinity;
|
|
5749
|
+
let minY = Infinity;
|
|
5750
|
+
let maxX = -Infinity;
|
|
5751
|
+
let maxY = -Infinity;
|
|
5752
|
+
for (const node of plan.nodes) {
|
|
5753
|
+
minX = Math.min(minX, node.x);
|
|
5754
|
+
minY = Math.min(minY, node.y);
|
|
5755
|
+
maxX = Math.max(maxX, node.x + node.width);
|
|
5756
|
+
maxY = Math.max(maxY, node.y + node.height);
|
|
5757
|
+
}
|
|
5758
|
+
for (const gb of plan.groupBoundaries ?? []) {
|
|
5759
|
+
minX = Math.min(minX, gb.x);
|
|
5760
|
+
minY = Math.min(minY, gb.y);
|
|
5761
|
+
maxX = Math.max(maxX, gb.x + gb.width);
|
|
5762
|
+
maxY = Math.max(maxY, gb.y + gb.height);
|
|
5763
|
+
}
|
|
5764
|
+
for (const bus of plan.treeBuses ?? []) {
|
|
5765
|
+
minX = Math.min(minX, bus.parentX, ...bus.childXs.length ? bus.childXs : [bus.parentX]);
|
|
5766
|
+
minY = Math.min(minY, bus.parentY, bus.branchY, bus.childY);
|
|
5767
|
+
maxX = Math.max(maxX, bus.parentX, ...bus.childXs.length ? bus.childXs : [bus.parentX]);
|
|
5768
|
+
maxY = Math.max(maxY, bus.parentY, bus.branchY, bus.childY);
|
|
5769
|
+
}
|
|
5770
|
+
if (plan.diagramType === "sequence") {
|
|
5771
|
+
let maxMsgY = minY;
|
|
5772
|
+
for (const msg of plan.sequenceMessages ?? []) {
|
|
5773
|
+
maxMsgY = Math.max(maxMsgY, msg.y + 70);
|
|
5774
|
+
}
|
|
5775
|
+
for (const act of plan.sequenceActivations ?? []) {
|
|
5776
|
+
maxMsgY = Math.max(maxMsgY, act.y + act.height + 40);
|
|
5777
|
+
}
|
|
5778
|
+
maxY = Math.max(maxY, maxMsgY, plan.meta.height - 24);
|
|
5779
|
+
}
|
|
5780
|
+
const titleText = (plan.title ?? plan.meta?.title ?? "").trim();
|
|
5781
|
+
if (titleText.length > 0) {
|
|
5782
|
+
minY = Math.min(minY, 20);
|
|
5783
|
+
}
|
|
5784
|
+
const hasBeatCaptions = plan.beats && plan.beats.some((b) => b.label && b.label.trim().length > 0);
|
|
5785
|
+
if (hasBeatCaptions) {
|
|
5786
|
+
maxY = Math.max(maxY, plan.meta.height - 18);
|
|
5787
|
+
}
|
|
5788
|
+
for (const ann of plan.annotations ?? []) {
|
|
5789
|
+
const targetNode = plan.nodes.find((n) => n.id === ann.target);
|
|
5790
|
+
if (targetNode) {
|
|
5791
|
+
minX = Math.min(minX, targetNode.x - 24);
|
|
5792
|
+
maxX = Math.max(maxX, targetNode.x + targetNode.width + 24);
|
|
5793
|
+
minY = Math.min(minY, targetNode.y - 24);
|
|
5794
|
+
maxY = Math.max(maxY, targetNode.y + targetNode.height + 24);
|
|
5795
|
+
}
|
|
5796
|
+
}
|
|
5797
|
+
const pad = options?.padding ?? (options?.tight === false ? 24 : 10);
|
|
5798
|
+
minX = Math.max(0, minX - pad);
|
|
5799
|
+
minY = Math.max(0, minY - pad);
|
|
5800
|
+
maxX = Math.min(plan.meta.width, maxX + pad);
|
|
5801
|
+
maxY = Math.min(plan.meta.height, maxY + pad);
|
|
5802
|
+
const width = Math.max(maxX - minX, 100);
|
|
5803
|
+
const height = Math.max(maxY - minY, 80);
|
|
5804
|
+
return { minX, minY, maxX, maxY, width, height };
|
|
5805
|
+
}
|
|
5645
5806
|
function createDiagram(opts) {
|
|
5646
5807
|
const {
|
|
5647
5808
|
container,
|
|
@@ -5654,6 +5815,7 @@ function createDiagram(opts) {
|
|
|
5654
5815
|
playbackRate: initialPlaybackRate,
|
|
5655
5816
|
controls: explicitControls,
|
|
5656
5817
|
interactiveViewport: explicitInteractiveViewport,
|
|
5818
|
+
clickToPlay: explicitClickToPlay,
|
|
5657
5819
|
shareUrl,
|
|
5658
5820
|
autoplay: explicitAutoplay,
|
|
5659
5821
|
loop: explicitLoop,
|
|
@@ -5661,17 +5823,48 @@ function createDiagram(opts) {
|
|
|
5661
5823
|
onWarning = (w) => console.warn(`[markdy] line ${w.line}: ${w.message}`),
|
|
5662
5824
|
onTimeUpdate,
|
|
5663
5825
|
onPlayStateChange,
|
|
5664
|
-
onEnded
|
|
5826
|
+
onEnded,
|
|
5827
|
+
responsiveLayout = true,
|
|
5828
|
+
fitMode = "width",
|
|
5829
|
+
targetWidthRatio = 0.98
|
|
5665
5830
|
} = opts;
|
|
5666
|
-
|
|
5831
|
+
function detectContainerOrientation() {
|
|
5832
|
+
const cWidth = container?.clientWidth || 0;
|
|
5833
|
+
const cHeight = container?.clientHeight || 0;
|
|
5834
|
+
if (typeof window === "undefined") {
|
|
5835
|
+
if (cWidth > 0 && cHeight > 0) {
|
|
5836
|
+
return cHeight > cWidth * 1.05 ? "portrait" : "landscape";
|
|
5837
|
+
}
|
|
5838
|
+
return "landscape";
|
|
5839
|
+
}
|
|
5840
|
+
const isMobileViewport = window.innerWidth < 768;
|
|
5841
|
+
if (isMobileViewport) {
|
|
5842
|
+
return "portrait";
|
|
5843
|
+
}
|
|
5844
|
+
if (cWidth > 0 && cHeight > 0) {
|
|
5845
|
+
if (cHeight > cWidth * 1.18) return "portrait";
|
|
5846
|
+
return "landscape";
|
|
5847
|
+
}
|
|
5848
|
+
return window.innerWidth < window.innerHeight ? "portrait" : "landscape";
|
|
5849
|
+
}
|
|
5850
|
+
const ast = parse(code);
|
|
5667
5851
|
for (const w of ast.diagnostics) {
|
|
5668
5852
|
if (w.severity === "warning") onWarning(w);
|
|
5669
5853
|
}
|
|
5670
|
-
const
|
|
5671
|
-
|
|
5672
|
-
|
|
5673
|
-
|
|
5854
|
+
const hasExplicitDirection = ast.meta.explicitDirection === true;
|
|
5855
|
+
const shouldAdaptOrientation = responsiveLayout !== false && (!hasExplicitDirection || responsiveLayout === true);
|
|
5856
|
+
let activeOrientation = detectContainerOrientation();
|
|
5857
|
+
if (shouldAdaptOrientation) {
|
|
5858
|
+
ast.meta.direction = activeOrientation === "portrait" ? "TB" : "LR";
|
|
5674
5859
|
}
|
|
5860
|
+
if (!ast.meta.explicitWidth || !ast.meta.explicitHeight) {
|
|
5861
|
+
const dims = computeAdaptiveDimensions(ast);
|
|
5862
|
+
if (!ast.meta.explicitWidth) ast.meta.width = dims.width;
|
|
5863
|
+
if (!ast.meta.explicitHeight) ast.meta.height = dims.height;
|
|
5864
|
+
}
|
|
5865
|
+
const hasExplicitTheme = Boolean(ast.meta.explicitTheme === true && ast.meta.theme !== "auto");
|
|
5866
|
+
const initialTheme = hasExplicitTheme ? ast.meta.theme : detectHostTheme(container);
|
|
5867
|
+
const plan = compilePlan(ast, resolveTheme2(initialTheme));
|
|
5675
5868
|
let hostThemeObserver = null;
|
|
5676
5869
|
let mediaQueryListener = null;
|
|
5677
5870
|
let colorSchemeQuery = null;
|
|
@@ -5684,6 +5877,7 @@ function createDiagram(opts) {
|
|
|
5684
5877
|
copyright: explicitCopyright,
|
|
5685
5878
|
controls: explicitControls,
|
|
5686
5879
|
interactiveViewport: explicitInteractiveViewport,
|
|
5880
|
+
clickToPlay: explicitClickToPlay,
|
|
5687
5881
|
progress: hostProgress,
|
|
5688
5882
|
progressColor: hostProgressColor
|
|
5689
5883
|
});
|
|
@@ -5736,18 +5930,22 @@ function createDiagram(opts) {
|
|
|
5736
5930
|
});
|
|
5737
5931
|
if (container.style.aspectRatio) container.style.aspectRatio = "unset";
|
|
5738
5932
|
if (container.style.overflow === "hidden") container.style.overflow = "visible";
|
|
5933
|
+
const initialBounds = computeDiagramContentBounds(plan);
|
|
5934
|
+
const contentRatio = `${initialBounds.width} / ${initialBounds.height}`;
|
|
5739
5935
|
const viewport = document.createElement("div");
|
|
5740
5936
|
viewport.className = "markdy-viewport";
|
|
5937
|
+
applyThemeVariables(viewport, plan.theme);
|
|
5741
5938
|
Object.assign(viewport.style, {
|
|
5742
5939
|
position: "relative",
|
|
5743
5940
|
width: "100%",
|
|
5744
5941
|
maxWidth: "100%",
|
|
5745
5942
|
maxHeight: "100%",
|
|
5746
|
-
aspectRatio:
|
|
5943
|
+
aspectRatio: contentRatio,
|
|
5747
5944
|
overflow: "hidden",
|
|
5748
5945
|
boxSizing: "border-box",
|
|
5749
5946
|
flex: "1 1 auto",
|
|
5750
|
-
minHeight: "0"
|
|
5947
|
+
minHeight: "0",
|
|
5948
|
+
background: plan.theme.canvas
|
|
5751
5949
|
});
|
|
5752
5950
|
container.appendChild(viewport);
|
|
5753
5951
|
let progressEl = null;
|
|
@@ -5957,81 +6155,9 @@ function createDiagram(opts) {
|
|
|
5957
6155
|
nodeLayer.appendChild(el);
|
|
5958
6156
|
nodeEls.set(node.id, el);
|
|
5959
6157
|
}
|
|
5960
|
-
let fitScale = 1;
|
|
5961
|
-
let sceneOffsetX = 0;
|
|
5962
|
-
let sceneOffsetY = 0;
|
|
5963
|
-
function computeContentBounds() {
|
|
5964
|
-
if (!plan.nodes || plan.nodes.length === 0) {
|
|
5965
|
-
return { minX: 0, minY: 0, maxX: plan.meta.width, maxY: plan.meta.height, width: plan.meta.width, height: plan.meta.height };
|
|
5966
|
-
}
|
|
5967
|
-
let minX = Infinity;
|
|
5968
|
-
let minY = Infinity;
|
|
5969
|
-
let maxX = -Infinity;
|
|
5970
|
-
let maxY = -Infinity;
|
|
5971
|
-
for (const node of plan.nodes) {
|
|
5972
|
-
minX = Math.min(minX, node.x);
|
|
5973
|
-
minY = Math.min(minY, node.y);
|
|
5974
|
-
maxX = Math.max(maxX, node.x + node.width);
|
|
5975
|
-
maxY = Math.max(maxY, node.y + node.height);
|
|
5976
|
-
}
|
|
5977
|
-
for (const gb of plan.groupBoundaries ?? []) {
|
|
5978
|
-
minX = Math.min(minX, gb.x);
|
|
5979
|
-
minY = Math.min(minY, gb.y);
|
|
5980
|
-
maxX = Math.max(maxX, gb.x + gb.width);
|
|
5981
|
-
maxY = Math.max(maxY, gb.y + gb.height);
|
|
5982
|
-
}
|
|
5983
|
-
for (const bus of plan.treeBuses ?? []) {
|
|
5984
|
-
minX = Math.min(minX, bus.parentX, ...bus.childXs.length ? bus.childXs : [bus.parentX]);
|
|
5985
|
-
minY = Math.min(minY, bus.parentY, bus.branchY, bus.childY);
|
|
5986
|
-
maxX = Math.max(maxX, bus.parentX, ...bus.childXs.length ? bus.childXs : [bus.parentX]);
|
|
5987
|
-
maxY = Math.max(maxY, bus.parentY, bus.branchY, bus.childY);
|
|
5988
|
-
}
|
|
5989
|
-
if (plan.title) {
|
|
5990
|
-
minY = Math.min(minY, 20);
|
|
5991
|
-
}
|
|
5992
|
-
const pad = 36;
|
|
5993
|
-
minX = Math.max(0, minX - pad);
|
|
5994
|
-
minY = Math.max(0, minY - pad);
|
|
5995
|
-
maxX = Math.min(plan.meta.width, maxX + pad);
|
|
5996
|
-
maxY = Math.min(plan.meta.height, maxY + pad);
|
|
5997
|
-
const width = Math.max(maxX - minX, 200);
|
|
5998
|
-
const height = Math.max(maxY - minY, 140);
|
|
5999
|
-
return { minX, minY, maxX, maxY, width, height };
|
|
6000
|
-
}
|
|
6001
|
-
function scaleScene() {
|
|
6002
|
-
const isBrowserLayout = (viewport.clientWidth || container.clientWidth || 0) > 0;
|
|
6003
|
-
if (!isBrowserLayout) {
|
|
6004
|
-
fitScale = 1;
|
|
6005
|
-
sceneOffsetX = 0;
|
|
6006
|
-
sceneOffsetY = 0;
|
|
6007
|
-
scene.style.left = "0px";
|
|
6008
|
-
scene.style.top = "0px";
|
|
6009
|
-
scene.style.transformOrigin = "0 0";
|
|
6010
|
-
scene.style.transform = "scale(1)";
|
|
6011
|
-
return;
|
|
6012
|
-
}
|
|
6013
|
-
const vWidth = viewport.clientWidth || container.clientWidth || plan.meta.width;
|
|
6014
|
-
const vHeight = viewport.clientHeight || container.clientHeight || vWidth * plan.meta.height / plan.meta.width;
|
|
6015
|
-
const canvasScaleX = vWidth / plan.meta.width;
|
|
6016
|
-
const canvasScaleY = vHeight / plan.meta.height;
|
|
6017
|
-
fitScale = Math.min(canvasScaleX, canvasScaleY);
|
|
6018
|
-
if (!Number.isFinite(fitScale) || fitScale <= 0) fitScale = 1;
|
|
6019
|
-
const scaledWidth = plan.meta.width * fitScale;
|
|
6020
|
-
const scaledHeight = plan.meta.height * fitScale;
|
|
6021
|
-
sceneOffsetX = (vWidth - scaledWidth) / 2;
|
|
6022
|
-
sceneOffsetY = (vHeight - scaledHeight) / 2;
|
|
6023
|
-
scene.style.left = `${sceneOffsetX}px`;
|
|
6024
|
-
scene.style.top = `${sceneOffsetY}px`;
|
|
6025
|
-
scene.style.transformOrigin = "0 0";
|
|
6026
|
-
scene.style.transform = `scale(${fitScale})`;
|
|
6027
|
-
}
|
|
6028
|
-
scaleScene();
|
|
6029
|
-
const resizeObserver = typeof ResizeObserver === "function" ? new ResizeObserver(scaleScene) : null;
|
|
6030
|
-
resizeObserver?.observe(viewport);
|
|
6031
|
-
if (container !== viewport) resizeObserver?.observe(container);
|
|
6032
6158
|
const edgeRuntimes = /* @__PURE__ */ new Map();
|
|
6033
6159
|
const edgeSceneId = createEdgeSceneId();
|
|
6034
|
-
|
|
6160
|
+
let sequenceAnims = plan.diagramType === "sequence" ? mountSequenceLayer(
|
|
6035
6161
|
sequenceLayer,
|
|
6036
6162
|
plan.nodes,
|
|
6037
6163
|
plan.sequenceMessages,
|
|
@@ -6039,7 +6165,7 @@ function createDiagram(opts) {
|
|
|
6039
6165
|
plan.theme,
|
|
6040
6166
|
{ width: plan.meta.width, height: plan.meta.height }
|
|
6041
6167
|
) : [];
|
|
6042
|
-
|
|
6168
|
+
let allAnims = [
|
|
6043
6169
|
...sequenceAnims,
|
|
6044
6170
|
...buildStructuralEdgeAnimations(
|
|
6045
6171
|
plan.edges,
|
|
@@ -6066,6 +6192,140 @@ function createDiagram(opts) {
|
|
|
6066
6192
|
anim.pause();
|
|
6067
6193
|
anim.currentTime = 0;
|
|
6068
6194
|
}
|
|
6195
|
+
let fitScale = 1;
|
|
6196
|
+
let sceneOffsetX = 0;
|
|
6197
|
+
let sceneOffsetY = 0;
|
|
6198
|
+
function computeContentBounds() {
|
|
6199
|
+
return computeDiagramContentBounds(plan);
|
|
6200
|
+
}
|
|
6201
|
+
function relayoutOrientation(newDirection) {
|
|
6202
|
+
ast.meta.direction = newDirection;
|
|
6203
|
+
const dims = computeAdaptiveDimensions(ast);
|
|
6204
|
+
if (!ast.meta.explicitWidth) ast.meta.width = dims.width;
|
|
6205
|
+
if (!ast.meta.explicitHeight) ast.meta.height = dims.height;
|
|
6206
|
+
const newPlan = compilePlan(ast, plan.theme);
|
|
6207
|
+
const newBounds = computeDiagramContentBounds(newPlan);
|
|
6208
|
+
scene.style.width = `${newPlan.meta.width}px`;
|
|
6209
|
+
scene.style.height = `${newPlan.meta.height}px`;
|
|
6210
|
+
viewport.style.aspectRatio = `${newBounds.width} / ${newBounds.height}`;
|
|
6211
|
+
plan.nodes = newPlan.nodes;
|
|
6212
|
+
plan.edges = newPlan.edges;
|
|
6213
|
+
plan.groupBoundaries = newPlan.groupBoundaries;
|
|
6214
|
+
plan.treeBuses = newPlan.treeBuses;
|
|
6215
|
+
plan.cues = newPlan.cues;
|
|
6216
|
+
plan.beats = newPlan.beats;
|
|
6217
|
+
plan.meta = newPlan.meta;
|
|
6218
|
+
for (const node of plan.nodes) {
|
|
6219
|
+
const el = nodeEls.get(node.id);
|
|
6220
|
+
if (el) {
|
|
6221
|
+
el.style.left = `${node.x}px`;
|
|
6222
|
+
el.style.top = `${node.y}px`;
|
|
6223
|
+
el.style.width = `${node.width}px`;
|
|
6224
|
+
el.style.height = `${node.height}px`;
|
|
6225
|
+
}
|
|
6226
|
+
}
|
|
6227
|
+
treeLayer.innerHTML = "";
|
|
6228
|
+
mountTreeBuses(treeLayer, plan.treeBuses, plan.theme);
|
|
6229
|
+
groupLayer.innerHTML = "";
|
|
6230
|
+
mountGroupBoundaries(groupLayer, plan.groupBoundaries, plan.theme);
|
|
6231
|
+
structuralEdgeHost.innerHTML = "";
|
|
6232
|
+
edgeRuntimes.clear();
|
|
6233
|
+
const newStructuralAnims = buildStructuralEdgeAnimations(
|
|
6234
|
+
plan.edges,
|
|
6235
|
+
plan.nodes,
|
|
6236
|
+
plan.theme,
|
|
6237
|
+
structuralEdgeHost,
|
|
6238
|
+
{ width: plan.meta.width, height: plan.meta.height },
|
|
6239
|
+
edgeRuntimes,
|
|
6240
|
+
edgeSceneId,
|
|
6241
|
+
plan.diagramType,
|
|
6242
|
+
plan.cues
|
|
6243
|
+
);
|
|
6244
|
+
for (const anim of allAnims) anim.cancel();
|
|
6245
|
+
allAnims = [
|
|
6246
|
+
...plan.diagramType === "sequence" ? mountSequenceLayer(
|
|
6247
|
+
sequenceLayer,
|
|
6248
|
+
plan.nodes,
|
|
6249
|
+
plan.sequenceMessages,
|
|
6250
|
+
plan.sequenceActivations,
|
|
6251
|
+
plan.theme,
|
|
6252
|
+
{ width: plan.meta.width, height: plan.meta.height }
|
|
6253
|
+
) : [],
|
|
6254
|
+
...newStructuralAnims,
|
|
6255
|
+
...buildCueAnimations(
|
|
6256
|
+
plan.cues,
|
|
6257
|
+
nodeEls,
|
|
6258
|
+
plan.nodes,
|
|
6259
|
+
plan.theme,
|
|
6260
|
+
cameraLayer,
|
|
6261
|
+
titleEl,
|
|
6262
|
+
{ width: plan.meta.width, height: plan.meta.height },
|
|
6263
|
+
plan.edges,
|
|
6264
|
+
edgeRuntimes,
|
|
6265
|
+
edgeSceneId,
|
|
6266
|
+
plan.diagramType
|
|
6267
|
+
),
|
|
6268
|
+
...buildBeatCaptionAnimations(plan.beats, captionLayer)
|
|
6269
|
+
];
|
|
6270
|
+
applyCurrentTime();
|
|
6271
|
+
scaleScene();
|
|
6272
|
+
}
|
|
6273
|
+
function scaleScene() {
|
|
6274
|
+
const isBrowserLayout = (viewport.clientWidth || container.clientWidth || 0) > 0;
|
|
6275
|
+
if (!isBrowserLayout) {
|
|
6276
|
+
fitScale = 1;
|
|
6277
|
+
sceneOffsetX = 0;
|
|
6278
|
+
sceneOffsetY = 0;
|
|
6279
|
+
scene.style.left = "0px";
|
|
6280
|
+
scene.style.top = "0px";
|
|
6281
|
+
scene.style.transformOrigin = "0 0";
|
|
6282
|
+
scene.style.transform = "scale(1)";
|
|
6283
|
+
return;
|
|
6284
|
+
}
|
|
6285
|
+
if (shouldAdaptOrientation) {
|
|
6286
|
+
const currentOrientation = detectContainerOrientation();
|
|
6287
|
+
if (currentOrientation !== activeOrientation) {
|
|
6288
|
+
activeOrientation = currentOrientation;
|
|
6289
|
+
relayoutOrientation(activeOrientation === "portrait" ? "TB" : "LR");
|
|
6290
|
+
return;
|
|
6291
|
+
}
|
|
6292
|
+
}
|
|
6293
|
+
const vWidth = viewport.clientWidth || container.clientWidth || plan.meta.width;
|
|
6294
|
+
const fallbackHeight = vWidth * plan.meta.height / plan.meta.width;
|
|
6295
|
+
const vHeight = viewport.clientHeight || container.clientHeight || fallbackHeight;
|
|
6296
|
+
const bounds = computeContentBounds();
|
|
6297
|
+
const contentW = bounds.width;
|
|
6298
|
+
const contentH = bounds.height;
|
|
6299
|
+
const targetRatio = Math.min(1, Math.max(0.95, targetWidthRatio ?? 0.98));
|
|
6300
|
+
const widthScale = vWidth * targetRatio / contentW;
|
|
6301
|
+
if (fitMode === "contain") {
|
|
6302
|
+
const heightScale = (vHeight - 16) * targetRatio / contentH;
|
|
6303
|
+
fitScale = Math.min(widthScale, heightScale);
|
|
6304
|
+
} else {
|
|
6305
|
+
fitScale = widthScale;
|
|
6306
|
+
}
|
|
6307
|
+
if (!Number.isFinite(fitScale) || fitScale <= 0) fitScale = 1;
|
|
6308
|
+
scene.style.setProperty("--markdy-scale", fitScale.toFixed(4));
|
|
6309
|
+
viewport.style.setProperty("--markdy-scale", fitScale.toFixed(4));
|
|
6310
|
+
container.style.setProperty("--markdy-scale", fitScale.toFixed(4));
|
|
6311
|
+
const scaledContentW = contentW * fitScale;
|
|
6312
|
+
const scaledContentH = contentH * fitScale;
|
|
6313
|
+
sceneOffsetX = (vWidth - scaledContentW) / 2 - bounds.minX * fitScale;
|
|
6314
|
+
if (fitMode === "contain") {
|
|
6315
|
+
sceneOffsetY = (vHeight - scaledContentH) / 2 - bounds.minY * fitScale;
|
|
6316
|
+
} else {
|
|
6317
|
+
const topSafeMargin = scaledContentH <= vHeight ? Math.max(8, Math.min(18, (vHeight - scaledContentH) / 2)) : 8;
|
|
6318
|
+
sceneOffsetY = topSafeMargin - bounds.minY * fitScale;
|
|
6319
|
+
}
|
|
6320
|
+
scene.style.left = `${sceneOffsetX}px`;
|
|
6321
|
+
scene.style.top = `${sceneOffsetY}px`;
|
|
6322
|
+
scene.style.transformOrigin = "0 0";
|
|
6323
|
+
scene.style.transform = `scale(${fitScale})`;
|
|
6324
|
+
}
|
|
6325
|
+
scaleScene();
|
|
6326
|
+
const resizeObserver = typeof ResizeObserver === "function" ? new ResizeObserver(scaleScene) : null;
|
|
6327
|
+
resizeObserver?.observe(viewport);
|
|
6328
|
+
if (container !== viewport) resizeObserver?.observe(container);
|
|
6069
6329
|
let sceneMs = 0;
|
|
6070
6330
|
let lastRafTs = null;
|
|
6071
6331
|
let isPlaying = false;
|
|
@@ -7045,9 +7305,9 @@ function createDiagram(opts) {
|
|
|
7045
7305
|
ensureFooter().insertBefore(toolbar, badge);
|
|
7046
7306
|
syncControls();
|
|
7047
7307
|
}
|
|
7048
|
-
viewport.style.cursor = interactiveViewport ? "grab" : "pointer";
|
|
7308
|
+
viewport.style.cursor = interactiveViewport ? "grab" : clickToPlay ? "pointer" : "default";
|
|
7049
7309
|
if (interactiveViewport) {
|
|
7050
|
-
viewport.style.touchAction = "
|
|
7310
|
+
viewport.style.touchAction = "pan-y";
|
|
7051
7311
|
if (allowZoom) viewport.addEventListener("wheel", handleViewportWheel, { passive: false });
|
|
7052
7312
|
if (allowPan) {
|
|
7053
7313
|
viewport.addEventListener("pointerdown", handleViewportPointerDown);
|
|
@@ -7528,6 +7788,7 @@ export {
|
|
|
7528
7788
|
applyImpactHighlight,
|
|
7529
7789
|
calculateBlastRadius,
|
|
7530
7790
|
clearImpactHighlight,
|
|
7791
|
+
computeDiagramContentBounds,
|
|
7531
7792
|
createDiagram,
|
|
7532
7793
|
detectHostTheme,
|
|
7533
7794
|
encodeGifSequence,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markdy/renderer-dom",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.3",
|
|
4
4
|
"description": "Browser renderer for diagram-native animated MarkdyScript architecture diagrams, built on the Web Animations API.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -46,14 +46,14 @@
|
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"html2canvas": "^1.4.1",
|
|
49
|
-
"@markdy/core": "1.3.
|
|
49
|
+
"@markdy/core": "1.3.3"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"jsdom": "^29.1.1",
|
|
53
53
|
"tsup": "^8.5.1",
|
|
54
54
|
"typescript": "^5.9.3",
|
|
55
55
|
"vitest": "^4.1.7",
|
|
56
|
-
"@markdy/stdlib-systems": "1.3.
|
|
56
|
+
"@markdy/stdlib-systems": "1.3.3"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|
|
59
59
|
"build": "tsup",
|