mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 13:25:12 +00:00
refactor: find in page (#7086)
- refactor rxjs data flow - use canvas text to mitigate searchable search box input text issue
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { contextBridge } from 'electron';
|
||||
|
||||
import { affine, appInfo, cmdFind, getElectronAPIs } from './electron-api';
|
||||
import { affine, appInfo, getElectronAPIs } from './electron-api';
|
||||
|
||||
const { apis, events } = getElectronAPIs();
|
||||
|
||||
@@ -10,7 +10,6 @@ contextBridge.exposeInMainWorld('events', events);
|
||||
|
||||
try {
|
||||
contextBridge.exposeInMainWorld('affine', affine);
|
||||
contextBridge.exposeInMainWorld('cmdFind', cmdFind);
|
||||
} catch (error) {
|
||||
console.error('Failed to expose affine APIs to window object!', error);
|
||||
}
|
||||
|
||||
@@ -47,20 +47,6 @@ export const affine = {
|
||||
},
|
||||
};
|
||||
|
||||
export const cmdFind = {
|
||||
findInPage: (text: string, options?: Electron.FindInPageOptions) =>
|
||||
ipcRenderer.invoke('findInPage:findInPage', text, options),
|
||||
stopFindInPage: (
|
||||
action: 'clearSelection' | 'keepSelection' | 'activateSelection'
|
||||
) => ipcRenderer.invoke('findInPage:stopFindInPage', action),
|
||||
onFindInPageResult: (callBack: (data: any) => void) =>
|
||||
ipcRenderer.on('found-in-page-result', (_event, data) => callBack(data)),
|
||||
offFindInPageResult: (callBack: (data: any) => void) =>
|
||||
ipcRenderer.removeListener('found-in-page-result', (_event, data) =>
|
||||
callBack(data)
|
||||
),
|
||||
};
|
||||
|
||||
export function getElectronAPIs() {
|
||||
const mainAPIs = getMainAPIs();
|
||||
const helperAPIs = getHelperAPIs();
|
||||
|
||||
Reference in New Issue
Block a user