Add localResourceRoots to webview options

Fixes #44039

Add a new option that lets extensions override which root folders a webview can load local resources from. Defaults to allowing any resource in the workspace
This commit is contained in:
Matt Bierner
2018-02-21 14:04:35 -08:00
parent bcbd3395bd
commit 2d1f6d422b
8 changed files with 44 additions and 25 deletions

View File

@@ -201,7 +201,9 @@ class WebviewEditor extends BaseWebviewEditor {
this.webview.options = {
allowScripts: input.options.enableScripts,
enableWrappedPostMessage: true
enableWrappedPostMessage: true,
useSameOriginForRoot: false,
localResourceRoots: (input && input.options.localResourceRoots) || this._contextService.getWorkspace().folders.map(x => x.uri)
};
this.webview.contents = input.html;
}
@@ -215,7 +217,6 @@ class WebviewEditor extends BaseWebviewEditor {
this._partService.getContainer(Parts.EDITOR_PART),
this.themeService,
this._environmentService,
this._contextService,
this._contextViewService,
this.contextKey,
this.findInputFocusContextKey,