@industry-theme/markdown-panels 0.2.15 → 0.2.17

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.
@@ -1 +1 @@
1
- {"version":3,"file":"MarkdownPanel.d.ts","sourceRoot":"","sources":["../../src/panels/MarkdownPanel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAQ5D,OAAO,gCAAgC,CAAC;AACxC,OAAO,KAAK,EAAE,mBAAmB,EAAmB,MAAM,UAAU,CAAC;AAUrE;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAgVvD,CAAC"}
1
+ {"version":3,"file":"MarkdownPanel.d.ts","sourceRoot":"","sources":["../../src/panels/MarkdownPanel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAS5D,OAAO,gCAAgC,CAAC;AACxC,OAAO,KAAK,EAAE,mBAAmB,EAAmB,MAAM,UAAU,CAAC;AAmBrE;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAsZvD,CAAC"}
@@ -43296,6 +43296,7 @@ var IndustryMarkdownSlide = React2__default.memo(function IndustryMarkdownSlide2
43296
43296
  handleRunBashCommand,
43297
43297
  handlePromptCopy,
43298
43298
  enableHtmlPopout = true,
43299
+ autoFocusOnVisible = true,
43299
43300
  searchQuery,
43300
43301
  slideHeaderMarginTopOverride,
43301
43302
  theme: themeOverride,
@@ -43502,11 +43503,11 @@ var IndustryMarkdownSlide = React2__default.memo(function IndustryMarkdownSlide2
43502
43503
  }
43503
43504
  }, [enableKeyboardScrolling, isVisible, slideIndex, scrollConfig]);
43504
43505
  useEffect(() => {
43505
- if (isVisible && slideRef.current) {
43506
+ if (autoFocusOnVisible && isVisible && slideRef.current) {
43506
43507
  console.log("🎯 Auto-focusing slide container");
43507
43508
  slideRef.current.focus();
43508
43509
  }
43509
- }, [isVisible]);
43510
+ }, [autoFocusOnVisible, isVisible]);
43510
43511
  const openPlaceholderModal = (placeholders, promptContent) => {
43511
43512
  if (!handlePromptCopy)
43512
43513
  return;
@@ -46595,11 +46596,13 @@ var SlidePresentationBook = ({
46595
46596
  slideIdPrefix = "slide",
46596
46597
  enableHtmlPopout = true,
46597
46598
  enableKeyboardScrolling = true,
46599
+ autoFocusOnVisible = true,
46598
46600
  onLinkClick,
46599
46601
  handleRunBashCommand,
46600
46602
  handlePromptCopy,
46601
46603
  fontSizeScale,
46602
- theme: theme2
46604
+ theme: theme2,
46605
+ repositoryInfo
46603
46606
  }) => {
46604
46607
  const [isMobile, setIsMobile] = useState(false);
46605
46608
  useEffect(() => {
@@ -46992,11 +46995,13 @@ var SlidePresentationBook = ({
46992
46995
  onCheckboxChange,
46993
46996
  enableHtmlPopout,
46994
46997
  enableKeyboardScrolling,
46998
+ autoFocusOnVisible,
46995
46999
  onLinkClick,
46996
47000
  handleRunBashCommand,
46997
47001
  handlePromptCopy,
46998
47002
  fontSizeScale,
46999
- searchQuery: showSearch ? searchQuery : void 0
47003
+ searchQuery: showSearch ? searchQuery : void 0,
47004
+ repositoryInfo
47000
47005
  }) : /* @__PURE__ */ React2__default.createElement("div", {
47001
47006
  style: {
47002
47007
  height: "100%",
@@ -47113,11 +47118,13 @@ var SlidePresentationBook = ({
47113
47118
  onCheckboxChange,
47114
47119
  enableHtmlPopout,
47115
47120
  enableKeyboardScrolling,
47121
+ autoFocusOnVisible,
47116
47122
  onLinkClick,
47117
47123
  handleRunBashCommand,
47118
47124
  handlePromptCopy,
47119
47125
  fontSizeScale,
47120
- searchQuery: showSearch ? searchQuery : void 0
47126
+ searchQuery: showSearch ? searchQuery : void 0,
47127
+ repositoryInfo
47121
47128
  }) : /* @__PURE__ */ React2__default.createElement("div", {
47122
47129
  style: {
47123
47130
  height: "100%",
@@ -47302,11 +47309,13 @@ var SlidePresentationBook = ({
47302
47309
  onCheckboxChange,
47303
47310
  enableHtmlPopout,
47304
47311
  enableKeyboardScrolling,
47312
+ autoFocusOnVisible,
47305
47313
  onLinkClick,
47306
47314
  handleRunBashCommand,
47307
47315
  handlePromptCopy,
47308
47316
  fontSizeScale,
47309
47317
  searchQuery: showSearch ? searchQuery : void 0,
47318
+ repositoryInfo,
47310
47319
  transparentBackground: true,
47311
47320
  additionalPadding: {
47312
47321
  left: `${theme2.space[4]}px`,
@@ -47346,11 +47355,13 @@ var SlidePresentationBook = ({
47346
47355
  onCheckboxChange,
47347
47356
  enableHtmlPopout,
47348
47357
  enableKeyboardScrolling,
47358
+ autoFocusOnVisible,
47349
47359
  onLinkClick,
47350
47360
  handleRunBashCommand,
47351
47361
  handlePromptCopy,
47352
47362
  fontSizeScale,
47353
47363
  searchQuery: showSearch ? searchQuery : void 0,
47364
+ repositoryInfo,
47354
47365
  transparentBackground: true,
47355
47366
  additionalPadding: {
47356
47367
  left: `${theme2.space[2]}px`,
@@ -47414,11 +47425,13 @@ var SlidePresentationBook = ({
47414
47425
  onCheckboxChange,
47415
47426
  enableHtmlPopout,
47416
47427
  enableKeyboardScrolling,
47428
+ autoFocusOnVisible,
47417
47429
  onLinkClick,
47418
47430
  handleRunBashCommand,
47419
47431
  handlePromptCopy,
47420
47432
  fontSizeScale,
47421
47433
  searchQuery: showSearch ? searchQuery : void 0,
47434
+ repositoryInfo,
47422
47435
  transparentBackground: false,
47423
47436
  disableScroll: false
47424
47437
  }))) : /* @__PURE__ */ React2__default.createElement("div", {
@@ -47494,6 +47507,7 @@ var DocumentView = ({
47494
47507
  slideIdPrefix = "document",
47495
47508
  enableHtmlPopout = true,
47496
47509
  enableKeyboardScrolling = true,
47510
+ autoFocusOnVisible = true,
47497
47511
  onLinkClick,
47498
47512
  handleRunBashCommand,
47499
47513
  handlePromptCopy,
@@ -47541,6 +47555,7 @@ var DocumentView = ({
47541
47555
  onCheckboxChange,
47542
47556
  enableHtmlPopout,
47543
47557
  enableKeyboardScrolling,
47558
+ autoFocusOnVisible,
47544
47559
  onLinkClick,
47545
47560
  handleRunBashCommand,
47546
47561
  fontSizeScale,
@@ -47577,6 +47592,7 @@ var DocumentView = ({
47577
47592
  onCheckboxChange,
47578
47593
  enableHtmlPopout,
47579
47594
  enableKeyboardScrolling,
47595
+ autoFocusOnVisible,
47580
47596
  onLinkClick,
47581
47597
  handleRunBashCommand,
47582
47598
  fontSizeScale,
@@ -47643,6 +47659,7 @@ var DocumentView = ({
47643
47659
  onCheckboxChange,
47644
47660
  enableHtmlPopout,
47645
47661
  enableKeyboardScrolling,
47662
+ autoFocusOnVisible,
47646
47663
  onLinkClick,
47647
47664
  handleRunBashCommand,
47648
47665
  fontSizeScale,
@@ -47666,17 +47683,23 @@ const basename = (path2) => {
47666
47683
  const parts = path2.split("/");
47667
47684
  return parts[parts.length - 1] || path2;
47668
47685
  };
47686
+ const getBasePath = (filePath) => {
47687
+ const parts = filePath.split("/");
47688
+ parts.pop();
47689
+ return parts.join("/");
47690
+ };
47669
47691
  const MarkdownPanel = ({
47670
47692
  context,
47671
47693
  actions: _actions,
47672
47694
  events
47673
47695
  }) => {
47674
- var _a, _b, _c, _d, _e;
47696
+ var _a, _b, _c, _d, _e, _f, _g;
47675
47697
  const { theme: theme2 } = useTheme();
47676
47698
  const [viewMode, setViewMode] = useState("book");
47677
47699
  const [currentSlide, setCurrentSlide] = useState(0);
47678
47700
  const [fontSizeScale, setFontSizeScale] = useState(1);
47679
47701
  const [isMobile, setIsMobile] = useState(false);
47702
+ const [preferencesLoaded, setPreferencesLoaded] = useState(false);
47680
47703
  useEffect(() => {
47681
47704
  const checkMobile = () => {
47682
47705
  setIsMobile(window.innerWidth < 768);
@@ -47685,10 +47708,30 @@ const MarkdownPanel = ({
47685
47708
  window.addEventListener("resize", checkMobile);
47686
47709
  return () => window.removeEventListener("resize", checkMobile);
47687
47710
  }, []);
47711
+ useEffect(() => {
47712
+ const unsubscribe = events.on("markdown-panel:set-preferences", (event) => {
47713
+ const payload = event.payload;
47714
+ if (payload.viewMode) {
47715
+ setViewMode(payload.viewMode);
47716
+ }
47717
+ if (payload.fontSizeScale !== void 0) {
47718
+ setFontSizeScale(payload.fontSizeScale);
47719
+ }
47720
+ setPreferencesLoaded(true);
47721
+ });
47722
+ return unsubscribe;
47723
+ }, [events]);
47724
+ useEffect(() => {
47725
+ events.emit({
47726
+ type: "markdown-panel:request-preferences",
47727
+ source: "markdown-panel",
47728
+ timestamp: Date.now(),
47729
+ payload: {}
47730
+ });
47731
+ }, [events]);
47688
47732
  useEffect(() => {
47689
47733
  const unsubscribe = events.on("file:opened", (event) => {
47690
47734
  console.log("Markdown Panel: File opened:", event.payload);
47691
- setViewMode("book");
47692
47735
  setCurrentSlide(0);
47693
47736
  });
47694
47737
  return unsubscribe;
@@ -47702,11 +47745,51 @@ const MarkdownPanel = ({
47702
47745
  );
47703
47746
  const slides = presentation.slides.map((slide) => slide.location.content);
47704
47747
  const hasSlides = slides.length > 1;
47748
+ const repositoryInfo = useMemo(() => {
47749
+ var _a2, _b2, _c2;
47750
+ const source2 = (_a2 = activeFile == null ? void 0 : activeFile.data) == null ? void 0 : _a2.source;
47751
+ if (!source2) return void 0;
47752
+ const branch = source2.locationType === "branch" ? source2.location : ((_b2 = source2.metadata) == null ? void 0 : _b2.currentBranch) || "main";
47753
+ return {
47754
+ owner: source2.owner,
47755
+ repo: source2.name,
47756
+ branch,
47757
+ basePath: getBasePath(((_c2 = activeFile == null ? void 0 : activeFile.data) == null ? void 0 : _c2.path) || "")
47758
+ };
47759
+ }, [(_e = activeFile == null ? void 0 : activeFile.data) == null ? void 0 : _e.source, (_f = activeFile == null ? void 0 : activeFile.data) == null ? void 0 : _f.path]);
47705
47760
  const handleFontSizeIncrease = () => {
47706
- setFontSizeScale((prev) => Math.min(prev + 0.1, 3));
47761
+ setFontSizeScale((prev) => {
47762
+ const newScale = Math.min(prev + 0.1, 3);
47763
+ events.emit({
47764
+ type: "markdown-panel:font-scale-change",
47765
+ source: "markdown-panel",
47766
+ timestamp: Date.now(),
47767
+ payload: { fontSizeScale: newScale }
47768
+ });
47769
+ return newScale;
47770
+ });
47707
47771
  };
47708
47772
  const handleFontSizeDecrease = () => {
47709
- setFontSizeScale((prev) => Math.max(prev - 0.1, 0.5));
47773
+ setFontSizeScale((prev) => {
47774
+ const newScale = Math.max(prev - 0.1, 0.5);
47775
+ events.emit({
47776
+ type: "markdown-panel:font-scale-change",
47777
+ source: "markdown-panel",
47778
+ timestamp: Date.now(),
47779
+ payload: { fontSizeScale: newScale }
47780
+ });
47781
+ return newScale;
47782
+ });
47783
+ };
47784
+ const handleViewModeChange = (mode) => {
47785
+ setViewMode(mode);
47786
+ setCurrentSlide(0);
47787
+ events.emit({
47788
+ type: "markdown-panel:view-mode-change",
47789
+ source: "markdown-panel",
47790
+ timestamp: Date.now(),
47791
+ payload: { viewMode: mode }
47792
+ });
47710
47793
  };
47711
47794
  if (activeFile == null ? void 0 : activeFile.loading) {
47712
47795
  return /* @__PURE__ */ jsx(
@@ -47722,7 +47805,7 @@ const MarkdownPanel = ({
47722
47805
  },
47723
47806
  children: /* @__PURE__ */ jsx("div", { style: { textAlign: "center" }, children: /* @__PURE__ */ jsxs("p", { style: { color: theme2.colors.textSecondary }, children: [
47724
47807
  "Loading ",
47725
- ((_e = activeFile.data) == null ? void 0 : _e.path) || "file",
47808
+ ((_g = activeFile.data) == null ? void 0 : _g.path) || "file",
47726
47809
  "..."
47727
47810
  ] }) })
47728
47811
  }
@@ -47876,10 +47959,7 @@ const MarkdownPanel = ({
47876
47959
  /* @__PURE__ */ jsx(
47877
47960
  "button",
47878
47961
  {
47879
- onClick: () => {
47880
- setViewMode("book");
47881
- setCurrentSlide(0);
47882
- },
47962
+ onClick: () => handleViewModeChange("book"),
47883
47963
  title: "Sections",
47884
47964
  style: {
47885
47965
  background: viewMode === "book" ? theme2.colors.primary : "transparent",
@@ -47901,10 +47981,7 @@ const MarkdownPanel = ({
47901
47981
  /* @__PURE__ */ jsx(
47902
47982
  "button",
47903
47983
  {
47904
- onClick: () => {
47905
- setViewMode("document");
47906
- setCurrentSlide(0);
47907
- },
47984
+ onClick: () => handleViewModeChange("document"),
47908
47985
  title: "Document",
47909
47986
  style: {
47910
47987
  background: viewMode === "document" ? theme2.colors.primary : "transparent",
@@ -47943,15 +48020,14 @@ const MarkdownPanel = ({
47943
48020
  children: viewMode === "document" ? /* @__PURE__ */ jsx(
47944
48021
  DocumentView,
47945
48022
  {
47946
- content: slides,
48023
+ content: markdownContent,
47947
48024
  theme: theme2,
47948
48025
  fontSizeScale,
47949
48026
  onCheckboxChange: () => {
47950
48027
  },
47951
48028
  slideIdPrefix: "markdown-panel",
47952
- showSectionHeaders: true,
47953
- showSeparators: true,
47954
- maxWidth: "100%"
48029
+ maxWidth: "100%",
48030
+ repositoryInfo
47955
48031
  }
47956
48032
  ) : /* @__PURE__ */ jsx(
47957
48033
  SlidePresentationBook,
@@ -47972,7 +48048,8 @@ const MarkdownPanel = ({
47972
48048
  enableKeyboardScrolling: true,
47973
48049
  tocDisplayMode: "sidebar",
47974
48050
  tocSidebarPosition: "left",
47975
- initialTocOpen: false
48051
+ initialTocOpen: false,
48052
+ repositoryInfo
47976
48053
  }
47977
48054
  )
47978
48055
  }