Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Add Paste Without Formatting to context menu
Browse files Browse the repository at this point in the history
Fixes #5822
  • Loading branch information
Liunkae authored and bsclifton committed Jan 25, 2017
1 parent 5f836e8 commit b5999fd
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions js/contextMenus.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -999,7 +1009,7 @@ function mainTemplateInit (nodeProps, frame, tab) {
}
}

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',
Expand Down

0 comments on commit b5999fd

Please sign in to comment.