diff --git a/app/src/quickpreview/index.es6 b/app/src/quickpreview/index.es6 index b7d9cb905..03cf5b542 100644 --- a/app/src/quickpreview/index.es6 +++ b/app/src/quickpreview/index.es6 @@ -53,6 +53,95 @@ const CrossplatformPreviewableExtensions = [ 'xlsb', ]; +const PreviewWindowMenuTemplate = [ + { + label: 'File', + role: 'window', + submenu: [ + { + label: 'Minimize Window', + accelerator: 'CmdOrCtrl+M', + role: 'minimize', + }, + { + label: 'Close Window', + accelerator: 'CmdOrCtrl+W', + role: 'close', + }, + ], + }, + { + label: 'Edit', + submenu: [ + { + label: 'Undo', + accelerator: 'CmdOrCtrl+Z', + role: 'undo', + }, + { + label: 'Redo', + accelerator: 'Shift+CmdOrCtrl+Z', + role: 'redo', + }, + { + type: 'separator', + }, + { + label: 'Cut', + accelerator: 'CmdOrCtrl+X', + role: 'cut', + }, + { + label: 'Copy', + accelerator: 'CmdOrCtrl+C', + role: 'copy', + }, + { + label: 'Paste', + accelerator: 'CmdOrCtrl+V', + role: 'paste', + }, + { + label: 'Select All', + accelerator: 'CmdOrCtrl+A', + role: 'selectall', + }, + ], + }, + { + label: 'View', + submenu: [ + { + label: 'Reload', + accelerator: 'CmdOrCtrl+R', + click: function(item, focusedWindow) { + if (focusedWindow) focusedWindow.reload(); + }, + }, + { + label: 'Toggle Full Screen', + accelerator: (function() { + if (process.platform === 'darwin') return 'Ctrl+Command+F'; + else return 'F11'; + })(), + click: function(item, focusedWindow) { + if (focusedWindow) focusedWindow.setFullScreen(!focusedWindow.isFullScreen()); + }, + }, + { + label: 'Toggle Developer Tools', + accelerator: (function() { + if (process.platform === 'darwin') return 'Alt+Command+I'; + else return 'Ctrl+Shift+I'; + })(), + click: function(item, focusedWindow) { + if (focusedWindow) focusedWindow.toggleDevTools(); + }, + }, + ], + }, +]; + export function canPossiblyPreviewExtension(file) { if (file.size > FileSizeLimit) { return false; @@ -92,6 +181,7 @@ export function displayQuickPreviewWindow(filePath) { quickPreviewWindow.once('closed', () => { quickPreviewWindow = null; }); + quickPreviewWindow.setMenu(remote.Menu.buildFromTemplate(PreviewWindowMenuTemplate)); } else { quickPreviewWindow.show(); } diff --git a/app/src/quickpreview/preload.js b/app/src/quickpreview/preload.js index b9941392a..631c0a105 100644 --- a/app/src/quickpreview/preload.js +++ b/app/src/quickpreview/preload.js @@ -35,6 +35,9 @@ global.finishWithData = (previewPath, arrayBuffer) => { }; global.finishWithWindowCapture = (previewPath, startedAt = Date.now()) => { + // Remove scroll bars or they appear in the capture on Windows + document.body.style.overflow = 'hidden'; + // Wait up to 1 sec for images in the rendered HTML to finish loading const waitingForImage = Array.from(document.querySelectorAll('img')).find( i => i.complete === false