Skip to content

Commit

Permalink
fix: jupyterlab layout
Browse files Browse the repository at this point in the history
  • Loading branch information
echarles committed Aug 9, 2023
1 parent d2aaa88 commit 3177cd1
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 30 deletions.
2 changes: 1 addition & 1 deletion examples/cra/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"dependencies": {
"@datalayer/jupyter-react": "0.5.2",
"@datalayer/primer-addons": "0.0.19",
"@datalayer/primer-addons": "0.0.20",
"react": "18.2.0",
"react-dom": "18.2.0",
"web-vitals": "2.1.4"
Expand Down
2 changes: 1 addition & 1 deletion examples/lexical/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"dependencies": {
"@datalayer/jupyter-lexical": "0.0.1",
"@datalayer/primer-addons": "0.0.19",
"@datalayer/primer-addons": "0.0.20",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-json-tree": "0.17.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/lexical/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
},
"dependencies": {
"@datalayer/jupyter-react": "0.5.2",
"@datalayer/primer-addons": "0.0.19",
"@datalayer/primer-addons": "0.0.20",
"@jupyterlab/application": "4.0.3",
"@jupyterlab/coreutils": "6.0.3",
"@jupyterlab/services": "7.0.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"@datalayer/jupyterlite-kernel": "0.1.0-beta.13",
"@datalayer/jupyterlite-server": "0.1.0-beta.13",
"@datalayer/jupyterlite-server-extension": "0.1.0-beta.13",
"@datalayer/primer-addons": "0.0.19",
"@datalayer/primer-addons": "0.0.20",
"@datalayer/typescript-fsa-redux-observable": "0.18.0",
"@jupyter-widgets/base": "6.0.5",
"@jupyter-widgets/controls": "5.0.6",
Expand Down
39 changes: 39 additions & 0 deletions packages/react/src/components/viewer/output/OutputAdapter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { IOutput } from '@jupyterlab/nbformat';
import { OutputArea, OutputAreaModel } from '@jupyterlab/outputarea';
import { IRenderMime, RenderMimeRegistry, standardRendererFactories } from '@jupyterlab/rendermime';
import { rendererFactory as jsonRendererFactory } from '@jupyterlab/json-extension';
import { rendererFactory as javascriptRendererFactory } from '@jupyterlab/javascript-extension';

export class OutputAdapter {
private _renderers: IRenderMime.IRendererFactory[];
private _outputArea: OutputArea;
private _rendermime: RenderMimeRegistry;

public constructor(outputs?: IOutput[]) {
this._renderers = standardRendererFactories.filter(factory => factory.mimeTypes[0] !== 'text/javascript');
this._renderers.push(jsonRendererFactory);
this._renderers.push(javascriptRendererFactory);
this._rendermime = new RenderMimeRegistry({
initialFactories: this._renderers,
});
const outputAreaModel = new OutputAreaModel({
trusted: true,
values: outputs,
})
this._outputArea = new OutputArea({
model: outputAreaModel,
rendermime: this._rendermime,
});
}

public clearOutput() {
this._outputArea.model.clear();
}

get outputArea(): OutputArea {
return this._outputArea;
}

}

export default OutputAdapter;
4 changes: 2 additions & 2 deletions packages/react/src/components/viewer/output/OutputViewer.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ICell, IOutput } from '@jupyterlab/nbformat';
import Lumino from '../../../jupyter/lumino/Lumino';
import OutputAdapter from '../../../components/output/OutputAdapter';
import OutputAdapter from './OutputAdapter';

type Props = {
cell: ICell,
Expand All @@ -9,7 +9,7 @@ type Props = {
const OutputViewer = (props: Props) => {
const { cell } = props;
const outputs = cell.outputs ? (cell.outputs as IOutput[]) : undefined;
const outputAdapter = new OutputAdapter(undefined, outputs);
const outputAdapter = new OutputAdapter(outputs);
switch(cell.cell_type) {
case 'code': {
return (
Expand Down
8 changes: 0 additions & 8 deletions packages/react/src/jupyter/lab/notebook/classic/icon.ts

This file was deleted.

4 changes: 2 additions & 2 deletions packages/react/src/jupyter/lab/notebook/classic/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { CommandRegistry } from '@lumino/commands';
import { ReadonlyPartialJSONObject } from '@lumino/coreutils';
import { IDisposable } from '@lumino/disposable';
import { ClassicRender, IClassicRenderTracker, ClassicRenderFactory } from './classicRender';
import { notebookClassicIcon } from './icon';
import { jupiterIconLabIcon as notebookClassicIcon } from '@datalayer/icons-react/data2/JupiterIconLabIcon';

export namespace CommandIDs {
export const classicRender = 'notebook:render-with-classic';
Expand All @@ -29,7 +29,7 @@ class ClassicRenderButton implements DocumentRegistry.IWidgetExtension<NotebookP
const button = new ToolbarButton({
className: 'classicRender',
tooltip: 'Render with Classic',
icon: notebookClassicIcon,
icon: notebookClassicIcon as any,
onClick: () => { this._commands.execute(CommandIDs.classicRender); }
});
panel.toolbar.insertAfter('cellType', 'classicRender', button);
Expand Down
8 changes: 0 additions & 8 deletions packages/react/src/jupyter/lab/notebook/dashboard/icon.ts

This file was deleted.

10 changes: 5 additions & 5 deletions packages/react/src/jupyter/lab/notebook/dashboard/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { CommandRegistry } from '@lumino/commands';
import { ReadonlyPartialJSONObject } from '@lumino/coreutils';
import { IDisposable } from '@lumino/disposable';
import { JupyterFrontEnd, JupyterFrontEndPlugin, ILayoutRestorer } from '@jupyterlab/application';
import { ICommandPalette, WidgetTracker, ToolbarButton } from '@jupyterlab/apputils';
import { ISettingRegistry } from '@jupyterlab/settingregistry';
import { DocumentRegistry } from '@jupyterlab/docregistry';
import { IMainMenu } from '@jupyterlab/mainmenu';
import { INotebookTracker, NotebookPanel, INotebookModel } from '@jupyterlab/notebook';
import { CommandRegistry } from '@lumino/commands';
import { ReadonlyPartialJSONObject } from '@lumino/coreutils';
import { IDisposable } from '@lumino/disposable';
import { Dashboard, IDashboardTracker, DashboardFactory } from './dashboard';
import { dashboardIcon } from './icon';
import { academicCapIconLabIcon as dashboardIcon } from '@datalayer/icons-react/data1/AcademicCapIconLabIcon';

export namespace CommandIDs {
export const dashboardRender = 'notebook:render-with-dashboard';
Expand All @@ -28,7 +28,7 @@ class DashboardButton implements DocumentRegistry.IWidgetExtension<NotebookPanel
const button = new ToolbarButton({
className: 'dashboardRender',
tooltip: 'Dashboard',
icon: dashboardIcon,
icon: dashboardIcon as any,
onClick: () => { this._commands.execute(CommandIDs.dashboardRender); }
});
panel.toolbar.insertAfter('cellType', 'dashboardRender', button);
Expand Down
2 changes: 1 addition & 1 deletion packages/traitlets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"kill": "make kill || true"
},
"dependencies": {
"@datalayer/primer-addons": "0.0.19",
"@datalayer/primer-addons": "0.0.20",
"@jupyterlab/application": "4.0.3",
"@jupyterlab/coreutils": "6.0.3",
"@jupyterlab/services": "7.0.3",
Expand Down

0 comments on commit 3177cd1

Please sign in to comment.