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

Fix some API inconsistencies related to web views #12091

Merged
merged 1 commit into from
Jan 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- [Previous Changelogs](https://github.com/eclipse-theia/theia/tree/master/doc/changelogs/)

## v1.34.0 - 01/26/2023

- [plugin] Fixed some API inconsistencies related to web views [#12087](https://github.com/eclipse-theia/theia/issues/12087) - Contributed on behalf of STMicroelectronics
- [plugin] added support for `isTransient` of `TerminalOptions` and `ExternalTerminalOptions` VS Code API [#12055](https://github.com/eclipse-theia/theia/pull/12055) - Contributed on behalf of STMicroelectronics
- [terminal] added support for preference `terminal.integrated.enablePersistentSessions` to allow disabling restoring terminals on reload [#12055](https://github.com/eclipse-theia/theia/pull/12055) - Contributed on behalf of STMicroelectronics

Expand Down
10 changes: 7 additions & 3 deletions packages/plugin-ext/src/main/browser/webview/webview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export interface WebviewContentOptions {
readonly allowForms?: boolean;
readonly localResourceRoots?: ReadonlyArray<string>;
readonly portMapping?: ReadonlyArray<WebviewPortMapping>;
readonly enableCommandUris?: boolean;
readonly enableCommandUris?: boolean | readonly string[];
}

@injectable()
Expand Down Expand Up @@ -450,8 +450,12 @@ export class WebviewWidget extends BaseWidget implements StatefulWidget, Extract
}
return link;
}
if (!!this.contentOptions.enableCommandUris && link.scheme === Schemes.command) {
return link;
if (link.scheme === Schemes.command) {
if (Array.isArray(this.contentOptions.enableCommandUris) && this.contentOptions.enableCommandUris.some(value => value === link.path.toString())) {
return link;
} else if (this.contentOptions.enableCommandUris === true) {
return link;
}
paul-marechal marked this conversation as resolved.
Show resolved Hide resolved
}
return undefined;
}
Expand Down
8 changes: 5 additions & 3 deletions packages/plugin/src/theia.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3871,9 +3871,11 @@ export module '@theia/plugin' {
/**
* Controls whether command uris are enabled in webview content or not.
*
* Defaults to false.
* Defaults to `false` (command uris are disabled).
*
* If you pass in an array, only the commands in the array are allowed.
*/
readonly enableCommandUris?: boolean;
readonly enableCommandUris?: boolean | readonly string[];

/**
* Root paths from which the webview can load local (filesystem) resources using the `theia-resource:` scheme.
Expand Down Expand Up @@ -5026,7 +5028,7 @@ export module '@theia/plugin' {
*
* @return New webview panel.
*/
export function createWebviewPanel(viewType: string, title: string, showOptions: ViewColumn | WebviewPanelShowOptions,
export function createWebviewPanel(viewType: string, title: string, showOptions: ViewColumn | { readonly viewColumn: ViewColumn; readonly preserveFocus?: boolean },
options?: WebviewPanelOptions & WebviewOptions): WebviewPanel;

/**
Expand Down