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

Issues with JS and TextDocumentContentProvider #2912

Closed
dfinke opened this issue Feb 10, 2016 · 10 comments
Closed

Issues with JS and TextDocumentContentProvider #2912

dfinke opened this issue Feb 10, 2016 · 10 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug verified Verification succeeded
Milestone

Comments

@dfinke
Copy link

dfinke commented Feb 10, 2016

TextDocumentContentProvider works. I used this as a starting point https://github.com/Microsoft/vscode-extension-samples/tree/master/textdocumentprovider-sample

This works if you save it as an html file and open it in a browser, but not if I return it in provideTextDocumentContent:
https://gist.github.com/dfinke/f51f8cba643b1b153ef8

Is there a way to make it work or debug?

@alexdima
Copy link
Member

I didn't implement this, but I think we use an <iframe> to render the preview and we disable all <scripts> because they would run in the UI thread.

fyi @jrieken

@egamma
Copy link
Member

egamma commented Feb 11, 2016

@alexandrudima correct, but we do not disable JS execution and I don't think we strip scripts. This was the state when we last discussed it and the intent is to switch from an <iframe> to a <webview>.

@dfinke the code is here:
vscode\src\vs\workbench\parts\html\browser\htmlPreviewPart.ts

To debug this pls see https://github.com/Microsoft/vscode/wiki/How-to-Contribute#development-workflow in the Debugging section. The htmlPreview code runs into the renderer process.

I'll look into this later, I see where you are going with your scenario and this is a interesting scenario.

@egamma
Copy link
Member

egamma commented Feb 11, 2016

@dfinke @alexandrudima
In the markdown preview the JavaScript from the above gist is executed as shown below. I was assuming that the html preview mostly mimics the mark down preview, but this is not the case and I did not succeed to execute scripts in the html preview.

md

@dfinke
Copy link
Author

dfinke commented Feb 11, 2016

Very cool. So a few tweaks to the html preview and vs code can be an interactive d3 pad.

I was looking at the htmlPreviewPart.ts to see if I could swap the iframe out, but I don't know if that would be enough. Maybe cloning the markdown preview is the place to start.

@egamma
Copy link
Member

egamma commented Feb 12, 2016

Maybe cloning the markdown preview is the place to start.

well this is where it started 😄, need to understand the differences with regard to JS handling in the two implementations.

As a workaround you could already do the d3 things using the markdown preview as is done in the twitter extension, but we should really get this to work.

@dfinke
Copy link
Author

dfinke commented Feb 27, 2016

The short Tweet on this drove questions in my direction. The snippet does not work in the 0.10.8 release. I know the Build conference is coming. Hopefully this can make it into the editor no too long after. It'd be a great feature.

@bpasero bpasero assigned jrieken and unassigned bpasero Feb 29, 2016
@egamma egamma mentioned this issue Mar 4, 2016
82 tasks
@jrieken jrieken changed the title TextDocumentContentProvider + d3 Issues with JS and TextDocumentContentProvider Mar 7, 2016
@jrieken jrieken added the bug Issue identified by VS Code Team member as probable bug label Mar 7, 2016
@jrieken jrieken added this to the March 2016 milestone Mar 7, 2016
@jrieken
Copy link
Member

jrieken commented Mar 7, 2016

I'll take a look - things are rendered in an iframe and script aren't blocked in anyway.

@alexdima
Copy link
Member

alexdima commented Mar 7, 2016

@jrieken Maybe we should use a <webview> ?

jrieken added a commit that referenced this issue Mar 8, 2016
@jrieken
Copy link
Member

jrieken commented Mar 8, 2016

The web view is past GA and tracked in #2414

@jrieken jrieken closed this as completed Mar 8, 2016
@jrieken jrieken assigned bpasero and unassigned jrieken Mar 21, 2016
@bpasero
Copy link
Member

bpasero commented Mar 21, 2016

👍

image

@bpasero bpasero added the verified Verification succeeded label Mar 21, 2016
@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

5 participants