shim pdf print
This commit is contained in:
parent
610af0c4b1
commit
30590be9e3
4 changed files with 29 additions and 5 deletions
|
|
@ -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",
|
||||||
|
|
|
||||||
|
|
@ -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) {
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
return { canceled: true, filePath: undefined };
|
}
|
||||||
|
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) {
|
async showMessageBox(browserWindow, options) {
|
||||||
|
|
|
||||||
|
|
@ -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)");
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue