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

Webview API prototype 2 #44165

Closed
wants to merge 1 commit into from
Closed

Webview API prototype 2 #44165

wants to merge 1 commit into from

Conversation

mjbvz
Copy link
Collaborator

@mjbvz mjbvz commented Feb 22, 2018

Part of #43713

Second pass at the webview api. This iterations specifically looks at managing webviews.

Major changes:

  • Adds an id field to webviews. The id is provided by the extension and identifies the webview. It is used with the new event handling apis

  • Adds a new onDidChangeActiveEditor api. This is similar to onDidChangeActiveTextEditor but is also fired when you change webviews. It replaces the old onFocus and onBlur events on the webview itself

  • Replaces createWebview with getOrCreateWebview. This new API uses the id and column together as a key. The idea is that only a single webview of id may exist in a given column

  • Adds an onDidCloseWebview api. This is fired when a webview is closed by the user

The motivation for these changes is #27983, which tracks using the same markdown preview for any active markdown files. I believe this case is similar to how other extensions may use the webview.

Part of #43713

Second try at refining the webview api. This pass specifically looks at managing webviews. Major changes:

- Adds an `id` field to webviews. The id is provided by the extension and identifies the webview. It is used with the new event handling apis

- Adds a new `onDidChangeActiveEditor` api. This is similar to `onDidChangeActiveTextEditor` but is also fired when you change webviews. It replaces the old `onFocus` and `onBlur` events on the webview itself

- Replaces `createWebview` with `getOrCreateWebview`. This new API uses the id and column together as a key. The idea is that only a single webview of id may exist in a given column

- Adds an `onDidCloseWebview` api. This is fired when a webview is closed by the user

The motivation for these changes is #27983, which tracks using the same markdown preview for any active markdown files. I believe this case is similar to how other extensions may use the webview.
@mjbvz mjbvz self-assigned this Feb 22, 2018
@mjbvz mjbvz requested a review from jrieken February 22, 2018 02:08
mjbvz added a commit that referenced this pull request Feb 23, 2018
Part of #43713

Third try at refining the webview api. This pass reworks  #44165.  Major changes:

- Adds an `id` field to webviews. The id is provided by the extension and identifies the webview. It is used with the new event handling apis.

- Adds a new `onDidChangeActiveEditor` api. This is similar to `onDidChangeActiveTextEditor` but is also fired when you change webviews. It replaces the old `onFocus` and `onBlur` events on the webview itself

- Adds an `onDispose` event ot webviews. This is fired when a webview is closed by the user

- Perist webview state when the editor group changes. This is enabled for all webviews, not just those with keep alive.
@mjbvz mjbvz mentioned this pull request Feb 23, 2018
@mjbvz
Copy link
Collaborator Author

mjbvz commented Feb 23, 2018

Superseded by #44307

@mjbvz mjbvz closed this Feb 23, 2018
@DonJayamanne
Copy link
Contributor

@mjbvz I couldn't find a onDidCloseWebview event in the #44307 PR.
Will that not make it into the API?

@DonJayamanne
Copy link
Contributor

Thats fine, please ignore the previous comment, I believe the Uri being passed into createWebView makes the onDidCloseWebView unnecessary.

mjbvz added a commit that referenced this pull request Feb 26, 2018
Part of #43713

Third try at refining the webview api. This pass reworks  #44165.  Major changes:

- Adds an `id` field to webviews. The id is provided by the extension and identifies the webview. It is used with the new event handling apis.

- Adds a new `onDidChangeActiveEditor` api. This is similar to `onDidChangeActiveTextEditor` but is also fired when you change webviews. It replaces the old `onFocus` and `onBlur` events on the webview itself

- Adds an `onDispose` event ot webviews. This is fired when a webview is closed by the user

- Perist webview state when the editor group changes. This is enabled for all webviews, not just those with keep alive.
mjbvz added a commit that referenced this pull request Feb 26, 2018
* Webview API prototype 3

Part of #43713

Third try at refining the webview api. This pass reworks  #44165.  Major changes:

- Adds an `id` field to webviews. The id is provided by the extension and identifies the webview. It is used with the new event handling apis.

- Adds a new `onDidChangeActiveEditor` api. This is similar to `onDidChangeActiveTextEditor` but is also fired when you change webviews. It replaces the old `onFocus` and `onBlur` events on the webview itself

- Adds an `onDispose` event ot webviews. This is fired when a webview is closed by the user

- Perist webview state when the editor group changes. This is enabled for all webviews, not just those with keep alive.

* Throw error when trying to access disposed webview

* Improving webview documentation

* Clean up dispose management

* Throw if we receive a bad handle

* Move more event handling to input

* Simplify input updating

* Remove extra container property

* Fixing md security alert button

* Remove extra update container call

* Restore syncing of preview to active editor

* Fixing posting to webview

* Debounce preview updates

* Remove previewUri

* Enable direct window.postMessage instead of window.parent.postMessage

* Fixing scroll position not preserved when updating previews

* Revert parent.postMessage change.

Old behavior was correct

* Properly hide webview container on tab switch

* Make sure we only handle scroll events for the correct document

* Don't try setting negative scroll

* Revert vs code whitespace change
@mjbvz mjbvz deleted the webview-api-pass2 branch March 2, 2018 20:54
@github-actions github-actions bot locked and limited conversation to collaborators Mar 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants