mirror of
https://github.com/amitwh/markdown-converter.git
synced 2026-10-01 09:19:34 +05:30
fix(flowchart): pre-await getUserDataPath to fix persistence; bump v4.9.0 → v4.9.1
Amit Haridas
This commit is contained in:
+12
-4
@@ -2436,16 +2436,24 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||
.run({ nodes: [div] })
|
||||
.catch((err) => console.warn('flowchart preview render failed:', err));
|
||||
};
|
||||
// Pre-resolve the userData path on first panel render and cache it. The
|
||||
// flowchart panel's getUserDataPath() must be sync (it is interpolated into
|
||||
// the persistence path on mount); calling flowchartIO.getUserDataPath()
|
||||
// directly would coerce the IPC Promise to "[object Promise]" and break
|
||||
// every write/read against <userData>/flowchart-session.json.
|
||||
let cachedUserDataPath = null;
|
||||
sidebarManager.registerPanel('flowchart', {
|
||||
title: 'Flow Chart',
|
||||
render: (container) =>
|
||||
renderFlowChartPanel(container, {
|
||||
getUserDataPath: flowchartIO.getUserDataPath,
|
||||
render: async (container) => {
|
||||
if (!cachedUserDataPath) cachedUserDataPath = await flowchartIO.getUserDataPath();
|
||||
return renderFlowChartPanel(container, {
|
||||
getUserDataPath: () => cachedUserDataPath,
|
||||
readFile: flowchartIO.readFile,
|
||||
writeFile: flowchartIO.writeFile,
|
||||
insertAtCursor: (text) => tabManager.insertAtCursor(text),
|
||||
renderMermaid: renderFlowChartMermaid,
|
||||
}),
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
// Wiki-link navigation: open the target note (creating it on demand after
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
*
|
||||
* @param {HTMLElement} container Mount point inside the sidebar panel
|
||||
* @param {object} deps
|
||||
* @param {() => string} deps.getUserDataPath Absolute userData directory
|
||||
* @param {() => string} deps.getUserDataPath Absolute userData directory (renderer pre-resolves and caches this on first mount — must be synchronous and return a real string, not a Promise)
|
||||
* @param {(path:string) => Promise<string|null>} deps.readFile
|
||||
* @param {(path:string, content:string) => Promise<void>} deps.writeFile
|
||||
* @param {(text:string) => void} deps.insertAtCursor
|
||||
|
||||
Reference in New Issue
Block a user