@markdy/renderer-dom 1.4.15 → 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.
Files changed (2) hide show
  1. package/dist/index.js +158 -31
  2. 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;
@@ -4035,10 +4037,32 @@ function ensureSceneStyles(doc) {
4035
4037
  color: #ffffff !important;
4036
4038
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12) !important;
4037
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
+ }
4038
4051
  .markdy-btn-flashed {
4039
- background: rgba(37, 99, 235, 0.15) !important;
4040
- color: #2563eb !important;
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;
4041
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;
4042
4066
  }
4043
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 */
4044
4068
  .markdy-code-panel-overlay {
@@ -7198,7 +7222,8 @@ function createDiagram(opts) {
7198
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>',
7199
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>',
7200
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>',
7201
- 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>'
7202
7227
  };
7203
7228
  function applyViewportTransform() {
7204
7229
  viewportTransform.style.transform = `translate(${viewportPanX}px, ${viewportPanY}px) scale(${viewportScale})`;
@@ -7713,20 +7738,89 @@ function createDiagram(opts) {
7713
7738
  return button;
7714
7739
  });
7715
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
+ }
7716
7812
  function flashControlLabel(button, message) {
7717
- const originalHtml = button.dataset.originalHtml ?? button.innerHTML;
7718
- button.dataset.originalHtml = originalHtml;
7719
7813
  const isSuccess = !message.toLowerCase().includes("fail");
7720
- button.innerHTML = isSuccess ? `${ICONS2.check}<span class="markdy-btn-label">${message}</span>` : `<span class="markdy-btn-label">${message}</span>`;
7721
- button.classList.add("markdy-btn-flashed");
7722
- setTimeout(() => {
7723
- button.innerHTML = button.dataset.originalHtml ?? originalHtml;
7724
- delete button.dataset.originalHtml;
7725
- button.classList.remove("markdy-btn-flashed");
7726
- }, 1500);
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
+ });
7727
7821
  }
7728
7822
  function downloadFile(filename, contents, type) {
7729
- const blob = new Blob([contents], { type });
7823
+ const blob = contents instanceof Blob ? contents : new Blob([contents], { type });
7730
7824
  const url = URL.createObjectURL(blob);
7731
7825
  const link = document.createElement("a");
7732
7826
  link.href = url;
@@ -7750,10 +7844,20 @@ function createDiagram(opts) {
7750
7844
  const svg = exportDiagramAsVectorSvg(container);
7751
7845
  const name = (plan.title || "markdy-diagram").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
7752
7846
  downloadFile(`${name || "markdy-diagram"}.svg`, svg, "image/svg+xml");
7753
- flashControlLabel(button, "Saved");
7847
+ flashControlState(button, {
7848
+ icon: ICONS2.check,
7849
+ label: "Saved",
7850
+ title: "SVG exported successfully",
7851
+ duration: 1500
7852
+ });
7754
7853
  } catch (error) {
7755
7854
  onWarning({ severity: "warning", message: `SVG export failed: ${String(error)}`, line: 0 });
7756
- flashControlLabel(button, "Failed");
7855
+ flashControlState(button, {
7856
+ label: "Failed",
7857
+ title: "SVG export failed",
7858
+ stateClass: "markdy-btn-failed",
7859
+ duration: 2e3
7860
+ });
7757
7861
  } finally {
7758
7862
  diagram.seek(resumeAt / 1e3);
7759
7863
  if (wasPlaying) diagram.play();
@@ -7766,27 +7870,37 @@ function createDiagram(opts) {
7766
7870
  const button = makeControlButton("GIF", "Export diagram as animated GIF", ICONS2.gif);
7767
7871
  button.className = "markdy-control-gif";
7768
7872
  let exporting = false;
7873
+ let cancelBusy = null;
7769
7874
  button.addEventListener("click", async () => {
7770
7875
  if (exporting) return;
7771
7876
  exporting = true;
7772
- flashControlLabel(button, "Recording...");
7773
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
+ });
7774
7884
  try {
7775
7885
  const blob = await diagram.exportGif();
7776
7886
  const name = (plan.title || "markdy-diagram").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
7777
- const url = URL.createObjectURL(blob);
7778
- const link = document.createElement("a");
7779
- link.href = url;
7780
- link.download = `${name || "markdy-diagram"}.gif`;
7781
- link.style.display = "none";
7782
- document.body.appendChild(link);
7783
- link.click();
7784
- document.body.removeChild(link);
7785
- URL.revokeObjectURL(url);
7786
- 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
+ });
7787
7895
  } catch (error) {
7788
7896
  onWarning({ severity: "warning", message: `GIF export failed: ${String(error)}`, line: 0 });
7789
- flashControlLabel(button, "Failed");
7897
+ cancelBusy?.();
7898
+ flashControlState(button, {
7899
+ label: "Failed",
7900
+ title: "GIF export failed",
7901
+ stateClass: "markdy-btn-failed",
7902
+ duration: 2e3
7903
+ });
7790
7904
  } finally {
7791
7905
  exporting = false;
7792
7906
  button.removeAttribute("disabled");
@@ -7803,10 +7917,20 @@ function createDiagram(opts) {
7803
7917
  const hash = await compressMarkdyToUrlHash(code);
7804
7918
  const base = shareUrl ?? MARKDY_PLAYGROUND_URL;
7805
7919
  await navigator.clipboard.writeText(`${base}#code=${hash}`);
7806
- flashControlLabel(button, "Copied");
7920
+ flashControlState(button, {
7921
+ icon: ICONS2.check,
7922
+ label: "Copied",
7923
+ title: "Share link copied to clipboard",
7924
+ duration: 1500
7925
+ });
7807
7926
  } catch (error) {
7808
7927
  onWarning({ severity: "warning", message: `Share link failed: ${String(error)}`, line: 0 });
7809
- flashControlLabel(button, "Failed");
7928
+ flashControlState(button, {
7929
+ label: "Failed",
7930
+ title: "Failed to copy share link",
7931
+ stateClass: "markdy-btn-failed",
7932
+ duration: 2e3
7933
+ });
7810
7934
  }
7811
7935
  });
7812
7936
  toolbar.appendChild(button);
@@ -7822,7 +7946,10 @@ function createDiagram(opts) {
7822
7946
  const isDark = darkThemes.includes(currentName);
7823
7947
  const targetThemes = isDark ? lightThemes : darkThemes;
7824
7948
  const nextTheme = targetThemes[Math.floor(Math.random() * targetThemes.length)];
7825
- flashControlLabel(button, nextTheme);
7949
+ flashControlState(button, {
7950
+ title: `Theme: ${nextTheme}`,
7951
+ duration: 400
7952
+ });
7826
7953
  diagram.setTheme(nextTheme);
7827
7954
  container.dispatchEvent(
7828
7955
  new CustomEvent("markdy-theme-switch", {
@@ -7867,7 +7994,7 @@ function createDiagram(opts) {
7867
7994
  }
7868
7995
  function mountCodeControl(toolbar) {
7869
7996
  if (!codeButton) return;
7870
- const button = makeControlButton("Code", "View MarkdyScript source");
7997
+ const button = makeControlButton("Code", "View MarkdyScript source", ICONS2.code);
7871
7998
  button.className = "markdy-control-code";
7872
7999
  button.setAttribute("aria-haspopup", "dialog");
7873
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.15",
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.15"
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.15"
56
+ "@markdy/stdlib-systems": "1.4.16"
57
57
  },
58
58
  "scripts": {
59
59
  "build": "tsup",