Skip to content

Commit

Permalink
[NEW] Add context menu option for links
Browse files Browse the repository at this point in the history
links should have a new menu item so people can open them (#552)
  • Loading branch information
vcapretz authored and gdelavald committed Oct 27, 2017
1 parent a6bc3bb commit a74d5f1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/i18n/lang/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"Learn_More": "Learn More",
"Minimize": "Minimize",
"More_spelling_suggestions": "More spelling suggestions",
"Open_Link": "Open link",
"New_Version": "New Version:",
"No": "No",
"No_suggestions": "No suggestions",
Expand Down
1 change: 1 addition & 0 deletions src/i18n/lang/pt-br.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"Learn_More": "Saiba Mais",
"Minimize": "Minimizar",
"More_spelling_suggestions": "Mais sugestões de grafia",
"Open_Link": "Abrir link",
"New_Version": "Nova Versão:",
"No": "Não",
"No_suggestions": "Sem sugestões",
Expand Down
13 changes: 12 additions & 1 deletion src/public/lib/SpellCheck.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const os = require('os');
const checker = require('spellchecker');
const { remote, webFrame } = require('electron');
const { remote, webFrame, shell } = require('electron');
const i18n = require('../../i18n/index');

const webContents = remote.getCurrentWebContents();
Expand Down Expand Up @@ -273,6 +273,17 @@ class SpellCheck {
}

setTimeout(() => {
if (event.target.nodeName === 'A') {
const targetLink = event.target.href;

template.unshift({
label: i18n.__('Open_Link'),
click: () => {
shell.openExternal(targetLink);
}
});
}

if (['TEXTAREA', 'INPUT'].indexOf(event.target.nodeName) > -1) {
const text = window.getSelection().toString().trim();
if (text !== '' && !this.isCorrect(text)) {
Expand Down

0 comments on commit a74d5f1

Please sign in to comment.