add shim, basic stubs

This commit is contained in:
Nystik
2026-03-07 12:23:08 +01:00
parent 1c5aaa8b45
commit 8b43493d87
5 changed files with 360 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
// Shim for electron.webFrame
// Obsidian uses: getZoomLevel(), setZoomLevel()
let currentZoom = 0;
export const webFrame = {
getZoomLevel() {
return currentZoom;
},
setZoomLevel(level) {
currentZoom = level;
// Approximate Electron's zoom behavior via CSS zoom
// Electron zoom level 0 = 100%, each step is ~20%
const scale = Math.pow(1.2, level);
document.body.style.zoom = scale;
},
getZoomFactor() {
return Math.pow(1.2, currentZoom);
},
setZoomFactor(factor) {
currentZoom = Math.log(factor) / Math.log(1.2);
document.body.style.zoom = factor;
},
};