microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.98k stars 29.19k forks source link

Not able to rendered HTML Content in chat view extension of Visual Studio Code. #217798

Closed Gautam1-Krishna closed 4 months ago

Gautam1-Krishna commented 4 months ago

I am trying to create one chat view extension for visual studio code but not able to rendered html content

Here is my extention.ts code

import * as vscode from 'vscode';

export function activate(context: vscode.ExtensionContext) { console.log('Congratulations, your extension "chatview" is now active!'); let disposable = vscode.window.registerWebviewViewProvider('chat-view', new ChatViewProvider()); context.subscriptions.push(disposable); }

class ChatViewProvider implements vscode.WebviewViewProvider {

private _view?: vscode.WebviewView;

public resolveWebviewView(webviewView: vscode.WebviewView){
    console.log('Inside resolveWebviewView Methode');
    this._view = webviewView;
    this._view.webview.html = this.getWebviewContent();
}

private getWebviewContent() {
    console.log('Inside Html Methode');
    return `

<!DOCTYPE html>

Chat View
`; } } // This method is called when your extension is deactivated export function deactivate() {} here is my package.json code { "name": "chatview", "displayName": "ChatView", "description": "", "version": "0.0.1", "engines": { "vscode": "^1.90.0" }, "categories": [ "Other" ], "activationEvents": [], "main": "./out/extension.js", "contributes": { "views": { "explorer": [ { "id": "chatview", "name": "Chat View", "location": "sidebar" } ] }, "commands": [ { "command": "chatview.helloWorld", "title": "Hello World" } ] }, "scripts": { "vscode:prepublish": "npm run compile", "compile": "tsc -p ./", "watch": "tsc -watch -p ./", "pretest": "npm run compile && npm run lint", "lint": "eslint src --ext ts", "test": "node ./out/test/runTest.js" }, "devDependencies": { "@types/vscode": "^1.90.0", "@types/mocha": "^10.0.3", "@types/node": "18.x", "@typescript-eslint/eslint-plugin": "^6.9.0", "@typescript-eslint/parser": "^6.9.0", "eslint": "^8.52.0", "glob": "^10.3.10", "mocha": "^10.2.0", "typescript": "^5.2.2", "@vscode/test-electron": "^2.3.6" } } ```[tasklist] ### Tasks ```
vscodenpa commented 4 months ago

We have a great extension developer community over on GitHub discussions and Slack where extension authors help each other. This is a great place for you to ask questions and find support.

Happy Coding!