@manuscripts/body-editor 1.7.13 → 1.7.14

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.
@@ -556,14 +556,22 @@ const selectAllIsolating = (state, dispatch) => {
556
556
  return true;
557
557
  };
558
558
  exports.selectAllIsolating = selectAllIsolating;
559
- const createAndFillTableElement = (state) => state.schema.nodes.table_element.createChecked({}, [
560
- state.schema.nodes.table.create({}, state.schema.nodes.table_body.create({}, Array.from([1, 2, 3, 4], () => state.schema.nodes.table_row.create({}, [
559
+ const createAndFillTableElement = (state) => {
560
+ const emptyTableHeader = state.schema.nodes.table_row.create({}, [
561
+ state.schema.nodes.table_header.create(),
562
+ state.schema.nodes.table_header.create(),
563
+ ]);
564
+ const emptyTableRow = state.schema.nodes.table_row.create({}, [
561
565
  state.schema.nodes.table_cell.create(),
562
566
  state.schema.nodes.table_cell.create(),
563
- ])))),
564
- createAndFillFigcaptionElement(state),
565
- state.schema.nodes.listing.create(),
566
- ]);
567
+ ]);
568
+ const tableRows = [emptyTableHeader, ...Array(3).fill(emptyTableRow)];
569
+ return state.schema.nodes.table_element.createChecked({}, [
570
+ state.schema.nodes.table.create({}, tableRows),
571
+ createAndFillFigcaptionElement(state),
572
+ state.schema.nodes.listing.create(),
573
+ ]);
574
+ };
567
575
  exports.createAndFillTableElement = createAndFillTableElement;
568
576
  const createAndFillFigureElement = (state) => state.schema.nodes.figure_element.create({}, [
569
577
  state.schema.nodes.figure.create({}, [
package/dist/cjs/menus.js CHANGED
@@ -351,36 +351,21 @@ const getEditorMenus = (editor) => {
351
351
  {
352
352
  id: 'format-table-add-column-before',
353
353
  label: 'Add Column Before',
354
- isEnabled: isCommandValid(prosemirror_tables_1.addColumnBefore),
354
+ isEnabled: isCommandValid((0, commands_1.ifInTableBody)(prosemirror_tables_1.addColumnBefore)),
355
355
  run: doCommand(prosemirror_tables_1.addColumnBefore),
356
356
  },
357
357
  {
358
358
  id: 'format-table-add-column-after',
359
359
  label: 'Add Column After',
360
- isEnabled: isCommandValid(prosemirror_tables_1.addColumnAfter),
360
+ isEnabled: isCommandValid((0, commands_1.ifInTableBody)(prosemirror_tables_1.addColumnAfter)),
361
361
  run: doCommand(prosemirror_tables_1.addColumnAfter),
362
362
  },
363
363
  {
364
364
  id: 'format-table-delete-column',
365
365
  label: 'Delete Column',
366
- isEnabled: isCommandValid(prosemirror_tables_1.deleteColumn),
366
+ isEnabled: isCommandValid((0, commands_1.ifInTableBody)(prosemirror_tables_1.deleteColumn)),
367
367
  run: doCommand(prosemirror_tables_1.deleteColumn),
368
368
  },
369
- {
370
- role: 'separator',
371
- },
372
- {
373
- id: 'merge-cells',
374
- label: 'Merge Cells',
375
- isEnabled: isCommandValid(prosemirror_tables_1.mergeCells),
376
- run: doCommand(prosemirror_tables_1.mergeCells),
377
- },
378
- {
379
- id: 'split-cells',
380
- label: 'Split Cell',
381
- isEnabled: isCommandValid(prosemirror_tables_1.splitCell),
382
- run: doCommand(prosemirror_tables_1.splitCell),
383
- },
384
369
  ],
385
370
  },
386
371
  ],
@@ -524,14 +524,22 @@ export const selectAllIsolating = (state, dispatch) => {
524
524
  }
525
525
  return true;
526
526
  };
527
- export const createAndFillTableElement = (state) => state.schema.nodes.table_element.createChecked({}, [
528
- state.schema.nodes.table.create({}, state.schema.nodes.table_body.create({}, Array.from([1, 2, 3, 4], () => state.schema.nodes.table_row.create({}, [
527
+ export const createAndFillTableElement = (state) => {
528
+ const emptyTableHeader = state.schema.nodes.table_row.create({}, [
529
+ state.schema.nodes.table_header.create(),
530
+ state.schema.nodes.table_header.create(),
531
+ ]);
532
+ const emptyTableRow = state.schema.nodes.table_row.create({}, [
529
533
  state.schema.nodes.table_cell.create(),
530
534
  state.schema.nodes.table_cell.create(),
531
- ])))),
532
- createAndFillFigcaptionElement(state),
533
- state.schema.nodes.listing.create(),
534
- ]);
535
+ ]);
536
+ const tableRows = [emptyTableHeader, ...Array(3).fill(emptyTableRow)];
537
+ return state.schema.nodes.table_element.createChecked({}, [
538
+ state.schema.nodes.table.create({}, tableRows),
539
+ createAndFillFigcaptionElement(state),
540
+ state.schema.nodes.listing.create(),
541
+ ]);
542
+ };
535
543
  const createAndFillFigureElement = (state) => state.schema.nodes.figure_element.create({}, [
536
544
  state.schema.nodes.figure.create({}, [
537
545
  state.schema.nodes.figcaption.create(),
package/dist/es/menus.js CHANGED
@@ -17,7 +17,7 @@ import { schema } from '@manuscripts/transform';
17
17
  import { toggleMark } from 'prosemirror-commands';
18
18
  import { redo, undo } from 'prosemirror-history';
19
19
  import { wrapInList } from 'prosemirror-schema-list';
20
- import { addColumnAfter, addColumnBefore, addRowAfter, addRowBefore, deleteColumn, deleteRow, mergeCells, splitCell, } from 'prosemirror-tables';
20
+ import { addColumnAfter, addColumnBefore, addRowAfter, addRowBefore, deleteColumn, deleteRow, } from 'prosemirror-tables';
21
21
  import { addComment, blockActive, canInsert, ifInTableBody, insertBlock, insertCrossReference, insertGraphicalAbstract, insertInlineCitation, insertInlineEquation, insertInlineFootnote, insertLink, insertSection, markActive, } from './commands';
22
22
  import { skipCommandTracking } from './keys/list';
23
23
  import { deleteClosestParentElement, findClosestParentElementNodeName, } from './lib/hierarchy';
@@ -348,36 +348,21 @@ export const getEditorMenus = (editor) => {
348
348
  {
349
349
  id: 'format-table-add-column-before',
350
350
  label: 'Add Column Before',
351
- isEnabled: isCommandValid(addColumnBefore),
351
+ isEnabled: isCommandValid(ifInTableBody(addColumnBefore)),
352
352
  run: doCommand(addColumnBefore),
353
353
  },
354
354
  {
355
355
  id: 'format-table-add-column-after',
356
356
  label: 'Add Column After',
357
- isEnabled: isCommandValid(addColumnAfter),
357
+ isEnabled: isCommandValid(ifInTableBody(addColumnAfter)),
358
358
  run: doCommand(addColumnAfter),
359
359
  },
360
360
  {
361
361
  id: 'format-table-delete-column',
362
362
  label: 'Delete Column',
363
- isEnabled: isCommandValid(deleteColumn),
363
+ isEnabled: isCommandValid(ifInTableBody(deleteColumn)),
364
364
  run: doCommand(deleteColumn),
365
365
  },
366
- {
367
- role: 'separator',
368
- },
369
- {
370
- id: 'merge-cells',
371
- label: 'Merge Cells',
372
- isEnabled: isCommandValid(mergeCells),
373
- run: doCommand(mergeCells),
374
- },
375
- {
376
- id: 'split-cells',
377
- label: 'Split Cell',
378
- isEnabled: isCommandValid(splitCell),
379
- run: doCommand(splitCell),
380
- },
381
366
  ],
382
367
  },
383
368
  ],
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@manuscripts/body-editor",
3
3
  "description": "Prosemirror components for editing and viewing manuscripts",
4
- "version": "1.7.13",
4
+ "version": "1.7.14",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -31,9 +31,9 @@
31
31
  "@manuscripts/assets": "^0.6.4",
32
32
  "@manuscripts/json-schema": "^2.2.4",
33
33
  "@manuscripts/library": "^1.3.3",
34
- "@manuscripts/style-guide": "1.7.8",
34
+ "@manuscripts/style-guide": "^1.7.9",
35
35
  "@manuscripts/track-changes-plugin": "^1.7.5",
36
- "@manuscripts/transform": "2.1.3",
36
+ "@manuscripts/transform": "^2.1.4",
37
37
  "astrocite-eutils": "^0.16.4",
38
38
  "axios": "^1.6.7",
39
39
  "codemirror": "^5.58.1",
@@ -51,7 +51,7 @@
51
51
  "prosemirror-model": "^1.18.3",
52
52
  "prosemirror-schema-list": "^1.2.2",
53
53
  "prosemirror-state": "^1.4.2",
54
- "prosemirror-tables": "^1.3.0",
54
+ "prosemirror-tables": "^1.3.5",
55
55
  "prosemirror-transform": "^1.7.0",
56
56
  "prosemirror-utils": "^0.9.6",
57
57
  "prosemirror-view": "^1.29.1",
@@ -109,4 +109,4 @@
109
109
  "resolutions": {
110
110
  "@types/react": "^17.0.2"
111
111
  }
112
- }
112
+ }