diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/index.html | 18 | ||||
-rw-r--r-- | src/stores/ServicesStore.js | 4 | ||||
-rw-r--r-- | src/webview/plugin.js | 16 |
3 files changed, 36 insertions, 2 deletions
diff --git a/src/index.html b/src/index.html index 05a93e37b..9e5acd705 100644 --- a/src/index.html +++ b/src/index.html | |||
@@ -23,6 +23,24 @@ | |||
23 | s.async = true; | 23 | s.async = true; |
24 | s.setAttribute('src', lrHost + '/livereload.js'); | 24 | s.setAttribute('src', lrHost + '/livereload.js'); |
25 | document.body.appendChild(s); | 25 | document.body.appendChild(s); |
26 | |||
27 | s.onload = () => { | ||
28 | console.log('livereload loaded'); | ||
29 | const originalReloadBehaviour = window._onLiveReloadFileChanged; | ||
30 | |||
31 | window._onLiveReloadFileChanged = (file) => { | ||
32 | if (!file.path.includes('/build/webview/') && !file.path.includes('/build/index.js') && !file.path.includes('/build/electron/')) { | ||
33 | originalReloadBehaviour(file); | ||
34 | } else { | ||
35 | if (file.path.includes('/build/webview/')) { | ||
36 | console.log('Livereload: Reloading all webvies'); | ||
37 | const webviews = document.querySelectorAll('webview').forEach(webview => webview.reload()); | ||
38 | } else { | ||
39 | console.log('Livereload: skip reload as only main process files have changed'); | ||
40 | } | ||
41 | } | ||
42 | } | ||
43 | } | ||
26 | })(); | 44 | })(); |
27 | } | 45 | } |
28 | </script> | 46 | </script> |
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 | }; | ||