@manuscripts/transform 4.2.17 → 4.2.19

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.
@@ -1158,6 +1158,23 @@ class JATSExporter {
1158
1158
  }
1159
1159
  }
1160
1160
  };
1161
+ this.buildContributorName = (contributor) => {
1162
+ const { given, family } = contributor.attrs.bibliographicName;
1163
+ if (Boolean(given) !== Boolean(family)) {
1164
+ return this.createElement('string-name', given || family);
1165
+ }
1166
+ const name = this.createElement('name');
1167
+ if (contributor.attrs.bibliographicName.family) {
1168
+ this.appendElement(name, 'surname', contributor.attrs.bibliographicName.family);
1169
+ }
1170
+ if (contributor.attrs.bibliographicName.given) {
1171
+ this.appendElement(name, 'given-names', contributor.attrs.bibliographicName.given);
1172
+ }
1173
+ if (contributor.attrs.prefix) {
1174
+ this.appendElement(name, 'prefix', contributor.attrs.prefix);
1175
+ }
1176
+ return name;
1177
+ };
1161
1178
  this.createAuthorNotesElement = () => {
1162
1179
  const authorNotesEl = this.createElement('author-notes');
1163
1180
  const authorNotesNode = this.getFirstChildOfType(schema_1.schema.nodes.author_notes);
@@ -1426,19 +1443,6 @@ class JATSExporter {
1426
1443
  article.appendChild(floatsGroup);
1427
1444
  }
1428
1445
  };
1429
- this.buildContributorName = (contributor) => {
1430
- const name = this.createElement('name');
1431
- if (contributor.attrs.bibliographicName.family) {
1432
- this.appendElement(name, 'surname', contributor.attrs.bibliographicName.family);
1433
- }
1434
- if (contributor.attrs.bibliographicName.given) {
1435
- this.appendElement(name, 'given-names', contributor.attrs.bibliographicName.given);
1436
- }
1437
- if (contributor.attrs.prefix) {
1438
- this.appendElement(name, 'prefix', contributor.attrs.prefix);
1439
- }
1440
- return name;
1441
- };
1442
1446
  }
1443
1447
  getFirstChildOfType(type, node) {
1444
1448
  return this.getChildrenOfType(type, node)[0];
@@ -131,6 +131,16 @@ class JATSDOMParser {
131
131
  this.getAddressLine = (element, index) => {
132
132
  return ((0, utils_1.getTrimmedTextContent)(element, `addr-line:nth-of-type(${index})`) || '');
133
133
  };
134
+ this.getSurname = (element) => {
135
+ const surname = (0, utils_1.getTrimmedTextContent)(element, 'surname');
136
+ if (surname) {
137
+ return surname;
138
+ }
139
+ const stringName = element.querySelector('string-name');
140
+ if (stringName && !stringName.querySelector('given-names')) {
141
+ return (0, utils_1.getTrimmedTextContent)(element, 'string-name');
142
+ }
143
+ };
134
144
  this.getRefType = (element) => {
135
145
  const citation = element.querySelector('element-citation, mixed-citation');
136
146
  const type = citation?.getAttribute('publication-type');
@@ -409,8 +419,8 @@ class JATSDOMParser {
409
419
  ? element.getAttribute('corresp') === 'yes'
410
420
  : undefined,
411
421
  bibliographicName: {
412
- given: (0, utils_1.getTrimmedTextContent)(element, 'name > given-names'),
413
- family: (0, utils_1.getTrimmedTextContent)(element, 'name > surname'),
422
+ given: (0, utils_1.getTrimmedTextContent)(element, 'given-names'),
423
+ family: this.getSurname(element),
414
424
  ObjectType: json_schema_1.ObjectTypes.BibliographicName,
415
425
  },
416
426
  ORCIDIdentifier: (0, utils_1.getTrimmedTextContent)(element, 'contrib-id[contrib-id-type="orcid"]'),
@@ -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.2.17";
4
+ exports.VERSION = "4.2.19";
@@ -1118,6 +1118,23 @@ export class JATSExporter {
1118
1118
  }
1119
1119
  }
1120
1120
  };
1121
+ this.buildContributorName = (contributor) => {
1122
+ const { given, family } = contributor.attrs.bibliographicName;
1123
+ if (Boolean(given) !== Boolean(family)) {
1124
+ return this.createElement('string-name', given || family);
1125
+ }
1126
+ const name = this.createElement('name');
1127
+ if (contributor.attrs.bibliographicName.family) {
1128
+ this.appendElement(name, 'surname', contributor.attrs.bibliographicName.family);
1129
+ }
1130
+ if (contributor.attrs.bibliographicName.given) {
1131
+ this.appendElement(name, 'given-names', contributor.attrs.bibliographicName.given);
1132
+ }
1133
+ if (contributor.attrs.prefix) {
1134
+ this.appendElement(name, 'prefix', contributor.attrs.prefix);
1135
+ }
1136
+ return name;
1137
+ };
1121
1138
  this.createAuthorNotesElement = () => {
1122
1139
  const authorNotesEl = this.createElement('author-notes');
1123
1140
  const authorNotesNode = this.getFirstChildOfType(schema.nodes.author_notes);
@@ -1386,19 +1403,6 @@ export class JATSExporter {
1386
1403
  article.appendChild(floatsGroup);
1387
1404
  }
1388
1405
  };
1389
- this.buildContributorName = (contributor) => {
1390
- const name = this.createElement('name');
1391
- if (contributor.attrs.bibliographicName.family) {
1392
- this.appendElement(name, 'surname', contributor.attrs.bibliographicName.family);
1393
- }
1394
- if (contributor.attrs.bibliographicName.given) {
1395
- this.appendElement(name, 'given-names', contributor.attrs.bibliographicName.given);
1396
- }
1397
- if (contributor.attrs.prefix) {
1398
- this.appendElement(name, 'prefix', contributor.attrs.prefix);
1399
- }
1400
- return name;
1401
- };
1402
1406
  }
1403
1407
  getFirstChildOfType(type, node) {
1404
1408
  return this.getChildrenOfType(type, node)[0];
@@ -128,6 +128,16 @@ export class JATSDOMParser {
128
128
  this.getAddressLine = (element, index) => {
129
129
  return (getTrimmedTextContent(element, `addr-line:nth-of-type(${index})`) || '');
130
130
  };
131
+ this.getSurname = (element) => {
132
+ const surname = getTrimmedTextContent(element, 'surname');
133
+ if (surname) {
134
+ return surname;
135
+ }
136
+ const stringName = element.querySelector('string-name');
137
+ if (stringName && !stringName.querySelector('given-names')) {
138
+ return getTrimmedTextContent(element, 'string-name');
139
+ }
140
+ };
131
141
  this.getRefType = (element) => {
132
142
  const citation = element.querySelector('element-citation, mixed-citation');
133
143
  const type = citation?.getAttribute('publication-type');
@@ -406,8 +416,8 @@ export class JATSDOMParser {
406
416
  ? element.getAttribute('corresp') === 'yes'
407
417
  : undefined,
408
418
  bibliographicName: {
409
- given: getTrimmedTextContent(element, 'name > given-names'),
410
- family: getTrimmedTextContent(element, 'name > surname'),
419
+ given: getTrimmedTextContent(element, 'given-names'),
420
+ family: this.getSurname(element),
411
421
  ObjectType: ObjectTypes.BibliographicName,
412
422
  },
413
423
  ORCIDIdentifier: getTrimmedTextContent(element, 'contrib-id[contrib-id-type="orcid"]'),
@@ -1 +1 @@
1
- export const VERSION = "4.2.17";
1
+ export const VERSION = "4.2.19";
@@ -61,6 +61,7 @@ export declare class JATSExporter {
61
61
  protected serializeNode: (node: ManuscriptNode) => Node;
62
62
  private validateContributor;
63
63
  private buildContributors;
64
+ private buildContributorName;
64
65
  private createAuthorNotesElement;
65
66
  private appendModelsToAuthorNotes;
66
67
  private appendCorrespondingToElement;
@@ -84,7 +85,6 @@ export declare class JATSExporter {
84
85
  private moveSectionsToBack;
85
86
  sectionToFootnote: (section: Element, fnType: string) => HTMLElement;
86
87
  private moveFloatsGroup;
87
- private buildContributorName;
88
88
  private moveCoiStatementToAuthorNotes;
89
89
  private updateFootnoteTypes;
90
90
  private fillEmptyElements;
@@ -30,6 +30,7 @@ export declare class JATSDOMParser {
30
30
  private getFigAttrs;
31
31
  private getInstitutionDetails;
32
32
  private getAddressLine;
33
+ private getSurname;
33
34
  private getRefType;
34
35
  private getNameContent;
35
36
  private getDateContent;
@@ -1 +1 @@
1
- export declare const VERSION = "4.2.17";
1
+ export declare const VERSION = "4.2.19";
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.2.17",
4
+ "version": "4.2.19",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-transform",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",