Theia API Documentation v1.65.0
    Preparing search index...

    A webview displays html content, like an iframe.

    interface Webview {
        cspSource: string;
        html: string;
        onDidReceiveMessage: Event<any>;
        options: WebviewOptions;
        asWebviewUri(localResource: Uri): Uri;
        postMessage(message: any): Thenable<boolean>;
    }

    Implemented by

    Index

    Properties

    cspSource: string

    Content security policy source for webview resources.

    This is the origin that should be used in a content security policy rule:

    img-src https: ${webview.cspSource} ...;
    
    html: string

    Contents of the webview.

    Should be a complete html document.

    onDidReceiveMessage: Event<any>

    Fired when the webview content posts a message.

    Content settings for the webview.

    Methods

    • Convert a uri for the local file system to one that can be used inside webviews.

      Webviews cannot directly load resources from the workspace or local file system using file: uris. The asWebviewUri function takes a local file: uri and converts it into a uri that can be used inside of a webview to load the same resource:

      webview.html = `<img src="${webview.asWebviewUri(vscode.Uri.file('/Users/codey/workspace/cat.gif'))}">`
      

      Parameters

      • localResource: Uri

      Returns Uri