@manuscripts/transform 4.3.35 → 4.3.37

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.
package/README.md CHANGED
@@ -24,7 +24,7 @@ It provides a way to import/export [Manuscript JSON Schema](https://gitlab.com/m
24
24
 
25
25
  ### Manuscript JSON Schema to ProseMirror Model
26
26
 
27
- ```typescript
27
+ ```typescript
28
28
  import { Decoder, ContainedModel } from '@manuscripts/manuscript-transform'
29
29
 
30
30
 
@@ -89,7 +89,11 @@ exports.sectionCategories = [
89
89
  'competing interests',
90
90
  ],
91
91
  label: 'Conflict of Interest',
92
- titles: ['Conflict of Interest Statement', 'COI Statement', 'Competing Interests'],
92
+ titles: [
93
+ 'Conflict of Interest Statement',
94
+ 'COI Statement',
95
+ 'Competing Interests',
96
+ ],
93
97
  group: 'backmatter',
94
98
  isUnique: true,
95
99
  },
@@ -1020,6 +1020,12 @@ class JATSExporter {
1020
1020
  }
1021
1021
  const $name = this.buildContributorName(contributor);
1022
1022
  $contrib.appendChild($name);
1023
+ if (contributor.attrs.suffix) {
1024
+ this.appendElement($name, 'suffix', contributor.attrs.suffix);
1025
+ }
1026
+ contributor.attrs.degrees?.forEach((degree) => {
1027
+ this.appendElement($contrib, 'degrees', degree);
1028
+ });
1023
1029
  if (contributor.attrs.email) {
1024
1030
  this.appendElement($contrib, 'email', contributor.attrs.email);
1025
1031
  }
@@ -1051,7 +1057,7 @@ class JATSExporter {
1051
1057
  }
1052
1058
  this.appendElement($contrib, 'role', credit.vocabTerm, {
1053
1059
  'vocab-identifier': 'http://credit.niso.org/',
1054
- 'vocab': 'CRediT',
1060
+ vocab: 'CRediT',
1055
1061
  'vocab-term': credit.vocabTerm,
1056
1062
  'vocab-term-identifier': url,
1057
1063
  });
@@ -406,6 +406,8 @@ class JATSDOMParser {
406
406
  given: (0, utils_1.getTrimmedTextContent)(element, 'given-names'),
407
407
  family: this.getSurname(element),
408
408
  prefix: (0, utils_1.getTrimmedTextContent)(element, 'prefix'),
409
+ suffix: (0, utils_1.getTrimmedTextContent)(element, 'suffix'),
410
+ degrees: Array.from(element.querySelectorAll('degrees')).map((degree) => (0, utils_1.getTrimmedTextContent)(degree)) || [],
409
411
  ORCID: (0, utils_1.getTrimmedTextContent)(element, 'contrib-id[contrib-id-type="orcid"]'),
410
412
  creditRoles: (0, utils_1.getCreditRole)(element),
411
413
  priority: this.parsePriority(element.getAttribute('priority')),
@@ -115,10 +115,10 @@ const moveAffiliations = (front, createElement) => {
115
115
  }
116
116
  };
117
117
  exports.moveAffiliations = moveAffiliations;
118
- const moveAbstracts = (front, group, createElement) => {
118
+ const moveAbstracts = (front, group, createElement, sectionCategories) => {
119
119
  const abstracts = front.querySelectorAll('article-meta > abstract, article-meta > trans-abstract');
120
120
  abstracts.forEach((abstract) => {
121
- const sec = createAbstractSection(abstract, createElement);
121
+ const sec = createAbstractSection(abstract, createElement, sectionCategories);
122
122
  removeNodeFromParent(abstract);
123
123
  group.appendChild(sec);
124
124
  });
@@ -148,9 +148,9 @@ const createBody = (doc, body, createElement) => {
148
148
  body.append(group);
149
149
  };
150
150
  exports.createBody = createBody;
151
- const createAbstracts = (front, body, createElement) => {
151
+ const createAbstracts = (front, body, createElement, sectionCategories) => {
152
152
  const group = createSectionGroup('abstracts', createElement);
153
- (0, exports.moveAbstracts)(front, group, createElement);
153
+ (0, exports.moveAbstracts)(front, group, createElement, sectionCategories);
154
154
  body.insertBefore(group, body.lastElementChild);
155
155
  };
156
156
  exports.createAbstracts = createAbstracts;
@@ -221,7 +221,7 @@ const moveCaptionsToEnd = (body) => {
221
221
  }
222
222
  };
223
223
  exports.moveCaptionsToEnd = moveCaptionsToEnd;
224
- const createAbstractSection = (abstract, createElement) => {
224
+ const createAbstractSection = (abstract, createElement, sectionCategories) => {
225
225
  const abstractType = abstract.getAttribute('abstract-type');
226
226
  const sectionType = abstractType ? `abstract-${abstractType}` : 'abstract';
227
227
  let section = createElement('sec');
@@ -235,9 +235,15 @@ const createAbstractSection = (abstract, createElement) => {
235
235
  section.setAttribute('sec-type', sectionType);
236
236
  if (!abstract.querySelector(':scope > title')) {
237
237
  const title = createElement('title');
238
- title.textContent = abstractType
239
- ? `${capitalizeFirstLetter(abstractType.split('-').join(' '))} Abstract`
240
- : 'Abstract';
238
+ const category = sectionCategories?.find((c) => c.id === sectionType || c.synonyms.includes(sectionType));
239
+ if (category?.titles[0]) {
240
+ title.textContent = category.titles[0];
241
+ }
242
+ else {
243
+ title.textContent = abstractType
244
+ ? `${capitalizeFirstLetter(abstractType.split('-').join(' '))} Abstract`
245
+ : 'Abstract';
246
+ }
241
247
  section.appendChild(title);
242
248
  }
243
249
  while (abstract.firstChild) {
@@ -46,7 +46,7 @@ const processJATS = (doc, sectionCategories) => {
46
46
  }
47
47
  (0, jats_transformations_1.moveCaptionsToEnd)(body);
48
48
  (0, jats_transformations_1.createBody)(doc, body, createElement);
49
- (0, jats_transformations_1.createAbstracts)(front, body, createElement);
49
+ (0, jats_transformations_1.createAbstracts)(front, body, createElement, sectionCategories);
50
50
  (0, jats_transformations_1.createBackmatter)(doc, body, sectionCategories, createElement);
51
51
  (0, jats_transformations_1.createSupplementaryMaterialsSection)(doc, body, createElement);
52
52
  (0, jats_transformations_1.createKeywordsSection)(doc, body, createElement);
@@ -14,6 +14,7 @@ exports.contributor = {
14
14
  family: { default: undefined },
15
15
  prefix: { default: undefined },
16
16
  suffix: { default: undefined },
17
+ degrees: { default: [] },
17
18
  email: { default: undefined },
18
19
  ORCID: { default: undefined },
19
20
  isCorresponding: { default: false },
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = "4.3.35";
4
+ exports.VERSION = "4.3.37";
@@ -86,7 +86,11 @@ export const sectionCategories = [
86
86
  'competing interests',
87
87
  ],
88
88
  label: 'Conflict of Interest',
89
- titles: ['Conflict of Interest Statement', 'COI Statement', 'Competing Interests'],
89
+ titles: [
90
+ 'Conflict of Interest Statement',
91
+ 'COI Statement',
92
+ 'Competing Interests',
93
+ ],
90
94
  group: 'backmatter',
91
95
  isUnique: true,
92
96
  },
@@ -980,6 +980,12 @@ export class JATSExporter {
980
980
  }
981
981
  const $name = this.buildContributorName(contributor);
982
982
  $contrib.appendChild($name);
983
+ if (contributor.attrs.suffix) {
984
+ this.appendElement($name, 'suffix', contributor.attrs.suffix);
985
+ }
986
+ contributor.attrs.degrees?.forEach((degree) => {
987
+ this.appendElement($contrib, 'degrees', degree);
988
+ });
983
989
  if (contributor.attrs.email) {
984
990
  this.appendElement($contrib, 'email', contributor.attrs.email);
985
991
  }
@@ -1011,7 +1017,7 @@ export class JATSExporter {
1011
1017
  }
1012
1018
  this.appendElement($contrib, 'role', credit.vocabTerm, {
1013
1019
  'vocab-identifier': 'http://credit.niso.org/',
1014
- 'vocab': 'CRediT',
1020
+ vocab: 'CRediT',
1015
1021
  'vocab-term': credit.vocabTerm,
1016
1022
  'vocab-term-identifier': url,
1017
1023
  });
@@ -403,6 +403,8 @@ export class JATSDOMParser {
403
403
  given: getTrimmedTextContent(element, 'given-names'),
404
404
  family: this.getSurname(element),
405
405
  prefix: getTrimmedTextContent(element, 'prefix'),
406
+ suffix: getTrimmedTextContent(element, 'suffix'),
407
+ degrees: Array.from(element.querySelectorAll('degrees')).map((degree) => getTrimmedTextContent(degree)) || [],
406
408
  ORCID: getTrimmedTextContent(element, 'contrib-id[contrib-id-type="orcid"]'),
407
409
  creditRoles: getCreditRole(element),
408
410
  priority: this.parsePriority(element.getAttribute('priority')),
@@ -105,10 +105,10 @@ export const moveAffiliations = (front, createElement) => {
105
105
  front.parentNode?.insertBefore(affiliations, front);
106
106
  }
107
107
  };
108
- export const moveAbstracts = (front, group, createElement) => {
108
+ export const moveAbstracts = (front, group, createElement, sectionCategories) => {
109
109
  const abstracts = front.querySelectorAll('article-meta > abstract, article-meta > trans-abstract');
110
110
  abstracts.forEach((abstract) => {
111
- const sec = createAbstractSection(abstract, createElement);
111
+ const sec = createAbstractSection(abstract, createElement, sectionCategories);
112
112
  removeNodeFromParent(abstract);
113
113
  group.appendChild(sec);
114
114
  });
@@ -135,9 +135,9 @@ export const createBody = (doc, body, createElement) => {
135
135
  });
136
136
  body.append(group);
137
137
  };
138
- export const createAbstracts = (front, body, createElement) => {
138
+ export const createAbstracts = (front, body, createElement, sectionCategories) => {
139
139
  const group = createSectionGroup('abstracts', createElement);
140
- moveAbstracts(front, group, createElement);
140
+ moveAbstracts(front, group, createElement, sectionCategories);
141
141
  body.insertBefore(group, body.lastElementChild);
142
142
  };
143
143
  export const createBackmatter = (doc, body, sectionCategories, createElement) => {
@@ -205,7 +205,7 @@ export const moveCaptionsToEnd = (body) => {
205
205
  }
206
206
  }
207
207
  };
208
- const createAbstractSection = (abstract, createElement) => {
208
+ const createAbstractSection = (abstract, createElement, sectionCategories) => {
209
209
  const abstractType = abstract.getAttribute('abstract-type');
210
210
  const sectionType = abstractType ? `abstract-${abstractType}` : 'abstract';
211
211
  let section = createElement('sec');
@@ -219,9 +219,15 @@ const createAbstractSection = (abstract, createElement) => {
219
219
  section.setAttribute('sec-type', sectionType);
220
220
  if (!abstract.querySelector(':scope > title')) {
221
221
  const title = createElement('title');
222
- title.textContent = abstractType
223
- ? `${capitalizeFirstLetter(abstractType.split('-').join(' '))} Abstract`
224
- : 'Abstract';
222
+ const category = sectionCategories?.find((c) => c.id === sectionType || c.synonyms.includes(sectionType));
223
+ if (category?.titles[0]) {
224
+ title.textContent = category.titles[0];
225
+ }
226
+ else {
227
+ title.textContent = abstractType
228
+ ? `${capitalizeFirstLetter(abstractType.split('-').join(' '))} Abstract`
229
+ : 'Abstract';
230
+ }
225
231
  section.appendChild(title);
226
232
  }
227
233
  while (abstract.firstChild) {
@@ -43,7 +43,7 @@ const processJATS = (doc, sectionCategories) => {
43
43
  }
44
44
  moveCaptionsToEnd(body);
45
45
  createBody(doc, body, createElement);
46
- createAbstracts(front, body, createElement);
46
+ createAbstracts(front, body, createElement, sectionCategories);
47
47
  createBackmatter(doc, body, sectionCategories, createElement);
48
48
  createSupplementaryMaterialsSection(doc, body, createElement);
49
49
  createKeywordsSection(doc, body, createElement);
@@ -11,6 +11,7 @@ export const contributor = {
11
11
  family: { default: undefined },
12
12
  prefix: { default: undefined },
13
13
  suffix: { default: undefined },
14
+ degrees: { default: [] },
14
15
  email: { default: undefined },
15
16
  ORCID: { default: undefined },
16
17
  isCorresponding: { default: false },
@@ -1 +1 @@
1
- export const VERSION = "4.3.35";
1
+ export const VERSION = "4.3.37";
@@ -22,10 +22,10 @@ export declare const moveAuthorNotes: (front: Element, createElement: CreateElem
22
22
  export declare const moveAwards: (front: Element) => void;
23
23
  export declare const moveContributors: (front: Element, createElement: CreateElement) => void;
24
24
  export declare const moveAffiliations: (front: Element, createElement: CreateElement) => void;
25
- export declare const moveAbstracts: (front: Element, group: Element, createElement: CreateElement) => void;
25
+ export declare const moveAbstracts: (front: Element, group: Element, createElement: CreateElement, sectionCategories?: SectionCategory[]) => void;
26
26
  export declare const moveHeroImage: (doc: Document) => void;
27
27
  export declare const createBody: (doc: Document, body: Element, createElement: CreateElement) => void;
28
- export declare const createAbstracts: (front: Element, body: Element, createElement: CreateElement) => void;
28
+ export declare const createAbstracts: (front: Element, body: Element, createElement: CreateElement, sectionCategories?: SectionCategory[]) => void;
29
29
  export declare const createBackmatter: (doc: Document, body: Element, sectionCategories: SectionCategory[], createElement: CreateElement) => void;
30
30
  export declare const moveCaptionsToEnd: (body: Element) => void;
31
31
  export declare const createKeywordsSection: (document: Document, body: Element, createElement: CreateElement) => void;
@@ -16,6 +16,7 @@ export interface ContributorAttrs {
16
16
  suffix?: string;
17
17
  email?: string;
18
18
  ORCID?: string;
19
+ degrees: string[];
19
20
  isCorresponding: boolean;
20
21
  priority: number;
21
22
  isJointContributor: boolean;
@@ -1 +1 @@
1
- export declare const VERSION = "4.3.35";
1
+ export declare const VERSION = "4.3.37";
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": "4.3.35",
4
+ "version": "4.3.37",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-transform",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",