mirror of
https://github.com/SchildiChat/element-web.git
synced 2024-10-01 01:26:12 -04:00
Merge pull request #11690 from vector-im/t3chguy/context_menu_accelerators
Add accelerators to context menu options like cut&paste in electron
This commit is contained in:
commit
443d3812d1
@ -56,7 +56,7 @@ function onLinkContextMenu(ev, params) {
|
|||||||
let addSaveAs = false;
|
let addSaveAs = false;
|
||||||
if (params.mediaType && params.mediaType === 'image' && !url.startsWith('file://')) {
|
if (params.mediaType && params.mediaType === 'image' && !url.startsWith('file://')) {
|
||||||
popupMenu.append(new MenuItem({
|
popupMenu.append(new MenuItem({
|
||||||
label: 'Copy image',
|
label: '&Copy image',
|
||||||
click() {
|
click() {
|
||||||
if (url.startsWith('data:')) {
|
if (url.startsWith('data:')) {
|
||||||
clipboard.writeImage(nativeImage.createFromDataURL(url));
|
clipboard.writeImage(nativeImage.createFromDataURL(url));
|
||||||
@ -76,14 +76,14 @@ function onLinkContextMenu(ev, params) {
|
|||||||
// Special-case e-mail URLs to strip the `mailto:` like modern browsers do
|
// Special-case e-mail URLs to strip the `mailto:` like modern browsers do
|
||||||
if (url.startsWith(MAILTO_PREFIX)) {
|
if (url.startsWith(MAILTO_PREFIX)) {
|
||||||
popupMenu.append(new MenuItem({
|
popupMenu.append(new MenuItem({
|
||||||
label: 'Copy email address',
|
label: 'Copy email &address',
|
||||||
click() {
|
click() {
|
||||||
clipboard.writeText(url.substr(MAILTO_PREFIX.length));
|
clipboard.writeText(url.substr(MAILTO_PREFIX.length));
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
} else {
|
} else {
|
||||||
popupMenu.append(new MenuItem({
|
popupMenu.append(new MenuItem({
|
||||||
label: 'Copy link address',
|
label: 'Copy link &address',
|
||||||
click() {
|
click() {
|
||||||
clipboard.writeText(url);
|
clipboard.writeText(url);
|
||||||
},
|
},
|
||||||
@ -93,7 +93,7 @@ function onLinkContextMenu(ev, params) {
|
|||||||
|
|
||||||
if (addSaveAs) {
|
if (addSaveAs) {
|
||||||
popupMenu.append(new MenuItem({
|
popupMenu.append(new MenuItem({
|
||||||
label: 'Save image as...',
|
label: 'Sa&ve image as...',
|
||||||
click() {
|
click() {
|
||||||
const targetFileName = params.titleText || "image.png";
|
const targetFileName = params.titleText || "image.png";
|
||||||
const filePath = dialog.showSaveDialog({
|
const filePath = dialog.showSaveDialog({
|
||||||
@ -128,18 +128,22 @@ function onLinkContextMenu(ev, params) {
|
|||||||
function _CutCopyPasteSelectContextMenus(params) {
|
function _CutCopyPasteSelectContextMenus(params) {
|
||||||
return [{
|
return [{
|
||||||
role: 'cut',
|
role: 'cut',
|
||||||
|
label: 'Cu&t',
|
||||||
enabled: params.editFlags.canCut,
|
enabled: params.editFlags.canCut,
|
||||||
}, {
|
}, {
|
||||||
role: 'copy',
|
role: 'copy',
|
||||||
|
label: '&Copy',
|
||||||
enabled: params.editFlags.canCopy,
|
enabled: params.editFlags.canCopy,
|
||||||
}, {
|
}, {
|
||||||
role: 'paste',
|
role: 'paste',
|
||||||
|
label: '&Paste',
|
||||||
enabled: params.editFlags.canPaste,
|
enabled: params.editFlags.canPaste,
|
||||||
}, {
|
}, {
|
||||||
role: 'pasteandmatchstyle',
|
role: 'pasteandmatchstyle',
|
||||||
enabled: params.editFlags.canPaste,
|
enabled: params.editFlags.canPaste,
|
||||||
}, {
|
}, {
|
||||||
role: 'selectall',
|
role: 'selectall',
|
||||||
|
label: "Select &All",
|
||||||
enabled: params.editFlags.canSelectAll,
|
enabled: params.editFlags.canSelectAll,
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user