diff --git a/package-lock.json b/package-lock.json index 0b1ebfef..643fc824 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "bottleneck", - "version": "0.1.8", + "version": "0.1.10", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "bottleneck", - "version": "0.1.8", + "version": "0.1.10", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/src/main/index.ts b/src/main/index.ts index 5ee77fcf..47f74ef1 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -155,6 +155,35 @@ function createWindow() { // Set up application menu const menu = createMenu(mainWindow); Menu.setApplicationMenu(menu); + + // Enable native find-in-page functionality with keyboard shortcuts + let findActive = false; + + mainWindow.webContents.on("before-input-event", (event, input) => { + // Handle Cmd/Ctrl+F to start find + if (input.type === "keyDown" && input.key === "f" && (input.control || input.meta)) { + event.preventDefault(); + // Start find with empty string to show the find interface + mainWindow?.webContents.findInPage(""); + findActive = true; + } + // Handle Escape to stop find + else if (input.type === "keyDown" && input.key === "Escape" && findActive) { + event.preventDefault(); + mainWindow?.webContents.stopFindInPage("clearSelection"); + findActive = false; + } + // Handle Enter for find next (when find is active) + else if (input.type === "keyDown" && input.key === "Enter" && findActive && !input.shift) { + event.preventDefault(); + mainWindow?.webContents.findInPage("", { forward: true, findNext: true }); + } + // Handle Shift+Enter for find previous (when find is active) + else if (input.type === "keyDown" && input.key === "Enter" && findActive && input.shift) { + event.preventDefault(); + mainWindow?.webContents.findInPage("", { forward: false, findNext: true }); + } + }); } // App event handlers diff --git a/src/main/menu.ts b/src/main/menu.ts index 9da308ef..156c573d 100644 --- a/src/main/menu.ts +++ b/src/main/menu.ts @@ -80,6 +80,31 @@ export function createMenu(mainWindow: BrowserWindow): Menu { { role: "delete" as const }, { role: "selectAll" as const }, { type: "separator" as const }, + { + label: "Find", + accelerator: "Cmd+F", + click: () => { + // Start find with empty string to show find interface + mainWindow.webContents.findInPage(""); + }, + }, + { + label: "Find Next", + accelerator: "Cmd+G", + click: () => { + // Find next occurrence + mainWindow.webContents.findInPage("", { forward: true, findNext: true }); + }, + }, + { + label: "Find Previous", + accelerator: "Cmd+Shift+G", + click: () => { + // Find previous occurrence + mainWindow.webContents.findInPage("", { forward: false, findNext: true }); + }, + }, + { type: "separator" as const }, { label: "Speech", submenu: [ @@ -92,6 +117,31 @@ export function createMenu(mainWindow: BrowserWindow): Menu { { role: "delete" as const }, { type: "separator" as const }, { role: "selectAll" as const }, + { type: "separator" as const }, + { + label: "Find", + accelerator: "Ctrl+F", + click: () => { + // Start find with empty string to show find interface + mainWindow.webContents.findInPage(""); + }, + }, + { + label: "Find Next", + accelerator: "F3", + click: () => { + // Find next occurrence + mainWindow.webContents.findInPage("", { forward: true, findNext: true }); + }, + }, + { + label: "Find Previous", + accelerator: "Shift+F3", + click: () => { + // Find previous occurrence + mainWindow.webContents.findInPage("", { forward: false, findNext: true }); + }, + }, ]), ], },