git ssb

10+

Matt McKegg / patchwork



Commit 0bc52a13a9c729a0b10e7f1bc22d167d5945ce75

remove Open Link and Copy Link when internal to patchwork

Matt McKegg committed on 2/19/2017, 1:37:01 PM
Parent: 350cc06021a41ffbb2830a1223d37e07b40a98ab

Files changed

lib/context-menu-and-spellcheck.jschanged
lib/context-menu-and-spellcheck.jsView
@@ -1,15 +1,52 @@
1-var electron = require('electron')
1 +var {remote, shell, clipboard, ipcRenderer} = require('electron')
22 var {SpellCheckHandler, ContextMenuListener, ContextMenuBuilder} = require('electron-spellchecker')
3-var MenuItem = electron.remote.MenuItem
3 +var {MenuItem, Menu} = remote
44
55 window.spellCheckHandler = new SpellCheckHandler()
66 window.spellCheckHandler.attachToInput()
77
88 // Start off as US English, America #1 (lol)
99 window.spellCheckHandler.switchLanguage('en-US')
1010
1111 var contextMenuBuilder = new ContextMenuBuilder(window.spellCheckHandler, null, true)
12 +
13 +contextMenuBuilder.buildMenuForLink = function (menuInfo) {
14 + var menu = new Menu()
15 + var isEmailAddress = menuInfo.linkURL.startsWith('mailto:')
16 + var isFile = menuInfo.linkURL.startsWith('file:')
17 +
18 + if (!isFile) {
19 + var copyLink = new MenuItem({
20 + label: isEmailAddress ? this.stringTable.copyMail() : this.stringTable.copyLinkUrl(),
21 + click: () => {
22 + // Omit the mailto: portion of the link; we just want the address
23 + clipboard.writeText(isEmailAddress ? menuInfo.linkText : menuInfo.linkURL)
24 + }
25 + })
26 +
27 + var openLink = new MenuItem({
28 + label: this.stringTable.openLinkUrl(),
29 + click: () => {
30 + shell.openExternal(menuInfo.linkURL)
31 + }
32 + })
33 +
34 + menu.append(copyLink)
35 + menu.append(openLink)
36 + }
37 +
38 + if (this.isSrcUrlValid(menuInfo)) {
39 + if (!isFile) this.addSeparator(menu)
40 + this.addImageItems(menu, menuInfo)
41 + }
42 +
43 + this.addInspectElement(menu, menuInfo)
44 + this.processMenu(menu, menuInfo)
45 +
46 + return menu
47 +}
48 +
1249 module.exports = new ContextMenuListener((info) => {
1350 contextMenuBuilder.buildMenuForElement(info).then((menu) => {
1451 var element = document.elementFromPoint(info.x, info.y)
1552 while (element && !element.msg) {
@@ -18,9 +55,9 @@
1855
1956 menu.append(new MenuItem({
2057 label: 'Inspect Server Process',
2158 click: function () {
22- electron.ipcRenderer.send('open-background-devtools')
59 + ipcRenderer.send('open-background-devtools')
2360 }
2461 }))
2562
2663 menu.append(new MenuItem({
@@ -42,13 +79,13 @@
4279 }))
4380 menu.append(new MenuItem({
4481 label: 'Copy Message ID',
4582 click: function () {
46- electron.clipboard.writeText(element.msg.key)
83 + clipboard.writeText(element.msg.key)
4784 }
4885 }))
4986 }
50- menu.popup(electron.remote.getCurrentWindow())
87 + menu.popup(remote.getCurrentWindow())
5188 }).catch((err) => {
5289 throw err
5390 })
5491 })

Built with git-ssb-web