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:
pengx17
2024-05-28 06:19:53 +00:00
parent bd9c929d05
commit 2ca77d9170
12 changed files with 276 additions and 192 deletions
@@ -5,7 +5,11 @@ import { useCallback, useEffect } from 'react';
export function useRegisterFindInPageCommands() {
const findInPage = useService(FindInPageService).findInPage;
const toggleVisible = useCallback(() => {
findInPage.toggleVisible();
// get the selected text in page
const selection = window.getSelection();
const selectedText = selection?.toString();
findInPage.toggleVisible(selectedText);
}, [findInPage]);
useEffect(() => {