@manuscripts/transform 2.1.1-LEAN-3336-7 → 2.1.1-LEAN-3336-9

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.
@@ -582,6 +582,10 @@ const nodes = [
582
582
  };
583
583
  },
584
584
  },
585
+ {
586
+ tag: 'colgroup',
587
+ node: 'table_colgroup',
588
+ },
585
589
  {
586
590
  tag: 'xref[ref-type="bibr"]',
587
591
  node: 'citation',
@@ -73,8 +73,7 @@ const parseJATSBody = (doc, body, references) => {
73
73
  }
74
74
  const replacements = new Map(references === null || references === void 0 ? void 0 : references.IDs);
75
75
  (0, jats_parser_utils_1.updateDocumentIDs)(node, replacements);
76
- const models = (0, transformer_1.encode)(node);
77
- return models.values();
76
+ return (0, transformer_1.encode)(node).values();
78
77
  };
79
78
  exports.parseJATSBody = parseJATSBody;
80
79
  const createBibliographyModels = (references) => {
@@ -967,7 +967,7 @@ class JATSExporter {
967
967
  return;
968
968
  }
969
969
  const table = this.serializeNode(tableNode);
970
- const tbodyElement = document.createElement('tbody');
970
+ const tbodyElement = this.document.createElement('tbody');
971
971
  while (table.firstChild) {
972
972
  const child = table.firstChild;
973
973
  table.removeChild(child);
@@ -15,7 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.tableHeader = exports.tableRow = exports.tableCell = exports.table = exports.tableNodes = void 0;
18
+ exports.tableCell = exports.tableHeader = exports.tableRow = exports.table = exports.tableNodes = void 0;
19
19
  const prosemirror_tables_1 = require("prosemirror-tables");
20
20
  const table_cell_styles_1 = require("../../lib/table-cell-styles");
21
21
  const tableOptions = {
@@ -45,6 +45,14 @@ const tableOptions = {
45
45
  }
46
46
  },
47
47
  },
48
+ class: {
49
+ default: null,
50
+ setDOMAttr(value, attrs) {
51
+ if (value) {
52
+ attrs['class'] = value;
53
+ }
54
+ },
55
+ },
48
56
  valign: {
49
57
  default: null,
50
58
  getFromDOM(dom) {
@@ -92,7 +100,27 @@ const tableOptions = {
92
100
  },
93
101
  };
94
102
  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: '' } }) });
96
- exports.tableCell = exports.tableNodes.table_cell;
103
+ 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 } }) });
104
+ const tableCell = exports.tableNodes.table_cell;
105
+ exports.tableCell = tableCell;
106
+ tableCell.toDOM = (node) => {
107
+ if (!node.textContent) {
108
+ node.attrs.class = 'placeholder';
109
+ }
110
+ if (exports.tableNodes.table_cell.toDOM) {
111
+ return exports.tableNodes.table_cell.toDOM(node);
112
+ }
113
+ return ['td'];
114
+ };
115
+ const tableHeader = exports.tableNodes.table_cell;
116
+ exports.tableHeader = tableHeader;
117
+ tableHeader.toDOM = (node) => {
118
+ if (!node.textContent) {
119
+ node.attrs.class = 'placeholder';
120
+ }
121
+ if (exports.tableNodes.table_header.toDOM) {
122
+ return exports.tableNodes.table_header.toDOM(node);
123
+ }
124
+ return ['th'];
125
+ };
97
126
  exports.tableRow = exports.tableNodes.table_row;
98
- exports.tableHeader = exports.tableNodes.table_header;
@@ -557,9 +557,12 @@ 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
  },
@@ -793,11 +796,12 @@ class Decoder {
793
796
  createTableColGroup(model) {
794
797
  const tableId = model.containedObjectID;
795
798
  const tableModel = this.getModel(tableId);
796
- if (tableModel) {
797
- return this.parseContents(tableModel.contents, undefined, [], {
798
- topNode: schema_1.schema.nodes.table_colgroup.create(),
799
- });
799
+ if (!tableModel || !tableModel.contents.includes('<colgroup>')) {
800
+ return undefined;
800
801
  }
802
+ return this.parseContents(tableModel.contents, undefined, [], {
803
+ topNode: schema_1.schema.nodes.table_colgroup.create(),
804
+ });
801
805
  }
802
806
  createTableElementFooter(model) {
803
807
  const tableElementFooterID = model.tableElementFooterID;
@@ -576,6 +576,10 @@ const nodes = [
576
576
  };
577
577
  },
578
578
  },
579
+ {
580
+ tag: 'colgroup',
581
+ node: 'table_colgroup',
582
+ },
579
583
  {
580
584
  tag: 'xref[ref-type="bibr"]',
581
585
  node: 'citation',
@@ -69,8 +69,7 @@ export const parseJATSBody = (doc, body, references) => {
69
69
  }
70
70
  const replacements = new Map(references === null || references === void 0 ? void 0 : references.IDs);
71
71
  updateDocumentIDs(node, replacements);
72
- const models = encode(node);
73
- return models.values();
72
+ return encode(node).values();
74
73
  };
75
74
  const createBibliographyModels = (references) => {
76
75
  const models = [];
@@ -959,7 +959,7 @@ export class JATSExporter {
959
959
  return;
960
960
  }
961
961
  const table = this.serializeNode(tableNode);
962
- const tbodyElement = document.createElement('tbody');
962
+ const tbodyElement = this.document.createElement('tbody');
963
963
  while (table.firstChild) {
964
964
  const child = table.firstChild;
965
965
  table.removeChild(child);
@@ -42,6 +42,14 @@ const tableOptions = {
42
42
  }
43
43
  },
44
44
  },
45
+ class: {
46
+ default: null,
47
+ setDOMAttr(value, attrs) {
48
+ if (value) {
49
+ attrs['class'] = value;
50
+ }
51
+ },
52
+ },
45
53
  valign: {
46
54
  default: null,
47
55
  getFromDOM(dom) {
@@ -89,7 +97,26 @@ const tableOptions = {
89
97
  },
90
98
  };
91
99
  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: '' } }) });
93
- export const tableCell = tableNodes.table_cell;
100
+ 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 } }) });
101
+ const tableCell = tableNodes.table_cell;
102
+ tableCell.toDOM = (node) => {
103
+ if (!node.textContent) {
104
+ node.attrs.class = 'placeholder';
105
+ }
106
+ if (tableNodes.table_cell.toDOM) {
107
+ return tableNodes.table_cell.toDOM(node);
108
+ }
109
+ return ['td'];
110
+ };
111
+ const tableHeader = tableNodes.table_cell;
112
+ tableHeader.toDOM = (node) => {
113
+ if (!node.textContent) {
114
+ node.attrs.class = 'placeholder';
115
+ }
116
+ if (tableNodes.table_header.toDOM) {
117
+ return tableNodes.table_header.toDOM(node);
118
+ }
119
+ return ['th'];
120
+ };
94
121
  export const tableRow = tableNodes.table_row;
95
- export const tableHeader = tableNodes.table_header;
122
+ export { tableHeader, tableCell };
@@ -548,9 +548,12 @@ 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
  },
@@ -784,11 +787,12 @@ export class Decoder {
784
787
  createTableColGroup(model) {
785
788
  const tableId = model.containedObjectID;
786
789
  const tableModel = this.getModel(tableId);
787
- if (tableModel) {
788
- return this.parseContents(tableModel.contents, undefined, [], {
789
- topNode: schema.nodes.table_colgroup.create(),
790
- });
790
+ if (!tableModel || !tableModel.contents.includes('<colgroup>')) {
791
+ return undefined;
791
792
  }
793
+ return this.parseContents(tableModel.contents, undefined, [], {
794
+ topNode: schema.nodes.table_colgroup.create(),
795
+ });
792
796
  }
793
797
  createTableElementFooter(model) {
794
798
  const tableElementFooterID = model.tableElementFooterID;
@@ -20,6 +20,12 @@ export declare const table: {
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,7 @@ 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 tableCell: import("prosemirror-model").NodeSpec;
48
+ declare const tableCell: import("prosemirror-model").NodeSpec;
49
+ declare const tableHeader: import("prosemirror-model").NodeSpec;
43
50
  export declare const tableRow: import("prosemirror-model").NodeSpec;
44
- export declare const tableHeader: import("prosemirror-model").NodeSpec;
51
+ export { tableHeader, tableCell };
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-7",
4
+ "version": "2.1.1-LEAN-3336-9",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-transform",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -35,7 +35,7 @@
35
35
  "jszip": "^3.10.1",
36
36
  "mathjax-full": "^3.2.2",
37
37
  "mime": "^3.0.0",
38
- "prosemirror-model": "^1.18.3",
38
+ "prosemirror-model": "^1.8.1",
39
39
  "prosemirror-tables": "^1.3.5",
40
40
  "uuid": "^9.0.0",
41
41
  "w3c-xmlserializer": "^4.0.0"
@@ -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
- */