|
7 | 7 | FONT_FACES,
|
8 | 8 | FONT_SIZES,
|
9 | 9 | } from "@cocalc/frontend/editors/editor-button-bar";
|
| 10 | +import { menu } from "@cocalc/frontend/i18n"; |
10 | 11 | import { addEditorMenus } from "./editor-menus";
|
11 | 12 |
|
12 | 13 | const FORMAT_SPEC = {
|
@@ -118,128 +119,132 @@ const FORMAT_SPEC = {
|
118 | 119 |
|
119 | 120 | const FORMAT_MENUS = {
|
120 | 121 | insert: {
|
121 |
| - label: "Insert", |
| 122 | + label: menu.insert, |
122 | 123 | pos: 1.3,
|
123 |
| - math: ["equation", "display_equation", "ai_formula"], |
124 |
| - lists: ["insertunorderedlist", "insertorderedlist"], |
125 |
| - objects: [ |
126 |
| - "table", |
127 |
| - "link", |
128 |
| - "quote", |
129 |
| - "image", |
130 |
| - "horizontalRule", |
131 |
| - "format_code", |
132 |
| - "SpecialChar", |
133 |
| - ], |
| 124 | + entries: { |
| 125 | + math: ["equation", "display_equation", "ai_formula"], |
| 126 | + lists: ["insertunorderedlist", "insertorderedlist"], |
| 127 | + objects: [ |
| 128 | + "table", |
| 129 | + "link", |
| 130 | + "quote", |
| 131 | + "image", |
| 132 | + "horizontalRule", |
| 133 | + "format_code", |
| 134 | + "SpecialChar", |
| 135 | + ], |
| 136 | + }, |
134 | 137 | },
|
135 | 138 | format: {
|
136 |
| - label: "Format", |
| 139 | + label: menu.format, |
137 | 140 | pos: 1.5,
|
138 |
| - font_text: [ |
139 |
| - { |
140 |
| - icon: "bold", |
141 |
| - isVisible: "format_action", |
142 |
| - name: "font", |
143 |
| - label: "Font", |
144 |
| - children: [ |
145 |
| - "bold", |
146 |
| - "italic", |
147 |
| - "underline", |
148 |
| - "strikethrough", |
149 |
| - "code", |
150 |
| - "sub", |
151 |
| - "sup", |
152 |
| - ], |
153 |
| - }, |
154 |
| - { |
155 |
| - icon: "text-height", |
156 |
| - isVisible: "format_action", // todo |
157 |
| - name: "font-size", |
158 |
| - label: "Size", |
159 |
| - children: FONT_SIZES.map((size) => { |
160 |
| - return { |
161 |
| - name: `${size}`, |
162 |
| - onClick: ({ props }) => |
163 |
| - props.actions.format_action("font_size_new", size), |
164 |
| - label: ( |
165 |
| - <span style={{ fontSize: size }}> |
166 |
| - {size} {size === "medium" ? "(default)" : undefined} |
167 |
| - </span> |
168 |
| - ), |
169 |
| - icon: <span style={{ fontSize: size }}>A</span>, |
170 |
| - }; |
171 |
| - }), |
172 |
| - }, |
173 |
| - { |
174 |
| - icon: "font", |
175 |
| - isVisible: "format_action", // todo |
176 |
| - name: "font-family", |
177 |
| - label: "Family", |
178 |
| - children: FONT_FACES.map((family) => { |
179 |
| - return { |
180 |
| - name: family, |
181 |
| - onClick: ({ props }) => |
182 |
| - props.actions.format_action("font_family", family), |
183 |
| - label: <span style={{ fontFamily: family }}>{family}</span>, |
184 |
| - icon: <span style={{ fontFamily: family }}>A</span>, |
185 |
| - }; |
186 |
| - }), |
187 |
| - }, |
188 |
| - { |
189 |
| - icon: "header", |
190 |
| - isVisible: "format_action", // todo |
191 |
| - name: "header", |
192 |
| - label: "Heading", |
193 |
| - children: range(1, 7).map((heading) => { |
194 |
| - return { |
195 |
| - name: `heading-${heading}`, |
196 |
| - onClick: ({ props }) => |
197 |
| - props.actions.format_action(`format_heading_${heading}`), |
198 |
| - label: <HeadingContent heading={heading} />, |
199 |
| - }; |
200 |
| - }), |
201 |
| - }, |
202 |
| - { |
203 |
| - icon: "colors", |
204 |
| - isVisible: "format_action", |
205 |
| - name: "color", |
206 |
| - label: "Color", |
207 |
| - children: [ |
208 |
| - { |
209 |
| - stayOpenOnClick: true, |
210 |
| - label: ({ props }) => ( |
211 |
| - <div |
212 |
| - onClick={(e) => { |
213 |
| - // hack so can select a color without picker closing. |
214 |
| - e.stopPropagation(); |
215 |
| - }} |
216 |
| - > |
217 |
| - <ColorPicker |
218 |
| - radio |
219 |
| - onChange={(code) => { |
220 |
| - props.actions.format_action("color", code); |
| 141 | + entries: { |
| 142 | + font_text: [ |
| 143 | + { |
| 144 | + icon: "bold", |
| 145 | + isVisible: "format_action", |
| 146 | + name: "font", |
| 147 | + label: "Font", |
| 148 | + children: [ |
| 149 | + "bold", |
| 150 | + "italic", |
| 151 | + "underline", |
| 152 | + "strikethrough", |
| 153 | + "code", |
| 154 | + "sub", |
| 155 | + "sup", |
| 156 | + ], |
| 157 | + }, |
| 158 | + { |
| 159 | + icon: "text-height", |
| 160 | + isVisible: "format_action", // todo |
| 161 | + name: "font-size", |
| 162 | + label: "Size", |
| 163 | + children: FONT_SIZES.map((size) => { |
| 164 | + return { |
| 165 | + name: `${size}`, |
| 166 | + onClick: ({ props }) => |
| 167 | + props.actions.format_action("font_size_new", size), |
| 168 | + label: ( |
| 169 | + <span style={{ fontSize: size }}> |
| 170 | + {size} {size === "medium" ? "(default)" : undefined} |
| 171 | + </span> |
| 172 | + ), |
| 173 | + icon: <span style={{ fontSize: size }}>A</span>, |
| 174 | + }; |
| 175 | + }), |
| 176 | + }, |
| 177 | + { |
| 178 | + icon: "font", |
| 179 | + isVisible: "format_action", // todo |
| 180 | + name: "font-family", |
| 181 | + label: "Family", |
| 182 | + children: FONT_FACES.map((family) => { |
| 183 | + return { |
| 184 | + name: family, |
| 185 | + onClick: ({ props }) => |
| 186 | + props.actions.format_action("font_family", family), |
| 187 | + label: <span style={{ fontFamily: family }}>{family}</span>, |
| 188 | + icon: <span style={{ fontFamily: family }}>A</span>, |
| 189 | + }; |
| 190 | + }), |
| 191 | + }, |
| 192 | + { |
| 193 | + icon: "header", |
| 194 | + isVisible: "format_action", // todo |
| 195 | + name: "header", |
| 196 | + label: "Heading", |
| 197 | + children: range(1, 7).map((heading) => { |
| 198 | + return { |
| 199 | + name: `heading-${heading}`, |
| 200 | + onClick: ({ props }) => |
| 201 | + props.actions.format_action(`format_heading_${heading}`), |
| 202 | + label: <HeadingContent heading={heading} />, |
| 203 | + }; |
| 204 | + }), |
| 205 | + }, |
| 206 | + { |
| 207 | + icon: "colors", |
| 208 | + isVisible: "format_action", |
| 209 | + name: "color", |
| 210 | + label: "Color", |
| 211 | + children: [ |
| 212 | + { |
| 213 | + stayOpenOnClick: true, |
| 214 | + label: ({ props }) => ( |
| 215 | + <div |
| 216 | + onClick={(e) => { |
| 217 | + // hack so can select a color without picker closing. |
| 218 | + e.stopPropagation(); |
221 | 219 | }}
|
222 |
| - /> |
223 |
| - </div> |
224 |
| - ), |
225 |
| - }, |
226 |
| - ], |
227 |
| - }, |
228 |
| - { |
229 |
| - icon: "text", |
230 |
| - isVisible: "format_action", |
231 |
| - name: "text", |
232 |
| - label: "Text", |
233 |
| - children: [ |
234 |
| - "justifyleft", |
235 |
| - "justifycenter", |
236 |
| - "justifyright", |
237 |
| - "justifyfull", |
238 |
| - ], |
239 |
| - }, |
240 |
| - "comment", |
241 |
| - "unformat", |
242 |
| - ], |
| 220 | + > |
| 221 | + <ColorPicker |
| 222 | + radio |
| 223 | + onChange={(code) => { |
| 224 | + props.actions.format_action("color", code); |
| 225 | + }} |
| 226 | + /> |
| 227 | + </div> |
| 228 | + ), |
| 229 | + }, |
| 230 | + ], |
| 231 | + }, |
| 232 | + { |
| 233 | + icon: "text", |
| 234 | + isVisible: "format_action", |
| 235 | + name: "text", |
| 236 | + label: "Text", |
| 237 | + children: [ |
| 238 | + "justifyleft", |
| 239 | + "justifycenter", |
| 240 | + "justifyright", |
| 241 | + "justifyfull", |
| 242 | + ], |
| 243 | + }, |
| 244 | + "comment", |
| 245 | + "unformat", |
| 246 | + ], |
| 247 | + }, |
243 | 248 | },
|
244 | 249 | };
|
245 | 250 |
|
|
0 commit comments