diff options
author | 2018-01-05 14:36:45 +0100 | |
---|---|---|
committer | 2018-01-05 14:36:45 +0100 | |
commit | e2d6edf093823bbbab35ef3a1c62e946913507b8 (patch) | |
tree | 94259d76cb2127d4bfc332460e6cdf06c63300eb /src/webview | |
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/webview')
-rw-r--r-- | src/webview/plugin.js | 16 |
1 files changed, 14 insertions, 2 deletions
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 | }; | ||