From 5108cded87ef489931ddcc92a0f037094e564624 Mon Sep 17 00:00:00 2001 From: Evan Morikawa Date: Mon, 29 Aug 2016 19:07:44 -0700 Subject: [PATCH] feat(webview): can add .open-external class in webview --- internal_packages/onboarding/lib/page-authenticate.jsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal_packages/onboarding/lib/page-authenticate.jsx b/internal_packages/onboarding/lib/page-authenticate.jsx index f260954ee..c230d7e22 100644 --- a/internal_packages/onboarding/lib/page-authenticate.jsx +++ b/internal_packages/onboarding/lib/page-authenticate.jsx @@ -1,4 +1,5 @@ import React from 'react'; +import {shell} from 'electron' import classnames from 'classnames'; import ReactDOM from 'react-dom'; import {IdentityStore} from 'nylas-exports'; @@ -86,6 +87,7 @@ export default class AuthenticatePage extends React.Component { webview.addEventListener('did-fail-load', this.webviewDidFailLoad); webview.addEventListener('did-finish-load', this.webviewDidFinishLoad); webview.addEventListener('console-message', (e) => { + if (/^http.+/i.test(e.message)) { shell.openExternal(e.message) } console.log('Guest page logged a message:', e.message); }); } @@ -128,6 +130,7 @@ export default class AuthenticatePage extends React.Component { const js = ` var a = document.querySelector('#pro-account'); result = a ? a.innerText : null; + document.querySelector('.open-external').addEventListener('click', function(event) {console.log(this.href); event.preventDefault(); return false;}) `; const webview = ReactDOM.findDOMNode(this.refs.webview);