@manuscripts/transform 3.0.61 → 3.0.62

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.
@@ -1056,13 +1056,7 @@ class JATSExporter {
1056
1056
  }
1057
1057
  };
1058
1058
  this.buildContributors = (articleMeta) => {
1059
- const contributorNodes = this.getChildrenOfType(schema_1.schema.nodes.contributor);
1060
- const authorContributorNodes = contributorNodes
1061
- .filter((n) => n.attrs.role === 'author')
1062
- .sort(sortContributors);
1063
- const otherContributorsNodes = contributorNodes
1064
- .filter((n) => n.attrs.role !== 'author')
1065
- .sort(sortContributors);
1059
+ const contributorNodes = this.getChildrenOfType(schema_1.schema.nodes.contributor).sort(sortContributors);
1066
1060
  const affiliationLabels = new Map();
1067
1061
  const creatAffiliationLabel = (rid) => {
1068
1062
  let label = affiliationLabels.get(rid);
@@ -1079,11 +1073,11 @@ class JATSExporter {
1079
1073
  sup.textContent = String(content);
1080
1074
  return sup;
1081
1075
  };
1082
- if (authorContributorNodes.length) {
1076
+ if (contributorNodes.length) {
1083
1077
  const contribGroup = this.createElement('contrib-group');
1084
1078
  contribGroup.setAttribute('content-type', 'authors');
1085
1079
  articleMeta.appendChild(contribGroup);
1086
- authorContributorNodes.forEach((contributor) => {
1080
+ contributorNodes.forEach((contributor) => {
1087
1081
  try {
1088
1082
  this.validateContributor(contributor);
1089
1083
  }
@@ -1097,95 +1091,51 @@ class JATSExporter {
1097
1091
  if (contributor.attrs.isCorresponding) {
1098
1092
  contrib.setAttribute('corresp', 'yes');
1099
1093
  }
1094
+ if (contributor.attrs.role) {
1095
+ this.appendElement(contrib, 'role', contributor.attrs.role);
1096
+ }
1100
1097
  if (contributor.attrs.ORCIDIdentifier) {
1101
- const identifier = this.createElement('contrib-id');
1102
- identifier.setAttribute('contrib-id-type', 'orcid');
1103
- identifier.textContent = contributor.attrs.ORCIDIdentifier;
1104
- contrib.appendChild(identifier);
1098
+ this.appendElement(contrib, 'contrib-id', contributor.attrs.ORCIDIdentifier, { 'contrib-id-type': 'orcid' });
1105
1099
  }
1106
1100
  const name = this.buildContributorName(contributor);
1107
1101
  contrib.appendChild(name);
1108
1102
  if (contributor.attrs.email) {
1109
- const email = this.createElement('email');
1110
- email.textContent = contributor.attrs.email;
1111
- contrib.appendChild(email);
1103
+ this.appendElement(contrib, 'email', contributor.attrs.email);
1112
1104
  }
1113
1105
  if (contributor.attrs.affiliations) {
1114
1106
  contributor.attrs.affiliations.forEach((rid) => {
1115
- const xref = this.createElement('xref');
1116
- xref.setAttribute('ref-type', 'aff');
1117
- xref.setAttribute('rid', normalizeID(rid));
1107
+ const xref = this.appendElement(contrib, 'xref', '', {
1108
+ 'ref-type': 'aff',
1109
+ rid: normalizeID(rid),
1110
+ });
1118
1111
  xref.appendChild(creatAffiliationLabel(rid));
1119
1112
  contrib.appendChild(xref);
1120
1113
  });
1121
1114
  }
1122
1115
  if (contributor.attrs.footnote) {
1123
1116
  contributor.attrs.footnote.map((note) => {
1124
- const xref = this.createElement('xref');
1125
- xref.setAttribute('ref-type', 'fn');
1126
- xref.setAttribute('rid', normalizeID(note.noteID));
1117
+ const xref = this.appendElement(contrib, 'xref', '', {
1118
+ 'ref-type': 'fn',
1119
+ rid: normalizeID(note.noteID),
1120
+ });
1127
1121
  xref.appendChild(createFootNotesLabels(note.noteLabel));
1128
1122
  contrib.appendChild(xref);
1129
1123
  });
1130
1124
  }
1131
1125
  if (contributor.attrs.corresp) {
1132
1126
  contributor.attrs.corresp.map((corresp) => {
1133
- const xref = this.createElement('xref');
1134
- xref.setAttribute('ref-type', 'corresp');
1135
- xref.setAttribute('rid', normalizeID(corresp.correspID));
1127
+ const xref = this.appendElement(contrib, 'xref', '', {
1128
+ 'ref-type': 'corresp',
1129
+ rid: normalizeID(corresp.correspID),
1130
+ });
1136
1131
  xref.appendChild(createFootNotesLabels(corresp.correspLabel));
1137
1132
  contrib.appendChild(xref);
1138
1133
  });
1139
1134
  }
1140
1135
  contribGroup.appendChild(contrib);
1141
1136
  });
1142
- if (otherContributorsNodes.length) {
1143
- const contribGroup = this.createElement('contrib-group');
1144
- articleMeta.appendChild(contribGroup);
1145
- otherContributorsNodes.forEach((contributor) => {
1146
- try {
1147
- this.validateContributor(contributor);
1148
- }
1149
- catch (error) {
1150
- warn(error.message);
1151
- return;
1152
- }
1153
- const contrib = this.createElement('contrib');
1154
- contrib.setAttribute('id', normalizeID(contributor.attrs.id));
1155
- const name = this.buildContributorName(contributor);
1156
- contrib.appendChild(name);
1157
- if (contributor.attrs.email) {
1158
- const email = this.createElement('email');
1159
- email.textContent = contributor.attrs.email;
1160
- contrib.appendChild(email);
1161
- }
1162
- if (contributor.attrs.affiliations) {
1163
- contributor.attrs.affiliations.forEach((rid) => {
1164
- const xref = this.createElement('xref');
1165
- xref.setAttribute('ref-type', 'aff');
1166
- xref.setAttribute('rid', normalizeID(rid));
1167
- xref.appendChild(creatAffiliationLabel(rid));
1168
- contrib.appendChild(xref);
1169
- });
1170
- }
1171
- if (contributor.attrs.footnote) {
1172
- contributor.attrs.footnote.map((note) => {
1173
- const xref = this.createElement('xref');
1174
- xref.setAttribute('ref-type', 'fn');
1175
- xref.setAttribute('rid', normalizeID(note.noteID));
1176
- xref.appendChild(createFootNotesLabels(note.noteLabel));
1177
- contrib.appendChild(xref);
1178
- });
1179
- }
1180
- contribGroup.appendChild(contrib);
1181
- });
1182
- }
1183
1137
  const affiliationRIDs = [];
1184
- const sortedContributors = [
1185
- ...authorContributorNodes,
1186
- ...otherContributorsNodes,
1187
- ];
1188
- for (const contributor of sortedContributors) {
1138
+ for (const contributor of contributorNodes) {
1189
1139
  if (contributor.attrs.affiliations) {
1190
1140
  affiliationRIDs.push(...contributor.attrs.affiliations);
1191
1141
  }
@@ -1534,14 +1484,13 @@ class JATSExporter {
1534
1484
  this.buildContributorName = (contributor) => {
1535
1485
  const name = this.createElement('name');
1536
1486
  if (contributor.attrs.bibliographicName.family) {
1537
- const surname = this.createElement('surname');
1538
- surname.textContent = contributor.attrs.bibliographicName.family;
1539
- name.appendChild(surname);
1487
+ this.appendElement(name, 'surname', contributor.attrs.bibliographicName.family);
1540
1488
  }
1541
1489
  if (contributor.attrs.bibliographicName.given) {
1542
- const givenNames = this.createElement('given-names');
1543
- givenNames.textContent = contributor.attrs.bibliographicName.given;
1544
- name.appendChild(givenNames);
1490
+ this.appendElement(name, 'given-names', contributor.attrs.bibliographicName.given);
1491
+ }
1492
+ if (contributor.attrs.prefix) {
1493
+ this.appendElement(name, 'prefix', contributor.attrs.prefix);
1545
1494
  }
1546
1495
  return name;
1547
1496
  };
@@ -403,7 +403,7 @@ class JATSDOMParser {
403
403
  }
404
404
  return {
405
405
  id: element.getAttribute('id'),
406
- role: 'author',
406
+ role: (0, utils_1.getTrimmedTextContent)(element, 'role'),
407
407
  affiliations,
408
408
  corresp,
409
409
  footnote,
@@ -418,6 +418,7 @@ class JATSDOMParser {
418
418
  ORCIDIdentifier: (0, utils_1.getTrimmedTextContent)(element, 'contrib-id[contrib-id-type="orcid"]'),
419
419
  priority: this.parsePriority(element.getAttribute('priority')),
420
420
  email: (0, utils_1.getTrimmedTextContent)(element, 'email') || '',
421
+ prefix: (0, utils_1.getTrimmedTextContent)(element, 'prefix'),
421
422
  };
422
423
  },
423
424
  getContent: () => {
@@ -19,6 +19,7 @@ exports.contributor = {
19
19
  priority: { default: undefined },
20
20
  dataTracked: { default: null },
21
21
  contents: { default: '' },
22
+ prefix: { default: '' },
22
23
  },
23
24
  group: 'block',
24
25
  toDOM: (node) => {
@@ -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 = "3.0.61";
4
+ exports.VERSION = "3.0.62";
@@ -1048,13 +1048,7 @@ export class JATSExporter {
1048
1048
  }
1049
1049
  };
1050
1050
  this.buildContributors = (articleMeta) => {
1051
- const contributorNodes = this.getChildrenOfType(schema.nodes.contributor);
1052
- const authorContributorNodes = contributorNodes
1053
- .filter((n) => n.attrs.role === 'author')
1054
- .sort(sortContributors);
1055
- const otherContributorsNodes = contributorNodes
1056
- .filter((n) => n.attrs.role !== 'author')
1057
- .sort(sortContributors);
1051
+ const contributorNodes = this.getChildrenOfType(schema.nodes.contributor).sort(sortContributors);
1058
1052
  const affiliationLabels = new Map();
1059
1053
  const creatAffiliationLabel = (rid) => {
1060
1054
  let label = affiliationLabels.get(rid);
@@ -1071,11 +1065,11 @@ export class JATSExporter {
1071
1065
  sup.textContent = String(content);
1072
1066
  return sup;
1073
1067
  };
1074
- if (authorContributorNodes.length) {
1068
+ if (contributorNodes.length) {
1075
1069
  const contribGroup = this.createElement('contrib-group');
1076
1070
  contribGroup.setAttribute('content-type', 'authors');
1077
1071
  articleMeta.appendChild(contribGroup);
1078
- authorContributorNodes.forEach((contributor) => {
1072
+ contributorNodes.forEach((contributor) => {
1079
1073
  try {
1080
1074
  this.validateContributor(contributor);
1081
1075
  }
@@ -1089,95 +1083,51 @@ export class JATSExporter {
1089
1083
  if (contributor.attrs.isCorresponding) {
1090
1084
  contrib.setAttribute('corresp', 'yes');
1091
1085
  }
1086
+ if (contributor.attrs.role) {
1087
+ this.appendElement(contrib, 'role', contributor.attrs.role);
1088
+ }
1092
1089
  if (contributor.attrs.ORCIDIdentifier) {
1093
- const identifier = this.createElement('contrib-id');
1094
- identifier.setAttribute('contrib-id-type', 'orcid');
1095
- identifier.textContent = contributor.attrs.ORCIDIdentifier;
1096
- contrib.appendChild(identifier);
1090
+ this.appendElement(contrib, 'contrib-id', contributor.attrs.ORCIDIdentifier, { 'contrib-id-type': 'orcid' });
1097
1091
  }
1098
1092
  const name = this.buildContributorName(contributor);
1099
1093
  contrib.appendChild(name);
1100
1094
  if (contributor.attrs.email) {
1101
- const email = this.createElement('email');
1102
- email.textContent = contributor.attrs.email;
1103
- contrib.appendChild(email);
1095
+ this.appendElement(contrib, 'email', contributor.attrs.email);
1104
1096
  }
1105
1097
  if (contributor.attrs.affiliations) {
1106
1098
  contributor.attrs.affiliations.forEach((rid) => {
1107
- const xref = this.createElement('xref');
1108
- xref.setAttribute('ref-type', 'aff');
1109
- xref.setAttribute('rid', normalizeID(rid));
1099
+ const xref = this.appendElement(contrib, 'xref', '', {
1100
+ 'ref-type': 'aff',
1101
+ rid: normalizeID(rid),
1102
+ });
1110
1103
  xref.appendChild(creatAffiliationLabel(rid));
1111
1104
  contrib.appendChild(xref);
1112
1105
  });
1113
1106
  }
1114
1107
  if (contributor.attrs.footnote) {
1115
1108
  contributor.attrs.footnote.map((note) => {
1116
- const xref = this.createElement('xref');
1117
- xref.setAttribute('ref-type', 'fn');
1118
- xref.setAttribute('rid', normalizeID(note.noteID));
1109
+ const xref = this.appendElement(contrib, 'xref', '', {
1110
+ 'ref-type': 'fn',
1111
+ rid: normalizeID(note.noteID),
1112
+ });
1119
1113
  xref.appendChild(createFootNotesLabels(note.noteLabel));
1120
1114
  contrib.appendChild(xref);
1121
1115
  });
1122
1116
  }
1123
1117
  if (contributor.attrs.corresp) {
1124
1118
  contributor.attrs.corresp.map((corresp) => {
1125
- const xref = this.createElement('xref');
1126
- xref.setAttribute('ref-type', 'corresp');
1127
- xref.setAttribute('rid', normalizeID(corresp.correspID));
1119
+ const xref = this.appendElement(contrib, 'xref', '', {
1120
+ 'ref-type': 'corresp',
1121
+ rid: normalizeID(corresp.correspID),
1122
+ });
1128
1123
  xref.appendChild(createFootNotesLabels(corresp.correspLabel));
1129
1124
  contrib.appendChild(xref);
1130
1125
  });
1131
1126
  }
1132
1127
  contribGroup.appendChild(contrib);
1133
1128
  });
1134
- if (otherContributorsNodes.length) {
1135
- const contribGroup = this.createElement('contrib-group');
1136
- articleMeta.appendChild(contribGroup);
1137
- otherContributorsNodes.forEach((contributor) => {
1138
- try {
1139
- this.validateContributor(contributor);
1140
- }
1141
- catch (error) {
1142
- warn(error.message);
1143
- return;
1144
- }
1145
- const contrib = this.createElement('contrib');
1146
- contrib.setAttribute('id', normalizeID(contributor.attrs.id));
1147
- const name = this.buildContributorName(contributor);
1148
- contrib.appendChild(name);
1149
- if (contributor.attrs.email) {
1150
- const email = this.createElement('email');
1151
- email.textContent = contributor.attrs.email;
1152
- contrib.appendChild(email);
1153
- }
1154
- if (contributor.attrs.affiliations) {
1155
- contributor.attrs.affiliations.forEach((rid) => {
1156
- const xref = this.createElement('xref');
1157
- xref.setAttribute('ref-type', 'aff');
1158
- xref.setAttribute('rid', normalizeID(rid));
1159
- xref.appendChild(creatAffiliationLabel(rid));
1160
- contrib.appendChild(xref);
1161
- });
1162
- }
1163
- if (contributor.attrs.footnote) {
1164
- contributor.attrs.footnote.map((note) => {
1165
- const xref = this.createElement('xref');
1166
- xref.setAttribute('ref-type', 'fn');
1167
- xref.setAttribute('rid', normalizeID(note.noteID));
1168
- xref.appendChild(createFootNotesLabels(note.noteLabel));
1169
- contrib.appendChild(xref);
1170
- });
1171
- }
1172
- contribGroup.appendChild(contrib);
1173
- });
1174
- }
1175
1129
  const affiliationRIDs = [];
1176
- const sortedContributors = [
1177
- ...authorContributorNodes,
1178
- ...otherContributorsNodes,
1179
- ];
1180
- for (const contributor of sortedContributors) {
1130
+ for (const contributor of contributorNodes) {
1181
1131
  if (contributor.attrs.affiliations) {
1182
1132
  affiliationRIDs.push(...contributor.attrs.affiliations);
1183
1133
  }
@@ -1526,14 +1476,13 @@ export class JATSExporter {
1526
1476
  this.buildContributorName = (contributor) => {
1527
1477
  const name = this.createElement('name');
1528
1478
  if (contributor.attrs.bibliographicName.family) {
1529
- const surname = this.createElement('surname');
1530
- surname.textContent = contributor.attrs.bibliographicName.family;
1531
- name.appendChild(surname);
1479
+ this.appendElement(name, 'surname', contributor.attrs.bibliographicName.family);
1532
1480
  }
1533
1481
  if (contributor.attrs.bibliographicName.given) {
1534
- const givenNames = this.createElement('given-names');
1535
- givenNames.textContent = contributor.attrs.bibliographicName.given;
1536
- name.appendChild(givenNames);
1482
+ this.appendElement(name, 'given-names', contributor.attrs.bibliographicName.given);
1483
+ }
1484
+ if (contributor.attrs.prefix) {
1485
+ this.appendElement(name, 'prefix', contributor.attrs.prefix);
1537
1486
  }
1538
1487
  return name;
1539
1488
  };
@@ -400,7 +400,7 @@ export class JATSDOMParser {
400
400
  }
401
401
  return {
402
402
  id: element.getAttribute('id'),
403
- role: 'author',
403
+ role: getTrimmedTextContent(element, 'role'),
404
404
  affiliations,
405
405
  corresp,
406
406
  footnote,
@@ -415,6 +415,7 @@ export class JATSDOMParser {
415
415
  ORCIDIdentifier: getTrimmedTextContent(element, 'contrib-id[contrib-id-type="orcid"]'),
416
416
  priority: this.parsePriority(element.getAttribute('priority')),
417
417
  email: getTrimmedTextContent(element, 'email') || '',
418
+ prefix: getTrimmedTextContent(element, 'prefix'),
418
419
  };
419
420
  },
420
421
  getContent: () => {
@@ -16,6 +16,7 @@ export const contributor = {
16
16
  priority: { default: undefined },
17
17
  dataTracked: { default: null },
18
18
  contents: { default: '' },
19
+ prefix: { default: '' },
19
20
  },
20
21
  group: 'block',
21
22
  toDOM: (node) => {
@@ -1 +1 @@
1
- export const VERSION = "3.0.61";
1
+ export const VERSION = "3.0.62";
@@ -23,6 +23,7 @@ interface Attrs {
23
23
  priority: number;
24
24
  isJointContributor: boolean;
25
25
  footnote: ContributorFootnote[];
26
+ prefix: string;
26
27
  }
27
28
  export interface ContributorNode extends ManuscriptNode {
28
29
  attrs: Attrs;
@@ -1 +1 @@
1
- export declare const VERSION = "3.0.61";
1
+ export declare const VERSION = "3.0.62";
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": "3.0.61",
4
+ "version": "3.0.62",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-transform",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",