@manuscripts/transform 2.1.1-LEAN-3336-6 → 2.1.1-LEAN-3336-8

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.
@@ -530,10 +530,6 @@ const nodes = [
530
530
  };
531
531
  },
532
532
  },
533
- {
534
- tag: 'tbody',
535
- skip: true,
536
- },
537
533
  {
538
534
  tag: 'tfoot',
539
535
  skip: true,
@@ -573,7 +569,7 @@ const nodes = [
573
569
  const element = node;
574
570
  const colspan = element.getAttribute('colspan');
575
571
  const rowspan = element.getAttribute('rowspan');
576
- return Object.assign(Object.assign(Object.assign({ celltype: 'th' }, (colspan && { colspan })), (rowspan && { rowspan })), { valign: element.getAttribute('valign'), align: element.getAttribute('align'), scope: element.getAttribute('scope'), style: element.getAttribute('style') });
572
+ return Object.assign(Object.assign(Object.assign({}, (colspan && { colspan })), (rowspan && { rowspan })), { valign: element.getAttribute('valign'), align: element.getAttribute('align'), scope: element.getAttribute('scope'), style: element.getAttribute('style') });
577
573
  },
578
574
  },
579
575
  {
@@ -586,6 +582,10 @@ const nodes = [
586
582
  };
587
583
  },
588
584
  },
585
+ {
586
+ tag: 'colgroup',
587
+ node: 'table_colgroup',
588
+ },
589
589
  {
590
590
  tag: 'xref[ref-type="bibr"]',
591
591
  node: 'citation',
@@ -241,18 +241,27 @@ exports.jatsBodyTransformations = {
241
241
  fixTables(body, createElement) {
242
242
  const tables = body.querySelectorAll('table-wrap > table');
243
243
  tables.forEach((table) => {
244
+ var _a;
245
+ const colgroup = table.querySelector('colgroup');
246
+ const cols = table.querySelectorAll('col');
247
+ if (!colgroup && table.firstChild && cols.length > 0) {
248
+ const colgroup = createElement('colgroup');
249
+ for (const col of cols) {
250
+ colgroup.appendChild(col);
251
+ }
252
+ (_a = table.parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore(colgroup, table);
253
+ }
254
+ const rows = table.querySelectorAll('tr');
255
+ for (const row of rows) {
256
+ table.appendChild(row);
257
+ }
258
+ const thead = table.querySelector('thead');
259
+ if (thead) {
260
+ table.removeChild(thead);
261
+ }
244
262
  const tbody = table.querySelector('tbody');
245
263
  if (tbody) {
246
- const headerRow = table.querySelector('thead > tr');
247
- if (!headerRow) {
248
- const tr = createElement('tr');
249
- tbody.insertBefore(tr, tbody.firstElementChild);
250
- }
251
- const footerRow = table.querySelector('tfoot > tr');
252
- if (!footerRow) {
253
- const tr = createElement('tr');
254
- tbody.appendChild(tr);
255
- }
264
+ table.removeChild(tbody);
256
265
  }
257
266
  });
258
267
  },
@@ -615,7 +615,7 @@ class JATSExporter {
615
615
  const getModel = (id) => id ? this.modelMap.get(id) : undefined;
616
616
  const nodes = {
617
617
  table_header: (node) => [
618
- node.attrs.celltype,
618
+ 'th',
619
619
  Object.assign(Object.assign({ valign: node.attrs.valign, align: node.attrs.align, scope: node.attrs.scope, style: node.attrs.style }, (node.attrs.rowspan > 1 && { rowspan: node.attrs.rowspan })), (node.attrs.colspan > 1 && { colspan: node.attrs.colspan })),
620
620
  0,
621
621
  ],
@@ -879,7 +879,7 @@ class JATSExporter {
879
879
  return element;
880
880
  },
881
881
  table_cell: (node) => [
882
- node.attrs.celltype,
882
+ 'td',
883
883
  Object.assign(Object.assign({ valign: node.attrs.valign, align: node.attrs.align, scope: node.attrs.scope, style: node.attrs.style }, (node.attrs.rowspan > 1 && { rowspan: node.attrs.rowspan })), (node.attrs.colspan > 1 && { colspan: node.attrs.colspan })),
884
884
  0,
885
885
  ],
@@ -960,6 +960,26 @@ class JATSExporter {
960
960
  element.appendChild(this.serializeNode(childNode));
961
961
  }
962
962
  };
963
+ const appendTable = (element, node) => {
964
+ const tableNode = findChildNodeOfType(node, node.type.schema.nodes.table);
965
+ const colGroupNode = findChildNodeOfType(node, node.type.schema.nodes.table_colgroup);
966
+ if (!tableNode) {
967
+ return;
968
+ }
969
+ const table = this.serializeNode(tableNode);
970
+ const tbodyElement = document.createElement('tbody');
971
+ while (table.firstChild) {
972
+ const child = table.firstChild;
973
+ table.removeChild(child);
974
+ tbodyElement.appendChild(child);
975
+ }
976
+ table.appendChild(tbodyElement);
977
+ if (colGroupNode) {
978
+ const colGroup = this.serializeNode(colGroupNode);
979
+ table.insertBefore(colGroup, table.firstChild);
980
+ }
981
+ element.appendChild(table);
982
+ };
963
983
  const createFigureElement = (node, nodeName, contentNodeType, figType) => {
964
984
  const element = createElement(node, nodeName);
965
985
  if (figType) {
@@ -980,7 +1000,7 @@ class JATSExporter {
980
1000
  const element = createElement(node, nodeName);
981
1001
  appendLabels(element, node);
982
1002
  appendChildNodeOfType(element, node, node.type.schema.nodes.figcaption);
983
- appendChildNodeOfType(element, node, node.type.schema.nodes.table);
1003
+ appendTable(element, node);
984
1004
  appendChildNodeOfType(element, node, node.type.schema.nodes.table_element_footer);
985
1005
  if ((0, node_types_1.isExecutableNodeType)(node.type)) {
986
1006
  processExecutableNode(node, element);
@@ -15,22 +15,84 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.tableHeader = exports.tableCell = exports.tableRow = exports.table = exports.tnodes = void 0;
18
+ exports.tableHeader = exports.tableRow = exports.tableCell = exports.table = exports.tableNodes = void 0;
19
19
  const prosemirror_tables_1 = require("prosemirror-tables");
20
+ const table_cell_styles_1 = require("../../lib/table-cell-styles");
20
21
  const tableOptions = {
21
22
  tableGroup: 'block',
22
23
  cellContent: 'inline*',
23
24
  cellAttributes: {
24
- placeholder: { default: 'Data' },
25
- styles: { default: {} },
26
- valign: { default: null },
27
- align: { default: null },
28
- scope: { default: null },
29
- style: { default: null },
25
+ placeholder: {
26
+ default: 'Data',
27
+ getFromDOM(dom) {
28
+ return dom.getAttribute('data-placeholder-text') || '';
29
+ },
30
+ setDOMAttr(value, attrs) {
31
+ if (value) {
32
+ attrs['data-placeholder-text'] = value;
33
+ }
34
+ },
35
+ },
36
+ styles: {
37
+ default: {},
38
+ getFromDOM(dom) {
39
+ return (0, table_cell_styles_1.getTableCellStyles)(dom.style);
40
+ },
41
+ setDOMAttr(value, attrs) {
42
+ const styleString = (0, table_cell_styles_1.serializeTableCellStyles)(value);
43
+ if (styleString) {
44
+ attrs['style'] = value;
45
+ }
46
+ },
47
+ },
48
+ valign: {
49
+ default: null,
50
+ getFromDOM(dom) {
51
+ return dom.getAttribute('valign');
52
+ },
53
+ setDOMAttr(value, attrs) {
54
+ if (value) {
55
+ attrs['valign'] = value;
56
+ }
57
+ },
58
+ },
59
+ align: {
60
+ default: null,
61
+ getFromDOM(dom) {
62
+ return dom.getAttribute('align');
63
+ },
64
+ setDOMAttr(value, attrs) {
65
+ if (value) {
66
+ attrs['align'] = value;
67
+ }
68
+ },
69
+ },
70
+ scope: {
71
+ default: null,
72
+ getFromDOM(dom) {
73
+ return dom.getAttribute('scope');
74
+ },
75
+ setDOMAttr(value, attrs) {
76
+ if (value) {
77
+ attrs['scope'] = value;
78
+ }
79
+ },
80
+ },
81
+ style: {
82
+ default: null,
83
+ getFromDOM(dom) {
84
+ return dom.getAttribute('style');
85
+ },
86
+ setDOMAttr(value, attrs) {
87
+ if (value) {
88
+ attrs['style'] = value;
89
+ }
90
+ },
91
+ },
30
92
  },
31
93
  };
32
- exports.tnodes = (0, prosemirror_tables_1.tableNodes)(tableOptions);
33
- exports.table = Object.assign(Object.assign({}, exports.tnodes.table), { attrs: Object.assign(Object.assign({}, exports.tnodes.table.attrs), { id: { default: '' } }) });
34
- exports.tableRow = exports.tnodes.table_row;
35
- exports.tableCell = exports.tnodes.table_cell;
36
- exports.tableHeader = exports.tnodes.table_header;
94
+ exports.tableNodes = (0, prosemirror_tables_1.tableNodes)(tableOptions);
95
+ exports.table = Object.assign(Object.assign({}, exports.tableNodes.table), { attrs: Object.assign(Object.assign({}, exports.tableNodes.table.attrs), { id: { default: '' }, dataTracked: { default: null }, comments: { default: null } }) });
96
+ exports.tableCell = exports.tableNodes.table_cell;
97
+ exports.tableRow = exports.tableNodes.table_row;
98
+ exports.tableHeader = exports.tableNodes.table_header;
@@ -17,7 +17,7 @@
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.tableElement = void 0;
19
19
  exports.tableElement = {
20
- content: '(table | placeholder) table_element_footer? figcaption? (listing | placeholder)',
20
+ content: 'table_colgroup? (table | placeholder) table_element_footer? figcaption? (listing | placeholder)',
21
21
  attrs: {
22
22
  id: { default: '' },
23
23
  paragraphStyle: { default: '' },
@@ -557,15 +557,19 @@ class Decoder {
557
557
  },
558
558
  [json_schema_1.ObjectTypes.Table]: (data) => {
559
559
  const model = data;
560
- return this.parseContents(model.contents, undefined, [], {
560
+ const comments = this.createCommentNodes(model);
561
+ comments.forEach((c) => this.comments.set(c.attrs.id, c));
562
+ return this.parseContents(model.contents, undefined, this.getComments(model), {
561
563
  topNode: schema_1.schema.nodes.table.create({
562
564
  id: model._id,
565
+ comments: comments.map((c) => c.attrs.id),
563
566
  }),
564
567
  });
565
568
  },
566
569
  [json_schema_1.ObjectTypes.TableElement]: (data) => {
567
570
  const model = data;
568
571
  const table = this.createTable(model);
572
+ const tableColGroup = this.createTableColGroup(model);
569
573
  const tableElementFooter = this.createTableElementFooter(model);
570
574
  const figcaption = this.getFigcaption(model);
571
575
  const comments = this.createCommentNodes(model);
@@ -573,6 +577,9 @@ class Decoder {
573
577
  const content = tableElementFooter
574
578
  ? [table, tableElementFooter, figcaption]
575
579
  : [table, figcaption];
580
+ if (tableColGroup) {
581
+ content.unshift(tableColGroup);
582
+ }
576
583
  if (model.listingID) {
577
584
  const listing = this.createListing(model.listingID);
578
585
  content.push(listing);
@@ -786,6 +793,15 @@ class Decoder {
786
793
  }
787
794
  return table;
788
795
  }
796
+ createTableColGroup(model) {
797
+ const tableId = model.containedObjectID;
798
+ const tableModel = this.getModel(tableId);
799
+ if (tableModel) {
800
+ return this.parseContents(tableModel.contents, undefined, [], {
801
+ topNode: schema_1.schema.nodes.table_colgroup.create(),
802
+ });
803
+ }
804
+ }
789
805
  createTableElementFooter(model) {
790
806
  const tableElementFooterID = model.tableElementFooterID;
791
807
  if (!tableElementFooterID) {
@@ -99,9 +99,28 @@ const buildTableSection = (tagName, inputRows, parent) => {
99
99
  }
100
100
  return section;
101
101
  };
102
+ function buildTableColGroup(cols) {
103
+ if (cols.length === 0) {
104
+ return undefined;
105
+ }
106
+ const colgroup = document.createElement('colgroup');
107
+ for (const inputCol of cols) {
108
+ const col = document.createElement('col');
109
+ for (const attribute of inputCol.attributes) {
110
+ col.setAttribute(attribute.name, attribute.value);
111
+ }
112
+ colgroup.appendChild(inputCol);
113
+ }
114
+ return colgroup;
115
+ }
102
116
  const tableContents = (node, parent) => {
103
117
  const input = serializer.serializeNode(node);
118
+ const parentInput = serializer.serializeNode(parent);
104
119
  const output = document.createElement('table');
120
+ const colgroup = buildTableColGroup(Array.from(parentInput.querySelectorAll('col')));
121
+ if (colgroup) {
122
+ output.appendChild(colgroup);
123
+ }
105
124
  output.setAttribute('id', parent.attrs.id);
106
125
  output.classList.add('MPElement');
107
126
  if (parent.attrs.tableStyle) {
@@ -524,10 +524,6 @@ const nodes = [
524
524
  };
525
525
  },
526
526
  },
527
- {
528
- tag: 'tbody',
529
- skip: true,
530
- },
531
527
  {
532
528
  tag: 'tfoot',
533
529
  skip: true,
@@ -567,7 +563,7 @@ const nodes = [
567
563
  const element = node;
568
564
  const colspan = element.getAttribute('colspan');
569
565
  const rowspan = element.getAttribute('rowspan');
570
- return Object.assign(Object.assign(Object.assign({ celltype: 'th' }, (colspan && { colspan })), (rowspan && { rowspan })), { valign: element.getAttribute('valign'), align: element.getAttribute('align'), scope: element.getAttribute('scope'), style: element.getAttribute('style') });
566
+ return Object.assign(Object.assign(Object.assign({}, (colspan && { colspan })), (rowspan && { rowspan })), { valign: element.getAttribute('valign'), align: element.getAttribute('align'), scope: element.getAttribute('scope'), style: element.getAttribute('style') });
571
567
  },
572
568
  },
573
569
  {
@@ -580,6 +576,10 @@ const nodes = [
580
576
  };
581
577
  },
582
578
  },
579
+ {
580
+ tag: 'colgroup',
581
+ node: 'table_colgroup',
582
+ },
583
583
  {
584
584
  tag: 'xref[ref-type="bibr"]',
585
585
  node: 'citation',
@@ -238,18 +238,27 @@ export const jatsBodyTransformations = {
238
238
  fixTables(body, createElement) {
239
239
  const tables = body.querySelectorAll('table-wrap > table');
240
240
  tables.forEach((table) => {
241
+ var _a;
242
+ const colgroup = table.querySelector('colgroup');
243
+ const cols = table.querySelectorAll('col');
244
+ if (!colgroup && table.firstChild && cols.length > 0) {
245
+ const colgroup = createElement('colgroup');
246
+ for (const col of cols) {
247
+ colgroup.appendChild(col);
248
+ }
249
+ (_a = table.parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore(colgroup, table);
250
+ }
251
+ const rows = table.querySelectorAll('tr');
252
+ for (const row of rows) {
253
+ table.appendChild(row);
254
+ }
255
+ const thead = table.querySelector('thead');
256
+ if (thead) {
257
+ table.removeChild(thead);
258
+ }
241
259
  const tbody = table.querySelector('tbody');
242
260
  if (tbody) {
243
- const headerRow = table.querySelector('thead > tr');
244
- if (!headerRow) {
245
- const tr = createElement('tr');
246
- tbody.insertBefore(tr, tbody.firstElementChild);
247
- }
248
- const footerRow = table.querySelector('tfoot > tr');
249
- if (!footerRow) {
250
- const tr = createElement('tr');
251
- tbody.appendChild(tr);
252
- }
261
+ table.removeChild(tbody);
253
262
  }
254
263
  });
255
264
  },
@@ -607,7 +607,7 @@ export class JATSExporter {
607
607
  const getModel = (id) => id ? this.modelMap.get(id) : undefined;
608
608
  const nodes = {
609
609
  table_header: (node) => [
610
- node.attrs.celltype,
610
+ 'th',
611
611
  Object.assign(Object.assign({ valign: node.attrs.valign, align: node.attrs.align, scope: node.attrs.scope, style: node.attrs.style }, (node.attrs.rowspan > 1 && { rowspan: node.attrs.rowspan })), (node.attrs.colspan > 1 && { colspan: node.attrs.colspan })),
612
612
  0,
613
613
  ],
@@ -871,7 +871,7 @@ export class JATSExporter {
871
871
  return element;
872
872
  },
873
873
  table_cell: (node) => [
874
- node.attrs.celltype,
874
+ 'td',
875
875
  Object.assign(Object.assign({ valign: node.attrs.valign, align: node.attrs.align, scope: node.attrs.scope, style: node.attrs.style }, (node.attrs.rowspan > 1 && { rowspan: node.attrs.rowspan })), (node.attrs.colspan > 1 && { colspan: node.attrs.colspan })),
876
876
  0,
877
877
  ],
@@ -952,6 +952,26 @@ export class JATSExporter {
952
952
  element.appendChild(this.serializeNode(childNode));
953
953
  }
954
954
  };
955
+ const appendTable = (element, node) => {
956
+ const tableNode = findChildNodeOfType(node, node.type.schema.nodes.table);
957
+ const colGroupNode = findChildNodeOfType(node, node.type.schema.nodes.table_colgroup);
958
+ if (!tableNode) {
959
+ return;
960
+ }
961
+ const table = this.serializeNode(tableNode);
962
+ const tbodyElement = document.createElement('tbody');
963
+ while (table.firstChild) {
964
+ const child = table.firstChild;
965
+ table.removeChild(child);
966
+ tbodyElement.appendChild(child);
967
+ }
968
+ table.appendChild(tbodyElement);
969
+ if (colGroupNode) {
970
+ const colGroup = this.serializeNode(colGroupNode);
971
+ table.insertBefore(colGroup, table.firstChild);
972
+ }
973
+ element.appendChild(table);
974
+ };
955
975
  const createFigureElement = (node, nodeName, contentNodeType, figType) => {
956
976
  const element = createElement(node, nodeName);
957
977
  if (figType) {
@@ -972,7 +992,7 @@ export class JATSExporter {
972
992
  const element = createElement(node, nodeName);
973
993
  appendLabels(element, node);
974
994
  appendChildNodeOfType(element, node, node.type.schema.nodes.figcaption);
975
- appendChildNodeOfType(element, node, node.type.schema.nodes.table);
995
+ appendTable(element, node);
976
996
  appendChildNodeOfType(element, node, node.type.schema.nodes.table_element_footer);
977
997
  if (isExecutableNodeType(node.type)) {
978
998
  processExecutableNode(node, element);
@@ -13,21 +13,83 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { tableNodes } from 'prosemirror-tables';
16
+ import { tableNodes as createTableNodes, } from 'prosemirror-tables';
17
+ import { getTableCellStyles, serializeTableCellStyles, } from '../../lib/table-cell-styles';
17
18
  const tableOptions = {
18
19
  tableGroup: 'block',
19
20
  cellContent: 'inline*',
20
21
  cellAttributes: {
21
- placeholder: { default: 'Data' },
22
- styles: { default: {} },
23
- valign: { default: null },
24
- align: { default: null },
25
- scope: { default: null },
26
- style: { default: null },
22
+ placeholder: {
23
+ default: 'Data',
24
+ getFromDOM(dom) {
25
+ return dom.getAttribute('data-placeholder-text') || '';
26
+ },
27
+ setDOMAttr(value, attrs) {
28
+ if (value) {
29
+ attrs['data-placeholder-text'] = value;
30
+ }
31
+ },
32
+ },
33
+ styles: {
34
+ default: {},
35
+ getFromDOM(dom) {
36
+ return getTableCellStyles(dom.style);
37
+ },
38
+ setDOMAttr(value, attrs) {
39
+ const styleString = serializeTableCellStyles(value);
40
+ if (styleString) {
41
+ attrs['style'] = value;
42
+ }
43
+ },
44
+ },
45
+ valign: {
46
+ default: null,
47
+ getFromDOM(dom) {
48
+ return dom.getAttribute('valign');
49
+ },
50
+ setDOMAttr(value, attrs) {
51
+ if (value) {
52
+ attrs['valign'] = value;
53
+ }
54
+ },
55
+ },
56
+ align: {
57
+ default: null,
58
+ getFromDOM(dom) {
59
+ return dom.getAttribute('align');
60
+ },
61
+ setDOMAttr(value, attrs) {
62
+ if (value) {
63
+ attrs['align'] = value;
64
+ }
65
+ },
66
+ },
67
+ scope: {
68
+ default: null,
69
+ getFromDOM(dom) {
70
+ return dom.getAttribute('scope');
71
+ },
72
+ setDOMAttr(value, attrs) {
73
+ if (value) {
74
+ attrs['scope'] = value;
75
+ }
76
+ },
77
+ },
78
+ style: {
79
+ default: null,
80
+ getFromDOM(dom) {
81
+ return dom.getAttribute('style');
82
+ },
83
+ setDOMAttr(value, attrs) {
84
+ if (value) {
85
+ attrs['style'] = value;
86
+ }
87
+ },
88
+ },
27
89
  },
28
90
  };
29
- export const tnodes = tableNodes(tableOptions);
30
- export const table = Object.assign(Object.assign({}, tnodes.table), { attrs: Object.assign(Object.assign({}, tnodes.table.attrs), { id: { default: '' } }) });
31
- export const tableRow = tnodes.table_row;
32
- export const tableCell = tnodes.table_cell;
33
- export const tableHeader = tnodes.table_header;
91
+ export const tableNodes = createTableNodes(tableOptions);
92
+ export const table = Object.assign(Object.assign({}, tableNodes.table), { attrs: Object.assign(Object.assign({}, tableNodes.table.attrs), { id: { default: '' }, dataTracked: { default: null }, comments: { default: null } }) });
93
+ export const tableCell = tableNodes.table_cell;
94
+ export const tableRow = tableNodes.table_row;
95
+ export const tableHeader = tableNodes.table_header;
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  export const tableElement = {
17
- content: '(table | placeholder) table_element_footer? figcaption? (listing | placeholder)',
17
+ content: 'table_colgroup? (table | placeholder) table_element_footer? figcaption? (listing | placeholder)',
18
18
  attrs: {
19
19
  id: { default: '' },
20
20
  paragraphStyle: { default: '' },
@@ -548,15 +548,19 @@ export class Decoder {
548
548
  },
549
549
  [ObjectTypes.Table]: (data) => {
550
550
  const model = data;
551
- return this.parseContents(model.contents, undefined, [], {
551
+ const comments = this.createCommentNodes(model);
552
+ comments.forEach((c) => this.comments.set(c.attrs.id, c));
553
+ return this.parseContents(model.contents, undefined, this.getComments(model), {
552
554
  topNode: schema.nodes.table.create({
553
555
  id: model._id,
556
+ comments: comments.map((c) => c.attrs.id),
554
557
  }),
555
558
  });
556
559
  },
557
560
  [ObjectTypes.TableElement]: (data) => {
558
561
  const model = data;
559
562
  const table = this.createTable(model);
563
+ const tableColGroup = this.createTableColGroup(model);
560
564
  const tableElementFooter = this.createTableElementFooter(model);
561
565
  const figcaption = this.getFigcaption(model);
562
566
  const comments = this.createCommentNodes(model);
@@ -564,6 +568,9 @@ export class Decoder {
564
568
  const content = tableElementFooter
565
569
  ? [table, tableElementFooter, figcaption]
566
570
  : [table, figcaption];
571
+ if (tableColGroup) {
572
+ content.unshift(tableColGroup);
573
+ }
567
574
  if (model.listingID) {
568
575
  const listing = this.createListing(model.listingID);
569
576
  content.push(listing);
@@ -777,6 +784,15 @@ export class Decoder {
777
784
  }
778
785
  return table;
779
786
  }
787
+ createTableColGroup(model) {
788
+ const tableId = model.containedObjectID;
789
+ const tableModel = this.getModel(tableId);
790
+ if (tableModel) {
791
+ return this.parseContents(tableModel.contents, undefined, [], {
792
+ topNode: schema.nodes.table_colgroup.create(),
793
+ });
794
+ }
795
+ }
780
796
  createTableElementFooter(model) {
781
797
  const tableElementFooterID = model.tableElementFooterID;
782
798
  if (!tableElementFooterID) {
@@ -91,9 +91,28 @@ const buildTableSection = (tagName, inputRows, parent) => {
91
91
  }
92
92
  return section;
93
93
  };
94
+ function buildTableColGroup(cols) {
95
+ if (cols.length === 0) {
96
+ return undefined;
97
+ }
98
+ const colgroup = document.createElement('colgroup');
99
+ for (const inputCol of cols) {
100
+ const col = document.createElement('col');
101
+ for (const attribute of inputCol.attributes) {
102
+ col.setAttribute(attribute.name, attribute.value);
103
+ }
104
+ colgroup.appendChild(inputCol);
105
+ }
106
+ return colgroup;
107
+ }
94
108
  const tableContents = (node, parent) => {
95
109
  const input = serializer.serializeNode(node);
110
+ const parentInput = serializer.serializeNode(parent);
96
111
  const output = document.createElement('table');
112
+ const colgroup = buildTableColGroup(Array.from(parentInput.querySelectorAll('col')));
113
+ if (colgroup) {
114
+ output.appendChild(colgroup);
115
+ }
97
116
  output.setAttribute('id', parent.attrs.id);
98
117
  output.classList.add('MPElement');
99
118
  if (parent.attrs.tableStyle) {
@@ -14,12 +14,18 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import { TableNodes } from 'prosemirror-tables';
17
- export declare const tnodes: TableNodes;
17
+ export declare const tableNodes: TableNodes;
18
18
  export declare const table: {
19
19
  attrs: {
20
20
  id: {
21
21
  default: string;
22
22
  };
23
+ dataTracked: {
24
+ default: null;
25
+ };
26
+ comments: {
27
+ default: null;
28
+ };
23
29
  };
24
30
  content?: string | undefined;
25
31
  marks?: string | undefined;
@@ -39,6 +45,6 @@ export declare const table: {
39
45
  toDebugString?: ((node: import("prosemirror-model").Node) => string) | undefined;
40
46
  leafText?: ((node: import("prosemirror-model").Node) => string) | undefined;
41
47
  };
42
- export declare const tableRow: import("prosemirror-model").NodeSpec;
43
48
  export declare const tableCell: import("prosemirror-model").NodeSpec;
49
+ export declare const tableRow: import("prosemirror-model").NodeSpec;
44
50
  export declare const tableHeader: import("prosemirror-model").NodeSpec;
@@ -43,6 +43,7 @@ export declare class Decoder {
43
43
  private getManuscriptID;
44
44
  private getFigcaption;
45
45
  private createTable;
46
+ private createTableColGroup;
46
47
  private createTableElementFooter;
47
48
  private createListing;
48
49
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@manuscripts/transform",
3
3
  "description": "ProseMirror transformer for Manuscripts applications",
4
- "version": "2.1.1-LEAN-3336-6",
4
+ "version": "2.1.1-LEAN-3336-8",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-transform",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -1,16 +0,0 @@
1
- "use strict";
2
- /*!
3
- * © 2024 Atypon Systems LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
@@ -1,16 +0,0 @@
1
- "use strict";
2
- /*!
3
- * © 2024 Atypon Systems LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
@@ -1,15 +0,0 @@
1
- /*!
2
- * © 2024 Atypon Systems LLC
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */