Skip to content

Commit 808f93b

Browse files
vcapretzgdelavald
authored andcommitted
[NEW] Add context menu option for links
links should have a new menu item so people can open them (RocketChat#552)
1 parent 3f0e1a7 commit 808f93b

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

src/i18n/lang/en.i18n.json

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"Learn_More": "Learn More",
3939
"Minimize": "Minimize",
4040
"More_spelling_suggestions": "More spelling suggestions",
41+
"Open_Link": "Open link",
4142
"New_Version": "New Version:",
4243
"No": "No",
4344
"No_suggestions": "No suggestions",

src/i18n/lang/pt-br.i18n.json

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"Learn_More": "Saiba Mais",
3838
"Minimize": "Minimizar",
3939
"More_spelling_suggestions": "Mais sugestões de grafia",
40+
"Open_Link": "Abrir link",
4041
"New_Version": "Nova Versão:",
4142
"No": "Não",
4243
"No_suggestions": "Sem sugestões",

src/public/lib/SpellCheck.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const os = require('os');
22
const checker = require('spellchecker');
3-
const { remote, webFrame } = require('electron');
3+
const { remote, webFrame, shell } = require('electron');
44
const i18n = require('../../i18n/index');
55

66
const webContents = remote.getCurrentWebContents();
@@ -273,6 +273,17 @@ class SpellCheck {
273273
}
274274

275275
setTimeout(() => {
276+
if (event.target.nodeName === 'A') {
277+
const targetLink = event.target.href;
278+
279+
template.unshift({
280+
label: i18n.__('Open_Link'),
281+
click: () => {
282+
shell.openExternal(targetLink);
283+
}
284+
});
285+
}
286+
276287
if (['TEXTAREA', 'INPUT'].indexOf(event.target.nodeName) > -1) {
277288
const text = window.getSelection().toString().trim();
278289
if (text !== '' && !this.isCorrect(text)) {

0 commit comments

Comments
 (0)