aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Stefan Malzner <stefan@adlk.io>2018-01-05 14:36:45 +0100
committerLibravatar Stefan Malzner <stefan@adlk.io>2018-01-05 14:36:45 +0100
commite2d6edf093823bbbab35ef3a1c62e946913507b8 (patch)
tree94259d76cb2127d4bfc332460e6cdf06c63300eb
parentImprove annoying livereload reload behaviour for main/webview processes (diff)
downloadferdium-app-e2d6edf093823bbbab35ef3a1c62e946913507b8.tar.gz
ferdium-app-e2d6edf093823bbbab35ef3a1c62e946913507b8.tar.zst
ferdium-app-e2d6edf093823bbbab35ef3a1c62e946913507b8.zip
feat(Services): Improve handling of external links
-rw-r--r--src/stores/ServicesStore.js4
-rw-r--r--src/webview/plugin.js16
2 files changed, 18 insertions, 2 deletions
diff --git a/src/stores/ServicesStore.js b/src/stores/ServicesStore.js
index 87ee57a0d..bd5014aaa 100644
--- a/src/stores/ServicesStore.js
+++ b/src/stores/ServicesStore.js
@@ -336,6 +336,10 @@ export default class ServicesStore extends Store {
336 redirect: false, 336 redirect: false,
337 }); 337 });
338 } 338 }
339 } else if (channel === 'new-window') {
340 const url = args[0];
341
342 this.actions.app.openExternalUrl({ url });
339 } 343 }
340 } 344 }
341 345
diff --git a/src/webview/plugin.js b/src/webview/plugin.js
index 9903ee07a..d9e021e6d 100644
--- a/src/webview/plugin.js
+++ b/src/webview/plugin.js
@@ -5,8 +5,8 @@ import path from 'path';
5import { isDevMode } from '../environment'; 5import { isDevMode } from '../environment';
6import RecipeWebview from './lib/RecipeWebview'; 6import RecipeWebview from './lib/RecipeWebview';
7 7
8import Spellchecker from './spellchecker.js'; 8import Spellchecker from './spellchecker';
9import './notifications.js'; 9import './notifications';
10 10
11ipcRenderer.on('initializeRecipe', (e, data) => { 11ipcRenderer.on('initializeRecipe', (e, data) => {
12 const modulePath = path.join(data.recipe.path, 'webview.js'); 12 const modulePath = path.join(data.recipe.path, 'webview.js');
@@ -39,3 +39,15 @@ ipcRenderer.on('settings-update', (e, data) => {
39document.addEventListener('DOMContentLoaded', () => { 39document.addEventListener('DOMContentLoaded', () => {
40 ipcRenderer.sendToHost('hello'); 40 ipcRenderer.sendToHost('hello');
41}, false); 41}, false);
42
43// Patching window.open
44const originalWindowOpen = window.open;
45
46window.open = (url, frameName, features) => {
47 // We need to differentiate if the link should be opened in a popup or in the systems default browser
48 if (!frameName && !features) {
49 return ipcRenderer.sendToHost('new-window', url);
50 }
51
52 return originalWindowOpen(url, frameName, features);
53};