aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Stefan Malzner <stefan@adlk.io>2018-01-05 14:38:16 +0100
committerLibravatar GitHub <noreply@github.com>2018-01-05 14:38:16 +0100
commit9040afb1d25396a4beb03a512b8cbaa173bb745f (patch)
treeff54ec99039e8932df8460dbdc799d186e24d44c
parentMerge pull request #518 from dannyqiu/bug-fixes (diff)
parentfeat(Services): Improve handling of external links (diff)
downloadferdium-app-9040afb1d25396a4beb03a512b8cbaa173bb745f.tar.gz
ferdium-app-9040afb1d25396a4beb03a512b8cbaa173bb745f.tar.zst
ferdium-app-9040afb1d25396a4beb03a512b8cbaa173bb745f.zip
Merge pull request #541 from meetfranz/feature/external-links
[PR] Improve external link handling
-rw-r--r--gulpfile.babel.js2
-rw-r--r--src/index.html18
-rw-r--r--src/stores/ServicesStore.js4
-rw-r--r--src/webview/plugin.js16
4 files changed, 36 insertions, 4 deletions
diff --git a/gulpfile.babel.js b/gulpfile.babel.js
index b50001b2d..95b026f66 100644
--- a/gulpfile.babel.js
+++ b/gulpfile.babel.js
@@ -112,8 +112,6 @@ export function watch() {
112export function webserver() { 112export function webserver() {
113 gulp.src([ 113 gulp.src([
114 paths.dest, 114 paths.dest,
115 `!${paths.dest}/electron/**`,
116 `!${paths.dest}/webview/**`,
117 ]) 115 ])
118 .pipe(server({ 116 .pipe(server({
119 livereload: true, 117 livereload: true,
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';
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};