shim pdf print

This commit is contained in:
Nystik
2026-03-13 19:57:37 +01:00
parent 610af0c4b1
commit 30590be9e3
4 changed files with 29 additions and 5 deletions

View File

@@ -1,8 +1,8 @@
{
"name": "obsidian-bridge",
"name": "Ignis",
"version": "0.1.0",
"private": true,
"description": "Self-hosted Obsidian via Electron API shimming",
"description": "An Electron shim and server bridge for running Obsidian in a browser.",
"scripts": {
"build:shims": "node build.js",
"dev:server": "node server/index.js",

View File

@@ -157,6 +157,15 @@ export const ipcRenderer = {
handleRequestUrl(requestId, request);
return;
}
if (channel === "print-to-pdf") {
const [options] = args;
window.print();
queueMicrotask(() => {
ipcRenderer._emit("print-to-pdf", { success: true });
});
return;
}
},
sendSync(channel, ...args) {

View File

@@ -5,10 +5,18 @@ export const dialogShim = {
return { canceled: true, filePaths: [] };
},
// TODO: replace prompt() with a styled modal (matching vault manager style)
async showSaveDialog(browserWindow, options) {
// TODO: implement custom modal
console.log("[shim:dialog] showSaveDialog (stub):", options);
return { canceled: true, filePath: undefined };
if (typeof browserWindow === "object" && !options) {
options = browserWindow;
}
const defaultName =
options?.defaultPath?.split(/[/\\]/).pop() || "download";
const name = prompt("Save as:", defaultName);
if (!name) {
return { canceled: true, filePath: undefined };
}
return { canceled: false, filePath: "/downloads/" + name };
},
async showMessageBox(browserWindow, options) {

View File

@@ -165,6 +165,13 @@ const currentWebContents = {
this._windowOpenHandler = handler;
},
printToPDF(options) {
return new Promise((resolve) => {
window.print();
resolve(Buffer.from([]));
});
},
capturePage(rect) {
// TODO: could use html2canvas
console.log("[shim:webContents] capturePage (stub)");