@manuscripts/transform 3.0.8 → 3.0.9

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.
@@ -106,21 +106,20 @@ const parseDates = (historyNode) => {
106
106
  return history;
107
107
  };
108
108
  const getEmail = (element) => {
109
- var _a, _b, _c;
109
+ var _a, _b;
110
110
  const email = element.querySelector('email');
111
111
  if (email) {
112
112
  return {
113
113
  href: (_a = email.getAttributeNS(XLINK_NAMESPACE, 'href')) !== null && _a !== void 0 ? _a : '',
114
- text: (_c = (_b = email.textContent) === null || _b === void 0 ? void 0 : _b.trim()) !== null && _c !== void 0 ? _c : '',
114
+ text: (_b = (0, utils_1.getTrimmedTextContent)(email)) !== null && _b !== void 0 ? _b : '',
115
115
  };
116
116
  }
117
117
  };
118
118
  const getInstitutionDetails = (element) => {
119
- var _a;
120
119
  let department = '';
121
120
  let institution = '';
122
121
  for (const node of element.querySelectorAll('institution')) {
123
- const content = (_a = node.textContent) === null || _a === void 0 ? void 0 : _a.trim();
122
+ const content = (0, utils_1.getTrimmedTextContent)(node);
124
123
  if (!content) {
125
124
  continue;
126
125
  }
@@ -167,10 +166,10 @@ const parseRef = (element) => {
167
166
  const mixedCitation = element.querySelector('mixed-citation');
168
167
  if (authorNodes.length <= 0) {
169
168
  mixedCitation === null || mixedCitation === void 0 ? void 0 : mixedCitation.childNodes.forEach((item) => {
170
- var _a, _b, _c;
169
+ var _a, _b;
171
170
  if (item.nodeType === Node.TEXT_NODE &&
172
171
  ((_a = item.textContent) === null || _a === void 0 ? void 0 : _a.match(/[A-Za-z]+/g))) {
173
- attrs.literal = (_c = (_b = mixedCitation.textContent) === null || _b === void 0 ? void 0 : _b.trim()) !== null && _c !== void 0 ? _c : '';
172
+ attrs.literal = (_b = (0, utils_1.getTrimmedTextContent)(mixedCitation)) !== null && _b !== void 0 ? _b : '';
174
173
  return attrs;
175
174
  }
176
175
  });
@@ -208,7 +207,6 @@ const parseRef = (element) => {
208
207
  }
209
208
  const authors = [];
210
209
  authorNodes.forEach((authorNode) => {
211
- var _a;
212
210
  const name = (0, json_schema_1.buildBibliographicName)({});
213
211
  const given = (0, utils_1.getTrimmedTextContent)(authorNode, 'given-names');
214
212
  if (given) {
@@ -219,7 +217,7 @@ const parseRef = (element) => {
219
217
  name.family = family;
220
218
  }
221
219
  if (authorNode.nodeName === 'collab') {
222
- name.literal = (_a = authorNode.textContent) === null || _a === void 0 ? void 0 : _a.trim();
220
+ name.literal = (0, utils_1.getTrimmedTextContent)(authorNode);
223
221
  }
224
222
  authors.push(name);
225
223
  });
@@ -279,7 +277,7 @@ const nodes = [
279
277
  const doi = element.querySelector('front > article-meta > article-id[pub-id-type="doi"]');
280
278
  const history = element.querySelector('history');
281
279
  const dates = parseDates(history);
282
- return Object.assign({ doi: doi === null || doi === void 0 ? void 0 : doi.textContent, articleType: (_a = element.getAttribute('article-type')) !== null && _a !== void 0 ? _a : '', primaryLanguageCode: (_b = element.getAttribute('lang')) !== null && _b !== void 0 ? _b : '' }, dates);
280
+ return Object.assign({ doi: (0, utils_1.getTrimmedTextContent)(doi), articleType: (_a = element.getAttribute('article-type')) !== null && _a !== void 0 ? _a : '', primaryLanguageCode: (_b = element.getAttribute('lang')) !== null && _b !== void 0 ? _b : '' }, dates);
283
281
  },
284
282
  },
285
283
  {
@@ -311,7 +309,7 @@ const nodes = [
311
309
  return {
312
310
  id: element.getAttribute('id'),
313
311
  target: element.getAttribute('target-id'),
314
- contents: element.textContent,
312
+ contents: (0, utils_1.getTrimmedTextContent)(element),
315
313
  contributions: [(0, json_schema_1.buildContribution)(jats_comments_1.DEFAULT_PROFILE_ID)],
316
314
  };
317
315
  },
@@ -334,15 +332,14 @@ const nodes = [
334
332
  tag: 'award-group',
335
333
  node: 'award',
336
334
  getAttrs: (node) => {
337
- var _a, _b;
338
335
  const element = node;
339
336
  return {
340
337
  id: element.getAttribute('id'),
341
- recipient: (_a = element.querySelector('principal-award-recipient')) === null || _a === void 0 ? void 0 : _a.textContent,
338
+ recipient: (0, utils_1.getTrimmedTextContent)(element, 'principal-award-recipient'),
342
339
  code: Array.from(element.querySelectorAll('award-id'))
343
- .map((awardID) => awardID.textContent)
340
+ .map((awardID) => (0, utils_1.getTrimmedTextContent)(awardID))
344
341
  .reduce((acc, text) => (acc ? `${acc};${text}` : text), ''),
345
- source: (_b = element.querySelector('funding-source')) === null || _b === void 0 ? void 0 : _b.textContent,
342
+ source: (0, utils_1.getTrimmedTextContent)(element, 'funding-source'),
346
343
  };
347
344
  },
348
345
  },
@@ -362,7 +359,6 @@ const nodes = [
362
359
  tag: 'corresp',
363
360
  node: 'corresp',
364
361
  getAttrs: (node) => {
365
- var _a;
366
362
  const element = node;
367
363
  const label = element.querySelector('label');
368
364
  if (label) {
@@ -370,20 +366,18 @@ const nodes = [
370
366
  }
371
367
  return {
372
368
  id: element.getAttribute('id'),
373
- label: (_a = label === null || label === void 0 ? void 0 : label.textContent) === null || _a === void 0 ? void 0 : _a.trim(),
369
+ label: (0, utils_1.getTrimmedTextContent)(label),
374
370
  };
375
371
  },
376
372
  getContent: (node) => {
377
- var _a;
378
373
  const element = node;
379
- return prosemirror_model_1.Fragment.from(schema_1.schema.text(((_a = element.textContent) === null || _a === void 0 ? void 0 : _a.trim()) || ''));
374
+ return prosemirror_model_1.Fragment.from(schema_1.schema.text((0, utils_1.getTrimmedTextContent)(element) || ''));
380
375
  },
381
376
  },
382
377
  {
383
378
  tag: 'contrib[contrib-type="author"]',
384
379
  node: 'contributor',
385
380
  getAttrs: (node) => {
386
- var _a, _b;
387
381
  const element = node;
388
382
  const footnote = [];
389
383
  const affiliations = [];
@@ -399,13 +393,13 @@ const nodes = [
399
393
  case 'fn':
400
394
  footnote.push({
401
395
  noteID: rid,
402
- noteLabel: ((_a = xref.textContent) === null || _a === void 0 ? void 0 : _a.trim()) || '',
396
+ noteLabel: (0, utils_1.getTrimmedTextContent)(xref) || '',
403
397
  });
404
398
  break;
405
399
  case 'corresp':
406
400
  corresp.push({
407
401
  correspID: rid,
408
- correspLabel: ((_b = xref.textContent) === null || _b === void 0 ? void 0 : _b.trim()) || '',
402
+ correspLabel: (0, utils_1.getTrimmedTextContent)(xref) || '',
409
403
  });
410
404
  break;
411
405
  case 'aff':
@@ -528,12 +522,12 @@ const nodes = [
528
522
  node: 'listing',
529
523
  context: 'listing_element/',
530
524
  getAttrs: (node) => {
531
- var _a, _b, _c;
525
+ var _a;
532
526
  const element = node;
533
527
  return {
534
528
  id: element.getAttribute('id'),
535
529
  language: (_a = element.getAttribute('language')) !== null && _a !== void 0 ? _a : '',
536
- contents: (_c = (_b = element.textContent) === null || _b === void 0 ? void 0 : _b.trim()) !== null && _c !== void 0 ? _c : '',
530
+ contents: (0, utils_1.getTrimmedTextContent)(element),
537
531
  };
538
532
  },
539
533
  },
@@ -549,11 +543,11 @@ const nodes = [
549
543
  tag: 'disp-formula',
550
544
  node: 'equation_element',
551
545
  getAttrs: (node) => {
552
- var _a, _b;
546
+ var _a;
553
547
  const element = node;
554
548
  return {
555
549
  id: element.getAttribute('id'),
556
- label: (_b = (_a = element.querySelector('label')) === null || _a === void 0 ? void 0 : _a.textContent) !== null && _b !== void 0 ? _b : '',
550
+ label: (_a = (0, utils_1.getTrimmedTextContent)(element, 'label')) !== null && _a !== void 0 ? _a : '',
557
551
  };
558
552
  },
559
553
  getContent: (node, schema) => {
@@ -646,7 +640,7 @@ const nodes = [
646
640
  tag: 'fig',
647
641
  node: 'figure_element',
648
642
  getAttrs: (node) => {
649
- var _a, _b, _c, _d;
643
+ var _a, _b;
650
644
  const element = node;
651
645
  const labelNode = element.querySelector('label');
652
646
  if (labelNode) {
@@ -656,12 +650,12 @@ const nodes = [
656
650
  const position = element.getAttribute('position');
657
651
  const attribution = attrib
658
652
  ? {
659
- literal: (_b = (_a = attrib.textContent) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : '',
653
+ literal: (_a = (0, utils_1.getTrimmedTextContent)(attrib)) !== null && _a !== void 0 ? _a : '',
660
654
  }
661
655
  : undefined;
662
656
  return {
663
657
  id: element.getAttribute('id'),
664
- label: (_d = (_c = labelNode === null || labelNode === void 0 ? void 0 : labelNode.textContent) === null || _c === void 0 ? void 0 : _c.trim()) !== null && _d !== void 0 ? _d : '',
658
+ label: (_b = (0, utils_1.getTrimmedTextContent)(labelNode)) !== null && _b !== void 0 ? _b : '',
665
659
  attribution: attribution,
666
660
  position,
667
661
  };
@@ -779,14 +773,13 @@ const nodes = [
779
773
  tag: 'supplementary-material',
780
774
  node: 'supplement',
781
775
  getAttrs: (node) => {
782
- var _a;
783
776
  const element = node;
784
777
  return {
785
778
  id: element.getAttribute('id'),
786
779
  href: element.getAttributeNS(XLINK_NAMESPACE, 'href'),
787
780
  mimeType: element.getAttribute('mimetype'),
788
781
  mimeSubType: element.getAttribute('mime-subtype'),
789
- title: (_a = element.querySelector('title')) === null || _a === void 0 ? void 0 : _a.textContent,
782
+ title: (0, utils_1.getTrimmedTextContent)(element, 'title'),
790
783
  };
791
784
  },
792
785
  },
@@ -806,11 +799,10 @@ const nodes = [
806
799
  tag: 'sec[sec-type="box-element"]',
807
800
  node: 'box_element',
808
801
  getAttrs: (node) => {
809
- var _a;
810
802
  const element = node;
811
803
  return {
812
804
  id: element.getAttribute('id'),
813
- label: (_a = element.querySelector('label')) === null || _a === void 0 ? void 0 : _a.textContent,
805
+ label: (0, utils_1.getTrimmedTextContent)(element, 'label'),
814
806
  };
815
807
  },
816
808
  },
@@ -963,11 +955,11 @@ const nodes = [
963
955
  tag: 'xref[ref-type="bibr"]',
964
956
  node: 'citation',
965
957
  getAttrs: (node) => {
966
- var _a, _b;
958
+ var _a;
967
959
  const element = node;
968
960
  return {
969
961
  rids: ((_a = element.getAttribute('rid')) === null || _a === void 0 ? void 0 : _a.split(/\s+/)) || [],
970
- contents: (_b = element.textContent) === null || _b === void 0 ? void 0 : _b.trim(),
962
+ contents: (0, utils_1.getTrimmedTextContent)(element),
971
963
  };
972
964
  },
973
965
  },
@@ -975,11 +967,11 @@ const nodes = [
975
967
  tag: 'xref[ref-type="fn"]',
976
968
  node: 'inline_footnote',
977
969
  getAttrs: (node) => {
978
- var _a, _b;
970
+ var _a;
979
971
  const element = node;
980
972
  return {
981
973
  rids: ((_a = element.getAttribute('rid')) === null || _a === void 0 ? void 0 : _a.split(/\s+/)) || [],
982
- contents: (_b = element.textContent) === null || _b === void 0 ? void 0 : _b.trim(),
974
+ contents: (0, utils_1.getTrimmedTextContent)(element),
983
975
  };
984
976
  },
985
977
  },
@@ -987,11 +979,11 @@ const nodes = [
987
979
  tag: 'xref',
988
980
  node: 'cross_reference',
989
981
  getAttrs: (node) => {
990
- var _a, _b;
982
+ var _a;
991
983
  const element = node;
992
984
  return {
993
985
  rids: ((_a = element.getAttribute('rid')) === null || _a === void 0 ? void 0 : _a.split(/\s+/)) || [],
994
- label: (_b = element.textContent) === null || _b === void 0 ? void 0 : _b.trim(),
986
+ label: (0, utils_1.getTrimmedTextContent)(element),
995
987
  };
996
988
  },
997
989
  },
@@ -141,6 +141,7 @@ const renameJatsNodesToHTML = (node, container, createElement) => {
141
141
  });
142
142
  };
143
143
  const htmlFromJatsNode = (element, createElement) => {
144
+ var _a;
144
145
  if (!element) {
145
146
  return undefined;
146
147
  }
@@ -149,6 +150,6 @@ const htmlFromJatsNode = (element, createElement) => {
149
150
  }
150
151
  const temp = createElement('template');
151
152
  renameJatsNodesToHTML(element, temp, createElement);
152
- return temp.innerHTML;
153
+ return (_a = temp.innerHTML) === null || _a === void 0 ? void 0 : _a.trim();
153
154
  };
154
155
  exports.htmlFromJatsNode = htmlFromJatsNode;
@@ -75,12 +75,14 @@ const findParentNodeClosestToPos = ($pos, predicate) => {
75
75
  }
76
76
  };
77
77
  exports.findParentNodeClosestToPos = findParentNodeClosestToPos;
78
- const getTrimmedTextContent = (node, querySelector) => {
79
- var _a, _b;
78
+ const getTrimmedTextContent = (node, selector) => {
79
+ var _a, _b, _c;
80
80
  if (!node) {
81
- return null;
81
+ return undefined;
82
82
  }
83
- return (_b = (_a = node.querySelector(querySelector)) === null || _a === void 0 ? void 0 : _a.textContent) === null || _b === void 0 ? void 0 : _b.trim();
83
+ return selector
84
+ ? (_b = (_a = node.querySelector(selector)) === null || _a === void 0 ? void 0 : _a.textContent) === null || _b === void 0 ? void 0 : _b.trim()
85
+ : (_c = node.textContent) === null || _c === void 0 ? void 0 : _c.trim();
84
86
  };
85
87
  exports.getTrimmedTextContent = getTrimmedTextContent;
86
88
  const timestamp = () => Math.floor(Date.now() / 1000);
@@ -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.8";
4
+ exports.VERSION = "3.0.9";
@@ -100,21 +100,20 @@ const parseDates = (historyNode) => {
100
100
  return history;
101
101
  };
102
102
  const getEmail = (element) => {
103
- var _a, _b, _c;
103
+ var _a, _b;
104
104
  const email = element.querySelector('email');
105
105
  if (email) {
106
106
  return {
107
107
  href: (_a = email.getAttributeNS(XLINK_NAMESPACE, 'href')) !== null && _a !== void 0 ? _a : '',
108
- text: (_c = (_b = email.textContent) === null || _b === void 0 ? void 0 : _b.trim()) !== null && _c !== void 0 ? _c : '',
108
+ text: (_b = getTrimmedTextContent(email)) !== null && _b !== void 0 ? _b : '',
109
109
  };
110
110
  }
111
111
  };
112
112
  const getInstitutionDetails = (element) => {
113
- var _a;
114
113
  let department = '';
115
114
  let institution = '';
116
115
  for (const node of element.querySelectorAll('institution')) {
117
- const content = (_a = node.textContent) === null || _a === void 0 ? void 0 : _a.trim();
116
+ const content = getTrimmedTextContent(node);
118
117
  if (!content) {
119
118
  continue;
120
119
  }
@@ -161,10 +160,10 @@ const parseRef = (element) => {
161
160
  const mixedCitation = element.querySelector('mixed-citation');
162
161
  if (authorNodes.length <= 0) {
163
162
  mixedCitation === null || mixedCitation === void 0 ? void 0 : mixedCitation.childNodes.forEach((item) => {
164
- var _a, _b, _c;
163
+ var _a, _b;
165
164
  if (item.nodeType === Node.TEXT_NODE &&
166
165
  ((_a = item.textContent) === null || _a === void 0 ? void 0 : _a.match(/[A-Za-z]+/g))) {
167
- attrs.literal = (_c = (_b = mixedCitation.textContent) === null || _b === void 0 ? void 0 : _b.trim()) !== null && _c !== void 0 ? _c : '';
166
+ attrs.literal = (_b = getTrimmedTextContent(mixedCitation)) !== null && _b !== void 0 ? _b : '';
168
167
  return attrs;
169
168
  }
170
169
  });
@@ -202,7 +201,6 @@ const parseRef = (element) => {
202
201
  }
203
202
  const authors = [];
204
203
  authorNodes.forEach((authorNode) => {
205
- var _a;
206
204
  const name = buildBibliographicName({});
207
205
  const given = getTrimmedTextContent(authorNode, 'given-names');
208
206
  if (given) {
@@ -213,7 +211,7 @@ const parseRef = (element) => {
213
211
  name.family = family;
214
212
  }
215
213
  if (authorNode.nodeName === 'collab') {
216
- name.literal = (_a = authorNode.textContent) === null || _a === void 0 ? void 0 : _a.trim();
214
+ name.literal = getTrimmedTextContent(authorNode);
217
215
  }
218
216
  authors.push(name);
219
217
  });
@@ -273,7 +271,7 @@ const nodes = [
273
271
  const doi = element.querySelector('front > article-meta > article-id[pub-id-type="doi"]');
274
272
  const history = element.querySelector('history');
275
273
  const dates = parseDates(history);
276
- return Object.assign({ doi: doi === null || doi === void 0 ? void 0 : doi.textContent, articleType: (_a = element.getAttribute('article-type')) !== null && _a !== void 0 ? _a : '', primaryLanguageCode: (_b = element.getAttribute('lang')) !== null && _b !== void 0 ? _b : '' }, dates);
274
+ return Object.assign({ doi: getTrimmedTextContent(doi), articleType: (_a = element.getAttribute('article-type')) !== null && _a !== void 0 ? _a : '', primaryLanguageCode: (_b = element.getAttribute('lang')) !== null && _b !== void 0 ? _b : '' }, dates);
277
275
  },
278
276
  },
279
277
  {
@@ -305,7 +303,7 @@ const nodes = [
305
303
  return {
306
304
  id: element.getAttribute('id'),
307
305
  target: element.getAttribute('target-id'),
308
- contents: element.textContent,
306
+ contents: getTrimmedTextContent(element),
309
307
  contributions: [buildContribution(DEFAULT_PROFILE_ID)],
310
308
  };
311
309
  },
@@ -328,15 +326,14 @@ const nodes = [
328
326
  tag: 'award-group',
329
327
  node: 'award',
330
328
  getAttrs: (node) => {
331
- var _a, _b;
332
329
  const element = node;
333
330
  return {
334
331
  id: element.getAttribute('id'),
335
- recipient: (_a = element.querySelector('principal-award-recipient')) === null || _a === void 0 ? void 0 : _a.textContent,
332
+ recipient: getTrimmedTextContent(element, 'principal-award-recipient'),
336
333
  code: Array.from(element.querySelectorAll('award-id'))
337
- .map((awardID) => awardID.textContent)
334
+ .map((awardID) => getTrimmedTextContent(awardID))
338
335
  .reduce((acc, text) => (acc ? `${acc};${text}` : text), ''),
339
- source: (_b = element.querySelector('funding-source')) === null || _b === void 0 ? void 0 : _b.textContent,
336
+ source: getTrimmedTextContent(element, 'funding-source'),
340
337
  };
341
338
  },
342
339
  },
@@ -356,7 +353,6 @@ const nodes = [
356
353
  tag: 'corresp',
357
354
  node: 'corresp',
358
355
  getAttrs: (node) => {
359
- var _a;
360
356
  const element = node;
361
357
  const label = element.querySelector('label');
362
358
  if (label) {
@@ -364,20 +360,18 @@ const nodes = [
364
360
  }
365
361
  return {
366
362
  id: element.getAttribute('id'),
367
- label: (_a = label === null || label === void 0 ? void 0 : label.textContent) === null || _a === void 0 ? void 0 : _a.trim(),
363
+ label: getTrimmedTextContent(label),
368
364
  };
369
365
  },
370
366
  getContent: (node) => {
371
- var _a;
372
367
  const element = node;
373
- return Fragment.from(schema.text(((_a = element.textContent) === null || _a === void 0 ? void 0 : _a.trim()) || ''));
368
+ return Fragment.from(schema.text(getTrimmedTextContent(element) || ''));
374
369
  },
375
370
  },
376
371
  {
377
372
  tag: 'contrib[contrib-type="author"]',
378
373
  node: 'contributor',
379
374
  getAttrs: (node) => {
380
- var _a, _b;
381
375
  const element = node;
382
376
  const footnote = [];
383
377
  const affiliations = [];
@@ -393,13 +387,13 @@ const nodes = [
393
387
  case 'fn':
394
388
  footnote.push({
395
389
  noteID: rid,
396
- noteLabel: ((_a = xref.textContent) === null || _a === void 0 ? void 0 : _a.trim()) || '',
390
+ noteLabel: getTrimmedTextContent(xref) || '',
397
391
  });
398
392
  break;
399
393
  case 'corresp':
400
394
  corresp.push({
401
395
  correspID: rid,
402
- correspLabel: ((_b = xref.textContent) === null || _b === void 0 ? void 0 : _b.trim()) || '',
396
+ correspLabel: getTrimmedTextContent(xref) || '',
403
397
  });
404
398
  break;
405
399
  case 'aff':
@@ -522,12 +516,12 @@ const nodes = [
522
516
  node: 'listing',
523
517
  context: 'listing_element/',
524
518
  getAttrs: (node) => {
525
- var _a, _b, _c;
519
+ var _a;
526
520
  const element = node;
527
521
  return {
528
522
  id: element.getAttribute('id'),
529
523
  language: (_a = element.getAttribute('language')) !== null && _a !== void 0 ? _a : '',
530
- contents: (_c = (_b = element.textContent) === null || _b === void 0 ? void 0 : _b.trim()) !== null && _c !== void 0 ? _c : '',
524
+ contents: getTrimmedTextContent(element),
531
525
  };
532
526
  },
533
527
  },
@@ -543,11 +537,11 @@ const nodes = [
543
537
  tag: 'disp-formula',
544
538
  node: 'equation_element',
545
539
  getAttrs: (node) => {
546
- var _a, _b;
540
+ var _a;
547
541
  const element = node;
548
542
  return {
549
543
  id: element.getAttribute('id'),
550
- label: (_b = (_a = element.querySelector('label')) === null || _a === void 0 ? void 0 : _a.textContent) !== null && _b !== void 0 ? _b : '',
544
+ label: (_a = getTrimmedTextContent(element, 'label')) !== null && _a !== void 0 ? _a : '',
551
545
  };
552
546
  },
553
547
  getContent: (node, schema) => {
@@ -640,7 +634,7 @@ const nodes = [
640
634
  tag: 'fig',
641
635
  node: 'figure_element',
642
636
  getAttrs: (node) => {
643
- var _a, _b, _c, _d;
637
+ var _a, _b;
644
638
  const element = node;
645
639
  const labelNode = element.querySelector('label');
646
640
  if (labelNode) {
@@ -650,12 +644,12 @@ const nodes = [
650
644
  const position = element.getAttribute('position');
651
645
  const attribution = attrib
652
646
  ? {
653
- literal: (_b = (_a = attrib.textContent) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : '',
647
+ literal: (_a = getTrimmedTextContent(attrib)) !== null && _a !== void 0 ? _a : '',
654
648
  }
655
649
  : undefined;
656
650
  return {
657
651
  id: element.getAttribute('id'),
658
- label: (_d = (_c = labelNode === null || labelNode === void 0 ? void 0 : labelNode.textContent) === null || _c === void 0 ? void 0 : _c.trim()) !== null && _d !== void 0 ? _d : '',
652
+ label: (_b = getTrimmedTextContent(labelNode)) !== null && _b !== void 0 ? _b : '',
659
653
  attribution: attribution,
660
654
  position,
661
655
  };
@@ -773,14 +767,13 @@ const nodes = [
773
767
  tag: 'supplementary-material',
774
768
  node: 'supplement',
775
769
  getAttrs: (node) => {
776
- var _a;
777
770
  const element = node;
778
771
  return {
779
772
  id: element.getAttribute('id'),
780
773
  href: element.getAttributeNS(XLINK_NAMESPACE, 'href'),
781
774
  mimeType: element.getAttribute('mimetype'),
782
775
  mimeSubType: element.getAttribute('mime-subtype'),
783
- title: (_a = element.querySelector('title')) === null || _a === void 0 ? void 0 : _a.textContent,
776
+ title: getTrimmedTextContent(element, 'title'),
784
777
  };
785
778
  },
786
779
  },
@@ -800,11 +793,10 @@ const nodes = [
800
793
  tag: 'sec[sec-type="box-element"]',
801
794
  node: 'box_element',
802
795
  getAttrs: (node) => {
803
- var _a;
804
796
  const element = node;
805
797
  return {
806
798
  id: element.getAttribute('id'),
807
- label: (_a = element.querySelector('label')) === null || _a === void 0 ? void 0 : _a.textContent,
799
+ label: getTrimmedTextContent(element, 'label'),
808
800
  };
809
801
  },
810
802
  },
@@ -957,11 +949,11 @@ const nodes = [
957
949
  tag: 'xref[ref-type="bibr"]',
958
950
  node: 'citation',
959
951
  getAttrs: (node) => {
960
- var _a, _b;
952
+ var _a;
961
953
  const element = node;
962
954
  return {
963
955
  rids: ((_a = element.getAttribute('rid')) === null || _a === void 0 ? void 0 : _a.split(/\s+/)) || [],
964
- contents: (_b = element.textContent) === null || _b === void 0 ? void 0 : _b.trim(),
956
+ contents: getTrimmedTextContent(element),
965
957
  };
966
958
  },
967
959
  },
@@ -969,11 +961,11 @@ const nodes = [
969
961
  tag: 'xref[ref-type="fn"]',
970
962
  node: 'inline_footnote',
971
963
  getAttrs: (node) => {
972
- var _a, _b;
964
+ var _a;
973
965
  const element = node;
974
966
  return {
975
967
  rids: ((_a = element.getAttribute('rid')) === null || _a === void 0 ? void 0 : _a.split(/\s+/)) || [],
976
- contents: (_b = element.textContent) === null || _b === void 0 ? void 0 : _b.trim(),
968
+ contents: getTrimmedTextContent(element),
977
969
  };
978
970
  },
979
971
  },
@@ -981,11 +973,11 @@ const nodes = [
981
973
  tag: 'xref',
982
974
  node: 'cross_reference',
983
975
  getAttrs: (node) => {
984
- var _a, _b;
976
+ var _a;
985
977
  const element = node;
986
978
  return {
987
979
  rids: ((_a = element.getAttribute('rid')) === null || _a === void 0 ? void 0 : _a.split(/\s+/)) || [],
988
- label: (_b = element.textContent) === null || _b === void 0 ? void 0 : _b.trim(),
980
+ label: getTrimmedTextContent(element),
989
981
  };
990
982
  },
991
983
  },
@@ -137,6 +137,7 @@ const renameJatsNodesToHTML = (node, container, createElement) => {
137
137
  });
138
138
  };
139
139
  export const htmlFromJatsNode = (element, createElement) => {
140
+ var _a;
140
141
  if (!element) {
141
142
  return undefined;
142
143
  }
@@ -145,5 +146,5 @@ export const htmlFromJatsNode = (element, createElement) => {
145
146
  }
146
147
  const temp = createElement('template');
147
148
  renameJatsNodesToHTML(element, temp, createElement);
148
- return temp.innerHTML;
149
+ return (_a = temp.innerHTML) === null || _a === void 0 ? void 0 : _a.trim();
149
150
  };
@@ -67,12 +67,14 @@ export const findParentNodeClosestToPos = ($pos, predicate) => {
67
67
  }
68
68
  }
69
69
  };
70
- export const getTrimmedTextContent = (node, querySelector) => {
71
- var _a, _b;
70
+ export const getTrimmedTextContent = (node, selector) => {
71
+ var _a, _b, _c;
72
72
  if (!node) {
73
- return null;
73
+ return undefined;
74
74
  }
75
- return (_b = (_a = node.querySelector(querySelector)) === null || _a === void 0 ? void 0 : _a.textContent) === null || _b === void 0 ? void 0 : _b.trim();
75
+ return selector
76
+ ? (_b = (_a = node.querySelector(selector)) === null || _a === void 0 ? void 0 : _a.textContent) === null || _b === void 0 ? void 0 : _b.trim()
77
+ : (_c = node.textContent) === null || _c === void 0 ? void 0 : _c.trim();
76
78
  };
77
79
  export const timestamp = () => Math.floor(Date.now() / 1000);
78
80
  export const dateToTimestamp = (dateElement) => {
@@ -1 +1 @@
1
- export const VERSION = "3.0.8";
1
+ export const VERSION = "3.0.9";
@@ -25,6 +25,6 @@ export declare const findParentNodeClosestToPos: ($pos: ResolvedPos, predicate:
25
25
  depth: number;
26
26
  node: ProsemirrorNode;
27
27
  } | undefined;
28
- export declare const getTrimmedTextContent: (node: Element | Document | null, querySelector: string) => string | null | undefined;
28
+ export declare const getTrimmedTextContent: (node: Element | Document | null, selector?: string) => string | undefined;
29
29
  export declare const timestamp: () => number;
30
30
  export declare const dateToTimestamp: (dateElement: Element) => number | undefined;
@@ -1 +1 @@
1
- export declare const VERSION = "3.0.8";
1
+ export declare const VERSION = "3.0.9";
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.8",
4
+ "version": "3.0.9",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-transform",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",