themed-markdown 0.1.6 → 0.1.8

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 CHANGED
@@ -527,10 +527,11 @@ function IndustryHtmlModal({ isOpen, onClose, htmlContent, theme: theme2 }) {
527
527
  }
528
528
 
529
529
  // industryMarkdown/components/IndustryLazyMermaidDiagram.tsx
530
- var import_lucide_react = require("lucide-react");
530
+ var import_lucide_react2 = require("lucide-react");
531
531
  var import_react4 = __toESM(require("react"));
532
532
 
533
533
  // industryMarkdown/components/IndustryMermaidDiagram.tsx
534
+ var import_lucide_react = require("lucide-react");
534
535
  var import_react3 = __toESM(require("react"));
535
536
  var getMermaidSync = () => {
536
537
  if (typeof window !== "undefined") {
@@ -548,14 +549,14 @@ function IndustryMermaidDiagram({
548
549
  onCopyError,
549
550
  onError,
550
551
  rootMargin = "200px",
551
- isModalMode = false,
552
- fitMode = "height"
552
+ isModalMode = false
553
553
  }) {
554
554
  const theme2 = themeOverride || theme;
555
555
  const [errorDetails, setErrorDetails] = import_react3.useState(null);
556
556
  const [isIntersecting, setIsIntersecting] = import_react3.useState(false);
557
557
  const [hasRendered, setHasRendered] = import_react3.useState(false);
558
558
  const [containerElement, setContainerElement] = import_react3.useState(null);
559
+ const [zoomLevel, setZoomLevel] = import_react3.useState(1);
559
560
  const observerRef = import_react3.useRef(null);
560
561
  const containerRef = import_react3.default.useCallback((node) => {
561
562
  setContainerElement(node);
@@ -596,27 +597,29 @@ function IndustryMermaidDiagram({
596
597
  if (!mermaid || !containerElement)
597
598
  return;
598
599
  try {
600
+ const diagramBackground = theme2.colors.backgroundSecondary || theme2.colors.muted || theme2.colors.background;
601
+ const nodeBackground = theme2.colors.backgroundTertiary || theme2.colors.backgroundSecondary || theme2.colors.primary + "22";
599
602
  mermaid.initialize({
600
603
  startOnLoad: false,
601
604
  theme: "base",
602
605
  themeVariables: {
603
- primaryColor: "#1e1e1e",
604
- primaryTextColor: "#e0e0e0",
605
- primaryBorderColor: "#444",
606
- lineColor: "#666",
607
- secondaryColor: "#2a2a2a",
608
- tertiaryColor: "#333",
609
- background: "#1e1e1e",
610
- mainBkg: "#1e1e1e",
611
- secondBkg: "#2a2a2a",
612
- tertiaryBkg: "#333",
613
- secondaryBorderColor: "#555",
614
- tertiaryBorderColor: "#666",
615
- textColor: "#e0e0e0",
616
- labelTextColor: "#e0e0e0",
617
- altBackground: "#252525",
618
- errorBkgColor: "#552222",
619
- errorTextColor: "#ff6666"
606
+ primaryColor: nodeBackground,
607
+ primaryTextColor: theme2.colors.text,
608
+ primaryBorderColor: theme2.colors.border,
609
+ lineColor: theme2.colors.border,
610
+ secondaryColor: theme2.colors.secondary + "44",
611
+ tertiaryColor: theme2.colors.accent + "44",
612
+ background: diagramBackground,
613
+ mainBkg: nodeBackground,
614
+ secondBkg: theme2.colors.backgroundSecondary || theme2.colors.muted,
615
+ tertiaryBkg: theme2.colors.backgroundTertiary || theme2.colors.accent + "22",
616
+ secondaryBorderColor: theme2.colors.border,
617
+ tertiaryBorderColor: theme2.colors.accent,
618
+ textColor: theme2.colors.text,
619
+ labelTextColor: theme2.colors.text,
620
+ altBackground: theme2.colors.muted,
621
+ errorBkgColor: theme2.colors.error + "33",
622
+ errorTextColor: theme2.colors.error
620
623
  },
621
624
  securityLevel: "loose",
622
625
  logLevel: "error"
@@ -632,8 +635,8 @@ function IndustryMermaidDiagram({
632
635
  });
633
636
  const svgElement = graphDiv.querySelector("svg");
634
637
  if (svgElement) {
635
- svgElement.style.maxWidth = "100%";
636
- svgElement.style.maxHeight = "80vh";
638
+ svgElement.style.maxWidth = "none";
639
+ svgElement.style.maxHeight = "none";
637
640
  svgElement.style.width = "auto";
638
641
  svgElement.style.height = "auto";
639
642
  svgElement.style.display = "block";
@@ -641,12 +644,10 @@ function IndustryMermaidDiagram({
641
644
  if (isModalMode) {
642
645
  svgElement.style.width = "100%";
643
646
  svgElement.style.height = "auto";
644
- } else if (fitMode === "width") {
645
- svgElement.style.width = "100%";
646
- svgElement.style.maxHeight = "none";
647
- } else if (fitMode === "height") {
648
- svgElement.style.maxHeight = "60vh";
647
+ } else {
648
+ svgElement.style.maxHeight = "360px";
649
649
  svgElement.style.width = "auto";
650
+ svgElement.style.maxWidth = "100%";
650
651
  }
651
652
  } else {
652
653
  console.warn("No SVG element found after mermaid render");
@@ -683,7 +684,29 @@ function IndustryMermaidDiagram({
683
684
  }
684
685
  };
685
686
  renderDiagram();
686
- }, [hasRendered, code, id, theme2, containerElement, onError, fitMode, isModalMode]);
687
+ }, [hasRendered, code, id, theme2, containerElement, onError, isModalMode]);
688
+ import_react3.useEffect(() => {
689
+ if (!containerElement || !hasRendered)
690
+ return;
691
+ const svgElement = containerElement.querySelector("svg");
692
+ if (svgElement) {
693
+ if (zoomLevel !== 1) {
694
+ const originalWidth = svgElement.scrollWidth || svgElement.clientWidth;
695
+ const originalHeight = svgElement.scrollHeight || svgElement.clientHeight;
696
+ svgElement.style.transform = `scale(${zoomLevel})`;
697
+ svgElement.style.transformOrigin = "top left";
698
+ svgElement.style.width = `${originalWidth * zoomLevel}px`;
699
+ svgElement.style.height = `${originalHeight * zoomLevel}px`;
700
+ } else {
701
+ svgElement.style.transform = "";
702
+ svgElement.style.transformOrigin = "";
703
+ svgElement.style.width = "auto";
704
+ svgElement.style.height = "auto";
705
+ svgElement.style.maxHeight = "360px";
706
+ svgElement.style.maxWidth = "100%";
707
+ }
708
+ }
709
+ }, [zoomLevel, containerElement, hasRendered]);
687
710
  import_react3.useEffect(() => {
688
711
  if (errorDetails && onCopyError) {
689
712
  const handleKeyDown = (e) => {
@@ -704,12 +727,14 @@ function IndustryMermaidDiagram({
704
727
  position: "relative",
705
728
  width: "100%",
706
729
  minHeight: "200px",
730
+ maxHeight: "400px",
707
731
  display: "block",
708
732
  backgroundColor: hasRendered ? "transparent" : theme2.colors.backgroundSecondary,
709
- border: hasRendered ? "none" : `1px solid ${theme2.colors.border}`,
733
+ border: hasRendered ? `1px solid ${theme2.colors.border}` : `1px solid ${theme2.colors.border}`,
710
734
  borderRadius: theme2.radii[2],
711
- padding: hasRendered ? 0 : theme2.space[4],
712
- margin: `${theme2.space[4]}px 0`
735
+ padding: hasRendered ? theme2.space[3] : theme2.space[4],
736
+ margin: `${theme2.space[4]}px 0`,
737
+ overflow: hasRendered ? "auto" : "visible"
713
738
  };
714
739
  const placeholderStyle = {
715
740
  textAlign: "center",
@@ -718,6 +743,77 @@ function IndustryMermaidDiagram({
718
743
  fontFamily: theme2.fonts.body
719
744
  };
720
745
  return /* @__PURE__ */ import_react3.default.createElement("div", {
746
+ style: { position: "relative" }
747
+ }, hasRendered && !isModalMode && /* @__PURE__ */ import_react3.default.createElement("div", {
748
+ style: {
749
+ position: "absolute",
750
+ top: theme2.space[2],
751
+ right: theme2.space[2],
752
+ zIndex: 10,
753
+ display: "flex",
754
+ gap: theme2.space[1]
755
+ }
756
+ }, /* @__PURE__ */ import_react3.default.createElement("button", {
757
+ onClick: () => setZoomLevel(Math.min(3, zoomLevel + 0.25)),
758
+ disabled: zoomLevel >= 3,
759
+ style: {
760
+ padding: theme2.space[1],
761
+ backgroundColor: theme2.colors.backgroundSecondary,
762
+ border: `1px solid ${theme2.colors.border}`,
763
+ borderRadius: theme2.radii[1],
764
+ color: theme2.colors.text,
765
+ cursor: zoomLevel >= 3 ? "not-allowed" : "pointer",
766
+ display: "flex",
767
+ alignItems: "center",
768
+ justifyContent: "center",
769
+ width: "28px",
770
+ height: "28px",
771
+ opacity: zoomLevel >= 3 ? 0.5 : 1
772
+ },
773
+ title: "Zoom In"
774
+ }, /* @__PURE__ */ import_react3.default.createElement(import_lucide_react.ZoomIn, {
775
+ size: 14
776
+ })), /* @__PURE__ */ import_react3.default.createElement("button", {
777
+ onClick: () => setZoomLevel(Math.max(0.5, zoomLevel - 0.25)),
778
+ disabled: zoomLevel <= 0.5,
779
+ style: {
780
+ padding: theme2.space[1],
781
+ backgroundColor: theme2.colors.backgroundSecondary,
782
+ border: `1px solid ${theme2.colors.border}`,
783
+ borderRadius: theme2.radii[1],
784
+ color: theme2.colors.text,
785
+ cursor: zoomLevel <= 0.5 ? "not-allowed" : "pointer",
786
+ display: "flex",
787
+ alignItems: "center",
788
+ justifyContent: "center",
789
+ width: "28px",
790
+ height: "28px",
791
+ opacity: zoomLevel <= 0.5 ? 0.5 : 1
792
+ },
793
+ title: "Zoom Out"
794
+ }, /* @__PURE__ */ import_react3.default.createElement(import_lucide_react.ZoomOut, {
795
+ size: 14
796
+ })), /* @__PURE__ */ import_react3.default.createElement("button", {
797
+ onClick: () => setZoomLevel(1),
798
+ disabled: zoomLevel === 1,
799
+ style: {
800
+ padding: theme2.space[1],
801
+ backgroundColor: theme2.colors.backgroundSecondary,
802
+ border: `1px solid ${theme2.colors.border}`,
803
+ borderRadius: theme2.radii[1],
804
+ color: theme2.colors.text,
805
+ cursor: zoomLevel === 1 ? "not-allowed" : "pointer",
806
+ display: "flex",
807
+ alignItems: "center",
808
+ justifyContent: "center",
809
+ width: "28px",
810
+ height: "28px",
811
+ opacity: zoomLevel === 1 ? 0.5 : 1
812
+ },
813
+ title: "Reset Zoom"
814
+ }, /* @__PURE__ */ import_react3.default.createElement(import_lucide_react.RotateCcw, {
815
+ size: 14
816
+ }))), /* @__PURE__ */ import_react3.default.createElement("div", {
721
817
  ref: containerRef,
722
818
  style: containerStyle,
723
819
  className: "mermaid-container"
@@ -725,7 +821,7 @@ function IndustryMermaidDiagram({
725
821
  style: placeholderStyle
726
822
  }, /* @__PURE__ */ import_react3.default.createElement("div", null, "\uD83D\uDCCA Mermaid Diagram"), /* @__PURE__ */ import_react3.default.createElement("div", {
727
823
  style: { fontSize: theme2.fontSizes[1], marginTop: theme2.space[2], opacity: 0.7 }
728
- }, isIntersecting ? "Loading..." : "Scroll to view")));
824
+ }, isIntersecting ? "Loading..." : "Scroll to view"))));
729
825
  }
730
826
 
731
827
  // industryMarkdown/components/IndustryLazyMermaidDiagram.tsx
@@ -735,8 +831,7 @@ function IndustryLazyMermaidDiagram({
735
831
  onCopyError,
736
832
  rootMargin = "200px",
737
833
  onShowInPanel,
738
- theme: theme2 = theme,
739
- fitMode = "height"
834
+ theme: theme2 = theme
740
835
  }) {
741
836
  const [isIntersecting, setIsIntersecting] = import_react4.useState(false);
742
837
  const [hasRendered, setHasRendered] = import_react4.useState(false);
@@ -847,14 +942,14 @@ function IndustryLazyMermaidDiagram({
847
942
  e.currentTarget.style.backgroundColor = theme2.colors.background;
848
943
  },
849
944
  title: "Show in diagram panel"
850
- }, /* @__PURE__ */ import_react4.default.createElement(import_lucide_react.MoveRight, {
945
+ }, /* @__PURE__ */ import_react4.default.createElement(import_lucide_react2.MoveRight, {
851
946
  size: 14
852
947
  })), hasRendered ? /* @__PURE__ */ import_react4.default.createElement(IndustryMermaidDiagram, {
853
948
  code,
854
949
  id,
855
950
  onCopyError,
856
951
  onError: setHasError,
857
- fitMode
952
+ theme: theme2
858
953
  }) : /* @__PURE__ */ import_react4.default.createElement("div", {
859
954
  style: getPlaceholderStyle()
860
955
  }, /* @__PURE__ */ import_react4.default.createElement("div", {
@@ -865,7 +960,7 @@ function IndustryLazyMermaidDiagram({
865
960
  }
866
961
 
867
962
  // industryMarkdown/components/IndustryMarkdownComponents.tsx
868
- var import_lucide_react3 = require("lucide-react");
963
+ var import_lucide_react4 = require("lucide-react");
869
964
  var import_react7 = __toESM(require("react"));
870
965
 
871
966
  // industryMarkdown/utils/bashCommandParser.ts
@@ -1018,7 +1113,7 @@ function transformImageUrl(src, repositoryInfo) {
1018
1113
  }
1019
1114
 
1020
1115
  // industryMarkdown/components/IndustryBashCommandDropdown.tsx
1021
- var import_lucide_react2 = require("lucide-react");
1116
+ var import_lucide_react3 = require("lucide-react");
1022
1117
  var import_react6 = __toESM(require("react"));
1023
1118
  var IndustryBashCommandDropdown = ({
1024
1119
  commands,
@@ -1118,9 +1213,9 @@ var IndustryBashCommandDropdown = ({
1118
1213
  }
1119
1214
  }, isRunning ? /* @__PURE__ */ import_react6.default.createElement("span", {
1120
1215
  style: { fontSize: theme2.fontSizes[1] }
1121
- }, "...") : /* @__PURE__ */ import_react6.default.createElement(import_react6.default.Fragment, null, /* @__PURE__ */ import_react6.default.createElement(import_lucide_react2.Play, {
1216
+ }, "...") : /* @__PURE__ */ import_react6.default.createElement(import_react6.default.Fragment, null, /* @__PURE__ */ import_react6.default.createElement(import_lucide_react3.Play, {
1122
1217
  size: 14
1123
- }), "Run", /* @__PURE__ */ import_react6.default.createElement(import_lucide_react2.ChevronDown, {
1218
+ }), "Run", /* @__PURE__ */ import_react6.default.createElement(import_lucide_react3.ChevronDown, {
1124
1219
  size: 14
1125
1220
  }))), isOpen && /* @__PURE__ */ import_react6.default.createElement("div", {
1126
1221
  style: dropdownStyle
@@ -1177,7 +1272,7 @@ var IndustryBashCommandDropdown = ({
1177
1272
  }
1178
1273
  }, isRunning ? /* @__PURE__ */ import_react6.default.createElement("span", {
1179
1274
  style: { fontSize: theme2.fontSizes[1] }
1180
- }, "...") : /* @__PURE__ */ import_react6.default.createElement(import_react6.default.Fragment, null, /* @__PURE__ */ import_react6.default.createElement(import_lucide_react2.Play, {
1275
+ }, "...") : /* @__PURE__ */ import_react6.default.createElement(import_react6.default.Fragment, null, /* @__PURE__ */ import_react6.default.createElement(import_lucide_react3.Play, {
1181
1276
  size: 14
1182
1277
  }), "Run")));
1183
1278
  };
@@ -1595,9 +1690,9 @@ var createIndustryMarkdownComponents = ({
1595
1690
  transition: "all 0.15s ease-in-out"
1596
1691
  },
1597
1692
  title: copied ? "Copied!" : "Copy code to clipboard"
1598
- }, copied ? /* @__PURE__ */ import_react7.default.createElement(import_lucide_react3.Check, {
1693
+ }, copied ? /* @__PURE__ */ import_react7.default.createElement(import_lucide_react4.Check, {
1599
1694
  size: 14
1600
- }) : /* @__PURE__ */ import_react7.default.createElement(import_lucide_react3.Copy, {
1695
+ }) : /* @__PURE__ */ import_react7.default.createElement(import_lucide_react4.Copy, {
1601
1696
  size: 14
1602
1697
  }), copied ? "Copied!" : "Copy"), isExecutable && /* @__PURE__ */ import_react7.default.createElement(IndustryBashCommandDropdown, {
1603
1698
  commands: bashCommands,
@@ -1632,7 +1727,7 @@ var createIndustryMarkdownComponents = ({
1632
1727
  gap: `${theme2.space[1]}px`
1633
1728
  },
1634
1729
  title: "Render HTML in modal"
1635
- }, /* @__PURE__ */ import_react7.default.createElement(import_lucide_react3.Monitor, {
1730
+ }, /* @__PURE__ */ import_react7.default.createElement(import_lucide_react4.Monitor, {
1636
1731
  size: 14
1637
1732
  }), "Render HTML"), isPrompt && openPlaceholderModal && hasPlaceholders && /* @__PURE__ */ import_react7.default.createElement("button", {
1638
1733
  onClick: (e) => {
@@ -1652,7 +1747,7 @@ var createIndustryMarkdownComponents = ({
1652
1747
  gap: `${theme2.space[1]}px`
1653
1748
  },
1654
1749
  title: "Fill placeholders and copy"
1655
- }, /* @__PURE__ */ import_react7.default.createElement(import_lucide_react3.FileText, {
1750
+ }, /* @__PURE__ */ import_react7.default.createElement(import_lucide_react4.FileText, {
1656
1751
  size: 14
1657
1752
  }), "Fill & Copy (", placeholders.length, ")"))), isPrompt ? /* @__PURE__ */ import_react7.default.createElement("div", {
1658
1753
  style: {
@@ -2743,7 +2838,7 @@ var IndustryMarkdownSlide = import_react11.default.memo(function IndustryMarkdow
2743
2838
  }));
2744
2839
  });
2745
2840
  // industryMarkdown/components/SlidePresentation.tsx
2746
- var import_lucide_react4 = require("lucide-react");
2841
+ var import_lucide_react5 = require("lucide-react");
2747
2842
  var import_react12 = __toESM(require("react"));
2748
2843
  var SlidePresentation = ({
2749
2844
  slides,
@@ -2864,7 +2959,7 @@ var SlidePresentation = ({
2864
2959
  onMouseOut: (e) => {
2865
2960
  e.currentTarget.style.backgroundColor = "transparent";
2866
2961
  }
2867
- }, /* @__PURE__ */ import_react12.default.createElement(import_lucide_react4.ChevronLeft, {
2962
+ }, /* @__PURE__ */ import_react12.default.createElement(import_lucide_react5.ChevronLeft, {
2868
2963
  size: 16
2869
2964
  }), "Previous"), showSlideCounter && /* @__PURE__ */ import_react12.default.createElement("div", {
2870
2965
  style: {
@@ -2924,9 +3019,9 @@ var SlidePresentation = ({
2924
3019
  e.currentTarget.style.backgroundColor = "transparent";
2925
3020
  },
2926
3021
  title: isFullscreen ? "Exit fullscreen" : "Enter fullscreen"
2927
- }, isFullscreen ? /* @__PURE__ */ import_react12.default.createElement(import_lucide_react4.Minimize2, {
3022
+ }, isFullscreen ? /* @__PURE__ */ import_react12.default.createElement(import_lucide_react5.Minimize2, {
2928
3023
  size: 16
2929
- }) : /* @__PURE__ */ import_react12.default.createElement(import_lucide_react4.Maximize2, {
3024
+ }) : /* @__PURE__ */ import_react12.default.createElement(import_lucide_react5.Maximize2, {
2930
3025
  size: 16
2931
3026
  })), /* @__PURE__ */ import_react12.default.createElement("button", {
2932
3027
  onClick: goToNextSlide,
@@ -2954,7 +3049,7 @@ var SlidePresentation = ({
2954
3049
  onMouseOut: (e) => {
2955
3050
  e.currentTarget.style.backgroundColor = "transparent";
2956
3051
  }
2957
- }, "Next", /* @__PURE__ */ import_react12.default.createElement(import_lucide_react4.ChevronRight, {
3052
+ }, "Next", /* @__PURE__ */ import_react12.default.createElement(import_lucide_react5.ChevronRight, {
2958
3053
  size: 16
2959
3054
  })))), /* @__PURE__ */ import_react12.default.createElement("div", {
2960
3055
  style: {
@@ -3174,7 +3269,7 @@ var DocumentView = ({
3174
3269
  })))));
3175
3270
  };
3176
3271
  // industryMarkdown/components/IndustryEditableMarkdownSlide.tsx
3177
- var import_lucide_react5 = require("lucide-react");
3272
+ var import_lucide_react6 = require("lucide-react");
3178
3273
  var import_react14 = __toESM(require("react"));
3179
3274
  var IndustryEditableMarkdownSlide = ({
3180
3275
  content,
@@ -3285,7 +3380,7 @@ var IndustryEditableMarkdownSlide = ({
3285
3380
  fontSize: theme2.fontSizes[1],
3286
3381
  color: theme2.colors.textSecondary
3287
3382
  }
3288
- }, /* @__PURE__ */ import_react14.default.createElement(import_lucide_react5.Pencil, {
3383
+ }, /* @__PURE__ */ import_react14.default.createElement(import_lucide_react6.Pencil, {
3289
3384
  size: 16
3290
3385
  }), /* @__PURE__ */ import_react14.default.createElement("span", null, "Editing Mode"), autoSaveDelay && /* @__PURE__ */ import_react14.default.createElement("span", null, "(Auto-save enabled)")), /* @__PURE__ */ import_react14.default.createElement("div", {
3291
3386
  style: {
@@ -3308,7 +3403,7 @@ var IndustryEditableMarkdownSlide = ({
3308
3403
  cursor: isSaving ? "not-allowed" : "pointer",
3309
3404
  opacity: isSaving ? 0.7 : 1
3310
3405
  }
3311
- }, /* @__PURE__ */ import_react14.default.createElement(import_lucide_react5.Save, {
3406
+ }, /* @__PURE__ */ import_react14.default.createElement(import_lucide_react6.Save, {
3312
3407
  size: 14
3313
3408
  }), isSaving ? "Saving..." : "Save"), /* @__PURE__ */ import_react14.default.createElement("button", {
3314
3409
  onClick: handleCancel,
@@ -3324,7 +3419,7 @@ var IndustryEditableMarkdownSlide = ({
3324
3419
  fontSize: theme2.fontSizes[1],
3325
3420
  cursor: "pointer"
3326
3421
  }
3327
- }, /* @__PURE__ */ import_react14.default.createElement(import_lucide_react5.X, {
3422
+ }, /* @__PURE__ */ import_react14.default.createElement(import_lucide_react6.X, {
3328
3423
  size: 14
3329
3424
  }), "Cancel"))), /* @__PURE__ */ import_react14.default.createElement("div", {
3330
3425
  style: {
@@ -3378,7 +3473,7 @@ var IndustryEditableMarkdownSlide = ({
3378
3473
  },
3379
3474
  onMouseEnter: (e) => e.currentTarget.style.opacity = "1",
3380
3475
  onMouseLeave: (e) => e.currentTarget.style.opacity = "0.8"
3381
- }, /* @__PURE__ */ import_react14.default.createElement(import_lucide_react5.Pencil, {
3476
+ }, /* @__PURE__ */ import_react14.default.createElement(import_lucide_react6.Pencil, {
3382
3477
  size: 14
3383
3478
  }), "Edit"), /* @__PURE__ */ import_react14.default.createElement(IndustryMarkdownSlide, {
3384
3479
  ...slideProps,
package/dist/index.mjs CHANGED
@@ -449,6 +449,7 @@ import { MoveRight } from "lucide-react";
449
449
  import React4, { useEffect as useEffect3, useRef as useRef2, useState as useState4 } from "react";
450
450
 
451
451
  // industryMarkdown/components/IndustryMermaidDiagram.tsx
452
+ import { ZoomIn, ZoomOut, RotateCcw } from "lucide-react";
452
453
  import React3, { useEffect as useEffect2, useRef, useState as useState3 } from "react";
453
454
  var getMermaidSync = () => {
454
455
  if (typeof window !== "undefined") {
@@ -466,14 +467,14 @@ function IndustryMermaidDiagram({
466
467
  onCopyError,
467
468
  onError,
468
469
  rootMargin = "200px",
469
- isModalMode = false,
470
- fitMode = "height"
470
+ isModalMode = false
471
471
  }) {
472
472
  const theme2 = themeOverride || theme;
473
473
  const [errorDetails, setErrorDetails] = useState3(null);
474
474
  const [isIntersecting, setIsIntersecting] = useState3(false);
475
475
  const [hasRendered, setHasRendered] = useState3(false);
476
476
  const [containerElement, setContainerElement] = useState3(null);
477
+ const [zoomLevel, setZoomLevel] = useState3(1);
477
478
  const observerRef = useRef(null);
478
479
  const containerRef = React3.useCallback((node) => {
479
480
  setContainerElement(node);
@@ -514,27 +515,29 @@ function IndustryMermaidDiagram({
514
515
  if (!mermaid || !containerElement)
515
516
  return;
516
517
  try {
518
+ const diagramBackground = theme2.colors.backgroundSecondary || theme2.colors.muted || theme2.colors.background;
519
+ const nodeBackground = theme2.colors.backgroundTertiary || theme2.colors.backgroundSecondary || theme2.colors.primary + "22";
517
520
  mermaid.initialize({
518
521
  startOnLoad: false,
519
522
  theme: "base",
520
523
  themeVariables: {
521
- primaryColor: "#1e1e1e",
522
- primaryTextColor: "#e0e0e0",
523
- primaryBorderColor: "#444",
524
- lineColor: "#666",
525
- secondaryColor: "#2a2a2a",
526
- tertiaryColor: "#333",
527
- background: "#1e1e1e",
528
- mainBkg: "#1e1e1e",
529
- secondBkg: "#2a2a2a",
530
- tertiaryBkg: "#333",
531
- secondaryBorderColor: "#555",
532
- tertiaryBorderColor: "#666",
533
- textColor: "#e0e0e0",
534
- labelTextColor: "#e0e0e0",
535
- altBackground: "#252525",
536
- errorBkgColor: "#552222",
537
- errorTextColor: "#ff6666"
524
+ primaryColor: nodeBackground,
525
+ primaryTextColor: theme2.colors.text,
526
+ primaryBorderColor: theme2.colors.border,
527
+ lineColor: theme2.colors.border,
528
+ secondaryColor: theme2.colors.secondary + "44",
529
+ tertiaryColor: theme2.colors.accent + "44",
530
+ background: diagramBackground,
531
+ mainBkg: nodeBackground,
532
+ secondBkg: theme2.colors.backgroundSecondary || theme2.colors.muted,
533
+ tertiaryBkg: theme2.colors.backgroundTertiary || theme2.colors.accent + "22",
534
+ secondaryBorderColor: theme2.colors.border,
535
+ tertiaryBorderColor: theme2.colors.accent,
536
+ textColor: theme2.colors.text,
537
+ labelTextColor: theme2.colors.text,
538
+ altBackground: theme2.colors.muted,
539
+ errorBkgColor: theme2.colors.error + "33",
540
+ errorTextColor: theme2.colors.error
538
541
  },
539
542
  securityLevel: "loose",
540
543
  logLevel: "error"
@@ -550,8 +553,8 @@ function IndustryMermaidDiagram({
550
553
  });
551
554
  const svgElement = graphDiv.querySelector("svg");
552
555
  if (svgElement) {
553
- svgElement.style.maxWidth = "100%";
554
- svgElement.style.maxHeight = "80vh";
556
+ svgElement.style.maxWidth = "none";
557
+ svgElement.style.maxHeight = "none";
555
558
  svgElement.style.width = "auto";
556
559
  svgElement.style.height = "auto";
557
560
  svgElement.style.display = "block";
@@ -559,12 +562,10 @@ function IndustryMermaidDiagram({
559
562
  if (isModalMode) {
560
563
  svgElement.style.width = "100%";
561
564
  svgElement.style.height = "auto";
562
- } else if (fitMode === "width") {
563
- svgElement.style.width = "100%";
564
- svgElement.style.maxHeight = "none";
565
- } else if (fitMode === "height") {
566
- svgElement.style.maxHeight = "60vh";
565
+ } else {
566
+ svgElement.style.maxHeight = "360px";
567
567
  svgElement.style.width = "auto";
568
+ svgElement.style.maxWidth = "100%";
568
569
  }
569
570
  } else {
570
571
  console.warn("No SVG element found after mermaid render");
@@ -601,7 +602,29 @@ function IndustryMermaidDiagram({
601
602
  }
602
603
  };
603
604
  renderDiagram();
604
- }, [hasRendered, code, id, theme2, containerElement, onError, fitMode, isModalMode]);
605
+ }, [hasRendered, code, id, theme2, containerElement, onError, isModalMode]);
606
+ useEffect2(() => {
607
+ if (!containerElement || !hasRendered)
608
+ return;
609
+ const svgElement = containerElement.querySelector("svg");
610
+ if (svgElement) {
611
+ if (zoomLevel !== 1) {
612
+ const originalWidth = svgElement.scrollWidth || svgElement.clientWidth;
613
+ const originalHeight = svgElement.scrollHeight || svgElement.clientHeight;
614
+ svgElement.style.transform = `scale(${zoomLevel})`;
615
+ svgElement.style.transformOrigin = "top left";
616
+ svgElement.style.width = `${originalWidth * zoomLevel}px`;
617
+ svgElement.style.height = `${originalHeight * zoomLevel}px`;
618
+ } else {
619
+ svgElement.style.transform = "";
620
+ svgElement.style.transformOrigin = "";
621
+ svgElement.style.width = "auto";
622
+ svgElement.style.height = "auto";
623
+ svgElement.style.maxHeight = "360px";
624
+ svgElement.style.maxWidth = "100%";
625
+ }
626
+ }
627
+ }, [zoomLevel, containerElement, hasRendered]);
605
628
  useEffect2(() => {
606
629
  if (errorDetails && onCopyError) {
607
630
  const handleKeyDown = (e) => {
@@ -622,12 +645,14 @@ function IndustryMermaidDiagram({
622
645
  position: "relative",
623
646
  width: "100%",
624
647
  minHeight: "200px",
648
+ maxHeight: "400px",
625
649
  display: "block",
626
650
  backgroundColor: hasRendered ? "transparent" : theme2.colors.backgroundSecondary,
627
- border: hasRendered ? "none" : `1px solid ${theme2.colors.border}`,
651
+ border: hasRendered ? `1px solid ${theme2.colors.border}` : `1px solid ${theme2.colors.border}`,
628
652
  borderRadius: theme2.radii[2],
629
- padding: hasRendered ? 0 : theme2.space[4],
630
- margin: `${theme2.space[4]}px 0`
653
+ padding: hasRendered ? theme2.space[3] : theme2.space[4],
654
+ margin: `${theme2.space[4]}px 0`,
655
+ overflow: hasRendered ? "auto" : "visible"
631
656
  };
632
657
  const placeholderStyle = {
633
658
  textAlign: "center",
@@ -636,6 +661,77 @@ function IndustryMermaidDiagram({
636
661
  fontFamily: theme2.fonts.body
637
662
  };
638
663
  return /* @__PURE__ */ React3.createElement("div", {
664
+ style: { position: "relative" }
665
+ }, hasRendered && !isModalMode && /* @__PURE__ */ React3.createElement("div", {
666
+ style: {
667
+ position: "absolute",
668
+ top: theme2.space[2],
669
+ right: theme2.space[2],
670
+ zIndex: 10,
671
+ display: "flex",
672
+ gap: theme2.space[1]
673
+ }
674
+ }, /* @__PURE__ */ React3.createElement("button", {
675
+ onClick: () => setZoomLevel(Math.min(3, zoomLevel + 0.25)),
676
+ disabled: zoomLevel >= 3,
677
+ style: {
678
+ padding: theme2.space[1],
679
+ backgroundColor: theme2.colors.backgroundSecondary,
680
+ border: `1px solid ${theme2.colors.border}`,
681
+ borderRadius: theme2.radii[1],
682
+ color: theme2.colors.text,
683
+ cursor: zoomLevel >= 3 ? "not-allowed" : "pointer",
684
+ display: "flex",
685
+ alignItems: "center",
686
+ justifyContent: "center",
687
+ width: "28px",
688
+ height: "28px",
689
+ opacity: zoomLevel >= 3 ? 0.5 : 1
690
+ },
691
+ title: "Zoom In"
692
+ }, /* @__PURE__ */ React3.createElement(ZoomIn, {
693
+ size: 14
694
+ })), /* @__PURE__ */ React3.createElement("button", {
695
+ onClick: () => setZoomLevel(Math.max(0.5, zoomLevel - 0.25)),
696
+ disabled: zoomLevel <= 0.5,
697
+ style: {
698
+ padding: theme2.space[1],
699
+ backgroundColor: theme2.colors.backgroundSecondary,
700
+ border: `1px solid ${theme2.colors.border}`,
701
+ borderRadius: theme2.radii[1],
702
+ color: theme2.colors.text,
703
+ cursor: zoomLevel <= 0.5 ? "not-allowed" : "pointer",
704
+ display: "flex",
705
+ alignItems: "center",
706
+ justifyContent: "center",
707
+ width: "28px",
708
+ height: "28px",
709
+ opacity: zoomLevel <= 0.5 ? 0.5 : 1
710
+ },
711
+ title: "Zoom Out"
712
+ }, /* @__PURE__ */ React3.createElement(ZoomOut, {
713
+ size: 14
714
+ })), /* @__PURE__ */ React3.createElement("button", {
715
+ onClick: () => setZoomLevel(1),
716
+ disabled: zoomLevel === 1,
717
+ style: {
718
+ padding: theme2.space[1],
719
+ backgroundColor: theme2.colors.backgroundSecondary,
720
+ border: `1px solid ${theme2.colors.border}`,
721
+ borderRadius: theme2.radii[1],
722
+ color: theme2.colors.text,
723
+ cursor: zoomLevel === 1 ? "not-allowed" : "pointer",
724
+ display: "flex",
725
+ alignItems: "center",
726
+ justifyContent: "center",
727
+ width: "28px",
728
+ height: "28px",
729
+ opacity: zoomLevel === 1 ? 0.5 : 1
730
+ },
731
+ title: "Reset Zoom"
732
+ }, /* @__PURE__ */ React3.createElement(RotateCcw, {
733
+ size: 14
734
+ }))), /* @__PURE__ */ React3.createElement("div", {
639
735
  ref: containerRef,
640
736
  style: containerStyle,
641
737
  className: "mermaid-container"
@@ -643,7 +739,7 @@ function IndustryMermaidDiagram({
643
739
  style: placeholderStyle
644
740
  }, /* @__PURE__ */ React3.createElement("div", null, "\uD83D\uDCCA Mermaid Diagram"), /* @__PURE__ */ React3.createElement("div", {
645
741
  style: { fontSize: theme2.fontSizes[1], marginTop: theme2.space[2], opacity: 0.7 }
646
- }, isIntersecting ? "Loading..." : "Scroll to view")));
742
+ }, isIntersecting ? "Loading..." : "Scroll to view"))));
647
743
  }
648
744
 
649
745
  // industryMarkdown/components/IndustryLazyMermaidDiagram.tsx
@@ -653,8 +749,7 @@ function IndustryLazyMermaidDiagram({
653
749
  onCopyError,
654
750
  rootMargin = "200px",
655
751
  onShowInPanel,
656
- theme: theme2 = theme,
657
- fitMode = "height"
752
+ theme: theme2 = theme
658
753
  }) {
659
754
  const [isIntersecting, setIsIntersecting] = useState4(false);
660
755
  const [hasRendered, setHasRendered] = useState4(false);
@@ -772,7 +867,7 @@ function IndustryLazyMermaidDiagram({
772
867
  id,
773
868
  onCopyError,
774
869
  onError: setHasError,
775
- fitMode
870
+ theme: theme2
776
871
  }) : /* @__PURE__ */ React4.createElement("div", {
777
872
  style: getPlaceholderStyle()
778
873
  }, /* @__PURE__ */ React4.createElement("div", {
@@ -7,8 +7,7 @@ interface IndustryLazyMermaidDiagramProps {
7
7
  rootMargin?: string;
8
8
  onShowInPanel?: (code: string, title?: string) => void;
9
9
  theme?: Theme;
10
- fitMode?: 'height' | 'width';
11
10
  }
12
- export declare function IndustryLazyMermaidDiagram({ code, id, onCopyError, rootMargin, onShowInPanel, theme, fitMode, }: IndustryLazyMermaidDiagramProps): React.JSX.Element;
11
+ export declare function IndustryLazyMermaidDiagram({ code, id, onCopyError, rootMargin, onShowInPanel, theme, }: IndustryLazyMermaidDiagramProps): React.JSX.Element;
13
12
  export {};
14
13
  //# sourceMappingURL=IndustryLazyMermaidDiagram.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"IndustryLazyMermaidDiagram.d.ts","sourceRoot":"","sources":["../../../industryMarkdown/components/IndustryLazyMermaidDiagram.tsx"],"names":[],"mappings":"AACA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAE3D,OAAO,EAAE,KAAK,EAAyB,MAAM,qBAAqB,CAAC;AAInE,UAAU,+BAA+B;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,KAAK,IAAI,CAAC;IAClE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACvD,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,OAAO,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;CAC9B;AAED,wBAAgB,0BAA0B,CAAC,EACzC,IAAI,EACJ,EAAE,EACF,WAAW,EACX,UAAoB,EACpB,aAAa,EACb,KAAoB,EACpB,OAAkB,GACnB,EAAE,+BAA+B,qBA2JjC"}
1
+ {"version":3,"file":"IndustryLazyMermaidDiagram.d.ts","sourceRoot":"","sources":["../../../industryMarkdown/components/IndustryLazyMermaidDiagram.tsx"],"names":[],"mappings":"AACA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAE3D,OAAO,EAAE,KAAK,EAAyB,MAAM,qBAAqB,CAAC;AAInE,UAAU,+BAA+B;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,KAAK,IAAI,CAAC;IAClE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACvD,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;AAED,wBAAgB,0BAA0B,CAAC,EACzC,IAAI,EACJ,EAAE,EACF,WAAW,EACX,UAAoB,EACpB,aAAa,EACb,KAAoB,GACrB,EAAE,+BAA+B,qBA2JjC"}
@@ -13,4 +13,5 @@ export declare const WithTable: Story;
13
13
  export declare const LongContent: Story;
14
14
  export declare const WithASCIITable: Story;
15
15
  export declare const WithResizeObserver: Story;
16
+ export declare const MermaidFontScaling: Story;
16
17
  //# sourceMappingURL=IndustryMarkdownSlide.stories.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"IndustryMarkdownSlide.stories.d.ts","sourceRoot":"","sources":["../../../industryMarkdown/components/IndustryMarkdownSlide.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAKvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,qBAAqB,CAe5C,CAAC;AAEF,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnC,eAAO,MAAM,OAAO,EAAE,KAOrB,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,KAmBtB,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,KA8DzB,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,KA2BjC,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,KA+BpC,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KAgB1B,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,KAavB,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,KAyBzB,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,KA4E5B,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,KA8BhC,CAAC"}
1
+ {"version":3,"file":"IndustryMarkdownSlide.stories.d.ts","sourceRoot":"","sources":["../../../industryMarkdown/components/IndustryMarkdownSlide.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAKvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,qBAAqB,CAe5C,CAAC;AAEF,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnC,eAAO,MAAM,OAAO,EAAE,KAOrB,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,KAmBtB,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,KAkEzB,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,KA2BjC,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,KA+BpC,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KAgB1B,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,KAavB,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,KAyBzB,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,KA4E5B,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,KA8BhC,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,KAwFhC,CAAC"}
@@ -14,8 +14,7 @@ interface IndustryMermaidDiagramProps {
14
14
  onError?: (hasError: boolean) => void;
15
15
  rootMargin?: string;
16
16
  isModalMode?: boolean;
17
- fitMode?: 'height' | 'width';
18
17
  }
19
- export declare function IndustryMermaidDiagram({ code, id, theme: themeOverride, onCopyError, onError, rootMargin, isModalMode, fitMode, }: IndustryMermaidDiagramProps): React.JSX.Element;
18
+ export declare function IndustryMermaidDiagram({ code, id, theme: themeOverride, onCopyError, onError, rootMargin, isModalMode, }: IndustryMermaidDiagramProps): React.JSX.Element;
20
19
  export {};
21
20
  //# sourceMappingURL=IndustryMermaidDiagram.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"IndustryMermaidDiagram.d.ts","sourceRoot":"","sources":["../../../industryMarkdown/components/IndustryMermaidDiagram.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAsC,MAAM,OAAO,CAAC;AAE3D,OAAO,EAAE,KAAK,EAAyB,MAAM,qBAAqB,CAAC;AAEnE,UAAU,2BAA2B;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,WAAW,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,KAAK,IAAI,CAAC;IAClE,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,OAAO,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;CAC9B;AAmBD,wBAAgB,sBAAsB,CAAC,EACrC,IAAI,EACJ,EAAE,EACF,KAAK,EAAE,aAAa,EACpB,WAAW,EACX,OAAO,EACP,UAAoB,EACpB,WAAmB,EACnB,OAAkB,GACnB,EAAE,2BAA2B,qBA6N7B"}
1
+ {"version":3,"file":"IndustryMermaidDiagram.d.ts","sourceRoot":"","sources":["../../../industryMarkdown/components/IndustryMermaidDiagram.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAsC,MAAM,OAAO,CAAC;AAE3D,OAAO,EAAE,KAAK,EAAyB,MAAM,qBAAqB,CAAC;AAEnE,UAAU,2BAA2B;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,WAAW,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,KAAK,IAAI,CAAC;IAClE,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAmBD,wBAAgB,sBAAsB,CAAC,EACrC,IAAI,EACJ,EAAE,EACF,KAAK,EAAE,aAAa,EACpB,WAAW,EACX,OAAO,EACP,UAAoB,EACpB,WAAmB,GACpB,EAAE,2BAA2B,qBA4U7B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "themed-markdown",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "Industry-themed markdown renderer with presentation capabilities",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",