( plugin: CodeSpacePlugin, invokeOriginal: () => unknown, preferredView?: MutableMarkdownView | null )
| 483 | } |
| 484 | |
| 485 | async function runPatchedNativePdfExport( |
| 486 | plugin: CodeSpacePlugin, |
| 487 | invokeOriginal: () => unknown, |
| 488 | preferredView?: MutableMarkdownView | null |
| 489 | ): Promise<unknown> { |
| 490 | const view = |
| 491 | (preferredView?.file ? preferredView : null) ?? |
| 492 | (plugin.app.workspace.getActiveViewOfType(MarkdownView) as MutableMarkdownView | null); |
| 493 | if (!view?.file) { |
| 494 | debugNativePdf(null, "native export invoked without active markdown view"); |
| 495 | return await Promise.resolve(invokeOriginal()); |
| 496 | } |
| 497 | |
| 498 | const ownerDoc = view.containerEl?.ownerDocument ?? activeDocument; |
| 499 | const knownModals = getModalContainers(ownerDoc); |
| 500 | const fallbackMarkdown = view.getViewData(); |
| 501 | const stopSession = beginNativeExportSession(plugin, view.file, fallbackMarkdown, ownerDoc, knownModals); |
| 502 | debugNativePdf(activeNativeExportSession, "invoking original native export command", { |
| 503 | file: view.file.path, |
| 504 | markdownLength: fallbackMarkdown.length, |
| 505 | }); |
| 506 | |
| 507 | try { |
| 508 | const result = await Promise.resolve(invokeOriginal()); |
| 509 | return result; |
| 510 | } catch (error) { |
| 511 | stopSession(); |
| 512 | throw error; |
| 513 | } |
| 514 | } |
| 515 | |
| 516 | function installCachedReadOverride(plugin: CodeSpacePlugin) { |
| 517 | const vault = plugin.app.vault as MutableVault; |
no test coverage detected