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", "version": "0.1.0",
"private": true, "private": true,
"description": "Self-hosted Obsidian via Electron API shimming", "description": "An Electron shim and server bridge for running Obsidian in a browser.",
"scripts": { "scripts": {
"build:shims": "node build.js", "build:shims": "node build.js",
"dev:server": "node server/index.js", "dev:server": "node server/index.js",

View file

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

View file

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

View file

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