From f9cb20ffcbb1294e31c3a14e5535d4f12274b13c Mon Sep 17 00:00:00 2001 From: Stefan Malzner Date: Fri, 5 Jan 2018 14:34:36 +0100 Subject: Improve annoying livereload reload behaviour for main/webview processes --- src/index.html | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src') 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 @@ s.async = true; s.setAttribute('src', lrHost + '/livereload.js'); document.body.appendChild(s); + + s.onload = () => { + console.log('livereload loaded'); + const originalReloadBehaviour = window._onLiveReloadFileChanged; + + window._onLiveReloadFileChanged = (file) => { + if (!file.path.includes('/build/webview/') && !file.path.includes('/build/index.js') && !file.path.includes('/build/electron/')) { + originalReloadBehaviour(file); + } else { + if (file.path.includes('/build/webview/')) { + console.log('Livereload: Reloading all webvies'); + const webviews = document.querySelectorAll('webview').forEach(webview => webview.reload()); + } else { + console.log('Livereload: skip reload as only main process files have changed'); + } + } + } + } })(); } -- cgit v1.2.3-70-g09d2 From e2d6edf093823bbbab35ef3a1c62e946913507b8 Mon Sep 17 00:00:00 2001 From: Stefan Malzner Date: Fri, 5 Jan 2018 14:36:45 +0100 Subject: feat(Services): Improve handling of external links --- src/stores/ServicesStore.js | 4 ++++ src/webview/plugin.js | 16 ++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) (limited to 'src') 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 { redirect: false, }); } + } else if (channel === 'new-window') { + const url = args[0]; + + this.actions.app.openExternalUrl({ url }); } } 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'; import { isDevMode } from '../environment'; import RecipeWebview from './lib/RecipeWebview'; -import Spellchecker from './spellchecker.js'; -import './notifications.js'; +import Spellchecker from './spellchecker'; +import './notifications'; ipcRenderer.on('initializeRecipe', (e, data) => { const modulePath = path.join(data.recipe.path, 'webview.js'); @@ -39,3 +39,15 @@ ipcRenderer.on('settings-update', (e, data) => { document.addEventListener('DOMContentLoaded', () => { ipcRenderer.sendToHost('hello'); }, false); + +// Patching window.open +const originalWindowOpen = window.open; + +window.open = (url, frameName, features) => { + // We need to differentiate if the link should be opened in a popup or in the systems default browser + if (!frameName && !features) { + return ipcRenderer.sendToHost('new-window', url); + } + + return originalWindowOpen(url, frameName, features); +}; -- cgit v1.2.3-70-g09d2