diff options
author | Stefan Malzner <stefan@adlk.io> | 2018-01-05 14:36:45 +0100 |
---|---|---|
committer | Stefan Malzner <stefan@adlk.io> | 2018-01-05 14:36:45 +0100 |
commit | e2d6edf093823bbbab35ef3a1c62e946913507b8 (patch) | |
tree | 94259d76cb2127d4bfc332460e6cdf06c63300eb /src | |
parent | Improve annoying livereload reload behaviour for main/webview processes (diff) | |
download | ferdium-app-e2d6edf093823bbbab35ef3a1c62e946913507b8.tar.gz ferdium-app-e2d6edf093823bbbab35ef3a1c62e946913507b8.tar.zst ferdium-app-e2d6edf093823bbbab35ef3a1c62e946913507b8.zip |
feat(Services): Improve handling of external links
Diffstat (limited to 'src')
-rw-r--r-- | src/stores/ServicesStore.js | 4 | ||||
-rw-r--r-- | src/webview/plugin.js | 16 |
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'; | |||
5 | import { isDevMode } from '../environment'; | 5 | import { isDevMode } from '../environment'; |
6 | import RecipeWebview from './lib/RecipeWebview'; | 6 | import RecipeWebview from './lib/RecipeWebview'; |
7 | 7 | ||
8 | import Spellchecker from './spellchecker.js'; | 8 | import Spellchecker from './spellchecker'; |
9 | import './notifications.js'; | 9 | import './notifications'; |
10 | 10 | ||
11 | ipcRenderer.on('initializeRecipe', (e, data) => { | 11 | ipcRenderer.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) => { | |||
39 | document.addEventListener('DOMContentLoaded', () => { | 39 | document.addEventListener('DOMContentLoaded', () => { |
40 | ipcRenderer.sendToHost('hello'); | 40 | ipcRenderer.sendToHost('hello'); |
41 | }, false); | 41 | }, false); |
42 | |||
43 | // Patching window.open | ||
44 | const originalWindowOpen = window.open; | ||
45 | |||
46 | window.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 | }; | ||