open external links in system browser

This commit is contained in:
Christopher Willis-Ford 2020-10-06 14:34:01 -07:00
parent 8fc98e1c37
commit 3b1dd4e008
4 changed files with 12 additions and 11 deletions

View file

@ -1,4 +1,4 @@
import {BrowserWindow, Menu, app, dialog, ipcMain, systemPreferences} from 'electron';
import {BrowserWindow, Menu, app, dialog, ipcMain, shell, systemPreferences} from 'electron';
import fs from 'fs-extra';
import path from 'path';
import {URL} from 'url';
@ -193,6 +193,11 @@ const createWindow = ({search = null, url = 'index.html', ...browserWindowOption
}
});
webContents.on('new-window', (event, newWindowUrl) => {
shell.openExternal(newWindowUrl);
event.preventDefault();
});
const fullUrl = makeFullUrl(url, search);
window.loadURL(fullUrl);

View file

@ -5,7 +5,6 @@ import {productName, version} from '../../package.json';
import logo from '../icon/ScratchDesktop.svg';
import styles from './about.css';
// TODO: localization?
const AboutElement = () => (
<div className={styles.aboutBox}>
<div><img

View file

@ -1,4 +1,4 @@
import {ipcRenderer, remote, shell} from 'electron';
import {ipcRenderer, remote} from 'electron';
import bindAll from 'lodash.bindall';
import omit from 'lodash.omit';
import PropTypes from 'prop-types';
@ -28,12 +28,6 @@ import ElectronStorageHelper from '../common/ElectronStorageHelper';
import styles from './app.css';
// override window.open so that it uses the OS's default browser, not an electron browser
window.open = function (url, target) {
if (target === '_blank') {
shell.openExternal(url);
}
};
// Register "base" page view
// analytics.pageview('/');

View file

@ -3,7 +3,6 @@ import ReactDOM from 'react-dom';
import styles from './privacy.css';
// TODO: localization?
const PrivacyElement = () => (
<div className={styles.privacyBox}>
<h1>Privacy Policy</h1>
@ -11,7 +10,11 @@ const PrivacyElement = () => (
We understand how important privacy is to our community, especially children and their parents. We wrote
this privacy policy to explain what information we collect through the Scratch application (the
&ldquo;App&rdquo;), how we use it, and what we&apos;re doing to keep it safe. If you have any questions
regarding this privacy policy, you can <a href="https://scratch.mit.edu/contact-us">contact us</a>.
regarding this privacy policy, you can <a
href="https://scratch.mit.edu/contact-us/"
target="_blank"
rel="noopener noreferrer"
>contact us</a>.
</p>
<h2>What information does the App collect?</h2>
<p>