Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to post message from rendered HTML output to NotebookEditor #98353

Closed
DonJayamanne opened this issue May 21, 2020 · 2 comments · Fixed by #100414
Closed

Unable to post message from rendered HTML output to NotebookEditor #98353

DonJayamanne opened this issue May 21, 2020 · 2 comments · Fixed by #100414
Assignees
Labels
insiders-released Patch has been released in VS Code Insiders notebook under-discussion Issue is under discussion for relevance, priority, approach
Milestone

Comments

@DonJayamanne
Copy link
Contributor

  • VSCode Version:
  • OS Version:

Steps to Reproduce:

Renderer:

 {
 outputKind: CellOutputKind.Rich,
 data: {
	 data['text/html'] = `
		 <button onclick="myFunction()">Click me</button>
		 <script>
			 function myFunction() {
				 acquireVsCodeApi().postMessage({type:'Don', payload:'wow'});
			 }
		 </script>
		 `
	}
 };

Add event handler to receive messages:

 notebook.activeNotebookEditor?.onDidReceiveMessage((e) => {
	 console.error('Callback not executed');
 });

Does this issue occur when all extensions are disabled?: N/A

@rebornix /cc

@DonJayamanne DonJayamanne changed the title Unable to post message from HTML to NotebookEditor Unable to post message from rendered HTML output to NotebookEditor May 21, 2020
@rebornix rebornix added notebook under-discussion Issue is under discussion for relevance, priority, approach labels Jun 5, 2020
@rebornix rebornix added this to the June 2020 milestone Jun 5, 2020
@rebornix
Copy link
Member

rebornix commented Jun 5, 2020

cc @connor4312 as we are moving to new API for renderers in webview.

@connor4312
Copy link
Member

connor4312 commented Jun 15, 2020

I'm not sure why postMessage stopped working for you in the webview, but I am planning to change this.

Primarily, there's now the API acquireNotebookRendererApi(rendererType) API which exposes events and state scoped per the renderer. The returned object also has the postMessage key on it. I plan to introduce an optional onDidReceiveMessage method to the NotebookOutputRenderer which will receive messages sent from the webview.

I understand you're intending to ship Insiders soon; I'll try to get that in tomorrow morning.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
insiders-released Patch has been released in VS Code Insiders notebook under-discussion Issue is under discussion for relevance, priority, approach
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants
@rebornix @DonJayamanne @connor4312 and others