Skip to content

Support search in iframe based webview #96307

Closed

Description

@mjbvz

For #83188

Problem

On desktop, VS Code's webviews using the electron <webview> tag. This gives a nice api for searching inside a webview

However on web we use normal iframes for webviews. These currently don't support the search functionality because there is no equivalent API for searching inside a iframe.

This is one blocker for using normal iframes for the webviews in desktop VS Code: #83188

Request

Implement search for iframe based webviews. This should attempt to match the behavior of the existing search functionality as much as possible

/cc Robo (@deepak1556)

Activity

  1. added
    feature-request
    webview
    web
    on Apr 27, 2020
  2. added this to the May 2020 milestone on Apr 27, 2020
  3. mjbvz commented on Apr 27, 2020

    @mjbvz
    ContributorAuthor

    Solutions investigated:

    • Window.find — Non-standard. Doesn't provide enough control

    • JavaScript library (such as mark.js) — Requires JS on page. Modifies page content

    • Find text and other proposals — Never standardized and no longer active :(

  4. added
    sandbox
    on Sep 15, 2020
  5. mjbvz commented on Feb 27, 2021

    @mjbvz
    ContributorAuthor

    I've explored various ways to implement this. There are two parts to this:

    1. Performing the search in the webview document itself.

      Here we need to get a list of ranges. This is more complicated than it may sound since a search result may span multiple html nodes

    2. Highlight the results

      The only way I found that might let us do this somewhat reliably is execCommand('backColor'). This API is terrible to work with

  6. 34 remaining items

  7. rzhao271 commented on May 26, 2021

    @rzhao271
    Collaborator

    I still think this behaviour differs too much from the way the find widget currently works with webviews to be worth implementing.
    It's closer to the search viewlet behaviour, but even that doesn't have the problem of focus being stolen away from the searchbox during searches.

  8. bpasero commented on May 28, 2021

    @bpasero
    Contributor

    Matt Bierner (@mjbvz) any chance we could get ea8c6b3 into our builds? I have iframe based webviews enabled via settings ("webview.experimental.useIframes": true) and in markdown preview I am currently greeted with this:

    image

    My rationale is that I would like to selfhost on Raymond Zhao (@rzhao271) changes for enabling find in iframes, but currently that is impossible.

  9. bpasero commented on Jun 1, 2021

    @bpasero
    Contributor

    Next steps:

  10. added a commit that references this issue on Jun 7, 2021
    01e5a6e
  11. added a commit that references this issue on Jun 23, 2021
    76ed52e
  12. added a commit that references this issue on Jun 24, 2021
    9a8a439
  13. added
    unreleased
    insiders-released
    and removed
    unreleased
    on Jun 24, 2021
  14. added
    on-release-notes
    on Jun 25, 2021
  15. locked and limited conversation to collaborators on Aug 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

electron-12-updatefeature-requestinsiders-releasedon-release-noteson-testplansandboxwebwebview

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions