mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-15 05:37:32 +00:00
feat(core): cmd+f search in doc function (#7040)
You can use the cmd+F shortcut key to trigger the FindInPage function.
This commit is contained in:
17
packages/frontend/electron/src/main/find-in-page/handlers.ts
Normal file
17
packages/frontend/electron/src/main/find-in-page/handlers.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
export const findInPageHandlers = {
|
||||
findInPage: async (
|
||||
event: Electron.IpcMainInvokeEvent,
|
||||
text: string,
|
||||
options?: Electron.FindInPageOptions
|
||||
) => {
|
||||
const webContents = event.sender;
|
||||
return webContents.findInPage(text, options);
|
||||
},
|
||||
stopFindInPage: async (
|
||||
event: Electron.IpcMainInvokeEvent,
|
||||
action: 'clearSelection' | 'keepSelection' | 'activateSelection'
|
||||
) => {
|
||||
const webContents = event.sender;
|
||||
return webContents.stopFindInPage(action);
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
export * from './handlers';
|
||||
@@ -3,6 +3,7 @@ import { ipcMain } from 'electron';
|
||||
import { clipboardHandlers } from './clipboard';
|
||||
import { configStorageHandlers } from './config-storage';
|
||||
import { exportHandlers } from './export';
|
||||
import { findInPageHandlers } from './find-in-page';
|
||||
import { getLogFilePath, logger, revealLogFile } from './logger';
|
||||
import { uiHandlers } from './ui/handlers';
|
||||
import { updaterHandlers } from './updater';
|
||||
@@ -24,6 +25,7 @@ export const allHandlers = {
|
||||
export: exportHandlers,
|
||||
updater: updaterHandlers,
|
||||
configStorage: configStorageHandlers,
|
||||
findInPage: findInPageHandlers,
|
||||
};
|
||||
|
||||
export const registerHandlers = () => {
|
||||
|
||||
@@ -169,6 +169,16 @@ async function createWindow(additionalArguments: string[]) {
|
||||
uiSubjects.onFullScreen$.next(false);
|
||||
});
|
||||
|
||||
browserWindow.webContents.on('found-in-page', (_event, result) => {
|
||||
const { requestId, activeMatchOrdinal, matches, finalUpdate } = result;
|
||||
browserWindow.webContents.send('found-in-page-result', {
|
||||
requestId,
|
||||
activeMatchOrdinal,
|
||||
matches,
|
||||
finalUpdate,
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* URL for main window.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user