wry
wry copied to clipboard
feat: add find-in-page, closes #585
What kind of change does this PR introduce?
- [ ] Bugfix
- [x] Feature
- [ ] Docs
- [ ] New Binding issue #___
- [ ] Code style update
- [ ] Refactor
- [ ] Build-related changes
- [ ] Other, please describe:
Does this PR introduce a breaking change?
- [ ] Yes, and the changes were approved in issue #___
- [x] No
Checklist
- [x] When resolving issues, they are referenced in the PR's title (e.g
fix: remove a typo, closes #___, #___) - [x] A change file is added if any packages will require a version bump due to this PR per the instructions in the readme.
- [x] I have added a convincing reason for adding this feature, if necessary
Other information
This feature highlight the search text automatically. Also electron has this feature. Searching word on browser by using JavaScript is too heavy process. And I think we should provide this feature from wry if it is possible.
Ah I see, I didn't know it highlights it too. I see that electron has this event https://www.electronjs.org/docs/latest/api/web-contents#event-found-in-page with information about the matched text, can we provide some of these?
I want to provide these information but I can't find API to do it :(
Additionally wkwebview.findString API has restriction that text is not highlighted only on macOS (but text is selected like window.find).
This is the issue in webkit: https://bugs.webkit.org/show_bug.cgi?id=140210.
Also electron has this feature.
If electron has it, it should be possible for webview2 perhaps (since they are both chromium)? This method will be really awkward if it doesn't support Windows which is the major desktop most users use
Webview2 builtin these feature with search box. But webview2 doesn't provide the API to find text in page :(
Maybe worth opening a feature request at webview2 feedback repo and hold this PR until it happens?
How about using window.find through evaluate_script as a fallback for WebView2?
I sill don't see much value in this API
Many projects are using the same functionality in Electron. https://github.com/search?l=TypeScript&q=findInPage+electron&type=Code
This functionality is useful for some document viewer to search its content.