@manuscripts/transform 1.5.4-LEAN-3030 → 1.5.4-LEAN-2996

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 (55) hide show
  1. package/dist/cjs/jats/importer/jats-body-dom-parser.js +18 -23
  2. package/dist/cjs/jats/importer/jats-body-transformations.js +3 -3
  3. package/dist/cjs/jats/jats-exporter.js +6 -11
  4. package/dist/cjs/lib/utils.js +1 -10
  5. package/dist/cjs/schema/index.js +12 -16
  6. package/dist/cjs/schema/nodes/affiliations_section.js +15 -0
  7. package/dist/cjs/schema/nodes/contributors_section.js +15 -0
  8. package/dist/cjs/schema/nodes/keyword.js +1 -0
  9. package/dist/cjs/schema/nodes/keywords_element.js +1 -1
  10. package/dist/cjs/schema/nodes/{keyword_group.js → keywords_group.js} +6 -6
  11. package/dist/cjs/schema/nodes/{keywords.js → keywords_section.js} +7 -7
  12. package/dist/cjs/schema/nodes/manuscript.js +1 -1
  13. package/dist/cjs/transformer/decode.js +113 -108
  14. package/dist/cjs/transformer/encode.js +37 -15
  15. package/dist/cjs/transformer/node-names.js +1 -1
  16. package/dist/cjs/transformer/node-title.js +1 -1
  17. package/dist/cjs/transformer/node-types.js +4 -7
  18. package/dist/cjs/transformer/section-category.js +8 -35
  19. package/dist/es/jats/importer/jats-body-dom-parser.js +18 -23
  20. package/dist/es/jats/importer/jats-body-transformations.js +3 -3
  21. package/dist/es/jats/jats-exporter.js +6 -11
  22. package/dist/es/lib/utils.js +0 -8
  23. package/dist/es/schema/index.js +12 -16
  24. package/dist/es/schema/nodes/{affiliations.js → affiliations_section.js} +3 -3
  25. package/dist/es/schema/nodes/{contributors.js → contributors_section.js} +3 -3
  26. package/dist/es/schema/nodes/keyword.js +1 -0
  27. package/dist/es/schema/nodes/keywords_element.js +1 -1
  28. package/dist/es/schema/nodes/{keyword_group.js → keywords_group.js} +4 -4
  29. package/dist/es/schema/nodes/{keywords.js → keywords_section.js} +5 -5
  30. package/dist/es/schema/nodes/manuscript.js +1 -1
  31. package/dist/es/transformer/decode.js +114 -109
  32. package/dist/es/transformer/encode.js +37 -15
  33. package/dist/es/transformer/node-names.js +1 -1
  34. package/dist/es/transformer/node-title.js +1 -1
  35. package/dist/es/transformer/node-types.js +4 -7
  36. package/dist/es/transformer/section-category.js +7 -33
  37. package/dist/types/lib/utils.d.ts +0 -1
  38. package/dist/types/schema/index.d.ts +3 -3
  39. package/dist/types/schema/nodes/affiliations_section.d.ts +11 -0
  40. package/dist/types/schema/nodes/contributors_section.d.ts +11 -0
  41. package/dist/types/schema/nodes/keyword.d.ts +1 -0
  42. package/dist/types/schema/nodes/{keyword_group.d.ts → keywords_group.d.ts} +3 -3
  43. package/dist/types/schema/nodes/{keywords.d.ts → keywords_section.d.ts} +3 -3
  44. package/dist/types/schema/types.d.ts +1 -1
  45. package/dist/types/transformer/decode.d.ts +6 -6
  46. package/dist/types/transformer/encode.d.ts +1 -1
  47. package/dist/types/transformer/section-category.d.ts +0 -1
  48. package/package.json +2 -2
  49. package/dist/cjs/schema/nodes/affiliations.js +0 -15
  50. package/dist/cjs/schema/nodes/contributors.js +0 -15
  51. package/dist/cjs/schema/nodes/core_section.js +0 -27
  52. package/dist/es/schema/nodes/core_section.js +0 -24
  53. package/dist/types/schema/nodes/affiliations.d.ts +0 -11
  54. package/dist/types/schema/nodes/contributors.d.ts +0 -11
  55. package/dist/types/schema/nodes/core_section.d.ts +0 -17
@@ -34,7 +34,6 @@ const json_schema_1 = require("@manuscripts/json-schema");
34
34
  const debug_1 = __importDefault(require("debug"));
35
35
  const prosemirror_model_1 = require("prosemirror-model");
36
36
  const errors_1 = require("../errors");
37
- const utils_1 = require("../lib/utils");
38
37
  const schema_1 = require("../schema");
39
38
  const builders_1 = require("./builders");
40
39
  const highlight_markers_1 = require("./highlight-markers");
@@ -64,42 +63,18 @@ exports.sortSectionsByPriority = sortSectionsByPriority;
64
63
  const getSections = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.Section).sort(exports.sortSectionsByPriority);
65
64
  const getAffiliations = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.Affiliation);
66
65
  const getContributors = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.Contributor);
67
- const getKeywordElements = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.KeywordsElement);
68
- const getKeywordGroups = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.KeywordGroup);
69
- const getKeywords = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.Keyword);
70
- const getTitles = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.Titles)[0];
71
66
  const isManuscriptNode = (model) => model !== null;
72
67
  exports.isManuscriptNode = isManuscriptNode;
68
+ const isParagraphElement = (0, object_types_1.hasObjectType)(json_schema_1.ObjectTypes.ParagraphElement);
73
69
  const isFootnote = (0, object_types_1.hasObjectType)(json_schema_1.ObjectTypes.Footnote);
70
+ const isKeyword = (0, object_types_1.hasObjectType)(json_schema_1.ObjectTypes.Keyword);
71
+ const isKeywordsSection = (model) => model.category === 'MPSectionCategory:keywords';
72
+ const isAffiliationsSection = (model) => model.category === 'MPSectionCategory:affiliations';
73
+ const isContributorsSection = (model) => model.category === 'MPSectionCategory:contributors';
74
74
  const hasParentSection = (id) => (section) => section.path &&
75
75
  section.path.length > 1 &&
76
76
  section.path[section.path.length - 2] === id;
77
77
  class Decoder {
78
- createTitleNode() {
79
- const titles = getTitles(this.modelMap) || (0, builders_1.buildTitles)();
80
- return this.decode(titles);
81
- }
82
- createAffiliationsNode() {
83
- const affiliations = getAffiliations(this.modelMap)
84
- .map((a) => this.decode(a))
85
- .filter(Boolean);
86
- return schema_1.schema.nodes.affiliations.createAndFill({}, affiliations);
87
- }
88
- createContributorsNode() {
89
- const contributors = getContributors(this.modelMap)
90
- .map((c) => this.decode(c))
91
- .filter(Boolean);
92
- return schema_1.schema.nodes.contributors.createAndFill({}, contributors);
93
- }
94
- createKeywordsNode() {
95
- const elements = getKeywordElements(this.modelMap)
96
- .map((e) => this.decode(e))
97
- .filter(Boolean);
98
- return schema_1.schema.nodes.keywords.createAndFill({}, [
99
- schema_1.schema.nodes.section_title.create({}, schema_1.schema.text('Keywords')),
100
- ...elements,
101
- ]);
102
- }
103
78
  createMetaSectionNode() {
104
79
  const commentListNode = this.createCommentListNode();
105
80
  return schema_1.schema.nodes.meta_section.createAndFill({}, [
@@ -111,51 +86,54 @@ class Decoder {
111
86
  ...this.comments.values(),
112
87
  ]);
113
88
  }
89
+ handleMissingRootSectionNodes(rootSectionNodes) {
90
+ if (!rootSectionNodes.find((node) => node.type.name === 'affiliations_section')) {
91
+ this.createAffiliationSectionNode(rootSectionNodes);
92
+ }
93
+ if (!rootSectionNodes.find((node) => node.type.name === 'contributors_section')) {
94
+ this.createContributorSectionNode(rootSectionNodes);
95
+ }
96
+ }
97
+ createAffiliationSectionNode(rootSectionNodes) {
98
+ const affiliationNodes = getAffiliations(this.modelMap)
99
+ .map((affiliation) => this.decode(affiliation))
100
+ .filter(Boolean);
101
+ if (affiliationNodes.length) {
102
+ const node = schema_1.schema.nodes.affiliations_section.createAndFill({
103
+ id: (0, id_1.generateNodeID)(schema_1.schema.nodes.section),
104
+ }, affiliationNodes);
105
+ rootSectionNodes.unshift(node);
106
+ }
107
+ }
108
+ createContributorSectionNode(rootSectionNodes) {
109
+ const contributorNodes = getContributors(this.modelMap)
110
+ .map((contributor) => this.decode(contributor))
111
+ .filter(Boolean);
112
+ if (contributorNodes.length) {
113
+ const node = schema_1.schema.nodes.contributors_section.createAndFill({
114
+ id: (0, id_1.generateNodeID)(schema_1.schema.nodes.section),
115
+ }, contributorNodes);
116
+ rootSectionNodes.unshift(node);
117
+ }
118
+ }
119
+ createTitleNode() {
120
+ const titles = (0, exports.getModelsByType)(this.modelMap, json_schema_1.ObjectTypes.Titles)[0] ||
121
+ (0, builders_1.buildTitles)();
122
+ return this.decode(titles);
123
+ }
114
124
  createRootSectionNodes() {
115
- let rootSections = getSections(this.modelMap)
116
- .filter((section) => !section.path || section.path.length <= 1)
117
- .filter((section) => section.category !== 'MPSectionCategory:contributors' &&
118
- section.category !== 'MPSectionCategory:affiliations' &&
119
- section.category !== 'MPSectionCategory:keywords');
125
+ let rootSections = getSections(this.modelMap).filter((section) => !section.path || section.path.length <= 1);
120
126
  rootSections = this.addGeneratedLabels(rootSections);
121
- const sectionGroups = (0, utils_1.groupBy)(rootSections, (sec) => {
122
- var _a;
123
- return (0, section_category_1.chooseCoreSectionBySection)((_a = sec.category) !== null && _a !== void 0 ? _a : '');
124
- });
125
- this.ensureCoreSectionsExist(sectionGroups);
126
- const absSectionNode = sectionGroups['MPSectionCategory:abstracts']
127
- .map(this.decode)
128
- .filter(exports.isManuscriptNode);
129
- const bodySectionNodes = sectionGroups['MPSectionCategory:body']
130
- .map(this.decode)
131
- .filter(exports.isManuscriptNode);
132
- const backmatterSectionNodes = sectionGroups['MPSectionCategory:backmatter']
127
+ const rootSectionNodes = rootSections
133
128
  .map(this.decode)
134
129
  .filter(exports.isManuscriptNode);
135
- const abstractCoreSectionNodes = this.createAndFill(schema_1.schema.nodes.abstracts, absSectionNode);
136
- const bodyCoreSectionNodes = this.createAndFill(schema_1.schema.nodes.body, bodySectionNodes);
137
- const backmatterCoreSectionNodes = this.createAndFill(schema_1.schema.nodes.backmatter, backmatterSectionNodes);
138
- return {
139
- abstracts: abstractCoreSectionNodes,
140
- body: bodyCoreSectionNodes,
141
- backmatter: backmatterCoreSectionNodes,
142
- };
143
- }
144
- ensureCoreSectionsExist(coreSections) {
145
- if (!coreSections['MPSectionCategory:abstracts']) {
146
- coreSections['MPSectionCategory:abstracts'] = [];
147
- }
148
- if (!coreSections['MPSectionCategory:body']) {
149
- coreSections['MPSectionCategory:body'] = [];
130
+ this.handleMissingRootSectionNodes(rootSectionNodes);
131
+ if (!rootSectionNodes.length) {
132
+ rootSectionNodes.push(schema_1.schema.nodes.section.createAndFill({
133
+ id: (0, id_1.generateNodeID)(schema_1.schema.nodes.section),
134
+ }));
150
135
  }
151
- if (!coreSections['MPSectionCategory:backmatter']) {
152
- coreSections['MPSectionCategory:backmatter'] = [];
153
- }
154
- }
155
- createAndFill(nodeType, content) {
156
- return nodeType.createAndFill({
157
- id: (0, id_1.generateNodeID)(nodeType),
158
- }, content);
136
+ return rootSectionNodes;
159
137
  }
160
138
  createCommentsNode(model) {
161
139
  const comments = [];
@@ -361,32 +339,19 @@ class Decoder {
361
339
  },
362
340
  [json_schema_1.ObjectTypes.KeywordsElement]: (data) => {
363
341
  const model = data;
364
- const keywordGroups = getKeywordGroups(this.modelMap).map(k => this.decode(k));
342
+ const keywordGroups = this.getKeywordGroups();
365
343
  return schema_1.schema.nodes.keywords_element.create({
366
344
  id: model._id,
367
345
  paragraphStyle: model.paragraphStyle,
368
346
  }, keywordGroups);
369
347
  },
370
- [json_schema_1.ObjectTypes.KeywordGroup]: (data) => {
371
- const keywordGroup = data;
372
- const keywords = getKeywords(this.modelMap).filter(k => k.containedGroup === keywordGroup._id).map(k => this.decode(k));
373
- const comments = this.createCommentsNode(keywordGroup);
374
- comments.forEach((c) => this.comments.set(c.attrs.id, c));
375
- return schema_1.schema.nodes.keyword_group.create({
376
- id: keywordGroup._id,
377
- type: keywordGroup.type,
378
- comments: comments.map((c) => c.attrs.id),
379
- }, keywords);
380
- },
381
348
  [json_schema_1.ObjectTypes.Keyword]: (data) => {
382
- const keyword = data;
383
- const comments = this.createCommentsNode(keyword);
384
- comments.forEach((c) => this.comments.set(c.attrs.id, c));
349
+ const model = data;
385
350
  return schema_1.schema.nodes.keyword.create({
386
- id: keyword._id,
387
- contents: keyword.name,
388
- comments: comments.map((c) => c.attrs.id),
389
- }, schema_1.schema.text(keyword.name));
351
+ id: model._id,
352
+ contents: model.name,
353
+ comments: this.createCommentsNode(model),
354
+ }, schema_1.schema.text(model.name));
390
355
  },
391
356
  [json_schema_1.ObjectTypes.ListElement]: (data) => {
392
357
  const model = data;
@@ -508,6 +473,9 @@ class Decoder {
508
473
  for (const id of model.elementIDs) {
509
474
  const element = this.getModel(id);
510
475
  if (element) {
476
+ if (isKeywordsSection(model) && isParagraphElement(element)) {
477
+ continue;
478
+ }
511
479
  elements.push(element);
512
480
  }
513
481
  else if (this.allowMissingElements) {
@@ -548,11 +516,17 @@ class Decoder {
548
516
  const sectionNodeType = (0, section_category_1.chooseSectionNodeType)(sectionCategory);
549
517
  const commentNodes = this.createCommentsNode(model);
550
518
  commentNodes.forEach((c) => this.comments.set(c.attrs.id, c));
551
- const content = (sectionLabelNode
552
- ? [sectionLabelNode, sectionTitleNode]
553
- : [sectionTitleNode])
554
- .concat(elementNodes)
555
- .concat(nestedSections);
519
+ let content;
520
+ if (isAffiliationsSection(model) || isContributorsSection(model)) {
521
+ content = elementNodes.concat(nestedSections);
522
+ }
523
+ else {
524
+ content = (sectionLabelNode
525
+ ? [sectionLabelNode, sectionTitleNode]
526
+ : [sectionTitleNode])
527
+ .concat(elementNodes)
528
+ .concat(nestedSections);
529
+ }
556
530
  const sectionNode = sectionNodeType.createAndFill({
557
531
  id: model._id,
558
532
  category: sectionCategory,
@@ -671,21 +645,13 @@ class Decoder {
671
645
  };
672
646
  this.getModel = (id) => this.modelMap.get(id);
673
647
  this.createArticleNode = (manuscriptID) => {
674
- const title = this.createTitleNode();
675
- const contributors = this.createContributorsNode();
676
- const affiliations = this.createAffiliationsNode();
677
- const keywords = this.createKeywordsNode();
678
- const { abstracts, body, backmatter } = this.createRootSectionNodes();
679
- const meta = this.createMetaSectionNode();
648
+ const titlesNode = this.createTitleNode();
649
+ const rootSectionNodes = this.createRootSectionNodes();
650
+ const metaSectionNode = this.createMetaSectionNode();
680
651
  const contents = [
681
- title,
682
- contributors,
683
- affiliations,
684
- keywords,
685
- abstracts,
686
- body,
687
- backmatter,
688
- meta,
652
+ titlesNode,
653
+ ...rootSectionNodes,
654
+ metaSectionNode,
689
655
  ];
690
656
  return schema_1.schema.nodes.manuscript.create({
691
657
  id: manuscriptID || this.getManuscriptID(),
@@ -727,6 +693,23 @@ class Decoder {
727
693
  }
728
694
  return parser.parse(template.content.firstElementChild, options);
729
695
  };
696
+ this.getKeywords = (id) => {
697
+ const keywordsOfKind = [];
698
+ const keywordsByGroup = [...this.modelMap.values()].filter((m) => m.objectType === json_schema_1.ObjectTypes.Keyword &&
699
+ m.containedGroup === id);
700
+ for (const model of keywordsByGroup) {
701
+ if (isKeyword(model)) {
702
+ const keyword = this.parseContents(model.name || '', 'div', this.getComments(model), {
703
+ topNode: schema_1.schema.nodes.keyword.create({
704
+ id: model._id,
705
+ contents: model.name,
706
+ }),
707
+ });
708
+ keywordsOfKind.push(keyword);
709
+ }
710
+ }
711
+ return keywordsOfKind;
712
+ };
730
713
  this.getManuscriptID = () => {
731
714
  for (const item of this.modelMap.values()) {
732
715
  if ((0, object_types_1.isManuscript)(item)) {
@@ -811,5 +794,27 @@ class Decoder {
811
794
  }
812
795
  return listing;
813
796
  }
797
+ getKeywordGroups() {
798
+ const kwdGroupNodes = [];
799
+ const kwdGroupsModels = [
800
+ ...this.modelMap.values(),
801
+ ].filter((model) => model.objectType === json_schema_1.ObjectTypes.KeywordGroup);
802
+ if (kwdGroupsModels.length > 0) {
803
+ for (const kwdGroupModel of kwdGroupsModels) {
804
+ const keywords = this.getKeywords(kwdGroupModel._id);
805
+ const commentNodes = this.createCommentsNode(kwdGroupModel);
806
+ commentNodes.forEach((c) => this.comments.set(c.attrs.id, c));
807
+ const contents = [];
808
+ contents.push(...keywords);
809
+ const kwdGroupNode = schema_1.schema.nodes.keywords_group.create({
810
+ id: kwdGroupModel._id,
811
+ type: kwdGroupModel.type,
812
+ comments: commentNodes.map((c) => c.attrs.id),
813
+ }, contents);
814
+ kwdGroupNodes.push(kwdGroupNode);
815
+ }
816
+ }
817
+ return kwdGroupNodes;
818
+ }
814
819
  }
815
820
  exports.Decoder = Decoder;
@@ -428,9 +428,34 @@ const encoders = {
428
428
  elementType: 'div',
429
429
  paragraphStyle: node.attrs.paragraphStyle || undefined,
430
430
  }),
431
- keyword_group: (node) => ({
431
+ keywords_group: (node) => ({
432
432
  type: node.attrs.type,
433
433
  }),
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
+ }),
434
459
  missing_figure: (node) => ({
435
460
  position: node.attrs.position || undefined,
436
461
  }),
@@ -548,17 +573,10 @@ const modelFromNode = (node, parent, path, priority) => {
548
573
  if ((0, highlight_markers_1.isHighlightableModel)(model)) {
549
574
  (0, highlight_markers_1.extractHighlightMarkers)(model, commentAnnotationsMap);
550
575
  }
551
- return { model, commentAnnotationsMap };
576
+ const comments = [...commentAnnotationsMap.values()];
577
+ return { model, comments };
552
578
  };
553
579
  exports.modelFromNode = modelFromNode;
554
- function isCoreSection(child) {
555
- return (child.type === schema_1.schema.nodes.abstracts ||
556
- child.type === schema_1.schema.nodes.body ||
557
- child.type === schema_1.schema.nodes.backmatter ||
558
- child.type === schema_1.schema.nodes.affiliations ||
559
- child.type === schema_1.schema.nodes.contributors ||
560
- child.type === schema_1.schema.nodes.keywords);
561
- }
562
580
  const encode = (node) => {
563
581
  const models = new Map();
564
582
  const priority = {
@@ -566,10 +584,6 @@ const encode = (node) => {
566
584
  };
567
585
  const placeholders = ['placeholder', 'placeholder_element'];
568
586
  const addModel = (path, parent) => (child) => {
569
- if (isCoreSection(child)) {
570
- child.forEach(addModel([], child));
571
- return;
572
- }
573
587
  if (!child.attrs.id) {
574
588
  return;
575
589
  }
@@ -582,10 +596,18 @@ const encode = (node) => {
582
596
  if (placeholders.includes(child.type.name)) {
583
597
  return;
584
598
  }
585
- const { model } = (0, exports.modelFromNode)(child, parent, path, priority);
599
+ const { model, comments } = (0, exports.modelFromNode)(child, parent, path, priority);
586
600
  if (models.has(model._id)) {
587
601
  throw Error(`Encountered duplicate ids in models map while encoding: ${model._id}`);
588
602
  }
603
+ comments.forEach((comment) => {
604
+ const proseMirrorComment = models.get(comment._id);
605
+ if (proseMirrorComment) {
606
+ ;
607
+ proseMirrorComment.selector = comment.selector;
608
+ models.set(comment._id, proseMirrorComment);
609
+ }
610
+ });
589
611
  models.set(model._id, model);
590
612
  child.forEach(addModel(path.concat(child.attrs.id), child));
591
613
  };
@@ -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'],
41
+ [schema_1.schema.nodes.keywords_section, '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:
53
+ case nodes.keywords_section:
54
54
  case nodes.toc_section:
55
55
  case nodes.graphical_abstract_section:
56
56
  return snippetOfNodeType(node, nodes.section_title);
@@ -19,9 +19,6 @@ 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],
25
22
  [schema_1.schema.nodes.comment, json_schema_1.ObjectTypes.CommentAnnotation],
26
23
  [schema_1.schema.nodes.bibliography_item, json_schema_1.ObjectTypes.BibliographyItem],
27
24
  [schema_1.schema.nodes.bibliography_element, json_schema_1.ObjectTypes.BibliographyElement],
@@ -43,8 +40,8 @@ exports.nodeTypesMap = new Map([
43
40
  [schema_1.schema.nodes.inline_equation, json_schema_1.ObjectTypes.InlineMathFragment],
44
41
  [schema_1.schema.nodes.keyword, json_schema_1.ObjectTypes.Keyword],
45
42
  [schema_1.schema.nodes.keywords_element, json_schema_1.ObjectTypes.KeywordsElement],
46
- [schema_1.schema.nodes.keywords, json_schema_1.ObjectTypes.Section],
47
- [schema_1.schema.nodes.keyword_group, json_schema_1.ObjectTypes.KeywordGroup],
43
+ [schema_1.schema.nodes.keywords_section, json_schema_1.ObjectTypes.Section],
44
+ [schema_1.schema.nodes.keywords_group, json_schema_1.ObjectTypes.KeywordGroup],
48
45
  [schema_1.schema.nodes.listing, json_schema_1.ObjectTypes.Listing],
49
46
  [schema_1.schema.nodes.listing_element, json_schema_1.ObjectTypes.ListingElement],
50
47
  [schema_1.schema.nodes.manuscript, json_schema_1.ObjectTypes.Manuscript],
@@ -60,9 +57,9 @@ exports.nodeTypesMap = new Map([
60
57
  [schema_1.schema.nodes.affiliation, json_schema_1.ObjectTypes.Affiliation],
61
58
  [schema_1.schema.nodes.contributor, json_schema_1.ObjectTypes.Contributor],
62
59
  [schema_1.schema.nodes.table_element_footer, json_schema_1.ObjectTypes.TableElementFooter],
63
- [schema_1.schema.nodes.contributors, json_schema_1.ObjectTypes.Section],
64
- [schema_1.schema.nodes.affiliations, json_schema_1.ObjectTypes.Section],
65
60
  [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],
66
63
  ]);
67
64
  const isExecutableNodeType = (type) => (0, schema_1.hasGroup)(type, schema_1.GROUP_EXECUTABLE);
68
65
  exports.isExecutableNodeType = isExecutableNodeType;
@@ -15,14 +15,14 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.chooseSectionCategoryFromTitle = exports.chooseSectionCategory = exports.chooseSectionCategoryByType = exports.chooseCoreSectionBySection = 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.chooseSecType = exports.chooseJatsFnType = exports.buildSectionCategory = exports.guessSectionCategory = exports.chooseSectionLableName = exports.chooseSectionNodeType = exports.isAnySectionNode = exports.getCoreSectionTitles = void 0;
19
19
  const json_schema_1 = require("@manuscripts/json-schema");
20
20
  const core_section_categories_1 = require("../lib/core-section-categories");
21
21
  const schema_1 = require("../schema");
22
22
  const sectionNodeTypes = [
23
23
  schema_1.schema.nodes.bibliography_section,
24
24
  schema_1.schema.nodes.footnotes_section,
25
- schema_1.schema.nodes.keywords,
25
+ schema_1.schema.nodes.keywords_section,
26
26
  schema_1.schema.nodes.section,
27
27
  schema_1.schema.nodes.toc_section,
28
28
  ];
@@ -45,11 +45,11 @@ const chooseSectionNodeType = (category) => {
45
45
  case 'MPSectionCategory:endnotes':
46
46
  return schema_1.schema.nodes.footnotes_section;
47
47
  case 'MPSectionCategory:keywords':
48
- return schema_1.schema.nodes.keywords;
48
+ return schema_1.schema.nodes.keywords_section;
49
49
  case 'MPSectionCategory:affiliations':
50
- return schema_1.schema.nodes.affiliations;
50
+ return schema_1.schema.nodes.affiliations_section;
51
51
  case 'MPSectionCategory:contributors':
52
- return schema_1.schema.nodes.contributors;
52
+ return schema_1.schema.nodes.contributors_section;
53
53
  case 'MPSectionCategory:toc':
54
54
  return schema_1.schema.nodes.toc_section;
55
55
  default:
@@ -90,15 +90,15 @@ const buildSectionCategory = (node) => {
90
90
  return 'MPSectionCategory:bibliography';
91
91
  case schema_1.schema.nodes.footnotes_section:
92
92
  return 'MPSectionCategory:endnotes';
93
- case schema_1.schema.nodes.keywords:
93
+ case schema_1.schema.nodes.keywords_section:
94
94
  return 'MPSectionCategory:keywords';
95
95
  case schema_1.schema.nodes.toc_section:
96
96
  return 'MPSectionCategory:toc';
97
97
  case schema_1.schema.nodes.graphical_abstract_section:
98
98
  return 'MPSectionCategory:abstract-graphical';
99
- case schema_1.schema.nodes.affiliations:
99
+ case schema_1.schema.nodes.affiliations_section:
100
100
  return 'MPSectionCategory:affiliations';
101
- case schema_1.schema.nodes.contributors:
101
+ case schema_1.schema.nodes.contributors_section:
102
102
  return 'MPSectionCategory:contributors';
103
103
  default:
104
104
  return node.attrs.category || undefined;
@@ -128,33 +128,6 @@ const chooseSecType = (sectionCategory) => {
128
128
  }
129
129
  };
130
130
  exports.chooseSecType = chooseSecType;
131
- const chooseCoreSectionBySection = (section) => {
132
- switch (section) {
133
- case 'MPSectionCategory:abstract':
134
- case 'MPSectionCategory:abstract-teaser':
135
- case 'MPSectionCategory:abstract-graphical':
136
- return 'MPSectionCategory:abstracts';
137
- case 'MPSectionCategory:acknowledgement':
138
- case 'MPSectionCategory:availability':
139
- case 'MPSectionCategory:conclusions':
140
- case 'MPSectionCategory:bibliography':
141
- case 'MPSectionCategory:discussion':
142
- case 'MPSectionCategory:endnotes':
143
- case 'MPSectionCategory:appendices':
144
- case 'MPSectionCategory:competing-interests':
145
- case 'MPSectionCategory:con':
146
- case 'MPSectionCategory:deceased':
147
- case 'MPSectionCategory:ethics-statement':
148
- case 'MPSectionCategory:financial-disclosure':
149
- case 'MPSectionCategory:supplementary-material':
150
- case 'MPSectionCategory:supported-by':
151
- case 'MPSectionCategory:abbreviations':
152
- case 'MPSectionCategory:results':
153
- return 'MPSectionCategory:backmatter';
154
- }
155
- return 'MPSectionCategory:body';
156
- };
157
- exports.chooseCoreSectionBySection = chooseCoreSectionBySection;
158
131
  const chooseSectionCategoryByType = (secType) => {
159
132
  switch (secType) {
160
133
  case 'abstract':
@@ -501,7 +501,7 @@ const nodes = [
501
501
  },
502
502
  {
503
503
  tag: 'sec[sec-type="affiliations"]',
504
- node: 'affiliations',
504
+ node: 'affiliations_section',
505
505
  getAttrs: (node) => {
506
506
  const element = node;
507
507
  return {
@@ -513,7 +513,7 @@ const nodes = [
513
513
  {
514
514
  tag: 'aff',
515
515
  node: 'affiliation',
516
- context: 'affiliations/',
516
+ context: 'affiliations_section/',
517
517
  getAttrs: (node) => {
518
518
  const element = node;
519
519
  const aff = {
@@ -560,7 +560,7 @@ const nodes = [
560
560
  },
561
561
  {
562
562
  tag: 'sec[sec-type="contributors"]',
563
- node: 'contributors',
563
+ node: 'contributors_section',
564
564
  getAttrs: (node) => {
565
565
  const element = node;
566
566
  return {
@@ -572,7 +572,7 @@ const nodes = [
572
572
  {
573
573
  tag: 'contrib',
574
574
  node: 'contributor',
575
- context: 'contributors/',
575
+ context: 'contributors_section/',
576
576
  getAttrs: (node) => {
577
577
  const element = node;
578
578
  const contrib = {
@@ -627,19 +627,19 @@ const nodes = [
627
627
  },
628
628
  {
629
629
  tag: 'sec[sec-type="keywords"]',
630
- node: 'keywords',
631
- },
632
- {
633
- tag: 'sec[sec-type="abstracts"]',
634
- node: 'abstracts',
635
- },
636
- {
637
- tag: 'sec[sec-type="body"]',
638
- node: 'body',
630
+ node: 'keywords_section',
631
+ getAttrs: (node) => {
632
+ const element = node;
633
+ return {
634
+ id: element.getAttribute('id'),
635
+ category: chooseSectionCategory(element),
636
+ };
637
+ },
639
638
  },
640
639
  {
641
- tag: 'sec[sec-type="backmatter"]',
642
- node: 'backmatter',
640
+ tag: 'kwd-group-list',
641
+ context: 'keywords_section/',
642
+ node: 'keywords_element',
643
643
  },
644
644
  {
645
645
  tag: 'sec',
@@ -652,15 +652,10 @@ const nodes = [
652
652
  };
653
653
  },
654
654
  },
655
- {
656
- tag: 'kwd-group-list',
657
- context: 'keywords/',
658
- node: 'keywords_element',
659
- },
660
655
  {
661
656
  tag: 'kwd-group',
662
657
  context: 'keywords_element/',
663
- node: 'keyword_group',
658
+ node: 'keywords_group',
664
659
  getAttrs: (node) => {
665
660
  const element = node;
666
661
  return {
@@ -670,7 +665,7 @@ const nodes = [
670
665
  },
671
666
  {
672
667
  tag: 'kwd',
673
- context: 'keyword_group//',
668
+ context: 'keywords_group//',
674
669
  node: 'keyword',
675
670
  },
676
671
  {
@@ -725,7 +720,7 @@ const nodes = [
725
720
  {
726
721
  tag: 'title',
727
722
  node: 'section_title',
728
- context: 'section/|footnotes_section/|bibliography_section/|keywords/',
723
+ context: 'section/|footnotes_section/|bibliography_section/|keywords_section/',
729
724
  },
730
725
  {
731
726
  tag: 'title',
@@ -377,9 +377,9 @@ export const jatsBodyTransformations = {
377
377
  const title = createElement('title');
378
378
  title.textContent = 'Keywords';
379
379
  section.append(title);
380
- const keywordsElement = createElement('kwd-group-list');
381
- keywordsElement.append(keywordGroups[0]);
382
- section.append(keywordsElement);
380
+ const kwdGroupsEl = createElement('kwd-group-list');
381
+ kwdGroupsEl.append(keywordGroups[0]);
382
+ section.append(kwdGroupsEl);
383
383
  body.prepend(section);
384
384
  }
385
385
  },