@manuscripts/transform 3.0.68-comparison-test.1 → 3.0.69

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 (35) hide show
  1. package/dist/cjs/jats/exporter/jats-exporter.js +43 -40
  2. package/dist/cjs/jats/importer/jats-dom-parser.js +13 -1
  3. package/dist/cjs/jats/importer/jats-transformations.js +9 -5
  4. package/dist/cjs/jats/importer/parse-jats-article.js +1 -1
  5. package/dist/cjs/schema/index.js +3 -0
  6. package/dist/cjs/schema/nodes/abstracts.js +1 -1
  7. package/dist/cjs/schema/nodes/list.js +0 -5
  8. package/dist/cjs/schema/nodes/table.js +3 -3
  9. package/dist/cjs/schema/nodes/table_col.js +0 -5
  10. package/dist/cjs/schema/nodes/trans_abstract.js +44 -0
  11. package/dist/cjs/transformer/node-names.js +1 -0
  12. package/dist/cjs/transformer/node-title.js +1 -0
  13. package/dist/cjs/version.js +1 -1
  14. package/dist/es/jats/exporter/jats-exporter.js +43 -40
  15. package/dist/es/jats/importer/jats-dom-parser.js +13 -1
  16. package/dist/es/jats/importer/jats-transformations.js +9 -5
  17. package/dist/es/jats/importer/parse-jats-article.js +1 -1
  18. package/dist/es/schema/index.js +3 -0
  19. package/dist/es/schema/nodes/abstracts.js +1 -1
  20. package/dist/es/schema/nodes/list.js +0 -5
  21. package/dist/es/schema/nodes/table.js +3 -3
  22. package/dist/es/schema/nodes/table_col.js +0 -5
  23. package/dist/es/schema/nodes/trans_abstract.js +40 -0
  24. package/dist/es/transformer/node-names.js +1 -0
  25. package/dist/es/transformer/node-title.js +1 -0
  26. package/dist/es/version.js +1 -1
  27. package/dist/types/jats/exporter/jats-exporter.d.ts +1 -1
  28. package/dist/types/jats/importer/jats-transformations.d.ts +2 -2
  29. package/dist/types/schema/index.d.ts +1 -0
  30. package/dist/types/schema/nodes/list.d.ts +0 -1
  31. package/dist/types/schema/nodes/table_col.d.ts +0 -1
  32. package/dist/types/schema/nodes/trans_abstract.d.ts +27 -0
  33. package/dist/types/schema/types.d.ts +1 -1
  34. package/dist/types/version.d.ts +1 -1
  35. package/package.json +1 -1
@@ -40,25 +40,21 @@ const publicationTypeToJats = {
40
40
  };
41
41
  const warn = (0, debug_1.default)('manuscripts-transform');
42
42
  const XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
43
+ const XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
43
44
  const normalizeID = (id) => id.replace(/:/g, '_');
44
45
  const parser = prosemirror_model_1.DOMParser.fromSchema(schema_1.schema);
45
- const insertAbstractNode = (articleMeta, abstractNode) => {
46
- const siblings = [
47
- 'kwd-group',
48
- 'funding-group',
49
- 'support-group',
50
- 'conference',
51
- 'counts',
52
- 'custom-meta-group',
53
- ];
54
- for (const sibling of siblings) {
55
- const siblingNode = articleMeta.querySelector(`:scope > ${sibling}`);
56
- if (siblingNode) {
57
- articleMeta.insertBefore(abstractNode, siblingNode);
58
- return;
59
- }
46
+ const insertAbstractNode = (front, abstractNode) => {
47
+ const articleMeta = front.querySelector(':scope > article-meta');
48
+ if (!articleMeta) {
49
+ return;
50
+ }
51
+ const insertBeforeElement = articleMeta.querySelector('kwd-group, funding-group, support-group, conference, counts, custom-meta-group');
52
+ if (insertBeforeElement) {
53
+ articleMeta.insertBefore(abstractNode, insertBeforeElement);
54
+ }
55
+ else {
56
+ articleMeta.appendChild(abstractNode);
60
57
  }
61
- articleMeta.appendChild(abstractNode);
62
58
  };
63
59
  const createCounter = () => {
64
60
  const counts = new Map();
@@ -564,6 +560,18 @@ class JATSExporter {
564
560
  };
565
561
  this.createSerializer = () => {
566
562
  const nodes = {
563
+ trans_abstract: (node) => {
564
+ const attrs = {
565
+ id: normalizeID(node.attrs.id),
566
+ };
567
+ if (node.attrs.lang) {
568
+ attrs['xml:lang'] = node.attrs.lang;
569
+ }
570
+ if (node.attrs.category) {
571
+ attrs['sec-type'] = node.attrs.category;
572
+ }
573
+ return ['trans-abstract', attrs, 0];
574
+ },
567
575
  hero_image: () => '',
568
576
  alt_text: (node) => {
569
577
  if (node.textContent) {
@@ -1387,15 +1395,13 @@ class JATSExporter {
1387
1395
  }
1388
1396
  };
1389
1397
  this.moveAbstracts = (front, body) => {
1390
- const container = body.querySelector(':scope > sec[sec-type="abstracts"]');
1391
- const abstractsNode = this.getFirstChildOfType(schema_1.schema.nodes.abstracts);
1392
- const abstractCategories = this.getAbstractCategories(abstractsNode);
1393
- const abstractSections = this.getAbstractSections(container, body, abstractCategories);
1394
- if (abstractSections.length) {
1395
- this.processAbstractSections(abstractSections, front);
1396
- }
1397
- if (container) {
1398
- body.removeChild(container);
1398
+ const abstractSections = this.getAbstractSections(body);
1399
+ for (const abstractSection of abstractSections) {
1400
+ const node = abstractSection.nodeName === 'trans-abstract'
1401
+ ? this.createTransAbstractNode(abstractSection)
1402
+ : this.createAbstractNode(abstractSection);
1403
+ abstractSection.remove();
1404
+ insertAbstractNode(front, node);
1399
1405
  }
1400
1406
  };
1401
1407
  this.moveSectionsToBack = (back, body) => {
@@ -1617,12 +1623,11 @@ class JATSExporter {
1617
1623
  });
1618
1624
  return categories;
1619
1625
  }
1620
- getAbstractSections(container, body, abstractCategories) {
1621
- if (container) {
1622
- return Array.from(container.querySelectorAll(':scope > sec'));
1623
- }
1624
- else {
1625
- const sections = Array.from(body.querySelectorAll(':scope > sec'));
1626
+ getAbstractSections(body) {
1627
+ {
1628
+ const abstractsNode = this.getFirstChildOfType(schema_1.schema.nodes.abstracts);
1629
+ const abstractCategories = this.getAbstractCategories(abstractsNode);
1630
+ const sections = Array.from(body.querySelectorAll(':scope > sec, :scope > trans-abstract'));
1626
1631
  return sections.filter((section) => this.isAbstractSection(section, abstractCategories));
1627
1632
  }
1628
1633
  }
@@ -1630,15 +1635,13 @@ class JATSExporter {
1630
1635
  const sectionType = section.getAttribute('sec-type');
1631
1636
  return sectionType ? abstractCategories.includes(sectionType) : false;
1632
1637
  }
1633
- processAbstractSections(abstractSections, front) {
1634
- for (const abstractSection of abstractSections) {
1635
- const abstractNode = this.createAbstractNode(abstractSection);
1636
- abstractSection.remove();
1637
- const articleMeta = front.querySelector(':scope > article-meta');
1638
- if (articleMeta) {
1639
- insertAbstractNode(articleMeta, abstractNode);
1640
- }
1641
- }
1638
+ createTransAbstractNode(transAbstract) {
1639
+ var _a;
1640
+ const transAbstractNode = this.createElement('trans-abstract');
1641
+ transAbstractNode.setAttributeNS(XML_NAMESPACE, 'lang', (_a = transAbstract.getAttribute('xml:lang')) !== null && _a !== void 0 ? _a : '');
1642
+ this.setAbstractType(transAbstractNode, transAbstract);
1643
+ transAbstractNode.append(...transAbstract.childNodes);
1644
+ return transAbstractNode;
1642
1645
  }
1643
1646
  createAbstractNode(abstractSection) {
1644
1647
  const abstractNode = this.createElement('abstract');
@@ -789,6 +789,18 @@ class JATSDOMParser {
789
789
  };
790
790
  },
791
791
  },
792
+ {
793
+ tag: 'trans-abstract',
794
+ node: 'trans_abstract',
795
+ getAttrs: (node) => {
796
+ var _a;
797
+ const element = node;
798
+ return {
799
+ lang: (_a = element.getAttribute('xml:lang')) !== null && _a !== void 0 ? _a : '',
800
+ category: this.chooseSectionCategory(element),
801
+ };
802
+ },
803
+ },
792
804
  {
793
805
  tag: 'sec[sec-type="abstracts"]',
794
806
  node: 'abstracts',
@@ -1055,7 +1067,7 @@ class JATSDOMParser {
1055
1067
  return false;
1056
1068
  }
1057
1069
  chooseSectionCategory(section) {
1058
- const secType = section.getAttribute('sec-type');
1070
+ const secType = section.getAttribute('sec-type') || section.getAttribute('abstract-type');
1059
1071
  const titleNode = section.firstElementChild;
1060
1072
  for (const category of this.sectionCategories) {
1061
1073
  if (this.isMatchingCategory(secType, titleNode, category)) {
@@ -103,8 +103,8 @@ const moveAffiliations = (front, createElement) => {
103
103
  }
104
104
  };
105
105
  exports.moveAffiliations = moveAffiliations;
106
- const moveAbstracts = (doc, group, createElement) => {
107
- const abstracts = doc.querySelectorAll('front > article-meta > abstract');
106
+ const moveAbstracts = (front, group, createElement) => {
107
+ const abstracts = front.querySelectorAll('article-meta > abstract, article-meta > trans-abstract');
108
108
  abstracts.forEach((abstract) => {
109
109
  const sec = createAbstractSection(abstract, createElement);
110
110
  removeNodeFromParent(abstract);
@@ -161,9 +161,9 @@ const createBody = (doc, body, createElement) => {
161
161
  body.append(group);
162
162
  };
163
163
  exports.createBody = createBody;
164
- const createAbstracts = (doc, body, createElement) => {
164
+ const createAbstracts = (front, body, createElement) => {
165
165
  const group = createSectionGroup('abstracts', createElement);
166
- (0, exports.moveAbstracts)(doc, group, createElement);
166
+ (0, exports.moveAbstracts)(front, group, createElement);
167
167
  body.insertBefore(group, body.lastElementChild);
168
168
  };
169
169
  exports.createAbstracts = createAbstracts;
@@ -233,8 +233,12 @@ const moveCaptionsToEnd = (body) => {
233
233
  exports.moveCaptionsToEnd = moveCaptionsToEnd;
234
234
  const createAbstractSection = (abstract, createElement) => {
235
235
  const abstractType = abstract.getAttribute('abstract-type');
236
- const section = createElement('sec');
237
236
  const sectionType = abstractType ? `abstract-${abstractType}` : 'abstract';
237
+ if (abstract.nodeName === 'trans-abstract') {
238
+ abstract.setAttribute('abstract-type', sectionType);
239
+ return abstract;
240
+ }
241
+ const section = createElement('sec');
238
242
  section.setAttribute('sec-type', sectionType);
239
243
  if (!abstract.querySelector(':scope > title')) {
240
244
  const title = createElement('title');
@@ -42,7 +42,7 @@ const processJATS = (doc, sectionCategories) => {
42
42
  (0, jats_transformations_1.moveCaptionsToEnd)(body);
43
43
  (0, jats_transformations_1.createBoxedElementSection)(body, createElement);
44
44
  (0, jats_transformations_1.createBody)(doc, body, createElement);
45
- (0, jats_transformations_1.createAbstracts)(doc, body, createElement);
45
+ (0, jats_transformations_1.createAbstracts)(front, body, createElement);
46
46
  (0, jats_transformations_1.createBackmatter)(doc, body, sectionCategories, createElement);
47
47
  (0, jats_transformations_1.createSupplementaryMaterialsSection)(doc, body, createElement);
48
48
  (0, jats_transformations_1.createKeywordsSection)(doc, body, createElement);
@@ -105,6 +105,7 @@ const table_element_1 = require("./nodes/table_element");
105
105
  const table_element_footer_1 = require("./nodes/table_element_footer");
106
106
  const text_1 = require("./nodes/text");
107
107
  const title_1 = require("./nodes/title");
108
+ const trans_abstract_1 = require("./nodes/trans_abstract");
108
109
  __exportStar(require("./groups"), exports);
109
110
  __exportStar(require("./nodes/affiliation"), exports);
110
111
  __exportStar(require("./nodes/affiliations"), exports);
@@ -176,6 +177,7 @@ __exportStar(require("./nodes/alt_text"), exports);
176
177
  __exportStar(require("./nodes/long_desc"), exports);
177
178
  __exportStar(require("./nodes/quote_image"), exports);
178
179
  __exportStar(require("./nodes/hero_image"), exports);
180
+ __exportStar(require("./nodes/trans_abstract"), exports);
179
181
  exports.schema = new prosemirror_model_1.Schema({
180
182
  marks: {
181
183
  bold: marks_1.bold,
@@ -271,5 +273,6 @@ exports.schema = new prosemirror_model_1.Schema({
271
273
  long_desc: long_desc_1.longDesc,
272
274
  quote_image: quote_image_1.quoteImage,
273
275
  hero_image: hero_image_1.heroImage,
276
+ trans_abstract: trans_abstract_1.transAbstract,
274
277
  },
275
278
  });
@@ -17,7 +17,7 @@
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.abstracts = void 0;
19
19
  exports.abstracts = {
20
- content: 'sections*',
20
+ content: 'sections* trans_abstract*',
21
21
  attrs: {
22
22
  id: { default: '' },
23
23
  },
@@ -93,7 +93,6 @@ exports.listItem = {
93
93
  defining: true,
94
94
  attrs: {
95
95
  placeholder: { default: 'List item' },
96
- id: { default: '' },
97
96
  dataTracked: { default: null },
98
97
  },
99
98
  parseDOM: [
@@ -103,7 +102,6 @@ exports.listItem = {
103
102
  const dom = p;
104
103
  return {
105
104
  placeholder: dom.getAttribute('data-placeholder-text') || '',
106
- id: dom.getAttribute('id') || '',
107
105
  };
108
106
  },
109
107
  },
@@ -114,9 +112,6 @@ exports.listItem = {
114
112
  if (listItemNode.attrs.placeholder) {
115
113
  attrs['data-placeholder-text'] = listItemNode.attrs.placeholder;
116
114
  }
117
- if (listItemNode.attrs.id) {
118
- attrs['id'] = listItemNode.attrs.id;
119
- }
120
115
  return ['li', attrs, 0];
121
116
  },
122
117
  };
@@ -87,6 +87,6 @@ exports.table = {
87
87
  ];
88
88
  },
89
89
  };
90
- exports.tableRow = Object.assign(Object.assign({}, tableNodes.table_row), { attrs: Object.assign(Object.assign({}, tableNodes.table_row.attrs), { id: { default: '' }, dataTracked: { default: null } }) });
91
- exports.tableCell = Object.assign(Object.assign({}, tableNodes.table_cell), { attrs: Object.assign(Object.assign({}, tableNodes.table_cell.attrs), { id: { default: '' }, dataTracked: { default: null } }) });
92
- exports.tableHeader = Object.assign(Object.assign({}, tableNodes.table_header), { attrs: Object.assign(Object.assign({}, tableNodes.table_header.attrs), { id: { default: '' }, dataTracked: { default: null } }) });
90
+ exports.tableRow = Object.assign(Object.assign({}, tableNodes.table_row), { attrs: Object.assign(Object.assign({}, tableNodes.table_row.attrs), { dataTracked: { default: null } }) });
91
+ exports.tableCell = Object.assign(Object.assign({}, tableNodes.table_cell), { attrs: Object.assign(Object.assign({}, tableNodes.table_cell.attrs), { dataTracked: { default: null } }) });
92
+ exports.tableHeader = Object.assign(Object.assign({}, tableNodes.table_header), { attrs: Object.assign(Object.assign({}, tableNodes.table_header.attrs), { dataTracked: { default: null } }) });
@@ -31,7 +31,6 @@ exports.tableColGroup = {
31
31
  exports.tableCol = {
32
32
  attrs: {
33
33
  width: { default: '' },
34
- id: { default: '' },
35
34
  },
36
35
  group: 'block',
37
36
  parseDOM: [
@@ -41,7 +40,6 @@ exports.tableCol = {
41
40
  const dom = p;
42
41
  return {
43
42
  width: dom.getAttribute('width'),
44
- id: dom.getAttribute('id'),
45
43
  };
46
44
  },
47
45
  },
@@ -52,9 +50,6 @@ exports.tableCol = {
52
50
  if (tableColNode.attrs.width) {
53
51
  attrs['width'] = tableColNode.attrs.width;
54
52
  }
55
- if (tableColNode.attrs.id) {
56
- attrs['id'] = tableColNode.attrs.id;
57
- }
58
53
  return ['col', attrs];
59
54
  },
60
55
  };
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ /*!
3
+ * © 2025 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.isTransAbstractNode = exports.transAbstract = void 0;
19
+ const index_1 = require("../index");
20
+ exports.transAbstract = {
21
+ content: '(paragraph | element)* sections*',
22
+ attrs: {
23
+ id: { default: '' },
24
+ lang: { default: '' },
25
+ category: { default: '' },
26
+ dataTracked: { default: null },
27
+ },
28
+ group: 'block element',
29
+ selectable: false,
30
+ toDOM: (node) => {
31
+ const { id, lang } = node.attrs;
32
+ return [
33
+ 'section',
34
+ {
35
+ id,
36
+ lang,
37
+ class: 'trans-abstract',
38
+ },
39
+ 0,
40
+ ];
41
+ },
42
+ };
43
+ const isTransAbstractNode = (node) => node.type === index_1.schema.nodes.transAbstract;
44
+ exports.isTransAbstractNode = isTransAbstractNode;
@@ -31,6 +31,7 @@ exports.nodeNames = new Map([
31
31
  [schema_1.schema.nodes.equation_element, 'Equation'],
32
32
  [schema_1.schema.nodes.figure_element, 'Figure'],
33
33
  [schema_1.schema.nodes.image_element, 'Image'],
34
+ [schema_1.schema.nodes.hero_image, 'Hero Image'],
34
35
  [schema_1.schema.nodes.table_element, 'Table'],
35
36
  [schema_1.schema.nodes.table_cell, 'Table Cell'],
36
37
  [schema_1.schema.nodes.table_col, 'Table Column'],
@@ -67,6 +67,7 @@ const nodeTitle = (node) => {
67
67
  case nodes.listing_element:
68
68
  case nodes.multi_graphic_figure_element:
69
69
  case nodes.image_element:
70
+ case nodes.hero_image:
70
71
  return '';
71
72
  case nodes.box_element:
72
73
  return '';
@@ -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.68-comparison-test.1";
4
+ exports.VERSION = "3.0.69";
@@ -34,25 +34,21 @@ const publicationTypeToJats = {
34
34
  };
35
35
  const warn = debug('manuscripts-transform');
36
36
  const XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
37
+ const XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
37
38
  const normalizeID = (id) => id.replace(/:/g, '_');
38
39
  const parser = ProsemirrorDOMParser.fromSchema(schema);
39
- const insertAbstractNode = (articleMeta, abstractNode) => {
40
- const siblings = [
41
- 'kwd-group',
42
- 'funding-group',
43
- 'support-group',
44
- 'conference',
45
- 'counts',
46
- 'custom-meta-group',
47
- ];
48
- for (const sibling of siblings) {
49
- const siblingNode = articleMeta.querySelector(`:scope > ${sibling}`);
50
- if (siblingNode) {
51
- articleMeta.insertBefore(abstractNode, siblingNode);
52
- return;
53
- }
40
+ const insertAbstractNode = (front, abstractNode) => {
41
+ const articleMeta = front.querySelector(':scope > article-meta');
42
+ if (!articleMeta) {
43
+ return;
44
+ }
45
+ const insertBeforeElement = articleMeta.querySelector('kwd-group, funding-group, support-group, conference, counts, custom-meta-group');
46
+ if (insertBeforeElement) {
47
+ articleMeta.insertBefore(abstractNode, insertBeforeElement);
48
+ }
49
+ else {
50
+ articleMeta.appendChild(abstractNode);
54
51
  }
55
- articleMeta.appendChild(abstractNode);
56
52
  };
57
53
  export const createCounter = () => {
58
54
  const counts = new Map();
@@ -556,6 +552,18 @@ export class JATSExporter {
556
552
  };
557
553
  this.createSerializer = () => {
558
554
  const nodes = {
555
+ trans_abstract: (node) => {
556
+ const attrs = {
557
+ id: normalizeID(node.attrs.id),
558
+ };
559
+ if (node.attrs.lang) {
560
+ attrs['xml:lang'] = node.attrs.lang;
561
+ }
562
+ if (node.attrs.category) {
563
+ attrs['sec-type'] = node.attrs.category;
564
+ }
565
+ return ['trans-abstract', attrs, 0];
566
+ },
559
567
  hero_image: () => '',
560
568
  alt_text: (node) => {
561
569
  if (node.textContent) {
@@ -1379,15 +1387,13 @@ export class JATSExporter {
1379
1387
  }
1380
1388
  };
1381
1389
  this.moveAbstracts = (front, body) => {
1382
- const container = body.querySelector(':scope > sec[sec-type="abstracts"]');
1383
- const abstractsNode = this.getFirstChildOfType(schema.nodes.abstracts);
1384
- const abstractCategories = this.getAbstractCategories(abstractsNode);
1385
- const abstractSections = this.getAbstractSections(container, body, abstractCategories);
1386
- if (abstractSections.length) {
1387
- this.processAbstractSections(abstractSections, front);
1388
- }
1389
- if (container) {
1390
- body.removeChild(container);
1390
+ const abstractSections = this.getAbstractSections(body);
1391
+ for (const abstractSection of abstractSections) {
1392
+ const node = abstractSection.nodeName === 'trans-abstract'
1393
+ ? this.createTransAbstractNode(abstractSection)
1394
+ : this.createAbstractNode(abstractSection);
1395
+ abstractSection.remove();
1396
+ insertAbstractNode(front, node);
1391
1397
  }
1392
1398
  };
1393
1399
  this.moveSectionsToBack = (back, body) => {
@@ -1609,12 +1615,11 @@ export class JATSExporter {
1609
1615
  });
1610
1616
  return categories;
1611
1617
  }
1612
- getAbstractSections(container, body, abstractCategories) {
1613
- if (container) {
1614
- return Array.from(container.querySelectorAll(':scope > sec'));
1615
- }
1616
- else {
1617
- const sections = Array.from(body.querySelectorAll(':scope > sec'));
1618
+ getAbstractSections(body) {
1619
+ {
1620
+ const abstractsNode = this.getFirstChildOfType(schema.nodes.abstracts);
1621
+ const abstractCategories = this.getAbstractCategories(abstractsNode);
1622
+ const sections = Array.from(body.querySelectorAll(':scope > sec, :scope > trans-abstract'));
1618
1623
  return sections.filter((section) => this.isAbstractSection(section, abstractCategories));
1619
1624
  }
1620
1625
  }
@@ -1622,15 +1627,13 @@ export class JATSExporter {
1622
1627
  const sectionType = section.getAttribute('sec-type');
1623
1628
  return sectionType ? abstractCategories.includes(sectionType) : false;
1624
1629
  }
1625
- processAbstractSections(abstractSections, front) {
1626
- for (const abstractSection of abstractSections) {
1627
- const abstractNode = this.createAbstractNode(abstractSection);
1628
- abstractSection.remove();
1629
- const articleMeta = front.querySelector(':scope > article-meta');
1630
- if (articleMeta) {
1631
- insertAbstractNode(articleMeta, abstractNode);
1632
- }
1633
- }
1630
+ createTransAbstractNode(transAbstract) {
1631
+ var _a;
1632
+ const transAbstractNode = this.createElement('trans-abstract');
1633
+ transAbstractNode.setAttributeNS(XML_NAMESPACE, 'lang', (_a = transAbstract.getAttribute('xml:lang')) !== null && _a !== void 0 ? _a : '');
1634
+ this.setAbstractType(transAbstractNode, transAbstract);
1635
+ transAbstractNode.append(...transAbstract.childNodes);
1636
+ return transAbstractNode;
1634
1637
  }
1635
1638
  createAbstractNode(abstractSection) {
1636
1639
  const abstractNode = this.createElement('abstract');
@@ -786,6 +786,18 @@ export class JATSDOMParser {
786
786
  };
787
787
  },
788
788
  },
789
+ {
790
+ tag: 'trans-abstract',
791
+ node: 'trans_abstract',
792
+ getAttrs: (node) => {
793
+ var _a;
794
+ const element = node;
795
+ return {
796
+ lang: (_a = element.getAttribute('xml:lang')) !== null && _a !== void 0 ? _a : '',
797
+ category: this.chooseSectionCategory(element),
798
+ };
799
+ },
800
+ },
789
801
  {
790
802
  tag: 'sec[sec-type="abstracts"]',
791
803
  node: 'abstracts',
@@ -1052,7 +1064,7 @@ export class JATSDOMParser {
1052
1064
  return false;
1053
1065
  }
1054
1066
  chooseSectionCategory(section) {
1055
- const secType = section.getAttribute('sec-type');
1067
+ const secType = section.getAttribute('sec-type') || section.getAttribute('abstract-type');
1056
1068
  const titleNode = section.firstElementChild;
1057
1069
  for (const category of this.sectionCategories) {
1058
1070
  if (this.isMatchingCategory(secType, titleNode, category)) {
@@ -94,8 +94,8 @@ export const moveAffiliations = (front, createElement) => {
94
94
  (_a = front.parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore(affiliations, front);
95
95
  }
96
96
  };
97
- export const moveAbstracts = (doc, group, createElement) => {
98
- const abstracts = doc.querySelectorAll('front > article-meta > abstract');
97
+ export const moveAbstracts = (front, group, createElement) => {
98
+ const abstracts = front.querySelectorAll('article-meta > abstract, article-meta > trans-abstract');
99
99
  abstracts.forEach((abstract) => {
100
100
  const sec = createAbstractSection(abstract, createElement);
101
101
  removeNodeFromParent(abstract);
@@ -148,9 +148,9 @@ export const createBody = (doc, body, createElement) => {
148
148
  });
149
149
  body.append(group);
150
150
  };
151
- export const createAbstracts = (doc, body, createElement) => {
151
+ export const createAbstracts = (front, body, createElement) => {
152
152
  const group = createSectionGroup('abstracts', createElement);
153
- moveAbstracts(doc, group, createElement);
153
+ moveAbstracts(front, group, createElement);
154
154
  body.insertBefore(group, body.lastElementChild);
155
155
  };
156
156
  export const createBackmatter = (doc, body, sectionCategories, createElement) => {
@@ -217,8 +217,12 @@ export const moveCaptionsToEnd = (body) => {
217
217
  };
218
218
  const createAbstractSection = (abstract, createElement) => {
219
219
  const abstractType = abstract.getAttribute('abstract-type');
220
- const section = createElement('sec');
221
220
  const sectionType = abstractType ? `abstract-${abstractType}` : 'abstract';
221
+ if (abstract.nodeName === 'trans-abstract') {
222
+ abstract.setAttribute('abstract-type', sectionType);
223
+ return abstract;
224
+ }
225
+ const section = createElement('sec');
222
226
  section.setAttribute('sec-type', sectionType);
223
227
  if (!abstract.querySelector(':scope > title')) {
224
228
  const title = createElement('title');
@@ -39,7 +39,7 @@ const processJATS = (doc, sectionCategories) => {
39
39
  moveCaptionsToEnd(body);
40
40
  createBoxedElementSection(body, createElement);
41
41
  createBody(doc, body, createElement);
42
- createAbstracts(doc, body, createElement);
42
+ createAbstracts(front, body, createElement);
43
43
  createBackmatter(doc, body, sectionCategories, createElement);
44
44
  createSupplementaryMaterialsSection(doc, body, createElement);
45
45
  createKeywordsSection(doc, body, createElement);
@@ -88,6 +88,7 @@ import { tableElement } from './nodes/table_element';
88
88
  import { tableElementFooter } from './nodes/table_element_footer';
89
89
  import { text, textBlock } from './nodes/text';
90
90
  import { title } from './nodes/title';
91
+ import { transAbstract } from './nodes/trans_abstract';
91
92
  export * from './groups';
92
93
  export * from './nodes/affiliation';
93
94
  export * from './nodes/affiliations';
@@ -159,6 +160,7 @@ export * from './nodes/alt_text';
159
160
  export * from './nodes/long_desc';
160
161
  export * from './nodes/quote_image';
161
162
  export * from './nodes/hero_image';
163
+ export * from './nodes/trans_abstract';
162
164
  export const schema = new Schema({
163
165
  marks: {
164
166
  bold,
@@ -254,5 +256,6 @@ export const schema = new Schema({
254
256
  long_desc: longDesc,
255
257
  quote_image: quoteImage,
256
258
  hero_image: heroImage,
259
+ trans_abstract: transAbstract,
257
260
  },
258
261
  });
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  export const abstracts = {
17
- content: 'sections*',
17
+ content: 'sections* trans_abstract*',
18
18
  attrs: {
19
19
  id: { default: '' },
20
20
  },
@@ -88,7 +88,6 @@ export const listItem = {
88
88
  defining: true,
89
89
  attrs: {
90
90
  placeholder: { default: 'List item' },
91
- id: { default: '' },
92
91
  dataTracked: { default: null },
93
92
  },
94
93
  parseDOM: [
@@ -98,7 +97,6 @@ export const listItem = {
98
97
  const dom = p;
99
98
  return {
100
99
  placeholder: dom.getAttribute('data-placeholder-text') || '',
101
- id: dom.getAttribute('id') || '',
102
100
  };
103
101
  },
104
102
  },
@@ -109,9 +107,6 @@ export const listItem = {
109
107
  if (listItemNode.attrs.placeholder) {
110
108
  attrs['data-placeholder-text'] = listItemNode.attrs.placeholder;
111
109
  }
112
- if (listItemNode.attrs.id) {
113
- attrs['id'] = listItemNode.attrs.id;
114
- }
115
110
  return ['li', attrs, 0];
116
111
  },
117
112
  };
@@ -84,6 +84,6 @@ export const table = {
84
84
  ];
85
85
  },
86
86
  };
87
- export const tableRow = Object.assign(Object.assign({}, tableNodes.table_row), { attrs: Object.assign(Object.assign({}, tableNodes.table_row.attrs), { id: { default: '' }, dataTracked: { default: null } }) });
88
- export const tableCell = Object.assign(Object.assign({}, tableNodes.table_cell), { attrs: Object.assign(Object.assign({}, tableNodes.table_cell.attrs), { id: { default: '' }, dataTracked: { default: null } }) });
89
- export const tableHeader = Object.assign(Object.assign({}, tableNodes.table_header), { attrs: Object.assign(Object.assign({}, tableNodes.table_header.attrs), { id: { default: '' }, dataTracked: { default: null } }) });
87
+ export const tableRow = Object.assign(Object.assign({}, tableNodes.table_row), { attrs: Object.assign(Object.assign({}, tableNodes.table_row.attrs), { dataTracked: { default: null } }) });
88
+ export const tableCell = Object.assign(Object.assign({}, tableNodes.table_cell), { attrs: Object.assign(Object.assign({}, tableNodes.table_cell.attrs), { dataTracked: { default: null } }) });
89
+ export const tableHeader = Object.assign(Object.assign({}, tableNodes.table_header), { attrs: Object.assign(Object.assign({}, tableNodes.table_header.attrs), { dataTracked: { default: null } }) });
@@ -28,7 +28,6 @@ export const tableColGroup = {
28
28
  export const tableCol = {
29
29
  attrs: {
30
30
  width: { default: '' },
31
- id: { default: '' },
32
31
  },
33
32
  group: 'block',
34
33
  parseDOM: [
@@ -38,7 +37,6 @@ export const tableCol = {
38
37
  const dom = p;
39
38
  return {
40
39
  width: dom.getAttribute('width'),
41
- id: dom.getAttribute('id'),
42
40
  };
43
41
  },
44
42
  },
@@ -49,9 +47,6 @@ export const tableCol = {
49
47
  if (tableColNode.attrs.width) {
50
48
  attrs['width'] = tableColNode.attrs.width;
51
49
  }
52
- if (tableColNode.attrs.id) {
53
- attrs['id'] = tableColNode.attrs.id;
54
- }
55
50
  return ['col', attrs];
56
51
  },
57
52
  };
@@ -0,0 +1,40 @@
1
+ /*!
2
+ * © 2025 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 { schema } from '../index';
17
+ export const transAbstract = {
18
+ content: '(paragraph | element)* sections*',
19
+ attrs: {
20
+ id: { default: '' },
21
+ lang: { default: '' },
22
+ category: { default: '' },
23
+ dataTracked: { default: null },
24
+ },
25
+ group: 'block element',
26
+ selectable: false,
27
+ toDOM: (node) => {
28
+ const { id, lang } = node.attrs;
29
+ return [
30
+ 'section',
31
+ {
32
+ id,
33
+ lang,
34
+ class: 'trans-abstract',
35
+ },
36
+ 0,
37
+ ];
38
+ },
39
+ };
40
+ export const isTransAbstractNode = (node) => node.type === schema.nodes.transAbstract;
@@ -28,6 +28,7 @@ export const nodeNames = new Map([
28
28
  [schema.nodes.equation_element, 'Equation'],
29
29
  [schema.nodes.figure_element, 'Figure'],
30
30
  [schema.nodes.image_element, 'Image'],
31
+ [schema.nodes.hero_image, 'Hero Image'],
31
32
  [schema.nodes.table_element, 'Table'],
32
33
  [schema.nodes.table_cell, 'Table Cell'],
33
34
  [schema.nodes.table_col, 'Table Column'],
@@ -64,6 +64,7 @@ export const nodeTitle = (node) => {
64
64
  case nodes.listing_element:
65
65
  case nodes.multi_graphic_figure_element:
66
66
  case nodes.image_element:
67
+ case nodes.hero_image:
67
68
  return '';
68
69
  case nodes.box_element:
69
70
  return '';
@@ -1 +1 @@
1
- export const VERSION = "3.0.68-comparison-test.1";
1
+ export const VERSION = "3.0.69";
@@ -101,7 +101,7 @@ export declare class JATSExporter {
101
101
  private getAbstractCategories;
102
102
  private getAbstractSections;
103
103
  private isAbstractSection;
104
- private processAbstractSections;
104
+ private createTransAbstractNode;
105
105
  private createAbstractNode;
106
106
  private setAbstractType;
107
107
  private moveSectionsToBack;
@@ -21,11 +21,11 @@ export declare const moveAuthorNotes: (front: Element, createElement: CreateElem
21
21
  export declare const moveAwards: (front: Element) => void;
22
22
  export declare const moveContributors: (front: Element, createElement: CreateElement) => void;
23
23
  export declare const moveAffiliations: (front: Element, createElement: CreateElement) => void;
24
- export declare const moveAbstracts: (doc: Document, group: Element, createElement: CreateElement) => void;
24
+ export declare const moveAbstracts: (front: Element, group: Element, createElement: CreateElement) => void;
25
25
  export declare const moveHeroImage: (doc: Document) => void;
26
26
  export declare const createBoxedElementSection: (body: Element, createElement: (tagName: string) => HTMLElement) => void;
27
27
  export declare const createBody: (doc: Document, body: Element, createElement: CreateElement) => void;
28
- export declare const createAbstracts: (doc: Document, body: Element, createElement: CreateElement) => void;
28
+ export declare const createAbstracts: (front: Element, body: Element, createElement: CreateElement) => 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;
@@ -86,4 +86,5 @@ export * from './nodes/alt_text';
86
86
  export * from './nodes/long_desc';
87
87
  export * from './nodes/quote_image';
88
88
  export * from './nodes/hero_image';
89
+ export * from './nodes/trans_abstract';
89
90
  export declare const schema: Schema<Nodes, Marks>;
@@ -17,7 +17,6 @@ export declare const list: NodeSpec;
17
17
  export interface ListItemNode extends ManuscriptNode {
18
18
  attrs: {
19
19
  placeholder: string;
20
- id: string;
21
20
  };
22
21
  }
23
22
  export declare const listItem: NodeSpec;
@@ -18,7 +18,6 @@ import { ManuscriptNode } from '../types';
18
18
  export interface TableColNode extends ManuscriptNode {
19
19
  attrs: {
20
20
  width: string;
21
- id: string;
22
21
  };
23
22
  }
24
23
  export declare const tableColGroup: NodeSpec;
@@ -0,0 +1,27 @@
1
+ /*!
2
+ * © 2025 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 type { ManuscriptNode } from '../types';
18
+ export interface TransAbstractAttrs {
19
+ id: string;
20
+ lang: string;
21
+ category: string;
22
+ }
23
+ export interface TransAbstractNode extends ManuscriptNode {
24
+ attrs: TransAbstractAttrs;
25
+ }
26
+ export declare const transAbstract: NodeSpec;
27
+ export declare const isTransAbstractNode: (node: ManuscriptNode) => node is TransAbstractNode;
@@ -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' | 'quote_image' | 'list' | 'caption' | 'caption_title' | 'comment' | 'comments' | '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' | 'keyword_group' | 'keywords' | 'link' | 'list_item' | 'listing' | 'listing_element' | 'manuscript' | 'abstracts' | 'body' | 'backmatter' | 'missing_figure' | 'paragraph' | 'placeholder' | 'placeholder_element' | 'pullquote_element' | 'section' | 'section_label' | 'section_title' | 'section_title_plain' | 'table' | 'table_cell' | 'table_element' | 'table_row' | 'table_colgroup' | 'table_col' | 'table_header' | 'text' | 'text_block' | 'affiliation' | 'contributor' | 'table_element_footer' | 'title' | 'affiliations' | 'contributors' | 'supplements' | 'supplement' | 'author_notes' | 'corresp' | 'general_table_footnote' | 'box_element' | 'awards' | 'award' | 'embed' | 'image_element' | 'attachment' | 'attachments' | 'alt_title' | 'alt_text' | 'alt_titles' | 'long_desc' | 'hero_image';
20
+ export type Nodes = 'attribution' | 'bibliography_item' | 'bibliography_element' | 'bibliography_section' | 'blockquote_element' | 'quote_image' | 'list' | 'caption' | 'caption_title' | 'comment' | 'comments' | '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' | 'keyword_group' | 'keywords' | 'link' | 'list_item' | 'listing' | 'listing_element' | 'manuscript' | 'abstracts' | 'body' | 'backmatter' | 'missing_figure' | 'paragraph' | 'placeholder' | 'placeholder_element' | 'pullquote_element' | 'section' | 'section_label' | 'section_title' | 'section_title_plain' | 'table' | 'table_cell' | 'table_element' | 'table_row' | 'table_colgroup' | 'table_col' | 'table_header' | 'text' | 'text_block' | 'affiliation' | 'contributor' | 'table_element_footer' | 'title' | 'affiliations' | 'contributors' | 'supplements' | 'supplement' | 'author_notes' | 'corresp' | 'general_table_footnote' | 'box_element' | 'awards' | 'award' | 'embed' | 'image_element' | 'attachment' | 'attachments' | 'alt_title' | 'alt_text' | 'alt_titles' | 'long_desc' | 'hero_image' | 'trans_abstract';
21
21
  export type ManuscriptSchema = Schema<Nodes, Marks>;
22
22
  export type ManuscriptEditorState = EditorState;
23
23
  export type ManuscriptEditorView = EditorView;
@@ -1 +1 @@
1
- export declare const VERSION = "3.0.68-comparison-test.1";
1
+ export declare const VERSION = "3.0.69";
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.68-comparison-test.1",
4
+ "version": "3.0.69",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-transform",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",