@manuscripts/transform 1.5.7 → 1.5.8-LEAN-3030

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 (131) hide show
  1. package/dist/cjs/index.js +1 -1
  2. package/dist/cjs/jats/importer/index.js +1 -3
  3. package/dist/cjs/jats/importer/jats-body-dom-parser.js +23 -227
  4. package/dist/cjs/jats/importer/jats-body-transformations.js +110 -201
  5. package/dist/cjs/jats/importer/jats-comments.js +100 -98
  6. package/dist/cjs/jats/importer/jats-front-parser.js +87 -81
  7. package/dist/cjs/jats/importer/jats-journal-meta-parser.js +51 -39
  8. package/dist/cjs/jats/importer/jats-parser-utils.js +17 -56
  9. package/dist/cjs/jats/importer/jats-reference-parser.js +24 -79
  10. package/dist/cjs/jats/importer/jats-references.js +34 -0
  11. package/dist/cjs/jats/importer/parse-jats-article.js +67 -173
  12. package/dist/cjs/jats/index.js +1 -3
  13. package/dist/cjs/jats/jats-exporter.js +33 -54
  14. package/dist/cjs/lib/section-group-type.js +30 -0
  15. package/dist/cjs/lib/utils.js +23 -1
  16. package/dist/cjs/schema/index.js +20 -17
  17. package/dist/cjs/schema/nodes/abstracts.js +27 -0
  18. package/dist/cjs/schema/nodes/affiliations.js +27 -0
  19. package/dist/cjs/schema/nodes/backmatter.js +27 -0
  20. package/dist/cjs/schema/nodes/body.js +27 -0
  21. package/dist/cjs/schema/nodes/citation.js +10 -15
  22. package/dist/cjs/schema/nodes/{comment_list.js → comments.js} +4 -4
  23. package/dist/cjs/schema/nodes/contributors.js +27 -0
  24. package/dist/cjs/schema/nodes/{meta_section.js → core_section.js} +6 -5
  25. package/dist/cjs/schema/nodes/cross_reference.js +4 -3
  26. package/dist/cjs/schema/nodes/inline_footnote.js +6 -5
  27. package/dist/cjs/schema/nodes/keyword.js +0 -1
  28. package/dist/cjs/schema/nodes/{keywords_group.js → keyword_group.js} +6 -6
  29. package/dist/cjs/schema/nodes/{keywords_section.js → keywords.js} +7 -7
  30. package/dist/cjs/schema/nodes/keywords_element.js +1 -1
  31. package/dist/cjs/schema/nodes/manuscript.js +5 -2
  32. package/dist/cjs/transformer/builders.js +9 -86
  33. package/dist/cjs/transformer/decode.js +143 -162
  34. package/dist/cjs/transformer/encode.js +54 -45
  35. package/dist/cjs/transformer/highlight-markers.js +4 -4
  36. package/dist/cjs/transformer/html.js +5 -20
  37. package/dist/cjs/transformer/node-names.js +1 -1
  38. package/dist/cjs/transformer/node-title.js +1 -1
  39. package/dist/cjs/transformer/node-types.js +7 -6
  40. package/dist/cjs/transformer/object-types.js +1 -2
  41. package/dist/cjs/transformer/section-category.js +35 -17
  42. package/dist/es/index.js +1 -1
  43. package/dist/es/jats/importer/index.js +1 -1
  44. package/dist/es/jats/importer/jats-body-dom-parser.js +23 -227
  45. package/dist/es/jats/importer/jats-body-transformations.js +111 -202
  46. package/dist/es/jats/importer/jats-comments.js +97 -96
  47. package/dist/es/jats/importer/jats-front-parser.js +88 -82
  48. package/dist/es/jats/importer/jats-journal-meta-parser.js +51 -39
  49. package/dist/es/jats/importer/jats-parser-utils.js +16 -54
  50. package/dist/es/jats/importer/jats-reference-parser.js +27 -82
  51. package/dist/es/jats/importer/jats-references.js +30 -0
  52. package/dist/es/jats/importer/parse-jats-article.js +70 -174
  53. package/dist/es/jats/index.js +1 -1
  54. package/dist/es/jats/jats-exporter.js +33 -54
  55. package/dist/es/lib/section-group-type.js +27 -0
  56. package/dist/es/lib/utils.js +20 -0
  57. package/dist/es/schema/index.js +21 -18
  58. package/dist/es/schema/nodes/abstracts.js +24 -0
  59. package/dist/es/schema/nodes/affiliations.js +24 -0
  60. package/dist/es/schema/nodes/backmatter.js +24 -0
  61. package/dist/es/schema/nodes/body.js +24 -0
  62. package/dist/es/schema/nodes/citation.js +10 -15
  63. package/dist/es/schema/nodes/{comment_list.js → comments.js} +3 -3
  64. package/dist/es/schema/nodes/contributors.js +24 -0
  65. package/dist/es/schema/nodes/{meta_section.js → core_section.js} +5 -4
  66. package/dist/es/schema/nodes/cross_reference.js +4 -3
  67. package/dist/es/schema/nodes/inline_footnote.js +6 -5
  68. package/dist/es/schema/nodes/keyword.js +0 -1
  69. package/dist/es/schema/nodes/{keywords_group.js → keyword_group.js} +4 -4
  70. package/dist/es/schema/nodes/{keywords_section.js → keywords.js} +5 -5
  71. package/dist/es/schema/nodes/keywords_element.js +1 -1
  72. package/dist/es/schema/nodes/manuscript.js +3 -1
  73. package/dist/es/transformer/builders.js +6 -73
  74. package/dist/es/transformer/decode.js +143 -161
  75. package/dist/es/transformer/encode.js +57 -48
  76. package/dist/es/transformer/highlight-markers.js +1 -1
  77. package/dist/es/transformer/html.js +5 -20
  78. package/dist/es/transformer/node-names.js +1 -1
  79. package/dist/es/transformer/node-title.js +1 -1
  80. package/dist/es/transformer/node-types.js +7 -6
  81. package/dist/es/transformer/object-types.js +0 -1
  82. package/dist/es/transformer/section-category.js +33 -15
  83. package/dist/types/index.d.ts +1 -1
  84. package/dist/types/jats/importer/index.d.ts +1 -1
  85. package/dist/types/jats/importer/jats-body-transformations.d.ts +16 -19
  86. package/dist/types/jats/importer/jats-comments.d.ts +13 -9
  87. package/dist/types/jats/importer/jats-front-parser.d.ts +35 -12
  88. package/dist/types/jats/importer/jats-journal-meta-parser.d.ts +4 -4
  89. package/dist/types/jats/importer/jats-parser-utils.d.ts +1 -6
  90. package/dist/types/jats/importer/jats-reference-parser.d.ts +2 -6
  91. package/dist/types/jats/importer/jats-references.d.ts +12 -0
  92. package/dist/types/jats/importer/parse-jats-article.d.ts +5 -17
  93. package/dist/types/jats/index.d.ts +1 -1
  94. package/dist/types/lib/section-group-type.d.ts +31 -0
  95. package/dist/types/lib/utils.d.ts +4 -1
  96. package/dist/types/schema/index.d.ts +4 -5
  97. package/dist/types/schema/nodes/{meta_section.d.ts → abstracts.d.ts} +1 -9
  98. package/dist/types/schema/nodes/affiliations.d.ts +17 -0
  99. package/dist/types/schema/nodes/backmatter.d.ts +17 -0
  100. package/dist/types/schema/nodes/body.d.ts +17 -0
  101. package/dist/types/schema/nodes/citation.d.ts +3 -5
  102. package/dist/types/schema/nodes/comments.d.ts +17 -0
  103. package/dist/types/schema/nodes/contributors.d.ts +17 -0
  104. package/dist/types/schema/nodes/core_section.d.ts +17 -0
  105. package/dist/types/schema/nodes/cross_reference.d.ts +1 -1
  106. package/dist/types/schema/nodes/inline_footnote.d.ts +1 -1
  107. package/dist/types/schema/nodes/keyword.d.ts +0 -1
  108. package/dist/types/schema/nodes/{contributors_element.d.ts → keyword_group.d.ts} +3 -4
  109. package/dist/types/schema/nodes/{comment_list.d.ts → keywords.d.ts} +3 -2
  110. package/dist/types/schema/nodes/manuscript.d.ts +1 -0
  111. package/dist/types/schema/types.d.ts +1 -1
  112. package/dist/types/transformer/builders.d.ts +2 -14
  113. package/dist/types/transformer/decode.d.ts +7 -9
  114. package/dist/types/transformer/encode.d.ts +1 -1
  115. package/dist/types/transformer/highlight-markers.d.ts +1 -0
  116. package/dist/types/transformer/object-types.d.ts +1 -2
  117. package/dist/types/transformer/section-category.d.ts +1 -1
  118. package/package.json +1 -1
  119. package/dist/cjs/lib/core-section-categories.js +0 -29
  120. package/dist/cjs/schema/nodes/affiliations_section.js +0 -36
  121. package/dist/cjs/schema/nodes/contributors_element.js +0 -49
  122. package/dist/cjs/schema/nodes/contributors_section.js +0 -36
  123. package/dist/es/lib/core-section-categories.js +0 -26
  124. package/dist/es/schema/nodes/affiliations_section.js +0 -32
  125. package/dist/es/schema/nodes/contributors_element.js +0 -46
  126. package/dist/es/schema/nodes/contributors_section.js +0 -32
  127. package/dist/types/lib/core-section-categories.d.ts +0 -8
  128. package/dist/types/schema/nodes/affiliations_section.d.ts +0 -11
  129. package/dist/types/schema/nodes/contributors_section.d.ts +0 -12
  130. package/dist/types/schema/nodes/keywords_group.d.ts +0 -26
  131. package/dist/types/schema/nodes/keywords_section.d.ts +0 -26
@@ -25,6 +25,7 @@ const utils_1 = require("../lib/utils");
25
25
  const schema_1 = require("../schema");
26
26
  const builders_1 = require("./builders");
27
27
  const highlight_markers_1 = require("./highlight-markers");
28
+ const id_1 = require("./id");
28
29
  const node_types_1 = require("./node-types");
29
30
  const section_category_1 = require("./section-category");
30
31
  const serializer = prosemirror_model_1.DOMSerializer.fromSchema(schema_1.schema);
@@ -428,34 +429,9 @@ const encoders = {
428
429
  elementType: 'div',
429
430
  paragraphStyle: node.attrs.paragraphStyle || undefined,
430
431
  }),
431
- keywords_group: (node) => ({
432
+ keyword_group: (node) => ({
432
433
  type: node.attrs.type,
433
434
  }),
434
- keywords_section: (node, parent, path, priority) => ({
435
- category: (0, section_category_1.buildSectionCategory)(node),
436
- priority: priority.value++,
437
- title: inlineContentsOfNodeType(node, node.type.schema.nodes.section_title),
438
- path: path.concat([node.attrs.id]),
439
- elementIDs: childElements(node)
440
- .map((childNode) => childNode.attrs.id)
441
- .filter((id) => id),
442
- }),
443
- affiliations_section: (node, parent, path, priority) => ({
444
- category: (0, section_category_1.buildSectionCategory)(node),
445
- priority: priority.value++,
446
- path: path.concat([node.attrs.id]),
447
- elementIDs: childElements(node)
448
- .map((childNode) => childNode.attrs.id)
449
- .filter((id) => id),
450
- }),
451
- contributors_section: (node, parent, path, priority) => ({
452
- category: (0, section_category_1.buildSectionCategory)(node),
453
- priority: priority.value++,
454
- path: path.concat([node.attrs.id]),
455
- elementIDs: childElements(node)
456
- .map((childNode) => childNode.attrs.id)
457
- .filter((id) => id),
458
- }),
459
435
  missing_figure: (node) => ({
460
436
  position: node.attrs.position || undefined,
461
437
  }),
@@ -577,28 +553,48 @@ const modelFromNode = (node, parent, path, priority) => {
577
553
  return { model, comments };
578
554
  };
579
555
  exports.modelFromNode = modelFromNode;
580
- const encode = (node) => {
556
+ const containerTypes = [
557
+ schema_1.schema.nodes.affiliations,
558
+ schema_1.schema.nodes.contributors,
559
+ schema_1.schema.nodes.affiliations,
560
+ schema_1.schema.nodes.keywords,
561
+ schema_1.schema.nodes.abstracts,
562
+ schema_1.schema.nodes.body,
563
+ schema_1.schema.nodes.backmatter,
564
+ schema_1.schema.nodes.comments,
565
+ ];
566
+ const encode = (node, preserveWithRepeatedID = false) => {
581
567
  const models = new Map();
582
568
  const priority = {
583
569
  value: 1,
584
570
  };
585
571
  const placeholders = ['placeholder', 'placeholder_element'];
586
- const addModel = (path, parent) => (child) => {
572
+ const processNode = (path, parent) => (child) => {
573
+ if (containerTypes.includes(child.type)) {
574
+ child.forEach(processNode([], child));
575
+ return;
576
+ }
587
577
  if (!child.attrs.id) {
588
578
  return;
589
579
  }
590
580
  if ((0, schema_1.isHighlightMarkerNode)(child)) {
591
581
  return;
592
582
  }
593
- if (child.type === schema_1.schema.nodes.meta_section) {
583
+ if (placeholders.includes(child.type.name)) {
594
584
  return;
595
585
  }
596
- if (placeholders.includes(child.type.name)) {
586
+ if (parent.type === schema_1.schema.nodes.paragraph) {
597
587
  return;
598
588
  }
599
589
  const { model, comments } = (0, exports.modelFromNode)(child, parent, path, priority);
600
- if (models.has(model._id)) {
601
- throw Error(`Encountered duplicate ids in models map while encoding: ${model._id}`);
590
+ const existingModel = models.get(model._id);
591
+ if (existingModel) {
592
+ if (preserveWithRepeatedID && !(0, utils_1.modelsEqual)(model, existingModel)) {
593
+ model._id = (0, id_1.generateID)(model.objectType);
594
+ }
595
+ else {
596
+ throw Error(`Encountered duplicate ids in models map while encoding: ${model._id}`);
597
+ }
602
598
  }
603
599
  comments.forEach((comment) => {
604
600
  const proseMirrorComment = models.get(comment._id);
@@ -609,23 +605,36 @@ const encode = (node) => {
609
605
  }
610
606
  });
611
607
  models.set(model._id, model);
612
- child.forEach(addModel(path.concat(child.attrs.id), child));
608
+ child.forEach(processNode(path.concat(child.attrs.id), child));
613
609
  };
614
- node.forEach((cNode) => {
615
- if (cNode.type === schema_1.schema.nodes.meta_section) {
616
- processMetaSectionNode(cNode, models, priority);
617
- }
618
- });
619
- node.forEach(addModel([], node));
610
+ node.forEach(processNode([], node));
611
+ if ((0, schema_1.isManuscriptNode)(node)) {
612
+ builders_1.auxiliaryObjectTypes.forEach((t) => {
613
+ const order = generateElementOrder(node, t);
614
+ if (order) {
615
+ models.set(order._id, order);
616
+ }
617
+ });
618
+ }
620
619
  return models;
621
620
  };
622
621
  exports.encode = encode;
623
- const processMetaSectionNode = (node, models, priority) => {
624
- node.descendants((child) => {
625
- if ((!child.content || child.content.size === 0) &&
626
- node_types_1.nodeTypesMap.get(child.type)) {
627
- const { model } = (0, exports.modelFromNode)(child, node, [], priority);
628
- models.set(model._id, model);
622
+ const generateElementOrder = (node, nodeType) => {
623
+ const ids = [];
624
+ node.descendants((n) => {
625
+ if (n.type === nodeType) {
626
+ ids.push(n.attrs.id);
629
627
  }
628
+ return true;
630
629
  });
630
+ if (!ids.length) {
631
+ return undefined;
632
+ }
633
+ const type = node_types_1.nodeTypesMap.get(nodeType);
634
+ if (!type) {
635
+ return undefined;
636
+ }
637
+ const order = (0, builders_1.buildElementsOrder)(type);
638
+ order.elements = ids;
639
+ return order;
631
640
  };
@@ -15,15 +15,15 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.insertHighlightMarkers = exports.extractHighlightMarkers = exports.isHighlightableModel = void 0;
18
+ exports.insertHighlightMarkers = exports.extractHighlightMarkers = exports.isHighlightableModel = exports.highlightableFields = void 0;
19
19
  const builders_1 = require("./builders");
20
- const highlightableFields = [
20
+ exports.highlightableFields = [
21
21
  'caption',
22
22
  'contents',
23
23
  'title',
24
24
  ];
25
25
  const isHighlightableModel = (model) => {
26
- for (const field of highlightableFields) {
26
+ for (const field of exports.highlightableFields) {
27
27
  if (field in model) {
28
28
  return true;
29
29
  }
@@ -32,7 +32,7 @@ const isHighlightableModel = (model) => {
32
32
  };
33
33
  exports.isHighlightableModel = isHighlightableModel;
34
34
  const extractHighlightMarkers = (model, commentAnnotationsMap) => {
35
- for (const field of highlightableFields) {
35
+ for (const field of exports.highlightableFields) {
36
36
  let html = model[field];
37
37
  if (html === undefined) {
38
38
  continue;
@@ -200,11 +200,9 @@ class HTMLTransformer {
200
200
  const citationNode = node;
201
201
  const element = this.document.createElement('span');
202
202
  element.setAttribute('class', 'citation');
203
- const citation = getModel(citationNode.attrs.rid);
204
- if (citation) {
205
- element.setAttribute('data-reference-ids', citation.embeddedCitationItems
206
- .map((item) => item.bibliographyItem)
207
- .join(' '));
203
+ const rids = citationNode.attrs.rids;
204
+ if (rids.length) {
205
+ element.setAttribute('data-reference-ids', rids.join(' '));
208
206
  }
209
207
  if (citationNode.attrs.contents) {
210
208
  element.innerHTML = citationNode.attrs.contents;
@@ -215,20 +213,7 @@ class HTMLTransformer {
215
213
  const crossReferenceNode = node;
216
214
  const element = this.document.createElement('a');
217
215
  element.classList.add('cross-reference');
218
- const auxiliaryObjectReference = getModel(crossReferenceNode.attrs.rid);
219
- if (auxiliaryObjectReference &&
220
- auxiliaryObjectReference.referencedObject) {
221
- if (auxiliaryObjectReference.referencedObject.startsWith('MPFigureElement')) {
222
- const model = getModel(auxiliaryObjectReference.referencedObject);
223
- if (model && model.containedObjectIDs.length > 0) {
224
- element.setAttribute('href', `#${model.containedObjectIDs[0]}`);
225
- }
226
- }
227
- else {
228
- element.setAttribute('href', `#${auxiliaryObjectReference.referencedObject}`);
229
- }
230
- element.setAttribute('data-reference-ids', crossReferenceNode.attrs.rid);
231
- }
216
+ element.setAttribute('data-reference-ids', crossReferenceNode.attrs.rids.join(' '));
232
217
  element.textContent =
233
218
  crossReferenceNode.attrs.customLabel || crossReferenceNode.attrs.label;
234
219
  return element;
@@ -262,7 +247,7 @@ class HTMLTransformer {
262
247
  };
263
248
  return ['span', attrs];
264
249
  };
265
- nodes.meta_section = () => '';
250
+ nodes.comments = () => '';
266
251
  const serializer = new prosemirror_model_1.DOMSerializer(nodes, marks);
267
252
  return serializer.serializeFragment(fragment, { document });
268
253
  };
@@ -38,6 +38,6 @@ exports.nodeNames = new Map([
38
38
  [schema_1.schema.nodes.table_element, 'Table'],
39
39
  [schema_1.schema.nodes.blockquote_element, 'Block Quote'],
40
40
  [schema_1.schema.nodes.pullquote_element, 'Pull Quote'],
41
- [schema_1.schema.nodes.keywords_section, 'Section'],
41
+ [schema_1.schema.nodes.keywords, 'Section'],
42
42
  [schema_1.schema.nodes.toc_section, 'Section'],
43
43
  ]);
@@ -50,7 +50,7 @@ const nodeTitle = (node) => {
50
50
  case nodes.section:
51
51
  case nodes.bibliography_section:
52
52
  case nodes.footnotes_section:
53
- case nodes.keywords_section:
53
+ case nodes.keywords:
54
54
  case nodes.toc_section:
55
55
  case nodes.graphical_abstract_section:
56
56
  return snippetOfNodeType(node, nodes.section_title);
@@ -19,6 +19,9 @@ exports.isNodeType = exports.isSectionNodeType = exports.isElementNodeType = exp
19
19
  const json_schema_1 = require("@manuscripts/json-schema");
20
20
  const schema_1 = require("../schema");
21
21
  exports.nodeTypesMap = new Map([
22
+ [schema_1.schema.nodes.abstracts, json_schema_1.ObjectTypes.Section],
23
+ [schema_1.schema.nodes.body, json_schema_1.ObjectTypes.Section],
24
+ [schema_1.schema.nodes.backmatter, json_schema_1.ObjectTypes.Section],
22
25
  [schema_1.schema.nodes.comment, json_schema_1.ObjectTypes.CommentAnnotation],
23
26
  [schema_1.schema.nodes.bibliography_item, json_schema_1.ObjectTypes.BibliographyItem],
24
27
  [schema_1.schema.nodes.bibliography_element, json_schema_1.ObjectTypes.BibliographyElement],
@@ -26,7 +29,6 @@ exports.nodeTypesMap = new Map([
26
29
  [schema_1.schema.nodes.blockquote_element, json_schema_1.ObjectTypes.QuoteElement],
27
30
  [schema_1.schema.nodes.bullet_list, json_schema_1.ObjectTypes.ListElement],
28
31
  [schema_1.schema.nodes.citation, json_schema_1.ObjectTypes.Citation],
29
- [schema_1.schema.nodes.cross_reference, json_schema_1.ObjectTypes.AuxiliaryObjectReference],
30
32
  [schema_1.schema.nodes.equation, json_schema_1.ObjectTypes.Equation],
31
33
  [schema_1.schema.nodes.equation_element, json_schema_1.ObjectTypes.EquationElement],
32
34
  [schema_1.schema.nodes.figure, json_schema_1.ObjectTypes.Figure],
@@ -40,8 +42,8 @@ exports.nodeTypesMap = new Map([
40
42
  [schema_1.schema.nodes.inline_equation, json_schema_1.ObjectTypes.InlineMathFragment],
41
43
  [schema_1.schema.nodes.keyword, json_schema_1.ObjectTypes.Keyword],
42
44
  [schema_1.schema.nodes.keywords_element, json_schema_1.ObjectTypes.KeywordsElement],
43
- [schema_1.schema.nodes.keywords_section, json_schema_1.ObjectTypes.Section],
44
- [schema_1.schema.nodes.keywords_group, json_schema_1.ObjectTypes.KeywordGroup],
45
+ [schema_1.schema.nodes.keywords, json_schema_1.ObjectTypes.Section],
46
+ [schema_1.schema.nodes.keyword_group, json_schema_1.ObjectTypes.KeywordGroup],
45
47
  [schema_1.schema.nodes.listing, json_schema_1.ObjectTypes.Listing],
46
48
  [schema_1.schema.nodes.listing_element, json_schema_1.ObjectTypes.ListingElement],
47
49
  [schema_1.schema.nodes.manuscript, json_schema_1.ObjectTypes.Manuscript],
@@ -53,13 +55,12 @@ exports.nodeTypesMap = new Map([
53
55
  [schema_1.schema.nodes.table_element, json_schema_1.ObjectTypes.TableElement],
54
56
  [schema_1.schema.nodes.toc_element, json_schema_1.ObjectTypes.TOCElement],
55
57
  [schema_1.schema.nodes.toc_section, json_schema_1.ObjectTypes.Section],
56
- [schema_1.schema.nodes.meta_section, json_schema_1.ObjectTypes.MetaSection],
57
58
  [schema_1.schema.nodes.affiliation, json_schema_1.ObjectTypes.Affiliation],
58
59
  [schema_1.schema.nodes.contributor, json_schema_1.ObjectTypes.Contributor],
59
60
  [schema_1.schema.nodes.table_element_footer, json_schema_1.ObjectTypes.TableElementFooter],
61
+ [schema_1.schema.nodes.contributors, json_schema_1.ObjectTypes.Section],
62
+ [schema_1.schema.nodes.affiliations, json_schema_1.ObjectTypes.Section],
60
63
  [schema_1.schema.nodes.title, json_schema_1.ObjectTypes.Titles],
61
- [schema_1.schema.nodes.contributors_section, json_schema_1.ObjectTypes.Section],
62
- [schema_1.schema.nodes.affiliations_section, json_schema_1.ObjectTypes.Section],
63
64
  ]);
64
65
  const isExecutableNodeType = (type) => (0, schema_1.hasGroup)(type, schema_1.GROUP_EXECUTABLE);
65
66
  exports.isExecutableNodeType = isExecutableNodeType;
@@ -15,7 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.isKeyword = exports.isCommentAnnotation = exports.isUserProfile = exports.isTable = exports.isManuscript = exports.isFigure = exports.hasObjectType = exports.isManuscriptModel = exports.manuscriptObjects = exports.elementObjects = exports.ExtraObjectTypes = void 0;
18
+ exports.isKeyword = exports.isCommentAnnotation = exports.isTable = exports.isManuscript = exports.isFigure = exports.hasObjectType = exports.isManuscriptModel = exports.manuscriptObjects = exports.elementObjects = exports.ExtraObjectTypes = void 0;
19
19
  const json_schema_1 = require("@manuscripts/json-schema");
20
20
  var ExtraObjectTypes;
21
21
  (function (ExtraObjectTypes) {
@@ -53,6 +53,5 @@ exports.hasObjectType = hasObjectType;
53
53
  exports.isFigure = (0, exports.hasObjectType)(json_schema_1.ObjectTypes.Figure);
54
54
  exports.isManuscript = (0, exports.hasObjectType)(json_schema_1.ObjectTypes.Manuscript);
55
55
  exports.isTable = (0, exports.hasObjectType)(json_schema_1.ObjectTypes.Table);
56
- exports.isUserProfile = (0, exports.hasObjectType)(json_schema_1.ObjectTypes.UserProfile);
57
56
  exports.isCommentAnnotation = (0, exports.hasObjectType)(json_schema_1.ObjectTypes.CommentAnnotation);
58
57
  exports.isKeyword = (0, exports.hasObjectType)(json_schema_1.ObjectTypes.Keyword);
@@ -15,25 +15,16 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.chooseSectionCategoryFromTitle = exports.chooseSectionCategory = exports.chooseSectionCategoryByType = exports.chooseSecType = exports.chooseJatsFnType = exports.buildSectionCategory = exports.guessSectionCategory = exports.chooseSectionLableName = exports.chooseSectionNodeType = exports.isAnySectionNode = exports.getCoreSectionTitles = void 0;
18
+ exports.chooseSectionCategoryFromTitle = exports.chooseSectionCategory = exports.chooseSectionCategoryByType = exports.chooseCoreSectionBySection = exports.chooseSecType = exports.chooseJatsFnType = exports.buildSectionCategory = exports.guessSectionCategory = exports.chooseSectionLableName = exports.chooseSectionNodeType = exports.isAnySectionNode = void 0;
19
19
  const json_schema_1 = require("@manuscripts/json-schema");
20
- const core_section_categories_1 = require("../lib/core-section-categories");
21
20
  const schema_1 = require("../schema");
22
21
  const sectionNodeTypes = [
23
22
  schema_1.schema.nodes.bibliography_section,
24
23
  schema_1.schema.nodes.footnotes_section,
25
- schema_1.schema.nodes.keywords_section,
24
+ schema_1.schema.nodes.keywords,
26
25
  schema_1.schema.nodes.section,
27
26
  schema_1.schema.nodes.toc_section,
28
27
  ];
29
- const getCoreSectionTitles = (sectionCategory) => {
30
- const category = core_section_categories_1.coreSectionCategories.find((section) => section._id === sectionCategory);
31
- if (category) {
32
- return category.titles.length ? category.titles : [' '];
33
- }
34
- throw new Error(`${sectionCategory} not found in core sections`);
35
- };
36
- exports.getCoreSectionTitles = getCoreSectionTitles;
37
28
  const isAnySectionNode = (node) => sectionNodeTypes.includes(node.type);
38
29
  exports.isAnySectionNode = isAnySectionNode;
39
30
  const chooseSectionNodeType = (category) => {
@@ -45,11 +36,11 @@ const chooseSectionNodeType = (category) => {
45
36
  case 'MPSectionCategory:endnotes':
46
37
  return schema_1.schema.nodes.footnotes_section;
47
38
  case 'MPSectionCategory:keywords':
48
- return schema_1.schema.nodes.keywords_section;
39
+ return schema_1.schema.nodes.keywords;
49
40
  case 'MPSectionCategory:affiliations':
50
- return schema_1.schema.nodes.affiliations_section;
41
+ return schema_1.schema.nodes.affiliations;
51
42
  case 'MPSectionCategory:contributors':
52
- return schema_1.schema.nodes.contributors_section;
43
+ return schema_1.schema.nodes.contributors;
53
44
  case 'MPSectionCategory:toc':
54
45
  return schema_1.schema.nodes.toc_section;
55
46
  default:
@@ -90,15 +81,15 @@ const buildSectionCategory = (node) => {
90
81
  return 'MPSectionCategory:bibliography';
91
82
  case schema_1.schema.nodes.footnotes_section:
92
83
  return 'MPSectionCategory:endnotes';
93
- case schema_1.schema.nodes.keywords_section:
84
+ case schema_1.schema.nodes.keywords:
94
85
  return 'MPSectionCategory:keywords';
95
86
  case schema_1.schema.nodes.toc_section:
96
87
  return 'MPSectionCategory:toc';
97
88
  case schema_1.schema.nodes.graphical_abstract_section:
98
89
  return 'MPSectionCategory:abstract-graphical';
99
- case schema_1.schema.nodes.affiliations_section:
90
+ case schema_1.schema.nodes.affiliations:
100
91
  return 'MPSectionCategory:affiliations';
101
- case schema_1.schema.nodes.contributors_section:
92
+ case schema_1.schema.nodes.contributors:
102
93
  return 'MPSectionCategory:contributors';
103
94
  default:
104
95
  return node.attrs.category || undefined;
@@ -128,6 +119,33 @@ const chooseSecType = (sectionCategory) => {
128
119
  }
129
120
  };
130
121
  exports.chooseSecType = chooseSecType;
122
+ const chooseCoreSectionBySection = (section) => {
123
+ switch (section) {
124
+ case 'MPSectionCategory:abstract':
125
+ case 'MPSectionCategory:abstract-teaser':
126
+ case 'MPSectionCategory:abstract-graphical':
127
+ return 'MPSectionCategory:abstracts';
128
+ case 'MPSectionCategory:acknowledgement':
129
+ case 'MPSectionCategory:availability':
130
+ case 'MPSectionCategory:conclusions':
131
+ case 'MPSectionCategory:bibliography':
132
+ case 'MPSectionCategory:discussion':
133
+ case 'MPSectionCategory:endnotes':
134
+ case 'MPSectionCategory:appendices':
135
+ case 'MPSectionCategory:competing-interests':
136
+ case 'MPSectionCategory:con':
137
+ case 'MPSectionCategory:deceased':
138
+ case 'MPSectionCategory:ethics-statement':
139
+ case 'MPSectionCategory:financial-disclosure':
140
+ case 'MPSectionCategory:supplementary-material':
141
+ case 'MPSectionCategory:supported-by':
142
+ case 'MPSectionCategory:abbreviations':
143
+ case 'MPSectionCategory:results':
144
+ return 'MPSectionCategory:backmatter';
145
+ }
146
+ return 'MPSectionCategory:body';
147
+ };
148
+ exports.chooseCoreSectionBySection = chooseCoreSectionBySection;
131
149
  const chooseSectionCategoryByType = (secType) => {
132
150
  switch (secType) {
133
151
  case 'abstract':
package/dist/es/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export * from './lib/core-section-categories';
1
+ export * from './lib/section-group-type';
2
2
  export * from './lib/table-cell-styles';
3
3
  export * from './lib/utils';
4
4
  export * from './mathjax';
@@ -13,4 +13,4 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- export { parseJATSFront, parseJATSBody, parseJATSReferences, parseJATSArticle, getElementsOrder, } from './parse-jats-article';
16
+ export { parseJATSFront, parseJATSBody, parseJATSArticle, } from './parse-jats-article';