mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 21:05:19 +00:00
fix(electron): optimize find in page in electron (2) (#9901)
1. find in page should have higher z-index than other modals 2. fix focused texts are not automatically being used as the default input value for searching
This commit is contained in:
@@ -9,12 +9,12 @@ import { useCallback, useEffect } from 'react';
|
||||
|
||||
export function useRegisterFindInPageCommands() {
|
||||
const findInPage = useServiceOptional(FindInPageService)?.findInPage;
|
||||
const toggleVisible = useCallback(() => {
|
||||
const showFindInPage = useCallback(() => {
|
||||
// get the selected text in page
|
||||
const selection = window.getSelection();
|
||||
const selectedText = selection?.toString();
|
||||
|
||||
findInPage?.toggleVisible(selectedText);
|
||||
findInPage?.findInPage(selectedText);
|
||||
}, [findInPage]);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -33,8 +33,7 @@ export function useRegisterFindInPageCommands() {
|
||||
label: '',
|
||||
run() {
|
||||
track.$.cmdk.general.findInPage();
|
||||
|
||||
toggleVisible();
|
||||
showFindInPage();
|
||||
},
|
||||
})
|
||||
);
|
||||
@@ -42,5 +41,5 @@ export function useRegisterFindInPageCommands() {
|
||||
return () => {
|
||||
unsubs.forEach(unsub => unsub());
|
||||
};
|
||||
}, [toggleVisible]);
|
||||
}, [findInPage, showFindInPage]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user