Skip to content

Issues with JS and TextDocumentContentProvider #2912

Closed

Description

@dfinke

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?

Activity

  1. alexdima commented on Feb 11, 2016

    @alexdima
    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 Johannes Rieken (@jrieken)

  2. egamma commented on Feb 11, 2016

    @egamma
    Member

    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>.

    Doug Finke (@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.

  3. egamma commented on Feb 11, 2016

    @egamma
    Member

    Doug Finke (@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

  4. dfinke commented on Feb 11, 2016

    @dfinke
    Author

    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.

  5. egamma commented on Feb 12, 2016

    @egamma
    Member

    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.

  6. dfinke commented on Feb 27, 2016

    @dfinke
    Author

    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.

  7. changed the title [-]TextDocumentContentProvider + d3[/-] [+]Issues with JS and TextDocumentContentProvider[/+] on Mar 7, 2016
  8. added
    bug
    on Mar 7, 2016
  9. jrieken commented on Mar 7, 2016

    @jrieken
    Contributor

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

  10. alexdima commented on Mar 7, 2016

    @alexdima
    Member

    Johannes Rieken (@jrieken) Maybe we should use a <webview> ?

  11. added a commit that references this issue on Mar 8, 2016
  12. jrieken commented on Mar 8, 2016

    @jrieken
    Contributor

    The web view is past GA and tracked in #2414

  13. bpasero commented on Mar 21, 2016

    @bpasero
    Contributor

    👍

    image

  14. locked and limited conversation to collaborators on Nov 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugverified

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions