mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 13:00:58 +00:00
💄 for NotebookRendererMessaging, fyi @connor4312
This commit is contained in:
parent
48c9fd1130
commit
cb4f7b5690
29
src/vs/vscode.d.ts
vendored
29
src/vs/vscode.d.ts
vendored
|
@ -11560,31 +11560,14 @@ declare module 'vscode' {
|
|||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Message received from {@link NotebookRendererMessaging.onDidReceiveMessage}
|
||||
*/
|
||||
export interface NotebookRendererMessage {
|
||||
/**
|
||||
* Editor that sent the message.
|
||||
*/
|
||||
readonly editor: NotebookEditor;
|
||||
|
||||
/**
|
||||
* Message sent from the webview.
|
||||
*/
|
||||
readonly message: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renderer messaging is used to communicate with a single renderer. It's
|
||||
* returned from {@link notebooks.createRendererMessaging}.
|
||||
* Renderer messaging is used to communicate with a single renderer. It's returned from {@link notebooks.createRendererMessaging}.
|
||||
*/
|
||||
export interface NotebookRendererMessaging {
|
||||
/**
|
||||
* Events that fires when a message is received from a renderer.
|
||||
*/
|
||||
readonly onDidReceiveMessage: Event<NotebookRendererMessage>;
|
||||
readonly onDidReceiveMessage: Event<{ editor: NotebookEditor, message: any }>;
|
||||
|
||||
/**
|
||||
* Sends a message to the renderer.
|
||||
|
@ -12331,13 +12314,11 @@ declare module 'vscode' {
|
|||
export function registerNotebookCellStatusBarItemProvider(notebookType: string, provider: NotebookCellStatusBarItemProvider): Disposable;
|
||||
|
||||
/**
|
||||
* Creates a new messaging instance used to communicate with a specific
|
||||
* renderer defined in this extension's package.json. The renderer only
|
||||
* has access to messaging if `requiresMessaging` is set to `always` or
|
||||
* `optional` in its `notebookRenderer ` contribution.
|
||||
* Creates a new messaging instance used to communicate with a specific renderer defined in this extension's package.json. The renderer only
|
||||
* has access to messaging if `requiresMessaging` is set to `always` or `optional` in its `notebookRenderer ` contribution.
|
||||
*
|
||||
* @see https://github.com/microsoft/vscode/issues/123601
|
||||
* @param rendererId The renderer ID to communicate with
|
||||
* @returns A new notebook renderer messaging object.
|
||||
*/
|
||||
export function createRendererMessaging(rendererId: string): NotebookRendererMessaging;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import * as vscode from 'vscode';
|
|||
|
||||
|
||||
export class ExtHostNotebookRenderers implements ExtHostNotebookRenderersShape {
|
||||
private readonly _rendererMessageEmitters = new Map<string /* rendererId */, Emitter<vscode.NotebookRendererMessage>>();
|
||||
private readonly _rendererMessageEmitters = new Map<string /* rendererId */, Emitter<{ editor: vscode.NotebookEditor, message: any }>>();
|
||||
private readonly proxy: MainThreadNotebookRenderersShape;
|
||||
|
||||
constructor(mainContext: IMainContext, private readonly _extHostNotebook: ExtHostNotebookController) {
|
||||
|
@ -36,7 +36,7 @@ export class ExtHostNotebookRenderers implements ExtHostNotebookRenderersShape {
|
|||
|
||||
const messaging: vscode.NotebookRendererMessaging = {
|
||||
onDidReceiveMessage: (listener, thisArg, disposables) => {
|
||||
const wrappedListener = notebookEditorVisible ? listener : (evt: vscode.NotebookRendererMessage) => {
|
||||
const wrappedListener = notebookEditorVisible ? listener : (evt: { editor: vscode.NotebookEditor, message: any }) => {
|
||||
const obj = {};
|
||||
notebookEditorAliases.set(obj, evt.editor);
|
||||
listener({ editor: obj as vscode.NotebookEditor, message: evt.message });
|
||||
|
|
Loading…
Reference in a new issue