@markdy/renderer-dom 1.4.14 → 1.4.16
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 +167 -56
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -3886,6 +3886,8 @@ function ensureSceneStyles(doc) {
|
|
|
3886
3886
|
position: relative;
|
|
3887
3887
|
pointer-events: auto;
|
|
3888
3888
|
isolation: isolate;
|
|
3889
|
+
overflow: hidden;
|
|
3890
|
+
text-overflow: ellipsis;
|
|
3889
3891
|
}
|
|
3890
3892
|
.markdy-controls button:hover:not([aria-pressed="true"]) {
|
|
3891
3893
|
position: relative;
|
|
@@ -3954,10 +3956,6 @@ function ensureSceneStyles(doc) {
|
|
|
3954
3956
|
min-width: 25px !important;
|
|
3955
3957
|
justify-content: center !important;
|
|
3956
3958
|
}
|
|
3957
|
-
.markdy-controls-secondary,
|
|
3958
|
-
.markdy-control-divider-secondary {
|
|
3959
|
-
display: none !important;
|
|
3960
|
-
}
|
|
3961
3959
|
.markdy-speed-group {
|
|
3962
3960
|
display: none !important;
|
|
3963
3961
|
}
|
|
@@ -3969,19 +3967,13 @@ function ensureSceneStyles(doc) {
|
|
|
3969
3967
|
}
|
|
3970
3968
|
.markdy-badge {
|
|
3971
3969
|
font-size: 9px !important;
|
|
3972
|
-
opacity: 0.
|
|
3973
|
-
}
|
|
3974
|
-
.markdy-badge-prefix {
|
|
3975
|
-
display: none !important;
|
|
3976
|
-
}
|
|
3977
|
-
}
|
|
3978
|
-
@media (max-width: 440px) {
|
|
3979
|
-
.markdy-badge {
|
|
3980
|
-
display: none !important;
|
|
3970
|
+
opacity: 0.7;
|
|
3981
3971
|
}
|
|
3982
3972
|
}
|
|
3983
3973
|
@media (max-width: 360px) {
|
|
3984
|
-
.markdy-control-reset
|
|
3974
|
+
.markdy-control-reset-view,
|
|
3975
|
+
.markdy-control-share,
|
|
3976
|
+
.markdy-control-code {
|
|
3985
3977
|
display: none !important;
|
|
3986
3978
|
}
|
|
3987
3979
|
}
|
|
@@ -3996,27 +3988,21 @@ function ensureSceneStyles(doc) {
|
|
|
3996
3988
|
min-width: 25px !important;
|
|
3997
3989
|
justify-content: center !important;
|
|
3998
3990
|
}
|
|
3999
|
-
.markdy-controls-secondary,
|
|
4000
|
-
.markdy-control-divider-secondary {
|
|
4001
|
-
display: none !important;
|
|
4002
|
-
}
|
|
4003
3991
|
.markdy-speed-group {
|
|
4004
3992
|
display: none !important;
|
|
4005
3993
|
}
|
|
4006
3994
|
.markdy-controls {
|
|
4007
3995
|
gap: 4px !important;
|
|
4008
3996
|
}
|
|
4009
|
-
.markdy-badge-prefix {
|
|
4010
|
-
display: none !important;
|
|
4011
|
-
}
|
|
4012
|
-
}
|
|
4013
|
-
@container markdy-root (max-width: 440px) {
|
|
4014
3997
|
.markdy-badge {
|
|
4015
|
-
|
|
3998
|
+
font-size: 9px !important;
|
|
3999
|
+
opacity: 0.7;
|
|
4016
4000
|
}
|
|
4017
4001
|
}
|
|
4018
4002
|
@container markdy-root (max-width: 360px) {
|
|
4019
|
-
.markdy-control-reset
|
|
4003
|
+
.markdy-control-reset-view,
|
|
4004
|
+
.markdy-control-share,
|
|
4005
|
+
.markdy-control-code {
|
|
4020
4006
|
display: none !important;
|
|
4021
4007
|
}
|
|
4022
4008
|
}
|
|
@@ -4051,10 +4037,32 @@ function ensureSceneStyles(doc) {
|
|
|
4051
4037
|
color: #ffffff !important;
|
|
4052
4038
|
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12) !important;
|
|
4053
4039
|
}
|
|
4040
|
+
@keyframes markdy-spin {
|
|
4041
|
+
from {
|
|
4042
|
+
transform: rotate(0deg);
|
|
4043
|
+
}
|
|
4044
|
+
to {
|
|
4045
|
+
transform: rotate(360deg);
|
|
4046
|
+
}
|
|
4047
|
+
}
|
|
4048
|
+
.markdy-icon-spin {
|
|
4049
|
+
animation: markdy-spin 0.8s linear infinite;
|
|
4050
|
+
}
|
|
4054
4051
|
.markdy-btn-flashed {
|
|
4055
|
-
background: rgba(
|
|
4056
|
-
color: #
|
|
4052
|
+
background: rgba(16, 185, 129, 0.12) !important;
|
|
4053
|
+
color: #10b981 !important;
|
|
4054
|
+
border-color: rgba(16, 185, 129, 0.4) !important;
|
|
4055
|
+
}
|
|
4056
|
+
.markdy-btn-busy {
|
|
4057
|
+
opacity: 0.85;
|
|
4058
|
+
cursor: wait !important;
|
|
4057
4059
|
border-color: #2563eb !important;
|
|
4060
|
+
color: #2563eb !important;
|
|
4061
|
+
}
|
|
4062
|
+
.markdy-btn-failed {
|
|
4063
|
+
background: rgba(239, 68, 68, 0.12) !important;
|
|
4064
|
+
color: #ef4444 !important;
|
|
4065
|
+
border-color: rgba(239, 68, 68, 0.4) !important;
|
|
4058
4066
|
}
|
|
4059
4067
|
/* \u2500\u2500 Code panel overlay \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
4060
4068
|
.markdy-code-panel-overlay {
|
|
@@ -7214,7 +7222,8 @@ function createDiagram(opts) {
|
|
|
7214
7222
|
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>',
|
|
7215
7223
|
code: '<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"><polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/></svg>',
|
|
7216
7224
|
theme: '<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="9"/><path d="M12 3v18"/><path d="M12 3a9 9 0 0 1 0 18z" fill="currentColor"/></svg>',
|
|
7217
|
-
check: '<svg class="markdy-icon" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="#10b981" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>'
|
|
7225
|
+
check: '<svg class="markdy-icon" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="#10b981" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>',
|
|
7226
|
+
spinner: '<svg class="markdy-icon markdy-icon-spin" 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 12a9 9 0 1 1-6.219-8.56"/></svg>'
|
|
7218
7227
|
};
|
|
7219
7228
|
function applyViewportTransform() {
|
|
7220
7229
|
viewportTransform.style.transform = `translate(${viewportPanX}px, ${viewportPanY}px) scale(${viewportScale})`;
|
|
@@ -7729,20 +7738,89 @@ function createDiagram(opts) {
|
|
|
7729
7738
|
return button;
|
|
7730
7739
|
});
|
|
7731
7740
|
}
|
|
7741
|
+
function flashControlState(button, options) {
|
|
7742
|
+
const existingTimer = button._flashTimer;
|
|
7743
|
+
if (existingTimer) {
|
|
7744
|
+
clearTimeout(existingTimer);
|
|
7745
|
+
delete button._flashTimer;
|
|
7746
|
+
}
|
|
7747
|
+
if (!button.dataset.origTitle) {
|
|
7748
|
+
button.dataset.origTitle = button.title || "";
|
|
7749
|
+
}
|
|
7750
|
+
if (!button.dataset.origAria) {
|
|
7751
|
+
button.dataset.origAria = button.getAttribute("aria-label") || "";
|
|
7752
|
+
}
|
|
7753
|
+
const iconContainer = button.querySelector("svg.markdy-icon");
|
|
7754
|
+
const labelContainer = button.querySelector(".markdy-btn-label");
|
|
7755
|
+
if (iconContainer && !button.dataset.origIcon) {
|
|
7756
|
+
button.dataset.origIcon = iconContainer.outerHTML;
|
|
7757
|
+
}
|
|
7758
|
+
if (labelContainer && button.dataset.origLabel === void 0) {
|
|
7759
|
+
button.dataset.origLabel = labelContainer.textContent || "";
|
|
7760
|
+
}
|
|
7761
|
+
if (options.icon && iconContainer) {
|
|
7762
|
+
const temp = document.createElement("div");
|
|
7763
|
+
temp.innerHTML = options.icon.trim();
|
|
7764
|
+
const newIcon = temp.firstElementChild;
|
|
7765
|
+
if (newIcon) {
|
|
7766
|
+
iconContainer.replaceWith(newIcon);
|
|
7767
|
+
}
|
|
7768
|
+
}
|
|
7769
|
+
if (options.label !== void 0 && labelContainer) {
|
|
7770
|
+
labelContainer.textContent = options.label;
|
|
7771
|
+
}
|
|
7772
|
+
if (options.title) {
|
|
7773
|
+
button.title = options.title;
|
|
7774
|
+
button.setAttribute("aria-label", options.title);
|
|
7775
|
+
}
|
|
7776
|
+
button.classList.remove("markdy-btn-flashed", "markdy-btn-busy", "markdy-btn-failed");
|
|
7777
|
+
const activeClass = options.stateClass ?? (options.busy ? "markdy-btn-busy" : "markdy-btn-flashed");
|
|
7778
|
+
button.classList.add(activeClass);
|
|
7779
|
+
const reset = () => {
|
|
7780
|
+
if (button._flashTimer) {
|
|
7781
|
+
clearTimeout(button._flashTimer);
|
|
7782
|
+
delete button._flashTimer;
|
|
7783
|
+
}
|
|
7784
|
+
button.classList.remove("markdy-btn-flashed", "markdy-btn-busy", "markdy-btn-failed");
|
|
7785
|
+
if (button.dataset.origTitle !== void 0) {
|
|
7786
|
+
button.title = button.dataset.origTitle;
|
|
7787
|
+
delete button.dataset.origTitle;
|
|
7788
|
+
}
|
|
7789
|
+
if (button.dataset.origAria !== void 0) {
|
|
7790
|
+
button.setAttribute("aria-label", button.dataset.origAria);
|
|
7791
|
+
delete button.dataset.origAria;
|
|
7792
|
+
}
|
|
7793
|
+
const currentIcon = button.querySelector("svg.markdy-icon");
|
|
7794
|
+
if (currentIcon && button.dataset.origIcon) {
|
|
7795
|
+
const temp = document.createElement("div");
|
|
7796
|
+
temp.innerHTML = button.dataset.origIcon.trim();
|
|
7797
|
+
const origIconEl = temp.firstElementChild;
|
|
7798
|
+
if (origIconEl) currentIcon.replaceWith(origIconEl);
|
|
7799
|
+
delete button.dataset.origIcon;
|
|
7800
|
+
}
|
|
7801
|
+
const currentLabel = button.querySelector(".markdy-btn-label");
|
|
7802
|
+
if (currentLabel && button.dataset.origLabel !== void 0) {
|
|
7803
|
+
currentLabel.textContent = button.dataset.origLabel;
|
|
7804
|
+
delete button.dataset.origLabel;
|
|
7805
|
+
}
|
|
7806
|
+
};
|
|
7807
|
+
if (options.duration && options.duration > 0) {
|
|
7808
|
+
button._flashTimer = setTimeout(reset, options.duration);
|
|
7809
|
+
}
|
|
7810
|
+
return reset;
|
|
7811
|
+
}
|
|
7732
7812
|
function flashControlLabel(button, message) {
|
|
7733
|
-
const originalHtml = button.dataset.originalHtml ?? button.innerHTML;
|
|
7734
|
-
button.dataset.originalHtml = originalHtml;
|
|
7735
7813
|
const isSuccess = !message.toLowerCase().includes("fail");
|
|
7736
|
-
button
|
|
7737
|
-
|
|
7738
|
-
|
|
7739
|
-
|
|
7740
|
-
|
|
7741
|
-
|
|
7742
|
-
}
|
|
7814
|
+
flashControlState(button, {
|
|
7815
|
+
icon: isSuccess ? ICONS2.check : void 0,
|
|
7816
|
+
label: message,
|
|
7817
|
+
title: message,
|
|
7818
|
+
stateClass: isSuccess ? "markdy-btn-flashed" : "markdy-btn-failed",
|
|
7819
|
+
duration: 1500
|
|
7820
|
+
});
|
|
7743
7821
|
}
|
|
7744
7822
|
function downloadFile(filename, contents, type) {
|
|
7745
|
-
const blob = new Blob([contents], { type });
|
|
7823
|
+
const blob = contents instanceof Blob ? contents : new Blob([contents], { type });
|
|
7746
7824
|
const url = URL.createObjectURL(blob);
|
|
7747
7825
|
const link = document.createElement("a");
|
|
7748
7826
|
link.href = url;
|
|
@@ -7766,10 +7844,20 @@ function createDiagram(opts) {
|
|
|
7766
7844
|
const svg = exportDiagramAsVectorSvg(container);
|
|
7767
7845
|
const name = (plan.title || "markdy-diagram").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
7768
7846
|
downloadFile(`${name || "markdy-diagram"}.svg`, svg, "image/svg+xml");
|
|
7769
|
-
|
|
7847
|
+
flashControlState(button, {
|
|
7848
|
+
icon: ICONS2.check,
|
|
7849
|
+
label: "Saved",
|
|
7850
|
+
title: "SVG exported successfully",
|
|
7851
|
+
duration: 1500
|
|
7852
|
+
});
|
|
7770
7853
|
} catch (error) {
|
|
7771
7854
|
onWarning({ severity: "warning", message: `SVG export failed: ${String(error)}`, line: 0 });
|
|
7772
|
-
|
|
7855
|
+
flashControlState(button, {
|
|
7856
|
+
label: "Failed",
|
|
7857
|
+
title: "SVG export failed",
|
|
7858
|
+
stateClass: "markdy-btn-failed",
|
|
7859
|
+
duration: 2e3
|
|
7860
|
+
});
|
|
7773
7861
|
} finally {
|
|
7774
7862
|
diagram.seek(resumeAt / 1e3);
|
|
7775
7863
|
if (wasPlaying) diagram.play();
|
|
@@ -7782,27 +7870,37 @@ function createDiagram(opts) {
|
|
|
7782
7870
|
const button = makeControlButton("GIF", "Export diagram as animated GIF", ICONS2.gif);
|
|
7783
7871
|
button.className = "markdy-control-gif";
|
|
7784
7872
|
let exporting = false;
|
|
7873
|
+
let cancelBusy = null;
|
|
7785
7874
|
button.addEventListener("click", async () => {
|
|
7786
7875
|
if (exporting) return;
|
|
7787
7876
|
exporting = true;
|
|
7788
|
-
flashControlLabel(button, "Recording...");
|
|
7789
7877
|
button.setAttribute("disabled", "true");
|
|
7878
|
+
cancelBusy = flashControlState(button, {
|
|
7879
|
+
icon: ICONS2.spinner,
|
|
7880
|
+
label: "Recording...",
|
|
7881
|
+
title: "Recording animated GIF...",
|
|
7882
|
+
busy: true
|
|
7883
|
+
});
|
|
7790
7884
|
try {
|
|
7791
7885
|
const blob = await diagram.exportGif();
|
|
7792
7886
|
const name = (plan.title || "markdy-diagram").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
7793
|
-
|
|
7794
|
-
|
|
7795
|
-
|
|
7796
|
-
|
|
7797
|
-
|
|
7798
|
-
|
|
7799
|
-
|
|
7800
|
-
|
|
7801
|
-
URL.revokeObjectURL(url);
|
|
7802
|
-
flashControlLabel(button, "Saved");
|
|
7887
|
+
downloadFile(`${name || "markdy-diagram"}.gif`, blob, "image/gif");
|
|
7888
|
+
cancelBusy?.();
|
|
7889
|
+
flashControlState(button, {
|
|
7890
|
+
icon: ICONS2.check,
|
|
7891
|
+
label: "Saved",
|
|
7892
|
+
title: "GIF exported successfully",
|
|
7893
|
+
duration: 1500
|
|
7894
|
+
});
|
|
7803
7895
|
} catch (error) {
|
|
7804
7896
|
onWarning({ severity: "warning", message: `GIF export failed: ${String(error)}`, line: 0 });
|
|
7805
|
-
|
|
7897
|
+
cancelBusy?.();
|
|
7898
|
+
flashControlState(button, {
|
|
7899
|
+
label: "Failed",
|
|
7900
|
+
title: "GIF export failed",
|
|
7901
|
+
stateClass: "markdy-btn-failed",
|
|
7902
|
+
duration: 2e3
|
|
7903
|
+
});
|
|
7806
7904
|
} finally {
|
|
7807
7905
|
exporting = false;
|
|
7808
7906
|
button.removeAttribute("disabled");
|
|
@@ -7819,10 +7917,20 @@ function createDiagram(opts) {
|
|
|
7819
7917
|
const hash = await compressMarkdyToUrlHash(code);
|
|
7820
7918
|
const base = shareUrl ?? MARKDY_PLAYGROUND_URL;
|
|
7821
7919
|
await navigator.clipboard.writeText(`${base}#code=${hash}`);
|
|
7822
|
-
|
|
7920
|
+
flashControlState(button, {
|
|
7921
|
+
icon: ICONS2.check,
|
|
7922
|
+
label: "Copied",
|
|
7923
|
+
title: "Share link copied to clipboard",
|
|
7924
|
+
duration: 1500
|
|
7925
|
+
});
|
|
7823
7926
|
} catch (error) {
|
|
7824
7927
|
onWarning({ severity: "warning", message: `Share link failed: ${String(error)}`, line: 0 });
|
|
7825
|
-
|
|
7928
|
+
flashControlState(button, {
|
|
7929
|
+
label: "Failed",
|
|
7930
|
+
title: "Failed to copy share link",
|
|
7931
|
+
stateClass: "markdy-btn-failed",
|
|
7932
|
+
duration: 2e3
|
|
7933
|
+
});
|
|
7826
7934
|
}
|
|
7827
7935
|
});
|
|
7828
7936
|
toolbar.appendChild(button);
|
|
@@ -7838,7 +7946,10 @@ function createDiagram(opts) {
|
|
|
7838
7946
|
const isDark = darkThemes.includes(currentName);
|
|
7839
7947
|
const targetThemes = isDark ? lightThemes : darkThemes;
|
|
7840
7948
|
const nextTheme = targetThemes[Math.floor(Math.random() * targetThemes.length)];
|
|
7841
|
-
|
|
7949
|
+
flashControlState(button, {
|
|
7950
|
+
title: `Theme: ${nextTheme}`,
|
|
7951
|
+
duration: 400
|
|
7952
|
+
});
|
|
7842
7953
|
diagram.setTheme(nextTheme);
|
|
7843
7954
|
container.dispatchEvent(
|
|
7844
7955
|
new CustomEvent("markdy-theme-switch", {
|
|
@@ -7883,7 +7994,7 @@ function createDiagram(opts) {
|
|
|
7883
7994
|
}
|
|
7884
7995
|
function mountCodeControl(toolbar) {
|
|
7885
7996
|
if (!codeButton) return;
|
|
7886
|
-
const button = makeControlButton("Code", "View MarkdyScript source");
|
|
7997
|
+
const button = makeControlButton("Code", "View MarkdyScript source", ICONS2.code);
|
|
7887
7998
|
button.className = "markdy-control-code";
|
|
7888
7999
|
button.setAttribute("aria-haspopup", "dialog");
|
|
7889
8000
|
button.setAttribute("aria-expanded", "false");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markdy/renderer-dom",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.16",
|
|
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.16"
|
|
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.16"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|
|
59
59
|
"build": "tsup",
|