@industry-theme/markdown-panels 0.2.23 → 0.2.24
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;AAS5D,OAAO,gCAAgC,CAAC;AACxC,OAAO,KAAK,EAAE,mBAAmB,EAAmB,MAAM,UAAU,CAAC;AAmBrE,MAAM,WAAW,kBAAmB,SAAQ,mBAAmB;IAC7D;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,
|
|
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,MAAM,WAAW,kBAAmB,SAAQ,mBAAmB;IAC7D;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAoetD,CAAC"}
|
package/dist/panels.bundle.js
CHANGED
|
@@ -47723,22 +47723,52 @@ const MarkdownPanel = ({
|
|
|
47723
47723
|
filePath: filePathProp,
|
|
47724
47724
|
width
|
|
47725
47725
|
}) => {
|
|
47726
|
-
var _a, _b, _c, _d, _e2, _f
|
|
47726
|
+
var _a, _b, _c, _d, _e2, _f;
|
|
47727
47727
|
const { theme: theme2 } = useTheme();
|
|
47728
47728
|
const [viewMode, setViewMode] = useState("document");
|
|
47729
47729
|
const [currentSlide, setCurrentSlide] = useState(0);
|
|
47730
47730
|
const [fontSizeScale, setFontSizeScale] = useState(1);
|
|
47731
47731
|
const [isMobile, setIsMobile] = useState(false);
|
|
47732
47732
|
const [preferencesLoaded, setPreferencesLoaded] = useState(false);
|
|
47733
|
+
const [propBasedContent, setPropBasedContent] = useState(null);
|
|
47733
47734
|
useEffect(() => {
|
|
47734
|
-
if (filePathProp) {
|
|
47735
|
+
if (!filePathProp) {
|
|
47736
|
+
setPropBasedContent(null);
|
|
47737
|
+
return;
|
|
47738
|
+
}
|
|
47739
|
+
if ((propBasedContent == null ? void 0 : propBasedContent.path) === filePathProp && !propBasedContent.loading) {
|
|
47740
|
+
return;
|
|
47741
|
+
}
|
|
47742
|
+
const loadContent = async () => {
|
|
47743
|
+
var _a2;
|
|
47735
47744
|
console.log("[MarkdownPanel] Loading file from prop:", filePathProp);
|
|
47736
|
-
|
|
47737
|
-
|
|
47738
|
-
|
|
47745
|
+
setPropBasedContent({ path: filePathProp, content: "", loading: true, error: null });
|
|
47746
|
+
try {
|
|
47747
|
+
const fileSystem = (_a2 = context.adapters) == null ? void 0 : _a2.fileSystem;
|
|
47748
|
+
if (fileSystem == null ? void 0 : fileSystem.readFile) {
|
|
47749
|
+
const content2 = await fileSystem.readFile(filePathProp);
|
|
47750
|
+
setPropBasedContent({ path: filePathProp, content: content2, loading: false, error: null });
|
|
47751
|
+
} else {
|
|
47752
|
+
const setActiveFile = actions == null ? void 0 : actions.setActiveFile;
|
|
47753
|
+
if (typeof setActiveFile === "function") {
|
|
47754
|
+
await setActiveFile(filePathProp);
|
|
47755
|
+
setPropBasedContent(null);
|
|
47756
|
+
} else {
|
|
47757
|
+
throw new Error("No file reading capability available");
|
|
47758
|
+
}
|
|
47759
|
+
}
|
|
47760
|
+
} catch (err) {
|
|
47761
|
+
console.error("[MarkdownPanel] Failed to load file:", err);
|
|
47762
|
+
setPropBasedContent({
|
|
47763
|
+
path: filePathProp,
|
|
47764
|
+
content: "",
|
|
47765
|
+
loading: false,
|
|
47766
|
+
error: err instanceof Error ? err : new Error(String(err))
|
|
47767
|
+
});
|
|
47739
47768
|
}
|
|
47740
|
-
}
|
|
47741
|
-
|
|
47769
|
+
};
|
|
47770
|
+
loadContent();
|
|
47771
|
+
}, [filePathProp, (_a = context.adapters) == null ? void 0 : _a.fileSystem, actions]);
|
|
47742
47772
|
useEffect(() => {
|
|
47743
47773
|
const checkMobile = () => {
|
|
47744
47774
|
setIsMobile(window.innerWidth < 768);
|
|
@@ -47775,9 +47805,19 @@ const MarkdownPanel = ({
|
|
|
47775
47805
|
});
|
|
47776
47806
|
return unsubscribe;
|
|
47777
47807
|
}, [events]);
|
|
47778
|
-
const
|
|
47779
|
-
const
|
|
47780
|
-
const
|
|
47808
|
+
const activeFileSlice = context.getSlice("active-file");
|
|
47809
|
+
const usePropBasedContent = filePathProp && (propBasedContent == null ? void 0 : propBasedContent.path) === filePathProp;
|
|
47810
|
+
const activeFile = usePropBasedContent ? {
|
|
47811
|
+
data: {
|
|
47812
|
+
path: propBasedContent.path,
|
|
47813
|
+
content: propBasedContent.content,
|
|
47814
|
+
type: "markdown"
|
|
47815
|
+
},
|
|
47816
|
+
loading: propBasedContent.loading,
|
|
47817
|
+
error: propBasedContent.error
|
|
47818
|
+
} : activeFileSlice;
|
|
47819
|
+
const isMarkdown = ((_b = activeFile == null ? void 0 : activeFile.data) == null ? void 0 : _b.type) === "markdown" || ((_d = (_c = activeFile == null ? void 0 : activeFile.data) == null ? void 0 : _c.path) == null ? void 0 : _d.match(/\.(md|mdx|markdown)$/i));
|
|
47820
|
+
const markdownContent = ((_e2 = activeFile == null ? void 0 : activeFile.data) == null ? void 0 : _e2.content) || "";
|
|
47781
47821
|
const presentation = useMemo(
|
|
47782
47822
|
() => parseMarkdownIntoPresentation2(markdownContent),
|
|
47783
47823
|
[markdownContent]
|
|
@@ -47785,17 +47825,18 @@ const MarkdownPanel = ({
|
|
|
47785
47825
|
const slides = presentation.slides.map((slide) => slide.location.content);
|
|
47786
47826
|
const hasSlides = slides.length > 1;
|
|
47787
47827
|
const repositoryInfo = useMemo(() => {
|
|
47788
|
-
var _a2, _b2
|
|
47789
|
-
|
|
47828
|
+
var _a2, _b2;
|
|
47829
|
+
if (usePropBasedContent || !(activeFileSlice == null ? void 0 : activeFileSlice.data)) return void 0;
|
|
47830
|
+
const source2 = "source" in activeFileSlice.data ? activeFileSlice.data.source : void 0;
|
|
47790
47831
|
if (!source2) return void 0;
|
|
47791
|
-
const branch = source2.locationType === "branch" ? source2.location : ((
|
|
47832
|
+
const branch = source2.locationType === "branch" ? source2.location : ((_a2 = source2.metadata) == null ? void 0 : _a2.currentBranch) || "main";
|
|
47792
47833
|
return {
|
|
47793
47834
|
owner: source2.owner,
|
|
47794
47835
|
repo: source2.name,
|
|
47795
47836
|
branch,
|
|
47796
|
-
basePath: getBasePath(((
|
|
47837
|
+
basePath: getBasePath(((_b2 = activeFileSlice == null ? void 0 : activeFileSlice.data) == null ? void 0 : _b2.path) || "")
|
|
47797
47838
|
};
|
|
47798
|
-
}, [
|
|
47839
|
+
}, [usePropBasedContent, activeFileSlice == null ? void 0 : activeFileSlice.data]);
|
|
47799
47840
|
const handleFontSizeIncrease = () => {
|
|
47800
47841
|
setFontSizeScale((prev) => {
|
|
47801
47842
|
const newScale = Math.min(prev + 0.1, 3);
|
|
@@ -47844,7 +47885,7 @@ const MarkdownPanel = ({
|
|
|
47844
47885
|
},
|
|
47845
47886
|
children: /* @__PURE__ */ jsx("div", { style: { textAlign: "center" }, children: /* @__PURE__ */ jsxs("p", { style: { color: theme2.colors.textSecondary }, children: [
|
|
47846
47887
|
"Loading ",
|
|
47847
|
-
((
|
|
47888
|
+
((_f = activeFile.data) == null ? void 0 : _f.path) || "file",
|
|
47848
47889
|
"..."
|
|
47849
47890
|
] }) })
|
|
47850
47891
|
}
|