diff --git a/package.json b/package.json index 1b0ada062..1e549260a 100644 --- a/package.json +++ b/package.json @@ -79,7 +79,7 @@ "@babel/core": "^7.18.10", "@babel/preset-env": "^7.18.10", "@babel/preset-typescript": "^7.18.6", - "@electron/asar": "^3.2.3", + "@electron/asar": "3.2.10", "@electron/fuses": "^1.7.0", "@mapbox/node-pre-gyp": "^1.0.11", "@playwright/test": "1.48.0", diff --git a/src/webcontents-handler.ts b/src/webcontents-handler.ts index d5773edda..43ab14c4b 100644 --- a/src/webcontents-handler.ts +++ b/src/webcontents-handler.ts @@ -176,15 +176,18 @@ function onLinkContextMenu(ev: Event, params: ContextMenuParams, webContents: We ev.preventDefault(); } -function cutCopyPasteSelectContextMenus(params: ContextMenuParams): MenuItemConstructorOptions[] { +function cutCopyPasteSelectContextMenus( + params: ContextMenuParams, + webContents: WebContents, +): MenuItemConstructorOptions[] { const options: MenuItemConstructorOptions[] = []; if (params.misspelledWord) { params.dictionarySuggestions.forEach((word) => { options.push({ label: word, - click: (menuItem, browserWindow) => { - browserWindow?.webContents.replaceMisspelling(word); + click: () => { + webContents.replaceMisspelling(word); }, }); }); @@ -194,8 +197,8 @@ function cutCopyPasteSelectContextMenus(params: ContextMenuParams): MenuItemCons }, { label: _t("right_click_menu|add_to_dictionary"), - click: (menuItem, browserWindow) => { - browserWindow?.webContents.session.addWordToSpellCheckerDictionary(params.misspelledWord); + click: () => { + webContents.session.addWordToSpellCheckerDictionary(params.misspelledWord); }, }, { @@ -237,8 +240,8 @@ function cutCopyPasteSelectContextMenus(params: ContextMenuParams): MenuItemCons return options; } -function onSelectedContextMenu(ev: Event, params: ContextMenuParams): void { - const items = cutCopyPasteSelectContextMenus(params); +function onSelectedContextMenu(ev: Event, params: ContextMenuParams, webContents: WebContents): void { + const items = cutCopyPasteSelectContextMenus(params, webContents); const popupMenu = Menu.buildFromTemplate(items); // popup() requires an options object even for no options @@ -246,12 +249,12 @@ function onSelectedContextMenu(ev: Event, params: ContextMenuParams): void { ev.preventDefault(); } -function onEditableContextMenu(ev: Event, params: ContextMenuParams): void { +function onEditableContextMenu(ev: Event, params: ContextMenuParams, webContents: WebContents): void { const items: MenuItemConstructorOptions[] = [ { role: "undo" }, { role: "redo", enabled: params.editFlags.canRedo }, { type: "separator" }, - ...cutCopyPasteSelectContextMenus(params), + ...cutCopyPasteSelectContextMenus(params, webContents), ]; const popupMenu = Menu.buildFromTemplate(items); @@ -286,9 +289,9 @@ export default (webContents: WebContents): void => { if (params.linkURL || params.srcURL) { onLinkContextMenu(ev, params, webContents); } else if (params.selectionText) { - onSelectedContextMenu(ev, params); + onSelectedContextMenu(ev, params, webContents); } else if (params.isEditable) { - onEditableContextMenu(ev, params); + onEditableContextMenu(ev, params, webContents); } }); diff --git a/yarn.lock b/yarn.lock index dc6211822..883d9f2ff 100644 --- a/yarn.lock +++ b/yarn.lock @@ -973,7 +973,7 @@ ajv "^6.12.0" ajv-keywords "^3.4.1" -"@electron/asar@^3.2.3": +"@electron/asar@3.2.10": version "3.2.10" resolved "https://registry.yarnpkg.com/@electron/asar/-/asar-3.2.10.tgz#615cf346b734b23cafa4e0603551010bd0e50aa8" integrity sha512-mvBSwIBUeiRscrCeJE1LwctAriBj65eUDm0Pc11iE5gRwzkmsdbS7FnZ1XUWjpSeQWL1L5g12Fc/SchPM9DUOw==