mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-03-26 03:29:14 +00:00
[Preview this branch](https://cosmos-explorer-preview.azurewebsites.net/pull/762?feature.someFeatureFlagYouMightNeed=true) The main change in this PR fixes the snapshot functionality in the Publish pane-related components. Because the code cell outputs are now rendered in their own iframes for security reasons, a single snapshot of the notebook is no longer possible: each cell output takes its own snapshot and the snapshots are collated on the main notebook snapshot. - Move the snapshot functionality to notebook components: this removes the reference of the notebook DOM node that we must pass to the Publish pane via explorer. - Add slice in the state and actions in notebook redux for notebook snapshot requests and result - Add post robot message to take snapshots and receive results - Add logic in `NotebookRenderer` to wait for all output snapshots done before taking the main one collating. - Use `zustand` to share snapshot between Redux world and React world. This solves the issue of keeping the `PanelContainer` component generic, while being able to update its children (`PublishPanel` component) with the new snapshot. Additional changes: - Add `local()` in `@font-face` to check if font is already installed before downloading the font (must be done for Safari, but not Edge/Chrome) - Add "Export output to image" menu item in notebook cell, since each cell output can take its own snapshot (which can be downloaded) 
51 lines
1.7 KiB
TypeScript
51 lines
1.7 KiB
TypeScript
// Vendor modules
|
|
import { actions, createContentRef, createKernelRef, selectors } from "@nteract/core";
|
|
import * as React from "react";
|
|
import { ReactAdapter } from "../../../Bindings/ReactBindingHandler";
|
|
import { NotebookClientV2 } from "../NotebookClientV2";
|
|
import { NotebookContentItem } from "../NotebookContentItem";
|
|
import { NotebookComponentBootstrapper } from "./NotebookComponentBootstrapper";
|
|
import VirtualCommandBarComponent from "./VirtualCommandBarComponent";
|
|
|
|
export interface NotebookComponentAdapterOptions {
|
|
contentItem: NotebookContentItem;
|
|
notebooksBasePath: string;
|
|
notebookClient: NotebookClientV2;
|
|
onUpdateKernelInfo: () => void;
|
|
}
|
|
|
|
export class NotebookComponentAdapter extends NotebookComponentBootstrapper implements ReactAdapter {
|
|
private onUpdateKernelInfo: () => void;
|
|
public parameters: any;
|
|
|
|
constructor(options: NotebookComponentAdapterOptions) {
|
|
super({
|
|
contentRef: selectors.contentRefByFilepath(options.notebookClient.getStore().getState(), {
|
|
filepath: options.contentItem.path,
|
|
}),
|
|
notebookClient: options.notebookClient,
|
|
});
|
|
|
|
this.onUpdateKernelInfo = options.onUpdateKernelInfo;
|
|
|
|
if (!this.contentRef) {
|
|
this.contentRef = createContentRef();
|
|
const kernelRef = createKernelRef();
|
|
|
|
// Request fetching notebook content
|
|
this.getStore().dispatch(
|
|
actions.fetchContent({
|
|
filepath: options.contentItem.path,
|
|
params: {},
|
|
kernelRef,
|
|
contentRef: this.contentRef,
|
|
})
|
|
);
|
|
}
|
|
}
|
|
|
|
protected renderExtraComponent = (): JSX.Element => {
|
|
return <VirtualCommandBarComponent contentRef={this.contentRef} onRender={this.onUpdateKernelInfo} />;
|
|
};
|
|
}
|