-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch to overlay webviews for notebooks (#5829)
Addresses #5491 This PR changes how we render html output in notebooks 2.0 by switching to overlay webviews instead of standard ones. The reason for this switch was that there is no way to preserve the content of the webview across visibility changes with standard webviews. This means we would have to fully re-render every output every time the user switched to the notebook view. One benefit of this switch is we were able to remove all the logic surrounding different webview types being returned from the various webview services, simplifying the API a good bit. ### QA Notes - Dynamic plots like hvplot should still show up as expected. - You should be able to navigate away from the notebook and back and the plot should reappear in the same state it was in. - Plots should never spill out of the notebook containment. (e.g. be visible when the notebook isnt. This is an annoying problem with overlay webviews that we've had to deal with before in the plots pane etc..)
- Loading branch information
Showing
14 changed files
with
444 additions
and
167 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
src/vs/workbench/contrib/positronNotebook/browser/NotebookVisibilityContext.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (C) 2024 Posit Software, PBC. All rights reserved. | ||
* Licensed under the Elastic License 2.0. See LICENSE.txt for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
// React. | ||
import React, { PropsWithChildren, createContext, useContext } from 'react'; | ||
|
||
// Other dependencies. | ||
import { ISettableObservable } from '../../../../base/common/observableInternal/base.js'; | ||
|
||
/** | ||
* Create the notebook visibility context. | ||
*/ | ||
const NotebookVisibilityContext = createContext<ISettableObservable<boolean>>(undefined!); | ||
|
||
/** | ||
* Provider component for notebook visibility state | ||
*/ | ||
export const NotebookVisibilityProvider = ({ | ||
isVisible, | ||
children | ||
}: PropsWithChildren<{ isVisible: ISettableObservable<boolean> }>) => { | ||
return ( | ||
<NotebookVisibilityContext.Provider value={isVisible}> | ||
{children} | ||
</NotebookVisibilityContext.Provider> | ||
); | ||
}; | ||
|
||
/** | ||
* Hook to access the notebook visibility state | ||
* @returns The current visibility state as a boolean | ||
*/ | ||
export const useNotebookVisibility = () => { | ||
return useContext(NotebookVisibilityContext) | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.