Skip to content

Investigate better UX for previewing things #22068

Open

Description

~~People use previewHtml for building UI which does't work well. We should investigate different options~~~

We will tackle the problem from the other side: #22068 (comment)

Activity

  1. daviwil commented on Mar 12, 2017

    @daviwil
    Contributor

    Looking forward to this!

  2. smelukov commented on Mar 20, 2017

    @smelukov

    Maybe the better solution is provided a possibility to build own UI inside a tab through DOM-access (like in Atom).
    Something like DOMContentProvider or like that...
    Or access to DOM of previewHtml

    For example: if I want to insert an iframe inside a tab and get access to its contentWindow-property, then previewHtml is useless for this task. But if I'll have access to DOM of a tab or to DOM of rendered HTML, then this task will have a simple solution.

  3. smelukov commented on Mar 30, 2017

    @smelukov

    Hi! Is there any chance to get a possibility to create an iframe inside a tab? :)

  4. added
    plan-item
    on Apr 13, 2017
  5. changed the title [-]Investigate better UX api[/-] [+]Investigate better UX for previewing things[/+] on Apr 13, 2017
  6. jrieken commented on Apr 13, 2017

    @jrieken
    ContributorAuthor

    FYI - I have updated the title of this issue to better reflect what we are shooting for. We know that some people badly wish for customisable and extendable UI. Unfortunately that is still a major challange and we tackle things one at a time.

    Today, the previewHtml-command is an ok workaround. It has many gaps and problems and won't be the UX story of the future. To name a few: webview restarts when reparented, webview as many bugs in general, webview can swallow events like drag which we need, key events need to be captured and send "upwards" etc, etc

    Initially the previewHtml-command has been added to allow the markdown extension to preview content. Other extensions have implemented the same pattern, e.g preview svg. However, some extensions also have started to implement rich UIs with this, e.g mssql. This brought us into a situation in which evolving the initial preview functionality often breaks the UX-extensibility usage.

    The idea is to make better API for previewing markdown or more general for previewing derived resources, like html from markdown, html from svg, or JS from TS. This would allow for some improvements like

    • simplified synchronised scrolling
    • side-by-side preview inside one tab
    • synchronised search
    • restoring the editor with a preview-view
    • etc
  7. jrieken commented on Apr 13, 2017

    @jrieken
    ContributorAuthor
  8. jrieken commented on Apr 18, 2017

    @jrieken
    ContributorAuthor

    Mockup showing in-editor-peview of something (note that source-view and that preview share the same editor/tab)

    screen shot 2017-04-18 at 14 37 07

    Gif how iaWriter sync scrolling from both sides and how it 'zooms' the preview when moving the sash

    apr-18-2017 14-45-38

    From the API point to view we need to design a provider that, given a document, can return a preview. The preview is either an URI to another source file, e.g. JS from TS, or html sources that should be rendered. Details are to be defined, but in general something along these lines

    interface Preview {
      // allow for scrolling sync, some bidirectional line mapping 
      // allow for preview-kind, e.g. source or html-rendered
      // ...
    }
    
    interface PreviewProvider {
      providePreview(document: TextDocument): ProviderResult<Preview>;
    }
  9. mjbvz commented on Apr 19, 2017

    @mjbvz
    Contributor

    Yes I'm very much in favor of standardizing the preview functionality. A preview provider was one option that we considered when originally looking at implementing markdown scroll synchronization: #5047 (comment)

    Besides previewing documents like markdown, the other case I'd be interested in is extension contributed previews of binary/asset files, such as texture files or 3D files

  10. jrieken commented on Apr 21, 2017

    @jrieken
    ContributorAuthor

    Besides previewing documents like markdown, the other case I'd be interested in is extension contributed previews of binary/asset files, such as texture files or 3D files

    Question is if that would require them to run JS code or if we can build a standard preview without allowing extensions to execute JS. I'd be happy if we can avoid the web view for the new world

  11. 14 remaining items

  12. keshann93 commented on Apr 29, 2020

    @keshann93

    anyone still looking for a markdown preview/editor for vscode, tryout this extension

  13. mjbvz commented on Jun 22, 2020

    @mjbvz
    Contributor

    This should be covered by the custom editor api that was shipped in VS Code 1.46

    Please file new issues if you find that any features/api is missing from custom editors

  14. added
    custom-editors
    on Jun 22, 2020
  15. jrieken commented on Jun 23, 2020

    @jrieken
    ContributorAuthor

    Please file new issues if you find that any features/api is missing from custom editors

    This is all about a text editor with a webview to its side (but still being a single logical workbench editor). Custom editors cannot really do that because there is no way they can drive a Monaco editor the way we do

  16. mjbvz commented on Jun 23, 2020

    @mjbvz
    Contributor

    Johannes Rieken (@jrieken) It may make sense to split this out into separate proposals. We've discussed allowing custom editors to mark themselves as "beside" so that they automatically open in a split view next to the text editor

  17. DanTup commented on Jul 13, 2021

    @DanTup
    Contributor

    Would these have to be custom editors? Or could it also support TextDocumentContentProvider?

    I was playing with an idea to show the current code file with generated code expanded as a preview to the side (since there aren't any APIs for us to show read-only generated code "inline" in the editor, and get full navigation/semantic token support). It seems like Matt Bierner (@mjbvz)'s comment above with support for TextDocumentContentProvider might do it (and if done right, might even allow debugging stepping through the generated code while keeping the two together?).

  18. added
    workbench-editors
    on Sep 2, 2021
  19. bpasero commented on Sep 8, 2021

    @bpasero
    Contributor

    With #132651 it is possible to split an editor into 2 in the same group:

    image

    While what is pushed now is limiting to opening the same editor side by side, #36700 would allow this for any 2 editors.

    There is nothing technical blocking us from simply putting a text file to the left and a preview editor to the right as this hack shows:

    image

    But there are some questions:

    • how would an extension API look like for markdown to open a preview like that
    • the preview editor is not syncing with the text document, so whatever magic we do there needs to expand to side-by-side-editors which probably needs extension API too
    • how would a user be able to trigger this UI, should it be another action in the editor toolbar for previewing or even be the default?
  20. mjbvz commented on Sep 9, 2021

    @mjbvz
    Contributor

    Benjamin Pasero (@bpasero) Trying to support webviews is tough since webviews aren't tied directly to a resource (at least not at the vscode api layer). Maybe we can make that functionality specific to custom editors

    To start, can we create a command that opens the current resource in a split view with the text editor on the left and default custom editor on the right? That seems possible with the work you've been doing

    Longer term, we should also likely allow users to configure if a resource opens in this split view by default, and potentially let extensions create editors in split mode by default as well

  21. DanTup commented on Sep 9, 2021

    @DanTup
    Contributor

    Maybe we can make that functionality specific to custom editors

    Could TextDocumentContentProvider be supported too? I'd like to show a preview of code with generated code included, and this would work great (it's readonly, and has other functionality like hovers, navigation, etc.). Building a custom editor just to show another code view would be pretty clunky.

  22. bpasero commented on Sep 10, 2021

    @bpasero
    Contributor

    Matt Bierner (@mjbvz) to clarify how the side by side editor works: you can literally put any editor (anything that extends EditorPane) into either sides. The side by side editor is essentially a host of 2 full editors that can be independent from each other.

    There is a bit of a challenge how this editor is being accessed from other components because components have to be aware that there is a left and a right side, so this would probably need a bit of adoption going forward. In other words, any code that does IEditorService.activeEditor and Co will need to check for side by side editor.

    To start, can we create a command that opens the current resource in a split view with the text editor on the left and default custom editor on the right? That seems possible with the work you've been doing

    Yeah possible. Any kind of editor can be opened to the side. An alternative idea I had was to add a command that would allow you to pick an editor from quick open to put to the side of the active editor. But that requires that you have opened a markdown preview before.

  23. hho commented on Mar 6, 2024

    @hho
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

custom-editorsfeature-requestwebviewworkbench-editors

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions