mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-12-26 01:53:13 +08:00
feat(webview): can add .open-external class in webview
This commit is contained in:
parent
88ed82dd0d
commit
5108cded87
1 changed files with 3 additions and 0 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue