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

See https://github.com/brave/browser-laptop/issues/1253 #1672

Merged
merged 2 commits into from
May 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/extensions/brave/locales/en-US/menu.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ bookmarkPage=Bookmark Page
bookmarkLink=Bookmark This Link
openFile=Open File...
openLocation=Open Location...
openSearch=Open Search...
openSearch=Search for "{{selectedVariable}}"
importFrom=Import from...
closeWindow=Close Window
savePageAs=Save Page as...
Expand Down
50 changes: 22 additions & 28 deletions js/contextMenus.js
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,18 @@ const copyEmailAddressMenuItem = (location) => {
}
}

const searchSelectionMenuItem = (location) => {
return {
label: locale.translation('openSearch').replace(/{{\s*selectedVariable\s*}}/, location),
click: (item, focusedWindow) => {
if (focusedWindow && location) {
let searchUrl = windowStore.getState().getIn(['searchDetail', 'searchURL']).replace('{searchTerms}', encodeURIComponent(location))
windowActions.newFrame({ location: searchUrl }, true)
}
}
}
}

function mainTemplateInit (nodeProps, frame) {
const template = []
const nodeName = nodeProps.name
Expand Down Expand Up @@ -660,25 +672,22 @@ function mainTemplateInit (nodeProps, frame) {
focusedWindow.webContents.downloadURL(nodeProps.src)
}
}
})
template.push({
}, {
label: locale.translation('openImageInNewTab'),
click: (item, focusedWindow) => {
if (focusedWindow && nodeProps.src) {
// TODO: open this in the next tab instead of last tab
focusedWindow.webContents.send(messages.SHORTCUT_NEW_FRAME, nodeProps.src)
}
}
})
template.push({
}, {
label: locale.translation('copyImageAddress'),
click: (item, focusedWindow) => {
if (focusedWindow && nodeProps.src) {
clipboard.writeText(nodeProps.src)
}
}
})
template.push(CommonMenu.separatorMenuItem)
}, CommonMenu.separatorMenuItem)
}

if (nodeName === 'TEXTAREA' || nodeName === 'INPUT' || nodeProps.isContentEditable) {
Expand All @@ -694,33 +703,18 @@ function mainTemplateInit (nodeProps, frame) {
role: 'redo'
}, CommonMenu.separatorMenuItem, ...editableItems, CommonMenu.separatorMenuItem)
} else if (nodeProps.hasSelection) {
template.push(
// {
// label: locale.translation('openSearch'),
// enabled: false,
// click: (item, focusedWindow) => {
// // TODO: ..
// }
// },
{
label: locale.translation('copy'),
accelerator: 'CmdOrCtrl+C',
role: 'copy'
}, CommonMenu.separatorMenuItem)
template.push(searchSelectionMenuItem(nodeProps.selection), {
label: locale.translation('copy'),
accelerator: 'CmdOrCtrl+C',
role: 'copy'
}, CommonMenu.separatorMenuItem)
} else {
if (nodeProps.href) {
template.push(addBookmarkMenuItem('bookmarkLink', {
location: nodeProps.href,
tags: [siteTags.BOOKMARK]
}, false)
// ,{
// label: locale.translation('openSearch'),
// enabled: false,
// click: (item, focusedWindow) => {
// // TODO: ..
// }
// }
)
}, false),
searchSelectionMenuItem(nodeProps.href))
} else {
template.push(
{
Expand Down