Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add find-in-page, closes #585 #593

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from

Conversation

keiya01
Copy link
Member

@keiya01 keiya01 commented May 22, 2022

What kind of change does this PR introduce?

  • Bugfix
  • 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 #___
  • No

Checklist

  • When resolving issues, they are referenced in the PR's title (e.g fix: remove a typo, closes #___, #___)
  • A change file is added if any packages will require a version bump due to this PR per the instructions in the readme.
  • I have added a convincing reason for adding this feature, if necessary

Other information

@keiya01 keiya01 requested review from a team May 22, 2022 02:41
@keiya01 keiya01 requested a review from a team as a code owner May 22, 2022 02:41
Copy link
Member

@amrbashir amrbashir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know how this feature might be useful for desktop apps tbh. It only returns whether a match has been found or not, it doesn't return the matched word nor the html element that contains it. I can't think of a use case for it at all.

@keiya01
Copy link
Member Author

keiya01 commented May 22, 2022

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.

@amrbashir
Copy link
Member

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?

@keiya01
Copy link
Member Author

keiya01 commented May 22, 2022

I want to provide these information but I can't find API to do it :(

@keiya01
Copy link
Member Author

keiya01 commented May 22, 2022

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.

Copy link
Member

@amrbashir amrbashir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I sill don't see much value in this API but I will leave that for @wusyong to decide and I will just do a review.

.changes/add-find-in-page.md Outdated Show resolved Hide resolved
src/webview/mod.rs Outdated Show resolved Hide resolved
src/webview/mod.rs Outdated Show resolved Hide resolved
src/webview/mod.rs Outdated Show resolved Hide resolved
src/webview/webkitgtk/mod.rs Outdated Show resolved Hide resolved
@keiya01 keiya01 force-pushed the feat/add-find-in-page branch from 44b5b85 to 95712db Compare May 23, 2022 00:17
@wusyong
Copy link
Member

wusyong commented May 23, 2022

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

@keiya01
Copy link
Member Author

keiya01 commented May 23, 2022

Webview2 builtin these feature with search box. But webview2 doesn't provide the API to find text in page :(

@amrbashir
Copy link
Member

Maybe worth opening a feature request at webview2 feedback repo and hold this PR until it happens?

@rhysd
Copy link
Contributor

rhysd commented Nov 5, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants