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

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 +1 -1
  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
@@ -507,7 +507,7 @@ const nodes = [
507
507
  },
508
508
  {
509
509
  tag: 'sec[sec-type="affiliations"]',
510
- node: 'affiliations',
510
+ node: 'affiliations_section',
511
511
  getAttrs: (node) => {
512
512
  const element = node;
513
513
  return {
@@ -519,7 +519,7 @@ const nodes = [
519
519
  {
520
520
  tag: 'aff',
521
521
  node: 'affiliation',
522
- context: 'affiliations/',
522
+ context: 'affiliations_section/',
523
523
  getAttrs: (node) => {
524
524
  const element = node;
525
525
  const aff = {
@@ -566,7 +566,7 @@ const nodes = [
566
566
  },
567
567
  {
568
568
  tag: 'sec[sec-type="contributors"]',
569
- node: 'contributors',
569
+ node: 'contributors_section',
570
570
  getAttrs: (node) => {
571
571
  const element = node;
572
572
  return {
@@ -578,7 +578,7 @@ const nodes = [
578
578
  {
579
579
  tag: 'contrib',
580
580
  node: 'contributor',
581
- context: 'contributors/',
581
+ context: 'contributors_section/',
582
582
  getAttrs: (node) => {
583
583
  const element = node;
584
584
  const contrib = {
@@ -633,19 +633,19 @@ const nodes = [
633
633
  },
634
634
  {
635
635
  tag: 'sec[sec-type="keywords"]',
636
- node: 'keywords',
637
- },
638
- {
639
- tag: 'sec[sec-type="abstracts"]',
640
- node: 'abstracts',
641
- },
642
- {
643
- tag: 'sec[sec-type="body"]',
644
- node: 'body',
636
+ node: 'keywords_section',
637
+ getAttrs: (node) => {
638
+ const element = node;
639
+ return {
640
+ id: element.getAttribute('id'),
641
+ category: (0, transformer_1.chooseSectionCategory)(element),
642
+ };
643
+ },
645
644
  },
646
645
  {
647
- tag: 'sec[sec-type="backmatter"]',
648
- node: 'backmatter',
646
+ tag: 'kwd-group-list',
647
+ context: 'keywords_section/',
648
+ node: 'keywords_element',
649
649
  },
650
650
  {
651
651
  tag: 'sec',
@@ -658,15 +658,10 @@ const nodes = [
658
658
  };
659
659
  },
660
660
  },
661
- {
662
- tag: 'kwd-group-list',
663
- context: 'keywords/',
664
- node: 'keywords_element',
665
- },
666
661
  {
667
662
  tag: 'kwd-group',
668
663
  context: 'keywords_element/',
669
- node: 'keyword_group',
664
+ node: 'keywords_group',
670
665
  getAttrs: (node) => {
671
666
  const element = node;
672
667
  return {
@@ -676,7 +671,7 @@ const nodes = [
676
671
  },
677
672
  {
678
673
  tag: 'kwd',
679
- context: 'keyword_group//',
674
+ context: 'keywords_group//',
680
675
  node: 'keyword',
681
676
  },
682
677
  {
@@ -731,7 +726,7 @@ const nodes = [
731
726
  {
732
727
  tag: 'title',
733
728
  node: 'section_title',
734
- context: 'section/|footnotes_section/|bibliography_section/|keywords/',
729
+ context: 'section/|footnotes_section/|bibliography_section/|keywords_section/',
735
730
  },
736
731
  {
737
732
  tag: 'title',
@@ -380,9 +380,9 @@ exports.jatsBodyTransformations = {
380
380
  const title = createElement('title');
381
381
  title.textContent = 'Keywords';
382
382
  section.append(title);
383
- const keywordsElement = createElement('kwd-group-list');
384
- keywordsElement.append(keywordGroups[0]);
385
- section.append(keywordsElement);
383
+ const kwdGroupsEl = createElement('kwd-group-list');
384
+ kwdGroupsEl.append(keywordGroups[0]);
385
+ section.append(kwdGroupsEl);
386
386
  body.prepend(section);
387
387
  }
388
388
  },
@@ -431,11 +431,9 @@ class JATSExporter {
431
431
  }
432
432
  };
433
433
  this.buildBody = (fragment) => {
434
+ const content = this.serializeFragment(fragment);
434
435
  const body = this.document.createElement('body');
435
- fragment.forEach((cFragment) => {
436
- const serializedNode = this.serializeNode(cFragment);
437
- body.append(...serializedNode.childNodes);
438
- });
436
+ body.appendChild(content);
439
437
  this.fixBody(body, fragment);
440
438
  return body;
441
439
  };
@@ -602,8 +600,8 @@ class JATSExporter {
602
600
  const getModel = (id) => id ? this.modelMap.get(id) : undefined;
603
601
  const nodes = {
604
602
  title: () => '',
605
- affiliations: () => '',
606
- contributors: () => '',
603
+ affiliations_section: () => '',
604
+ contributors_section: () => '',
607
605
  table_element_footer: () => ['table-wrap-foot', 0],
608
606
  contributor: () => '',
609
607
  affiliation: () => '',
@@ -612,10 +610,7 @@ class JATSExporter {
612
610
  bibliography_element: () => '',
613
611
  bibliography_item: () => '',
614
612
  comment_list: () => '',
615
- keyword_group: () => '',
616
- body: () => ['body', 0],
617
- abstracts: () => ['abstract', 0],
618
- backmatter: () => ['backmatter', 0],
613
+ keywords_group: () => '',
619
614
  bibliography_section: (node) => [
620
615
  'ref-list',
621
616
  { id: normalizeID(node.attrs.id) },
@@ -794,7 +789,7 @@ class JATSExporter {
794
789
  },
795
790
  keyword: () => '',
796
791
  keywords_element: () => '',
797
- keywords: () => '',
792
+ keywords_section: () => '',
798
793
  link: (node) => {
799
794
  const text = node.textContent;
800
795
  if (!text) {
@@ -15,7 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.groupBy = exports.getTrimmedTextContent = exports.findParentNodeClosestToPos = exports.isInAbstractsSection = exports.isInBibliographySection = exports.isInGraphicalAbstractSection = exports.findNodePositions = exports.iterateChildren = void 0;
18
+ exports.getTrimmedTextContent = exports.findParentNodeClosestToPos = exports.isInAbstractsSection = exports.isInBibliographySection = exports.isInGraphicalAbstractSection = exports.findNodePositions = exports.iterateChildren = void 0;
19
19
  const bibliography_section_1 = require("../schema/nodes/bibliography_section");
20
20
  const graphical_abstract_section_1 = require("../schema/nodes/graphical_abstract_section");
21
21
  function* iterateChildren(node, recurse = false) {
@@ -94,12 +94,3 @@ const getTrimmedTextContent = (node, querySelector) => {
94
94
  return (_b = (_a = node.querySelector(querySelector)) === null || _a === void 0 ? void 0 : _a.textContent) === null || _b === void 0 ? void 0 : _b.trim();
95
95
  };
96
96
  exports.getTrimmedTextContent = getTrimmedTextContent;
97
- const groupBy = (list, getKey) => list.reduce((previous, currentItem) => {
98
- const group = getKey(currentItem);
99
- if (!previous[group]) {
100
- previous[group] = [];
101
- }
102
- previous[group].push(currentItem);
103
- return previous;
104
- }, {});
105
- exports.groupBy = groupBy;
@@ -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 affiliations_1 = require("./nodes/affiliations");
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,8 +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 contributors_1 = require("./nodes/contributors");
49
- const core_section_1 = require("./nodes/core_section");
48
+ const contributors_section_1 = require("./nodes/contributors_section");
50
49
  const cross_reference_1 = require("./nodes/cross_reference");
51
50
  const doc_1 = require("./nodes/doc");
52
51
  const equation_1 = require("./nodes/equation");
@@ -63,8 +62,9 @@ const highlight_marker_1 = require("./nodes/highlight_marker");
63
62
  const inline_equation_1 = require("./nodes/inline_equation");
64
63
  const inline_footnote_1 = require("./nodes/inline_footnote");
65
64
  const keyword_1 = require("./nodes/keyword");
66
- const keyword_group_1 = require("./nodes/keyword_group");
67
- const keywords_1 = require("./nodes/keywords");
65
+ const keywords_element_1 = require("./nodes/keywords_element");
66
+ const keywords_group_1 = require("./nodes/keywords_group");
67
+ const keywords_section_1 = require("./nodes/keywords_section");
68
68
  const link_1 = require("./nodes/link");
69
69
  const list_1 = require("./nodes/list");
70
70
  const listing_1 = require("./nodes/listing");
@@ -88,7 +88,6 @@ const text_1 = require("./nodes/text");
88
88
  const title_1 = require("./nodes/title");
89
89
  const toc_element_1 = require("./nodes/toc_element");
90
90
  const toc_section_1 = require("./nodes/toc_section");
91
- const keywords_element_1 = require("./nodes/keywords_element");
92
91
  __exportStar(require("./groups"), exports);
93
92
  __exportStar(require("./types"), exports);
94
93
  __exportStar(require("./nodes/comment"), exports);
@@ -118,7 +117,7 @@ __exportStar(require("./nodes/inline_equation"), exports);
118
117
  __exportStar(require("./nodes/inline_footnote"), exports);
119
118
  __exportStar(require("./nodes/keyword"), exports);
120
119
  __exportStar(require("./nodes/keywords_element"), exports);
121
- __exportStar(require("./nodes/keywords"), exports);
120
+ __exportStar(require("./nodes/keywords_section"), exports);
122
121
  __exportStar(require("./nodes/link"), exports);
123
122
  __exportStar(require("./nodes/list"), exports);
124
123
  __exportStar(require("./nodes/listing"), exports);
@@ -143,8 +142,8 @@ __exportStar(require("./nodes/meta_section"), exports);
143
142
  __exportStar(require("./nodes/contributor"), exports);
144
143
  __exportStar(require("./nodes/table_element_footer"), exports);
145
144
  __exportStar(require("./nodes/title"), exports);
146
- __exportStar(require("./nodes/affiliations"), exports);
147
- __exportStar(require("./nodes/contributors"), exports);
145
+ __exportStar(require("./nodes/affiliations_section"), exports);
146
+ __exportStar(require("./nodes/contributors_section"), exports);
148
147
  exports.schema = new prosemirror_model_1.Schema({
149
148
  marks: {
150
149
  bold: marks_1.bold,
@@ -171,9 +170,6 @@ exports.schema = new prosemirror_model_1.Schema({
171
170
  caption: caption_1.caption,
172
171
  caption_title: caption_title_1.captionTitle,
173
172
  citation: citation_1.citation,
174
- abstracts: core_section_1.coreSection,
175
- body: core_section_1.coreSection,
176
- backmatter: core_section_1.coreSection,
177
173
  cross_reference: cross_reference_1.crossReference,
178
174
  doc: doc_1.doc,
179
175
  equation: equation_1.equation,
@@ -191,8 +187,8 @@ exports.schema = new prosemirror_model_1.Schema({
191
187
  inline_footnote: inline_footnote_1.inlineFootnote,
192
188
  keyword: keyword_1.keyword,
193
189
  keywords_element: keywords_element_1.keywordsElement,
194
- keywords: keywords_1.keywords,
195
- keyword_group: keyword_group_1.keywordGroup,
190
+ keywords_section: keywords_section_1.keywordsSection,
191
+ keywords_group: keywords_group_1.keywordsGroup,
196
192
  link: link_1.link,
197
193
  list_item: list_1.listItem,
198
194
  listing: listing_1.listing,
@@ -223,7 +219,7 @@ exports.schema = new prosemirror_model_1.Schema({
223
219
  contributor: contributor_1.contributor,
224
220
  table_element_footer: table_element_footer_1.tableElementFooter,
225
221
  title: title_1.title,
226
- affiliations: affiliations_1.affiliations,
227
- contributors: contributors_1.contributors,
222
+ affiliations_section: affiliations_section_1.affiliationsSection,
223
+ contributors_section: contributors_section_1.contributorsSection,
228
224
  },
229
225
  });
@@ -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;
@@ -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;
@@ -21,6 +21,7 @@ exports.keyword = {
21
21
  content: 'inline*',
22
22
  attrs: {
23
23
  id: { default: '' },
24
+ contents: { default: '' },
24
25
  dataTracked: { default: null },
25
26
  comments: { default: null },
26
27
  },
@@ -18,7 +18,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.keywordsElement = void 0;
19
19
  exports.keywordsElement = {
20
20
  atom: true,
21
- content: 'keyword_group*',
21
+ content: 'keywords_group*',
22
22
  attrs: {
23
23
  id: { default: '' },
24
24
  contents: { default: '' },
@@ -15,8 +15,8 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.isKeywordGroupNode = exports.keywordGroup = void 0;
19
- exports.keywordGroup = {
18
+ exports.isKeywordsGroupNode = exports.keywordsGroup = void 0;
19
+ exports.keywordsGroup = {
20
20
  content: 'keyword*',
21
21
  attrs: {
22
22
  id: { default: '' },
@@ -31,11 +31,11 @@ exports.keywordGroup = {
31
31
  },
32
32
  ],
33
33
  toDOM: (node) => {
34
- const keywordGroupNode = node;
34
+ const keywordsGroupNode = node;
35
35
  return [
36
36
  'div',
37
37
  {
38
- id: keywordGroupNode.attrs.id,
38
+ id: keywordsGroupNode.attrs.id,
39
39
  class: 'keywords',
40
40
  spellcheck: 'false',
41
41
  contenteditable: false,
@@ -44,5 +44,5 @@ exports.keywordGroup = {
44
44
  ];
45
45
  },
46
46
  };
47
- const isKeywordGroupNode = (node) => node.type === node.type.schema.nodes.keywords_group;
48
- exports.isKeywordGroupNode = isKeywordGroupNode;
47
+ const isKeywordsGroupNode = (node) => node.type === node.type.schema.nodes.keywords_group;
48
+ exports.isKeywordsGroupNode = isKeywordsGroupNode;
@@ -15,14 +15,14 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.isKeywordsNode = exports.keywords = void 0;
19
- exports.keywords = {
18
+ exports.isKeywordsSectionNode = exports.keywordsSection = void 0;
19
+ exports.keywordsSection = {
20
20
  content: 'section_title (keywords_element | placeholder_element)',
21
21
  attrs: {
22
22
  id: { default: '' },
23
23
  dataTracked: { default: null },
24
24
  },
25
- group: 'block',
25
+ group: 'block sections',
26
26
  selectable: false,
27
27
  parseDOM: [
28
28
  {
@@ -30,11 +30,11 @@ exports.keywords = {
30
30
  },
31
31
  ],
32
32
  toDOM: (node) => {
33
- const keywords = node;
33
+ const keywordsSectionNode = node;
34
34
  return [
35
35
  'div',
36
36
  {
37
- id: keywords.attrs.id,
37
+ id: keywordsSectionNode.attrs.id,
38
38
  class: 'keywords',
39
39
  spellcheck: 'false',
40
40
  contenteditable: false,
@@ -43,5 +43,5 @@ exports.keywords = {
43
43
  ];
44
44
  },
45
45
  };
46
- const isKeywordsNode = (node) => node.type === node.type.schema.nodes.keywords;
47
- exports.isKeywordsNode = isKeywordsNode;
46
+ const isKeywordsSectionNode = (node) => node.type === node.type.schema.nodes.keywords_section;
47
+ exports.isKeywordsSectionNode = isKeywordsSectionNode;
@@ -17,7 +17,7 @@
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.manuscript = void 0;
19
19
  exports.manuscript = {
20
- content: 'title? contributors? affiliations? keywords? abstracts body backmatter meta_section',
20
+ content: 'title* (section | sections)+ meta_section',
21
21
  attrs: {
22
22
  id: { default: '' },
23
23
  },