From 126000617f07bd38a6a7789e2ac0f8c70f1e9d5e Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Tue, 26 Apr 2022 13:05:22 +0200 Subject: [PATCH] added a setting to force iframe usage Closes #25 --- src/frame.ts | 2 +- src/settings-tab.ts | 15 +++++++++++++++ src/settings.ts | 7 +++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/frame.ts b/src/frame.ts index e776c8a..f12e705 100644 --- a/src/frame.ts +++ b/src/frame.ts @@ -16,7 +16,7 @@ export class CustomFrame { let style = `padding: ${this.settings.padding}px;`; if (additionalStyle) style += additionalStyle; - if (Platform.isDesktopApp) { + if (Platform.isDesktopApp && !this.data.forceIframe) { this.frame = document.createElement("webview"); this.frame.setAttribute("allowpopups", ""); this.frame.addEventListener("dom-ready", () => { diff --git a/src/settings-tab.ts b/src/settings-tab.ts index f260375..840c316 100644 --- a/src/settings-tab.ts +++ b/src/settings-tab.ts @@ -111,6 +111,20 @@ export class CustomFramesSettingTab extends PluginSettingTab { await this.plugin.saveSettings(); }); }); + new Setting(content) + .setName("Force iframe") + .setDesc(createFragment(f => { + f.createSpan({ text: "Whether this frame should use iframes on desktop as opposed to Electron webviews." }); + f.createEl("br"); + f.createEl("em", { text: "Only enable this setting if the frame is causing issues or frequent crashes. This setting causes all Desktop-only settings to be ignored." }); + })) + .addToggle(t => { + t.setValue(frame.forceIframe); + t.onChange(async v => { + frame.forceIframe = v; + await this.plugin.saveSettings(); + }); + }); new Setting(content) .setName("Page Zoom") .setDesc("The zoom that this frame's page should be displayed with, as a percentage.") @@ -171,6 +185,7 @@ export class CustomFramesSettingTab extends PluginSettingTab { addRibbonIcon: false, openInCenter: false, zoomLevel: 1, + forceIframe: false, customCss: "" }); } diff --git a/src/settings.ts b/src/settings.ts index 9976f2e..66c249b 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -11,6 +11,7 @@ export const presets: Record = { addRibbonIcon: true, openInCenter: true, zoomLevel: 1, + forceIframe: false, customCss: "" }, "calendar": { @@ -21,6 +22,7 @@ export const presets: Record = { addRibbonIcon: true, openInCenter: true, zoomLevel: 1, + forceIframe: false, customCss: `/* hide right-side menu, and some buttons */ div.d6McF, div.pw6cBb, @@ -40,6 +42,7 @@ div.dwlvNd { addRibbonIcon: false, openInCenter: false, zoomLevel: 1, + forceIframe: false, customCss: `/* hide the menu bar and the "Keep" text */ html > body > div:nth-child(2) > div:nth-child(2) > div:first-child, html > body > div:first-child > header:first-child > div > div:first-child > div > div:first-child > a:first-child > span { @@ -54,6 +57,7 @@ html > body > div:first-child > header:first-child > div > div:first-child > div addRibbonIcon: false, openInCenter: false, zoomLevel: 1, + forceIframe: false, customCss: `/* hide the help, home, search, and productivity overview buttons, create extra space, and prevent toast pop-up from acting weird */ [aria-label="Go to Home view"], #quick_find, [aria-label="Productivity"], [aria-label="Help & Feedback"] { display: none !important; @@ -80,6 +84,7 @@ html > body > div:first-child > header:first-child > div > div:first-child > div addRibbonIcon: true, openInCenter: true, zoomLevel: 1, + forceIframe: false, customCss: "" }, "twitter": { @@ -90,6 +95,7 @@ html > body > div:first-child > header:first-child > div > div:first-child > div addRibbonIcon: false, openInCenter: false, zoomLevel: 1, + forceIframe: false, customCss: "" } }; @@ -107,6 +113,7 @@ export interface CustomFrameSettings { addRibbonIcon: boolean; openInCenter: boolean; zoomLevel: number; + forceIframe: boolean; customCss: string; }