@markdy/renderer-dom 1.4.8 → 1.4.10
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.js +15 -10
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -6287,7 +6287,7 @@ function computeDiagramContentBounds(plan, options) {
|
|
|
6287
6287
|
}
|
|
6288
6288
|
const hasBeatCaptions = plan.beats && plan.beats.some((b) => b.label && b.label.trim().length > 0);
|
|
6289
6289
|
if (hasBeatCaptions) {
|
|
6290
|
-
maxY = Math.max(maxY,
|
|
6290
|
+
maxY = Math.max(maxY, maxY + 36);
|
|
6291
6291
|
}
|
|
6292
6292
|
for (const ann of plan.annotations ?? []) {
|
|
6293
6293
|
const targetNode = plan.nodes.find((n) => n.id === ann.target);
|
|
@@ -6318,7 +6318,7 @@ function computeSymmetricContentSpan(plan, bounds) {
|
|
|
6318
6318
|
const canvasCenterX = plan.meta.width / 2;
|
|
6319
6319
|
const leftSpan = Math.max(0, canvasCenterX - bounds.minX);
|
|
6320
6320
|
const rightSpan = Math.max(0, bounds.maxX - canvasCenterX);
|
|
6321
|
-
const halfSpanX = Math.max(
|
|
6321
|
+
const halfSpanX = Math.max(leftSpan, rightSpan, bounds.width / 2);
|
|
6322
6322
|
return {
|
|
6323
6323
|
symmetricContentW: halfSpanX * 2,
|
|
6324
6324
|
symmetricMinX: canvasCenterX - halfSpanX
|
|
@@ -6867,10 +6867,14 @@ function createDiagram(opts) {
|
|
|
6867
6867
|
return;
|
|
6868
6868
|
}
|
|
6869
6869
|
const vWidth = viewport.clientWidth || container.clientWidth || plan.meta.width;
|
|
6870
|
-
const
|
|
6871
|
-
const
|
|
6872
|
-
const
|
|
6873
|
-
const
|
|
6870
|
+
const initialMeasureBounds = computeContentBounds();
|
|
6871
|
+
const { symmetricContentW: initSymW } = computeSymmetricContentSpan(plan, initialMeasureBounds);
|
|
6872
|
+
const naturalHeight = vWidth * initialMeasureBounds.height / initSymW;
|
|
6873
|
+
const isHeightConstrained = hasInitialHeightConstraint;
|
|
6874
|
+
const vHeight = isHeightConstrained ? viewport.clientHeight || container.clientHeight || naturalHeight : naturalHeight;
|
|
6875
|
+
const resolvedFit = fitViewActive ? "contain" : fitMode === "auto" ? isHeightConstrained ? "contain" : "width" : fitMode;
|
|
6876
|
+
const defaultTargetRatio = vWidth <= 480 ? 0.95 : 0.9;
|
|
6877
|
+
const targetRatio = Math.min(1, Math.max(0.85, targetWidthRatio ?? defaultTargetRatio));
|
|
6874
6878
|
const ADAPTABLE_DIAGRAM_TYPES = /* @__PURE__ */ new Set([
|
|
6875
6879
|
"architecture",
|
|
6876
6880
|
"flowchart",
|
|
@@ -6888,12 +6892,12 @@ function createDiagram(opts) {
|
|
|
6888
6892
|
]);
|
|
6889
6893
|
if (shouldAdaptOrientation && ADAPTABLE_DIAGRAM_TYPES.has(plan.diagramType)) {
|
|
6890
6894
|
const detectedOrientation = detectContainerOrientation(activeOrientation);
|
|
6891
|
-
const isHeightConstrained = hasInitialHeightConstraint || vHeight > 0 && Math.abs(vHeight - naturalHeight) > 2;
|
|
6892
6895
|
const containerRatio = vWidth / Math.max(1, vHeight);
|
|
6893
6896
|
let currentOrientation = activeOrientation;
|
|
6894
6897
|
const score = (orientation) => {
|
|
6895
|
-
const { bounds: bounds2 } = layoutForDirection(directionForOrientation(orientation));
|
|
6896
|
-
const
|
|
6898
|
+
const { plan: candPlan, bounds: bounds2 } = layoutForDirection(directionForOrientation(orientation));
|
|
6899
|
+
const { symmetricContentW: candSymW } = computeSymmetricContentSpan(candPlan, bounds2);
|
|
6900
|
+
const widthScale2 = vWidth * targetRatio / candSymW;
|
|
6897
6901
|
const heightScale = isHeightConstrained ? Math.max(1, vHeight - 24) * targetRatio / bounds2.height : 1;
|
|
6898
6902
|
return {
|
|
6899
6903
|
fit: Math.min(1, widthScale2, heightScale),
|
|
@@ -6937,7 +6941,8 @@ function createDiagram(opts) {
|
|
|
6937
6941
|
}
|
|
6938
6942
|
if (!Number.isFinite(fitScale) || fitScale <= 0) fitScale = 1;
|
|
6939
6943
|
if (fitMode === "auto" && !fitViewActive) {
|
|
6940
|
-
const
|
|
6944
|
+
const defaultMin = vWidth <= 480 ? 0.75 : 0.85;
|
|
6945
|
+
const minimum = Number.isFinite(minReadableScale) && minReadableScale >= 0 && minReadableScale <= 1 ? minReadableScale : defaultMin;
|
|
6941
6946
|
fitScale = Math.max(fitScale, minimum);
|
|
6942
6947
|
}
|
|
6943
6948
|
const scaleStr = fitScale.toFixed(4);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markdy/renderer-dom",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.10",
|
|
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.4.
|
|
49
|
+
"@markdy/core": "1.4.10"
|
|
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.4.
|
|
56
|
+
"@markdy/stdlib-systems": "1.4.10"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|
|
59
59
|
"build": "tsup",
|