CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/next/components/account/config/editor/jupyter.tsx
Views: 687
1
import register from "../register";
2
import { Space } from "antd";
3
import Loading from "components/share/loading";
4
import A from "components/misc/A";
5
import useEditTable from "lib/hooks/edit-table";
6
import { JUPYTER_CLASSIC_MODERN } from "@cocalc/util/theme";
7
8
const desc = {
9
jupyter_line_numbers: `Display line numbers to the left of input cells in Jupyter notebooks.`,
10
ask_jupyter_kernel: `Each time you create a new Jupyter notebook, by default it will ask which kernel to use.
11
If you disable this option, then new notebooks will open using the kernel that you most recently explicitly
12
selected. You can of course change the kernel of any notebook at any time in the Kernel dropdown menu.`,
13
disable_jupyter_virtualization: `By default Jupyter notebooks are rendered using "virtualization" or "windowing", so only the visible cells are actually rendered. If you select this option, then we instead render entire notebook. This is potentially much slower but may address some subtle issues. You must close and open your notebook to see the change.`,
14
jupyter_classic: `CoCalc includes a mode where it embeds
15
the classical Jupyter notebook in an iframe and installs a plugin to enable realtime collaboration.
16
However, collaboration does not work as well as in the default Jupyter editor.`,
17
};
18
19
interface Data {
20
editor_settings: {
21
ask_jupyter_kernel?: boolean;
22
jupyter_line_numbers?: boolean;
23
disable_jupyter_virtualization?: boolean;
24
jupyter_classic?: boolean;
25
};
26
}
27
28
register({
29
path: "editor/jupyter",
30
title: "Jupyter Notebooks",
31
icon: "ipynb",
32
desc: "Configuration options specific to Jupyter notebooks, e.g., line numbers for input cells or asking for the kernel for new notebooks.",
33
search: desc,
34
Component: () => {
35
const { edited, original, Save, EditBoolean } = useEditTable<Data>({
36
accounts: { editor_settings: null },
37
});
38
39
if (original == null || edited == null) {
40
return <Loading />;
41
}
42
43
return (
44
<Space direction="vertical" size="large">
45
<Save />
46
<EditBoolean
47
icon="list-ol"
48
path="editor_settings.jupyter_line_numbers"
49
title="Line Numbers"
50
desc={desc.jupyter_line_numbers}
51
label="Line numbers"
52
/>
53
<EditBoolean
54
icon="question-circle"
55
path="editor_settings.ask_jupyter_kernel"
56
title="New Notebook Kernel"
57
desc={desc.ask_jupyter_kernel}
58
label="Ask which kernel to use"
59
/>
60
<EditBoolean
61
icon="list"
62
path="editor_settings.disable_jupyter_virtualization"
63
title="Disable Jupyter Virtualization"
64
desc={desc.disable_jupyter_virtualization}
65
label={
66
<>
67
No virtualization -- render entire notebook rather than rendering
68
just the visible part of it using{" "}
69
<A href="https://virtuoso.dev/">react-virtuoso</A>.
70
</>
71
}
72
/>
73
<EditBoolean
74
icon="ipynb"
75
path="editor_settings.jupyter_classic"
76
title="Jupyter Classic"
77
desc={
78
<>
79
{desc.jupyter_classic}{" "}
80
<A href={JUPYTER_CLASSIC_MODERN}>
81
(DANGER: this can cause trouble...)
82
</A>{" "}
83
You can also{" "}
84
<A href="https://doc.cocalc.com/jupyter.html#alternatives-plain-jupyter-server-and-jupyterlab-server">
85
very easily use a standard JupyterLab or Jupyter classic server
86
</A>{" "}
87
from any CoCalc project, without changing this setting.
88
</>
89
}
90
label="Use Jupyter classic"
91
/>
92
</Space>
93
);
94
},
95
});
96
97