@markdy/renderer-dom 1.4.22 → 1.4.24
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 +10 -0
- package/dist/index.js +172 -49
- package/package.json +4 -3
package/dist/index.d.ts
CHANGED
|
@@ -203,6 +203,12 @@ interface DiagramOptions {
|
|
|
203
203
|
defaultFit?: boolean;
|
|
204
204
|
/** Alias for defaultFit. */
|
|
205
205
|
fit?: boolean;
|
|
206
|
+
/**
|
|
207
|
+
* Initial interact state (pinch, zoom, and drag). Defaults to false when undeclared.
|
|
208
|
+
*/
|
|
209
|
+
defaultInteract?: boolean;
|
|
210
|
+
/** Alias for defaultInteract. */
|
|
211
|
+
interact?: boolean;
|
|
206
212
|
/**
|
|
207
213
|
* Optional custom fullscreen toggle handler.
|
|
208
214
|
* When provided, the footer fullscreen control delegates toggling to this callback.
|
|
@@ -228,6 +234,10 @@ interface Diagram {
|
|
|
228
234
|
exportGif(options?: GifDiagramExportOptions): Promise<Blob>;
|
|
229
235
|
resize(): void;
|
|
230
236
|
resetView(): void;
|
|
237
|
+
toggleInteract(active?: boolean): void;
|
|
238
|
+
isInteractActive(): boolean;
|
|
239
|
+
toggleFitView(): void;
|
|
240
|
+
isFitActive(): boolean;
|
|
231
241
|
syncFullscreen(isFull?: boolean): void;
|
|
232
242
|
destroy(): void;
|
|
233
243
|
}
|
package/dist/index.js
CHANGED
|
@@ -6575,6 +6575,8 @@ function createDiagram(opts) {
|
|
|
6575
6575
|
contentPadding,
|
|
6576
6576
|
defaultFit,
|
|
6577
6577
|
fit: explicitFitOption,
|
|
6578
|
+
defaultInteract,
|
|
6579
|
+
interact: explicitInteractOption,
|
|
6578
6580
|
defaultThemes,
|
|
6579
6581
|
defaultLightTheme,
|
|
6580
6582
|
defaultDarkTheme
|
|
@@ -6616,13 +6618,21 @@ function createDiagram(opts) {
|
|
|
6616
6618
|
if (!ast.meta.explicitWidth) ast.meta.width = dims.width;
|
|
6617
6619
|
if (!ast.meta.explicitHeight) ast.meta.height = dims.height;
|
|
6618
6620
|
}
|
|
6619
|
-
const hasExplicitTheme = Boolean(ast.meta.explicitTheme === true && ast.meta.theme !== "auto");
|
|
6620
6621
|
const optionsDefaultLight = defaultThemes?.light ?? defaultLightTheme;
|
|
6621
6622
|
const optionsDefaultDark = defaultThemes?.dark ?? defaultDarkTheme;
|
|
6622
6623
|
const explicitDefaults = {
|
|
6623
6624
|
light: ast.meta.defaultThemes?.light ?? optionsDefaultLight,
|
|
6624
6625
|
dark: ast.meta.defaultThemes?.dark ?? optionsDefaultDark
|
|
6625
6626
|
};
|
|
6627
|
+
const hasScriptDualThemes = Boolean(ast.meta.defaultThemes?.light || ast.meta.defaultThemes?.dark);
|
|
6628
|
+
const hasOptionsDualThemes = Boolean(explicitDefaults.light || explicitDefaults.dark);
|
|
6629
|
+
const win = typeof window !== "undefined" ? window : null;
|
|
6630
|
+
const hasGlobalDualThemes = Boolean(
|
|
6631
|
+
win && Boolean(win.__MARKDY_DEFAULT_THEMES__?.light || win.__MARKDY_DEFAULT_THEMES__?.dark)
|
|
6632
|
+
);
|
|
6633
|
+
const hasExplicitTheme = Boolean(
|
|
6634
|
+
ast.meta.explicitTheme === true && ast.meta.theme !== "auto" && !hasScriptDualThemes && !hasOptionsDualThemes && !hasGlobalDualThemes
|
|
6635
|
+
);
|
|
6626
6636
|
const initialTheme = hasExplicitTheme ? ast.meta.theme : detectHostTheme(container, explicitDefaults);
|
|
6627
6637
|
const plan = compilePlan(ast, resolveTheme2(initialTheme));
|
|
6628
6638
|
let hostThemeObserver = null;
|
|
@@ -6656,6 +6666,7 @@ function createDiagram(opts) {
|
|
|
6656
6666
|
speed: speedControls,
|
|
6657
6667
|
speeds: speedOptions,
|
|
6658
6668
|
fit: fitViewButton,
|
|
6669
|
+
interact: interactButton,
|
|
6659
6670
|
resetView: resetViewButton,
|
|
6660
6671
|
fullscreen: fullscreenButton,
|
|
6661
6672
|
svg: svgButton,
|
|
@@ -6713,6 +6724,7 @@ function createDiagram(opts) {
|
|
|
6713
6724
|
let controlsScrubberTooltip = null;
|
|
6714
6725
|
let controlsRateButtons = [];
|
|
6715
6726
|
let controlsSeekBar = null;
|
|
6727
|
+
let controlsInteractButton = null;
|
|
6716
6728
|
let controlsFitButton = null;
|
|
6717
6729
|
let closeCodePanel = null;
|
|
6718
6730
|
let progressEl = null;
|
|
@@ -7273,16 +7285,20 @@ function createDiagram(opts) {
|
|
|
7273
7285
|
let dragMoved = false;
|
|
7274
7286
|
let suppressNextClick = false;
|
|
7275
7287
|
const explicitFit = defaultFit ?? explicitFitOption;
|
|
7276
|
-
let fitViewActive = explicitFit !== void 0 ? Boolean(explicitFit) :
|
|
7288
|
+
let fitViewActive = explicitFit !== void 0 ? Boolean(explicitFit) : opts.fitMode === "contain" || Boolean(showControls);
|
|
7277
7289
|
if (fitViewActive) {
|
|
7278
7290
|
cameraLayer.style.setProperty("transform", "none", "important");
|
|
7279
7291
|
}
|
|
7292
|
+
const hasAuthorInteraction = Boolean(plan.meta.player?.interaction?.pan) || Boolean(plan.meta.player?.interaction?.zoom) || Boolean(plan.meta.player?.interaction?.enabled);
|
|
7293
|
+
const explicitInteract = defaultInteract ?? explicitInteractOption;
|
|
7294
|
+
let interactActive = explicitInteract !== void 0 ? Boolean(explicitInteract) : hasAuthorInteraction || Boolean(explicitInteractiveViewport);
|
|
7280
7295
|
const ICONS2 = {
|
|
7281
7296
|
play: '<svg class="markdy-icon" width="12" height="12" viewBox="0 0 24 24" fill="currentColor"><path d="M8 5v14l11-7z"/></svg>',
|
|
7282
7297
|
pause: '<svg class="markdy-icon" width="12" height="12" viewBox="0 0 24 24" fill="currentColor"><path d="M6 19h4V5H6v14zm8-14v14h4V5h-4z"/></svg>',
|
|
7283
7298
|
restart: '<svg class="markdy-icon" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/><path d="M3 3v5h5"/></svg>',
|
|
7284
7299
|
prevBeat: '<svg class="markdy-icon" width="12" height="12" viewBox="0 0 24 24" fill="currentColor"><path d="M6 6h2v12H6zm3.5 6 8.5 6V6z"/></svg>',
|
|
7285
7300
|
nextBeat: '<svg class="markdy-icon" width="12" height="12" viewBox="0 0 24 24" fill="currentColor"><path d="M6 18l8.5-6L6 6v12zM16 6v12h2V6h-2z"/></svg>',
|
|
7301
|
+
interact: '<svg class="markdy-icon" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2"/><path d="M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2"/><path d="M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8"/><path d="M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15"/></svg>',
|
|
7286
7302
|
fit: '<svg class="markdy-icon" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"/></svg>',
|
|
7287
7303
|
resetView: '<svg class="markdy-icon" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><circle cx="12" cy="12" r="3"/></svg>',
|
|
7288
7304
|
fullscreen: '<svg class="markdy-icon" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7"/></svg>',
|
|
@@ -7299,7 +7315,6 @@ function createDiagram(opts) {
|
|
|
7299
7315
|
viewportTransform.style.transform = `translate(${viewportPanX}px, ${viewportPanY}px) scale(${viewportScale})`;
|
|
7300
7316
|
}
|
|
7301
7317
|
function resetViewportTransform() {
|
|
7302
|
-
releaseFitView();
|
|
7303
7318
|
viewportScale = 1;
|
|
7304
7319
|
viewportPanX = 0;
|
|
7305
7320
|
viewportPanY = 0;
|
|
@@ -7316,6 +7331,7 @@ function createDiagram(opts) {
|
|
|
7316
7331
|
function toggleFitView() {
|
|
7317
7332
|
if (fitViewActive) {
|
|
7318
7333
|
resetViewportTransform();
|
|
7334
|
+
releaseFitView();
|
|
7319
7335
|
syncControls();
|
|
7320
7336
|
return;
|
|
7321
7337
|
}
|
|
@@ -7330,7 +7346,29 @@ function createDiagram(opts) {
|
|
|
7330
7346
|
viewport.scrollTop = 0;
|
|
7331
7347
|
syncControls();
|
|
7332
7348
|
}
|
|
7349
|
+
function toggleInteract(force) {
|
|
7350
|
+
interactActive = force !== void 0 ? force : !interactActive;
|
|
7351
|
+
if (interactActive) {
|
|
7352
|
+
viewport.style.cursor = "grab";
|
|
7353
|
+
viewport.style.touchAction = "none";
|
|
7354
|
+
} else {
|
|
7355
|
+
resetViewportTransform();
|
|
7356
|
+
if (defaultFit !== false) {
|
|
7357
|
+
fitViewActive = true;
|
|
7358
|
+
cameraLayer.style.setProperty("transform", "none", "important");
|
|
7359
|
+
scaleScene();
|
|
7360
|
+
}
|
|
7361
|
+
viewport.style.cursor = clickToPlay ? "pointer" : "default";
|
|
7362
|
+
viewport.style.touchAction = scrollableViewport ? "pan-x pan-y" : "auto";
|
|
7363
|
+
}
|
|
7364
|
+
syncControls();
|
|
7365
|
+
}
|
|
7366
|
+
const activePointers = /* @__PURE__ */ new Map();
|
|
7367
|
+
let initialPinchDistance = null;
|
|
7368
|
+
let initialPinchScale = 1;
|
|
7369
|
+
let pinchScenePoint = { x: 0, y: 0 };
|
|
7333
7370
|
function handleViewportWheel(event) {
|
|
7371
|
+
if (!interactActive) return;
|
|
7334
7372
|
if (scrollableViewport && !event.ctrlKey && !event.metaKey) return;
|
|
7335
7373
|
event.preventDefault();
|
|
7336
7374
|
const rect = viewport.getBoundingClientRect();
|
|
@@ -7346,40 +7384,99 @@ function createDiagram(opts) {
|
|
|
7346
7384
|
applyViewportTransform();
|
|
7347
7385
|
}
|
|
7348
7386
|
function handleViewportPointerDown(event) {
|
|
7387
|
+
if (!interactActive) return;
|
|
7349
7388
|
if (scrollableViewport) return;
|
|
7350
7389
|
if (!allowPan) return;
|
|
7351
|
-
if (event.button !== 0
|
|
7352
|
-
|
|
7353
|
-
|
|
7354
|
-
|
|
7355
|
-
|
|
7356
|
-
|
|
7357
|
-
|
|
7358
|
-
|
|
7359
|
-
|
|
7390
|
+
if (event.button !== 0) return;
|
|
7391
|
+
activePointers.set(event.pointerId, { clientX: event.clientX, clientY: event.clientY });
|
|
7392
|
+
try {
|
|
7393
|
+
viewport.setPointerCapture(event.pointerId);
|
|
7394
|
+
} catch {
|
|
7395
|
+
}
|
|
7396
|
+
if (activePointers.size === 1) {
|
|
7397
|
+
activePointerId = event.pointerId;
|
|
7398
|
+
dragStartX = event.clientX;
|
|
7399
|
+
dragStartY = event.clientY;
|
|
7400
|
+
dragLastX = event.clientX;
|
|
7401
|
+
dragLastY = event.clientY;
|
|
7402
|
+
dragMoved = false;
|
|
7403
|
+
viewport.style.cursor = "grabbing";
|
|
7404
|
+
} else if (activePointers.size === 2) {
|
|
7405
|
+
const pts = Array.from(activePointers.values());
|
|
7406
|
+
const p1 = pts[0];
|
|
7407
|
+
const p2 = pts[1];
|
|
7408
|
+
initialPinchDistance = Math.hypot(p2.clientX - p1.clientX, p2.clientY - p1.clientY);
|
|
7409
|
+
initialPinchScale = viewportScale;
|
|
7410
|
+
const midX = (p1.clientX + p2.clientX) / 2;
|
|
7411
|
+
const midY = (p1.clientY + p2.clientY) / 2;
|
|
7412
|
+
const rect = viewport.getBoundingClientRect();
|
|
7413
|
+
const pointerX = (midX - rect.left + viewport.scrollLeft - sceneOffsetX) / fitScale;
|
|
7414
|
+
const pointerY = (midY - rect.top + viewport.scrollTop - sceneOffsetY) / fitScale;
|
|
7415
|
+
pinchScenePoint = {
|
|
7416
|
+
x: (pointerX - viewportPanX) / viewportScale,
|
|
7417
|
+
y: (pointerY - viewportPanY) / viewportScale
|
|
7418
|
+
};
|
|
7419
|
+
dragMoved = true;
|
|
7420
|
+
}
|
|
7360
7421
|
}
|
|
7361
7422
|
function handleViewportPointerMove(event) {
|
|
7362
|
-
if (
|
|
7363
|
-
|
|
7364
|
-
|
|
7365
|
-
|
|
7366
|
-
|
|
7367
|
-
|
|
7368
|
-
|
|
7369
|
-
|
|
7370
|
-
|
|
7371
|
-
|
|
7372
|
-
|
|
7423
|
+
if (!interactActive) return;
|
|
7424
|
+
if (!activePointers.has(event.pointerId)) return;
|
|
7425
|
+
activePointers.set(event.pointerId, { clientX: event.clientX, clientY: event.clientY });
|
|
7426
|
+
if (activePointers.size === 1 && event.pointerId === activePointerId) {
|
|
7427
|
+
const deltaX = (event.clientX - dragLastX) / fitScale;
|
|
7428
|
+
const deltaY = (event.clientY - dragLastY) / fitScale;
|
|
7429
|
+
const totalX = event.clientX - dragStartX;
|
|
7430
|
+
const totalY = event.clientY - dragStartY;
|
|
7431
|
+
if (!dragMoved && Math.hypot(totalX, totalY) >= DRAG_CLICK_THRESHOLD_PX) dragMoved = true;
|
|
7432
|
+
dragLastX = event.clientX;
|
|
7433
|
+
dragLastY = event.clientY;
|
|
7434
|
+
viewportPanX += deltaX;
|
|
7435
|
+
viewportPanY += deltaY;
|
|
7436
|
+
applyViewportTransform();
|
|
7437
|
+
} else if (activePointers.size >= 2 && initialPinchDistance && initialPinchDistance > 0) {
|
|
7438
|
+
const pts = Array.from(activePointers.values());
|
|
7439
|
+
const p1 = pts[0];
|
|
7440
|
+
const p2 = pts[1];
|
|
7441
|
+
const currentDistance = Math.hypot(p2.clientX - p1.clientX, p2.clientY - p1.clientY);
|
|
7442
|
+
const pinchRatio = currentDistance / initialPinchDistance;
|
|
7443
|
+
const nextScale = Math.min(MAX_VIEWPORT_ZOOM, Math.max(MIN_VIEWPORT_ZOOM, initialPinchScale * pinchRatio));
|
|
7444
|
+
const midX = (p1.clientX + p2.clientX) / 2;
|
|
7445
|
+
const midY = (p1.clientY + p2.clientY) / 2;
|
|
7446
|
+
const rect = viewport.getBoundingClientRect();
|
|
7447
|
+
const pointerX = (midX - rect.left + viewport.scrollLeft - sceneOffsetX) / fitScale;
|
|
7448
|
+
const pointerY = (midY - rect.top + viewport.scrollTop - sceneOffsetY) / fitScale;
|
|
7449
|
+
viewportScale = nextScale;
|
|
7450
|
+
viewportPanX = pointerX - pinchScenePoint.x * viewportScale;
|
|
7451
|
+
viewportPanY = pointerY - pinchScenePoint.y * viewportScale;
|
|
7452
|
+
applyViewportTransform();
|
|
7453
|
+
dragMoved = true;
|
|
7454
|
+
}
|
|
7373
7455
|
}
|
|
7374
7456
|
function handleViewportPointerEnd(event) {
|
|
7375
|
-
if (event.pointerId
|
|
7457
|
+
if (viewport.hasPointerCapture(event.pointerId)) {
|
|
7458
|
+
try {
|
|
7459
|
+
viewport.releasePointerCapture(event.pointerId);
|
|
7460
|
+
} catch {
|
|
7461
|
+
}
|
|
7462
|
+
}
|
|
7463
|
+
activePointers.delete(event.pointerId);
|
|
7376
7464
|
if (dragMoved) suppressNextClick = true;
|
|
7377
|
-
if (
|
|
7378
|
-
|
|
7379
|
-
|
|
7380
|
-
|
|
7465
|
+
if (activePointers.size === 1) {
|
|
7466
|
+
const remaining = Array.from(activePointers.entries())[0];
|
|
7467
|
+
activePointerId = remaining[0];
|
|
7468
|
+
dragLastX = remaining[1].clientX;
|
|
7469
|
+
dragLastY = remaining[1].clientY;
|
|
7470
|
+
viewport.style.cursor = "grabbing";
|
|
7471
|
+
} else if (activePointers.size === 0) {
|
|
7472
|
+
activePointerId = null;
|
|
7473
|
+
initialPinchDistance = null;
|
|
7474
|
+
dragMoved = false;
|
|
7475
|
+
viewport.style.cursor = interactActive ? "grab" : clickToPlay ? "pointer" : "default";
|
|
7476
|
+
}
|
|
7381
7477
|
}
|
|
7382
7478
|
function handleViewportDoubleClick(event) {
|
|
7479
|
+
if (!interactActive) return;
|
|
7383
7480
|
event.preventDefault();
|
|
7384
7481
|
suppressNextClick = false;
|
|
7385
7482
|
resetViewportTransform();
|
|
@@ -7402,8 +7499,9 @@ function createDiagram(opts) {
|
|
|
7402
7499
|
controlsSeekBar.value = String(sceneMs / 1e3);
|
|
7403
7500
|
controlsSeekBar.style.setProperty("--seek-pct", `${clamped * 100}%`);
|
|
7404
7501
|
}
|
|
7405
|
-
if (
|
|
7406
|
-
|
|
7502
|
+
if (controlsInteractButton) {
|
|
7503
|
+
const pressed = defaultFit === false ? fitViewActive : interactActive;
|
|
7504
|
+
controlsInteractButton.setAttribute("aria-pressed", pressed ? "true" : "false");
|
|
7407
7505
|
}
|
|
7408
7506
|
}
|
|
7409
7507
|
function emitPlayStateChange(playing) {
|
|
@@ -7516,6 +7614,10 @@ function createDiagram(opts) {
|
|
|
7516
7614
|
applyThemeVariables(container, newTheme);
|
|
7517
7615
|
container.style.background = newTheme.canvas;
|
|
7518
7616
|
container.style.color = newTheme.text;
|
|
7617
|
+
if (container.parentElement && container.parentElement.classList.contains("markdy-root")) {
|
|
7618
|
+
container.parentElement.style.background = newTheme.canvas;
|
|
7619
|
+
applyThemeVariables(container.parentElement, newTheme);
|
|
7620
|
+
}
|
|
7519
7621
|
applyThemeVariables(viewport, newTheme);
|
|
7520
7622
|
viewport.style.background = newTheme.canvas;
|
|
7521
7623
|
viewport.style.color = newTheme.text;
|
|
@@ -7650,6 +7752,18 @@ function createDiagram(opts) {
|
|
|
7650
7752
|
resetView() {
|
|
7651
7753
|
resetViewportTransform();
|
|
7652
7754
|
},
|
|
7755
|
+
toggleInteract(active) {
|
|
7756
|
+
toggleInteract(active);
|
|
7757
|
+
},
|
|
7758
|
+
isInteractActive() {
|
|
7759
|
+
return interactActive;
|
|
7760
|
+
},
|
|
7761
|
+
toggleFitView() {
|
|
7762
|
+
toggleFitView();
|
|
7763
|
+
},
|
|
7764
|
+
isFitActive() {
|
|
7765
|
+
return fitViewActive;
|
|
7766
|
+
},
|
|
7653
7767
|
syncFullscreen(isFull) {
|
|
7654
7768
|
syncFullscreenHandler?.(isFull);
|
|
7655
7769
|
},
|
|
@@ -8204,13 +8318,24 @@ function createDiagram(opts) {
|
|
|
8204
8318
|
});
|
|
8205
8319
|
toolbar.appendChild(button);
|
|
8206
8320
|
}
|
|
8321
|
+
function mountInteractControl(toolbar) {
|
|
8322
|
+
const showButton = (interactButton ?? fitViewButton) !== false && (Boolean(interactButton) || Boolean(fitViewButton));
|
|
8323
|
+
if (!showButton) return;
|
|
8324
|
+
controlsInteractButton = makeControlButton("Interact", "Toggle interactive mode (pinch, zoom, and drag)", ICONS2.interact);
|
|
8325
|
+
controlsInteractButton.className = "markdy-control-interact markdy-control-fit";
|
|
8326
|
+
controlsInteractButton.setAttribute("aria-pressed", (defaultFit === false ? fitViewActive : interactActive) ? "true" : "false");
|
|
8327
|
+
controlsInteractButton.addEventListener("click", () => {
|
|
8328
|
+
if (defaultFit === false) {
|
|
8329
|
+
toggleFitView();
|
|
8330
|
+
} else {
|
|
8331
|
+
toggleInteract();
|
|
8332
|
+
}
|
|
8333
|
+
});
|
|
8334
|
+
controlsFitButton = controlsInteractButton;
|
|
8335
|
+
toolbar.appendChild(controlsInteractButton);
|
|
8336
|
+
}
|
|
8207
8337
|
function mountFitControl(toolbar) {
|
|
8208
|
-
|
|
8209
|
-
controlsFitButton = makeControlButton("Fit", "Fit all items in view and ignore camera zoom", ICONS2.fit);
|
|
8210
|
-
controlsFitButton.className = "markdy-control-fit";
|
|
8211
|
-
controlsFitButton.setAttribute("aria-pressed", fitViewActive ? "true" : "false");
|
|
8212
|
-
controlsFitButton.addEventListener("click", toggleFitView);
|
|
8213
|
-
toolbar.appendChild(controlsFitButton);
|
|
8338
|
+
mountInteractControl(toolbar);
|
|
8214
8339
|
}
|
|
8215
8340
|
function mountResetViewControl(toolbar) {
|
|
8216
8341
|
if (!resetViewButton) return;
|
|
@@ -8458,13 +8583,13 @@ function createDiagram(opts) {
|
|
|
8458
8583
|
mountSpeedControls(speedGroup);
|
|
8459
8584
|
toolsGroup.appendChild(speedGroup);
|
|
8460
8585
|
}
|
|
8461
|
-
if (fitViewButton || resetViewButton || fullscreenButton) {
|
|
8586
|
+
if (interactButton || fitViewButton || resetViewButton || fullscreenButton) {
|
|
8462
8587
|
if (toolsGroup.children.length > 0) {
|
|
8463
8588
|
const divider = document.createElement("div");
|
|
8464
8589
|
divider.className = "markdy-control-divider";
|
|
8465
8590
|
toolsGroup.appendChild(divider);
|
|
8466
8591
|
}
|
|
8467
|
-
|
|
8592
|
+
mountInteractControl(toolsGroup);
|
|
8468
8593
|
mountResetViewControl(toolsGroup);
|
|
8469
8594
|
mountFullscreenControl(toolsGroup);
|
|
8470
8595
|
}
|
|
@@ -8487,18 +8612,16 @@ function createDiagram(opts) {
|
|
|
8487
8612
|
ensureFooter().insertBefore(toolbar, badge);
|
|
8488
8613
|
syncControls();
|
|
8489
8614
|
}
|
|
8490
|
-
viewport.style.cursor =
|
|
8491
|
-
|
|
8492
|
-
|
|
8493
|
-
|
|
8494
|
-
|
|
8495
|
-
|
|
8496
|
-
|
|
8497
|
-
|
|
8498
|
-
viewport.addEventListener("pointercancel", handleViewportPointerEnd);
|
|
8499
|
-
}
|
|
8500
|
-
if (doubleClickToReset) viewport.addEventListener("dblclick", handleViewportDoubleClick);
|
|
8615
|
+
viewport.style.cursor = interactActive ? "grab" : clickToPlay ? "pointer" : "default";
|
|
8616
|
+
viewport.style.touchAction = interactActive ? "none" : scrollableViewport ? "pan-x pan-y" : "auto";
|
|
8617
|
+
if (allowZoom) viewport.addEventListener("wheel", handleViewportWheel, { passive: false });
|
|
8618
|
+
if (allowPan) {
|
|
8619
|
+
viewport.addEventListener("pointerdown", handleViewportPointerDown);
|
|
8620
|
+
viewport.addEventListener("pointermove", handleViewportPointerMove);
|
|
8621
|
+
viewport.addEventListener("pointerup", handleViewportPointerEnd);
|
|
8622
|
+
viewport.addEventListener("pointercancel", handleViewportPointerEnd);
|
|
8501
8623
|
}
|
|
8624
|
+
if (doubleClickToReset) viewport.addEventListener("dblclick", handleViewportDoubleClick);
|
|
8502
8625
|
if (showControls) mountControls();
|
|
8503
8626
|
if (clickToPlay) {
|
|
8504
8627
|
viewport.addEventListener("click", () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markdy/renderer-dom",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.24",
|
|
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",
|
|
@@ -41,10 +41,11 @@
|
|
|
41
41
|
"url": "https://github.com/HoangYell/markdy-com/issues"
|
|
42
42
|
},
|
|
43
43
|
"publishConfig": {
|
|
44
|
-
"access": "public"
|
|
44
|
+
"access": "public",
|
|
45
|
+
"registry": "https://registry.npmjs.org"
|
|
45
46
|
},
|
|
46
47
|
"dependencies": {
|
|
47
|
-
"@markdy/core": "1.4.
|
|
48
|
+
"@markdy/core": "^1.4.24",
|
|
48
49
|
"html2canvas": "^1.4.1"
|
|
49
50
|
},
|
|
50
51
|
"devDependencies": {
|