vscode#WebviewPanelOptions TypeScript Examples

The following examples show how to use vscode#WebviewPanelOptions. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: webview-utils.ts    From plugin-vscode with Apache License 2.0 7 votes vote down vote up
export function getCommonWebViewOptions(): Partial<WebviewOptions & WebviewPanelOptions> {
    return {
        enableScripts: true,
        retainContextWhenHidden: true,
        localResourceRoots: [
            Uri.file(join((ballerinaExtInstance.context as ExtensionContext).extensionPath, 'resources', 'jslibs')),
            Uri.file(getWebViewResourceRoot()),
            Uri.file(getNodeModulesRoot())
        ],
    };
}
Example #2
Source File: docview.ts    From vscode-lean4 with Apache License 2.0 6 votes vote down vote up
private getWebview(): WebviewPanel {
        if (!this.webview) {
            const options: WebviewOptions & WebviewPanelOptions = {
                enableFindWidget: true,
                enableScripts: true,
                enableCommandUris: true,
                retainContextWhenHidden: true,
            };

            this.webview = window.createWebviewPanel('lean4', 'Lean Documentation',
                { viewColumn: 3, preserveFocus: true }, options)
            this.webview.onDidDispose(() => this.webview = undefined);
            this.webview.webview.onDidReceiveMessage(m => this.receiveMessage(m));

            let first = true;
            this.webview.onDidChangeViewState(async () => {
                if (first) {
                    first = false;
                    // super hacky way to show both infoview and docview in a split
                    await commands.executeCommand('workbench.action.focusRightGroup');
                    await commands.executeCommand('workbench.action.moveEditorToBelowGroup');
                }
            });
        }
        return this.webview;
    }