Skip to content
Permalink
Browse files
feat(Services): Improve handling of external links
  • Loading branch information
adlk committed Jan 5, 2018
1 parent f9cb20f commit e2d6edf093823bbbab35ef3a1c62e946913507b8
Showing with 18 additions and 2 deletions.
  1. +4 −0 src/stores/ServicesStore.js
  2. +14 −2 src/webview/plugin.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 });
}
}

@@ -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);
};

0 comments on commit e2d6edf

Please sign in to comment.