SDA-3966 Support Paste as plain text

This commit is contained in:
sbenmoussati
2022-11-16 15:13:52 +01:00
committed by Salah Benmoussati
parent 6d4c198e79
commit 921fd5eeea
4 changed files with 22 additions and 2 deletions

View File

@@ -71,6 +71,7 @@ const macAccelerator = {
zoomIn: 'CommandOrControl+Plus',
zoomOut: 'CommandOrControl+-',
resetZoom: 'CommandOrControl+0',
pasteAndMatchStyle: 'Cmd+Shift+V',
},
};
@@ -333,7 +334,7 @@ export class AppMenu {
this.assignRoleOrLabel({ role: 'paste', label: i18n.t('Paste')() }),
this.assignRoleOrLabel({
role: 'pasteAndMatchStyle',
label: i18n.t('Paste and Match Style')(),
label: i18n.t('Paste as plain text')(),
}),
this.assignRoleOrLabel({ role: 'delete', label: i18n.t('Delete')() }),
this.assignRoleOrLabel({

View File

@@ -14,6 +14,7 @@ interface IContextMenuStringTable {
cut: () => string;
copy: () => string;
paste: () => string;
pasteAsPlainText: () => string;
inspectElement: () => string;
}
@@ -29,6 +30,7 @@ const contextMenuStringTable: IContextMenuStringTable = {
cut: () => `Cut`,
copy: () => `Copy`,
paste: () => `Paste`,
pasteAsPlainText: () => `Paste as plain text`,
inspectElement: () => `Inspect Element`,
};
@@ -175,6 +177,7 @@ export class ContextMenuBuilder {
this.addCut(menu, menuInfo);
this.addCopy(menu, menuInfo);
this.addPaste(menu, menuInfo);
this.addPasteAsPlainText(menu, menuInfo);
this.addInspectElement(menu, menuInfo);
this.processMenu(menu, menuInfo);
@@ -189,7 +192,6 @@ export class ContextMenuBuilder {
public buildMenuForLink(menuInfo) {
const menu = new Menu();
const isEmailAddress = menuInfo.linkURL.startsWith('mailto:');
const copyLink = new MenuItem({
label: isEmailAddress
? this.stringTable.copyMail()
@@ -433,6 +435,21 @@ export class ContextMenuBuilder {
return menu;
}
/**
* Adds the Paste menu item.
*/
public addPasteAsPlainText(menu, menuInfo) {
menu.append(
new MenuItem({
label: this.stringTable.pasteAsPlainText(),
accelerator: 'CommandOrControl+Shift+V',
enabled: menuInfo.editFlags.canPaste,
role: 'pasteAndMatchStyle',
}),
);
return menu;
}
/**
* Adds a separator item.
*/

View File

@@ -119,6 +119,7 @@
"Oops! Something went wrong. Would you like to restart the app?": "Oops! Something went wrong. Would you like to restart the app?",
"Paste": "Paste",
"Paste and Match Style": "Paste and Match Style",
"Paste as plain text ": "Paste as plain text",
"Permission Denied": "Permission Denied",
"Permissions": {
"Your administrator has disabled Full Screen. Please contact your admin for help": "Your administrator has disabled Full Screen. Please contact your admin for help",

View File

@@ -119,6 +119,7 @@
"Oops! Something went wrong. Would you like to restart the app?": "Oops! Something went wrong. Would you like to restart the app?",
"Paste": "Paste",
"Paste and Match Style": "Paste and Match Style",
"Paste as plain text": "Paste as plain text ",
"Permission Denied": "Permission Denied",
"Permissions": {
"Your administrator has disabled Full Screen. Please contact your admin for help": "Your administrator has disabled Full Screen. Please contact your admin for help",