@manuscripts/transform 2.3.35 → 2.3.37-LEAN-3911.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 (123) hide show
  1. package/dist/cjs/jats/importer/create-article-node.js +31 -0
  2. package/dist/cjs/jats/importer/index.js +3 -3
  3. package/dist/cjs/jats/importer/jats-body-transformations.js +70 -0
  4. package/dist/cjs/jats/importer/jats-comments.js +27 -104
  5. package/dist/cjs/jats/importer/{jats-body-dom-parser.js → jats-dom-parser.js} +229 -9
  6. package/dist/cjs/jats/importer/jats-front-transformations.js +262 -0
  7. package/dist/cjs/jats/importer/jats-journal-meta-parser.js +8 -1
  8. package/dist/cjs/jats/importer/jats-parser-utils.js +39 -5
  9. package/dist/cjs/jats/importer/jats-reference-parser.js +16 -27
  10. package/dist/cjs/jats/importer/jats-references.js +18 -18
  11. package/dist/cjs/jats/importer/parse-jats-article.js +42 -78
  12. package/dist/cjs/jats/index.js +4 -3
  13. package/dist/cjs/jats/jats-exporter.js +252 -354
  14. package/dist/cjs/{transformer → jats}/labels.js +3 -3
  15. package/dist/cjs/lib/utils.js +9 -1
  16. package/dist/cjs/schema/index.js +2 -0
  17. package/dist/cjs/schema/nodes/box_element.js +55 -0
  18. package/dist/cjs/transformer/id.js +10 -5
  19. package/dist/cjs/transformer/index.js +0 -18
  20. package/dist/cjs/transformer/node-types.js +1 -0
  21. package/dist/cjs/transformer/section-category.js +8 -0
  22. package/dist/cjs/version.js +1 -1
  23. package/dist/{cjs/transformer/serializer.js → es/jats/importer/create-article-node.js} +12 -8
  24. package/dist/es/jats/importer/index.js +2 -1
  25. package/dist/es/jats/importer/jats-body-transformations.js +70 -0
  26. package/dist/es/jats/importer/jats-comments.js +26 -101
  27. package/dist/es/jats/importer/{jats-body-dom-parser.js → jats-dom-parser.js} +230 -10
  28. package/dist/es/jats/importer/jats-front-transformations.js +259 -0
  29. package/dist/es/jats/importer/jats-journal-meta-parser.js +6 -0
  30. package/dist/es/jats/importer/jats-parser-utils.js +40 -6
  31. package/dist/es/jats/importer/jats-reference-parser.js +16 -27
  32. package/dist/es/jats/importer/jats-references.js +18 -18
  33. package/dist/es/jats/importer/parse-jats-article.js +43 -77
  34. package/dist/es/jats/index.js +3 -1
  35. package/dist/es/jats/jats-exporter.js +254 -356
  36. package/dist/es/{transformer → jats}/labels.js +3 -3
  37. package/dist/es/lib/utils.js +7 -0
  38. package/dist/es/schema/index.js +2 -0
  39. package/dist/es/schema/nodes/box_element.js +52 -0
  40. package/dist/es/transformer/id.js +8 -3
  41. package/dist/es/transformer/index.js +0 -16
  42. package/dist/es/transformer/node-types.js +1 -0
  43. package/dist/es/transformer/section-category.js +8 -0
  44. package/dist/es/version.js +1 -1
  45. package/dist/{cjs/transformer/models.js → types/jats/importer/create-article-node.d.ts} +3 -3
  46. package/dist/types/jats/importer/index.d.ts +2 -1
  47. package/dist/types/jats/importer/jats-body-transformations.d.ts +5 -0
  48. package/dist/types/jats/importer/jats-comments.d.ts +4 -10
  49. package/dist/types/jats/importer/{jats-body-dom-parser.d.ts → jats-dom-parser.d.ts} +1 -1
  50. package/dist/types/jats/importer/jats-front-transformations.d.ts +38 -0
  51. package/dist/types/jats/importer/jats-journal-meta-parser.d.ts +10 -0
  52. package/dist/types/jats/importer/jats-references.d.ts +19 -8
  53. package/dist/types/jats/importer/parse-jats-article.d.ts +12 -5
  54. package/dist/types/jats/index.d.ts +3 -1
  55. package/dist/types/jats/jats-exporter.d.ts +10 -29
  56. package/dist/types/{transformer → jats}/labels.d.ts +2 -1
  57. package/dist/types/lib/utils.d.ts +3 -0
  58. package/dist/types/schema/nodes/bibliography_item.d.ts +28 -5
  59. package/dist/{es/transformer/models.js → types/schema/nodes/box_element.d.ts} +10 -0
  60. package/dist/types/schema/nodes/contributor.d.ts +10 -0
  61. package/dist/types/schema/nodes/keyword_group.d.ts +1 -0
  62. package/dist/types/schema/types.d.ts +1 -1
  63. package/dist/types/transformer/id.d.ts +5 -2
  64. package/dist/types/transformer/index.d.ts +0 -16
  65. package/dist/types/transformer/section-category.d.ts +2 -2
  66. package/dist/types/version.d.ts +1 -1
  67. package/package.json +2 -1
  68. package/dist/cjs/__tests__/data/project-dump.json +0 -825
  69. package/dist/cjs/jats/importer/jats-front-parser.js +0 -321
  70. package/dist/cjs/transformer/__tests__/__helpers__/doc.js +0 -37
  71. package/dist/cjs/transformer/builders.js +0 -219
  72. package/dist/cjs/transformer/decode.js +0 -874
  73. package/dist/cjs/transformer/document-object-types.js +0 -31
  74. package/dist/cjs/transformer/encode.js +0 -664
  75. package/dist/cjs/transformer/footnote-category.js +0 -20
  76. package/dist/cjs/transformer/footnotes-order.js +0 -60
  77. package/dist/cjs/transformer/highlight-markers.js +0 -138
  78. package/dist/cjs/transformer/html.js +0 -400
  79. package/dist/cjs/transformer/manuscript-dependencies.js +0 -21
  80. package/dist/cjs/transformer/model-map.js +0 -26
  81. package/dist/cjs/transformer/object-types.js +0 -57
  82. package/dist/cjs/transformer/project-bundle.js +0 -94
  83. package/dist/cjs/transformer/update-identifiers.js +0 -93
  84. package/dist/es/__tests__/data/project-dump.json +0 -825
  85. package/dist/es/jats/importer/jats-front-parser.js +0 -315
  86. package/dist/es/transformer/__tests__/__helpers__/doc.js +0 -29
  87. package/dist/es/transformer/builders.js +0 -186
  88. package/dist/es/transformer/decode.js +0 -864
  89. package/dist/es/transformer/document-object-types.js +0 -28
  90. package/dist/es/transformer/encode.js +0 -654
  91. package/dist/es/transformer/footnote-category.js +0 -16
  92. package/dist/es/transformer/footnotes-order.js +0 -55
  93. package/dist/es/transformer/highlight-markers.js +0 -132
  94. package/dist/es/transformer/html.js +0 -393
  95. package/dist/es/transformer/manuscript-dependencies.js +0 -17
  96. package/dist/es/transformer/model-map.js +0 -22
  97. package/dist/es/transformer/object-types.js +0 -52
  98. package/dist/es/transformer/project-bundle.js +0 -85
  99. package/dist/es/transformer/serializer.js +0 -17
  100. package/dist/es/transformer/update-identifiers.js +0 -87
  101. package/dist/types/jats/importer/jats-front-parser.d.ts +0 -84
  102. package/dist/types/transformer/__tests__/__helpers__/doc.d.ts +0 -18
  103. package/dist/types/transformer/builders.d.ts +0 -61
  104. package/dist/types/transformer/decode.d.ts +0 -51
  105. package/dist/types/transformer/document-object-types.d.ts +0 -17
  106. package/dist/types/transformer/encode.d.ts +0 -29
  107. package/dist/types/transformer/footnote-category.d.ts +0 -17
  108. package/dist/types/transformer/footnotes-order.d.ts +0 -22
  109. package/dist/types/transformer/highlight-markers.d.ts +0 -31
  110. package/dist/types/transformer/html.d.ts +0 -36
  111. package/dist/types/transformer/manuscript-dependencies.d.ts +0 -4
  112. package/dist/types/transformer/model-map.d.ts +0 -19
  113. package/dist/types/transformer/models.d.ts +0 -48
  114. package/dist/types/transformer/object-types.d.ts +0 -30
  115. package/dist/types/transformer/project-bundle.d.ts +0 -30
  116. package/dist/types/transformer/serializer.d.ts +0 -19
  117. package/dist/types/transformer/update-identifiers.d.ts +0 -23
  118. /package/dist/cjs/{transformer → jats}/filename.js +0 -0
  119. /package/dist/cjs/{transformer → jats}/timestamp.js +0 -0
  120. /package/dist/es/{transformer → jats}/filename.js +0 -0
  121. /package/dist/es/{transformer → jats}/timestamp.js +0 -0
  122. /package/dist/types/{transformer → jats}/filename.d.ts +0 -0
  123. /package/dist/types/{transformer → jats}/timestamp.d.ts +0 -0
@@ -0,0 +1,31 @@
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
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.createArticleNode = void 0;
19
+ const schema_1 = require("../../schema");
20
+ const jats_front_transformations_1 = require("./jats-front-transformations");
21
+ const createArticleNode = (manuscript) => {
22
+ const title = schema_1.schema.nodes.title.createChecked({}, schema_1.schema.text(jats_front_transformations_1.defaultTitle));
23
+ return schema_1.schema.nodes.manuscript.createAndFill({
24
+ id: manuscript._id,
25
+ doi: manuscript.DOI,
26
+ articleType: manuscript.articleType,
27
+ prototype: manuscript.prototype,
28
+ primaryLanguageCode: manuscript.primaryLanguageCode,
29
+ }, title);
30
+ };
31
+ exports.createArticleNode = createArticleNode;
@@ -15,8 +15,8 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.parseJATSArticle = exports.parseJATSBody = exports.parseJATSFront = void 0;
18
+ exports.parseJATSArticle = exports.createArticleNode = void 0;
19
+ var create_article_node_1 = require("./create-article-node");
20
+ Object.defineProperty(exports, "createArticleNode", { enumerable: true, get: function () { return create_article_node_1.createArticleNode; } });
19
21
  var parse_jats_article_1 = require("./parse-jats-article");
20
- Object.defineProperty(exports, "parseJATSFront", { enumerable: true, get: function () { return parse_jats_article_1.parseJATSFront; } });
21
- Object.defineProperty(exports, "parseJATSBody", { enumerable: true, get: function () { return parse_jats_article_1.parseJATSBody; } });
22
22
  Object.defineProperty(exports, "parseJATSArticle", { enumerable: true, get: function () { return parse_jats_article_1.parseJATSArticle; } });
@@ -302,4 +302,74 @@ exports.jatsBodyTransformations = {
302
302
  body.prepend(section);
303
303
  }
304
304
  },
305
+ moveReferencesToBackmatter(body, references, createElement) {
306
+ const backmatter = body.querySelector('sec[sec-type="backmatter"]');
307
+ if (!references || !references.items.size || !backmatter) {
308
+ return;
309
+ }
310
+ const bibliographySection = this.createBibliographySection(createElement);
311
+ const bibliographyElement = createElement('bibliography-element');
312
+ references.getBibliographyItems().forEach((item) => {
313
+ const bibliographyItem = this.createBibliographyItem(item, createElement);
314
+ bibliographyElement.appendChild(bibliographyItem);
315
+ });
316
+ bibliographySection.appendChild(bibliographyElement);
317
+ backmatter.appendChild(bibliographySection);
318
+ },
319
+ createBibliographySection(createElement) {
320
+ const section = createElement('sec');
321
+ section.setAttribute('sec-type', 'bibliography_section');
322
+ const title = createElement('title');
323
+ title.textContent = 'References';
324
+ section.appendChild(title);
325
+ return section;
326
+ },
327
+ createBibliographyItem(item, createElement) {
328
+ var _a, _b, _c;
329
+ const bibliographyItem = createElement('bibliography-item');
330
+ bibliographyItem.setAttribute('id', item.id);
331
+ bibliographyItem.setAttribute('type', item.type);
332
+ (_a = item.author) === null || _a === void 0 ? void 0 : _a.forEach((author) => {
333
+ const authorElement = createElement('author');
334
+ authorElement.setAttribute('id', author._id);
335
+ authorElement.setAttribute('family', author.family || '');
336
+ authorElement.setAttribute('given', author.given || '');
337
+ bibliographyItem.appendChild(authorElement);
338
+ });
339
+ if (item.issued) {
340
+ const issuedEl = createElement('issued');
341
+ issuedEl.setAttribute('id', ((_b = item.issued) === null || _b === void 0 ? void 0 : _b._id) || '');
342
+ const dateParts = item.issued['date-parts'];
343
+ const year = (_c = dateParts === null || dateParts === void 0 ? void 0 : dateParts[0]) === null || _c === void 0 ? void 0 : _c[0];
344
+ if (year) {
345
+ issuedEl.setAttribute('year', year.toString());
346
+ }
347
+ bibliographyItem.appendChild(issuedEl);
348
+ }
349
+ if (item.containerTitle) {
350
+ bibliographyItem.setAttribute('containerTitle', item.containerTitle);
351
+ }
352
+ if (item.volume) {
353
+ bibliographyItem.setAttribute('volume', item.volume.toString());
354
+ }
355
+ if (item.issue) {
356
+ bibliographyItem.setAttribute('issue', item.issue.toString());
357
+ }
358
+ if (item.supplement) {
359
+ bibliographyItem.setAttribute('supplement', item.supplement);
360
+ }
361
+ if (item.page) {
362
+ bibliographyItem.setAttribute('page', item.page.toString());
363
+ }
364
+ if (item.title) {
365
+ bibliographyItem.setAttribute('title', item.title);
366
+ }
367
+ if (item.literal) {
368
+ bibliographyItem.setAttribute('literal', item.literal);
369
+ }
370
+ if (item.doi) {
371
+ bibliographyItem.setAttribute('DOI', item.doi);
372
+ }
373
+ return bibliographyItem;
374
+ },
305
375
  };
@@ -15,10 +15,10 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.createReferenceComments = exports.createComments = exports.markComments = exports.parseJATSComment = exports.isJATSComment = void 0;
19
- const uuid_1 = require("uuid");
18
+ exports.markComments = exports.parseJATSComment = exports.isJATSComment = exports.DEFAULT_PROFILE_ID = void 0;
19
+ const json_schema_1 = require("@manuscripts/json-schema");
20
20
  const transformer_1 = require("../../transformer");
21
- const DEFAULT_PROFILE_ID = 'MPUserProfile:0000000000000000000000000000000000000001';
21
+ exports.DEFAULT_PROFILE_ID = 'MPUserProfile:0000000000000000000000000000000000000001';
22
22
  const isJATSComment = (node) => {
23
23
  return (node.nodeType === node.PROCESSING_INSTRUCTION_NODE &&
24
24
  node.nodeName === 'AuthorQuery');
@@ -27,35 +27,34 @@ exports.isJATSComment = isJATSComment;
27
27
  const parseJATSComment = (node) => {
28
28
  const text = node.textContent;
29
29
  if (text) {
30
- const id = /id="(.+)"/.exec(text);
31
30
  const queryText = /queryText="(.+)"/.exec(text);
32
- if (id && queryText) {
31
+ if (queryText) {
32
+ const parentNode = node.parentNode;
33
+ const index = parentNode.outerHTML.indexOf(queryText[1]);
33
34
  return {
34
- id: id[1],
35
+ id: (0, transformer_1.generateID)(json_schema_1.ObjectTypes.CommentAnnotation),
35
36
  text: queryText[1],
37
+ index,
36
38
  };
37
39
  }
38
40
  }
39
41
  };
40
42
  exports.parseJATSComment = parseJATSComment;
41
43
  const markComments = (doc) => {
42
- const marks = [];
44
+ var _a;
43
45
  const root = doc.getRootNode();
44
46
  const queue = [root];
47
+ const commentsElement = doc.createElement('comments-annotations');
45
48
  while (queue.length !== 0) {
46
49
  const node = queue.shift();
47
50
  if (node) {
48
51
  if ((0, exports.isJATSComment)(node)) {
49
52
  const comment = (0, exports.parseJATSComment)(node);
50
53
  if (comment) {
51
- const token = addMark(doc, node);
52
- if (token) {
53
- const mark = {
54
- token,
55
- comment,
56
- };
57
- marks.push(mark);
58
- }
54
+ const highlightMarker = createHighlightMarkerElement(doc, comment.id);
55
+ (_a = node.parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore(highlightMarker, node);
56
+ const commentElement = createCommentElement(doc, comment);
57
+ commentsElement.appendChild(commentElement);
59
58
  }
60
59
  }
61
60
  node.childNodes.forEach((child) => {
@@ -63,96 +62,20 @@ const markComments = (doc) => {
63
62
  });
64
63
  }
65
64
  }
66
- return marks;
67
- };
68
- exports.markComments = markComments;
69
- const addMark = (doc, node) => {
70
- const parent = node.parentElement;
71
- if (parent) {
72
- const token = (0, uuid_1.v4)();
73
- const tokenNode = doc.createTextNode(token);
74
- parent.insertBefore(tokenNode, node);
75
- return token;
65
+ if (commentsElement.hasChildNodes()) {
66
+ doc.documentElement.appendChild(commentsElement);
76
67
  }
77
68
  };
78
- const createComments = (models, marks) => {
79
- const comments = [];
80
- for (const model of models) {
81
- if ((0, transformer_1.isHighlightableModel)(model)) {
82
- comments.push(...processModel(model, marks));
83
- }
84
- else if ((0, transformer_1.isKeyword)(model)) {
85
- comments.push(...processKeyword(model, marks));
86
- }
87
- }
88
- return comments;
89
- };
90
- exports.createComments = createComments;
91
- const getFieldMarks = (content, marks) => {
92
- return marks
93
- .filter((m) => content.indexOf(m.token) >= 0)
94
- .sort((a, b) => content.indexOf(a.token) - content.indexOf(b.token));
95
- };
96
- const processModel = (model, marks) => {
97
- const comments = [];
98
- for (const field of transformer_1.highlightableFields) {
99
- const content = model[field];
100
- if (!content) {
101
- continue;
102
- }
103
- const results = processContent(model, content, getFieldMarks(content, marks));
104
- model[field] = results.content;
105
- comments.push(...results.comments);
106
- }
107
- return comments;
108
- };
109
- const processKeyword = (model, marks) => {
110
- const comments = [];
111
- const name = model.name;
112
- let content = name;
113
- for (const mark of getFieldMarks(name, marks)) {
114
- content = name.replace(mark.token, '');
115
- const target = model.containedGroup;
116
- if (!target) {
117
- continue;
118
- }
119
- const contributions = [(0, transformer_1.buildContribution)(DEFAULT_PROFILE_ID)];
120
- const comment = (0, transformer_1.buildComment)(target, mark.comment.text, undefined, contributions);
121
- model.name = content;
122
- comments.push(comment);
123
- }
124
- return comments;
125
- };
126
- const processContent = (model, content, marks) => {
127
- const comments = [];
128
- let result = content;
129
- for (const mark of marks) {
130
- const token = mark.token;
131
- const index = result.indexOf(token);
132
- result = result.replace(token, '');
133
- const contributions = [(0, transformer_1.buildContribution)(DEFAULT_PROFILE_ID)];
134
- const selector = {
135
- from: index,
136
- to: index,
137
- };
138
- const comment = (0, transformer_1.buildComment)(model._id, mark.comment.text, selector, contributions);
139
- comments.push(comment);
140
- }
141
- return {
142
- content: result,
143
- comments,
144
- };
69
+ exports.markComments = markComments;
70
+ const createHighlightMarkerElement = (doc, id) => {
71
+ const highlightMarker = doc.createElement('highlight-marker');
72
+ highlightMarker.setAttribute('id', id);
73
+ highlightMarker.setAttribute('position', 'point');
74
+ return highlightMarker;
145
75
  };
146
- const createReferenceComments = (references) => {
147
- const comments = [];
148
- for (const item of references.getBibliographyItems()) {
149
- const id = item._id;
150
- for (const comment of references.getComments(id)) {
151
- const contributions = [(0, transformer_1.buildContribution)(DEFAULT_PROFILE_ID)];
152
- const c = (0, transformer_1.buildComment)(id, comment.text, undefined, contributions);
153
- comments.push(c);
154
- }
155
- }
156
- return comments;
76
+ const createCommentElement = (doc, comment) => {
77
+ const commentElement = doc.createElement('comment-annotation');
78
+ commentElement.setAttribute('id', comment.id);
79
+ commentElement.textContent = comment.text;
80
+ return commentElement;
157
81
  };
158
- exports.createReferenceComments = createReferenceComments;
@@ -18,11 +18,13 @@ 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");
24
25
  const schema_1 = require("../../schema");
25
26
  const transformer_1 = require("../../transformer");
27
+ const jats_comments_1 = require("./jats-comments");
26
28
  const XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
27
29
  const chooseContentType = (graphicNode) => {
28
30
  if (graphicNode) {
@@ -37,6 +39,12 @@ const chooseContentType = (graphicNode) => {
37
39
  }
38
40
  }
39
41
  };
42
+ const parsePriority = (priority) => {
43
+ if (!priority) {
44
+ return undefined;
45
+ }
46
+ return parseInt(priority);
47
+ };
40
48
  const getEquationContent = (p) => {
41
49
  var _a;
42
50
  const element = p;
@@ -101,6 +109,174 @@ const marks = [
101
109
  },
102
110
  ];
103
111
  const nodes = [
112
+ {
113
+ tag: 'article',
114
+ node: 'manuscript',
115
+ getAttrs: (node) => {
116
+ const element = node;
117
+ return {
118
+ doi: element.getAttribute('DOI'),
119
+ articleType: element.getAttribute('article-type') || '',
120
+ prototype: element.getAttribute('prototype') || '',
121
+ primaryLanguageCode: element.getAttribute('primary-language-code') || '',
122
+ };
123
+ },
124
+ },
125
+ {
126
+ tag: 'article-title',
127
+ node: 'title',
128
+ getAttrs: (node) => {
129
+ const element = node;
130
+ return {
131
+ id: element.getAttribute('id'),
132
+ };
133
+ },
134
+ },
135
+ {
136
+ tag: 'highlight-marker',
137
+ node: 'highlight_marker',
138
+ getAttrs: (node) => {
139
+ var _a;
140
+ const element = node;
141
+ const id = element.getAttribute('id');
142
+ return {
143
+ id: id,
144
+ position: (_a = element.getAttribute('position')) !== null && _a !== void 0 ? _a : '',
145
+ };
146
+ },
147
+ },
148
+ {
149
+ tag: 'comment-annotation',
150
+ node: 'comment',
151
+ getAttrs: (node) => {
152
+ const element = node;
153
+ return {
154
+ id: element.getAttribute('id'),
155
+ contents: element.textContent,
156
+ contributions: [
157
+ {
158
+ _id: (0, transformer_1.generateID)(json_schema_1.ObjectTypes.Contribution),
159
+ objecType: json_schema_1.ObjectTypes.Contribution,
160
+ profileID: jats_comments_1.DEFAULT_PROFILE_ID,
161
+ timestamp: (0, json_schema_1.timestamp)(),
162
+ },
163
+ ],
164
+ };
165
+ },
166
+ },
167
+ {
168
+ tag: 'author-notes',
169
+ node: 'author_notes',
170
+ getAttrs: (node) => {
171
+ const element = node;
172
+ return {
173
+ id: element.getAttribute('id'),
174
+ };
175
+ },
176
+ },
177
+ {
178
+ tag: 'fn-author',
179
+ node: 'footnote',
180
+ getAttrs: (node) => {
181
+ const element = node;
182
+ return {
183
+ id: element.getAttribute('id'),
184
+ kind: 'footnote',
185
+ };
186
+ },
187
+ },
188
+ {
189
+ tag: 'corresp',
190
+ node: 'corresp',
191
+ getAttrs: (node) => {
192
+ const element = node;
193
+ return {
194
+ id: element.getAttribute('id'),
195
+ label: element.getAttribute('label'),
196
+ };
197
+ },
198
+ },
199
+ {
200
+ tag: 'contributor',
201
+ node: 'contributor',
202
+ getAttrs: (node) => {
203
+ const element = node;
204
+ const footnote = [];
205
+ const affiliations = [];
206
+ const corresp = [];
207
+ element.querySelectorAll('fn').forEach((fn) => {
208
+ const noteID = fn.getAttribute('noteID');
209
+ const noteLabel = fn.getAttribute('noteLabel');
210
+ if (noteID && noteLabel) {
211
+ footnote.push({ noteID, noteLabel });
212
+ }
213
+ });
214
+ element.querySelectorAll('corresp').forEach((correspondence) => {
215
+ const correspLabel = correspondence.getAttribute('correspLabel');
216
+ const correspID = correspondence.getAttribute('correspID');
217
+ if (correspID && correspLabel) {
218
+ corresp.push({ correspID, correspLabel });
219
+ }
220
+ });
221
+ element.querySelectorAll('aff').forEach((aff) => {
222
+ const affID = aff.getAttribute('affiliationID');
223
+ if (affID) {
224
+ affiliations.push(affID);
225
+ }
226
+ });
227
+ const isCorrespondingEl = element.getAttribute('isCorresponding');
228
+ return {
229
+ id: element.getAttribute('id'),
230
+ role: 'author',
231
+ isCorresponding: isCorrespondingEl
232
+ ? isCorrespondingEl === 'true'
233
+ : undefined,
234
+ bibliographicName: {
235
+ given: element.getAttribute('given'),
236
+ family: element.getAttribute('family'),
237
+ ObjectType: 'MPBibliographicName',
238
+ _id: (0, transformer_1.generateID)(json_schema_1.ObjectTypes.BibliographicName),
239
+ },
240
+ affiliations,
241
+ corresp: corresp.length ? corresp : undefined,
242
+ footnote: footnote.length ? footnote : undefined,
243
+ ORCIDIdentifier: element.getAttribute('ORCIDIdentifier'),
244
+ priority: parsePriority(element.getAttribute('priority')),
245
+ };
246
+ },
247
+ getContent: () => {
248
+ return prosemirror_model_1.Fragment.from(schema_1.schema.text('_'));
249
+ },
250
+ },
251
+ {
252
+ tag: 'affiliation',
253
+ node: 'affiliation',
254
+ getAttrs: (node) => {
255
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
256
+ const element = node;
257
+ const emailEl = element.querySelector('email');
258
+ return {
259
+ id: element.getAttribute('id'),
260
+ institution: (_a = element.getAttribute('institution')) !== null && _a !== void 0 ? _a : '',
261
+ department: (_b = element.getAttribute('department')) !== null && _b !== void 0 ? _b : '',
262
+ addressLine1: (_c = element.getAttribute('addressLine1')) !== null && _c !== void 0 ? _c : '',
263
+ addressLine2: (_d = element.getAttribute('addressLine2')) !== null && _d !== void 0 ? _d : '',
264
+ addressLine3: (_e = element.getAttribute('addressLine3')) !== null && _e !== void 0 ? _e : '',
265
+ postCode: (_f = element.getAttribute('postCode')) !== null && _f !== void 0 ? _f : '',
266
+ country: (_g = element.getAttribute('country')) !== null && _g !== void 0 ? _g : '',
267
+ email: emailEl
268
+ ? {
269
+ href: (_h = emailEl.getAttributeNS(XLINK_NAMESPACE, 'href')) !== null && _h !== void 0 ? _h : '',
270
+ text: (_k = (_j = emailEl.textContent) === null || _j === void 0 ? void 0 : _j.trim()) !== null && _k !== void 0 ? _k : '',
271
+ }
272
+ : undefined,
273
+ priority: parsePriority(element.getAttribute('priority')),
274
+ };
275
+ },
276
+ getContent: () => {
277
+ return prosemirror_model_1.Fragment.from(schema_1.schema.text('_'));
278
+ },
279
+ },
104
280
  {
105
281
  tag: 'attrib',
106
282
  node: 'attribution',
@@ -109,10 +285,6 @@ const nodes = [
109
285
  tag: 'back',
110
286
  ignore: true,
111
287
  },
112
- {
113
- tag: 'body',
114
- node: 'manuscript',
115
- },
116
288
  {
117
289
  tag: 'break',
118
290
  node: 'hard_break',
@@ -132,13 +304,13 @@ const nodes = [
132
304
  const title = element.querySelector('title');
133
305
  if (title) {
134
306
  const captionTitle = schema.nodes.caption_title.create();
135
- content.push(exports.jatsBodyDOMParser.parse(title, { topNode: captionTitle }));
307
+ content.push(exports.jatsDOMParser.parse(title, { topNode: captionTitle }));
136
308
  }
137
309
  const paragraphs = element.querySelectorAll('p');
138
310
  if (paragraphs.length) {
139
311
  const figcaption = schema.nodes.caption.create();
140
312
  for (const paragraph of paragraphs) {
141
- content.push(exports.jatsBodyDOMParser.parse(paragraph, { topNode: figcaption }));
313
+ content.push(exports.jatsDOMParser.parse(paragraph, { topNode: figcaption }));
142
314
  }
143
315
  }
144
316
  return prosemirror_model_1.Fragment.from(content);
@@ -329,7 +501,7 @@ const nodes = [
329
501
  const paragraphs = [];
330
502
  node.childNodes.forEach((p) => {
331
503
  const paragraph = schema_1.schema.nodes.paragraph.create();
332
- const content = exports.jatsBodyDOMParser.parse(p, {
504
+ const content = exports.jatsDOMParser.parse(p, {
333
505
  topNode: paragraph,
334
506
  });
335
507
  paragraphs.push(content);
@@ -428,6 +600,54 @@ const nodes = [
428
600
  tag: 'sec[sec-type="backmatter"]',
429
601
  node: 'backmatter',
430
602
  },
603
+ {
604
+ tag: 'bibliography-element',
605
+ node: 'bibliography_element',
606
+ getAttrs: (node) => {
607
+ const element = node;
608
+ return {
609
+ id: element.getAttribute('id'),
610
+ };
611
+ },
612
+ },
613
+ {
614
+ tag: 'bibliography-item',
615
+ node: 'bibliography_item',
616
+ getAttrs: (node) => {
617
+ const element = node;
618
+ const authors = [];
619
+ element.querySelectorAll('author').forEach((author) => {
620
+ authors.push({
621
+ _id: author.getAttribute('id') || '',
622
+ given: author.getAttribute('given') || '',
623
+ family: author.getAttribute('family') || '',
624
+ objectType: 'MPBibliographicName',
625
+ });
626
+ });
627
+ const issuedEl = element.querySelector('issued');
628
+ const issued = issuedEl
629
+ ? {
630
+ objectType: 'MPBibliographicDate',
631
+ _id: issuedEl.getAttribute('id'),
632
+ 'date-parts': [[issuedEl.getAttribute('year')]],
633
+ }
634
+ : undefined;
635
+ return {
636
+ id: element.getAttribute('id'),
637
+ type: element.getAttribute('type'),
638
+ containerTitle: element.getAttribute('container-title'),
639
+ volume: element.getAttribute('volume'),
640
+ issue: element.getAttribute('issue'),
641
+ supplement: element.getAttribute('supplement'),
642
+ page: element.getAttribute('page'),
643
+ title: element.getAttribute('title'),
644
+ literal: element.getAttribute('literal'),
645
+ author: authors,
646
+ issued,
647
+ DOI: element.getAttribute('DOI'),
648
+ };
649
+ },
650
+ },
431
651
  {
432
652
  tag: 'sec',
433
653
  node: 'section',
@@ -580,4 +800,4 @@ const nodes = [
580
800
  },
581
801
  },
582
802
  ];
583
- exports.jatsBodyDOMParser = new prosemirror_model_1.DOMParser(schema_1.schema, [...marks, ...nodes]);
803
+ exports.jatsDOMParser = new prosemirror_model_1.DOMParser(schema_1.schema, [...marks, ...nodes]);