var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // main.ts var main_exports = {}; __export(main_exports, { default: () => CustomPdfExportPlugin }); module.exports = __toCommonJS(main_exports); var import_obsidian = require("obsidian"); var CustomPdfExportPlugin = class extends import_obsidian.Plugin { async onload() { this.addRibbonIcon("document", "Custom PDF Export", () => { new PdfExportModal(this.app).open(); }); this.addCommand({ id: "open-custom-pdf-export", name: "Export note to styled PDF", callback: () => { new PdfExportModal(this.app).open(); } }); } }; var PdfExportModal = class extends import_obsidian.Modal { constructor(app) { super(app); this.pdfFont = "Inter"; this.pdfFontSize = "14px"; this.pdfThemeColor = "#333333"; this.activeFile = null; this.previewComponent = new import_obsidian.Component(); } onOpen() { const { contentEl } = this; contentEl.empty(); this.previewComponent.load(); contentEl.addClass("pdf-export-modal-content"); const container = contentEl.createDiv({ cls: "pdf-split-container" }); const controlsPane = container.createDiv({ cls: "pdf-controls-pane" }); controlsPane.createEl("h2", { text: "PDF Settings" }); new import_obsidian.Setting(controlsPane).setName("Font Family").addText( (t) => t.setValue(this.pdfFont).onChange((v) => { this.pdfFont = v; this.updatePreviewVariables(); }) ); new import_obsidian.Setting(controlsPane).setName("Font Size").addText( (t) => t.setValue(this.pdfFontSize).onChange((v) => { this.pdfFontSize = v; this.updatePreviewVariables(); }) ); new import_obsidian.Setting(controlsPane).setName("Theme Color").addColorPicker( (c) => c.setValue(this.pdfThemeColor).onChange((v) => { this.pdfThemeColor = v; this.updatePreviewVariables(); }) ); const exportBtn = controlsPane.createEl("button", { text: "Export PDF", cls: "mod-cta" }); exportBtn.onclick = () => this.executeExport(); const previewPane = container.createDiv({ cls: "pdf-preview-pane" }); previewPane.createEl("h3", { text: "Preview" }); this.previewContainer = previewPane.createDiv({ cls: "pdf-preview-container pdf-export" }); this.activeFile = this.app.workspace.getActiveFile(); if (this.activeFile) { this.renderPreview(); } else { this.previewContainer.setText("Open a note to preview."); } this.updatePreviewVariables(); } onClose() { this.previewComponent.unload(); } async renderPreview() { if (!this.activeFile) return; const content = await this.app.vault.cachedRead(this.activeFile); this.previewContainer.empty(); const transformed = this.transformFootnotesForPdf(content); await import_obsidian.MarkdownRenderer.renderMarkdown( transformed, this.previewContainer, this.activeFile.path, this.previewComponent ); } updatePreviewVariables() { if (!this.previewContainer) return; this.previewContainer.style.setProperty("--pdf-font", this.pdfFont); this.previewContainer.style.setProperty("--pdf-font-size", this.pdfFontSize); this.previewContainer.style.setProperty("--pdf-theme-color", this.pdfThemeColor); } transformFootnotesForPdf(content) { return content.replace(/\^\[([^\]]+)\]/g, (_, note) => { return `(${note})`; }); } executeExport() { if (!this.activeFile) { new import_obsidian.Notice("No active note."); return; } document.body.style.setProperty("--pdf-font", this.pdfFont); document.body.style.setProperty("--pdf-font-size", this.pdfFontSize); document.body.style.setProperty("--pdf-theme-color", this.pdfThemeColor); this.app.commands.executeCommandById("workspace:export-pdf"); new import_obsidian.Notice("Choose where to save the exported PDF."); this.close(); setTimeout(() => { document.body.style.removeProperty("--pdf-font"); document.body.style.removeProperty("--pdf-font-size"); document.body.style.removeProperty("--pdf-theme-color"); }, 5e3); } };