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