1- var { remote, shell, clipboard, ipcRenderer } = require ( 'electron' )
2- var { SpellCheckHandler, ContextMenuListener, ContextMenuBuilder } = require ( 'electron-spellchecker' )
3- var { MenuItem, Menu } = remote
4- var ref = require ( 'ssb-ref' )
1+ const { remote, shell, clipboard, ipcRenderer } = require ( 'electron' )
2+ const { SpellCheckHandler, ContextMenuListener, ContextMenuBuilder } = require ( 'electron-spellchecker' )
3+ const { MenuItem, Menu } = remote
4+ const ref = require ( 'ssb-ref' )
55
6- var navigateHandler = null
6+ let navigateHandler = null
77module . exports = setupContextMenuAndSpellCheck
88
99function setupContextMenuAndSpellCheck ( config , { navigate, get } ) {
@@ -14,7 +14,7 @@ function setupContextMenuAndSpellCheck (config, { navigate, get }) {
1414 // Start off as US English, America #1 (lol)
1515 spellCheckHandler . switchLanguage ( 'en-US' )
1616
17- var contextMenuBuilder = new ContextMenuBuilder ( spellCheckHandler , null , true , ( menu , menuInfo ) => {
17+ const contextMenuBuilder = new ContextMenuBuilder ( spellCheckHandler , null , true , ( menu , menuInfo ) => {
1818 const ddg = new MenuItem ( {
1919 label : 'Search with DuckDuckGo' ,
2020 click : ( ) => {
@@ -38,25 +38,25 @@ function setupContextMenuAndSpellCheck (config, { navigate, get }) {
3838 } )
3939
4040 contextMenuBuilder . buildMenuForLink = function ( menuInfo ) {
41- var element = document . elementFromPoint ( menuInfo . x , menuInfo . y )
41+ const element = document . elementFromPoint ( menuInfo . x , menuInfo . y )
4242
43- var menu = new Menu ( )
44- var isEmailAddress = menuInfo . linkURL . startsWith ( 'mailto:' )
45- var isFile = menuInfo . linkURL . startsWith ( 'file:' )
43+ const menu = new Menu ( )
44+ const isEmailAddress = menuInfo . linkURL . startsWith ( 'mailto:' )
45+ const isFile = menuInfo . linkURL . startsWith ( 'file:' )
4646
4747 // use the anchor of a link if it directly references an ID
48- var extractedRef = element && ref . isLink ( element . anchor ) ? element . anchor : ref . extract ( menuInfo . linkURL )
48+ const extractedRef = element && ref . isLink ( element . anchor ) ? element . anchor : ref . extract ( menuInfo . linkURL )
4949
5050 if ( ! isFile ) {
51- var copyLink = new MenuItem ( {
51+ const copyLink = new MenuItem ( {
5252 label : isEmailAddress ? this . stringTable . copyMail ( ) : this . stringTable . copyLinkUrl ( ) ,
5353 click : ( ) => {
5454 // Omit the mailto: portion of the link; we just want the address
5555 clipboard . writeText ( isEmailAddress ? menuInfo . linkText : menuInfo . linkURL )
5656 }
5757 } )
5858
59- var openLink = new MenuItem ( {
59+ const openLink = new MenuItem ( {
6060 label : this . stringTable . openLinkUrl ( ) ,
6161 click : ( ) => {
6262 shell . openExternal ( menuInfo . linkURL )
@@ -77,7 +77,7 @@ function setupContextMenuAndSpellCheck (config, { navigate, get }) {
7777 } ) )
7878 this . addSeparator ( menu )
7979 }
80- var copyRef = new MenuItem ( {
80+ const copyRef = new MenuItem ( {
8181 label : `Copy Link Ref (${ extractedRef . slice ( 0 , 10 ) } ...)` ,
8282 click : ( ) => {
8383 // Omit the mailto: portion of the link; we just want the address
@@ -87,7 +87,7 @@ function setupContextMenuAndSpellCheck (config, { navigate, get }) {
8787 menu . append ( copyRef )
8888
8989 if ( ref . isBlob ( extractedRef ) && menuInfo . hasImageContents ) {
90- var copyEmbed = new MenuItem ( {
90+ const copyEmbed = new MenuItem ( {
9191 label : `Copy Embed Markdown` ,
9292 click : ( ) => {
9393 // Omit the mailto: portion of the link; we just want the address
@@ -111,7 +111,7 @@ function setupContextMenuAndSpellCheck (config, { navigate, get }) {
111111
112112 module . exports . menu = new ContextMenuListener ( ( info ) => {
113113 contextMenuBuilder . buildMenuForElement ( info ) . then ( ( menu ) => {
114- var element = document . elementFromPoint ( info . x , info . y )
114+ let element = document . elementFromPoint ( info . x , info . y )
115115 while ( element && ! element . msg ) {
116116 element = element . parentNode
117117 }
0 commit comments