@datalayer/jupyter-react 0.19.4 → 0.19.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/app/tabs/components/NotebookComponent.js +3 -2
- package/lib/app/tabs/components/NotebookComponent.js.map +1 -1
- package/lib/components/cell/CellCommands.d.ts +1 -1
- package/lib/components/cell/CellCommands.js +7 -7
- package/lib/components/cell/CellCommands.js.map +1 -1
- package/lib/components/console/Console.js +5 -5
- package/lib/components/console/Console.js.map +1 -1
- package/lib/components/notebook/BaseNotebook.d.ts +7 -7
- package/lib/components/notebook/BaseNotebook.js +95 -80
- package/lib/components/notebook/BaseNotebook.js.map +1 -1
- package/lib/components/notebook/Notebook.css +13 -0
- package/lib/components/notebook/Notebook.d.ts +0 -3
- package/lib/components/notebook/Notebook.js +8 -18
- package/lib/components/notebook/Notebook.js.map +1 -1
- package/lib/components/notebook/NotebookAdapter.d.ts +7 -9
- package/lib/components/notebook/NotebookAdapter.js +17 -21
- package/lib/components/notebook/NotebookAdapter.js.map +1 -1
- package/lib/components/notebook/NotebookCommands.d.ts +2 -2
- package/lib/components/notebook/NotebookCommands.js +62 -52
- package/lib/components/notebook/NotebookCommands.js.map +1 -1
- package/lib/components/notebook/SimpleNotebook.d.ts +9 -3
- package/lib/components/notebook/SimpleNotebook.js +2 -13
- package/lib/components/notebook/SimpleNotebook.js.map +1 -1
- package/lib/components/notebook/cell/metadata/CellMetadataEditor.d.ts +14 -6
- package/lib/components/notebook/cell/metadata/CellMetadataEditor.js +35 -37
- package/lib/components/notebook/cell/metadata/CellMetadataEditor.js.map +1 -1
- package/lib/components/notebook/cell/metadata/NbGraderCells.d.ts +2 -2
- package/lib/components/notebook/cell/metadata/NbGraderCells.js +2 -2
- package/lib/components/notebook/cell/metadata/NbGraderCells.js.map +1 -1
- package/lib/components/notebook/cell/sidebar/CellSidebar.d.ts +28 -2
- package/lib/components/notebook/cell/sidebar/CellSidebar.js +64 -78
- package/lib/components/notebook/cell/sidebar/CellSidebar.js.map +1 -1
- package/lib/components/notebook/cell/sidebar/CellSidebarButton.d.ts +3 -2
- package/lib/components/notebook/cell/sidebar/CellSidebarButton.js +57 -72
- package/lib/components/notebook/cell/sidebar/CellSidebarButton.js.map +1 -1
- package/lib/components/notebook/cell/sidebar/CellSidebarRun.d.ts +3 -2
- package/lib/components/notebook/cell/sidebar/CellSidebarRun.js +14 -29
- package/lib/components/notebook/cell/sidebar/CellSidebarRun.js.map +1 -1
- package/lib/components/notebook/cell/sidebar/extension.d.ts +31 -0
- package/lib/components/notebook/cell/sidebar/extension.js +121 -0
- package/lib/components/notebook/cell/sidebar/extension.js.map +1 -0
- package/lib/components/notebook/cell/sidebar/index.d.ts +1 -1
- package/lib/components/notebook/cell/sidebar/index.js +1 -1
- package/lib/components/notebook/cell/sidebar/index.js.map +1 -1
- package/lib/components/notebook/content/JupyterReactContentFactory.d.ts +1 -12
- package/lib/components/notebook/content/JupyterReactContentFactory.js +2 -21
- package/lib/components/notebook/content/JupyterReactContentFactory.js.map +1 -1
- package/lib/components/output/Output.js +1 -1
- package/lib/components/output/Output.js.map +1 -1
- package/lib/components/output/OutputAdapter.js +2 -2
- package/lib/components/output/OutputAdapter.js.map +1 -1
- package/lib/examples/Bokeh.js +8 -4
- package/lib/examples/Bokeh.js.map +1 -1
- package/lib/examples/Bqplot.js +8 -4
- package/lib/examples/Bqplot.js.map +1 -1
- package/lib/examples/CellLite.js +2 -2
- package/lib/examples/CellLite.js.map +1 -1
- package/lib/examples/ConsoleLite.js +2 -2
- package/lib/examples/ConsoleLite.js.map +1 -1
- package/lib/examples/Dashboard.js +8 -9
- package/lib/examples/Dashboard.js.map +1 -1
- package/lib/examples/Deno.js +8 -4
- package/lib/examples/Deno.js.map +1 -1
- package/lib/examples/GeoJson.js +10 -5
- package/lib/examples/GeoJson.js.map +1 -1
- package/lib/examples/IPyLeaflet.js +8 -4
- package/lib/examples/IPyLeaflet.js.map +1 -1
- package/lib/examples/IPyReact.js +8 -4
- package/lib/examples/IPyReact.js.map +1 -1
- package/lib/examples/IPyWidgets.js +8 -9
- package/lib/examples/IPyWidgets.js.map +1 -1
- package/lib/examples/IPyWidgetsState.js +8 -9
- package/lib/examples/IPyWidgetsState.js.map +1 -1
- package/lib/examples/JupyterContext.js +20 -22
- package/lib/examples/JupyterContext.js.map +1 -1
- package/lib/examples/KernelExecute.js +1 -1
- package/lib/examples/KernelExecute.js.map +1 -1
- package/lib/examples/KernelExecutor.js +1 -1
- package/lib/examples/KernelExecutor.js.map +1 -1
- package/lib/examples/Kernels.js +1 -1
- package/lib/examples/Kernels.js.map +1 -1
- package/lib/examples/Matplotlib.js +8 -9
- package/lib/examples/Matplotlib.js.map +1 -1
- package/lib/examples/Notebook.js +4 -3
- package/lib/examples/Notebook.js.map +1 -1
- package/lib/examples/NotebookCellSidebar.js +5 -9
- package/lib/examples/NotebookCellSidebar.js.map +1 -1
- package/lib/examples/NotebookCellToolbar.js +11 -12
- package/lib/examples/NotebookCellToolbar.js.map +1 -1
- package/lib/examples/NotebookCollaborative.js +6 -3
- package/lib/examples/NotebookCollaborative.js.map +1 -1
- package/lib/examples/NotebookColormode.js +7 -11
- package/lib/examples/NotebookColormode.js.map +1 -1
- package/lib/examples/NotebookExtension.js +11 -12
- package/lib/examples/NotebookExtension.js.map +1 -1
- package/lib/examples/NotebookExternalContent.js +10 -12
- package/lib/examples/NotebookExternalContent.js.map +1 -1
- package/lib/examples/NotebookInit.js +5 -4
- package/lib/examples/NotebookInit.js.map +1 -1
- package/lib/examples/NotebookKernelChange.js +7 -6
- package/lib/examples/NotebookKernelChange.js.map +1 -1
- package/lib/examples/NotebookLess.js +8 -12
- package/lib/examples/NotebookLess.js.map +1 -1
- package/lib/examples/NotebookLite.js +6 -11
- package/lib/examples/NotebookLite.js.map +1 -1
- package/lib/examples/NotebookLiteContext.js +9 -10
- package/lib/examples/NotebookLiteContext.js.map +1 -1
- package/lib/examples/NotebookLocalServer.js +10 -7
- package/lib/examples/NotebookLocalServer.js.map +1 -1
- package/lib/examples/NotebookNbformat.js +8 -9
- package/lib/examples/NotebookNbformat.js.map +1 -1
- package/lib/examples/NotebookNbformatChange.js +9 -11
- package/lib/examples/NotebookNbformatChange.js.map +1 -1
- package/lib/examples/NotebookNoContext.js +4 -3
- package/lib/examples/NotebookNoContext.js.map +1 -1
- package/lib/examples/NotebookNoPrimer.js +5 -4
- package/lib/examples/NotebookNoPrimer.js.map +1 -1
- package/lib/examples/NotebookOnSessionConnection.js +7 -11
- package/lib/examples/NotebookOnSessionConnection.js.map +1 -1
- package/lib/examples/NotebookPath.js +4 -3
- package/lib/examples/NotebookPath.js.map +1 -1
- package/lib/examples/NotebookPathChange.js +9 -6
- package/lib/examples/NotebookPathChange.js.map +1 -1
- package/lib/examples/NotebookReadonly.js +6 -4
- package/lib/examples/NotebookReadonly.js.map +1 -1
- package/lib/examples/NotebookServiceManager.js +10 -14
- package/lib/examples/NotebookServiceManager.js.map +1 -1
- package/lib/examples/NotebookSkeleton.js +5 -4
- package/lib/examples/NotebookSkeleton.js.map +1 -1
- package/lib/examples/NotebookTheme.js +6 -10
- package/lib/examples/NotebookTheme.js.map +1 -1
- package/lib/examples/NotebookThemeColormode.js +6 -10
- package/lib/examples/NotebookThemeColormode.js.map +1 -1
- package/lib/examples/NotebookURL.js +4 -3
- package/lib/examples/NotebookURL.js.map +1 -1
- package/lib/examples/NotebookUnmount.js +7 -11
- package/lib/examples/NotebookUnmount.js.map +1 -1
- package/lib/examples/ObservableHQ.js +8 -4
- package/lib/examples/ObservableHQ.js.map +1 -1
- package/lib/examples/Output.js +3 -3
- package/lib/examples/Output.js.map +1 -1
- package/lib/examples/OutputWithMonitoring.js +1 -1
- package/lib/examples/OutputWithMonitoring.js.map +1 -1
- package/lib/examples/Outputs.js +3 -3
- package/lib/examples/Outputs.js.map +1 -1
- package/lib/examples/Panel.js +6 -3
- package/lib/examples/Panel.js.map +1 -1
- package/lib/examples/Plotly.js +8 -4
- package/lib/examples/Plotly.js.map +1 -1
- package/lib/examples/PyGWalker.js +8 -9
- package/lib/examples/PyGWalker.js.map +1 -1
- package/lib/examples/Vega.js +5 -4
- package/lib/examples/Vega.js.map +1 -1
- package/lib/examples/sidebars/CellSidebarSource.js +56 -73
- package/lib/examples/sidebars/CellSidebarSource.js.map +1 -1
- package/lib/jupyter/JupyterContext.d.ts +11 -0
- package/lib/jupyter/JupyterContext.js +2 -0
- package/lib/jupyter/JupyterContext.js.map +1 -1
- package/package.json +1 -1
- package/lib/components/notebook/cell/sidebar/CellSidebarWidget.d.ts +0 -16
- package/lib/components/notebook/cell/sidebar/CellSidebarWidget.js +0 -37
- package/lib/components/notebook/cell/sidebar/CellSidebarWidget.js.map +0 -1
- package/lib/examples/NotebookSimple.d.ts +0 -1
- package/lib/examples/NotebookSimple.js +0 -36
- package/lib/examples/NotebookSimple.js.map +0 -1
- package/lib/examples/notebooks/Lite.ipynb.json +0 -146
|
@@ -1,27 +1,25 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright (c) 2021-2023 Datalayer, Inc.
|
|
4
|
-
*
|
|
5
|
-
* MIT License
|
|
6
|
-
*/
|
|
7
|
-
import { useEffect, useState } from 'react';
|
|
8
|
-
import { ActionList, TextInput } from '@primer/react';
|
|
9
2
|
import { CheckIcon } from '@primer/octicons-react';
|
|
10
|
-
import
|
|
3
|
+
import { ActionList, TextInput } from '@primer/react';
|
|
4
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
11
5
|
import { newUlid } from '../../../../utils';
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
6
|
+
import NbGraderType, { getNbGraderType } from './NbGraderCells';
|
|
7
|
+
/**
|
|
8
|
+
* Cell metadata editor component
|
|
9
|
+
*/
|
|
10
|
+
export function CellMetadataEditor(props) {
|
|
11
|
+
const { cellModel } = props;
|
|
12
|
+
const [cellGradeType, setCellGradeType] = useState(getNbGraderType(cellModel));
|
|
13
|
+
const [nbGrade, setNbGrade] = useState(cellModel.getMetadata('nbgrader') ?? { grade_id: newUlid(), points: 1 });
|
|
16
14
|
useEffect(() => {
|
|
17
15
|
setNbGrade({
|
|
18
16
|
grade_id: nbGrade.grade_id ?? newUlid(),
|
|
19
17
|
points: nbGrade.points ?? 1,
|
|
20
18
|
});
|
|
21
19
|
}, [nbGrade]);
|
|
22
|
-
const handleGradeIdChange = (
|
|
23
|
-
const nbgrader =
|
|
24
|
-
|
|
20
|
+
const handleGradeIdChange = useCallback((cellModel, gradeId) => {
|
|
21
|
+
const nbgrader = cellModel.getMetadata('nbgrader');
|
|
22
|
+
cellModel.setMetadata('nbgrader', {
|
|
25
23
|
...nbgrader,
|
|
26
24
|
grade_id: gradeId,
|
|
27
25
|
});
|
|
@@ -29,12 +27,12 @@ export const CellMetadataEditor = (props) => {
|
|
|
29
27
|
...nbGrade,
|
|
30
28
|
grade_id: gradeId,
|
|
31
29
|
});
|
|
32
|
-
};
|
|
33
|
-
const handlePointsChange = (
|
|
30
|
+
}, []);
|
|
31
|
+
const handlePointsChange = useCallback((cellModel, points) => {
|
|
34
32
|
const points_number = +points;
|
|
35
33
|
if (!isNaN(points_number)) {
|
|
36
|
-
const nbgrader =
|
|
37
|
-
|
|
34
|
+
const nbgrader = cellModel.getMetadata('nbgrader');
|
|
35
|
+
cellModel.setMetadata('nbgrader', {
|
|
38
36
|
...nbgrader,
|
|
39
37
|
points: points_number,
|
|
40
38
|
});
|
|
@@ -43,17 +41,17 @@ export const CellMetadataEditor = (props) => {
|
|
|
43
41
|
points: points_number,
|
|
44
42
|
});
|
|
45
43
|
}
|
|
46
|
-
};
|
|
47
|
-
const assignCellGradeType = (
|
|
44
|
+
}, []);
|
|
45
|
+
const assignCellGradeType = useCallback((cellModel, cellGradeType) => {
|
|
48
46
|
switch (cellGradeType) {
|
|
49
47
|
case NbGraderType.NotGraded: {
|
|
50
|
-
|
|
48
|
+
cellModel.deleteMetadata('nbgrader');
|
|
51
49
|
setCellGradeType(NbGraderType.NotGraded);
|
|
52
50
|
break;
|
|
53
51
|
}
|
|
54
52
|
case NbGraderType.AutogradedAnswer: {
|
|
55
|
-
const nbgrader =
|
|
56
|
-
|
|
53
|
+
const nbgrader = cellModel.getMetadata('nbgrader');
|
|
54
|
+
cellModel.setMetadata('nbgrader', {
|
|
57
55
|
...nbgrader,
|
|
58
56
|
grade: false,
|
|
59
57
|
solution: true,
|
|
@@ -66,8 +64,8 @@ export const CellMetadataEditor = (props) => {
|
|
|
66
64
|
break;
|
|
67
65
|
}
|
|
68
66
|
case NbGraderType.AutogradedTest: {
|
|
69
|
-
const nbgrader =
|
|
70
|
-
|
|
67
|
+
const nbgrader = cellModel.getMetadata('nbgrader');
|
|
68
|
+
cellModel.setMetadata('nbgrader', {
|
|
71
69
|
...nbgrader,
|
|
72
70
|
grade: true,
|
|
73
71
|
solution: false,
|
|
@@ -80,8 +78,8 @@ export const CellMetadataEditor = (props) => {
|
|
|
80
78
|
break;
|
|
81
79
|
}
|
|
82
80
|
case NbGraderType.ManuallyGradedAnswer: {
|
|
83
|
-
const nbgrader =
|
|
84
|
-
|
|
81
|
+
const nbgrader = cellModel.getMetadata('nbgrader');
|
|
82
|
+
cellModel.setMetadata('nbgrader', {
|
|
85
83
|
...nbgrader,
|
|
86
84
|
grade: true,
|
|
87
85
|
solution: true,
|
|
@@ -94,8 +92,8 @@ export const CellMetadataEditor = (props) => {
|
|
|
94
92
|
break;
|
|
95
93
|
}
|
|
96
94
|
case NbGraderType.ManuallyGradedTask: {
|
|
97
|
-
const nbgrader =
|
|
98
|
-
|
|
95
|
+
const nbgrader = cellModel.getMetadata('nbgrader');
|
|
96
|
+
cellModel.setMetadata('nbgrader', {
|
|
99
97
|
...nbgrader,
|
|
100
98
|
// "points": 1,
|
|
101
99
|
grade: false,
|
|
@@ -109,8 +107,8 @@ export const CellMetadataEditor = (props) => {
|
|
|
109
107
|
break;
|
|
110
108
|
}
|
|
111
109
|
case NbGraderType.ReadonlyGraded: {
|
|
112
|
-
const nbgrader =
|
|
113
|
-
|
|
110
|
+
const nbgrader = cellModel.getMetadata('nbgrader');
|
|
111
|
+
cellModel.setMetadata('nbgrader', {
|
|
114
112
|
...nbgrader,
|
|
115
113
|
grade: false,
|
|
116
114
|
solution: false,
|
|
@@ -121,14 +119,14 @@ export const CellMetadataEditor = (props) => {
|
|
|
121
119
|
break;
|
|
122
120
|
}
|
|
123
121
|
}
|
|
124
|
-
};
|
|
125
|
-
return (_jsxs(ActionList, { showDividers: true, children: [_jsx(ActionList.Divider, {}), _jsxs(ActionList.Group, { title: "NbGrader Cell Type", variant: "subtle", children: [_jsxs(ActionList.Item, { onSelect: e => assignCellGradeType(
|
|
122
|
+
}, []);
|
|
123
|
+
return (_jsxs(ActionList, { showDividers: true, children: [_jsx(ActionList.Divider, {}), _jsxs(ActionList.Group, { title: "NbGrader Cell Type", variant: "subtle", children: [_jsxs(ActionList.Item, { onSelect: e => assignCellGradeType(cellModel, NbGraderType.NotGraded), children: [cellGradeType === NbGraderType.NotGraded && (_jsx(ActionList.LeadingVisual, { children: _jsx(CheckIcon, {}) })), "None", _jsx(ActionList.Description, { variant: "block", children: "Not a grader cell." })] }), _jsxs(ActionList.Item, { onSelect: e => assignCellGradeType(cellModel, NbGraderType.AutogradedAnswer), children: [cellGradeType === NbGraderType.AutogradedAnswer && (_jsx(ActionList.LeadingVisual, { children: _jsx(CheckIcon, {}) })), "Autograded answer", _jsx(ActionList.Description, { variant: "block", children: "An autograded answer cell." })] }), _jsxs(ActionList.Item, { role: "listitem", onClick: e => assignCellGradeType(cellModel, NbGraderType.AutogradedTest), children: [cellGradeType === NbGraderType.AutogradedTest && (_jsx(ActionList.LeadingVisual, { children: _jsx(CheckIcon, {}) })), "Autograded test", _jsx(ActionList.Description, { variant: "block", children: "An autograded test cell." })] }), _jsxs(ActionList.Item, { onSelect: e => assignCellGradeType(cellModel, NbGraderType.ManuallyGradedTask), children: [cellGradeType === NbGraderType.ManuallyGradedTask && (_jsx(ActionList.LeadingVisual, { children: _jsx(CheckIcon, {}) })), "Manually graded task", _jsx(ActionList.Description, { variant: "block", children: "A manually graded task cell." })] }), _jsxs(ActionList.Item, { onSelect: e => assignCellGradeType(cellModel, NbGraderType.ManuallyGradedAnswer), children: [cellGradeType === NbGraderType.ManuallyGradedAnswer && (_jsx(ActionList.LeadingVisual, { children: _jsx(CheckIcon, {}) })), "Manually graded answer", _jsx(ActionList.Description, { variant: "block", children: "A manually graded answer cell." })] }), _jsxs(ActionList.Item, { onSelect: e => assignCellGradeType(cellModel, NbGraderType.ReadonlyGraded), children: [cellGradeType === NbGraderType.ReadonlyGraded && (_jsx(ActionList.LeadingVisual, { children: _jsx(CheckIcon, {}) })), "Readonly", _jsx(ActionList.Description, { variant: "block", children: "A readonly grader cell." })] })] }), cellGradeType !== NbGraderType.NotGraded && (_jsxs(ActionList.Group, { title: "NbGrader Metadata", variant: "subtle", children: [_jsxs(ActionList.Item, { onSelect: e => e.preventDefault(), children: ["Grade ID:", ' ', _jsx(TextInput, { block: true, value: nbGrade.grade_id, onChange: e => {
|
|
126
124
|
e.preventDefault();
|
|
127
|
-
handleGradeIdChange(
|
|
125
|
+
handleGradeIdChange(cellModel, e.target.value);
|
|
128
126
|
} })] }), _jsxs(ActionList.Item, { children: ["Points:", ' ', _jsx(TextInput, { block: true, value: nbGrade.points, onChange: e => {
|
|
129
127
|
e.preventDefault();
|
|
130
|
-
handlePointsChange(
|
|
128
|
+
handlePointsChange(cellModel, e.target.value);
|
|
131
129
|
} })] })] }))] }));
|
|
132
|
-
}
|
|
130
|
+
}
|
|
133
131
|
export default CellMetadataEditor;
|
|
134
132
|
//# sourceMappingURL=CellMetadataEditor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CellMetadataEditor.js","sourceRoot":"","sources":["../../../../../src/components/notebook/cell/metadata/CellMetadataEditor.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version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AAa,KAAK,YAAY,CAAC,SAAS,IAAI,CAC3C,MAAC,UAAU,CAAC,KAAK,IAAC,KAAK,EAAC,mBAAmB,EAAC,OAAO,EAAC,QAAQ,aAC1D,MAAC,UAAU,CAAC,IAAI,IAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,cAAc,EAAE,0BACtC,GAAG,EAEX,KAAC,SAAS,IACR,KAAK,QACL,KAAK,EAAE,OAAO,CAAC,QAAQ,EACvB,QAAQ,EAAE,CAAC,CAAC,EAAE;oCACZ,CAAC,CAAC,cAAc,EAAE,CAAC;oCACnB,mBAAmB,CAAC,SAAS,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gCACjD,CAAC,GACD,IAEY,EAClB,MAAC,UAAU,CAAC,IAAI,0BACN,GAAG,EAET,KAAC,SAAS,IACR,KAAK,QACL,KAAK,EAAE,OAAO,CAAC,MAAM,EACrB,QAAQ,EAAE,CAAC,CAAC,EAAE;oCACZ,CAAC,CAAC,cAAc,EAAE,CAAC;oCACnB,kBAAkB,CAAC,SAAS,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gCAChD,CAAC,GACD,IAEY,IACD,CACpB,IAQU,CACd,CAAC;AACJ,CAAC;AAED,eAAe,kBAAkB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ICellModel } from '@jupyterlab/cells';
|
|
2
2
|
export declare enum NbGraderType {
|
|
3
3
|
NotGraded = 0,
|
|
4
4
|
AutogradedAnswer = 1,
|
|
@@ -7,5 +7,5 @@ export declare enum NbGraderType {
|
|
|
7
7
|
ManuallyGradedAnswer = 4,
|
|
8
8
|
ReadonlyGraded = 5
|
|
9
9
|
}
|
|
10
|
-
export declare const getNbGraderType: (
|
|
10
|
+
export declare const getNbGraderType: (cellModel: ICellModel) => NbGraderType;
|
|
11
11
|
export default NbGraderType;
|
|
@@ -69,8 +69,8 @@ export var NbGraderType;
|
|
|
69
69
|
NbGraderType[NbGraderType["ManuallyGradedAnswer"] = 4] = "ManuallyGradedAnswer";
|
|
70
70
|
NbGraderType[NbGraderType["ReadonlyGraded"] = 5] = "ReadonlyGraded";
|
|
71
71
|
})(NbGraderType || (NbGraderType = {}));
|
|
72
|
-
export const getNbGraderType = (
|
|
73
|
-
const nbgrader =
|
|
72
|
+
export const getNbGraderType = (cellModel) => {
|
|
73
|
+
const nbgrader = cellModel.getMetadata('nbgrader');
|
|
74
74
|
if (!nbgrader) {
|
|
75
75
|
return NbGraderType.NotGraded;
|
|
76
76
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NbGraderCells.js","sourceRoot":"","sources":["../../../../../src/components/notebook/cell/metadata/NbGraderCells.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwDE;AACF,MAAM,CAAN,IAAY,YAOX;AAPD,WAAY,YAAY;IACtB,yDAAS,CAAA;IACT,uEAAgB,CAAA;IAChB,mEAAc,CAAA;IACd,2EAAkB,CAAA;IAClB,+EAAoB,CAAA;IACpB,mEAAc,CAAA;AAChB,CAAC,EAPW,YAAY,KAAZ,YAAY,QAOvB;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"NbGraderCells.js","sourceRoot":"","sources":["../../../../../src/components/notebook/cell/metadata/NbGraderCells.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwDE;AACF,MAAM,CAAN,IAAY,YAOX;AAPD,WAAY,YAAY;IACtB,yDAAS,CAAA;IACT,uEAAgB,CAAA;IAChB,mEAAc,CAAA;IACd,2EAAkB,CAAA;IAClB,+EAAoB,CAAA;IACpB,mEAAc,CAAA;AAChB,CAAC,EAPW,YAAY,KAA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|
3
|
+
import type { ICellModel } from '@jupyterlab/cells';
|
|
4
|
+
/**
|
|
5
|
+
* Cell sidebar class name.
|
|
6
|
+
*/
|
|
7
|
+
export declare const DATALAYER_CELL_SIDEBAR_CLASS_NAME = "dla-CellSidebar-Container";
|
|
8
|
+
/**
|
|
9
|
+
* Cell sidebar properties
|
|
10
|
+
*/
|
|
11
|
+
export type ICellSidebarProps = {
|
|
12
|
+
/**
|
|
13
|
+
* Notebook command registry
|
|
14
|
+
*/
|
|
15
|
+
commands: CommandRegistry;
|
|
16
|
+
/**
|
|
17
|
+
* Cell model
|
|
18
|
+
*/
|
|
19
|
+
model: ICellModel;
|
|
20
|
+
/**
|
|
21
|
+
* Whether to display nbgrader features or not.
|
|
22
|
+
*/
|
|
23
|
+
nbgrader: boolean;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Cell sidebar component
|
|
27
|
+
*/
|
|
28
|
+
export declare function CellSidebar(props: ICellSidebarProps): JSX.Element;
|
|
3
29
|
export default CellSidebar;
|
|
@@ -1,84 +1,70 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* MIT License
|
|
6
|
-
*/
|
|
7
|
-
import { useState } from 'react';
|
|
8
|
-
import { ActionMenu, Button, Box } from '@primer/react';
|
|
9
|
-
import { ChevronRightIcon, XIcon, ChevronUpIcon, ChevronDownIcon, SquareIcon } from '@primer/octicons-react';
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ChevronDownIcon, ChevronRightIcon, ChevronUpIcon, SquareIcon, XIcon, } from '@primer/octicons-react';
|
|
3
|
+
import { ActionMenu, Box, Button } from '@primer/react';
|
|
4
|
+
import { NotebookCommandIds } from '../../NotebookCommands';
|
|
10
5
|
import CellMetadataEditor from '../metadata/CellMetadataEditor';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (cellWidget?.node.id === cellNodeId) {
|
|
22
|
-
if (!visible) {
|
|
23
|
-
setVisible(true);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
if (cellWidget?.node.id !== cellNodeId) {
|
|
27
|
-
if (visible) {
|
|
28
|
-
setVisible(false);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
if (!visible) {
|
|
33
|
-
return _jsx("div", {});
|
|
34
|
-
}
|
|
35
|
-
return activeCell ? (_jsxs(Box, { className: DATALAYER_CELL_SIDEBAR_CLASS_NAME, sx: {
|
|
6
|
+
/**
|
|
7
|
+
* Cell sidebar class name.
|
|
8
|
+
*/
|
|
9
|
+
export const DATALAYER_CELL_SIDEBAR_CLASS_NAME = 'dla-CellSidebar-Container';
|
|
10
|
+
/**
|
|
11
|
+
* Cell sidebar component
|
|
12
|
+
*/
|
|
13
|
+
export function CellSidebar(props) {
|
|
14
|
+
const { commands, model, nbgrader } = props;
|
|
15
|
+
return (_jsxs(Box, { className: DATALAYER_CELL_SIDEBAR_CLASS_NAME, sx: {
|
|
36
16
|
'& p': {
|
|
37
17
|
marginBottom: '0 !important',
|
|
38
18
|
},
|
|
39
|
-
}, children: [nbgrader && (_jsx(ActionMenu, { children: _jsx(CellMetadataEditor, {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
}
|
|
19
|
+
}, children: [nbgrader && (_jsx(ActionMenu, { children: _jsx(CellMetadataEditor, { cellModel: model }) })), _jsx(Button, { title: "Run cell", leadingVisual: ChevronRightIcon, variant: "invisible", size: "small", onClick: (e) => {
|
|
20
|
+
e.preventDefault();
|
|
21
|
+
commands.execute(NotebookCommandIds.run).catch(reason => {
|
|
22
|
+
console.error('Failed to run cell.', reason);
|
|
23
|
+
});
|
|
24
|
+
}, children: "Run" }), _jsx(Button, { title: "Insert code cell above", leadingVisual: ChevronUpIcon, variant: "invisible", size: "small", onClick: (e) => {
|
|
25
|
+
e.preventDefault();
|
|
26
|
+
commands.execute(NotebookCommandIds.insertAbove).catch(reason => {
|
|
27
|
+
console.error('Failed to insert code cell above.', reason);
|
|
28
|
+
});
|
|
29
|
+
}, children: "Code" }), _jsx(Button, { title: "Insert markdown cell above", leadingVisual: ChevronUpIcon, variant: "invisible", size: "small", onClick: (e) => {
|
|
30
|
+
e.preventDefault();
|
|
31
|
+
commands
|
|
32
|
+
.execute(NotebookCommandIds.insertAbove, { cellType: 'markdown' })
|
|
33
|
+
.catch(reason => {
|
|
34
|
+
console.error('Failed to insert markdown cell above.', reason);
|
|
35
|
+
});
|
|
36
|
+
}, children: "Markdown" }), model.type === 'code' ? (_jsx(Button, { title: "Convert to markdow cell", leadingVisual: SquareIcon, variant: "invisible", size: "small", onClick: (e) => {
|
|
37
|
+
e.preventDefault();
|
|
38
|
+
commands
|
|
39
|
+
.execute(NotebookCommandIds.changeCellTypeToMarkdown)
|
|
40
|
+
.catch(reason => {
|
|
41
|
+
console.error('Failed to change cell type to markdown.', reason);
|
|
42
|
+
});
|
|
43
|
+
}, children: "To Markdown" })) : (_jsx(Button, { title: "Convert to code cell", leadingVisual: SquareIcon, variant: "invisible", size: "small", onClick: (e) => {
|
|
44
|
+
e.preventDefault();
|
|
45
|
+
commands
|
|
46
|
+
.execute(NotebookCommandIds.changeCellTypeToCode)
|
|
47
|
+
.catch(reason => {
|
|
48
|
+
console.error('Failed to change cell type to code.', reason);
|
|
49
|
+
});
|
|
50
|
+
}, children: "To Code" })), _jsx(Button, { title: "Insert markdown cell below", leadingVisual: ChevronDownIcon, variant: "invisible", size: "small", onClick: (e) => {
|
|
51
|
+
e.preventDefault();
|
|
52
|
+
commands
|
|
53
|
+
.execute(NotebookCommandIds.insertBelow, { cellType: 'markdown' })
|
|
54
|
+
.catch(reason => {
|
|
55
|
+
console.error('Failed to insert markdown cell below.', reason);
|
|
56
|
+
});
|
|
57
|
+
}, children: "Markdown" }), _jsx(Button, { title: "Insert code cell below", leadingVisual: ChevronDownIcon, variant: "invisible", size: "small", onClick: (e) => {
|
|
58
|
+
e.preventDefault();
|
|
59
|
+
commands.execute(NotebookCommandIds.insertBelow).catch(reason => {
|
|
60
|
+
console.error('Failed to insert code cell below.', reason);
|
|
61
|
+
});
|
|
62
|
+
}, children: "Code" }), _jsx(Button, { title: "Delete cell", leadingVisual: XIcon, variant: "invisible", size: "small", onClick: (e) => {
|
|
63
|
+
e.preventDefault();
|
|
64
|
+
commands.execute(NotebookCommandIds.deleteCells).catch(reason => {
|
|
65
|
+
console.error('Failed to delete cells.', reason);
|
|
66
|
+
});
|
|
67
|
+
}, children: "Delete" })] }));
|
|
68
|
+
}
|
|
83
69
|
export default CellSidebar;
|
|
84
70
|
//# sourceMappingURL=CellSidebar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CellSidebar.js","sourceRoot":"","sources":["../../../../../src/components/notebook/cell/sidebar/CellSidebar.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"CellSidebar.js","sourceRoot":"","sources":["../../../../../src/components/notebook/cell/sidebar/CellSidebar.tsx"],"names":[],"mappings":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KAAK,EACpB,OAAO,EAAC,WAAW,EACnB,IAAI,EAAC,OAAO,EACZ,OAAO,EAAE,CAAC,CAAM,EAAE,EAAE;oBAClB,CAAC,CAAC,cAAc,EAAE,CAAC;oBACnB,QAAQ,CAAC,OAAO,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE;wBAC9D,OAAO,CAAC,KAAK,CAAC,yBAAyB,EAAE,MAAM,CAAC,CAAC;oBACnD,CAAC,CAAC,CAAC;gBACL,CAAC,uBAGM,IACL,CACP,CAAC;AACJ,CAAC;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ICellSidebarProps } from './CellSidebar';
|
|
3
|
+
export declare function CellSidebarButton(props: ICellSidebarProps): JSX.Element;
|
|
3
4
|
export default CellSidebarButton;
|
|
@@ -1,83 +1,68 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
/*
|
|
3
3
|
* Copyright (c) 2021-2023 Datalayer, Inc.
|
|
4
4
|
*
|
|
5
5
|
* MIT License
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
7
|
+
import { ChevronDownIcon, ChevronUpIcon, PlayIcon, SquareIcon, XIcon, } from '@primer/octicons-react';
|
|
8
8
|
import { Box, IconButton } from '@primer/react';
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const notebookStore = useNotebookStore();
|
|
15
|
-
const [visible, setVisible] = useState(false);
|
|
16
|
-
const activeCell = notebookStore.selectActiveCell(notebookId);
|
|
17
|
-
const layout = activeCell?.layout;
|
|
18
|
-
if (layout) {
|
|
19
|
-
const cellWidget = layout.widgets[0];
|
|
20
|
-
if (cellWidget?.node.id === cellNodeId) {
|
|
21
|
-
if (!visible) {
|
|
22
|
-
setVisible(true);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
if (cellWidget?.node.id !== cellNodeId) {
|
|
26
|
-
if (visible) {
|
|
27
|
-
setVisible(false);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
if (!visible) {
|
|
32
|
-
return _jsx(_Fragment, {});
|
|
33
|
-
}
|
|
34
|
-
return activeCell ? (_jsxs(Box, { className: DATALAYER_CELL_SIDEBAR_CLASS_NAME, sx: {
|
|
9
|
+
import { NotebookCommandIds } from '../../NotebookCommands';
|
|
10
|
+
import { DATALAYER_CELL_SIDEBAR_CLASS_NAME, } from './CellSidebar';
|
|
11
|
+
export function CellSidebarButton(props) {
|
|
12
|
+
const { commands, model } = props;
|
|
13
|
+
return (_jsxs(Box, { className: DATALAYER_CELL_SIDEBAR_CLASS_NAME, sx: {
|
|
35
14
|
'& p': {
|
|
36
15
|
marginBottom: '0 !important',
|
|
37
16
|
},
|
|
38
|
-
}, children: [_jsx(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
}
|
|
17
|
+
}, children: [_jsx(IconButton, { size: "small", color: "secondary", "aria-label": "Run cell", title: "Run cell", onClick: e => {
|
|
18
|
+
e.preventDefault();
|
|
19
|
+
commands.execute(NotebookCommandIds.run).catch(reason => {
|
|
20
|
+
console.error('Failed to run cell.', reason);
|
|
21
|
+
});
|
|
22
|
+
}, icon: PlayIcon, variant: "invisible" }), _jsx(IconButton, { size: "small", color: "secondary", "aria-label": "Add code cell above", title: "Add code cell above", onClick: e => {
|
|
23
|
+
e.preventDefault();
|
|
24
|
+
commands.execute(NotebookCommandIds.insertAbove).catch(reason => {
|
|
25
|
+
console.error('Failed to insert code cell above.', reason);
|
|
26
|
+
});
|
|
27
|
+
}, icon: ChevronUpIcon, variant: "invisible" }), _jsx(IconButton, { size: "small", color: "secondary", "aria-label": "Add markdown cell above", title: "Add markdown cell above", onClick: e => {
|
|
28
|
+
e.preventDefault();
|
|
29
|
+
commands
|
|
30
|
+
.execute(NotebookCommandIds.insertAbove, { cellType: 'markdown' })
|
|
31
|
+
.catch(reason => {
|
|
32
|
+
console.error('Failed to insert markdown cell above.', reason);
|
|
33
|
+
});
|
|
34
|
+
}, icon: ChevronUpIcon, variant: "invisible" }), model.type === 'code' ? (_jsx(IconButton, { "aria-label": "Convert to markdow cell", title: "Convert to markdow cell", icon: SquareIcon, size: "small", variant: "invisible", onClick: e => {
|
|
35
|
+
e.preventDefault();
|
|
36
|
+
commands
|
|
37
|
+
.execute(NotebookCommandIds.changeCellTypeToMarkdown)
|
|
38
|
+
.catch(reason => {
|
|
39
|
+
console.error('Failed to change cell type to markdown.', reason);
|
|
40
|
+
});
|
|
41
|
+
} })) : (_jsx(IconButton, { "aria-label": "Convert to code cell", title: "Convert to code cell", icon: SquareIcon, variant: "invisible", size: "small", onClick: (e) => {
|
|
42
|
+
e.preventDefault();
|
|
43
|
+
commands
|
|
44
|
+
.execute(NotebookCommandIds.changeCellTypeToCode)
|
|
45
|
+
.catch(reason => {
|
|
46
|
+
console.error('Failed to change cell type to code.', reason);
|
|
47
|
+
});
|
|
48
|
+
} })), _jsx(IconButton, { size: "small", color: "secondary", "aria-label": "Add markdown cell below", title: "Add markdown cell below", onClick: e => {
|
|
49
|
+
e.preventDefault();
|
|
50
|
+
commands
|
|
51
|
+
.execute(NotebookCommandIds.insertBelow, { cellType: 'markdown' })
|
|
52
|
+
.catch(reason => {
|
|
53
|
+
console.error('Failed to insert markdown cell below.', reason);
|
|
54
|
+
});
|
|
55
|
+
}, icon: ChevronDownIcon, variant: "invisible" }), _jsx(IconButton, { size: "small", color: "secondary", "aria-label": "Add code cell above", title: "Add code cell above", onClick: e => {
|
|
56
|
+
e.preventDefault();
|
|
57
|
+
commands.execute(NotebookCommandIds.insertBelow).catch(reason => {
|
|
58
|
+
console.error('Failed to insert code cell below.', reason);
|
|
59
|
+
});
|
|
60
|
+
}, icon: ChevronDownIcon, variant: "invisible" }), _jsx(IconButton, { size: "small", color: "error", "aria-label": "Delete cell", title: "Delete cell", onClick: e => {
|
|
61
|
+
e.preventDefault();
|
|
62
|
+
commands.execute(NotebookCommandIds.deleteCells).catch(reason => {
|
|
63
|
+
console.error('Failed to delete cells.', reason);
|
|
64
|
+
});
|
|
65
|
+
}, icon: XIcon, variant: "invisible" })] }));
|
|
66
|
+
}
|
|
82
67
|
export default CellSidebarButton;
|
|
83
68
|
//# sourceMappingURL=CellSidebarButton.js.map
|