@manuscripts/body-editor 1.6.10 → 1.6.12

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.
Files changed (95) hide show
  1. package/dist/cjs/commands.js +57 -1
  2. package/dist/cjs/components/toolbar/LevelSelector.js +2 -2
  3. package/dist/cjs/index.js +4 -9
  4. package/dist/cjs/keys/list.js +9 -9
  5. package/dist/cjs/lib/context-menu.js +81 -163
  6. package/dist/cjs/menus.js +353 -405
  7. package/dist/cjs/toolbar.js +30 -34
  8. package/dist/cjs/views/editable_block.js +12 -4
  9. package/dist/es/commands.js +57 -2
  10. package/dist/es/components/toolbar/LevelSelector.js +2 -2
  11. package/dist/es/index.js +2 -4
  12. package/dist/es/keys/list.js +7 -7
  13. package/dist/es/lib/context-menu.js +81 -163
  14. package/dist/es/menus.js +353 -405
  15. package/dist/es/toolbar.js +31 -35
  16. package/dist/es/views/editable_block.js +13 -5
  17. package/dist/types/commands.d.ts +1 -0
  18. package/dist/types/components/toolbar/LevelSelector.d.ts +2 -2
  19. package/dist/types/configs/editor-views.d.ts +14 -14
  20. package/dist/types/index.d.ts +2 -4
  21. package/dist/types/keys/list.d.ts +1 -1
  22. package/dist/types/lib/context-menu.d.ts +0 -7
  23. package/dist/types/menus.d.ts +2 -3
  24. package/dist/types/toolbar.d.ts +18 -1
  25. package/dist/types/views/bibliography_element_editable.d.ts +1 -1
  26. package/dist/types/views/blockquote_element_editable.d.ts +1 -1
  27. package/dist/types/views/bullet_list_editable.d.ts +1 -1
  28. package/dist/types/views/editable_block.d.ts +1 -1
  29. package/dist/types/views/equation_element_editable.d.ts +1 -1
  30. package/dist/types/views/figure_element_editable.d.ts +1 -1
  31. package/dist/types/views/footnote_editable.d.ts +1 -1
  32. package/dist/types/views/footnotes_element_editable.d.ts +1 -1
  33. package/dist/types/views/listing_element_editable.d.ts +1 -1
  34. package/dist/types/views/ordered_list_editable.d.ts +1 -1
  35. package/dist/types/views/paragraph_editable.d.ts +1 -1
  36. package/dist/types/views/placeholder_element_editable.d.ts +1 -1
  37. package/dist/types/views/pullquote_element_editable.d.ts +1 -1
  38. package/dist/types/views/section_title_editable.d.ts +1 -1
  39. package/dist/types/views/table_element_editable.d.ts +1 -1
  40. package/dist/types/views/toc_element_editable.d.ts +1 -1
  41. package/package.json +3 -5
  42. package/dist/cjs/components/application-menu/ApplicationMenu.js +0 -63
  43. package/dist/cjs/components/application-menu/MenuItemContainer.js +0 -127
  44. package/dist/cjs/components/application-menu/Shortcut.js +0 -63
  45. package/dist/cjs/components/application-menu/index.js +0 -22
  46. package/dist/cjs/components/application-menu/menuState.js +0 -49
  47. package/dist/cjs/components/application-menu/types.js +0 -17
  48. package/dist/cjs/components/application-menu/useApplicationMenus.js +0 -154
  49. package/dist/cjs/components/dialog/TableCellBorderOptions.js +0 -64
  50. package/dist/cjs/components/dialog/TableCellOptions.js +0 -50
  51. package/dist/cjs/components/dialog/TableOptions.js +0 -31
  52. package/dist/cjs/components/dialog/commands.js +0 -185
  53. package/dist/cjs/components/dialog/index.js +0 -26
  54. package/dist/cjs/components/dialog/shared.js +0 -48
  55. package/dist/cjs/components/dialog/types.js +0 -9
  56. package/dist/cjs/components/toolbar/ListStyleSelector.js +0 -150
  57. package/dist/cjs/components/toolbar/ManuscriptToolbar.js +0 -104
  58. package/dist/cjs/components/toolbar/OrderListSelector.js +0 -103
  59. package/dist/cjs/views/EditableBlock.js +0 -37
  60. package/dist/es/components/application-menu/ApplicationMenu.js +0 -56
  61. package/dist/es/components/application-menu/MenuItemContainer.js +0 -120
  62. package/dist/es/components/application-menu/Shortcut.js +0 -56
  63. package/dist/es/components/application-menu/index.js +0 -17
  64. package/dist/es/components/application-menu/menuState.js +0 -44
  65. package/dist/es/components/application-menu/types.js +0 -16
  66. package/dist/es/components/application-menu/useApplicationMenus.js +0 -148
  67. package/dist/es/components/dialog/TableCellBorderOptions.js +0 -36
  68. package/dist/es/components/dialog/TableCellOptions.js +0 -22
  69. package/dist/es/components/dialog/TableOptions.js +0 -26
  70. package/dist/es/components/dialog/commands.js +0 -177
  71. package/dist/es/components/dialog/index.js +0 -18
  72. package/dist/es/components/dialog/shared.js +0 -21
  73. package/dist/es/components/dialog/types.js +0 -6
  74. package/dist/es/components/toolbar/ListStyleSelector.js +0 -120
  75. package/dist/es/components/toolbar/ManuscriptToolbar.js +0 -97
  76. package/dist/es/components/toolbar/OrderListSelector.js +0 -72
  77. package/dist/es/views/EditableBlock.js +0 -29
  78. package/dist/types/components/application-menu/ApplicationMenu.d.ts +0 -24
  79. package/dist/types/components/application-menu/MenuItemContainer.d.ts +0 -27
  80. package/dist/types/components/application-menu/Shortcut.d.ts +0 -26
  81. package/dist/types/components/application-menu/index.d.ts +0 -18
  82. package/dist/types/components/application-menu/menuState.d.ts +0 -18
  83. package/dist/types/components/application-menu/types.d.ts +0 -47
  84. package/dist/types/components/application-menu/useApplicationMenus.d.ts +0 -12
  85. package/dist/types/components/dialog/TableCellBorderOptions.d.ts +0 -9
  86. package/dist/types/components/dialog/TableCellOptions.d.ts +0 -4
  87. package/dist/types/components/dialog/TableOptions.d.ts +0 -4
  88. package/dist/types/components/dialog/commands.d.ts +0 -28
  89. package/dist/types/components/dialog/index.d.ts +0 -4
  90. package/dist/types/components/dialog/shared.d.ts +0 -16
  91. package/dist/types/components/dialog/types.d.ts +0 -16
  92. package/dist/types/components/toolbar/ListStyleSelector.d.ts +0 -36
  93. package/dist/types/components/toolbar/ManuscriptToolbar.d.ts +0 -50
  94. package/dist/types/components/toolbar/OrderListSelector.d.ts +0 -14
  95. package/dist/types/views/EditableBlock.d.ts +0 -19
package/dist/es/menus.js CHANGED
@@ -18,421 +18,369 @@ import { toggleMark } from 'prosemirror-commands';
18
18
  import { redo, undo } from 'prosemirror-history';
19
19
  import { wrapInList } from 'prosemirror-schema-list';
20
20
  import { addColumnAfter, addColumnBefore, addRowAfter, addRowBefore, deleteColumn, deleteRow, mergeCells, splitCell, } from 'prosemirror-tables';
21
- import { addComment, blockActive, canInsert, ifInTableBody, insertBibliographySection, insertBlock, insertCrossReference, insertGraphicalAbstract, insertInlineCitation, insertInlineEquation, insertInlineFootnote, insertLink, insertSection, insertTOCSection, markActive, } from './commands';
22
- import { DialogNames } from './components/dialog';
23
- import { skipTrackingChanges } from './keys/list';
21
+ import { addComment, blockActive, canInsert, ifInTableBody, insertBlock, insertCrossReference, insertGraphicalAbstract, insertInlineCitation, insertInlineEquation, insertInlineFootnote, insertLink, insertSection, markActive, } from './commands';
22
+ import { skipCommandTracking } from './keys/list';
24
23
  import { deleteClosestParentElement, findClosestParentElementNodeName, } from './lib/hierarchy';
25
- export const getMenus = (editor, handleOpenDialog, footnotesEnabled, contentEditable) => {
24
+ export const getEditorMenus = (editor) => {
26
25
  const { isCommandValid, state } = editor;
27
- const wrap = (command) => () => editor.doCommand(command);
28
- let menus = [
29
- {
30
- id: 'edit',
31
- label: 'Edit',
32
- submenu: [
33
- {
34
- id: 'edit-undo',
35
- role: 'undo',
36
- label: 'Undo',
37
- accelerator: {
38
- mac: 'CommandOrControl+Z',
39
- pc: 'CommandOrControl+Z',
26
+ const doCommand = (command) => () => editor.doCommand(command);
27
+ const edit = {
28
+ id: 'edit',
29
+ label: 'Edit',
30
+ isEnabled: true,
31
+ submenu: [
32
+ {
33
+ id: 'edit-undo',
34
+ role: 'undo',
35
+ label: 'Undo',
36
+ shortcut: {
37
+ mac: 'CommandOrControl+Z',
38
+ pc: 'CommandOrControl+Z',
39
+ },
40
+ isEnabled: isCommandValid(undo),
41
+ run: doCommand(undo),
42
+ },
43
+ {
44
+ id: 'edit-redo',
45
+ role: 'redo',
46
+ label: 'Redo',
47
+ shortcut: {
48
+ mac: 'Shift+CommandOrControl+Z',
49
+ pc: 'CommandOrControl+Y',
50
+ },
51
+ isEnabled: isCommandValid(redo),
52
+ run: doCommand(redo),
53
+ },
54
+ {
55
+ role: 'separator',
56
+ },
57
+ {
58
+ id: 'edit-delete',
59
+ role: 'delete',
60
+ label: (() => {
61
+ const nodeName = findClosestParentElementNodeName(state);
62
+ return `Delete ${nodeName}`;
63
+ })(),
64
+ isEnabled: isCommandValid(deleteClosestParentElement),
65
+ run: doCommand(deleteClosestParentElement),
66
+ },
67
+ ],
68
+ };
69
+ const insert = {
70
+ id: 'insert',
71
+ label: 'Insert',
72
+ isEnabled: true,
73
+ submenu: [
74
+ {
75
+ id: 'insert-section',
76
+ label: 'Section',
77
+ shortcut: {
78
+ mac: 'CommandOrControl+Enter',
79
+ pc: 'CommandOrControl+Enter',
80
+ },
81
+ isEnabled: isCommandValid(insertSection()),
82
+ run: doCommand(insertSection()),
83
+ },
84
+ {
85
+ id: 'insert-graphical-abstract',
86
+ label: 'Graphical Abstract',
87
+ isEnabled: isCommandValid(insertGraphicalAbstract),
88
+ run: doCommand(insertGraphicalAbstract),
89
+ },
90
+ {
91
+ id: 'insert-subsection',
92
+ label: 'Subsection',
93
+ shortcut: {
94
+ mac: 'Shift+CommandOrControl+Enter',
95
+ pc: 'Shift+CommandOrControl+Enter',
96
+ },
97
+ isEnabled: isCommandValid(insertSection(true)),
98
+ run: doCommand(insertSection(true)),
99
+ },
100
+ {
101
+ id: 'insert-paragraph',
102
+ label: 'Paragraph',
103
+ isEnabled: isCommandValid(canInsert(schema.nodes.paragraph)),
104
+ run: doCommand(insertBlock(schema.nodes.paragraph)),
105
+ },
106
+ {
107
+ role: 'separator',
108
+ },
109
+ {
110
+ id: 'insert-ordered-list',
111
+ label: 'Numbered List',
112
+ shortcut: {
113
+ mac: 'Option+CommandOrControl+O',
114
+ pc: 'CommandOrControl+Option+O',
115
+ },
116
+ isEnabled: isCommandValid(wrapInList(schema.nodes.ordered_list)),
117
+ run: doCommand(skipCommandTracking(wrapInList(schema.nodes.ordered_list))),
118
+ },
119
+ {
120
+ id: 'insert-bullet-list',
121
+ label: 'Bullet List',
122
+ shortcut: {
123
+ mac: 'Option+CommandOrControl+K',
124
+ pc: 'CommandOrControl+Option+K',
125
+ },
126
+ isEnabled: isCommandValid(wrapInList(schema.nodes.bullet_list)),
127
+ run: doCommand(skipCommandTracking(wrapInList(schema.nodes.bullet_list))),
128
+ },
129
+ {
130
+ role: 'separator',
131
+ },
132
+ {
133
+ id: 'insert-blockquote',
134
+ label: 'Block Quote',
135
+ isEnabled: isCommandValid(canInsert(schema.nodes.blockquote_element)),
136
+ run: doCommand(insertBlock(schema.nodes.blockquote_element)),
137
+ },
138
+ {
139
+ id: 'insert-pullquote',
140
+ label: 'Pull Quote',
141
+ isEnabled: isCommandValid(canInsert(schema.nodes.pullquote_element)),
142
+ run: doCommand(insertBlock(schema.nodes.pullquote_element)),
143
+ },
144
+ {
145
+ role: 'separator',
146
+ },
147
+ {
148
+ id: 'insert-figure-element',
149
+ label: 'Figure Panel',
150
+ shortcut: {
151
+ mac: 'Option+CommandOrControl+P',
152
+ pc: 'CommandOrControl+Option+P',
153
+ },
154
+ isEnabled: isCommandValid(canInsert(schema.nodes.figure_element)),
155
+ run: doCommand(insertBlock(schema.nodes.figure_element)),
156
+ },
157
+ {
158
+ id: 'insert-table-element',
159
+ label: 'Table',
160
+ shortcut: {
161
+ mac: 'Option+CommandOrControl+T',
162
+ pc: 'CommandOrControl+Option+T',
163
+ },
164
+ isEnabled: isCommandValid(canInsert(schema.nodes.table_element)),
165
+ run: doCommand(insertBlock(schema.nodes.table_element)),
166
+ },
167
+ {
168
+ role: 'separator',
169
+ },
170
+ {
171
+ id: 'insert-link',
172
+ label: 'Link',
173
+ shortcut: {
174
+ mac: 'Option+CommandOrControl+H',
175
+ pc: 'CommandOrControl+Option+H',
176
+ },
177
+ isActive: blockActive(schema.nodes.link)(state),
178
+ isEnabled: isCommandValid(canInsert(schema.nodes.link)),
179
+ run: doCommand(insertLink),
180
+ },
181
+ {
182
+ role: 'separator',
183
+ },
184
+ {
185
+ id: 'insert-equation',
186
+ label: 'Equation',
187
+ shortcut: {
188
+ mac: 'Option+CommandOrControl+E',
189
+ pc: 'CommandOrControl+Option+E',
190
+ },
191
+ isEnabled: isCommandValid(canInsert(schema.nodes.equation_element)),
192
+ run: doCommand(insertBlock(schema.nodes.equation_element)),
193
+ },
194
+ {
195
+ id: 'insert-inline-equation',
196
+ label: 'Inline Equation',
197
+ shortcut: {
198
+ mac: 'Shift+Option+CommandOrControl+E',
199
+ pc: 'Shift+CommandOrControl+Option+E',
200
+ },
201
+ isEnabled: isCommandValid(canInsert(schema.nodes.inline_equation)),
202
+ run: doCommand(insertInlineEquation),
203
+ },
204
+ {
205
+ role: 'separator',
206
+ },
207
+ {
208
+ id: 'insert-citation',
209
+ label: 'Citation',
210
+ shortcut: {
211
+ mac: 'Option+CommandOrControl+C',
212
+ pc: 'CommandOrControl+Option+C',
213
+ },
214
+ isEnabled: isCommandValid(canInsert(schema.nodes.citation)),
215
+ run: doCommand(insertInlineCitation),
216
+ },
217
+ {
218
+ id: 'insert-cross-reference',
219
+ label: 'Cross-reference',
220
+ shortcut: {
221
+ mac: 'Option+CommandOrControl+R',
222
+ pc: 'CommandOrControl+Option+R',
223
+ },
224
+ isEnabled: isCommandValid(canInsert(schema.nodes.cross_reference)),
225
+ run: doCommand(insertCrossReference),
226
+ },
227
+ {
228
+ id: 'insert-footnote',
229
+ label: 'Footnote',
230
+ shortcut: {
231
+ mac: 'Option+CommandOrControl+F',
232
+ pc: 'CommandOrControl+Option+F',
233
+ },
234
+ isEnabled: isCommandValid(canInsert(schema.nodes.inline_footnote)),
235
+ run: doCommand(insertInlineFootnote('footnote')),
236
+ },
237
+ {
238
+ id: 'insert-comment',
239
+ label: 'Comment',
240
+ isEnabled: isCommandValid(addComment),
241
+ run: doCommand(addComment),
242
+ },
243
+ ],
244
+ };
245
+ const format = {
246
+ id: 'format',
247
+ label: 'Format',
248
+ isEnabled: true,
249
+ submenu: [
250
+ {
251
+ id: 'format-bold',
252
+ label: 'Bold',
253
+ shortcut: {
254
+ mac: 'CommandOrControl+B',
255
+ pc: 'CommandOrControl+B',
256
+ },
257
+ isActive: markActive(schema.marks.bold)(state),
258
+ isEnabled: isCommandValid(toggleMark(schema.marks.bold)),
259
+ run: doCommand(toggleMark(schema.marks.bold)),
260
+ },
261
+ {
262
+ id: 'format-italic',
263
+ label: 'Italic',
264
+ shortcut: {
265
+ mac: 'CommandOrControl+I',
266
+ pc: 'CommandOrControl+I',
267
+ },
268
+ isActive: markActive(schema.marks.italic)(state),
269
+ isEnabled: isCommandValid(toggleMark(schema.marks.italic)),
270
+ run: doCommand(toggleMark(schema.marks.italic)),
271
+ },
272
+ {
273
+ id: 'format-strikethrough',
274
+ label: 'Strikethrough',
275
+ shortcut: {
276
+ mac: 'CommandOrControl+Shift+X',
277
+ pc: 'CommandOrControl+Shift+X',
278
+ },
279
+ isActive: markActive(schema.marks.strikethrough)(state),
280
+ isEnabled: isCommandValid(toggleMark(schema.marks.strikethrough)),
281
+ run: doCommand(toggleMark(schema.marks.strikethrough)),
282
+ },
283
+ {
284
+ id: 'format-underline',
285
+ label: 'Underline',
286
+ shortcut: {
287
+ mac: 'CommandOrControl+U',
288
+ pc: 'CommandOrControl+U',
289
+ },
290
+ isActive: markActive(schema.marks.underline)(state),
291
+ isEnabled: isCommandValid(toggleMark(schema.marks.underline)),
292
+ run: doCommand(toggleMark(schema.marks.underline)),
293
+ },
294
+ {
295
+ role: 'separator',
296
+ },
297
+ {
298
+ id: 'format-superscript',
299
+ label: 'Superscript',
300
+ shortcut: {
301
+ mac: 'Option+CommandOrControl+=',
302
+ pc: 'CommandOrControl+Option+=',
303
+ },
304
+ isActive: markActive(schema.marks.superscript)(state),
305
+ isEnabled: isCommandValid(toggleMark(schema.marks.superscript)),
306
+ run: doCommand(toggleMark(schema.marks.superscript)),
307
+ },
308
+ {
309
+ id: 'format-subscript',
310
+ label: 'Subscript',
311
+ shortcut: {
312
+ mac: 'Option+CommandOrControl+-',
313
+ pc: 'CommandOrControl+Option+-',
314
+ },
315
+ isActive: markActive(schema.marks.subscript)(state),
316
+ isEnabled: isCommandValid(toggleMark(schema.marks.subscript)),
317
+ run: doCommand(toggleMark(schema.marks.subscript)),
318
+ },
319
+ {
320
+ role: 'separator',
321
+ },
322
+ {
323
+ id: 'format-table',
324
+ label: 'Table',
325
+ isEnabled: isCommandValid(blockActive(schema.nodes.table)),
326
+ submenu: [
327
+ {
328
+ id: 'format-table-add-row-before',
329
+ label: 'Add Row Above',
330
+ isEnabled: isCommandValid(ifInTableBody(addRowBefore)),
331
+ run: doCommand(addRowBefore),
40
332
  },
41
- enable: isCommandValid(undo),
42
- run: wrap(undo),
43
- },
44
- {
45
- id: 'edit-redo',
46
- role: 'redo',
47
- label: 'Redo',
48
- accelerator: {
49
- mac: 'Shift+CommandOrControl+Z',
50
- pc: 'CommandOrControl+Y',
333
+ {
334
+ id: 'format-table-add-row-after',
335
+ label: 'Add Row Below',
336
+ isEnabled: isCommandValid(ifInTableBody(addRowAfter)),
337
+ run: doCommand(addRowAfter),
51
338
  },
52
- enable: isCommandValid(redo),
53
- run: wrap(redo),
54
- },
55
- {
56
- role: 'separator',
57
- },
58
- {
59
- id: 'edit-delete',
60
- role: 'delete',
61
- label: (() => {
62
- const nodeName = findClosestParentElementNodeName(state);
63
- return `Delete ${nodeName}`;
64
- })(),
65
- enable: isCommandValid(deleteClosestParentElement),
66
- run: wrap(deleteClosestParentElement),
67
- },
68
- ],
69
- },
70
- {
71
- id: 'insert',
72
- label: 'Insert',
73
- submenu: [
74
- {
75
- id: 'insert-section',
76
- label: 'Section',
77
- accelerator: {
78
- mac: 'CommandOrControl+Enter',
79
- pc: 'CommandOrControl+Enter',
339
+ {
340
+ id: 'format-table-delete-row',
341
+ label: 'Delete Row',
342
+ isEnabled: isCommandValid(ifInTableBody(deleteRow)),
343
+ run: doCommand(deleteRow),
80
344
  },
81
- enable: isCommandValid(insertSection()),
82
- run: wrap(insertSection()),
83
- },
84
- {
85
- id: 'insert-graphical-abstract',
86
- label: 'Graphical Abstract',
87
- enable: isCommandValid(insertGraphicalAbstract),
88
- run: wrap(insertGraphicalAbstract),
89
- },
90
- {
91
- id: 'insert-subsection',
92
- label: 'Subsection',
93
- accelerator: {
94
- mac: 'Shift+CommandOrControl+Enter',
95
- pc: 'Shift+CommandOrControl+Enter',
345
+ {
346
+ role: 'separator',
96
347
  },
97
- enable: isCommandValid(insertSection(true)),
98
- run: wrap(insertSection(true)),
99
- },
100
- {
101
- id: 'insert-paragraph',
102
- label: 'Paragraph',
103
- enable: isCommandValid(canInsert(schema.nodes.paragraph)),
104
- run: wrap(insertBlock(schema.nodes.paragraph)),
105
- },
106
- {
107
- role: 'separator',
108
- },
109
- {
110
- id: 'insert-ordered-list',
111
- label: 'Numbered List',
112
- accelerator: {
113
- mac: 'Option+CommandOrControl+O',
114
- pc: 'CommandOrControl+Option+O',
115
- },
116
- enable: isCommandValid(wrapInList(schema.nodes.ordered_list)),
117
- run: wrap(skipTrackingChanges(wrapInList(schema.nodes.ordered_list))),
118
- },
119
- {
120
- id: 'insert-bullet-list',
121
- label: 'Bullet List',
122
- accelerator: {
123
- mac: 'Option+CommandOrControl+K',
124
- pc: 'CommandOrControl+Option+K',
125
- },
126
- enable: isCommandValid(wrapInList(schema.nodes.bullet_list)),
127
- run: wrap(skipTrackingChanges(wrapInList(schema.nodes.bullet_list))),
128
- },
129
- {
130
- role: 'separator',
131
- },
132
- {
133
- id: 'insert-blockquote',
134
- label: 'Block Quote',
135
- enable: isCommandValid(canInsert(schema.nodes.blockquote_element)),
136
- run: wrap(insertBlock(schema.nodes.blockquote_element)),
137
- },
138
- {
139
- id: 'insert-pullquote',
140
- label: 'Pull Quote',
141
- enable: isCommandValid(canInsert(schema.nodes.pullquote_element)),
142
- run: wrap(insertBlock(schema.nodes.pullquote_element)),
143
- },
144
- {
145
- role: 'separator',
146
- },
147
- {
148
- id: 'insert-figure-element',
149
- label: 'Figure Panel',
150
- accelerator: {
151
- mac: 'Option+CommandOrControl+P',
152
- pc: 'CommandOrControl+Option+P',
348
+ {
349
+ id: 'format-table-add-column-before',
350
+ label: 'Add Column Before',
351
+ isEnabled: isCommandValid(addColumnBefore),
352
+ run: doCommand(addColumnBefore),
153
353
  },
154
- enable: isCommandValid(canInsert(schema.nodes.figure_element)),
155
- run: wrap(insertBlock(schema.nodes.figure_element)),
156
- },
157
- {
158
- id: 'insert-table-element',
159
- label: 'Table',
160
- accelerator: {
161
- mac: 'Option+CommandOrControl+T',
162
- pc: 'CommandOrControl+Option+T',
354
+ {
355
+ id: 'format-table-add-column-after',
356
+ label: 'Add Column After',
357
+ isEnabled: isCommandValid(addColumnAfter),
358
+ run: doCommand(addColumnAfter),
163
359
  },
164
- enable: isCommandValid(canInsert(schema.nodes.table_element)),
165
- run: wrap(insertBlock(schema.nodes.table_element)),
166
- },
167
- {
168
- id: 'insert-listing',
169
- label: 'Listing',
170
- accelerator: {
171
- mac: 'Option+CommandOrControl+L',
172
- pc: 'CommandOrControl+Option+L',
360
+ {
361
+ id: 'format-table-delete-column',
362
+ label: 'Delete Column',
363
+ isEnabled: isCommandValid(deleteColumn),
364
+ run: doCommand(deleteColumn),
173
365
  },
174
- enable: isCommandValid(canInsert(schema.nodes.listing_element)),
175
- run: wrap(insertBlock(schema.nodes.listing_element)),
176
- },
177
- {
178
- role: 'separator',
179
- },
180
- {
181
- id: 'insert-link',
182
- label: 'Link',
183
- accelerator: {
184
- mac: 'Option+CommandOrControl+H',
185
- pc: 'CommandOrControl+Option+H',
366
+ {
367
+ role: 'separator',
186
368
  },
187
- active: blockActive(schema.nodes.link)(state),
188
- enable: isCommandValid(canInsert(schema.nodes.link)),
189
- run: wrap(insertLink),
190
- },
191
- {
192
- role: 'separator',
193
- },
194
- {
195
- id: 'insert-equation',
196
- label: 'Equation',
197
- accelerator: {
198
- mac: 'Option+CommandOrControl+E',
199
- pc: 'CommandOrControl+Option+E',
369
+ {
370
+ id: 'merge-cells',
371
+ label: 'Merge Cells',
372
+ isEnabled: isCommandValid(mergeCells),
373
+ run: doCommand(mergeCells),
200
374
  },
201
- enable: isCommandValid(canInsert(schema.nodes.equation_element)),
202
- run: wrap(insertBlock(schema.nodes.equation_element)),
203
- },
204
- {
205
- id: 'insert-inline-equation',
206
- label: 'Inline Equation',
207
- accelerator: {
208
- mac: 'Shift+Option+CommandOrControl+E',
209
- pc: 'Shift+CommandOrControl+Option+E',
375
+ {
376
+ id: 'split-cells',
377
+ label: 'Split Cell',
378
+ isEnabled: isCommandValid(splitCell),
379
+ run: doCommand(splitCell),
210
380
  },
211
- enable: isCommandValid(canInsert(schema.nodes.inline_equation)),
212
- run: wrap(insertInlineEquation),
213
- },
214
- {
215
- role: 'separator',
216
- },
217
- {
218
- id: 'insert-citation',
219
- label: 'Citation',
220
- accelerator: {
221
- mac: 'Option+CommandOrControl+C',
222
- pc: 'CommandOrControl+Option+C',
223
- },
224
- enable: isCommandValid(canInsert(schema.nodes.citation)),
225
- run: wrap(insertInlineCitation),
226
- },
227
- {
228
- id: 'insert-cross-reference',
229
- label: 'Cross-reference',
230
- accelerator: {
231
- mac: 'Option+CommandOrControl+R',
232
- pc: 'CommandOrControl+Option+R',
233
- },
234
- enable: isCommandValid(canInsert(schema.nodes.cross_reference)),
235
- run: wrap(insertCrossReference),
236
- },
237
- {
238
- id: 'insert-footnote',
239
- label: 'Footnote',
240
- accelerator: {
241
- mac: 'Option+CommandOrControl+F',
242
- pc: 'CommandOrControl+Option+F',
243
- },
244
- enable: isCommandValid(canInsert(schema.nodes.inline_footnote)),
245
- run: wrap(insertInlineFootnote('footnote')),
246
- },
247
- {
248
- id: 'insert-comment',
249
- label: 'Comment',
250
- enable: isCommandValid(addComment),
251
- run: wrap(addComment),
252
- },
253
- {
254
- role: 'separator',
255
- },
256
- {
257
- id: 'insert-toc',
258
- label: 'Table of Contents',
259
- enable: isCommandValid(insertTOCSection),
260
- run: wrap(insertTOCSection),
261
- },
262
- {
263
- id: 'insert-bibliography',
264
- label: 'Bibliography',
265
- enable: isCommandValid(insertBibliographySection),
266
- run: wrap(insertBibliographySection),
267
- },
268
- ],
269
- },
270
- {
271
- id: 'format',
272
- label: 'Format',
273
- submenu: [
274
- {
275
- id: 'format-bold',
276
- label: 'Bold',
277
- accelerator: {
278
- mac: 'CommandOrControl+B',
279
- pc: 'CommandOrControl+B',
280
- },
281
- active: markActive(schema.marks.bold)(state),
282
- enable: isCommandValid(toggleMark(schema.marks.bold)),
283
- run: wrap(toggleMark(schema.marks.bold)),
284
- },
285
- {
286
- id: 'format-italic',
287
- label: 'Italic',
288
- accelerator: {
289
- mac: 'CommandOrControl+I',
290
- pc: 'CommandOrControl+I',
291
- },
292
- active: markActive(schema.marks.italic)(state),
293
- enable: isCommandValid(toggleMark(schema.marks.italic)),
294
- run: wrap(toggleMark(schema.marks.italic)),
295
- },
296
- {
297
- id: 'format-strikethrough',
298
- label: 'Strikethrough',
299
- accelerator: {
300
- mac: 'CommandOrControl+Shift+X',
301
- pc: 'CommandOrControl+Shift+X',
302
- },
303
- active: markActive(schema.marks.strikethrough)(state),
304
- enable: isCommandValid(toggleMark(schema.marks.strikethrough)),
305
- run: wrap(toggleMark(schema.marks.strikethrough)),
306
- },
307
- {
308
- id: 'format-underline',
309
- label: 'Underline',
310
- accelerator: {
311
- mac: 'CommandOrControl+U',
312
- pc: 'CommandOrControl+U',
313
- },
314
- active: markActive(schema.marks.underline)(state),
315
- enable: isCommandValid(toggleMark(schema.marks.underline)),
316
- run: wrap(toggleMark(schema.marks.underline)),
317
- },
318
- {
319
- role: 'separator',
320
- },
321
- {
322
- id: 'format-superscript',
323
- label: 'Superscript',
324
- accelerator: {
325
- mac: 'Option+CommandOrControl+=',
326
- pc: 'CommandOrControl+Option+=',
327
- },
328
- active: markActive(schema.marks.superscript)(state),
329
- enable: isCommandValid(toggleMark(schema.marks.superscript)),
330
- run: wrap(toggleMark(schema.marks.superscript)),
331
- },
332
- {
333
- id: 'format-subscript',
334
- label: 'Subscript',
335
- accelerator: {
336
- mac: 'Option+CommandOrControl+-',
337
- pc: 'CommandOrControl+Option+-',
338
- },
339
- active: markActive(schema.marks.subscript)(state),
340
- enable: isCommandValid(toggleMark(schema.marks.subscript)),
341
- run: wrap(toggleMark(schema.marks.subscript)),
342
- },
343
- {
344
- role: 'separator',
345
- },
346
- {
347
- id: 'format-table',
348
- label: 'Table',
349
- enable: isCommandValid(blockActive(schema.nodes.table)),
350
- submenu: [
351
- {
352
- id: 'format-table-add-row-before',
353
- label: 'Add Row Above',
354
- enable: isCommandValid(ifInTableBody(addRowBefore)),
355
- run: wrap(addRowBefore),
356
- },
357
- {
358
- id: 'format-table-add-row-after',
359
- label: 'Add Row Below',
360
- enable: isCommandValid(ifInTableBody(addRowAfter)),
361
- run: wrap(addRowAfter),
362
- },
363
- {
364
- id: 'format-table-delete-row',
365
- label: 'Delete Row',
366
- enable: isCommandValid(ifInTableBody(deleteRow)),
367
- run: wrap(deleteRow),
368
- },
369
- {
370
- role: 'separator',
371
- },
372
- {
373
- id: 'format-table-add-column-before',
374
- label: 'Add Column Before',
375
- enable: isCommandValid(addColumnBefore),
376
- run: wrap(addColumnBefore),
377
- },
378
- {
379
- id: 'format-table-add-column-after',
380
- label: 'Add Column After',
381
- enable: isCommandValid(addColumnAfter),
382
- run: wrap(addColumnAfter),
383
- },
384
- {
385
- id: 'format-table-delete-column',
386
- label: 'Delete Column',
387
- enable: isCommandValid(deleteColumn),
388
- run: wrap(deleteColumn),
389
- },
390
- {
391
- role: 'separator',
392
- },
393
- {
394
- id: 'merge-cells',
395
- label: 'Merge Cells',
396
- enable: isCommandValid(mergeCells),
397
- run: wrap(mergeCells),
398
- },
399
- {
400
- id: 'split-cells',
401
- label: 'Split Cell',
402
- enable: isCommandValid(splitCell),
403
- run: wrap(splitCell),
404
- },
405
- {
406
- id: 'table-options',
407
- label: 'Table options \u2026',
408
- run: () => handleOpenDialog(DialogNames.TableOptions),
409
- enable: isCommandValid(ifInTableBody(deleteRow)),
410
- },
411
- {
412
- id: 'style-table-cell',
413
- label: 'Cell style \u2026',
414
- run: () => handleOpenDialog(DialogNames.TableCellOptions),
415
- enable: isCommandValid(ifInTableBody(deleteRow)),
416
- },
417
- {
418
- id: 'style-table-cell-border',
419
- label: 'Border style \u2026',
420
- run: () => DialogNames.TableCellBorderOptions,
421
- enable: isCommandValid(ifInTableBody(deleteRow)),
422
- },
423
- ],
424
- },
425
- ],
426
- },
427
- ];
428
- const menusEditable = ['insert', 'edit'];
429
- if (contentEditable === false) {
430
- menus = menus.filter((item) => !(item.id && menusEditable.includes(item.id)));
431
- }
432
- return menus.map((menuGroup) => {
433
- if (menuGroup.submenu) {
434
- menuGroup.submenu = menuGroup.submenu.filter((submenu) => !(submenu.id == 'insert-footnote' && !footnotesEnabled));
435
- }
436
- return menuGroup;
437
- });
381
+ ],
382
+ },
383
+ ],
384
+ };
385
+ return [edit, insert, format];
438
386
  };