Skip to content

Commit 81bf97d

Browse files
committed
Merge branch 'ft/rich/1' into ft/rich-editor/1
2 parents 9c797bc + 18d69fd commit 81bf97d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+989
-123
lines changed

.gitignore

+3-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ node_modules/
4040
# Version file is handled by hatchling
4141
**/jupyter_react/_version.py
4242

43-
**/jupyter_react/static
43+
**/jupyter_react/static/*.js
44+
**/jupyter_react/static/*.css
4445

4546
# Integration tests
4647
test-results/
@@ -174,4 +175,4 @@ packages/react/.vscode/launch.json
174175
!.licenserc.yaml
175176
!dev/notebooks/.datalayer
176177
!docs/static/img
177-
!packages/react/jupyter_react/static/README.md
178+
!**/static/README.md

examples/cra/src/App.test.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
* MIT License
55
*/
66

7-
import React from 'react';
87
import { render, screen } from '@testing-library/react';
98
import App from './App';
109

examples/cra/src/App.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const App = () => {
1414
return (
1515
<>
1616
<Layers/>
17-
<Jupyter startDefaultKernel={true} terminals={true}>
17+
<Jupyter startDefaultKernel terminals>
1818
<GalleryExample/>
1919
</Jupyter>
2020
</>

examples/cra/src/examples/AllExamples.tsx

+10-6
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ const AllExample = () => {
8383
<>
8484
<OutputToolbar />
8585
<Output
86-
showEditor={true}
86+
showEditor
8787
autoRun={false}
8888
kernel={kernel}
8989
code={"print('Hello Datalayer 👍')"}
@@ -93,16 +93,20 @@ const AllExample = () => {
9393
kernel={kernel}
9494
code={"print('Hello Datalayer 👍')"}
9595
/>
96-
<Output autoRun={true} kernel={kernel} code={source} />
96+
<Output autoRun kernel={kernel} code={source} />
9797
<Output
98-
autoRun={true}
98+
autoRun
9999
kernel={kernel}
100100
code={
101101
"print('=> Hello Datalayer again... I am the output of an non-shown editor 👍 <=')"
102102
}
103103
/>
104104
<CellToolbar cellId={CELL_ID} />
105-
<Cell id={CELL_ID} source={source} />
105+
<Cell
106+
id={CELL_ID}
107+
kernel={kernel}
108+
source={source}
109+
/>
106110
<CommandsToolbar />
107111
<Commands />
108112
<ConsoleToolbar />
@@ -115,7 +119,7 @@ const AllExample = () => {
115119
{serviceManager && <FileBrowser serviceManager={serviceManager}/> }
116120
<FileManagerJupyterLab />
117121
<NotebookToolbar notebookId={NOTEBOOK_ID} />
118-
<Notebook id={NOTEBOOK_ID} path="ping.ipynb"/>
122+
<Notebook id={NOTEBOOK_ID} path=".datalayer/ping.ipynb"/>
119123
<SettingsToolbar />
120124
<Settings />
121125
<LuminoComponent />
@@ -129,7 +133,7 @@ const div = document.createElement('div');
129133
document.body.appendChild(div);
130134

131135
render(
132-
<Jupyter collaborative={true} terminals={true}>
136+
<Jupyter startDefaultKernel collaborative terminals>
133137
<AllExample />
134138
</Jupyter>,
135139
div

examples/cra/src/examples/CellExample.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const div = document.createElement('div');
1515
document.body.appendChild(div);
1616

1717
render(
18-
<Jupyter collaborative={false} terminals={false}>
18+
<Jupyter startDefaultKernel collaborative={false} terminals={false}>
1919
<Layers />
2020
<CellComponents />
2121
</Jupyter>,

examples/cra/src/examples/ConsoleExample.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const div = document.createElement('div');
1515
document.body.appendChild(div);
1616

1717
render(
18-
<Jupyter collaborative={false} terminals={false}>
18+
<Jupyter startDefaultKernel collaborative={false} terminals={false}>
1919
<Layers />
2020
<ConsoleToolbar />
2121
<Console />

examples/cra/src/examples/LuminoExample.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const div = document.createElement('div');
1414
document.body.appendChild(div);
1515

1616
render(
17-
<Jupyter collaborative={false} terminals={false}>
17+
<Jupyter startDefaultKernel collaborative={false} terminals={false}>
1818
<Layers />
1919
<LuminoToolbar />
2020
<LuminoComponent />

examples/cra/src/examples/NotebookExample.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ const NOTEBOOK_UID = 'notebook-uid-example';
1818
*/
1919
const Example = () => {
2020
return (
21-
<Jupyter collaborative={false} terminals={false}>
21+
<Jupyter startDefaultKernel collaborative={false} terminals={false}>
2222
<Layers />
2323
<NotebookSimpleToolbar notebookId={NOTEBOOK_UID} />
24-
<Notebook id={NOTEBOOK_UID} path="ping.ipynb" />
24+
<Notebook id={NOTEBOOK_UID} path=".datalayer/ping.ipynb" />
2525
</Jupyter>
2626
);
2727
};

examples/cra/src/examples/NotebookSidebarExample.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ const NOTEBOOK_UID = 'notebook-id-simple';
1313

1414
export default function NotebookSidebarComponent() {
1515
return (
16-
<Jupyter collaborative={false} terminals={true}>
16+
<Jupyter startDefaultKernel collaborative={false} terminals>
1717
<div style={{padding: '2rem'}}>
1818
<Box sx={{width: '100%'}}>
1919
<NotebookToolbar notebookId={NOTEBOOK_UID} />
2020
<Notebook
21-
path="ping.ipynb"
21+
path=".datalayer/ping.ipynb"
2222
id={NOTEBOOK_UID}
2323
extensions={[new CellSidebarExtension({ factory: CellSidebar })]}
2424
/>

examples/cra/src/examples/OutputsExample.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const div = document.createElement('div');
1616
document.body.appendChild(div);
1717

1818
render(
19-
<Jupyter collaborative={false} terminals={false}>
19+
<Jupyter startDefaultKernel collaborative={false} terminals={false}>
2020
<Layers />
2121
<OutputsToolbar />
2222
<OutputsComponents />

examples/cra/src/examples/TerminalExample.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const div = document.createElement('div');
1515
document.body.appendChild(div);
1616

1717
render(
18-
<Jupyter collaborative={false} terminals={true}>
18+
<Jupyter startDefaultKernel collaborative={false} terminals>
1919
<Layers />
2020
<TerminalToolbar />
2121
<Terminal height="500px" />

examples/cra/src/examples/cell/CellToolbar.tsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
* MIT License
55
*/
66

7-
import React from 'react';
87
import { Box, IconButton, Text, Tooltip } from '@primer/react';
98
import { PlayIcon, ReplyIcon, ThreeBarsIcon } from '@primer/octicons-react';
109
import { useCellsStore } from '@datalayer/jupyter-react';
@@ -39,12 +38,12 @@ const CellToolbar = (props: {cellId: string}) => {
3938
onClick={() => cellStore.execute()}
4039
/>
4140
</Tooltip>
42-
<Tooltip aria-label="Run the cell">
41+
<Tooltip aria-label="Reset output count">
4342
<IconButton
4443
size="small"
4544
variant="invisible"
4645
icon={ReplyIcon}
47-
aria-label="Rest the outputcount"
46+
aria-label="Reset the output count"
4847
onClick={() => cellStore.setOutputsCount(cellId, 0)}
4948
/>
5049
</Tooltip>

examples/cra/src/examples/ipywidgets/IPyWidgetsExample.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const div = document.createElement('div');
1616
document.body.appendChild(div);
1717

1818
render(
19-
<Jupyter collaborative={false} terminals={false}>
19+
<Jupyter startDefaultKernel collaborative={false} terminals={false}>
2020
<Layers />
2121
<IPyWidgetsToolbar />
2222
<OutputIPyWidgets state={state} view={view} />

examples/cra/src/examples/labapp/JupyterLabHeadlessApp.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export const JupyterLabHeadlessAppExample = () => {
5353
}
5454
return (
5555
<>
56-
<Jupyter startDefaultKernel={false} disableCssLoading={true} colormode="light">
56+
<Jupyter startDefaultKernel={false} disableCssLoading colormode="light">
5757
{ boxPanel &&
5858
<div style={{ position: "relative" }}>
5959
<Box className="jp-LabShell"
@@ -79,7 +79,7 @@ export const JupyterLabHeadlessAppExample = () => {
7979
mimeRenderers={[
8080
mimePlotlyExtension,
8181
]}
82-
headless={true}
82+
headless
8383
onJupyterLab={onJupyterLab}
8484
pluginId="@jupyterlab/apputils-extension:themes"
8585
PluginType={ThemeManager}

examples/cra/src/examples/outputs/OutputsComponents.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,13 @@ export const OutputsComponents = () => {
153153
return <>
154154
<h3>Simple Output</h3>
155155
<Output
156-
autoRun={true}
156+
autoRun
157157
kernel={kernel}
158158
code={"print('Hello Datalayer 👍')"}
159159
/>
160160
<h3>IPyWidget Output</h3>
161161
<Output
162-
autoRun={true}
162+
autoRun
163163
kernel={kernel}
164164
code={SOURCE_IPYWIDGET}
165165
/>

packages/react/Makefile

+8
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,11 @@ publish-storybook: build-storybook ## publish to s3
8282
--paths "/*" \
8383
--profile datalayer && \
8484
echo open ✨ https://jupyter-ui-storybook.datalayer.tech )
85+
86+
publish-pypi: # publish the pypi package
87+
git clean -fdx && \
88+
python -m build
89+
@exec echo
90+
@exec echo twine upload ./dist/*-py3-none-any.whl
91+
@exec echo
92+
@exec echo https://pypi.org/project/jupyter-react/#history

packages/react/src/components/console/Console.tsx

+5-6
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,20 @@ import useConsoleStore from './ConsoleState';
1313
import './Console.css';
1414

1515
export const Console = (options: Console.IConsoleOptions) => {
16-
const { defaultKernel, defaultKernelIsLoading, serviceManager } =
17-
useJupyter();
16+
const { defaultKernel, serviceManager } = useJupyter();
1817
const [adapter, setAdapter] = useState<ConsoleAdapter>();
19-
const consoleStore = useConsoleStore();
18+
const store = useConsoleStore();
2019
useEffect(() => {
21-
if (serviceManager && !defaultKernelIsLoading) {
20+
if (serviceManager) {
2221
const adapter = new ConsoleAdapter({
2322
kernel: defaultKernel,
2423
serviceManager,
2524
code: options.code,
2625
});
2726
setAdapter(adapter);
28-
consoleStore.setAdapter(adapter);
27+
store.setAdapter(adapter);
2928
}
30-
}, [defaultKernel, defaultKernelIsLoading, serviceManager]);
29+
}, [defaultKernel, serviceManager]);
3130
return adapter ? (
3231
<Lumino>{adapter.panel}</Lumino>
3332
) : (

packages/react/src/components/notebook/Notebook.tsx

+4-5
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ import {
3838
import { CellMetadataEditor } from './cell/metadata';
3939
import { NotebookAdapter } from './NotebookAdapter';
4040
import { useNotebookStore } from './NotebookState';
41-
import { INotebookToolbarProps } from './toolbar/NotebookToolbar';
42-
41+
import { INotebookToolbarProps } from './toolbar';
4342
import { Loader } from '../utils';
43+
4444
import './Notebook.css';
4545

4646
export type ExternalIPyWidgets = {
@@ -147,7 +147,6 @@ export const Notebook = (props: INotebookProps) => {
147147
const portals = notebookStore.selectNotebookPortals(id);
148148

149149
const [isLoading, setIsLoading] = useState(false);
150-
console.log(isLoading);
151150

152151
// Bootstrap the Notebook Adapter.
153152
const bootstrapAdapter = async (
@@ -260,7 +259,7 @@ export const Notebook = (props: INotebookProps) => {
260259
}, [serviceManager, kernel]);
261260

262261
useEffect(() => {
263-
// As the server has the content source of thruth, we
262+
// As the server has the content source of truth, we
264263
// must ensure that the shared model is pristine before
265264
// to connect to the server. More over we should ensure,
266265
// the connection is disposed in case the server room is
@@ -300,7 +299,6 @@ export const Notebook = (props: INotebookProps) => {
300299
});
301300
}
302301
}
303-
304302
// FIXME inform the user.
305303
}
306304
};
@@ -402,6 +400,7 @@ export const Notebook = (props: INotebookProps) => {
402400
}
403401
sharedModel?.dispose();
404402
};
403+
405404
}, [adapter?.notebookPanel, collaborative]);
406405

407406
useEffect(() => {

packages/react/src/components/output/Output.tsx

+13-13
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export const Output = (props: IOutputProps) => {
102102
}
103103
};
104104
if (id && kernel) {
105-
const adapter = propsAdapter ?? new OutputAdapter(id, kernel, outputs ?? [], model,suppressCodeExecutionErrors);
105+
const adapter = propsAdapter ?? new OutputAdapter(id, kernel, outputs ?? [], model, suppressCodeExecutionErrors);
106106
setAdapter(adapter);
107107
outputStore.setAdapter(id, adapter);
108108
if (model) {
@@ -139,7 +139,7 @@ export const Output = (props: IOutputProps) => {
139139
});
140140
});
141141
return () => {
142-
// kernel.connection.then(k => k.shutdown().then(() => console.log(`Kernel ${k.id} is terminated.`)));
142+
// kernel.connection.then(k => k.shutdown().then(() => console.log(`Kernel ${k.id} is terminated.`)));
143143
};
144144
}
145145
}, [kernel]);
@@ -170,17 +170,17 @@ export const Output = (props: IOutputProps) => {
170170
}}
171171
>
172172
{/*
173-
<CodeMirrorDatalayerEditor
174-
autoRun={autoRun}
175-
code={code}
176-
codePre={codePre}
177-
disableRun={disableRun}
178-
insertText={insertText}
179-
kernel={kernel}
180-
outputAdapter={adapter}
181-
sourceId={id}
182-
toolbarPosition={toolbarPosition}
183-
/>
173+
<CodeMirrorDatalayerEditor
174+
autoRun={autoRun}
175+
code={code}
176+
codePre={codePre}
177+
disableRun={disableRun}
178+
insertText={insertText}
179+
kernel={kernel}
180+
outputAdapter={adapter}
181+
sourceId={id}
182+
toolbarPosition={toolbarPosition}
183+
/>
184184
*/}
185185
</Box>
186186
)}

packages/react/src/components/output/OutputAdapter.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ export class OutputAdapter {
5959
},
6060
0
6161
);
62-
// const widgetRegistry = activateWidgetExtension(this._rendermime);
63-
// activatePlotlyWidgetExtension(widgetRegistry);
62+
// const widgetRegistry = activateWidgetExtension(this._rendermime);
63+
// activatePlotlyWidgetExtension(widgetRegistry);
6464
const model =
6565
outputAreaModel ??
6666
new OutputAreaModel({

packages/react/src/examples/CellLite.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ document.body.appendChild(div);
1414
const root = createRoot(div);
1515

1616
root.render(
17-
<Jupyter lite>
17+
<Jupyter startDefaultKernel lite>
1818
<Box as="h1">A Jupyter Cell with a Lite Kernel</Box>
1919
<Cell
2020
source={`import sys
21-
print(f"👋 Hello Jupyter UI Lite {sys.platform} {get_ipython()}")`}
21+
print(f"👋 Hello Jupyter UI Lite - Platform: {sys.platform} - IPython: {get_ipython()}")`}
2222
/>
2323
</Jupyter>
2424
);

packages/react/src/examples/ConsoleLite.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ document.body.appendChild(div);
1414
const root = createRoot(div);
1515

1616
root.render(
17-
<Jupyter lite>
17+
<Jupyter startDefaultKernel lite>
1818
<Box as="h1">A Jupyter Console with a Lite Kernel</Box>
1919
<Console
2020
code={`import micropip
2121
await micropip.install('numpy')
2222
import numpy
23-
print(f'👋 Hello Jupyter Console with a Lite Kernel and numpy {numpy.__version__}')`}
23+
print(f'👋 Hello Jupyter Console with a Lite Kernel - Platform: {sys.platform} - IPython: {get_ipython()}") - numpy {numpy.__version__}')`}
2424
/>
2525
</Jupyter>
2626
);

0 commit comments

Comments
 (0)