當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript WebviewPanel.onDidDispose方法代碼示例

本文整理匯總了TypeScript中vscode.WebviewPanel.onDidDispose方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript WebviewPanel.onDidDispose方法的具體用法?TypeScript WebviewPanel.onDidDispose怎麽用?TypeScript WebviewPanel.onDidDispose使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在vscode.WebviewPanel的用法示例。


在下文中一共展示了WebviewPanel.onDidDispose方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: show

    async show(): Promise<void> {
        const html = await this.getHtml();

        if (this._panel === undefined) {
            this._panel = window.createWebviewPanel(
                this.id,
                this.title,
                { viewColumn: ViewColumn.Active, preserveFocus: false },
                {
                    retainContextWhenHidden: true,
                    enableFindWidget: true,
                    enableCommandUris: true,
                    enableScripts: true
                }
            );

            this._panel.iconPath = Uri.file(Container.context.asAbsolutePath('images/gitlens-icon.png'));
            this._disposablePanel = Disposable.from(
                this._panel,
                this._panel.onDidDispose(this.onPanelDisposed, this),
                this._panel.onDidChangeViewState(this.onViewStateChanged, this),
                this._panel.webview.onDidReceiveMessage(this.onMessageReceivedCore, this)
            );

            this._panel.webview.html = html;
        }
        else {
            // Reset the html to get the webview to reload
            this._panel.webview.html = '';
            this._panel.webview.html = html;
            this._panel.reveal(ViewColumn.Active, false);
        }
    }
開發者ID:eamodio,項目名稱:vscode-git-codelens,代碼行數:33,代碼來源:webviewBase.ts

示例2: show

  async show(): Promise<void> {
    const html = await this.getHtml();

    const rootPath = Uri
      .file(this.context.asAbsolutePath('.'))
      .with({scheme: 'vscode-resource'}).toString();

    // Replace placeholders in html content for assets and adding configurations as `window.bootstrap`
    const fullHtml = html
      .replace(/{{root}}/g, rootPath)
      .replace('\'{{bootstrap}}\'', JSON.stringify(this.getBootstrap()));

    // If panel already opened just reveal
    if (this.panel !== undefined) {
      this.panel.webview.html = fullHtml;
      return this.panel.reveal(ViewColumn.Active);
    }

    this.panel = window.createWebviewPanel(
      this.id,
      this.title,
      ViewColumn.Active,
      {
        retainContextWhenHidden: true,
        enableFindWidget: true,
        enableCommandUris: true,
        enableScripts: true
      }
    );

    // Applying listeners
    this.disposablePanel = Disposable.from(
      this.panel,
      this.panel.onDidDispose(this.onPanelDisposed, this),
      this.panel.onDidChangeViewState(this.onViewStateChanged, this),
      this.panel.webview.onDidReceiveMessage(this.onMessageReceived, this)
    );

    this.panel.webview.html = fullHtml;
  }
開發者ID:Manu-sh,項目名稱:dotfiles,代碼行數:40,代碼來源:Webview.ts

示例3: show

  public async show(): Promise<void> {
    if (!this.panel) {
      this.panel = window.createWebviewPanel(
        'requirementsPage',
        'Azure Blockchain Development Kit - Preview',
        ViewColumn.One,
        {
          enableCommandUris: true,
          enableScripts: true,
          retainContextWhenHidden: true,
        },
      );

      const rootPath = Uri.file(this.context.asAbsolutePath('.')).with({scheme: 'vscode-resource'}).toString();
      this.panel.webview.html = fs.readFileSync(Constants.requirementsPagePath, 'utf8').replace(/{{root}}/g, rootPath);
      this.panel.onDidDispose(() => {
        this.dispose();
      });
    } else {
      this.panel.reveal(ViewColumn.One);
    }

    this.context.subscriptions.push(
      this.panel.webview.onDidReceiveMessage(
        async (message) => {
          switch (message.command) {
            case 'documentready':
              if (this.panel) {
                this.panel.webview.postMessage({ versions: await required.getAllVersions() });
              }
              return;
          }
        },
        undefined,
        this.context.subscriptions),
    );
  }
開發者ID:chrisseg,項目名稱:vscode-azure-blockchain-ethereum,代碼行數:37,代碼來源:RequirementsPage.ts


注:本文中的vscode.WebviewPanel.onDidDispose方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。