@manuscripts/transform 1.4.6 → 1.5.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 (52) hide show
  1. package/dist/cjs/jats/importer/jats-body-dom-parser.js +126 -0
  2. package/dist/cjs/jats/importer/jats-body-transformations.js +59 -0
  3. package/dist/cjs/jats/importer/jats-front-parser.js +7 -7
  4. package/dist/cjs/jats/importer/jats-parser-utils.js +4 -0
  5. package/dist/cjs/jats/importer/parse-jats-article.js +7 -5
  6. package/dist/cjs/jats/jats-exporter.js +2 -2
  7. package/dist/cjs/lib/core-section-categories.js +2 -2
  8. package/dist/cjs/schema/index.js +6 -6
  9. package/dist/cjs/schema/nodes/affiliation.js +3 -0
  10. package/dist/cjs/schema/nodes/affiliations_section.js +15 -0
  11. package/dist/cjs/schema/nodes/contributor.js +8 -1
  12. package/dist/cjs/schema/nodes/contributors_section.js +15 -0
  13. package/dist/cjs/schema/nodes/meta_section.js +1 -1
  14. package/dist/cjs/transformer/decode.js +51 -23
  15. package/dist/cjs/transformer/encode.js +20 -0
  16. package/dist/cjs/transformer/node-types.js +2 -0
  17. package/dist/cjs/transformer/section-category.js +12 -0
  18. package/dist/es/jats/importer/jats-body-dom-parser.js +126 -0
  19. package/dist/es/jats/importer/jats-body-transformations.js +59 -0
  20. package/dist/es/jats/importer/jats-front-parser.js +1 -1
  21. package/dist/es/jats/importer/jats-parser-utils.js +4 -0
  22. package/dist/es/jats/importer/parse-jats-article.js +7 -5
  23. package/dist/es/jats/jats-exporter.js +2 -2
  24. package/dist/es/lib/core-section-categories.js +2 -2
  25. package/dist/es/schema/index.js +6 -6
  26. package/dist/es/schema/nodes/affiliation.js +3 -0
  27. package/dist/es/schema/nodes/affiliations_section.js +11 -0
  28. package/dist/es/schema/nodes/contributor.js +6 -0
  29. package/dist/es/schema/nodes/contributors_section.js +11 -0
  30. package/dist/es/schema/nodes/meta_section.js +1 -1
  31. package/dist/es/transformer/decode.js +51 -23
  32. package/dist/es/transformer/encode.js +20 -0
  33. package/dist/es/transformer/node-types.js +2 -0
  34. package/dist/es/transformer/section-category.js +12 -0
  35. package/dist/types/jats/importer/jats-body-transformations.d.ts +4 -1
  36. package/dist/types/jats/importer/jats-front-parser.d.ts +5 -5
  37. package/dist/types/jats/importer/parse-jats-article.d.ts +5 -2
  38. package/dist/types/schema/index.d.ts +2 -2
  39. package/dist/types/schema/nodes/affiliation.d.ts +1 -0
  40. package/dist/types/schema/nodes/affiliations_section.d.ts +11 -0
  41. package/dist/types/schema/nodes/contributor.d.ts +2 -0
  42. package/dist/types/schema/nodes/contributors_section.d.ts +11 -0
  43. package/dist/types/schema/types.d.ts +1 -1
  44. package/dist/types/transformer/decode.d.ts +3 -2
  45. package/dist/types/transformer/section-category.d.ts +2 -2
  46. package/package.json +2 -2
  47. package/dist/cjs/schema/nodes/affiliation_list.js +0 -10
  48. package/dist/cjs/schema/nodes/contributor_list.js +0 -10
  49. package/dist/es/schema/nodes/affiliation_list.js +0 -7
  50. package/dist/es/schema/nodes/contributor_list.js +0 -7
  51. package/dist/types/schema/nodes/affiliation_list.d.ts +0 -10
  52. package/dist/types/schema/nodes/contributor_list.d.ts +0 -10
@@ -505,6 +505,132 @@ const nodes = [
505
505
  };
506
506
  },
507
507
  },
508
+ {
509
+ tag: 'sec[sec-type="affiliations"]',
510
+ node: 'affiliations_section',
511
+ getAttrs: (node) => {
512
+ const element = node;
513
+ return {
514
+ id: element.getAttribute('id'),
515
+ category: 'MPSectionCategory:affiliations',
516
+ };
517
+ },
518
+ },
519
+ {
520
+ tag: 'aff',
521
+ node: 'affiliation',
522
+ context: 'affiliations_section/',
523
+ getAttrs: (node) => {
524
+ const element = node;
525
+ const aff = {
526
+ id: element.getAttribute('id'),
527
+ };
528
+ const institution = element.getAttribute('institution');
529
+ if (institution) {
530
+ aff.institution = institution;
531
+ }
532
+ const email = element.getAttribute('email');
533
+ if (email) {
534
+ aff.bibliographicName = JSON.parse(email);
535
+ }
536
+ const department = element.getAttribute('department');
537
+ if (department) {
538
+ aff.department = department;
539
+ }
540
+ const addressLine1 = element.getAttribute('addressLine1');
541
+ if (addressLine1) {
542
+ aff.addressLine1 = addressLine1;
543
+ }
544
+ const addressLine2 = element.getAttribute('addressLine2');
545
+ if (addressLine2) {
546
+ aff.addressLine2 = addressLine2;
547
+ }
548
+ const addressLine3 = element.getAttribute('addressLine3');
549
+ if (addressLine3) {
550
+ aff.addressLine3 = addressLine3;
551
+ }
552
+ const postCode = element.getAttribute('postCode');
553
+ if (postCode) {
554
+ aff.postCode = postCode;
555
+ }
556
+ const country = element.getAttribute('country');
557
+ if (country) {
558
+ aff.country = country;
559
+ }
560
+ const priority = element.getAttribute('priority');
561
+ if (priority) {
562
+ aff.priority = parseInt(priority);
563
+ }
564
+ return aff;
565
+ },
566
+ },
567
+ {
568
+ tag: 'sec[sec-type="contributors"]',
569
+ node: 'contributors_section',
570
+ getAttrs: (node) => {
571
+ const element = node;
572
+ return {
573
+ id: element.getAttribute('id'),
574
+ category: 'MPSectionCategory:contributors',
575
+ };
576
+ },
577
+ },
578
+ {
579
+ tag: 'contrib',
580
+ node: 'contributor',
581
+ context: 'contributors_section/',
582
+ getAttrs: (node) => {
583
+ const element = node;
584
+ const contrib = {
585
+ id: element.getAttribute('id'),
586
+ };
587
+ const role = element.getAttribute('role');
588
+ if (role) {
589
+ contrib.role = role;
590
+ }
591
+ const affiliations = element.getAttribute('affiliations');
592
+ if (affiliations) {
593
+ contrib.affiliations = JSON.parse(affiliations);
594
+ }
595
+ const footnote = element.getAttribute('footnote');
596
+ if (footnote) {
597
+ contrib.footnote = JSON.parse(footnote);
598
+ }
599
+ const corresp = element.getAttribute('corresp');
600
+ if (corresp) {
601
+ contrib.corresp = JSON.parse(corresp);
602
+ }
603
+ const bibliographicName = element.getAttribute('bibliographicName');
604
+ if (bibliographicName) {
605
+ contrib.bibliographicName = JSON.parse(bibliographicName);
606
+ }
607
+ const userID = element.getAttribute('userID');
608
+ if (userID) {
609
+ contrib.userID = userID;
610
+ }
611
+ const priority = element.getAttribute('priority');
612
+ if (priority) {
613
+ contrib.priority = parseInt(priority);
614
+ }
615
+ const invitationID = element.getAttribute('invitationID');
616
+ if (invitationID) {
617
+ contrib.invitationID = invitationID;
618
+ }
619
+ const objectType = element.getAttribute('objectType');
620
+ if (objectType) {
621
+ contrib.objectType = objectType;
622
+ }
623
+ const isCorresponding = element.getAttribute('isCorresponding');
624
+ if (isCorresponding) {
625
+ contrib.isCorresponding = JSON.parse(isCorresponding);
626
+ }
627
+ const ORCIDIdentifier = element.getAttribute('ORCIDIdentifier');
628
+ if (ORCIDIdentifier) {
629
+ contrib.ORCIDIdentifier = ORCIDIdentifier;
630
+ }
631
+ return contrib;
632
+ },
633
+ },
508
634
  {
509
635
  tag: 'sec[sec-type="keywords"]',
510
636
  node: 'keywords_section',
@@ -284,6 +284,65 @@ exports.jatsBodyTransformations = {
284
284
  }
285
285
  }
286
286
  },
287
+ moveAffiliationsToBody(doc, affiliations, body, createElement) {
288
+ if (affiliations === null || affiliations === void 0 ? void 0 : affiliations.length) {
289
+ const section = createElement('sec');
290
+ section.setAttribute('sec-type', 'affiliations');
291
+ affiliations.forEach((affiliation) => {
292
+ const item = doc.createElement('aff');
293
+ item.setAttribute('id', affiliation._id);
294
+ affiliation.institution &&
295
+ item.setAttribute('institution', affiliation.institution);
296
+ affiliation.email &&
297
+ item.setAttribute('email', JSON.stringify(affiliation.email));
298
+ affiliation.department &&
299
+ item.setAttribute('department', affiliation.department);
300
+ affiliation.addressLine1 &&
301
+ item.setAttribute('addressLine1', affiliation.addressLine1);
302
+ affiliation.addressLine2 &&
303
+ item.setAttribute('addressLine2', affiliation.addressLine2);
304
+ affiliation.addressLine3 &&
305
+ item.setAttribute('addressLine3', affiliation.addressLine3);
306
+ affiliation.postCode &&
307
+ item.setAttribute('postCode', affiliation.postCode);
308
+ affiliation.country && item.setAttribute('country', affiliation.country);
309
+ (affiliation.priority === 0 || affiliation.priority) &&
310
+ item.setAttribute('priority', affiliation.priority.toString());
311
+ section.appendChild(item);
312
+ });
313
+ body.prepend(section);
314
+ }
315
+ },
316
+ moveAuthorsToBody(doc, authors, body, createElement) {
317
+ if (authors === null || authors === void 0 ? void 0 : authors.length) {
318
+ const section = createElement('sec');
319
+ section.setAttribute('sec-type', 'contributors');
320
+ authors.forEach((author) => {
321
+ const item = doc.createElement('contrib');
322
+ item.setAttribute('id', author._id);
323
+ author.role && item.setAttribute('role', author.role);
324
+ author.affiliations &&
325
+ item.setAttribute('affiliations', JSON.stringify(author.affiliations));
326
+ author.footnote &&
327
+ item.setAttribute('footnote', JSON.stringify(author.footnote));
328
+ author.corresp &&
329
+ item.setAttribute('corresp', JSON.stringify(author.corresp));
330
+ author.bibliographicName &&
331
+ item.setAttribute('bibliographicName', JSON.stringify(author.bibliographicName));
332
+ author.userID && item.setAttribute('userID', author.userID);
333
+ author.invitationID &&
334
+ item.setAttribute('invitationID', author.invitationID);
335
+ author.isCorresponding &&
336
+ item.setAttribute('isCorresponding', JSON.stringify(author.isCorresponding));
337
+ author.ORCIDIdentifier &&
338
+ item.setAttribute('ORCIDIdentifier', author.ORCIDIdentifier);
339
+ (author.priority === 0 || author.priority) &&
340
+ item.setAttribute('priority', author.priority.toString());
341
+ section.appendChild(item);
342
+ });
343
+ body.prepend(section);
344
+ }
345
+ },
287
346
  moveFloatsGroupToBody(doc, body, createElement) {
288
347
  const floatsGroup = doc.querySelector('floats-group');
289
348
  if (floatsGroup) {
@@ -21,7 +21,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
21
21
  exports.jatsFrontParser = void 0;
22
22
  const debug_1 = __importDefault(require("debug"));
23
23
  const utils_1 = require("../../lib/utils");
24
- const builders_1 = require("../../transformer/builders");
24
+ const transformer_1 = require("../../transformer");
25
25
  const jats_journal_meta_parser_1 = require("./jats-journal-meta-parser");
26
26
  const warn = (0, debug_1.default)('manuscripts-transform');
27
27
  const XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
@@ -126,7 +126,7 @@ exports.jatsFrontParser = {
126
126
  for (const supplementNode of supplementNodes) {
127
127
  const supplTitle = (_a = (0, utils_1.getTrimmedTextContent)(supplementNode, 'caption > title')) !== null && _a !== void 0 ? _a : '';
128
128
  const href = (_b = supplementNode.getAttributeNS(XLINK_NAMESPACE, 'href')) !== null && _b !== void 0 ? _b : '';
129
- const supplementaryMaterial = (0, builders_1.buildSupplementaryMaterial)(supplTitle, href);
129
+ const supplementaryMaterial = (0, transformer_1.buildSupplementaryMaterial)(supplTitle, href);
130
130
  const mimeType = (_c = supplementNode.getAttribute('mimetype')) !== null && _c !== void 0 ? _c : '';
131
131
  const mimeSubtype = (_d = supplementNode.getAttribute('mime-subtype')) !== null && _d !== void 0 ? _d : '';
132
132
  if (mimeType && mimeSubtype) {
@@ -140,7 +140,7 @@ exports.jatsFrontParser = {
140
140
  const affiliationIDs = new Map();
141
141
  const affiliations = affiliationNodes.map((affiliationNode, priority) => {
142
142
  var _a, _b;
143
- const affiliation = (0, builders_1.buildAffiliation)('', priority);
143
+ const affiliation = (0, transformer_1.buildAffiliation)('', priority);
144
144
  for (const node of affiliationNode.querySelectorAll('institution')) {
145
145
  const content = (_a = node.textContent) === null || _a === void 0 ? void 0 : _a.trim();
146
146
  if (!content) {
@@ -190,7 +190,7 @@ exports.jatsFrontParser = {
190
190
  parseFootnoteNodes(footnoteNodes) {
191
191
  const footnoteIDs = new Map();
192
192
  const footnotes = footnoteNodes.map((footnoteNode) => {
193
- const fn = (0, builders_1.buildFootnote)('', footnoteNode.innerHTML);
193
+ const fn = (0, transformer_1.buildFootnote)('', footnoteNode.innerHTML);
194
194
  const id = footnoteNode.getAttribute('id');
195
195
  if (id) {
196
196
  footnoteIDs.set(id, fn._id);
@@ -210,7 +210,7 @@ exports.jatsFrontParser = {
210
210
  if (label) {
211
211
  label.remove();
212
212
  }
213
- const corresponding = (0, builders_1.buildCorresp)((_b = (_a = correspNode.textContent) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : '');
213
+ const corresponding = (0, transformer_1.buildCorresp)((_b = (_a = correspNode.textContent) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : '');
214
214
  corresponding.label = ((_c = label === null || label === void 0 ? void 0 : label.textContent) === null || _c === void 0 ? void 0 : _c.trim()) || undefined;
215
215
  const id = correspNode.getAttribute('id');
216
216
  if (id) {
@@ -226,7 +226,7 @@ exports.jatsFrontParser = {
226
226
  parseAuthorNodes(authorNodes, affiliationIDs, footnoteIDs, correspondingIDs) {
227
227
  return authorNodes.map((authorNode, priority) => {
228
228
  var _a, _b;
229
- const name = (0, builders_1.buildBibliographicName)({});
229
+ const name = (0, transformer_1.buildBibliographicName)({});
230
230
  const given = (0, utils_1.getTrimmedTextContent)(authorNode, 'name > given-names');
231
231
  if (given) {
232
232
  name.given = given;
@@ -235,7 +235,7 @@ exports.jatsFrontParser = {
235
235
  if (surname) {
236
236
  name.family = surname;
237
237
  }
238
- const contributor = (0, builders_1.buildContributor)(name, 'author', priority);
238
+ const contributor = (0, transformer_1.buildContributor)(name, 'author', priority);
239
239
  const corresponding = authorNode.getAttribute('corresp') === 'yes';
240
240
  if (corresponding) {
241
241
  contributor.isCorresponding = corresponding;
@@ -19,6 +19,7 @@ exports.htmlFromJatsNode = exports.fixBodyPMNode = exports.flatten = void 0;
19
19
  const json_schema_1 = require("@manuscripts/json-schema");
20
20
  const transformer_1 = require("../../transformer");
21
21
  const isAuxiliaryObjectReference = (0, transformer_1.hasObjectType)(json_schema_1.ObjectTypes.AuxiliaryObjectReference);
22
+ const excludedObjectTypes = [json_schema_1.ObjectTypes.Contributor, json_schema_1.ObjectTypes.Affiliation];
22
23
  function flatten(arrays) {
23
24
  return [].concat(...arrays);
24
25
  }
@@ -49,6 +50,9 @@ const addMissingID = (node, replacements, warnings) => {
49
50
  warnings.push(`Unknown object type for node type ${node.type.name}`);
50
51
  return;
51
52
  }
53
+ if (excludedObjectTypes.includes(objectType)) {
54
+ return;
55
+ }
52
56
  const previousID = node.attrs.id;
53
57
  const nextID = (0, transformer_1.generateID)(objectType);
54
58
  if (previousID) {
@@ -74,13 +74,13 @@ const parseJATSFront = async (front) => {
74
74
  return {
75
75
  models: generateModelIDs([
76
76
  manuscript,
77
- ...affiliations,
78
- ...authors,
79
77
  ...footnotes,
80
78
  ...correspondingList,
81
79
  journal,
82
80
  ...supplements,
83
81
  ]),
82
+ authors: [...authors],
83
+ affiliations: [...affiliations],
84
84
  };
85
85
  };
86
86
  exports.parseJATSFront = parseJATSFront;
@@ -106,7 +106,7 @@ const parseJATSReferences = (back, body, createElement) => {
106
106
  };
107
107
  };
108
108
  exports.parseJATSReferences = parseJATSReferences;
109
- const parseJATSBody = (document, body, bibliographyItems, refModels, referenceIdsMap, footnotesOrder) => {
109
+ const parseJATSBody = (document, body, bibliographyItems, authors, affiliations, refModels, referenceIdsMap, footnotesOrder) => {
110
110
  const createElement = createElementFn(document);
111
111
  const orderedFootnotesIDs = (0, footnotes_order_1.createOrderedFootnotesIDs)(document);
112
112
  jats_body_transformations_1.jatsBodyTransformations.moveFloatsGroupToBody(document, body, createElement);
@@ -116,6 +116,8 @@ const parseJATSBody = (document, body, bibliographyItems, refModels, referenceId
116
116
  jats_body_transformations_1.jatsBodyTransformations.moveTableFooterToEnd(body);
117
117
  jats_body_transformations_1.jatsBodyTransformations.moveBlockNodesFromParagraph(document, body, createElement);
118
118
  jats_body_transformations_1.jatsBodyTransformations.moveKeywordsToBody(document, body, createElement);
119
+ jats_body_transformations_1.jatsBodyTransformations.moveAffiliationsToBody(document, affiliations, body, createElement);
120
+ jats_body_transformations_1.jatsBodyTransformations.moveAuthorsToBody(document, authors, body, createElement);
119
121
  const node = jats_body_dom_parser_1.jatsBodyDOMParser.parse(body);
120
122
  if (!node.firstChild) {
121
123
  throw new Error('No content was parsed from the JATS article body');
@@ -168,14 +170,14 @@ const parseJATSArticle = async (doc) => {
168
170
  }
169
171
  const authorQueriesMap = (0, jats_comments_1.markProcessingInstructions)(doc);
170
172
  const createElement = createElementFn(document);
171
- const { models: frontModels } = await (0, exports.parseJATSFront)(front);
173
+ const { models: frontModels, authors, affiliations, } = await (0, exports.parseJATSFront)(front);
172
174
  const { references, crossReferences, referenceQueriesMap, referenceIdsMap } = (0, exports.parseJATSReferences)(back, body, createElement);
173
175
  transformTables(doc.querySelectorAll('table-wrap > table'), createElement);
174
176
  const footnotesOrder = (0, footnotes_order_1.createEmptyFootnotesOrder)();
175
177
  let elementsOrder = [];
176
178
  const bodyModels = [];
177
179
  if (body) {
178
- const bodyDoc = (0, exports.parseJATSBody)(doc, body, references, crossReferences, referenceIdsMap, footnotesOrder);
180
+ const bodyDoc = (0, exports.parseJATSBody)(doc, body, references, authors, affiliations, crossReferences, referenceIdsMap, footnotesOrder);
179
181
  bodyModels.push(...(0, encode_1.encode)(bodyDoc).values());
180
182
  elementsOrder = (0, exports.getElementsOrder)(bodyDoc);
181
183
  }
@@ -598,10 +598,10 @@ class JATSExporter {
598
598
  this.createSerializer = () => {
599
599
  const getModel = (id) => id ? this.modelMap.get(id) : undefined;
600
600
  const nodes = {
601
+ affiliations_section: () => '',
602
+ contributors_section: () => '',
601
603
  table_element_footer: () => ['table-wrap-foot', 0],
602
- contributor_list: () => '',
603
604
  contributor: () => '',
604
- affiliation_list: () => '',
605
605
  affiliation: () => '',
606
606
  meta_section: () => '',
607
607
  attribution: () => ['attrib', 0],
@@ -16,7 +16,7 @@ exports.coreSectionCategories = [
16
16
  desc: 'Backmatter section for grouping',
17
17
  objectType: 'MPSectionCategory',
18
18
  titles: [],
19
- priority: 170,
19
+ priority: 180,
20
20
  },
21
21
  {
22
22
  _id: 'MPSectionCategory:body',
@@ -24,6 +24,6 @@ exports.coreSectionCategories = [
24
24
  desc: 'Body section for grouping',
25
25
  objectType: 'MPSectionCategory',
26
26
  titles: [],
27
- priority: 190,
27
+ priority: 200,
28
28
  },
29
29
  ];
@@ -33,7 +33,7 @@ exports.schema = void 0;
33
33
  const prosemirror_model_1 = require("prosemirror-model");
34
34
  const marks_1 = require("./marks");
35
35
  const affiliation_1 = require("./nodes/affiliation");
36
- const affiliation_list_1 = require("./nodes/affiliation_list");
36
+ const affiliations_section_1 = require("./nodes/affiliations_section");
37
37
  const attribution_1 = require("./nodes/attribution");
38
38
  const bibliography_element_1 = require("./nodes/bibliography_element");
39
39
  const bibliography_item_1 = require("./nodes/bibliography_item");
@@ -45,7 +45,7 @@ const citation_1 = require("./nodes/citation");
45
45
  const comment_1 = require("./nodes/comment");
46
46
  const comment_list_1 = require("./nodes/comment_list");
47
47
  const contributor_1 = require("./nodes/contributor");
48
- const contributor_list_1 = require("./nodes/contributor_list");
48
+ const contributors_section_1 = require("./nodes/contributors_section");
49
49
  const cross_reference_1 = require("./nodes/cross_reference");
50
50
  const doc_1 = require("./nodes/doc");
51
51
  const equation_1 = require("./nodes/equation");
@@ -137,11 +137,11 @@ __exportStar(require("./nodes/text"), exports);
137
137
  __exportStar(require("./nodes/toc_element"), exports);
138
138
  __exportStar(require("./nodes/toc_section"), exports);
139
139
  __exportStar(require("./nodes/affiliation"), exports);
140
- __exportStar(require("./nodes/affiliation_list"), exports);
141
140
  __exportStar(require("./nodes/meta_section"), exports);
142
- __exportStar(require("./nodes/contributor_list"), exports);
143
141
  __exportStar(require("./nodes/contributor"), exports);
144
142
  __exportStar(require("./nodes/table_element_footer"), exports);
143
+ __exportStar(require("./nodes/affiliations_section"), exports);
144
+ __exportStar(require("./nodes/contributors_section"), exports);
145
145
  exports.schema = new prosemirror_model_1.Schema({
146
146
  marks: {
147
147
  bold: marks_1.bold,
@@ -214,9 +214,9 @@ exports.schema = new prosemirror_model_1.Schema({
214
214
  toc_section: toc_section_1.tocSection,
215
215
  affiliation: affiliation_1.affiliation,
216
216
  meta_section: meta_section_1.metaSection,
217
- affiliation_list: affiliation_list_1.affiliationList,
218
- contributor_list: contributor_list_1.contributorList,
219
217
  contributor: contributor_1.contributor,
220
218
  table_element_footer: table_element_footer_1.tableElementFooter,
219
+ affiliations_section: affiliations_section_1.affiliationsSection,
220
+ contributors_section: contributors_section_1.contributorsSection,
221
221
  },
222
222
  });
@@ -11,6 +11,7 @@ exports.affiliation = {
11
11
  addressLine3: { default: '' },
12
12
  postCode: { default: '' },
13
13
  country: { default: '' },
14
+ priority: { default: undefined },
14
15
  email: {
15
16
  default: {
16
17
  href: undefined,
@@ -18,6 +19,8 @@ exports.affiliation = {
18
19
  },
19
20
  },
20
21
  },
22
+ group: 'block element',
23
+ toDOM: () => ['span'],
21
24
  };
22
25
  const isAffiliationNode = (node) => node.type === node.type.schema.nodes.affiliation;
23
26
  exports.isAffiliationNode = isAffiliationNode;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isAffiliationsSectionNode = exports.affiliationsSection = void 0;
4
+ exports.affiliationsSection = {
5
+ content: 'section_title? affiliation*',
6
+ attrs: {
7
+ id: { default: '' },
8
+ dataTracked: { default: null },
9
+ },
10
+ group: 'block sections',
11
+ selectable: false,
12
+ toDOM: () => ['section', 0],
13
+ };
14
+ const isAffiliationsSectionNode = (node) => node.type === node.type.schema.nodes.affiliations_section;
15
+ exports.isAffiliationsSectionNode = isAffiliationsSectionNode;
@@ -1,15 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.contributor = void 0;
3
+ exports.isContributorNode = exports.contributor = void 0;
4
4
  exports.contributor = {
5
5
  attrs: {
6
6
  id: { default: '' },
7
7
  role: { default: '' },
8
8
  affiliations: { default: [] },
9
+ footnote: { default: undefined },
10
+ corresp: { default: undefined },
9
11
  bibliographicName: { default: {} },
10
12
  userID: { default: undefined },
11
13
  invitationID: { default: undefined },
12
14
  isCorresponding: { default: undefined },
13
15
  ORCIDIdentifier: { default: undefined },
16
+ priority: { default: undefined },
14
17
  },
18
+ group: 'block element',
19
+ toDOM: () => ['span'],
15
20
  };
21
+ const isContributorNode = (node) => node.type === node.type.schema.nodes.contributor;
22
+ exports.isContributorNode = isContributorNode;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isContributorsSectionNode = exports.contributorsSection = void 0;
4
+ exports.contributorsSection = {
5
+ content: 'section_title? contributor*',
6
+ attrs: {
7
+ id: { default: '' },
8
+ dataTracked: { default: null },
9
+ },
10
+ group: 'block sections',
11
+ selectable: false,
12
+ toDOM: () => ['section', 0],
13
+ };
14
+ const isContributorsSectionNode = (node) => node.type === node.type.schema.nodes.contributors_section;
15
+ exports.isContributorsSectionNode = isContributorsSectionNode;
@@ -17,7 +17,7 @@
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.metaSection = void 0;
19
19
  exports.metaSection = {
20
- content: 'affiliation_list contributor_list comment_list',
20
+ content: 'comment_list',
21
21
  attrs: {
22
22
  id: { default: 'META_SECTION' },
23
23
  },
@@ -67,29 +67,16 @@ exports.isManuscriptNode = isManuscriptNode;
67
67
  const isParagraphElement = (0, object_types_1.hasObjectType)(json_schema_1.ObjectTypes.ParagraphElement);
68
68
  const isFootnote = (0, object_types_1.hasObjectType)(json_schema_1.ObjectTypes.Footnote);
69
69
  const isKeyword = (0, object_types_1.hasObjectType)(json_schema_1.ObjectTypes.Keyword);
70
+ const isKeywordsSection = (model) => model.category === 'MPSectionCategory:keywords';
71
+ const isAffiliationsSection = (model) => model.category === 'MPSectionCategory:affiliations';
72
+ const isContributorsSection = (model) => model.category === 'MPSectionCategory:contributors';
70
73
  const hasParentSection = (id) => (section) => section.path &&
71
74
  section.path.length > 1 &&
72
75
  section.path[section.path.length - 2] === id;
73
76
  class Decoder {
74
- createAffiliationListNode() {
75
- const affiliationNodes = getAffiliations(this.modelMap)
76
- .map((affiliation) => this.decode(affiliation))
77
- .filter(Boolean);
78
- return schema_1.schema.nodes.affiliation_list.createAndFill({}, affiliationNodes);
79
- }
80
- createContributorListNode() {
81
- const contributorNodes = getContributors(this.modelMap)
82
- .map((contributor) => this.decode(contributor))
83
- .filter(Boolean);
84
- return schema_1.schema.nodes.contributor_list.createAndFill({}, contributorNodes);
85
- }
86
77
  createMetaSectionNode() {
87
- const affiliationListNode = this.createAffiliationListNode();
88
- const contributorListNode = this.createContributorListNode();
89
78
  const commentListNode = this.createCommentListNode();
90
79
  return schema_1.schema.nodes.meta_section.createAndFill({}, [
91
- affiliationListNode,
92
- contributorListNode,
93
80
  commentListNode,
94
81
  ]);
95
82
  }
@@ -98,12 +85,43 @@ class Decoder {
98
85
  ...this.comments.values(),
99
86
  ]);
100
87
  }
88
+ handleMissingRootSectionNodes(rootSectionNodes) {
89
+ if (!rootSectionNodes.find((node) => node.type.name === 'affiliations_section')) {
90
+ this.createAffiliationSectionNode(rootSectionNodes);
91
+ }
92
+ if (!rootSectionNodes.find((node) => node.type.name === 'contributors_section')) {
93
+ this.createContributorSectionNode(rootSectionNodes);
94
+ }
95
+ }
96
+ createAffiliationSectionNode(rootSectionNodes) {
97
+ const affiliationNodes = getAffiliations(this.modelMap)
98
+ .map((affiliation) => this.decode(affiliation))
99
+ .filter(Boolean);
100
+ if (affiliationNodes.length) {
101
+ const node = schema_1.schema.nodes.affiliations_section.createAndFill({
102
+ id: (0, id_1.generateNodeID)(schema_1.schema.nodes.section),
103
+ }, affiliationNodes);
104
+ rootSectionNodes.unshift(node);
105
+ }
106
+ }
107
+ createContributorSectionNode(rootSectionNodes) {
108
+ const contributorNodes = getContributors(this.modelMap)
109
+ .map((contributor) => this.decode(contributor))
110
+ .filter(Boolean);
111
+ if (contributorNodes.length) {
112
+ const node = schema_1.schema.nodes.contributors_section.createAndFill({
113
+ id: (0, id_1.generateNodeID)(schema_1.schema.nodes.section),
114
+ }, contributorNodes);
115
+ rootSectionNodes.unshift(node);
116
+ }
117
+ }
101
118
  createRootSectionNodes() {
102
119
  let rootSections = getSections(this.modelMap).filter((section) => !section.path || section.path.length <= 1);
103
120
  rootSections = this.addGeneratedLabels(rootSections);
104
121
  const rootSectionNodes = rootSections
105
122
  .map(this.decode)
106
123
  .filter(exports.isManuscriptNode);
124
+ this.handleMissingRootSectionNodes(rootSectionNodes);
107
125
  if (!rootSectionNodes.length) {
108
126
  rootSectionNodes.push(schema_1.schema.nodes.section.createAndFill({
109
127
  id: (0, id_1.generateNodeID)(schema_1.schema.nodes.section),
@@ -436,13 +454,12 @@ class Decoder {
436
454
  },
437
455
  [json_schema_1.ObjectTypes.Section]: (data) => {
438
456
  const model = data;
439
- const isKeywordsSection = model.category === 'MPSectionCategory:keywords';
440
457
  const elements = [];
441
458
  if (model.elementIDs) {
442
459
  for (const id of model.elementIDs) {
443
460
  const element = this.getModel(id);
444
461
  if (element) {
445
- if (isKeywordsSection && isParagraphElement(element)) {
462
+ if (isKeywordsSection(model) && isParagraphElement(element)) {
446
463
  continue;
447
464
  }
448
465
  elements.push(element);
@@ -485,11 +502,17 @@ class Decoder {
485
502
  const sectionNodeType = (0, section_category_1.chooseSectionNodeType)(sectionCategory);
486
503
  const commentNodes = this.createCommentsNode(model);
487
504
  commentNodes.forEach((c) => this.comments.set(c.attrs.id, c));
488
- const content = (sectionLabelNode
489
- ? [sectionLabelNode, sectionTitleNode]
490
- : [sectionTitleNode])
491
- .concat(elementNodes)
492
- .concat(nestedSections);
505
+ let content;
506
+ if (isAffiliationsSection(model) || isContributorsSection(model)) {
507
+ content = elementNodes.concat(nestedSections);
508
+ }
509
+ else {
510
+ content = (sectionLabelNode
511
+ ? [sectionLabelNode, sectionTitleNode]
512
+ : [sectionTitleNode])
513
+ .concat(elementNodes)
514
+ .concat(nestedSections);
515
+ }
493
516
  const sectionNode = sectionNodeType.createAndFill({
494
517
  id: model._id,
495
518
  category: sectionCategory,
@@ -578,6 +601,8 @@ class Decoder {
578
601
  postCode: model.postCode,
579
602
  country: model.country,
580
603
  email: model.email,
604
+ department: model.department,
605
+ priority: model.priority,
581
606
  });
582
607
  },
583
608
  [json_schema_1.ObjectTypes.Contributor]: (data) => {
@@ -591,6 +616,9 @@ class Decoder {
591
616
  invitationID: model.invitationID,
592
617
  isCorresponding: model.isCorresponding,
593
618
  ORCIDIdentifier: model.ORCIDIdentifier,
619
+ footnote: model.footnote,
620
+ corresp: model.corresp,
621
+ priority: model.priority,
594
622
  });
595
623
  },
596
624
  };
@@ -434,6 +434,22 @@ const encoders = {
434
434
  .map((childNode) => childNode.attrs.id)
435
435
  .filter((id) => id),
436
436
  }),
437
+ affiliations_section: (node, parent, path, priority) => ({
438
+ category: (0, section_category_1.buildSectionCategory)(node),
439
+ priority: priority.value++,
440
+ path: path.concat([node.attrs.id]),
441
+ elementIDs: childElements(node)
442
+ .map((childNode) => childNode.attrs.id)
443
+ .filter((id) => id),
444
+ }),
445
+ contributors_section: (node, parent, path, priority) => ({
446
+ category: (0, section_category_1.buildSectionCategory)(node),
447
+ priority: priority.value++,
448
+ path: path.concat([node.attrs.id]),
449
+ elementIDs: childElements(node)
450
+ .map((childNode) => childNode.attrs.id)
451
+ .filter((id) => id),
452
+ }),
437
453
  missing_figure: (node) => ({
438
454
  position: node.attrs.position || undefined,
439
455
  }),
@@ -514,6 +530,7 @@ const encoders = {
514
530
  postCode: node.attrs.postCode,
515
531
  country: node.attrs.country,
516
532
  email: node.attrs.email,
533
+ priority: node.attrs.priority,
517
534
  }),
518
535
  contributor: (node) => ({
519
536
  role: node.attrs.role,
@@ -523,6 +540,9 @@ const encoders = {
523
540
  invitationID: node.attrs.invitationID,
524
541
  isCorresponding: node.attrs.isCorresponding,
525
542
  ORCIDIdentifier: node.attrs.ORCIDIdentifier,
543
+ footnote: node.attrs.footnote,
544
+ corresp: node.attrs.corresp,
545
+ priority: node.attrs.priority,
526
546
  }),
527
547
  };
528
548
  const modelData = (node, parent, path, priority) => {