Merge pull request #8321 from vector-im/experimental
Merge redesign into develop
This commit is contained in:
commit
90140f6361
23 changed files with 1214 additions and 466 deletions
|
@ -1,10 +1,12 @@
|
|||
const {clipboard, nativeImage, Menu, MenuItem, shell} = require('electron');
|
||||
const url = require('url');
|
||||
|
||||
const MAILTO_PREFIX = "mailto:";
|
||||
|
||||
const PERMITTED_URL_SCHEMES = [
|
||||
'http:',
|
||||
'https:',
|
||||
'mailto:',
|
||||
MAILTO_PREFIX,
|
||||
];
|
||||
|
||||
function safeOpenURL(target) {
|
||||
|
@ -47,7 +49,7 @@ function onLinkContextMenu(ev, params) {
|
|||
|
||||
if (params.mediaType && params.mediaType === 'image' && !url.startsWith('file://')) {
|
||||
popupMenu.append(new MenuItem({
|
||||
label: 'Copy Image',
|
||||
label: 'Copy image',
|
||||
click() {
|
||||
if (url.startsWith('data:')) {
|
||||
clipboard.writeImage(nativeImage.createFromDataURL(url));
|
||||
|
@ -58,14 +60,24 @@ function onLinkContextMenu(ev, params) {
|
|||
}));
|
||||
}
|
||||
|
||||
// No point offerring to copy a blob: URL either
|
||||
// No point offering to copy a blob: URL either
|
||||
if (!url.startsWith('blob:')) {
|
||||
popupMenu.append(new MenuItem({
|
||||
label: 'Copy Link Address',
|
||||
click() {
|
||||
clipboard.writeText(url);
|
||||
},
|
||||
}));
|
||||
// Special-case e-mail URLs to strip the `mailto:` like modern browsers do
|
||||
if (url.startsWith(MAILTO_PREFIX)) {
|
||||
popupMenu.append(new MenuItem({
|
||||
label: 'Copy email address',
|
||||
click() {
|
||||
clipboard.writeText(url.substr(MAILTO_PREFIX.length));
|
||||
},
|
||||
}));
|
||||
} else {
|
||||
popupMenu.append(new MenuItem({
|
||||
label: 'Copy link address',
|
||||
click() {
|
||||
clipboard.writeText(url);
|
||||
},
|
||||
}));
|
||||
}
|
||||
}
|
||||
// popup() requires an options object even for no options
|
||||
popupMenu.popup({});
|
||||
|
@ -117,6 +129,18 @@ function onEditableContextMenu(ev, params) {
|
|||
|
||||
module.exports = (webContents) => {
|
||||
webContents.on('new-window', onWindowOrNavigate);
|
||||
// XXX: The below now does absolutely nothing because of
|
||||
// https://github.com/electron/electron/issues/8841
|
||||
// Whilst this isn't a security issue since without
|
||||
// node integration and with the sandbox, it should be
|
||||
// no worse than opening the site in Chrome, it obviously
|
||||
// means the user has to restart Riot to make it usable
|
||||
// again (often unintuitive because it minimises to the
|
||||
// system tray). We therefore need to be vigilant about
|
||||
// putting target="_blank" on links in Riot (although
|
||||
// we should generally be doing this anyway since links
|
||||
// navigating you away from Riot in the browser is
|
||||
// also annoying).
|
||||
webContents.on('will-navigate', onWindowOrNavigate);
|
||||
|
||||
webContents.on('context-menu', function(ev, params) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue