// Copyright (c) jdneo. All rights reserved. // Licensed under the MIT license. import { ViewColumn } from "vscode"; import { openKeybindingsEditor, promptHintMessage } from "../utils/uiUtils"; import { ILeetCodeWebviewOption, LeetCodeWebview } from "./LeetCodeWebview"; import { markdownEngine } from "./markdownEngine"; class LeetCodeSubmissionProvider extends LeetCodeWebview { protected readonly viewType: string = "leetcode.submission"; private result: IResult; public show(resultString: string): void { this.result = this.parseResult(resultString); this.showWebviewInternal(); this.showKeybindingsHint(); } protected getWebviewOption(): ILeetCodeWebviewOption { return { title: "Submission", viewColumn: ViewColumn.Two, }; } protected getWebviewContent(): string { const styles: string = markdownEngine.getStyles(); const title: string = `## ${this.result.messages[0]}`; const messages: string[] = this.result.messages.slice(1).map((m: string) => `* ${m}`); const sections: string[] = Object.keys(this.result) .filter((key: string) => key !== "messages") .map((key: string) => [ `### ${key}`, "```", this.result[key].join("\n"), "```", ].join("\n")); const body: string = markdownEngine.render([ title, ...messages, ...sections, ].join("\n")); return `
${styles} ${body} `; } protected onDidDisposeWebview(): void { super.onDidDisposeWebview(); delete this.result; } private async showKeybindingsHint(): Promise