@manuscripts/transform 2.10.0-LEAN-3577 → 3.0.0

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 (205) hide show
  1. package/dist/cjs/index.js +9 -7
  2. package/dist/cjs/jats/{jats-exporter.js → exporter/jats-exporter.js} +286 -416
  3. package/dist/cjs/jats/{jats-versions.js → exporter/jats-versions.js} +1 -3
  4. package/dist/cjs/{transformer → jats/exporter}/labels.js +7 -19
  5. package/dist/cjs/{transformer/filename.js → jats/importer/create-article-node.js} +12 -9
  6. package/dist/cjs/jats/importer/jats-body-transformations.js +22 -1
  7. package/dist/cjs/jats/importer/jats-comments.js +48 -110
  8. package/dist/cjs/jats/importer/{jats-body-dom-parser.js → jats-dom-parser.js} +364 -11
  9. package/dist/cjs/jats/importer/jats-journal-meta-parser.js +11 -1
  10. package/dist/cjs/jats/importer/jats-parser-utils.js +52 -4
  11. package/dist/cjs/jats/importer/jats-transformations.js +389 -0
  12. package/dist/cjs/jats/importer/parse-jats-article.js +43 -100
  13. package/dist/cjs/jats/index.js +7 -7
  14. package/dist/cjs/{transformer/models.js → lib/deafults.js} +3 -1
  15. package/dist/cjs/lib/utils.js +3 -1
  16. package/dist/cjs/schema/index.js +10 -0
  17. package/dist/cjs/schema/migration/migrate.js +3 -9
  18. package/dist/cjs/schema/migration/migration-script.js +1 -1
  19. package/dist/cjs/schema/migration/migration-scripts/1.2.5.js +2 -2
  20. package/dist/cjs/schema/migration/migration-scripts/2.3.22.js +28 -0
  21. package/dist/cjs/schema/migration/migration-scripts/index.js +3 -2
  22. package/dist/cjs/schema/nodes/author_notes.js +9 -2
  23. package/dist/cjs/schema/nodes/award.js +38 -0
  24. package/dist/cjs/{transformer/serializer.js → schema/nodes/awards.js} +20 -7
  25. package/dist/cjs/schema/nodes/backmatter.js +3 -2
  26. package/dist/cjs/schema/nodes/box_element.js +55 -0
  27. package/dist/cjs/schema/nodes/contributors.js +1 -1
  28. package/dist/cjs/schema/nodes/corresp.js +13 -2
  29. package/dist/cjs/schema/nodes/equation_element.js +0 -1
  30. package/dist/cjs/schema/nodes/figure_element.js +0 -1
  31. package/dist/cjs/schema/nodes/footnote.js +0 -1
  32. package/dist/cjs/schema/nodes/footnotes_section.js +1 -1
  33. package/dist/cjs/schema/nodes/highlight_marker.js +0 -4
  34. package/dist/cjs/schema/nodes/inline_equation.js +0 -1
  35. package/dist/cjs/schema/nodes/inline_footnote.js +1 -0
  36. package/dist/cjs/schema/nodes/keyword.js +0 -1
  37. package/dist/cjs/schema/nodes/listing.js +0 -1
  38. package/dist/cjs/schema/nodes/listing_element.js +0 -1
  39. package/dist/cjs/schema/nodes/manuscript.js +4 -1
  40. package/dist/cjs/schema/nodes/paragraph.js +0 -1
  41. package/dist/cjs/schema/nodes/section.js +0 -1
  42. package/dist/cjs/schema/nodes/table_element.js +1 -2
  43. package/dist/cjs/schema/nodes/title.js +1 -0
  44. package/dist/cjs/transformer/id.js +1 -5
  45. package/dist/cjs/transformer/index.js +0 -18
  46. package/dist/cjs/transformer/node-names.js +1 -0
  47. package/dist/cjs/transformer/node-types.js +1 -0
  48. package/dist/cjs/transformer/section-category.js +8 -0
  49. package/dist/cjs/version.js +1 -1
  50. package/dist/es/index.js +6 -5
  51. package/dist/es/jats/{jats-exporter.js → exporter/jats-exporter.js} +281 -411
  52. package/dist/es/jats/{jats-versions.js → exporter/jats-versions.js} +0 -1
  53. package/dist/es/{transformer → jats/exporter}/labels.js +7 -19
  54. package/dist/{cjs/transformer/model-map.js → es/jats/importer/create-article-node.js} +10 -10
  55. package/dist/es/jats/importer/jats-body-transformations.js +22 -1
  56. package/dist/es/jats/importer/jats-comments.js +49 -107
  57. package/dist/es/jats/importer/{jats-body-dom-parser.js → jats-dom-parser.js} +364 -11
  58. package/dist/es/jats/importer/jats-journal-meta-parser.js +9 -0
  59. package/dist/es/jats/importer/jats-parser-utils.js +54 -6
  60. package/dist/es/jats/importer/jats-transformations.js +370 -0
  61. package/dist/es/jats/importer/parse-jats-article.js +43 -98
  62. package/dist/es/jats/index.js +5 -3
  63. package/dist/{types/transformer/timestamp.d.ts → es/lib/deafults.js} +2 -2
  64. package/dist/es/lib/utils.js +1 -0
  65. package/dist/es/schema/index.js +10 -0
  66. package/dist/es/schema/migration/migrate.js +3 -9
  67. package/dist/es/schema/migration/migration-script.js +1 -1
  68. package/dist/es/schema/migration/migration-scripts/1.2.5.js +2 -2
  69. package/dist/es/schema/migration/migration-scripts/2.3.22.js +26 -0
  70. package/dist/es/schema/migration/migration-scripts/index.js +3 -2
  71. package/dist/es/schema/nodes/author_notes.js +9 -2
  72. package/dist/es/{transformer/__tests__/__helpers__/doc.js → schema/nodes/award.js} +19 -14
  73. package/dist/es/{transformer/model-map.js → schema/nodes/awards.js} +17 -7
  74. package/dist/es/schema/nodes/backmatter.js +3 -2
  75. package/dist/es/schema/nodes/box_element.js +52 -0
  76. package/dist/es/schema/nodes/contributors.js +1 -1
  77. package/dist/es/schema/nodes/corresp.js +11 -1
  78. package/dist/es/schema/nodes/equation_element.js +0 -1
  79. package/dist/es/schema/nodes/figure_element.js +0 -1
  80. package/dist/es/schema/nodes/footnote.js +0 -1
  81. package/dist/es/schema/nodes/footnotes_section.js +1 -1
  82. package/dist/es/schema/nodes/highlight_marker.js +0 -4
  83. package/dist/es/schema/nodes/inline_equation.js +0 -1
  84. package/dist/es/schema/nodes/inline_footnote.js +1 -0
  85. package/dist/es/schema/nodes/keyword.js +0 -1
  86. package/dist/es/schema/nodes/listing.js +0 -1
  87. package/dist/es/schema/nodes/listing_element.js +0 -1
  88. package/dist/es/schema/nodes/manuscript.js +4 -1
  89. package/dist/es/schema/nodes/paragraph.js +0 -1
  90. package/dist/es/schema/nodes/section.js +0 -1
  91. package/dist/es/schema/nodes/table_element.js +1 -2
  92. package/dist/es/schema/nodes/title.js +1 -0
  93. package/dist/es/transformer/id.js +0 -3
  94. package/dist/es/transformer/index.js +0 -16
  95. package/dist/es/transformer/node-names.js +1 -0
  96. package/dist/es/transformer/node-types.js +1 -0
  97. package/dist/es/transformer/section-category.js +8 -0
  98. package/dist/es/version.js +1 -1
  99. package/dist/types/index.d.ts +6 -5
  100. package/dist/types/jats/{jats-exporter.d.ts → exporter/jats-exporter.d.ts} +15 -29
  101. package/dist/types/jats/{jats-versions.d.ts → exporter/jats-versions.d.ts} +0 -1
  102. package/dist/types/{transformer → jats/exporter}/labels.d.ts +2 -3
  103. package/dist/{es/transformer/footnote-category.js → types/jats/importer/create-article-node.d.ts} +3 -2
  104. package/dist/types/jats/importer/jats-body-transformations.d.ts +1 -0
  105. package/dist/types/jats/importer/jats-comments.d.ts +2 -15
  106. package/dist/types/jats/importer/{jats-body-dom-parser.d.ts → jats-dom-parser.d.ts} +1 -1
  107. package/dist/types/jats/importer/jats-journal-meta-parser.d.ts +9 -0
  108. package/dist/types/jats/importer/jats-parser-utils.d.ts +2 -2
  109. package/dist/types/jats/importer/jats-transformations.d.ts +32 -0
  110. package/dist/types/jats/importer/parse-jats-article.d.ts +12 -5
  111. package/dist/types/jats/index.d.ts +5 -3
  112. package/dist/types/jats/types.d.ts +1 -0
  113. package/dist/{es/transformer/models.js → types/lib/deafults.d.ts} +2 -2
  114. package/dist/types/lib/utils.d.ts +1 -0
  115. package/dist/types/schema/index.d.ts +4 -0
  116. package/dist/types/schema/migration/migration-script.d.ts +1 -1
  117. package/dist/types/schema/migration/migration-scripts/1.2.5.d.ts +1 -1
  118. package/dist/types/schema/migration/migration-scripts/2.3.22.d.ts +8 -0
  119. package/dist/types/schema/migration/migration-scripts/index.d.ts +3 -2
  120. package/dist/types/{transformer/footnotes-order.d.ts → schema/nodes/award.d.ts} +14 -7
  121. package/dist/{cjs/transformer/footnote-category.js → types/schema/nodes/awards.d.ts} +12 -6
  122. package/dist/types/schema/nodes/bibliography_item.d.ts +3 -3
  123. package/dist/{es/transformer/filename.js → types/schema/nodes/box_element.d.ts} +11 -8
  124. package/dist/types/schema/nodes/contributor.d.ts +10 -0
  125. package/dist/types/schema/nodes/contributors.d.ts +8 -0
  126. package/dist/types/schema/nodes/corresp.d.ts +1 -0
  127. package/dist/types/schema/nodes/equation_element.d.ts +0 -2
  128. package/dist/types/schema/nodes/figure_element.d.ts +0 -2
  129. package/dist/types/schema/nodes/footnote.d.ts +0 -2
  130. package/dist/types/schema/nodes/highlight_marker.d.ts +0 -2
  131. package/dist/types/schema/nodes/inline_equation.d.ts +0 -2
  132. package/dist/types/schema/nodes/keyword.d.ts +0 -2
  133. package/dist/types/schema/nodes/keyword_group.d.ts +1 -0
  134. package/dist/types/schema/nodes/listing.d.ts +0 -2
  135. package/dist/types/schema/nodes/listing_element.d.ts +0 -2
  136. package/dist/types/schema/nodes/manuscript.d.ts +8 -4
  137. package/dist/types/schema/nodes/paragraph.d.ts +0 -2
  138. package/dist/types/schema/nodes/section.d.ts +0 -2
  139. package/dist/types/schema/nodes/table_element.d.ts +0 -2
  140. package/dist/types/schema/nodes/title.d.ts +1 -3
  141. package/dist/types/schema/types.d.ts +1 -1
  142. package/dist/types/transformer/id.d.ts +0 -3
  143. package/dist/types/transformer/index.d.ts +0 -16
  144. package/dist/types/transformer/section-category.d.ts +2 -2
  145. package/dist/types/version.d.ts +1 -1
  146. package/package.json +7 -8
  147. package/dist/cjs/__tests__/data/project-dump.json +0 -824
  148. package/dist/cjs/jats/importer/index.js +0 -22
  149. package/dist/cjs/jats/importer/jats-front-parser.js +0 -321
  150. package/dist/cjs/jats/importer/jats-reference-parser.js +0 -130
  151. package/dist/cjs/jats/importer/jats-references.js +0 -34
  152. package/dist/cjs/transformer/__tests__/__helpers__/doc.js +0 -37
  153. package/dist/cjs/transformer/builders.js +0 -219
  154. package/dist/cjs/transformer/decode.js +0 -878
  155. package/dist/cjs/transformer/document-object-types.js +0 -31
  156. package/dist/cjs/transformer/encode.js +0 -654
  157. package/dist/cjs/transformer/footnotes-order.js +0 -60
  158. package/dist/cjs/transformer/highlight-markers.js +0 -138
  159. package/dist/cjs/transformer/html.js +0 -401
  160. package/dist/cjs/transformer/manuscript-dependencies.js +0 -21
  161. package/dist/cjs/transformer/object-types.js +0 -57
  162. package/dist/cjs/transformer/project-bundle.js +0 -94
  163. package/dist/cjs/transformer/timestamp.js +0 -20
  164. package/dist/cjs/transformer/update-identifiers.js +0 -93
  165. package/dist/es/__tests__/data/project-dump.json +0 -824
  166. package/dist/es/jats/importer/index.js +0 -16
  167. package/dist/es/jats/importer/jats-front-parser.js +0 -315
  168. package/dist/es/jats/importer/jats-reference-parser.js +0 -127
  169. package/dist/es/jats/importer/jats-references.js +0 -30
  170. package/dist/es/transformer/builders.js +0 -186
  171. package/dist/es/transformer/decode.js +0 -868
  172. package/dist/es/transformer/document-object-types.js +0 -28
  173. package/dist/es/transformer/encode.js +0 -644
  174. package/dist/es/transformer/footnotes-order.js +0 -55
  175. package/dist/es/transformer/highlight-markers.js +0 -132
  176. package/dist/es/transformer/html.js +0 -394
  177. package/dist/es/transformer/manuscript-dependencies.js +0 -17
  178. package/dist/es/transformer/object-types.js +0 -52
  179. package/dist/es/transformer/project-bundle.js +0 -85
  180. package/dist/es/transformer/serializer.js +0 -17
  181. package/dist/es/transformer/timestamp.js +0 -16
  182. package/dist/es/transformer/update-identifiers.js +0 -87
  183. package/dist/types/jats/importer/index.d.ts +0 -16
  184. package/dist/types/jats/importer/jats-front-parser.d.ts +0 -84
  185. package/dist/types/jats/importer/jats-reference-parser.d.ts +0 -19
  186. package/dist/types/jats/importer/jats-references.d.ts +0 -12
  187. package/dist/types/transformer/__tests__/__helpers__/doc.d.ts +0 -18
  188. package/dist/types/transformer/builders.d.ts +0 -61
  189. package/dist/types/transformer/decode.d.ts +0 -50
  190. package/dist/types/transformer/document-object-types.d.ts +0 -17
  191. package/dist/types/transformer/encode.d.ts +0 -29
  192. package/dist/types/transformer/filename.d.ts +0 -16
  193. package/dist/types/transformer/footnote-category.d.ts +0 -17
  194. package/dist/types/transformer/highlight-markers.d.ts +0 -31
  195. package/dist/types/transformer/html.d.ts +0 -36
  196. package/dist/types/transformer/manuscript-dependencies.d.ts +0 -4
  197. package/dist/types/transformer/model-map.d.ts +0 -19
  198. package/dist/types/transformer/models.d.ts +0 -48
  199. package/dist/types/transformer/object-types.d.ts +0 -30
  200. package/dist/types/transformer/project-bundle.d.ts +0 -30
  201. package/dist/types/transformer/serializer.d.ts +0 -19
  202. package/dist/types/transformer/update-identifiers.d.ts +0 -23
  203. package/dist/types/types.d.ts +0 -2
  204. /package/dist/cjs/{types.js → jats/types.js} +0 -0
  205. /package/dist/es/{types.js → jats/types.js} +0 -0
@@ -18,11 +18,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
18
18
  return (mod && mod.__esModule) ? mod : { "default": mod };
19
19
  };
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.jatsBodyDOMParser = void 0;
21
+ exports.jatsDOMParser = void 0;
22
+ const json_schema_1 = require("@manuscripts/json-schema");
22
23
  const mime_1 = __importDefault(require("mime"));
23
24
  const prosemirror_model_1 = require("prosemirror-model");
25
+ const utils_1 = require("../../lib/utils");
24
26
  const schema_1 = require("../../schema");
25
27
  const transformer_1 = require("../../transformer");
28
+ const jats_comments_1 = require("./jats-comments");
29
+ const jats_parser_utils_1 = require("./jats-parser-utils");
26
30
  const XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
27
31
  const chooseContentType = (graphicNode) => {
28
32
  if (graphicNode) {
@@ -37,6 +41,12 @@ const chooseContentType = (graphicNode) => {
37
41
  }
38
42
  }
39
43
  };
44
+ const parsePriority = (priority) => {
45
+ if (!priority) {
46
+ return undefined;
47
+ }
48
+ return parseInt(priority);
49
+ };
40
50
  const getEquationContent = (p) => {
41
51
  var _a;
42
52
  const element = p;
@@ -48,7 +58,7 @@ const getEquationContent = (p) => {
48
58
  const nodeName = child.nodeName.replace(/^[a-z]:/, '');
49
59
  switch (nodeName) {
50
60
  case 'tex-math':
51
- contents = child.innerHTML;
61
+ contents = child.textContent;
52
62
  format = 'tex';
53
63
  break;
54
64
  case 'mml:math':
@@ -59,6 +69,129 @@ const getEquationContent = (p) => {
59
69
  }
60
70
  return { id, format, contents };
61
71
  };
72
+ const getEmail = (element) => {
73
+ var _a, _b, _c;
74
+ const email = element.querySelector('email');
75
+ if (email) {
76
+ return {
77
+ href: (_a = email.getAttributeNS(XLINK_NAMESPACE, 'href')) !== null && _a !== void 0 ? _a : '',
78
+ text: (_c = (_b = email.textContent) === null || _b === void 0 ? void 0 : _b.trim()) !== null && _c !== void 0 ? _c : '',
79
+ };
80
+ }
81
+ };
82
+ const getInstitutionDetails = (element) => {
83
+ var _a;
84
+ let department = '';
85
+ let institution = '';
86
+ for (const node of element.querySelectorAll('institution')) {
87
+ const content = (_a = node.textContent) === null || _a === void 0 ? void 0 : _a.trim();
88
+ if (!content) {
89
+ continue;
90
+ }
91
+ const type = node.getAttribute('content-type');
92
+ if (type === 'dept') {
93
+ department = content;
94
+ }
95
+ else {
96
+ institution = content;
97
+ }
98
+ }
99
+ return { department, institution };
100
+ };
101
+ const getAddressLine = (element, index) => {
102
+ return (0, utils_1.getTrimmedTextContent)(element, `addr-line:nth-of-type(${index})`) || '';
103
+ };
104
+ const getHTMLContent = (node, querySelector) => {
105
+ return (0, jats_parser_utils_1.htmlFromJatsNode)(node.querySelector(querySelector));
106
+ };
107
+ const chooseBibliographyItemType = (publicationType) => {
108
+ switch (publicationType) {
109
+ case 'book':
110
+ case 'thesis':
111
+ return publicationType;
112
+ case 'journal':
113
+ default:
114
+ return 'article-journal';
115
+ }
116
+ };
117
+ const parseRef = (element) => {
118
+ const publicationType = element.getAttribute('publication-type');
119
+ const authorNodes = [
120
+ ...element.querySelectorAll('person-group[person-group-type="author"] > *'),
121
+ ];
122
+ const id = element.id;
123
+ const attrs = {
124
+ id,
125
+ type: chooseBibliographyItemType(publicationType),
126
+ };
127
+ const title = getHTMLContent(element, 'article-title');
128
+ if (title) {
129
+ attrs.title = title;
130
+ }
131
+ const mixedCitation = element.querySelector('mixed-citation');
132
+ if (authorNodes.length <= 0) {
133
+ mixedCitation === null || mixedCitation === void 0 ? void 0 : mixedCitation.childNodes.forEach((item) => {
134
+ var _a, _b, _c;
135
+ if (item.nodeType === Node.TEXT_NODE &&
136
+ ((_a = item.textContent) === null || _a === void 0 ? void 0 : _a.match(/[A-Za-z]+/g))) {
137
+ attrs.literal = (_c = (_b = mixedCitation.textContent) === null || _b === void 0 ? void 0 : _b.trim()) !== null && _c !== void 0 ? _c : '';
138
+ return attrs;
139
+ }
140
+ });
141
+ }
142
+ const source = getHTMLContent(element, 'source');
143
+ if (source) {
144
+ attrs.containerTitle = source;
145
+ }
146
+ const volume = (0, utils_1.getTrimmedTextContent)(element, 'volume');
147
+ if (volume) {
148
+ attrs.volume = volume;
149
+ }
150
+ const issue = (0, utils_1.getTrimmedTextContent)(element, 'issue');
151
+ if (issue) {
152
+ attrs.issue = issue;
153
+ }
154
+ const supplement = (0, utils_1.getTrimmedTextContent)(element, 'supplement');
155
+ if (supplement) {
156
+ attrs.supplement = supplement;
157
+ }
158
+ const fpage = (0, utils_1.getTrimmedTextContent)(element, 'fpage');
159
+ const lpage = (0, utils_1.getTrimmedTextContent)(element, 'lpage');
160
+ if (fpage) {
161
+ attrs.page = lpage ? `${fpage}-${lpage}` : fpage;
162
+ }
163
+ const year = (0, utils_1.getTrimmedTextContent)(element, 'year');
164
+ if (year) {
165
+ attrs.issued = (0, json_schema_1.buildBibliographicDate)({
166
+ 'date-parts': [[year]],
167
+ });
168
+ }
169
+ const doi = (0, utils_1.getTrimmedTextContent)(element, 'pub-id[pub-id-type="doi"]');
170
+ if (doi) {
171
+ attrs.doi = doi;
172
+ }
173
+ const authors = [];
174
+ authorNodes.forEach((authorNode) => {
175
+ var _a;
176
+ const name = (0, json_schema_1.buildBibliographicName)({});
177
+ const given = (0, utils_1.getTrimmedTextContent)(authorNode, 'given-names');
178
+ if (given) {
179
+ name.given = given;
180
+ }
181
+ const family = (0, utils_1.getTrimmedTextContent)(authorNode, 'surname');
182
+ if (family) {
183
+ name.family = family;
184
+ }
185
+ if (authorNode.nodeName === 'collab') {
186
+ name.literal = (_a = authorNode.textContent) === null || _a === void 0 ? void 0 : _a.trim();
187
+ }
188
+ authors.push(name);
189
+ });
190
+ if (authors.length) {
191
+ attrs.author = authors;
192
+ }
193
+ return attrs;
194
+ };
62
195
  const marks = [
63
196
  {
64
197
  tag: 'bold',
@@ -101,6 +234,182 @@ const marks = [
101
234
  },
102
235
  ];
103
236
  const nodes = [
237
+ {
238
+ tag: 'article',
239
+ node: 'manuscript',
240
+ getAttrs: (node) => {
241
+ var _a, _b;
242
+ const element = node;
243
+ const doi = element.querySelector('front > article-meta > article-id[pub-id-type="doi"]');
244
+ return {
245
+ doi: doi === null || doi === void 0 ? void 0 : doi.textContent,
246
+ articleType: (_a = element.getAttribute('article-type')) !== null && _a !== void 0 ? _a : '',
247
+ primaryLanguageCode: (_b = element.getAttribute('lang')) !== null && _b !== void 0 ? _b : '',
248
+ };
249
+ },
250
+ },
251
+ {
252
+ tag: 'article-title',
253
+ node: 'title',
254
+ getAttrs: (node) => {
255
+ const element = node;
256
+ return {
257
+ id: element.getAttribute('id'),
258
+ };
259
+ },
260
+ },
261
+ {
262
+ tag: 'highlight-marker',
263
+ node: 'highlight_marker',
264
+ getAttrs: (node) => {
265
+ const element = node;
266
+ return {
267
+ id: element.id,
268
+ position: element.getAttribute('position'),
269
+ };
270
+ },
271
+ },
272
+ {
273
+ tag: 'comment',
274
+ node: 'comment',
275
+ getAttrs: (node) => {
276
+ const element = node;
277
+ return {
278
+ id: element.getAttribute('id'),
279
+ target: element.getAttribute('target-id'),
280
+ contents: element.textContent,
281
+ contributions: [(0, json_schema_1.buildContribution)(jats_comments_1.DEFAULT_PROFILE_ID)],
282
+ };
283
+ },
284
+ },
285
+ {
286
+ tag: 'author-notes',
287
+ node: 'author_notes',
288
+ getAttrs: (node) => {
289
+ const element = node;
290
+ return {
291
+ id: element.getAttribute('id'),
292
+ };
293
+ },
294
+ },
295
+ {
296
+ tag: 'fn:not([fn-type])',
297
+ node: 'footnote',
298
+ context: 'author_notes/',
299
+ getAttrs: (node) => {
300
+ const element = node;
301
+ return {
302
+ id: element.getAttribute('id'),
303
+ kind: 'footnote',
304
+ };
305
+ },
306
+ },
307
+ {
308
+ tag: 'corresp',
309
+ node: 'corresp',
310
+ getAttrs: (node) => {
311
+ var _a;
312
+ const element = node;
313
+ const label = element.querySelector('label');
314
+ if (label) {
315
+ label.remove();
316
+ }
317
+ return {
318
+ id: element.getAttribute('id'),
319
+ label: (_a = label === null || label === void 0 ? void 0 : label.textContent) === null || _a === void 0 ? void 0 : _a.trim(),
320
+ };
321
+ },
322
+ getContent: (node) => {
323
+ var _a;
324
+ const element = node;
325
+ return prosemirror_model_1.Fragment.from(schema_1.schema.text(((_a = element.textContent) === null || _a === void 0 ? void 0 : _a.trim()) || ''));
326
+ },
327
+ },
328
+ {
329
+ tag: 'contrib[contrib-type="author"]',
330
+ node: 'contributor',
331
+ getAttrs: (node) => {
332
+ var _a, _b;
333
+ const element = node;
334
+ const footnote = [];
335
+ const affiliations = [];
336
+ const corresp = [];
337
+ const xrefs = element.querySelectorAll('xref');
338
+ for (const xref of xrefs) {
339
+ const rid = xref.getAttribute('rid');
340
+ const type = xref.getAttribute('ref-type');
341
+ if (!rid) {
342
+ continue;
343
+ }
344
+ switch (type) {
345
+ case 'fn':
346
+ footnote.push({
347
+ noteID: rid,
348
+ noteLabel: ((_a = xref.textContent) === null || _a === void 0 ? void 0 : _a.trim()) || '',
349
+ });
350
+ break;
351
+ case 'corresp':
352
+ corresp.push({
353
+ correspID: rid,
354
+ correspLabel: ((_b = xref.textContent) === null || _b === void 0 ? void 0 : _b.trim()) || '',
355
+ });
356
+ break;
357
+ case 'aff':
358
+ affiliations.push(rid);
359
+ break;
360
+ }
361
+ }
362
+ return {
363
+ id: element.getAttribute('id'),
364
+ role: 'author',
365
+ affiliations,
366
+ corresp,
367
+ footnote,
368
+ isCorresponding: element.getAttribute('corresp')
369
+ ? element.getAttribute('corresp') === 'yes'
370
+ : undefined,
371
+ bibliographicName: {
372
+ given: (0, utils_1.getTrimmedTextContent)(element, 'name > given-names'),
373
+ family: (0, utils_1.getTrimmedTextContent)(element, 'name > surname'),
374
+ ObjectType: json_schema_1.ObjectTypes.BibliographicName,
375
+ },
376
+ ORCIDIdentifier: (0, utils_1.getTrimmedTextContent)(element, 'contrib-id[contrib-id-type="orcid"]'),
377
+ priority: parsePriority(element.getAttribute('priority')),
378
+ };
379
+ },
380
+ getContent: () => {
381
+ return prosemirror_model_1.Fragment.from(schema_1.schema.text('_'));
382
+ },
383
+ },
384
+ {
385
+ tag: 'affiliations',
386
+ node: 'affiliations',
387
+ },
388
+ {
389
+ tag: 'aff',
390
+ node: 'affiliation',
391
+ context: 'affiliations/',
392
+ getAttrs: (node) => {
393
+ var _a, _b;
394
+ const element = node;
395
+ const { department, institution } = getInstitutionDetails(element);
396
+ return {
397
+ id: element.getAttribute('id'),
398
+ institution: institution !== null && institution !== void 0 ? institution : '',
399
+ department: department !== null && department !== void 0 ? department : '',
400
+ addressLine1: getAddressLine(element, 1),
401
+ addressLine2: getAddressLine(element, 2),
402
+ addressLine3: getAddressLine(element, 3),
403
+ postCode: (_a = (0, utils_1.getTrimmedTextContent)(element, 'postal-code')) !== null && _a !== void 0 ? _a : '',
404
+ country: (_b = (0, utils_1.getTrimmedTextContent)(element, 'country')) !== null && _b !== void 0 ? _b : '',
405
+ email: getEmail(element),
406
+ priority: parsePriority(element.getAttribute('priority')),
407
+ };
408
+ },
409
+ getContent: () => {
410
+ return prosemirror_model_1.Fragment.from(schema_1.schema.text('_'));
411
+ },
412
+ },
104
413
  {
105
414
  tag: 'attrib',
106
415
  node: 'attribution',
@@ -109,10 +418,6 @@ const nodes = [
109
418
  tag: 'back',
110
419
  ignore: true,
111
420
  },
112
- {
113
- tag: 'body',
114
- node: 'manuscript',
115
- },
116
421
  {
117
422
  tag: 'break',
118
423
  node: 'hard_break',
@@ -132,13 +437,13 @@ const nodes = [
132
437
  const title = element.querySelector('title');
133
438
  if (title) {
134
439
  const captionTitle = schema.nodes.caption_title.create();
135
- content.push(exports.jatsBodyDOMParser.parse(title, { topNode: captionTitle }));
440
+ content.push(exports.jatsDOMParser.parse(title, { topNode: captionTitle }));
136
441
  }
137
442
  const paragraphs = element.querySelectorAll('p');
138
443
  if (paragraphs.length) {
139
444
  const figcaption = schema.nodes.caption.create();
140
445
  for (const paragraph of paragraphs) {
141
- content.push(exports.jatsBodyDOMParser.parse(paragraph, { topNode: figcaption }));
446
+ content.push(exports.jatsDOMParser.parse(paragraph, { topNode: figcaption }));
142
447
  }
143
448
  }
144
449
  return prosemirror_model_1.Fragment.from(content);
@@ -149,6 +454,17 @@ const nodes = [
149
454
  node: 'figcaption',
150
455
  context: 'table_element/',
151
456
  },
457
+ {
458
+ tag: 'caption',
459
+ node: 'figcaption',
460
+ context: 'box_element/',
461
+ getAttrs: (node) => {
462
+ const element = node;
463
+ return {
464
+ id: element.getAttribute('id'),
465
+ };
466
+ },
467
+ },
152
468
  {
153
469
  tag: 'code',
154
470
  node: 'listing',
@@ -329,7 +645,7 @@ const nodes = [
329
645
  const paragraphs = [];
330
646
  node.childNodes.forEach((p) => {
331
647
  const paragraph = schema_1.schema.nodes.paragraph.create();
332
- const content = exports.jatsBodyDOMParser.parse(p, {
648
+ const content = exports.jatsDOMParser.parse(p, {
333
649
  topNode: paragraph,
334
650
  });
335
651
  paragraphs.push(content);
@@ -428,6 +744,33 @@ const nodes = [
428
744
  tag: 'sec[sec-type="backmatter"]',
429
745
  node: 'backmatter',
430
746
  },
747
+ {
748
+ tag: 'sec[sec-type="box-element"]',
749
+ node: 'box_element',
750
+ getAttrs: (node) => {
751
+ var _a;
752
+ const element = node;
753
+ return {
754
+ id: element.getAttribute('id'),
755
+ label: (_a = element.querySelector('label')) === null || _a === void 0 ? void 0 : _a.textContent,
756
+ };
757
+ },
758
+ },
759
+ {
760
+ tag: 'sec[sec-type="bibliography"]',
761
+ node: 'bibliography_section',
762
+ },
763
+ {
764
+ tag: 'ref-list',
765
+ context: 'bibliography_section/',
766
+ node: 'bibliography_element',
767
+ },
768
+ {
769
+ tag: 'ref',
770
+ context: 'bibliography_element/',
771
+ node: 'bibliography_item',
772
+ getAttrs: (node) => parseRef(node),
773
+ },
431
774
  {
432
775
  tag: 'sec',
433
776
  node: 'section',
@@ -451,6 +794,7 @@ const nodes = [
451
794
  getAttrs: (node) => {
452
795
  const element = node;
453
796
  return {
797
+ id: element.id,
454
798
  type: element.getAttribute('kwd-group-type'),
455
799
  };
456
800
  },
@@ -460,6 +804,15 @@ const nodes = [
460
804
  context: 'keyword_group//',
461
805
  node: 'keyword',
462
806
  },
807
+ {
808
+ tag: 'label',
809
+ context: 'box_element/',
810
+ ignore: true,
811
+ },
812
+ {
813
+ tag: 'boxed-text',
814
+ ignore: true,
815
+ },
463
816
  {
464
817
  tag: 'label',
465
818
  context: 'section/',
@@ -498,7 +851,7 @@ const nodes = [
498
851
  {
499
852
  tag: 'title',
500
853
  node: 'section_title',
501
- context: 'section/|footnotes_section/|bibliography_section/|keywords/|supplements/',
854
+ context: 'section/|footnotes_section/|bibliography_section/|keywords/|supplements/|author_notes/',
502
855
  },
503
856
  {
504
857
  tag: 'title',
@@ -580,4 +933,4 @@ const nodes = [
580
933
  },
581
934
  },
582
935
  ];
583
- exports.jatsBodyDOMParser = new prosemirror_model_1.DOMParser(schema_1.schema, [...marks, ...nodes]);
936
+ exports.jatsDOMParser = new prosemirror_model_1.DOMParser(schema_1.schema, [...marks, ...nodes]);
@@ -15,7 +15,8 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.parseJournalMeta = exports.parseJournalISSNs = exports.parseJournalAbbreviatedTitles = exports.parseJournalIdentifiers = void 0;
18
+ exports.parseJournal = exports.parseJournalMeta = exports.parseJournalISSNs = exports.parseJournalAbbreviatedTitles = exports.parseJournalIdentifiers = void 0;
19
+ const json_schema_1 = require("@manuscripts/json-schema");
19
20
  const utils_1 = require("../../lib/utils");
20
21
  const parseJournalIdentifiers = (element) => {
21
22
  var _a;
@@ -91,3 +92,12 @@ const parseJournalMeta = (element) => {
91
92
  };
92
93
  };
93
94
  exports.parseJournalMeta = parseJournalMeta;
95
+ const parseJournal = (doc) => {
96
+ const journalMeta = doc.querySelector('journal-meta');
97
+ if (!journalMeta) {
98
+ return;
99
+ }
100
+ const meta = (0, exports.parseJournalMeta)(journalMeta);
101
+ return Object.assign(Object.assign({}, meta), { objectType: json_schema_1.ObjectTypes.Journal });
102
+ };
103
+ exports.parseJournal = parseJournal;
@@ -19,18 +19,21 @@ exports.htmlFromJatsNode = exports.updateDocumentIDs = void 0;
19
19
  const uuid_1 = require("uuid");
20
20
  const schema_1 = require("../../schema");
21
21
  const transformer_1 = require("../../transformer");
22
- const updateDocumentIDs = (node, replacements) => {
22
+ const updateDocumentIDs = (node) => {
23
+ const replacements = new Map();
23
24
  const warnings = [];
24
25
  recurseDoc(node, (n) => updateNodeID(n, replacements, warnings));
25
26
  recurseDoc(node, (n) => updateNodeRID(n, replacements, warnings));
26
27
  recurseDoc(node, (n) => updateNodeRIDS(n, replacements, warnings));
28
+ recurseDoc(node, (n) => updateContributorNodesIDS(n, replacements, warnings));
29
+ recurseDoc(node, (n) => updateCommentTarget(n, replacements, warnings));
27
30
  return warnings;
28
31
  };
29
32
  exports.updateDocumentIDs = updateDocumentIDs;
30
- function recurseDoc(node, fn) {
33
+ const recurseDoc = (node, fn) => {
31
34
  fn(node);
32
35
  node.descendants((n) => fn(n));
33
- }
36
+ };
34
37
  const updateNodeID = (node, replacements, warnings) => {
35
38
  if (node.type === schema_1.schema.nodes.inline_equation) {
36
39
  node.attrs = Object.assign(Object.assign({}, node.attrs), { id: `InlineMathFragment:${(0, uuid_1.v4)()}` });
@@ -40,6 +43,10 @@ const updateNodeID = (node, replacements, warnings) => {
40
43
  node.attrs = Object.assign(Object.assign({}, node.attrs), { id: `GeneralTableFootnote:${(0, uuid_1.v4)()}` });
41
44
  return;
42
45
  }
46
+ if (node.type === schema_1.schema.nodes.comment ||
47
+ node.type === schema_1.schema.nodes.highlight_marker) {
48
+ return;
49
+ }
43
50
  if (!('id' in node.attrs)) {
44
51
  return;
45
52
  }
@@ -49,7 +56,7 @@ const updateNodeID = (node, replacements, warnings) => {
49
56
  return;
50
57
  }
51
58
  const previousID = node.attrs.id;
52
- const nextID = (0, transformer_1.generateID)(objectType);
59
+ const nextID = (0, transformer_1.generateNodeID)(node.type);
53
60
  if (previousID) {
54
61
  if (replacements.has(previousID) ||
55
62
  Array.from(replacements.values()).includes(previousID)) {
@@ -78,6 +85,44 @@ const updateNodeRIDS = (node, replacements, warnings) => {
78
85
  }
79
86
  node.attrs = Object.assign(Object.assign({}, node.attrs), { rids: previousRIDs.map((r) => replacements.get(r) || r) });
80
87
  };
88
+ const updateContributorNodesIDS = (node, replacements, warnings) => {
89
+ var _a, _b;
90
+ if (node.type === schema_1.schema.nodes.contributor) {
91
+ const footnote = (_a = node.attrs.footnote) === null || _a === void 0 ? void 0 : _a.map((fn) => {
92
+ return replacements.get(fn.noteID)
93
+ ? Object.assign(Object.assign({}, fn), { noteID: replacements.get(fn.noteID) }) : undefined;
94
+ }).filter(Boolean);
95
+ const corresp = (_b = node.attrs.corresp) === null || _b === void 0 ? void 0 : _b.map((corresp) => {
96
+ return replacements.get(corresp.correspID)
97
+ ? Object.assign(Object.assign({}, corresp), { correspID: replacements.get(corresp.correspID) }) : undefined;
98
+ }).filter(Boolean);
99
+ const affiliations = node.attrs.affiliations
100
+ .map((affiliation) => {
101
+ return replacements.get(affiliation);
102
+ })
103
+ .filter(Boolean);
104
+ node.attrs = Object.assign(Object.assign({}, node.attrs), { footnote,
105
+ corresp,
106
+ affiliations });
107
+ }
108
+ if (node.type !== schema_1.schema.nodes.contributors) {
109
+ return false;
110
+ }
111
+ };
112
+ const updateCommentTarget = (node, replacements, warnings) => {
113
+ if (node.type !== schema_1.schema.nodes.comment) {
114
+ return;
115
+ }
116
+ const target = node.attrs.target;
117
+ if (!target) {
118
+ return;
119
+ }
120
+ if (!replacements.has(target)) {
121
+ }
122
+ else {
123
+ node.attrs = Object.assign(Object.assign({}, node.attrs), { target: replacements.get(target) });
124
+ }
125
+ };
81
126
  const JATS_TO_HTML_MAPPING = new Map([
82
127
  ['bold', 'b'],
83
128
  ['italic', 'i'],
@@ -113,6 +158,9 @@ const htmlFromJatsNode = (element, createElement) => {
113
158
  if (!element) {
114
159
  return undefined;
115
160
  }
161
+ if (!createElement) {
162
+ createElement = (tagName) => element.ownerDocument.createElement(tagName);
163
+ }
116
164
  const temp = createElement('template');
117
165
  renameJatsNodesToHTML(element, temp, createElement);
118
166
  return temp.innerHTML;