mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-20 10:19:02 +00:00
Type markdown preview webview message (#176444)
Simply types messages. Will clean up types in next pass
This commit is contained in:
@@ -4,17 +4,24 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { SettingsManager } from './settings';
|
||||
import type { FromWebviewMessage } from '../types/previewMessaging';
|
||||
|
||||
export interface MessagePoster {
|
||||
/**
|
||||
* Post a message to the markdown extension
|
||||
*/
|
||||
postMessage(type: string, body: object): void;
|
||||
postMessage<T extends FromWebviewMessage.Type>(
|
||||
type: T['type'],
|
||||
body: Omit<T, 'source' | 'type'>
|
||||
): void;
|
||||
}
|
||||
|
||||
export const createPosterForVsCode = (vscode: any, settingsManager: SettingsManager) => {
|
||||
return new class implements MessagePoster {
|
||||
postMessage(type: string, body: object): void {
|
||||
export const createPosterForVsCode = (vscode: any, settingsManager: SettingsManager): MessagePoster => {
|
||||
return {
|
||||
postMessage<T extends FromWebviewMessage.Type>(
|
||||
type: T['type'],
|
||||
body: Omit<T, 'source' | 'type'>
|
||||
): void {
|
||||
vscode.postMessage({
|
||||
type,
|
||||
source: settingsManager.settings!.source,
|
||||
|
||||
Reference in New Issue
Block a user