()
| 117 | let cancelled = false |
| 118 | |
| 119 | const load = async (): Promise<void> => { |
| 120 | try { |
| 121 | const [vault, notes, assetFiles, noteContent] = await Promise.all([ |
| 122 | window.zen.getCurrentVault(), |
| 123 | window.zen.listNotes(), |
| 124 | window.zen.listAssets(), |
| 125 | window.zen.readNote(notePath) |
| 126 | ]) |
| 127 | if (cancelled) return |
| 128 | if (!vault) { |
| 129 | throw new Error('No active vault was available for PDF export.') |
| 130 | } |
| 131 | |
| 132 | useStore.setState({ |
| 133 | vault: vault as VaultInfo, |
| 134 | notes: notes as NoteMeta[], |
| 135 | assetFiles: assetFiles as AssetMeta[], |
| 136 | selectedPath: noteContent.path, |
| 137 | activeNote: noteContent |
| 138 | }) |
| 139 | document.title = `${noteContent.title}.pdf` |
| 140 | setNote(noteContent) |
| 141 | } catch (err) { |
| 142 | if (cancelled) return |
| 143 | setError(err instanceof Error ? err.message : String(err)) |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | void load() |
| 148 |
no test coverage detected