vscode/extensions/markdown-language-features/preview-src/messaging.ts
2018-03-19 21:08:39 -07:00

24 lines
768 B
TypeScript

/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { getSettings } from './settings';
/**
* Post a message to the markdown extension
*/
export function postMessage(type: string, body: object) {
window.parent.postMessage({
type,
source: getSettings().source,
body
}, '*');
}
/**
* Post a command to be executed to the markdown extension
*/
export function postCommand(command: string, args: any[]) {
postMessage('command', { command, args });
}