@markdy/renderer-dom 1.4.19 → 1.4.21

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 +38 -15
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -4335,6 +4335,7 @@ function ensureSceneStyles(doc) {
4335
4335
  :root[data-theme="dark"] .markdy-diagram-root,
4336
4336
  .theme-dark .markdy-diagram-root,
4337
4337
  .dark .markdy-diagram-root {
4338
+ background: var(--md-canvas, #090b1a);
4338
4339
  border-color: var(--md-card-border, rgba(255, 255, 255, 0.09));
4339
4340
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.2);
4340
4341
  }
@@ -6681,7 +6682,9 @@ function createDiagram(opts) {
6681
6682
  display: "flex",
6682
6683
  flexDirection: "column",
6683
6684
  boxSizing: "border-box",
6684
- width: "100%"
6685
+ width: "100%",
6686
+ background: plan.theme.canvas,
6687
+ color: plan.theme.text
6685
6688
  });
6686
6689
  if (container.style.aspectRatio) container.style.aspectRatio = "unset";
6687
6690
  const initialBounds = computeDiagramContentBounds(plan, contentPadding !== void 0 ? { padding: contentPadding } : void 0);
@@ -7511,6 +7514,11 @@ function createDiagram(opts) {
7511
7514
  const newTheme = typeof theme === "string" ? resolveTheme2(theme) : theme;
7512
7515
  plan.theme = newTheme;
7513
7516
  applyThemeVariables(container, newTheme);
7517
+ container.style.background = newTheme.canvas;
7518
+ container.style.color = newTheme.text;
7519
+ applyThemeVariables(viewport, newTheme);
7520
+ viewport.style.background = newTheme.canvas;
7521
+ viewport.style.color = newTheme.text;
7514
7522
  applyThemeToScene(scene, newTheme);
7515
7523
  if (footer) {
7516
7524
  applyThemeVariables(footer, newTheme);
@@ -7673,6 +7681,8 @@ function createDiagram(opts) {
7673
7681
  if (viewport.parentNode === container) container.removeChild(viewport);
7674
7682
  }
7675
7683
  };
7684
+ let manualThemeOverride = false;
7685
+ let lastHostTheme = null;
7676
7686
  if (!hasExplicitTheme && typeof document !== "undefined") {
7677
7687
  const syncWithHost = () => {
7678
7688
  const currentDefaults = {
@@ -7680,6 +7690,15 @@ function createDiagram(opts) {
7680
7690
  dark: ast.meta.defaultThemes?.dark ?? optionsDefaultDark
7681
7691
  };
7682
7692
  const nextTheme = detectHostTheme(container, currentDefaults);
7693
+ if (lastHostTheme === null) {
7694
+ lastHostTheme = nextTheme;
7695
+ } else if (lastHostTheme !== nextTheme) {
7696
+ manualThemeOverride = false;
7697
+ lastHostTheme = nextTheme;
7698
+ }
7699
+ if (manualThemeOverride) {
7700
+ return;
7701
+ }
7683
7702
  diagram.setTheme(nextTheme);
7684
7703
  };
7685
7704
  const attributeFilter = [
@@ -7710,12 +7729,6 @@ function createDiagram(opts) {
7710
7729
  attributeFilter
7711
7730
  });
7712
7731
  }
7713
- if (container) {
7714
- hostThemeObserver.observe(container, {
7715
- attributes: true,
7716
- attributeFilter
7717
- });
7718
- }
7719
7732
  if (typeof window !== "undefined" && window.matchMedia) {
7720
7733
  colorSchemeQuery = window.matchMedia("(prefers-color-scheme: dark)");
7721
7734
  mediaQueryListener = syncWithHost;
@@ -8016,24 +8029,34 @@ function createDiagram(opts) {
8016
8029
  }
8017
8030
  function mountThemeControl(toolbar) {
8018
8031
  if (!themeButton) return;
8019
- const button = makeControlButton("Theme", "Toggle dark/light theme palette", ICONS2.theme);
8032
+ const button = makeControlButton("Theme", "Toggle theme palette", ICONS2.theme);
8020
8033
  button.className = "markdy-control-theme";
8021
8034
  button.addEventListener("click", () => {
8022
- const darkThemes = ["midnight", "blueprint", "graphite", "nebula", "terminal"];
8023
- const lightThemes = ["paper", "editorial", "sketchy", "ink", "doodle"];
8035
+ const ALL_THEMES = [
8036
+ "doodle",
8037
+ "paper",
8038
+ "editorial",
8039
+ "sketchy",
8040
+ "ink",
8041
+ "nebula",
8042
+ "midnight",
8043
+ "blueprint",
8044
+ "graphite",
8045
+ "terminal"
8046
+ ];
8024
8047
  const currentName = plan.theme.name || "paper";
8025
- const isDark = darkThemes.includes(currentName);
8026
- const targetThemes = isDark ? lightThemes : darkThemes;
8027
- const nextTheme = targetThemes[Math.floor(Math.random() * targetThemes.length)];
8048
+ const currentIndex = ALL_THEMES.indexOf(currentName);
8049
+ const nextTheme = ALL_THEMES[(currentIndex + 1) % ALL_THEMES.length];
8050
+ manualThemeOverride = true;
8028
8051
  flashControlState(button, {
8029
8052
  title: `Theme: ${nextTheme}`,
8030
- duration: 400
8053
+ duration: 900
8031
8054
  });
8032
8055
  diagram.setTheme(nextTheme);
8033
8056
  container.dispatchEvent(
8034
8057
  new CustomEvent("markdy-theme-switch", {
8035
8058
  bubbles: true,
8036
- detail: { theme: nextTheme, isDark: !isDark }
8059
+ detail: { theme: nextTheme }
8037
8060
  })
8038
8061
  );
8039
8062
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markdy/renderer-dom",
3
- "version": "1.4.19",
3
+ "version": "1.4.21",
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",
@@ -44,11 +44,11 @@
44
44
  "access": "public"
45
45
  },
46
46
  "dependencies": {
47
- "@markdy/core": "^1.4.19",
47
+ "@markdy/core": "^1.4.21",
48
48
  "html2canvas": "^1.4.1"
49
49
  },
50
50
  "devDependencies": {
51
- "@markdy/stdlib-systems": "^1.4.19",
51
+ "@markdy/stdlib-systems": "^1.4.21",
52
52
  "jsdom": "^29.1.1",
53
53
  "tsup": "^8.5.1",
54
54
  "typescript": "^5.9.3",