@markdy/renderer-dom 1.4.9 → 1.4.11
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 +340 -69
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -3703,40 +3703,151 @@ function ensureSceneStyles(doc) {
|
|
|
3703
3703
|
align-items: center;
|
|
3704
3704
|
justify-content: space-between;
|
|
3705
3705
|
gap: 8px;
|
|
3706
|
-
padding:
|
|
3706
|
+
padding: 8px 12px 7px 10px;
|
|
3707
3707
|
color: var(--md-text, #64748b);
|
|
3708
|
-
background: var(--md-footer-bg, rgba(248, 250, 252, 0.
|
|
3709
|
-
backdrop-filter: blur(
|
|
3710
|
-
-webkit-backdrop-filter: blur(
|
|
3711
|
-
border-top: 1px solid var(--md-card-border, rgba(148, 163, 184, 0.
|
|
3708
|
+
background: var(--md-footer-bg, rgba(248, 250, 252, 0.88));
|
|
3709
|
+
backdrop-filter: blur(12px);
|
|
3710
|
+
-webkit-backdrop-filter: blur(12px);
|
|
3711
|
+
border-top: 1px solid var(--md-card-border, rgba(148, 163, 184, 0.16));
|
|
3712
3712
|
z-index: 100;
|
|
3713
3713
|
pointer-events: auto;
|
|
3714
3714
|
flex-shrink: 0;
|
|
3715
3715
|
border-radius: 0 0 11px 11px;
|
|
3716
|
+
transition: background 0.2s ease, border-color 0.2s ease;
|
|
3717
|
+
}
|
|
3718
|
+
/* \u2500\u2500 Real Embedded Footer Scrubber \u2500\u2500 */
|
|
3719
|
+
.markdy-player-scrubber {
|
|
3720
|
+
position: absolute;
|
|
3721
|
+
top: 0;
|
|
3722
|
+
left: 0;
|
|
3723
|
+
right: 0;
|
|
3724
|
+
width: 100%;
|
|
3725
|
+
height: 12px;
|
|
3726
|
+
transform: translateY(-50%);
|
|
3727
|
+
cursor: pointer;
|
|
3728
|
+
z-index: 50;
|
|
3729
|
+
display: flex;
|
|
3730
|
+
align-items: center;
|
|
3731
|
+
padding: 0;
|
|
3732
|
+
margin: 0;
|
|
3733
|
+
}
|
|
3734
|
+
.markdy-player-scrubber-track {
|
|
3735
|
+
position: relative;
|
|
3736
|
+
width: 100%;
|
|
3737
|
+
height: 3px;
|
|
3738
|
+
background: var(--md-scrubber-bg, rgba(148, 163, 184, 0.25));
|
|
3739
|
+
border-radius: 9999px;
|
|
3740
|
+
transition: height 0.15s cubic-bezier(0.4, 0, 0.2, 1);
|
|
3741
|
+
overflow: visible;
|
|
3742
|
+
}
|
|
3743
|
+
.markdy-player-scrubber:hover .markdy-player-scrubber-track,
|
|
3744
|
+
.markdy-player-scrubber:active .markdy-player-scrubber-track {
|
|
3745
|
+
height: 5px;
|
|
3746
|
+
}
|
|
3747
|
+
.markdy-player-scrubber-fill {
|
|
3748
|
+
position: absolute;
|
|
3749
|
+
left: 0;
|
|
3750
|
+
top: 0;
|
|
3751
|
+
bottom: 0;
|
|
3752
|
+
width: 0%;
|
|
3753
|
+
background: var(--accent, #2563eb);
|
|
3754
|
+
border-radius: 9999px;
|
|
3755
|
+
pointer-events: none;
|
|
3756
|
+
transition: background 0.15s ease;
|
|
3757
|
+
}
|
|
3758
|
+
.markdy-player-scrubber-thumb {
|
|
3759
|
+
position: absolute;
|
|
3760
|
+
top: 50%;
|
|
3761
|
+
left: 0%;
|
|
3762
|
+
width: 11px;
|
|
3763
|
+
height: 11px;
|
|
3764
|
+
border-radius: 50%;
|
|
3765
|
+
background: var(--accent, #2563eb);
|
|
3766
|
+
border: 2px solid #ffffff;
|
|
3767
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
|
|
3768
|
+
transform: translate(-50%, -50%) scale(0);
|
|
3769
|
+
transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.15s ease;
|
|
3770
|
+
pointer-events: none;
|
|
3771
|
+
}
|
|
3772
|
+
.markdy-player-scrubber:hover .markdy-player-scrubber-thumb,
|
|
3773
|
+
.markdy-player-scrubber:active .markdy-player-scrubber-thumb {
|
|
3774
|
+
transform: translate(-50%, -50%) scale(1);
|
|
3775
|
+
}
|
|
3776
|
+
.markdy-player-scrubber-tick {
|
|
3777
|
+
position: absolute;
|
|
3778
|
+
top: 0;
|
|
3779
|
+
bottom: 0;
|
|
3780
|
+
width: 1.5px;
|
|
3781
|
+
background: var(--md-scrubber-tick, rgba(255, 255, 255, 0.6));
|
|
3782
|
+
transform: translateX(-50%);
|
|
3783
|
+
pointer-events: none;
|
|
3784
|
+
z-index: 2;
|
|
3785
|
+
}
|
|
3786
|
+
.markdy-player-scrubber .markdy-control-seek {
|
|
3787
|
+
position: absolute;
|
|
3788
|
+
inset: 0;
|
|
3789
|
+
width: 100%;
|
|
3790
|
+
height: 100%;
|
|
3791
|
+
opacity: 0;
|
|
3792
|
+
cursor: pointer;
|
|
3793
|
+
margin: 0;
|
|
3794
|
+
padding: 0;
|
|
3795
|
+
z-index: 10;
|
|
3796
|
+
appearance: none;
|
|
3797
|
+
-webkit-appearance: none;
|
|
3798
|
+
}
|
|
3799
|
+
.markdy-player-scrubber-tooltip {
|
|
3800
|
+
position: absolute;
|
|
3801
|
+
bottom: 16px;
|
|
3802
|
+
left: 0%;
|
|
3803
|
+
transform: translateX(-50%);
|
|
3804
|
+
padding: 2px 6px;
|
|
3805
|
+
font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
|
3806
|
+
font-size: 10px;
|
|
3807
|
+
font-weight: 600;
|
|
3808
|
+
color: #ffffff;
|
|
3809
|
+
background: rgba(15, 23, 42, 0.9);
|
|
3810
|
+
border: 1px solid rgba(255, 255, 255, 0.1);
|
|
3811
|
+
border-radius: 4px;
|
|
3812
|
+
pointer-events: none;
|
|
3813
|
+
opacity: 0;
|
|
3814
|
+
transition: opacity 0.1s ease;
|
|
3815
|
+
white-space: nowrap;
|
|
3816
|
+
z-index: 60;
|
|
3817
|
+
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
|
|
3818
|
+
}
|
|
3819
|
+
.markdy-player-beat-chip {
|
|
3820
|
+
display: inline-flex;
|
|
3821
|
+
align-items: center;
|
|
3822
|
+
padding: 2px 7px;
|
|
3823
|
+
font-size: 10px;
|
|
3824
|
+
font-weight: 600;
|
|
3825
|
+
color: var(--md-control-text, #475569);
|
|
3826
|
+
background: var(--md-segmented-bg, rgba(148, 163, 184, 0.12));
|
|
3827
|
+
border: 1px solid var(--md-control-border, rgba(148, 163, 184, 0.18));
|
|
3828
|
+
border-radius: 9999px;
|
|
3829
|
+
white-space: nowrap;
|
|
3830
|
+
max-width: 140px;
|
|
3831
|
+
overflow: hidden;
|
|
3832
|
+
text-overflow: ellipsis;
|
|
3833
|
+
letter-spacing: -0.01em;
|
|
3834
|
+
flex-shrink: 1;
|
|
3716
3835
|
}
|
|
3717
3836
|
.markdy-controls {
|
|
3718
3837
|
display: flex;
|
|
3719
3838
|
align-items: center;
|
|
3720
|
-
justify-content:
|
|
3839
|
+
justify-content: space-between;
|
|
3721
3840
|
flex: 1 1 auto;
|
|
3722
3841
|
width: auto;
|
|
3723
3842
|
min-width: 0;
|
|
3724
3843
|
gap: 6px;
|
|
3725
3844
|
max-width: 100%;
|
|
3726
|
-
|
|
3727
|
-
overflow-y: visible;
|
|
3728
|
-
scrollbar-width: none;
|
|
3729
|
-
-ms-overflow-style: none;
|
|
3730
|
-
-webkit-overflow-scrolling: touch;
|
|
3731
|
-
padding: 2px 2px 2px;
|
|
3845
|
+
padding: 0;
|
|
3732
3846
|
margin: 0;
|
|
3733
3847
|
position: relative;
|
|
3734
3848
|
z-index: 10;
|
|
3735
3849
|
pointer-events: auto;
|
|
3736
3850
|
}
|
|
3737
|
-
.markdy-controls::-webkit-scrollbar {
|
|
3738
|
-
display: none;
|
|
3739
|
-
}
|
|
3740
3851
|
.markdy-controls-group {
|
|
3741
3852
|
display: inline-flex;
|
|
3742
3853
|
align-items: center;
|
|
@@ -3749,25 +3860,15 @@ function ensureSceneStyles(doc) {
|
|
|
3749
3860
|
.markdy-controls-playback {
|
|
3750
3861
|
display: inline-flex;
|
|
3751
3862
|
align-items: center;
|
|
3752
|
-
gap:
|
|
3863
|
+
gap: 5px;
|
|
3753
3864
|
flex-shrink: 0;
|
|
3754
3865
|
}
|
|
3755
|
-
.markdy-controls-timeline {
|
|
3756
|
-
display: flex;
|
|
3757
|
-
align-items: center;
|
|
3758
|
-
gap: 8px;
|
|
3759
|
-
flex: 1 1 180px;
|
|
3760
|
-
min-width: 110px;
|
|
3761
|
-
max-width: 340px;
|
|
3762
|
-
}
|
|
3763
3866
|
.markdy-controls-tools {
|
|
3764
3867
|
display: inline-flex;
|
|
3765
3868
|
align-items: center;
|
|
3766
3869
|
gap: 4px;
|
|
3767
3870
|
flex-shrink: 0;
|
|
3768
|
-
|
|
3769
|
-
z-index: 5;
|
|
3770
|
-
pointer-events: auto;
|
|
3871
|
+
margin-left: auto;
|
|
3771
3872
|
}
|
|
3772
3873
|
.markdy-control-divider {
|
|
3773
3874
|
width: 1px;
|
|
@@ -3882,6 +3983,9 @@ function ensureSceneStyles(doc) {
|
|
|
3882
3983
|
.markdy-btn-label {
|
|
3883
3984
|
display: none !important;
|
|
3884
3985
|
}
|
|
3986
|
+
.markdy-player-beat-chip {
|
|
3987
|
+
display: none !important;
|
|
3988
|
+
}
|
|
3885
3989
|
.markdy-controls button {
|
|
3886
3990
|
padding: 0 !important;
|
|
3887
3991
|
width: 25px !important;
|
|
@@ -3900,7 +4004,7 @@ function ensureSceneStyles(doc) {
|
|
|
3900
4004
|
gap: 4px !important;
|
|
3901
4005
|
}
|
|
3902
4006
|
.markdy-footer {
|
|
3903
|
-
padding: 5px 8px !important;
|
|
4007
|
+
padding: 6px 10px 5px 8px !important;
|
|
3904
4008
|
}
|
|
3905
4009
|
.markdy-badge {
|
|
3906
4010
|
font-size: 9px !important;
|
|
@@ -3911,6 +4015,9 @@ function ensureSceneStyles(doc) {
|
|
|
3911
4015
|
.markdy-btn-label {
|
|
3912
4016
|
display: none !important;
|
|
3913
4017
|
}
|
|
4018
|
+
.markdy-player-beat-chip {
|
|
4019
|
+
display: none !important;
|
|
4020
|
+
}
|
|
3914
4021
|
.markdy-controls button {
|
|
3915
4022
|
padding: 0 !important;
|
|
3916
4023
|
width: 25px !important;
|
|
@@ -4256,10 +4363,32 @@ function ensureSceneStyles(doc) {
|
|
|
4256
4363
|
:root[data-theme="dark"] .markdy-footer,
|
|
4257
4364
|
.theme-dark .markdy-footer,
|
|
4258
4365
|
.dark .markdy-footer {
|
|
4259
|
-
background: var(--md-footer-bg, rgba(15, 23, 42, 0.
|
|
4366
|
+
background: var(--md-footer-bg, rgba(15, 23, 42, 0.88));
|
|
4260
4367
|
border-top-color: var(--md-card-border, rgba(255, 255, 255, 0.08));
|
|
4261
4368
|
color: #94a3b8;
|
|
4262
4369
|
}
|
|
4370
|
+
[data-markdy-theme="midnight"] .markdy-player-scrubber-track,
|
|
4371
|
+
[data-markdy-theme="blueprint"] .markdy-player-scrubber-track,
|
|
4372
|
+
[data-markdy-theme="terminal"] .markdy-player-scrubber-track,
|
|
4373
|
+
[data-markdy-theme="graphite"] .markdy-player-scrubber-track,
|
|
4374
|
+
[data-markdy-theme="nebula"] .markdy-player-scrubber-track,
|
|
4375
|
+
:root[data-theme="dark"] .markdy-player-scrubber-track,
|
|
4376
|
+
.theme-dark .markdy-player-scrubber-track,
|
|
4377
|
+
.dark .markdy-player-scrubber-track {
|
|
4378
|
+
background: rgba(255, 255, 255, 0.14);
|
|
4379
|
+
}
|
|
4380
|
+
[data-markdy-theme="midnight"] .markdy-player-beat-chip,
|
|
4381
|
+
[data-markdy-theme="blueprint"] .markdy-player-beat-chip,
|
|
4382
|
+
[data-markdy-theme="terminal"] .markdy-player-beat-chip,
|
|
4383
|
+
[data-markdy-theme="graphite"] .markdy-player-beat-chip,
|
|
4384
|
+
[data-markdy-theme="nebula"] .markdy-player-beat-chip,
|
|
4385
|
+
:root[data-theme="dark"] .markdy-player-beat-chip,
|
|
4386
|
+
.theme-dark .markdy-player-beat-chip,
|
|
4387
|
+
.dark .markdy-player-beat-chip {
|
|
4388
|
+
background: rgba(255, 255, 255, 0.08);
|
|
4389
|
+
border-color: rgba(255, 255, 255, 0.12);
|
|
4390
|
+
color: #cbd5e1;
|
|
4391
|
+
}
|
|
4263
4392
|
[data-markdy-theme="midnight"] .markdy-controls button:not([aria-pressed="true"]),
|
|
4264
4393
|
[data-markdy-theme="blueprint"] .markdy-controls button:not([aria-pressed="true"]),
|
|
4265
4394
|
[data-markdy-theme="terminal"] .markdy-controls button:not([aria-pressed="true"]),
|
|
@@ -4290,6 +4419,16 @@ function ensureSceneStyles(doc) {
|
|
|
4290
4419
|
.markdy--pseudo-fullscreen {
|
|
4291
4420
|
position: fixed !important;
|
|
4292
4421
|
inset: 0 !important;
|
|
4422
|
+
top: 0 !important;
|
|
4423
|
+
left: 0 !important;
|
|
4424
|
+
right: 0 !important;
|
|
4425
|
+
bottom: 0 !important;
|
|
4426
|
+
margin: 0 !important;
|
|
4427
|
+
border: none !important;
|
|
4428
|
+
border-radius: 0 !important;
|
|
4429
|
+
box-shadow: none !important;
|
|
4430
|
+
aspect-ratio: auto !important;
|
|
4431
|
+
transform: none !important;
|
|
4293
4432
|
z-index: 999999 !important;
|
|
4294
4433
|
width: 100vw !important;
|
|
4295
4434
|
width: 100dvw !important;
|
|
@@ -4305,8 +4444,13 @@ function ensureSceneStyles(doc) {
|
|
|
4305
4444
|
flex-direction: column !important;
|
|
4306
4445
|
justify-content: space-between !important;
|
|
4307
4446
|
align-items: center !important;
|
|
4308
|
-
padding: max(
|
|
4447
|
+
padding-top: max(8px, env(safe-area-inset-top, 0px)) !important;
|
|
4448
|
+
padding-left: max(8px, env(safe-area-inset-left, 0px)) !important;
|
|
4449
|
+
padding-right: max(8px, env(safe-area-inset-right, 0px)) !important;
|
|
4450
|
+
padding-bottom: 0 !important;
|
|
4309
4451
|
overflow: hidden !important;
|
|
4452
|
+
touch-action: pan-x pan-y !important;
|
|
4453
|
+
-webkit-overflow-scrolling: touch !important;
|
|
4310
4454
|
}
|
|
4311
4455
|
.markdy-fullscreen-host .markdy-diagram-root,
|
|
4312
4456
|
.markdy--pseudo-fullscreen .markdy-diagram-root {
|
|
@@ -4328,8 +4472,9 @@ function ensureSceneStyles(doc) {
|
|
|
4328
4472
|
width: 100% !important;
|
|
4329
4473
|
height: 100% !important;
|
|
4330
4474
|
max-width: 100% !important;
|
|
4331
|
-
max-height: calc(100vh -
|
|
4332
|
-
max-height: calc(100dvh -
|
|
4475
|
+
max-height: calc(100vh - 54px) !important;
|
|
4476
|
+
max-height: calc(100dvh - 54px) !important;
|
|
4477
|
+
aspect-ratio: auto !important;
|
|
4333
4478
|
display: flex !important;
|
|
4334
4479
|
align-items: center !important;
|
|
4335
4480
|
justify-content: center !important;
|
|
@@ -4344,7 +4489,8 @@ function ensureSceneStyles(doc) {
|
|
|
4344
4489
|
width: 100% !important;
|
|
4345
4490
|
max-width: 1400px !important;
|
|
4346
4491
|
margin: 0 auto !important;
|
|
4347
|
-
padding:
|
|
4492
|
+
padding: 6px 12px max(12px, env(safe-area-inset-bottom, 12px)) !important;
|
|
4493
|
+
box-sizing: border-box !important;
|
|
4348
4494
|
}
|
|
4349
4495
|
@media (hover: none) and (pointer: coarse) {
|
|
4350
4496
|
.markdy-controls {
|
|
@@ -6477,6 +6623,18 @@ function createDiagram(opts) {
|
|
|
6477
6623
|
background: plan.theme.canvas
|
|
6478
6624
|
});
|
|
6479
6625
|
container.appendChild(viewport);
|
|
6626
|
+
let controlsScrubber = null;
|
|
6627
|
+
let controlsScrubberTrack = null;
|
|
6628
|
+
let controlsScrubberFill = null;
|
|
6629
|
+
let controlsScrubberThumb = null;
|
|
6630
|
+
let controlsScrubberTooltip = null;
|
|
6631
|
+
let controlsBeatChip = null;
|
|
6632
|
+
let controlsPlayButton = null;
|
|
6633
|
+
let controlsRateButtons = [];
|
|
6634
|
+
let controlsSeekBar = null;
|
|
6635
|
+
let controlsTimeEl = null;
|
|
6636
|
+
let controlsFitButton = null;
|
|
6637
|
+
let closeCodePanel = null;
|
|
6480
6638
|
let progressEl = null;
|
|
6481
6639
|
if (showProgress) {
|
|
6482
6640
|
progressEl = document.createElement("div");
|
|
@@ -6498,14 +6656,39 @@ function createDiagram(opts) {
|
|
|
6498
6656
|
viewport.appendChild(progressEl);
|
|
6499
6657
|
}
|
|
6500
6658
|
function updateProgressBar(pct) {
|
|
6659
|
+
const clamped = Math.max(0, Math.min(1, pct));
|
|
6660
|
+
if (controlsScrubberFill) {
|
|
6661
|
+
controlsScrubberFill.style.width = `${clamped * 100}%`;
|
|
6662
|
+
}
|
|
6663
|
+
if (controlsScrubberThumb) {
|
|
6664
|
+
controlsScrubberThumb.style.left = `${clamped * 100}%`;
|
|
6665
|
+
}
|
|
6666
|
+
if (controlsSeekBar) {
|
|
6667
|
+
controlsSeekBar.value = String(sceneMs / 1e3);
|
|
6668
|
+
controlsSeekBar.style.setProperty("--seek-pct", `${clamped * 100}%`);
|
|
6669
|
+
}
|
|
6670
|
+
if (controlsTimeEl) {
|
|
6671
|
+
const cur = (sceneMs / 1e3).toFixed(1);
|
|
6672
|
+
const tot = durationSeconds.toFixed(1);
|
|
6673
|
+
controlsTimeEl.textContent = `${cur}s / ${tot}s`;
|
|
6674
|
+
}
|
|
6675
|
+
if (controlsBeatChip && plan.beats.length > 1) {
|
|
6676
|
+
const currentSec = sceneMs / 1e3;
|
|
6677
|
+
const currentBeat = plan.beats.find((b) => currentSec >= b.start && currentSec < b.end) || plan.beats[plan.beats.length - 1];
|
|
6678
|
+
if (currentBeat) {
|
|
6679
|
+
const beatIdx = plan.beats.indexOf(currentBeat) + 1;
|
|
6680
|
+
controlsBeatChip.textContent = currentBeat.label ? `${beatIdx}. ${currentBeat.label}` : `Beat ${beatIdx}`;
|
|
6681
|
+
controlsBeatChip.title = `Current beat: ${currentBeat.label || currentBeat.name}`;
|
|
6682
|
+
}
|
|
6683
|
+
}
|
|
6501
6684
|
if (!progressEl) return;
|
|
6502
6685
|
if (progressMode === "bar") {
|
|
6503
6686
|
progressEl.style.background = customColor ?? plan.theme.accent ?? "#2563eb";
|
|
6504
6687
|
progressEl.style.transformOrigin = "left center";
|
|
6505
|
-
progressEl.style.transform = `scaleX(${
|
|
6688
|
+
progressEl.style.transform = `scaleX(${clamped})`;
|
|
6506
6689
|
return;
|
|
6507
6690
|
}
|
|
6508
|
-
const deg =
|
|
6691
|
+
const deg = clamped * 360;
|
|
6509
6692
|
const colorStops = customColor ? customColor.includes(",") ? customColor : `${customColor} 0deg, ${customColor}` : DEFAULT_RAINBOW;
|
|
6510
6693
|
const vw = progressEl.clientWidth || viewport.clientWidth || plan.meta.width;
|
|
6511
6694
|
const vh = progressEl.clientHeight || viewport.clientHeight || plan.meta.height;
|
|
@@ -6870,8 +7053,9 @@ function createDiagram(opts) {
|
|
|
6870
7053
|
const initialMeasureBounds = computeContentBounds();
|
|
6871
7054
|
const { symmetricContentW: initSymW } = computeSymmetricContentSpan(plan, initialMeasureBounds);
|
|
6872
7055
|
const naturalHeight = vWidth * initialMeasureBounds.height / initSymW;
|
|
6873
|
-
const
|
|
6874
|
-
const isHeightConstrained = hasInitialHeightConstraint ||
|
|
7056
|
+
const isFullscreenActive = container.classList.contains("markdy-fullscreen-host") || container.classList.contains("markdy--pseudo-fullscreen") || typeof document !== "undefined" && (document.fullscreenElement === container || document.fullscreenElement === viewport || document.webkitFullscreenElement === container || document.webkitFullscreenElement === viewport);
|
|
7057
|
+
const isHeightConstrained = hasInitialHeightConstraint || isFullscreenActive;
|
|
7058
|
+
const vHeight = isHeightConstrained ? viewport.clientHeight || container.clientHeight || naturalHeight : naturalHeight;
|
|
6875
7059
|
const resolvedFit = fitViewActive ? "contain" : fitMode === "auto" ? isHeightConstrained ? "contain" : "width" : fitMode;
|
|
6876
7060
|
const defaultTargetRatio = vWidth <= 480 ? 0.95 : 0.9;
|
|
6877
7061
|
const targetRatio = Math.min(1, Math.max(0.85, targetWidthRatio ?? defaultTargetRatio));
|
|
@@ -7019,12 +7203,6 @@ function createDiagram(opts) {
|
|
|
7019
7203
|
let dragLastY = 0;
|
|
7020
7204
|
let dragMoved = false;
|
|
7021
7205
|
let suppressNextClick = false;
|
|
7022
|
-
let controlsPlayButton = null;
|
|
7023
|
-
let controlsRateButtons = [];
|
|
7024
|
-
let controlsSeekBar = null;
|
|
7025
|
-
let controlsTimeEl = null;
|
|
7026
|
-
let controlsFitButton = null;
|
|
7027
|
-
let closeCodePanel = null;
|
|
7028
7206
|
const explicitFit = defaultFit ?? explicitFitOption;
|
|
7029
7207
|
let fitViewActive = explicitFit !== void 0 ? Boolean(explicitFit) : plan.meta.player?.controls?.fit !== void 0 ? Boolean(plan.meta.player.controls.fit) : opts.fitMode === "contain" || Boolean(fitViewButton);
|
|
7030
7208
|
if (fitViewActive) {
|
|
@@ -7039,6 +7217,7 @@ function createDiagram(opts) {
|
|
|
7039
7217
|
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>',
|
|
7040
7218
|
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>',
|
|
7041
7219
|
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>',
|
|
7220
|
+
fullscreenExit: '<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="M4 14h6v6M20 10h-6V4M14 10l7-7M3 21l7-7"/></svg>',
|
|
7042
7221
|
svg: '<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="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>',
|
|
7043
7222
|
gif: '<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"><rect x="2" y="2" width="20" height="20" rx="3"/><circle cx="7" cy="7" r="1.5" fill="currentColor"/><circle cx="17" cy="7" r="1.5" fill="currentColor"/><circle cx="7" cy="17" r="1.5" fill="currentColor"/><circle cx="17" cy="17" r="1.5" fill="currentColor"/><path d="M10 10l5 2-5 2z" fill="currentColor"/></svg>',
|
|
7044
7223
|
share: '<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="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg>',
|
|
@@ -7136,6 +7315,14 @@ function createDiagram(opts) {
|
|
|
7136
7315
|
resetViewportTransform();
|
|
7137
7316
|
}
|
|
7138
7317
|
function syncControls() {
|
|
7318
|
+
const pct = totalDurationMs > 0 ? sceneMs / totalDurationMs : 0;
|
|
7319
|
+
const clamped = Math.max(0, Math.min(1, pct));
|
|
7320
|
+
if (controlsScrubberFill) {
|
|
7321
|
+
controlsScrubberFill.style.width = `${clamped * 100}%`;
|
|
7322
|
+
}
|
|
7323
|
+
if (controlsScrubberThumb) {
|
|
7324
|
+
controlsScrubberThumb.style.left = `${clamped * 100}%`;
|
|
7325
|
+
}
|
|
7139
7326
|
if (controlsPlayButton) {
|
|
7140
7327
|
const playing = isPlaying;
|
|
7141
7328
|
controlsPlayButton.innerHTML = `${playing ? ICONS2.pause : ICONS2.play}<span class="markdy-btn-label">${playing ? "Pause" : "Play"}</span>`;
|
|
@@ -7150,14 +7337,22 @@ function createDiagram(opts) {
|
|
|
7150
7337
|
}
|
|
7151
7338
|
if (controlsSeekBar) {
|
|
7152
7339
|
controlsSeekBar.value = String(sceneMs / 1e3);
|
|
7153
|
-
|
|
7154
|
-
controlsSeekBar.style.setProperty("--seek-pct", `${pct}%`);
|
|
7340
|
+
controlsSeekBar.style.setProperty("--seek-pct", `${clamped * 100}%`);
|
|
7155
7341
|
}
|
|
7156
7342
|
if (controlsTimeEl) {
|
|
7157
7343
|
const cur = (sceneMs / 1e3).toFixed(1);
|
|
7158
7344
|
const tot = durationSeconds.toFixed(1);
|
|
7159
7345
|
controlsTimeEl.textContent = `${cur}s / ${tot}s`;
|
|
7160
7346
|
}
|
|
7347
|
+
if (controlsBeatChip && plan.beats.length > 1) {
|
|
7348
|
+
const currentSec = sceneMs / 1e3;
|
|
7349
|
+
const currentBeat = plan.beats.find((b) => currentSec >= b.start && currentSec < b.end) || plan.beats[plan.beats.length - 1];
|
|
7350
|
+
if (currentBeat) {
|
|
7351
|
+
const beatIdx = plan.beats.indexOf(currentBeat) + 1;
|
|
7352
|
+
controlsBeatChip.textContent = currentBeat.label ? `${beatIdx}. ${currentBeat.label}` : `Beat ${beatIdx}`;
|
|
7353
|
+
controlsBeatChip.title = `Current beat: ${currentBeat.label || currentBeat.name}`;
|
|
7354
|
+
}
|
|
7355
|
+
}
|
|
7161
7356
|
if (controlsFitButton) {
|
|
7162
7357
|
controlsFitButton.setAttribute("aria-pressed", fitViewActive ? "true" : "false");
|
|
7163
7358
|
}
|
|
@@ -7515,8 +7710,39 @@ function createDiagram(opts) {
|
|
|
7515
7710
|
});
|
|
7516
7711
|
toolbar.appendChild(button);
|
|
7517
7712
|
}
|
|
7518
|
-
function
|
|
7713
|
+
function mountScrubber(footerEl) {
|
|
7519
7714
|
if (!seekBar) return;
|
|
7715
|
+
controlsScrubber = document.createElement("div");
|
|
7716
|
+
controlsScrubber.className = "markdy-player-scrubber";
|
|
7717
|
+
controlsScrubber.setAttribute("role", "presentation");
|
|
7718
|
+
controlsScrubberTrack = document.createElement("div");
|
|
7719
|
+
controlsScrubberTrack.className = "markdy-player-scrubber-track";
|
|
7720
|
+
if (plan.beats.length > 1 && totalDurationMs > 0) {
|
|
7721
|
+
for (let i = 1; i < plan.beats.length; i++) {
|
|
7722
|
+
const beat = plan.beats[i];
|
|
7723
|
+
const tick = document.createElement("div");
|
|
7724
|
+
tick.className = "markdy-player-scrubber-tick";
|
|
7725
|
+
tick.style.left = `${beat.start / durationSeconds * 100}%`;
|
|
7726
|
+
tick.title = beat.label || beat.name;
|
|
7727
|
+
controlsScrubberTrack.appendChild(tick);
|
|
7728
|
+
}
|
|
7729
|
+
}
|
|
7730
|
+
controlsScrubberFill = document.createElement("div");
|
|
7731
|
+
controlsScrubberFill.className = "markdy-player-scrubber-fill";
|
|
7732
|
+
if (customColor) {
|
|
7733
|
+
controlsScrubberFill.style.background = customColor;
|
|
7734
|
+
}
|
|
7735
|
+
controlsScrubberTrack.appendChild(controlsScrubberFill);
|
|
7736
|
+
controlsScrubberThumb = document.createElement("div");
|
|
7737
|
+
controlsScrubberThumb.className = "markdy-player-scrubber-thumb";
|
|
7738
|
+
if (customColor) {
|
|
7739
|
+
controlsScrubberThumb.style.background = customColor;
|
|
7740
|
+
}
|
|
7741
|
+
controlsScrubberTrack.appendChild(controlsScrubberThumb);
|
|
7742
|
+
controlsScrubberTooltip = document.createElement("div");
|
|
7743
|
+
controlsScrubberTooltip.className = "markdy-player-scrubber-tooltip";
|
|
7744
|
+
controlsScrubberTooltip.textContent = "0.0s";
|
|
7745
|
+
controlsScrubber.appendChild(controlsScrubberTooltip);
|
|
7520
7746
|
controlsSeekBar = document.createElement("input");
|
|
7521
7747
|
controlsSeekBar.className = "markdy-control-seek";
|
|
7522
7748
|
controlsSeekBar.type = "range";
|
|
@@ -7525,12 +7751,28 @@ function createDiagram(opts) {
|
|
|
7525
7751
|
controlsSeekBar.step = "0.01";
|
|
7526
7752
|
controlsSeekBar.value = String(sceneMs / 1e3);
|
|
7527
7753
|
controlsSeekBar.setAttribute("aria-label", "Seek diagram timeline");
|
|
7528
|
-
controlsSeekBar.addEventListener("input", () =>
|
|
7529
|
-
|
|
7530
|
-
|
|
7531
|
-
|
|
7532
|
-
|
|
7533
|
-
|
|
7754
|
+
controlsSeekBar.addEventListener("input", () => {
|
|
7755
|
+
const val = Number(controlsSeekBar?.value ?? 0);
|
|
7756
|
+
diagram.seek(val);
|
|
7757
|
+
});
|
|
7758
|
+
controlsScrubber.addEventListener("pointermove", (e) => {
|
|
7759
|
+
if (!controlsScrubber || !controlsScrubberTooltip) return;
|
|
7760
|
+
const rect = controlsScrubber.getBoundingClientRect();
|
|
7761
|
+
if (rect.width <= 0) return;
|
|
7762
|
+
const ratio = Math.max(0, Math.min(1, (e.clientX - rect.left) / rect.width));
|
|
7763
|
+
const hoverSec = ratio * durationSeconds;
|
|
7764
|
+
controlsScrubberTooltip.textContent = `${hoverSec.toFixed(1)}s`;
|
|
7765
|
+
controlsScrubberTooltip.style.left = `${ratio * 100}%`;
|
|
7766
|
+
controlsScrubberTooltip.style.opacity = "1";
|
|
7767
|
+
});
|
|
7768
|
+
controlsScrubber.addEventListener("pointerleave", () => {
|
|
7769
|
+
if (controlsScrubberTooltip) {
|
|
7770
|
+
controlsScrubberTooltip.style.opacity = "0";
|
|
7771
|
+
}
|
|
7772
|
+
});
|
|
7773
|
+
controlsScrubber.appendChild(controlsScrubberTrack);
|
|
7774
|
+
controlsScrubber.appendChild(controlsSeekBar);
|
|
7775
|
+
footerEl.insertBefore(controlsScrubber, footerEl.firstChild);
|
|
7534
7776
|
}
|
|
7535
7777
|
function mountSpeedControls(toolbar) {
|
|
7536
7778
|
if (!speedControls) return;
|
|
@@ -7828,12 +8070,14 @@ function createDiagram(opts) {
|
|
|
7828
8070
|
const button = makeControlButton("Full", "Toggle fullscreen view", ICONS2.fullscreen);
|
|
7829
8071
|
button.className = "markdy-control-fullscreen";
|
|
7830
8072
|
button.setAttribute("aria-pressed", "false");
|
|
8073
|
+
button.style.touchAction = "manipulation";
|
|
7831
8074
|
const host = container;
|
|
7832
8075
|
let isPseudoFull = false;
|
|
7833
8076
|
let originalBodyOverflow = null;
|
|
8077
|
+
let originalHtmlOverflow = null;
|
|
7834
8078
|
function isNativeFullscreenSupported() {
|
|
7835
8079
|
if (typeof document === "undefined") return false;
|
|
7836
|
-
if (typeof navigator !== "undefined" && /iPhone|iPod/i.test(navigator.userAgent)) {
|
|
8080
|
+
if (typeof navigator !== "undefined" && (/iPhone|iPad|iPod/i.test(navigator.userAgent) || navigator.platform === "MacIntel" && (navigator.maxTouchPoints || 0) > 1)) {
|
|
7837
8081
|
return false;
|
|
7838
8082
|
}
|
|
7839
8083
|
return Boolean(
|
|
@@ -7844,22 +8088,34 @@ function createDiagram(opts) {
|
|
|
7844
8088
|
const isFull = typeof explicitFull === "boolean" ? explicitFull : isPseudoFull || document.fullscreenElement === host || document.fullscreenElement === viewport || document.webkitFullscreenElement === host || document.webkitFullscreenElement === viewport || document.mozFullScreenElement === host || document.msFullscreenElement === host;
|
|
7845
8089
|
button.setAttribute("aria-pressed", isFull ? "true" : "false");
|
|
7846
8090
|
button.title = isFull ? "Exit fullscreen" : "Toggle fullscreen view";
|
|
7847
|
-
button.innerHTML = isFull ? `${ICONS2.
|
|
8091
|
+
button.innerHTML = isFull ? `${ICONS2.fullscreenExit}<span class="markdy-btn-label">Exit</span>` : `${ICONS2.fullscreen}<span class="markdy-btn-label">Full</span>`;
|
|
7848
8092
|
if (isFull) {
|
|
7849
8093
|
host.classList.add("markdy-fullscreen-host");
|
|
7850
8094
|
if (isPseudoFull) {
|
|
7851
8095
|
host.classList.add("markdy--pseudo-fullscreen");
|
|
7852
|
-
if (typeof document !== "undefined"
|
|
7853
|
-
|
|
7854
|
-
|
|
8096
|
+
if (typeof document !== "undefined") {
|
|
8097
|
+
if (document.documentElement && originalHtmlOverflow === null) {
|
|
8098
|
+
originalHtmlOverflow = document.documentElement.style.overflow;
|
|
8099
|
+
document.documentElement.style.overflow = "hidden";
|
|
8100
|
+
}
|
|
8101
|
+
if (document.body && originalBodyOverflow === null) {
|
|
8102
|
+
originalBodyOverflow = document.body.style.overflow;
|
|
8103
|
+
document.body.style.overflow = "hidden";
|
|
8104
|
+
}
|
|
7855
8105
|
}
|
|
7856
8106
|
}
|
|
7857
8107
|
} else {
|
|
7858
8108
|
host.classList.remove("markdy-fullscreen-host");
|
|
7859
8109
|
host.classList.remove("markdy--pseudo-fullscreen");
|
|
7860
|
-
if (typeof document !== "undefined"
|
|
7861
|
-
document.
|
|
7862
|
-
|
|
8110
|
+
if (typeof document !== "undefined") {
|
|
8111
|
+
if (document.documentElement && originalHtmlOverflow !== null) {
|
|
8112
|
+
document.documentElement.style.overflow = originalHtmlOverflow;
|
|
8113
|
+
originalHtmlOverflow = null;
|
|
8114
|
+
}
|
|
8115
|
+
if (document.body && originalBodyOverflow !== null) {
|
|
8116
|
+
document.body.style.overflow = originalBodyOverflow;
|
|
8117
|
+
originalBodyOverflow = null;
|
|
8118
|
+
}
|
|
7863
8119
|
}
|
|
7864
8120
|
}
|
|
7865
8121
|
requestAnimationFrame(() => {
|
|
@@ -7954,9 +8210,15 @@ function createDiagram(opts) {
|
|
|
7954
8210
|
document.removeEventListener("mozfullscreenchange", syncFullscreenState);
|
|
7955
8211
|
document.removeEventListener("MSFullscreenChange", syncFullscreenState);
|
|
7956
8212
|
window.removeEventListener("keydown", handleEscKey);
|
|
7957
|
-
if (
|
|
7958
|
-
document.
|
|
7959
|
-
|
|
8213
|
+
if (typeof document !== "undefined") {
|
|
8214
|
+
if (originalHtmlOverflow !== null && document.documentElement) {
|
|
8215
|
+
document.documentElement.style.overflow = originalHtmlOverflow;
|
|
8216
|
+
originalHtmlOverflow = null;
|
|
8217
|
+
}
|
|
8218
|
+
if (originalBodyOverflow !== null && document.body) {
|
|
8219
|
+
document.body.style.overflow = originalBodyOverflow;
|
|
8220
|
+
originalBodyOverflow = null;
|
|
8221
|
+
}
|
|
7960
8222
|
}
|
|
7961
8223
|
if (isPseudoFull) {
|
|
7962
8224
|
isPseudoFull = false;
|
|
@@ -8003,6 +8265,7 @@ function createDiagram(opts) {
|
|
|
8003
8265
|
display: "flex",
|
|
8004
8266
|
alignItems: "center",
|
|
8005
8267
|
justifyContent: "flex-start",
|
|
8268
|
+
width: "100%",
|
|
8006
8269
|
maxWidth: "100%",
|
|
8007
8270
|
border: "0",
|
|
8008
8271
|
borderRadius: "0",
|
|
@@ -8028,19 +8291,27 @@ function createDiagram(opts) {
|
|
|
8028
8291
|
]) {
|
|
8029
8292
|
toolbar.addEventListener(eventName, (event) => event.stopPropagation());
|
|
8030
8293
|
}
|
|
8294
|
+
if (seekBar) {
|
|
8295
|
+
mountScrubber(toolbar);
|
|
8296
|
+
}
|
|
8031
8297
|
const playbackGroup = document.createElement("div");
|
|
8032
8298
|
playbackGroup.className = "markdy-controls-group markdy-controls-playback";
|
|
8033
8299
|
mountPlayControl(playbackGroup);
|
|
8034
8300
|
mountBeatNavControls(playbackGroup, "prev");
|
|
8035
8301
|
mountBeatNavControls(playbackGroup, "next");
|
|
8036
8302
|
mountRestartControl(playbackGroup);
|
|
8037
|
-
|
|
8038
|
-
|
|
8039
|
-
|
|
8040
|
-
|
|
8041
|
-
|
|
8042
|
-
|
|
8303
|
+
controlsTimeEl = document.createElement("span");
|
|
8304
|
+
controlsTimeEl.className = "markdy-control-time";
|
|
8305
|
+
controlsTimeEl.textContent = `${(sceneMs / 1e3).toFixed(1)}s / ${durationSeconds.toFixed(1)}s`;
|
|
8306
|
+
playbackGroup.appendChild(controlsTimeEl);
|
|
8307
|
+
if (plan.beats.length > 1) {
|
|
8308
|
+
controlsBeatChip = document.createElement("span");
|
|
8309
|
+
controlsBeatChip.className = "markdy-player-beat-chip";
|
|
8310
|
+
const firstBeat = plan.beats[0];
|
|
8311
|
+
controlsBeatChip.textContent = firstBeat.label ? `1. ${firstBeat.label}` : "Beat 1";
|
|
8312
|
+
playbackGroup.appendChild(controlsBeatChip);
|
|
8043
8313
|
}
|
|
8314
|
+
if (playbackGroup.children.length > 0) toolbar.appendChild(playbackGroup);
|
|
8044
8315
|
const toolsGroup = document.createElement("div");
|
|
8045
8316
|
toolsGroup.className = "markdy-controls-group markdy-controls-tools";
|
|
8046
8317
|
if (speedControls) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markdy/renderer-dom",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.11",
|
|
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.11"
|
|
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.11"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|
|
59
59
|
"build": "tsup",
|