@manuscripts/transform 1.5.2-LEAN-3032 → 1.5.2-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 (37) hide show
  1. package/dist/cjs/jats/importer/jats-body-dom-parser.js +7 -19
  2. package/dist/cjs/jats/jats-exporter.js +5 -10
  3. package/dist/cjs/lib/utils.js +1 -10
  4. package/dist/cjs/schema/index.js +3 -7
  5. package/dist/cjs/schema/nodes/affiliations_section.js +1 -1
  6. package/dist/cjs/schema/nodes/contributors_section.js +1 -1
  7. package/dist/cjs/schema/nodes/keywords_section.js +1 -1
  8. package/dist/cjs/schema/nodes/manuscript.js +1 -1
  9. package/dist/cjs/transformer/decode.js +19 -67
  10. package/dist/cjs/transformer/encode.js +36 -14
  11. package/dist/cjs/transformer/node-names.js +1 -1
  12. package/dist/cjs/transformer/node-title.js +1 -1
  13. package/dist/cjs/transformer/node-types.js +3 -6
  14. package/dist/cjs/transformer/section-category.js +8 -35
  15. package/dist/es/jats/importer/jats-body-dom-parser.js +7 -19
  16. package/dist/es/jats/jats-exporter.js +5 -10
  17. package/dist/es/lib/utils.js +0 -8
  18. package/dist/es/schema/index.js +3 -7
  19. package/dist/es/schema/nodes/affiliations_section.js +1 -1
  20. package/dist/es/schema/nodes/contributors_section.js +1 -1
  21. package/dist/es/schema/nodes/keywords_section.js +1 -1
  22. package/dist/es/schema/nodes/manuscript.js +1 -1
  23. package/dist/es/transformer/decode.js +20 -68
  24. package/dist/es/transformer/encode.js +36 -14
  25. package/dist/es/transformer/node-names.js +1 -1
  26. package/dist/es/transformer/node-title.js +1 -1
  27. package/dist/es/transformer/node-types.js +3 -6
  28. package/dist/es/transformer/section-category.js +7 -33
  29. package/dist/types/lib/utils.d.ts +0 -1
  30. package/dist/types/schema/types.d.ts +1 -1
  31. package/dist/types/transformer/decode.d.ts +0 -3
  32. package/dist/types/transformer/encode.d.ts +1 -1
  33. package/dist/types/transformer/section-category.d.ts +0 -1
  34. package/package.json +2 -2
  35. package/dist/cjs/schema/nodes/core_section.js +0 -27
  36. package/dist/es/schema/nodes/core_section.js +0 -24
  37. package/dist/types/schema/nodes/core_section.d.ts +0 -25
@@ -423,11 +423,9 @@ export class JATSExporter {
423
423
  }
424
424
  };
425
425
  this.buildBody = (fragment) => {
426
+ const content = this.serializeFragment(fragment);
426
427
  const body = this.document.createElement('body');
427
- fragment.forEach((cFragment) => {
428
- const serializedNode = this.serializeNode(cFragment);
429
- body.append(...serializedNode.childNodes);
430
- });
428
+ body.appendChild(content);
431
429
  this.fixBody(body, fragment);
432
430
  return body;
433
431
  };
@@ -593,8 +591,8 @@ export class JATSExporter {
593
591
  this.createSerializer = () => {
594
592
  const getModel = (id) => id ? this.modelMap.get(id) : undefined;
595
593
  const nodes = {
596
- affiliations: () => '',
597
- contributors: () => '',
594
+ affiliations_section: () => '',
595
+ contributors_section: () => '',
598
596
  table_element_footer: () => ['table-wrap-foot', 0],
599
597
  contributor: () => '',
600
598
  affiliation: () => '',
@@ -604,9 +602,6 @@ export class JATSExporter {
604
602
  bibliography_item: () => '',
605
603
  comment_list: () => '',
606
604
  keywords_group: () => '',
607
- body: () => ['body', 0],
608
- abstracts: () => ['abstract', 0],
609
- backmatter: () => ['backmatter', 0],
610
605
  bibliography_section: (node) => [
611
606
  'ref-list',
612
607
  { id: normalizeID(node.attrs.id) },
@@ -785,7 +780,7 @@ export class JATSExporter {
785
780
  },
786
781
  keyword: () => '',
787
782
  keywords_element: () => '',
788
- keywords: () => '',
783
+ keywords_section: () => '',
789
784
  link: (node) => {
790
785
  const text = node.textContent;
791
786
  if (!text) {
@@ -84,11 +84,3 @@ export const getTrimmedTextContent = (node, querySelector) => {
84
84
  }
85
85
  return (_b = (_a = node.querySelector(querySelector)) === null || _a === void 0 ? void 0 : _a.textContent) === null || _b === void 0 ? void 0 : _b.trim();
86
86
  };
87
- export const groupBy = (list, getKey) => list.reduce((previous, currentItem) => {
88
- const group = getKey(currentItem);
89
- if (!previous[group]) {
90
- previous[group] = [];
91
- }
92
- previous[group].push(currentItem);
93
- return previous;
94
- }, {});
@@ -29,7 +29,6 @@ import { comment } from './nodes/comment';
29
29
  import { commentList } from './nodes/comment_list';
30
30
  import { contributor } from './nodes/contributor';
31
31
  import { contributorsSection } from './nodes/contributors_section';
32
- import { coreSection } from './nodes/core_section';
33
32
  import { crossReference } from './nodes/cross_reference';
34
33
  import { doc } from './nodes/doc';
35
34
  import { equation } from './nodes/equation';
@@ -152,9 +151,6 @@ export const schema = new Schema({
152
151
  caption,
153
152
  caption_title: captionTitle,
154
153
  citation,
155
- abstracts: coreSection,
156
- body: coreSection,
157
- backmatter: coreSection,
158
154
  cross_reference: crossReference,
159
155
  doc,
160
156
  equation,
@@ -172,7 +168,7 @@ export const schema = new Schema({
172
168
  inline_footnote: inlineFootnote,
173
169
  keyword,
174
170
  keywords_element: keywordsElement,
175
- keywords: keywordsSection,
171
+ keywords_section: keywordsSection,
176
172
  keywords_group: keywordsGroup,
177
173
  link,
178
174
  list_item: listItem,
@@ -203,7 +199,7 @@ export const schema = new Schema({
203
199
  meta_section: metaSection,
204
200
  contributor: contributor,
205
201
  table_element_footer: tableElementFooter,
206
- affiliations: affiliationsSection,
207
- contributors: contributorsSection,
202
+ affiliations_section: affiliationsSection,
203
+ contributors_section: contributorsSection,
208
204
  },
209
205
  });
@@ -8,4 +8,4 @@ export const affiliationsSection = {
8
8
  selectable: false,
9
9
  toDOM: () => ['section', 0],
10
10
  };
11
- export const isAffiliationsSectionNode = (node) => node.type === node.type.schema.nodes.affiliations;
11
+ export const isAffiliationsSectionNode = (node) => node.type === node.type.schema.nodes.affiliations_section;
@@ -8,4 +8,4 @@ export const contributorsSection = {
8
8
  selectable: false,
9
9
  toDOM: () => ['section', 0],
10
10
  };
11
- export const isContributorsSectionNode = (node) => node.type === node.type.schema.nodes.contributors;
11
+ export const isContributorsSectionNode = (node) => node.type === node.type.schema.nodes.contributors_section;
@@ -40,4 +40,4 @@ export const keywordsSection = {
40
40
  ];
41
41
  },
42
42
  };
43
- export const isKeywordsSectionNode = (node) => node.type === node.type.schema.nodes.keywords;
43
+ export const isKeywordsSectionNode = (node) => node.type === node.type.schema.nodes.keywords_section;
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  export const manuscript = {
17
- content: 'contributors? affiliations? keywords? abstracts body backmatter meta_section',
17
+ content: '(section | sections)+ meta_section',
18
18
  attrs: {
19
19
  id: { default: '' },
20
20
  },
@@ -28,12 +28,11 @@ import { ObjectTypes, } from '@manuscripts/json-schema';
28
28
  import debug from 'debug';
29
29
  import { DOMParser } from 'prosemirror-model';
30
30
  import { MissingElement } from '../errors';
31
- import { groupBy } from '../lib/utils';
32
31
  import { schema, } from '../schema';
33
32
  import { insertHighlightMarkers } from './highlight-markers';
34
33
  import { generateNodeID } from './id';
35
34
  import { ExtraObjectTypes, hasObjectType, isCommentAnnotation, isManuscript, } from './object-types';
36
- import { chooseCoreSectionBySection, chooseSectionLableName, chooseSectionNodeType, chooseSecType, guessSectionCategory, } from './section-category';
35
+ import { chooseSectionLableName, chooseSectionNodeType, chooseSecType, guessSectionCategory, } from './section-category';
37
36
  import { timestamp } from './timestamp';
38
37
  const warn = debug('manuscripts-transform');
39
38
  const parser = DOMParser.fromSchema(schema);
@@ -54,7 +53,6 @@ export const sortSectionsByPriority = (a, b) => a.priority === b.priority ? 0 :
54
53
  const getSections = (modelMap) => getModelsByType(modelMap, ObjectTypes.Section).sort(sortSectionsByPriority);
55
54
  const getAffiliations = (modelMap) => getModelsByType(modelMap, ObjectTypes.Affiliation);
56
55
  const getContributors = (modelMap) => getModelsByType(modelMap, ObjectTypes.Contributor);
57
- const getKeywordElements = (modelMap) => getModelsByType(modelMap, ObjectTypes.KeywordsElement);
58
56
  export const isManuscriptNode = (model) => model !== null;
59
57
  const isParagraphElement = hasObjectType(ObjectTypes.ParagraphElement);
60
58
  const isFootnote = hasObjectType(ObjectTypes.Footnote);
@@ -78,13 +76,10 @@ export class Decoder {
78
76
  ]);
79
77
  }
80
78
  handleMissingRootSectionNodes(rootSectionNodes) {
81
- if (!rootSectionNodes.find((node) => node.type.name === 'keywords')) {
82
- this.createKeywordsSectionNode(rootSectionNodes);
83
- }
84
- if (!rootSectionNodes.find((node) => node.type.name === 'affiliations')) {
79
+ if (!rootSectionNodes.find((node) => node.type.name === 'affiliations_section')) {
85
80
  this.createAffiliationSectionNode(rootSectionNodes);
86
81
  }
87
- if (!rootSectionNodes.find((node) => node.type.name === 'contributors')) {
82
+ if (!rootSectionNodes.find((node) => node.type.name === 'contributors_section')) {
88
83
  this.createContributorSectionNode(rootSectionNodes);
89
84
  }
90
85
  }
@@ -92,79 +87,37 @@ export class Decoder {
92
87
  const affiliationNodes = getAffiliations(this.modelMap)
93
88
  .map((affiliation) => this.decode(affiliation))
94
89
  .filter(Boolean);
95
- const node = schema.nodes.affiliations.createAndFill({
96
- id: generateNodeID(schema.nodes.section),
97
- }, affiliationNodes);
98
- rootSectionNodes.unshift(node);
90
+ if (affiliationNodes.length) {
91
+ const node = schema.nodes.affiliations_section.createAndFill({
92
+ id: generateNodeID(schema.nodes.section),
93
+ }, affiliationNodes);
94
+ rootSectionNodes.unshift(node);
95
+ }
99
96
  }
100
97
  createContributorSectionNode(rootSectionNodes) {
101
98
  const contributorNodes = getContributors(this.modelMap)
102
99
  .map((contributor) => this.decode(contributor))
103
100
  .filter(Boolean);
104
- const node = schema.nodes.contributors.createAndFill({
105
- id: generateNodeID(schema.nodes.section),
106
- }, contributorNodes);
107
- rootSectionNodes.unshift(node);
108
- }
109
- createKeywordsSectionNode(rootSectionNodes) {
110
- const keywordElementNodes = getKeywordElements(this.modelMap)
111
- .map((keywordEl) => this.decode(keywordEl))
112
- .filter(Boolean);
113
- if (keywordElementNodes) {
114
- const node = schema.nodes.keywords.createAndFill({
101
+ if (contributorNodes.length) {
102
+ const node = schema.nodes.contributors_section.createAndFill({
115
103
  id: generateNodeID(schema.nodes.section),
116
- }, [
117
- schema.nodes.section_title.create({}, schema.text('Keywords')),
118
- ...keywordElementNodes,
119
- ]);
104
+ }, contributorNodes);
120
105
  rootSectionNodes.unshift(node);
121
106
  }
122
107
  }
123
108
  createRootSectionNodes() {
124
- let rootSections = getSections(this.modelMap)
125
- .filter((section) => !section.path || section.path.length <= 1)
126
- .filter((section) => section.category !== 'MPSectionCategory:contributors' &&
127
- section.category !== 'MPSectionCategory:affiliations' &&
128
- section.category !== 'MPSectionCategory:keywords');
109
+ let rootSections = getSections(this.modelMap).filter((section) => !section.path || section.path.length <= 1);
129
110
  rootSections = this.addGeneratedLabels(rootSections);
130
- const sectionGroups = groupBy(rootSections, (sec) => {
131
- var _a;
132
- return chooseCoreSectionBySection((_a = sec.category) !== null && _a !== void 0 ? _a : '');
133
- });
134
- this.ensureCoreSectionsExist(sectionGroups);
135
- const absSectionNode = sectionGroups['MPSectionCategory:abstracts']
136
- .map(this.decode)
137
- .filter(isManuscriptNode);
138
- const bodySectionNodes = sectionGroups['MPSectionCategory:body']
111
+ const rootSectionNodes = rootSections
139
112
  .map(this.decode)
140
113
  .filter(isManuscriptNode);
141
- const backmatterSectionNodes = sectionGroups['MPSectionCategory:backmatter']
142
- .map(this.decode)
143
- .filter(isManuscriptNode);
144
- const abstractCoreSectionNodes = this.createAndFill(schema.nodes.abstracts, absSectionNode);
145
- const bodyCoreSectionNodes = this.createAndFill(schema.nodes.body, bodySectionNodes);
146
- const backmatterCoreSectionNodes = this.createAndFill(schema.nodes.backmatter, backmatterSectionNodes);
147
- return [
148
- abstractCoreSectionNodes,
149
- bodyCoreSectionNodes,
150
- backmatterCoreSectionNodes,
151
- ];
152
- }
153
- ensureCoreSectionsExist(coreSections) {
154
- if (!coreSections['MPSectionCategory:abstracts']) {
155
- coreSections['MPSectionCategory:abstracts'] = [];
156
- }
157
- if (!coreSections['MPSectionCategory:body']) {
158
- coreSections['MPSectionCategory:body'] = [];
159
- }
160
- if (!coreSections['MPSectionCategory:backmatter']) {
161
- coreSections['MPSectionCategory:backmatter'] = [];
114
+ this.handleMissingRootSectionNodes(rootSectionNodes);
115
+ if (!rootSectionNodes.length) {
116
+ rootSectionNodes.push(schema.nodes.section.createAndFill({
117
+ id: generateNodeID(schema.nodes.section),
118
+ }));
162
119
  }
163
- }
164
- createAndFill(nodeType, content) {
165
- return nodeType.createAndFill({
166
- id: generateNodeID(nodeType),
167
- }, content);
120
+ return rootSectionNodes;
168
121
  }
169
122
  createCommentsNode(model) {
170
123
  const comments = [];
@@ -669,7 +622,6 @@ export class Decoder {
669
622
  this.getModel = (id) => this.modelMap.get(id);
670
623
  this.createArticleNode = (manuscriptID) => {
671
624
  const rootSectionNodes = this.createRootSectionNodes();
672
- this.handleMissingRootSectionNodes(rootSectionNodes);
673
625
  const metaSectionNode = this.createMetaSectionNode();
674
626
  const contents = [...rootSectionNodes, metaSectionNode];
675
627
  return schema.nodes.manuscript.create({
@@ -417,6 +417,31 @@ const encoders = {
417
417
  keywords_group: (node) => ({
418
418
  type: node.attrs.type,
419
419
  }),
420
+ keywords_section: (node, parent, path, priority) => ({
421
+ category: buildSectionCategory(node),
422
+ priority: priority.value++,
423
+ title: inlineContentsOfNodeType(node, node.type.schema.nodes.section_title),
424
+ path: path.concat([node.attrs.id]),
425
+ elementIDs: childElements(node)
426
+ .map((childNode) => childNode.attrs.id)
427
+ .filter((id) => id),
428
+ }),
429
+ affiliations_section: (node, parent, path, priority) => ({
430
+ category: buildSectionCategory(node),
431
+ priority: priority.value++,
432
+ path: path.concat([node.attrs.id]),
433
+ elementIDs: childElements(node)
434
+ .map((childNode) => childNode.attrs.id)
435
+ .filter((id) => id),
436
+ }),
437
+ contributors_section: (node, parent, path, priority) => ({
438
+ category: 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
+ }),
420
445
  missing_figure: (node) => ({
421
446
  position: node.attrs.position || undefined,
422
447
  }),
@@ -534,16 +559,9 @@ export const modelFromNode = (node, parent, path, priority) => {
534
559
  if (isHighlightableModel(model)) {
535
560
  extractHighlightMarkers(model, commentAnnotationsMap);
536
561
  }
537
- return { model, commentAnnotationsMap };
562
+ const comments = [...commentAnnotationsMap.values()];
563
+ return { model, comments };
538
564
  };
539
- function isCoreSection(child) {
540
- return (child.type === schema.nodes.abstracts ||
541
- child.type === schema.nodes.body ||
542
- child.type === schema.nodes.backmatter ||
543
- child.type === schema.nodes.affiliations ||
544
- child.type === schema.nodes.contributors ||
545
- child.type === schema.nodes.keywords);
546
- }
547
565
  export const encode = (node) => {
548
566
  const models = new Map();
549
567
  const priority = {
@@ -551,10 +569,6 @@ export const encode = (node) => {
551
569
  };
552
570
  const placeholders = ['placeholder', 'placeholder_element'];
553
571
  const addModel = (path, parent) => (child) => {
554
- if (isCoreSection(child)) {
555
- child.forEach(addModel([], child));
556
- return;
557
- }
558
572
  if (!child.attrs.id) {
559
573
  return;
560
574
  }
@@ -567,10 +581,18 @@ export const encode = (node) => {
567
581
  if (placeholders.includes(child.type.name)) {
568
582
  return;
569
583
  }
570
- const { model } = modelFromNode(child, parent, path, priority);
584
+ const { model, comments } = modelFromNode(child, parent, path, priority);
571
585
  if (models.has(model._id)) {
572
586
  throw Error(`Encountered duplicate ids in models map while encoding: ${model._id}`);
573
587
  }
588
+ comments.forEach((comment) => {
589
+ const proseMirrorComment = models.get(comment._id);
590
+ if (proseMirrorComment) {
591
+ ;
592
+ proseMirrorComment.selector = comment.selector;
593
+ models.set(comment._id, proseMirrorComment);
594
+ }
595
+ });
574
596
  models.set(model._id, model);
575
597
  child.forEach(addModel(path.concat(child.attrs.id), child));
576
598
  };
@@ -35,6 +35,6 @@ export const nodeNames = new Map([
35
35
  [schema.nodes.table_element, 'Table'],
36
36
  [schema.nodes.blockquote_element, 'Block Quote'],
37
37
  [schema.nodes.pullquote_element, 'Pull Quote'],
38
- [schema.nodes.keywords, 'Section'],
38
+ [schema.nodes.keywords_section, 'Section'],
39
39
  [schema.nodes.toc_section, 'Section'],
40
40
  ]);
@@ -45,7 +45,7 @@ export const nodeTitle = (node) => {
45
45
  case nodes.section:
46
46
  case nodes.bibliography_section:
47
47
  case nodes.footnotes_section:
48
- case nodes.keywords:
48
+ case nodes.keywords_section:
49
49
  case nodes.toc_section:
50
50
  case nodes.graphical_abstract_section:
51
51
  return snippetOfNodeType(node, nodes.section_title);
@@ -16,9 +16,6 @@
16
16
  import { ObjectTypes } from '@manuscripts/json-schema';
17
17
  import { GROUP_ELEMENT, GROUP_EXECUTABLE, GROUP_SECTION, hasGroup, schema, } from '../schema';
18
18
  export const nodeTypesMap = new Map([
19
- [schema.nodes.abstracts, ObjectTypes.Section],
20
- [schema.nodes.body, ObjectTypes.Section],
21
- [schema.nodes.backmatter, ObjectTypes.Section],
22
19
  [schema.nodes.comment, ObjectTypes.CommentAnnotation],
23
20
  [schema.nodes.bibliography_item, ObjectTypes.BibliographyItem],
24
21
  [schema.nodes.bibliography_element, ObjectTypes.BibliographyElement],
@@ -40,7 +37,7 @@ export const nodeTypesMap = new Map([
40
37
  [schema.nodes.inline_equation, ObjectTypes.InlineMathFragment],
41
38
  [schema.nodes.keyword, ObjectTypes.Keyword],
42
39
  [schema.nodes.keywords_element, ObjectTypes.KeywordsElement],
43
- [schema.nodes.keywords, ObjectTypes.Section],
40
+ [schema.nodes.keywords_section, ObjectTypes.Section],
44
41
  [schema.nodes.keywords_group, ObjectTypes.KeywordGroup],
45
42
  [schema.nodes.listing, ObjectTypes.Listing],
46
43
  [schema.nodes.listing_element, ObjectTypes.ListingElement],
@@ -57,8 +54,8 @@ export const nodeTypesMap = new Map([
57
54
  [schema.nodes.affiliation, ObjectTypes.Affiliation],
58
55
  [schema.nodes.contributor, ObjectTypes.Contributor],
59
56
  [schema.nodes.table_element_footer, ObjectTypes.TableElementFooter],
60
- [schema.nodes.contributors, ObjectTypes.Section],
61
- [schema.nodes.affiliations, ObjectTypes.Section],
57
+ [schema.nodes.contributors_section, ObjectTypes.Section],
58
+ [schema.nodes.affiliations_section, ObjectTypes.Section],
62
59
  ]);
63
60
  export const isExecutableNodeType = (type) => hasGroup(type, GROUP_EXECUTABLE);
64
61
  export const isElementNodeType = (type) => hasGroup(type, GROUP_ELEMENT);
@@ -19,7 +19,7 @@ import { schema } from '../schema';
19
19
  const sectionNodeTypes = [
20
20
  schema.nodes.bibliography_section,
21
21
  schema.nodes.footnotes_section,
22
- schema.nodes.keywords,
22
+ schema.nodes.keywords_section,
23
23
  schema.nodes.section,
24
24
  schema.nodes.toc_section,
25
25
  ];
@@ -40,11 +40,11 @@ export const chooseSectionNodeType = (category) => {
40
40
  case 'MPSectionCategory:endnotes':
41
41
  return schema.nodes.footnotes_section;
42
42
  case 'MPSectionCategory:keywords':
43
- return schema.nodes.keywords;
43
+ return schema.nodes.keywords_section;
44
44
  case 'MPSectionCategory:affiliations':
45
- return schema.nodes.affiliations;
45
+ return schema.nodes.affiliations_section;
46
46
  case 'MPSectionCategory:contributors':
47
- return schema.nodes.contributors;
47
+ return schema.nodes.contributors_section;
48
48
  case 'MPSectionCategory:toc':
49
49
  return schema.nodes.toc_section;
50
50
  default:
@@ -82,15 +82,15 @@ export const buildSectionCategory = (node) => {
82
82
  return 'MPSectionCategory:bibliography';
83
83
  case schema.nodes.footnotes_section:
84
84
  return 'MPSectionCategory:endnotes';
85
- case schema.nodes.keywords:
85
+ case schema.nodes.keywords_section:
86
86
  return 'MPSectionCategory:keywords';
87
87
  case schema.nodes.toc_section:
88
88
  return 'MPSectionCategory:toc';
89
89
  case schema.nodes.graphical_abstract_section:
90
90
  return 'MPSectionCategory:abstract-graphical';
91
- case schema.nodes.affiliations:
91
+ case schema.nodes.affiliations_section:
92
92
  return 'MPSectionCategory:affiliations';
93
- case schema.nodes.contributors:
93
+ case schema.nodes.contributors_section:
94
94
  return 'MPSectionCategory:contributors';
95
95
  default:
96
96
  return node.attrs.category || undefined;
@@ -117,32 +117,6 @@ export const chooseSecType = (sectionCategory) => {
117
117
  return suffix;
118
118
  }
119
119
  };
120
- export const chooseCoreSectionBySection = (section) => {
121
- switch (section) {
122
- case 'MPSectionCategory:abstract':
123
- case 'MPSectionCategory:abstract-teaser':
124
- case 'MPSectionCategory:abstract-graphical':
125
- return 'MPSectionCategory:abstracts';
126
- case 'MPSectionCategory:acknowledgement':
127
- case 'MPSectionCategory:availability':
128
- case 'MPSectionCategory:conclusions':
129
- case 'MPSectionCategory:bibliography':
130
- case 'MPSectionCategory:discussion':
131
- case 'MPSectionCategory:endnotes':
132
- case 'MPSectionCategory:appendices':
133
- case 'MPSectionCategory:competing-interests':
134
- case 'MPSectionCategory:con':
135
- case 'MPSectionCategory:deceased':
136
- case 'MPSectionCategory:ethics-statement':
137
- case 'MPSectionCategory:financial-disclosure':
138
- case 'MPSectionCategory:supplementary-material':
139
- case 'MPSectionCategory:supported-by':
140
- case 'MPSectionCategory:abbreviations':
141
- case 'MPSectionCategory:results':
142
- return 'MPSectionCategory:backmatter';
143
- }
144
- return 'MPSectionCategory:body';
145
- };
146
120
  export const chooseSectionCategoryByType = (secType) => {
147
121
  switch (secType) {
148
122
  case 'abstract':
@@ -27,4 +27,3 @@ export declare const findParentNodeClosestToPos: ($pos: ResolvedPos, predicate:
27
27
  node: ProsemirrorNode;
28
28
  } | undefined;
29
29
  export declare const getTrimmedTextContent: (node: Element | Document, querySelector: string) => string | null | undefined;
30
- export declare const groupBy: <T, K extends string | number | symbol>(list: T[], getKey: (item: T) => K) => Record<K, T[]>;
@@ -17,7 +17,7 @@ import { Fragment, Mark as ProsemirrorMark, MarkType, Node as ProsemirrorNode, N
17
17
  import { EditorState, NodeSelection, Plugin, TextSelection, Transaction } from 'prosemirror-state';
18
18
  import { EditorView, NodeView } from 'prosemirror-view';
19
19
  export type Marks = 'bold' | 'code' | 'italic' | 'smallcaps' | 'strikethrough' | 'styled' | 'subscript' | 'superscript' | 'underline' | 'tracked_insert' | 'tracked_delete';
20
- export type Nodes = 'attribution' | 'bibliography_item' | 'bibliography_element' | 'bibliography_section' | 'blockquote_element' | 'bullet_list' | 'caption' | 'caption_title' | 'comment' | 'comment_list' | 'citation' | 'cross_reference' | 'doc' | 'equation' | 'equation_element' | 'figcaption' | 'figure' | 'graphical_abstract_section' | 'figure_element' | 'footnote' | 'footnotes_element' | 'footnotes_section' | 'hard_break' | 'highlight_marker' | 'inline_equation' | 'inline_footnote' | 'keyword' | 'keywords_element' | 'keywords_group' | 'keywords' | 'link' | 'list_item' | 'listing' | 'listing_element' | 'manuscript' | 'abstracts' | 'body' | 'backmatter' | 'missing_figure' | 'ordered_list' | 'paragraph' | 'placeholder' | 'placeholder_element' | 'pullquote_element' | 'section' | 'section_label' | 'section_title' | 'section_title_plain' | 'table' | 'table_body' | 'table_cell' | 'table_element' | 'table_row' | 'table_colgroup' | 'table_col' | 'text' | 'toc_element' | 'toc_section' | 'affiliation' | 'meta_section' | 'contributor' | 'table_element_footer' | 'affiliations' | 'contributors';
20
+ export type Nodes = 'attribution' | 'bibliography_item' | 'bibliography_element' | 'bibliography_section' | 'blockquote_element' | 'bullet_list' | 'caption' | 'caption_title' | 'comment' | 'comment_list' | 'citation' | 'cross_reference' | 'doc' | 'equation' | 'equation_element' | 'figcaption' | 'figure' | 'graphical_abstract_section' | 'figure_element' | 'footnote' | 'footnotes_element' | 'footnotes_section' | 'hard_break' | 'highlight_marker' | 'inline_equation' | 'inline_footnote' | 'keyword' | 'keywords_element' | 'keywords_group' | 'keywords_section' | 'link' | 'list_item' | 'listing' | 'listing_element' | 'manuscript' | 'missing_figure' | 'ordered_list' | 'paragraph' | 'placeholder' | 'placeholder_element' | 'pullquote_element' | 'section' | 'section_label' | 'section_title' | 'section_title_plain' | 'table' | 'table_body' | 'table_cell' | 'table_element' | 'table_row' | 'table_colgroup' | 'table_col' | 'text' | 'toc_element' | 'toc_section' | 'affiliation' | 'meta_section' | 'contributor' | 'table_element_footer' | 'affiliations_section' | 'contributors_section';
21
21
  export type ManuscriptSchema = Schema<Nodes, Marks>;
22
22
  export type ManuscriptEditorState = EditorState;
23
23
  export type ManuscriptEditorView = EditorView;
@@ -30,10 +30,7 @@ export declare class Decoder {
30
30
  private handleMissingRootSectionNodes;
31
31
  private createAffiliationSectionNode;
32
32
  private createContributorSectionNode;
33
- private createKeywordsSectionNode;
34
33
  private createRootSectionNodes;
35
- private ensureCoreSectionsExist;
36
- private createAndFill;
37
34
  private createCommentsNode;
38
35
  private getComments;
39
36
  private extractListing;
@@ -20,7 +20,7 @@ export declare const inlineContents: (node: ManuscriptNode) => string;
20
20
  export declare const inlineText: (node: ManuscriptNode) => string;
21
21
  export declare const modelFromNode: (node: ManuscriptNode, parent: ManuscriptNode, path: string[], priority: PrioritizedValue) => {
22
22
  model: Model;
23
- commentAnnotationsMap: Map<string, Build<CommentAnnotation>>;
23
+ comments: Build<CommentAnnotation>[];
24
24
  };
25
25
  interface PrioritizedValue {
26
26
  value: number;
@@ -25,7 +25,6 @@ export declare const guessSectionCategory: (elements: Element[]) => SectionCateg
25
25
  export declare const buildSectionCategory: (node: ManuscriptNode) => SectionCategory | undefined;
26
26
  export declare const chooseJatsFnType: (footnoteType: string) => string;
27
27
  export declare const chooseSecType: (sectionCategory: SectionCategory) => SecType;
28
- export declare const chooseCoreSectionBySection: (section: string) => string;
29
28
  export declare const chooseSectionCategoryByType: (secType: string) => SectionCategory | undefined;
30
29
  export declare const chooseSectionCategory: (section: HTMLElement) => SectionCategory | undefined;
31
30
  export declare const chooseSectionCategoryFromTitle: (title: string | null) => SectionCategory | undefined;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@manuscripts/transform",
3
3
  "description": "ProseMirror transformer for Manuscripts applications",
4
- "version": "1.5.2-LEAN-3032",
4
+ "version": "1.5.2-LEAN-2995",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-transform",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -82,4 +82,4 @@
82
82
  "prosemirror-state": "^1.4.2",
83
83
  "prosemirror-view": "^1.29.1"
84
84
  }
85
- }
85
+ }
@@ -1,27 +0,0 @@
1
- "use strict";
2
- /*!
3
- * © 2019 Atypon Systems LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.coreSection = void 0;
19
- exports.coreSection = {
20
- content: '(section | sections)*',
21
- atom: true,
22
- attrs: {
23
- id: { default: '' },
24
- },
25
- group: 'block sections',
26
- toDOM: () => ['section', 0],
27
- };
@@ -1,24 +0,0 @@
1
- /*!
2
- * © 2019 Atypon Systems LLC
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- export const coreSection = {
17
- content: '(section | sections)*',
18
- atom: true,
19
- attrs: {
20
- id: { default: '' },
21
- },
22
- group: 'block sections',
23
- toDOM: () => ['section', 0],
24
- };
@@ -1,25 +0,0 @@
1
- /*!
2
- * © 2019 Atypon Systems LLC
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- import { NodeSpec } from 'prosemirror-model';
17
- import { ManuscriptNode } from '../types';
18
- interface Attrs {
19
- id: string;
20
- }
21
- export interface CoreSection extends ManuscriptNode {
22
- attrs: Attrs;
23
- }
24
- export declare const coreSection: NodeSpec;
25
- export {};