Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

fix: open external links in default browser (fixes streetwriters/notesnook#248)

thecodrr4fc62b7f0abd
diff --git a/apps/web/desktop/electron.js b/apps/web/desktop/electron.js
index e4239e0db..cf23f5d96 100644
--- a/apps/web/desktop/electron.js
+++ b/apps/web/desktop/electron.js
@@ -1,4 +1,4 @@
-const { app, BrowserWindow, nativeTheme } = require("electron");
+const { app, BrowserWindow, nativeTheme, shell } = require("electron");
const path = require("path");
const os = require("os");
const { isDevelopment } = require("./utils");
@@ -42,7 +42,7 @@ async function createWindow() {
nodeIntegration: false, //true,
enableRemoteModule: false,
contextIsolation: true,
- nativeWindowOpen: true,
+ nativeWindowOpen: false,
spellcheck: false,
preload: __dirname + "/preload.js",
},
@@ -65,6 +65,14 @@ async function createWindow() {
global.win = null;
});
+ mainWindow.webContents.setWindowOpenHandler((details) => {
+ if (details.frameName === "_blank") {
+ shell.openExternal(details.url);
+ return { action: "deny" };
+ }
+ return { action: "allow" };
+ });
+
nativeTheme.on("updated", () => {
if (getTheme() === "system") {
sendMessageToRenderer(EVENTS.themeChanged, {