@markdy/renderer-dom 1.4.20 → 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 +36 -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,8 +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;
7514
7519
  applyThemeVariables(viewport, newTheme);
7515
7520
  viewport.style.background = newTheme.canvas;
7521
+ viewport.style.color = newTheme.text;
7516
7522
  applyThemeToScene(scene, newTheme);
7517
7523
  if (footer) {
7518
7524
  applyThemeVariables(footer, newTheme);
@@ -7675,6 +7681,8 @@ function createDiagram(opts) {
7675
7681
  if (viewport.parentNode === container) container.removeChild(viewport);
7676
7682
  }
7677
7683
  };
7684
+ let manualThemeOverride = false;
7685
+ let lastHostTheme = null;
7678
7686
  if (!hasExplicitTheme && typeof document !== "undefined") {
7679
7687
  const syncWithHost = () => {
7680
7688
  const currentDefaults = {
@@ -7682,6 +7690,15 @@ function createDiagram(opts) {
7682
7690
  dark: ast.meta.defaultThemes?.dark ?? optionsDefaultDark
7683
7691
  };
7684
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
+ }
7685
7702
  diagram.setTheme(nextTheme);
7686
7703
  };
7687
7704
  const attributeFilter = [
@@ -7712,12 +7729,6 @@ function createDiagram(opts) {
7712
7729
  attributeFilter
7713
7730
  });
7714
7731
  }
7715
- if (container) {
7716
- hostThemeObserver.observe(container, {
7717
- attributes: true,
7718
- attributeFilter
7719
- });
7720
- }
7721
7732
  if (typeof window !== "undefined" && window.matchMedia) {
7722
7733
  colorSchemeQuery = window.matchMedia("(prefers-color-scheme: dark)");
7723
7734
  mediaQueryListener = syncWithHost;
@@ -8018,24 +8029,34 @@ function createDiagram(opts) {
8018
8029
  }
8019
8030
  function mountThemeControl(toolbar) {
8020
8031
  if (!themeButton) return;
8021
- const button = makeControlButton("Theme", "Toggle dark/light theme palette", ICONS2.theme);
8032
+ const button = makeControlButton("Theme", "Toggle theme palette", ICONS2.theme);
8022
8033
  button.className = "markdy-control-theme";
8023
8034
  button.addEventListener("click", () => {
8024
- const darkThemes = ["midnight", "blueprint", "graphite", "nebula", "terminal"];
8025
- 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
+ ];
8026
8047
  const currentName = plan.theme.name || "paper";
8027
- const isDark = darkThemes.includes(currentName);
8028
- const targetThemes = isDark ? lightThemes : darkThemes;
8029
- 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;
8030
8051
  flashControlState(button, {
8031
8052
  title: `Theme: ${nextTheme}`,
8032
- duration: 400
8053
+ duration: 900
8033
8054
  });
8034
8055
  diagram.setTheme(nextTheme);
8035
8056
  container.dispatchEvent(
8036
8057
  new CustomEvent("markdy-theme-switch", {
8037
8058
  bubbles: true,
8038
- detail: { theme: nextTheme, isDark: !isDark }
8059
+ detail: { theme: nextTheme }
8039
8060
  })
8040
8061
  );
8041
8062
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markdy/renderer-dom",
3
- "version": "1.4.20",
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.20",
47
+ "@markdy/core": "^1.4.21",
48
48
  "html2canvas": "^1.4.1"
49
49
  },
50
50
  "devDependencies": {
51
- "@markdy/stdlib-systems": "^1.4.20",
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",