Skip to content

Commit 2f3f0ae

Browse files
authored
Merge pull request #8557 from sagemathinc/jupyter-cell-menu-cell-toolbar-8554
frontend/jupyter: add "Cell Toolbar" to cell toolbar dropdown "..."
2 parents a4d801d + c553a2e commit 2f3f0ae

File tree

2 files changed

+71
-9
lines changed

2 files changed

+71
-9
lines changed

src/packages/frontend/cspell.json

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,9 @@
6060
"ignoreWords": [
6161
"antd",
6262
"buttonbar",
63-
"buttonbar",
6463
"collab",
6564
"descr",
6665
"flyoutdragbar",
67-
"flyoutdragbar",
68-
"flyouts",
6966
"flyouts",
7067
"immutablejs",
7168
"ipynb",
@@ -79,22 +76,16 @@
7976
"mintime",
8077
"mistralai",
8178
"noconf",
82-
"noconf",
8379
"nprocs",
84-
"nprocs",
85-
"pchildren",
8680
"pchildren",
8781
"pids",
88-
"pids",
8982
"Popconfirm",
9083
"PoweroffOutlined",
9184
"ptree",
92-
"ptree",
9385
"reuseinflight",
9486
"sidechat",
9587
"vertexai",
9688
"vfill",
97-
"xsmall",
9889
"xsmall"
9990
],
10091
"flagWords": [],

src/packages/frontend/jupyter/cell-buttonbar-menu.tsx

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { useIntl } from "react-intl";
1111
import { alert_message } from "@cocalc/frontend/alerts";
1212
import { Icon } from "@cocalc/frontend/components";
1313
import { jupyter, labels } from "@cocalc/frontend/i18n";
14+
import { commands } from "./commands";
1415
import {
1516
CODE_BAR_BTN_STYLE,
1617
COPY_CELL_ICON,
@@ -21,6 +22,27 @@ import {
2122
export function CodeBarDropdownMenu({ actions, frameActions, id, cell }) {
2223
const intl = useIntl();
2324

25+
// All jupyter commands
26+
const allCommands = commands({
27+
jupyter_actions: actions,
28+
frame_actions: frameActions,
29+
});
30+
31+
// Extract the cell toolbar command definitions
32+
const toolbarNone = allCommands["cell toolbar none"];
33+
const toolbarAssignment = allCommands["cell toolbar create_assignment"];
34+
const toolbarSlideshow = allCommands["cell toolbar slideshow"];
35+
const toolbarMetadata = allCommands["cell toolbar metadata"];
36+
const toolbarAttachments = allCommands["cell toolbar attachments"];
37+
const toolbarTags = allCommands["cell toolbar tags"];
38+
const toolbarIds = allCommands["cell toolbar ids"];
39+
40+
// Helper to format labels safely
41+
const formatLabel = (cmd) => {
42+
const message = cmd.menu || cmd.m;
43+
return typeof message === "string" ? message : intl.formatMessage(message);
44+
};
45+
2446
function cut_cell(): void {
2547
if (id == null) return;
2648
frameActions.current?.unselect_all_cells();
@@ -113,6 +135,55 @@ export function CodeBarDropdownMenu({ actions, frameActions, id, cell }) {
113135
},
114136
],
115137
},
138+
{
139+
key: "cell-toolbar",
140+
label: intl.formatMessage(jupyter.commands.view_toolbars_menu),
141+
icon: <Icon name="tool" />,
142+
children: [
143+
{
144+
key: "cell-toolbar-none",
145+
label: formatLabel(toolbarNone),
146+
icon: <Icon name={toolbarNone.i} />,
147+
onClick: toolbarNone.f,
148+
},
149+
{
150+
key: "cell-toolbar-create-assignment",
151+
label: formatLabel(toolbarAssignment),
152+
icon: <Icon name={toolbarAssignment.i} />,
153+
onClick: toolbarAssignment.f,
154+
},
155+
{
156+
key: "cell-toolbar-slideshow",
157+
label: formatLabel(toolbarSlideshow),
158+
icon: <Icon name={toolbarSlideshow.i} />,
159+
onClick: toolbarSlideshow.f,
160+
},
161+
{
162+
key: "cell-toolbar-metadata",
163+
label: formatLabel(toolbarMetadata),
164+
icon: <Icon name={toolbarMetadata.i} />,
165+
onClick: toolbarMetadata.f,
166+
},
167+
{
168+
key: "cell-toolbar-attachments",
169+
label: formatLabel(toolbarAttachments),
170+
icon: <Icon name={toolbarAttachments.i} />,
171+
onClick: toolbarAttachments.f,
172+
},
173+
{
174+
key: "cell-toolbar-tags",
175+
label: formatLabel(toolbarTags),
176+
icon: <Icon name={toolbarTags.i} />,
177+
onClick: toolbarTags.f,
178+
},
179+
{
180+
key: "cell-toolbar-ids",
181+
label: formatLabel(toolbarIds),
182+
icon: <Icon name={toolbarIds.i} />,
183+
onClick: toolbarIds.f,
184+
},
185+
],
186+
},
116187
{ key: "divider4", type: "divider" },
117188
{
118189
key: "copy-cell",

0 commit comments

Comments
 (0)