From 000472fd9e5dbe73fed6262add7f51137eed5404 Mon Sep 17 00:00:00 2001 From: aidenlx Date: Sun, 16 Jan 2022 16:29:46 +0800 Subject: [PATCH] fix(hack-pdf): fix internal links failed to export --- src/hack-pdf.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/hack-pdf.ts b/src/hack-pdf.ts index a9f03bd..a349304 100644 --- a/src/hack-pdf.ts +++ b/src/hack-pdf.ts @@ -3,8 +3,6 @@ import { MarkdownView, TFile, Vault } from "obsidian"; import TableExtended from "./tx-main"; -const placeholder = "export2pdf"; - const Export2PDFHack = (plugin: TableExtended) => { const unloaders = [ around(MarkdownView.prototype, { @@ -12,8 +10,8 @@ const Export2PDFHack = (plugin: TableExtended) => { printToPdf: (original) => function (this: MarkdownView) { plugin.print2pdfFileCache = this.file; - // @ts-ignore - this.file = placeholder; + // shalow copy the file to provide basic info + this.file = { ...this.file, export2pdf: true } as any; original.call(this); this.file = plugin.print2pdfFileCache; }, @@ -21,7 +19,7 @@ const Export2PDFHack = (plugin: TableExtended) => { around(Vault.prototype, { cachedRead: (original) => async function (this: Vault, input: TFile | string) { - if (input === placeholder) { + if (!(input instanceof TFile) && (input as any)?.export2pdf) { const file = plugin.print2pdfFileCache; if (!file) { throw new Error(