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

Promote webview Api to stable #47989

Merged
merged 8 commits into from
Apr 19, 2018
Merged

Conversation

mjbvz
Copy link
Collaborator

@mjbvz mjbvz commented Apr 16, 2018

Promotes the proposed webview Api to stable

Fixes #43713
Fixes #28263

@mjbvz mjbvz self-assigned this Apr 16, 2018
@mjbvz mjbvz requested a review from jrieken April 16, 2018 18:52
/**
* Editor position of the panel.
*/
readonly position?: ViewColumn;
Copy link
Member

Choose a reason for hiding this comment

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

Not yet sure about that... We can make is deprecated from the start (grid layout) so that it compares to editors. Also, since it optional is can work like the editor-case (think of embedded editors or output-editors)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok, I'll make it as deprecated. The intent is that property could be extended in the future to use other locations such as panel positions:

position?: ViewColumn | PanelPosition;

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The other option is that we change this back to viewColumn and introduce the position property for use with grid layout

*
* Pass in an empty array to disallow access to any local resources.
*/
readonly localResourceRoots?: ReadonlyArray<Uri>;
Copy link
Member

Choose a reason for hiding this comment

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

Touches on #42091

Copy link
Member

Choose a reason for hiding this comment

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

Might need extra doc, how do I can add an extra root? Is this alway additive to the two default locations?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm writing a new section of the docs for webview. An extension can recreate the default values using extensionContext.path and workspaceRoots.

Copy link
Member

Choose a reason for hiding this comment

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

👍

/**
* Title of the webview shown in UI.
*/
title: string;
Copy link
Member

Choose a reason for hiding this comment

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

Not sure if this is a panel or widget property...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It was a panel property but I moved it to the webview. The intention is that title is a common property pretty much anywhere the webview would be used. The owner of a webview (such as the WebviewPanel) just figures out how to display it

Copy link
Member

Choose a reason for hiding this comment

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

The intention is that title is a common property pretty much anywhere the webview would be used.

Could we say the same of dispose? Somehow I was missing it from the panel and I would also miss that from something like WebviewWindow...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes I think most conceivable future api uses of the Webview would also want a dispose method. I'll move dispose and onDidDispose from the WebviewPanel class to the Webview itself

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, but that's the opposite of what I wanted ;-) It's kinda bogus to say createWebviewPanel but to then call webviewPanel.webview.dispose().

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So you would prefer it on both objects?

/**
* A webview displays html content, like an iframe.
*/
export interface Webview {
Copy link
Member

Choose a reason for hiding this comment

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

Can we sketch-up a sample for the editor-view-zone-case? Or one in which a webview would be inside a separate window?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Here's the branch with a webview widget (view zone) sketch: https://github.com/Microsoft/vscode/blob/mjbvz/webviewWidgetProto/src/vs/vscode.proposed.d.ts#L689

The window one would be similar. It could be as simple as a top level function called createWebviewWindow(...): Thenable<Webview> or we could introduce a WebviewWindow class that has window specific properties on it:

interface WebviewWindow {
     readonly webview: Webview;

     onWillClose: Event<void>;

    onDidFocus: Event<void>;

    ...
}

Copy link
Member

Choose a reason for hiding this comment

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

Makes sense

@jrieken
Copy link
Member

jrieken commented Apr 18, 2018

One more question Webview vs WebView vs TreeView...

mjbvz added 2 commits April 18, 2018 13:56
This allows us to more easily re-introduce a `position` property once we have gridlayout
@mjbvz
Copy link
Collaborator Author

mjbvz commented Apr 18, 2018

Good question. Electron uses one word: Webview. This makes sense if we say that a webview is whole concept (like an iframe). Splitting it to Web View makes it more consistent with Tree View but it also suggests that there is a separate concept called Web that the WebView is presenting

I may be overthinking this. What do you think?

Also better hide a few 'internal' methods / properties on the panel / webview
@mjbvz mjbvz force-pushed the promote-webview-api branch from fbbbe11 to 8fab6cc Compare April 18, 2018 23:18
@jrieken
Copy link
Member

jrieken commented Apr 19, 2018

that there is a separate concept called Web that the WebView is presenting

Good point, my gut wants Webview anyways

@mjbvz
Copy link
Collaborator Author

mjbvz commented Apr 19, 2018

Outcomes from the API sync this morning:

  • Stick to Chrome/Electron's one word Webview convention
  • Move title back to the panel.

I've made these changes and am merging the PR. We'll continue to polish it based on any feedback from the test pass or from extension authors

@mjbvz mjbvz merged commit 91191fb into microsoft:master Apr 19, 2018
@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.

[Plan Item] Propose new Webview API Better UI extensibility: retain webviews, provide communication channel
2 participants