You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Investigate better UX for previewing things #22068
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.
Reacted by Jun Han, Roman Dvornov, andreibreeze, Frederik Schubert, Mikhail Shustov, Shawn Doucet, naillizard, Markus Wolf, Devin Clark, Misha and 6 more
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
Mockup showing in-editor-peview of something (note that source-view and that preview share the same editor/tab)
Gif how iaWriter sync scrolling from both sides and how it 'zooms' the preview when moving the sash
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
interfacePreview{// allow for scrolling sync, some bidirectional line mapping // allow for preview-kind, e.g. source or html-rendered// ...}interfacePreviewProvider{providePreview(document: TextDocument): ProviderResult<Preview>;}
Reacted by Almenon, Splike, Chris and Simon Siefke
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
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
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
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
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?).
With #132651 it is possible to split an editor into 2 in the same group:
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:
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?
Reacted by Miguel Solorio, heartacker, Matt Bierner, Achille Lacoin, LucasOe and Michael A. Hawker
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
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.
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.
Activity
daviwil commentedon Mar 12, 2017
Looking forward to this!
smelukov commentedon Mar 20, 2017
Maybe the better solution is provided a possibility to build own UI inside a tab through DOM-access (like in Atom).
Something like
DOMContentProvideror like that...Or access to DOM of
previewHtmlFor example: if I want to insert an iframe inside a tab and get access to its
contentWindow-property, thenpreviewHtmlis 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.smelukov commentedon Mar 30, 2017
Hi! Is there any chance to get a possibility to create an iframe inside a tab? :)
[-]Investigate better UX api[/-][+]Investigate better UX for previewing things[/+]jrieken commentedon Apr 13, 2017
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
jrieken commentedon Apr 13, 2017
fyi Matt Bierner (@mjbvz)
jrieken commentedon Apr 18, 2017
Mockup showing in-editor-peview of something (note that source-view and that preview share the same editor/tab)
Gif how iaWriter sync scrolling from both sides and how it 'zooms' the preview when moving the sash
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
mjbvz commentedon Apr 19, 2017
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
jrieken commentedon Apr 21, 2017
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
14 remaining items
keshann93 commentedon Apr 29, 2020
anyone still looking for a markdown preview/editor for vscode, tryout this extension
mjbvz commentedon Jun 22, 2020
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
jrieken commentedon Jun 23, 2020
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
mjbvz commentedon Jun 23, 2020
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
DanTup commentedon Jul 13, 2021
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
TextDocumentContentProvidermight do it (and if done right, might even allow debugging stepping through the generated code while keeping the two together?).bpasero commentedon Sep 8, 2021
With #132651 it is possible to split an editor into 2 in the same group:
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:
But there are some questions:
mjbvz commentedon Sep 9, 2021
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
DanTup commentedon Sep 9, 2021
Could
TextDocumentContentProviderbe 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.bpasero commentedon Sep 10, 2021
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.activeEditorand Co will need to check for side by side editor.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.
hho commentedon Mar 6, 2024