// 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: string; public show(result: string): void { this.result = result; this.showWebviewInternal(); this.showKeybindingsHint(); } protected getWebviewOption(): ILeetCodeWebviewOption { return { title: "Submission", viewColumn: ViewColumn.Two, }; } protected getWebviewContent(): string { return ` ${markdownEngine.getStyles()}
${this.result.trim()}
`; } protected onDidDisposeWebview(): void { super.onDidDisposeWebview(); delete this.result; } private async showKeybindingsHint(): Promise { await promptHintMessage( "hint.commandShortcut", 'You can customize shortcut key bindings in File > Preferences > Keyboard Shortcuts with query "leetcode".', "Open Keybindings", (): Promise => openKeybindingsEditor("leetcode solution"), ); } } export const leetCodeSubmissionProvider: LeetCodeSubmissionProvider = new LeetCodeSubmissionProvider();