From 6f549fe0fdafcd6ea9208d76f300deacdb5d99f0 Mon Sep 17 00:00:00 2001 From: Liunkae Date: Wed, 21 Dec 2016 00:52:03 -0600 Subject: [PATCH] Add Paste Without Formatting to context menu Fixes #5822 --- js/contextMenus.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/js/contextMenus.js b/js/contextMenus.js index a124e1b0d02..2272138bd9a 100644 --- a/js/contextMenus.js +++ b/js/contextMenus.js @@ -642,7 +642,7 @@ function getMisspelledSuggestions (selection, isMisspelled, suggestions) { return menuUtil.sanitizeTemplateItems(template) } -function getEditableItems (selection, editFlags) { +function getEditableItems (selection, editFlags, hasFormat) { const hasSelection = selection.length > 0 const hasClipboard = clipboard.readText().length > 0 const template = [] @@ -670,6 +670,16 @@ function getEditableItems (selection, editFlags) { enabled: hasClipboard, role: 'paste' }) + if (hasFormat) { + template.push({ + label: locale.translation('pasteWithoutFormatting'), + accelerator: 'Shift+CmdOrCtrl+V', + enabled: hasClipboard, + click: function (item, focusedWindow) { + focusedWindow.webContents.pasteAndMatchStyle() + } + }) + } } return menuUtil.sanitizeTemplateItems(template) } @@ -999,7 +1009,7 @@ function mainTemplateInit (nodeProps, frame) { } } - const editableItems = getEditableItems(nodeProps.selectionText, nodeProps.editFlags) + const editableItems = getEditableItems(nodeProps.selectionText, nodeProps.editFlags, true) template.push(...misspelledSuggestions, { label: locale.translation('undo'), accelerator: 'CmdOrCtrl+Z',