-
Notifications
You must be signed in to change notification settings - Fork 92
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
Viewer pane pops out to editor tab #4808
Conversation
src/vs/workbench/contrib/positronPreviewEditor/browser/positronPreviewEditor.tsx
Show resolved
Hide resolved
@@ -30,7 +30,7 @@ export class PreviewHtml extends PreviewWebview { | |||
previewId: string, | |||
webview: PreviewOverlayWebview, | |||
readonly uri: URI, | |||
readonly html: ShowHtmlFileEvent | |||
readonly html?: ShowHtmlFileEvent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was edited to allow creation of PreviewUrl
independent of a ShowHtmlFileEvent
@@ -496,4 +501,35 @@ export class PositronPreviewService extends Disposable implements IPositronPrevi | |||
// It's a localhost http or https URL; we can handle it in the viewer. | |||
return true; | |||
} | |||
|
|||
public async openEditor(uri: URI, title?: string): Promise<void> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is where most of the content is; where we create the preview webview and open it in a custom editor. afaict, we are able to use PreviewUrl
for HTML files and local URLs, since they all will have a uri we can use to open.
I see some unexpected behaviour with switching between editors. It goes away once I close the preview editor tab. Somehow, the preview contents are always on top. Screen.Recording.2024-11-20.at.11.18.17.AM.mov |
Oh gosh, you are correct 😭 should be fixed now with a proper visibility event handler! |
I'm getting a blank editor on first view now. It seems to fix itself when switching to another editor tab and back. It might be something to do with the initial visibility flag on the editor? The preview service is using the webview service to create an overlay webview, which is sitting on top of the editor area. Maybe using a regular, non-overlay webview will make it easier to deal with visibility? |
Ah, this is it!
I had set it up this way to be able to reuse the webviews from the Viewer Pane, which require an overlay webview. I think the visibility was just me making it more complicated than it needed to be 😆 BUT if there are other important reasons to not use an overlay, I can look at teasing those two pieces apart! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
It will be interesting to see if there's feedback about bringing back the editor when the UI refreshes (might be useful for Workbench). The previews aren't currently saved so that's something that could be done later, if there's interest, to support this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few nits and style suggestions but looks good to me!
src/vs/workbench/contrib/positronPreviewEditor/browser/editorPreviewContainer.tsx
Outdated
Show resolved
Hide resolved
src/vs/workbench/contrib/positronPreviewEditor/browser/editorPreviewContainer.tsx
Outdated
Show resolved
Hide resolved
src/vs/workbench/contrib/positronPreviewEditor/browser/editorPreviewContainer.tsx
Outdated
Show resolved
Hide resolved
src/vs/workbench/contrib/positronPreviewEditor/browser/positronPreviewEditor.tsx
Show resolved
Hide resolved
src/vs/workbench/contrib/positronPreview/browser/positronPreviewServiceImpl.ts
Outdated
Show resolved
Hide resolved
…ewServiceImpl.ts Co-authored-by: Nick Strayer <nick.strayer@posit.co> Signed-off-by: Isabel Zimmerman <54685329+isabelizimm@users.noreply.github.com>
addresses #3714
Example video (bonus content: if you turn volume up you can hear puppy snoring 💤 )
editor-preview.mov
Can pop out HTML or url from viewer pane to editor tab. Should work for multiple editors, independently of the Viewer pane content.
Known problems/what is not included:
Preview
button in Quarto file to editor. It seems like Quarto has a different toolbar than urls/html (same with html sent to output, eg, No way to clear viewer with great-tables table #4601)very inspired by #4364 🫶
QA notes
These are all gestures I've gone through and confirmed working! It looks like a lot of steps but includes a lot of opening up files 😄
.qmd
filesquarto render filename_1.qmd
in Terminal so you have HTML outputfilename_1.qmd
still in editor,quarto preview filename_2.qmd
to get alocalhost
url.qmd
files in editors