@markdy/renderer-dom 1.4.1 → 1.4.2
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 +2 -0
- package/dist/index.js +83 -18
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -169,6 +169,8 @@ interface Diagram {
|
|
|
169
169
|
exportSvg(options?: SvgExportOptions): string;
|
|
170
170
|
exportPng(options?: PngExportOptions): Promise<Blob>;
|
|
171
171
|
exportGif(options?: GifDiagramExportOptions): Promise<Blob>;
|
|
172
|
+
resize(): void;
|
|
173
|
+
resetView(): void;
|
|
172
174
|
destroy(): void;
|
|
173
175
|
}
|
|
174
176
|
/**
|
package/dist/index.js
CHANGED
|
@@ -4179,18 +4179,32 @@ function ensureSceneStyles(doc) {
|
|
|
4179
4179
|
inset: 0 !important;
|
|
4180
4180
|
z-index: 999999 !important;
|
|
4181
4181
|
width: 100vw !important;
|
|
4182
|
+
width: 100dvw !important;
|
|
4182
4183
|
height: 100vh !important;
|
|
4184
|
+
height: 100dvh !important;
|
|
4183
4185
|
max-width: 100vw !important;
|
|
4186
|
+
max-width: 100dvw !important;
|
|
4184
4187
|
max-height: 100vh !important;
|
|
4188
|
+
max-height: 100dvh !important;
|
|
4185
4189
|
background-color: var(--md-canvas, #0b101b) !important;
|
|
4186
4190
|
box-sizing: border-box !important;
|
|
4187
4191
|
display: flex !important;
|
|
4188
4192
|
flex-direction: column !important;
|
|
4189
4193
|
justify-content: space-between !important;
|
|
4190
4194
|
align-items: center !important;
|
|
4191
|
-
padding: 16px 20px 12px !important;
|
|
4195
|
+
padding: max(16px, env(safe-area-inset-top, 16px)) max(20px, env(safe-area-inset-right, 20px)) max(12px, env(safe-area-inset-bottom, 12px)) max(20px, env(safe-area-inset-left, 20px)) !important;
|
|
4192
4196
|
overflow: hidden !important;
|
|
4193
4197
|
}
|
|
4198
|
+
.markdy-fullscreen-host .markdy-diagram-root,
|
|
4199
|
+
.markdy--pseudo-fullscreen .markdy-diagram-root {
|
|
4200
|
+
flex: 1 1 auto !important;
|
|
4201
|
+
width: 100% !important;
|
|
4202
|
+
height: 100% !important;
|
|
4203
|
+
display: flex !important;
|
|
4204
|
+
flex-direction: column !important;
|
|
4205
|
+
justify-content: space-between !important;
|
|
4206
|
+
align-items: center !important;
|
|
4207
|
+
}
|
|
4194
4208
|
.markdy-diagram-root:fullscreen .markdy-viewport,
|
|
4195
4209
|
.markdy-diagram-root:-webkit-full-screen .markdy-viewport,
|
|
4196
4210
|
.markdy-diagram-root:-moz-full-screen .markdy-viewport,
|
|
@@ -4202,6 +4216,7 @@ function ensureSceneStyles(doc) {
|
|
|
4202
4216
|
height: 100% !important;
|
|
4203
4217
|
max-width: 100% !important;
|
|
4204
4218
|
max-height: calc(100vh - 64px) !important;
|
|
4219
|
+
max-height: calc(100dvh - 64px) !important;
|
|
4205
4220
|
display: flex !important;
|
|
4206
4221
|
align-items: center !important;
|
|
4207
4222
|
justify-content: center !important;
|
|
@@ -4216,7 +4231,7 @@ function ensureSceneStyles(doc) {
|
|
|
4216
4231
|
width: 100% !important;
|
|
4217
4232
|
max-width: 1400px !important;
|
|
4218
4233
|
margin: 0 auto !important;
|
|
4219
|
-
padding: 8px 12px 4px !important;
|
|
4234
|
+
padding: 8px 12px max(4px, env(safe-area-inset-bottom, 4px)) !important;
|
|
4220
4235
|
}
|
|
4221
4236
|
@media (hover: none) and (pointer: coarse) {
|
|
4222
4237
|
.markdy-controls {
|
|
@@ -6950,6 +6965,14 @@ function createDiagram(opts) {
|
|
|
6950
6965
|
async exportGif(options) {
|
|
6951
6966
|
return await exportDiagramAsGif(container, diagram, options);
|
|
6952
6967
|
},
|
|
6968
|
+
resize() {
|
|
6969
|
+
scaleScene();
|
|
6970
|
+
applyViewportTransform();
|
|
6971
|
+
syncControls();
|
|
6972
|
+
},
|
|
6973
|
+
resetView() {
|
|
6974
|
+
resetViewportTransform();
|
|
6975
|
+
},
|
|
6953
6976
|
destroy() {
|
|
6954
6977
|
diagram.pause();
|
|
6955
6978
|
hostThemeObserver?.disconnect();
|
|
@@ -7372,6 +7395,16 @@ function createDiagram(opts) {
|
|
|
7372
7395
|
button.setAttribute("aria-pressed", "false");
|
|
7373
7396
|
const host = container;
|
|
7374
7397
|
let isPseudoFull = false;
|
|
7398
|
+
let originalBodyOverflow = null;
|
|
7399
|
+
function isNativeFullscreenSupported() {
|
|
7400
|
+
if (typeof document === "undefined") return false;
|
|
7401
|
+
if (typeof navigator !== "undefined" && /iPhone|iPod/i.test(navigator.userAgent)) {
|
|
7402
|
+
return false;
|
|
7403
|
+
}
|
|
7404
|
+
return Boolean(
|
|
7405
|
+
document.fullscreenEnabled || document.webkitFullscreenEnabled || document.mozFullScreenEnabled || document.msFullscreenEnabled
|
|
7406
|
+
);
|
|
7407
|
+
}
|
|
7375
7408
|
function syncFullscreenState() {
|
|
7376
7409
|
const isFull = isPseudoFull || document.fullscreenElement === host || document.fullscreenElement === viewport || document.webkitFullscreenElement === host || document.webkitFullscreenElement === viewport || document.mozFullScreenElement === host || document.msFullscreenElement === host;
|
|
7377
7410
|
button.setAttribute("aria-pressed", isFull ? "true" : "false");
|
|
@@ -7379,54 +7412,82 @@ function createDiagram(opts) {
|
|
|
7379
7412
|
button.innerHTML = isFull ? `${ICONS2.fullscreen}Exit` : `${ICONS2.fullscreen}Full`;
|
|
7380
7413
|
if (isFull) {
|
|
7381
7414
|
host.classList.add("markdy-fullscreen-host");
|
|
7415
|
+
if (isPseudoFull) {
|
|
7416
|
+
host.classList.add("markdy--pseudo-fullscreen");
|
|
7417
|
+
if (typeof document !== "undefined" && document.body && originalBodyOverflow === null) {
|
|
7418
|
+
originalBodyOverflow = document.body.style.overflow;
|
|
7419
|
+
document.body.style.overflow = "hidden";
|
|
7420
|
+
}
|
|
7421
|
+
}
|
|
7382
7422
|
} else {
|
|
7383
7423
|
host.classList.remove("markdy-fullscreen-host");
|
|
7384
7424
|
host.classList.remove("markdy--pseudo-fullscreen");
|
|
7425
|
+
if (typeof document !== "undefined" && document.body && originalBodyOverflow !== null) {
|
|
7426
|
+
document.body.style.overflow = originalBodyOverflow;
|
|
7427
|
+
originalBodyOverflow = null;
|
|
7428
|
+
}
|
|
7385
7429
|
}
|
|
7386
7430
|
requestAnimationFrame(() => {
|
|
7387
7431
|
scaleScene();
|
|
7388
7432
|
applyViewportTransform();
|
|
7389
7433
|
syncControls();
|
|
7390
7434
|
});
|
|
7435
|
+
setTimeout(() => {
|
|
7436
|
+
scaleScene();
|
|
7437
|
+
applyViewportTransform();
|
|
7438
|
+
syncControls();
|
|
7439
|
+
}, 120);
|
|
7391
7440
|
}
|
|
7392
7441
|
async function toggleFullscreen() {
|
|
7393
7442
|
try {
|
|
7394
|
-
const isCurrentlyFull = isPseudoFull || document.fullscreenElement === host || document.fullscreenElement === viewport || document.webkitFullscreenElement === host || document.mozFullScreenElement === host || document.msFullscreenElement === host;
|
|
7443
|
+
const isCurrentlyFull = isPseudoFull || document.fullscreenElement === host || document.fullscreenElement === viewport || document.webkitFullscreenElement === host || document.webkitFullscreenElement === viewport || document.mozFullScreenElement === host || document.msFullscreenElement === host;
|
|
7395
7444
|
if (!isCurrentlyFull) {
|
|
7396
|
-
|
|
7397
|
-
if (
|
|
7398
|
-
|
|
7399
|
-
|
|
7400
|
-
|
|
7401
|
-
|
|
7402
|
-
|
|
7403
|
-
|
|
7445
|
+
let enteredNative = false;
|
|
7446
|
+
if (isNativeFullscreenSupported()) {
|
|
7447
|
+
const req = host.requestFullscreen?.bind(host) || host.webkitRequestFullscreen?.bind(host) || host.mozRequestFullScreen?.bind(host) || host.msRequestFullscreen?.bind(host) || viewport.requestFullscreen?.bind(viewport) || viewport.webkitRequestFullscreen?.bind(viewport);
|
|
7448
|
+
if (req) {
|
|
7449
|
+
try {
|
|
7450
|
+
const res = req();
|
|
7451
|
+
if (res && typeof res.then === "function") {
|
|
7452
|
+
await res;
|
|
7453
|
+
}
|
|
7454
|
+
enteredNative = Boolean(
|
|
7455
|
+
document.fullscreenElement === host || document.fullscreenElement === viewport || document.webkitFullscreenElement === host || document.webkitFullscreenElement === viewport || document.mozFullScreenElement === host || document.msFullscreenElement === host
|
|
7456
|
+
);
|
|
7457
|
+
} catch {
|
|
7458
|
+
enteredNative = false;
|
|
7459
|
+
}
|
|
7404
7460
|
}
|
|
7405
|
-
}
|
|
7461
|
+
}
|
|
7462
|
+
if (!enteredNative) {
|
|
7406
7463
|
isPseudoFull = true;
|
|
7407
|
-
host.classList.add("markdy--pseudo-fullscreen");
|
|
7408
7464
|
syncFullscreenState();
|
|
7409
7465
|
}
|
|
7410
7466
|
} else {
|
|
7411
7467
|
if (isPseudoFull) {
|
|
7412
7468
|
isPseudoFull = false;
|
|
7413
|
-
host.classList.remove("markdy--pseudo-fullscreen");
|
|
7414
7469
|
syncFullscreenState();
|
|
7415
7470
|
} else {
|
|
7416
7471
|
const exit = document.exitFullscreen?.bind(document) || document.webkitExitFullscreen?.bind(document) || document.mozCancelFullScreen?.bind(document) || document.msExitFullscreen?.bind(document);
|
|
7417
7472
|
if (exit) {
|
|
7418
|
-
|
|
7473
|
+
try {
|
|
7474
|
+
const res = exit();
|
|
7475
|
+
if (res && typeof res.then === "function") {
|
|
7476
|
+
await res;
|
|
7477
|
+
}
|
|
7478
|
+
} catch {
|
|
7479
|
+
}
|
|
7419
7480
|
}
|
|
7481
|
+
isPseudoFull = false;
|
|
7482
|
+
syncFullscreenState();
|
|
7420
7483
|
}
|
|
7421
7484
|
}
|
|
7422
7485
|
} catch {
|
|
7423
7486
|
if (!isPseudoFull) {
|
|
7424
7487
|
isPseudoFull = true;
|
|
7425
|
-
host.classList.add("markdy--pseudo-fullscreen");
|
|
7426
7488
|
syncFullscreenState();
|
|
7427
7489
|
} else {
|
|
7428
7490
|
isPseudoFull = false;
|
|
7429
|
-
host.classList.remove("markdy--pseudo-fullscreen");
|
|
7430
7491
|
syncFullscreenState();
|
|
7431
7492
|
}
|
|
7432
7493
|
}
|
|
@@ -7438,7 +7499,6 @@ function createDiagram(opts) {
|
|
|
7438
7499
|
const handleEscKey = (e) => {
|
|
7439
7500
|
if (e.key === "Escape" && isPseudoFull) {
|
|
7440
7501
|
isPseudoFull = false;
|
|
7441
|
-
host.classList.remove("markdy--pseudo-fullscreen");
|
|
7442
7502
|
syncFullscreenState();
|
|
7443
7503
|
}
|
|
7444
7504
|
};
|
|
@@ -7453,7 +7513,12 @@ function createDiagram(opts) {
|
|
|
7453
7513
|
document.removeEventListener("mozfullscreenchange", syncFullscreenState);
|
|
7454
7514
|
document.removeEventListener("MSFullscreenChange", syncFullscreenState);
|
|
7455
7515
|
window.removeEventListener("keydown", handleEscKey);
|
|
7516
|
+
if (originalBodyOverflow !== null && typeof document !== "undefined" && document.body) {
|
|
7517
|
+
document.body.style.overflow = originalBodyOverflow;
|
|
7518
|
+
originalBodyOverflow = null;
|
|
7519
|
+
}
|
|
7456
7520
|
if (isPseudoFull) {
|
|
7521
|
+
isPseudoFull = false;
|
|
7457
7522
|
host.classList.remove("markdy--pseudo-fullscreen");
|
|
7458
7523
|
host.classList.remove("markdy-fullscreen-host");
|
|
7459
7524
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markdy/renderer-dom",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.2",
|
|
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.2"
|
|
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.2"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|
|
59
59
|
"build": "tsup",
|