Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update all non-major dependencies #1879

Merged
merged 4 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
25 changes: 14 additions & 11 deletions src/webcontents-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
},
});
});
Expand All @@ -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);
},
},
{
Expand Down Expand Up @@ -237,21 +240,21 @@ 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
popupMenu.popup({});
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);
Expand Down Expand Up @@ -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);
}
});

Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -973,7 +973,7 @@
ajv "^6.12.0"
ajv-keywords "^3.4.1"

"@electron/asar@^3.2.3":
"@electron/[email protected].10":
version "3.2.10"
resolved "https://registry.yarnpkg.com/@electron/asar/-/asar-3.2.10.tgz#615cf346b734b23cafa4e0603551010bd0e50aa8"
integrity sha512-mvBSwIBUeiRscrCeJE1LwctAriBj65eUDm0Pc11iE5gRwzkmsdbS7FnZ1XUWjpSeQWL1L5g12Fc/SchPM9DUOw==
Expand Down
Loading