@@ -11,6 +11,7 @@ import { useIntl } from "react-intl";
11
11
import { alert_message } from "@cocalc/frontend/alerts" ;
12
12
import { Icon } from "@cocalc/frontend/components" ;
13
13
import { jupyter , labels } from "@cocalc/frontend/i18n" ;
14
+ import { commands } from "./commands" ;
14
15
import {
15
16
CODE_BAR_BTN_STYLE ,
16
17
COPY_CELL_ICON ,
@@ -21,6 +22,27 @@ import {
21
22
export function CodeBarDropdownMenu ( { actions, frameActions, id, cell } ) {
22
23
const intl = useIntl ( ) ;
23
24
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
+
24
46
function cut_cell ( ) : void {
25
47
if ( id == null ) return ;
26
48
frameActions . current ?. unselect_all_cells ( ) ;
@@ -113,6 +135,55 @@ export function CodeBarDropdownMenu({ actions, frameActions, id, cell }) {
113
135
} ,
114
136
] ,
115
137
} ,
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
+ } ,
116
187
{ key : "divider4" , type : "divider" } ,
117
188
{
118
189
key : "copy-cell" ,
0 commit comments