@manuscripts/transform 4.4.0 → 4.4.2

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 (67) hide show
  1. package/dist/cjs/jats/exporter/jats-exporter.js +20 -6
  2. package/dist/cjs/jats/importer/jats-dom-parser.js +51 -2
  3. package/dist/cjs/jats/importer/jats-transformations.js +1 -1
  4. package/dist/cjs/schema/index.js +9 -0
  5. package/dist/cjs/schema/migration/migration-scripts/4.4.2.js +44 -0
  6. package/dist/cjs/schema/migration/migration-scripts/index.js +2 -0
  7. package/dist/cjs/schema/nodes/box_element.js +4 -0
  8. package/dist/cjs/schema/nodes/headshot_element.js +38 -0
  9. package/dist/cjs/schema/nodes/headshot_grid.js +37 -0
  10. package/dist/cjs/schema/nodes/headshot_image.js +51 -0
  11. package/dist/cjs/schema/nodes/hero_image.js +2 -0
  12. package/dist/cjs/schema/nodes/pullquote_element.js +4 -0
  13. package/dist/cjs/schema/nodes/table_element.js +9 -8
  14. package/dist/cjs/transformer/node-names.js +2 -0
  15. package/dist/cjs/transformer/node-title.js +6 -0
  16. package/dist/cjs/version.js +1 -1
  17. package/dist/es/jats/exporter/jats-exporter.js +20 -6
  18. package/dist/es/jats/importer/jats-dom-parser.js +51 -2
  19. package/dist/es/jats/importer/jats-transformations.js +1 -1
  20. package/dist/es/schema/index.js +9 -0
  21. package/dist/es/schema/migration/migration-scripts/4.4.2.js +42 -0
  22. package/dist/es/schema/migration/migration-scripts/index.js +2 -0
  23. package/dist/es/schema/nodes/box_element.js +4 -0
  24. package/dist/es/schema/nodes/headshot_element.js +34 -0
  25. package/dist/es/schema/nodes/headshot_grid.js +33 -0
  26. package/dist/es/schema/nodes/headshot_image.js +48 -0
  27. package/dist/es/schema/nodes/hero_image.js +2 -0
  28. package/dist/es/schema/nodes/pullquote_element.js +4 -0
  29. package/dist/es/schema/nodes/table_element.js +9 -8
  30. package/dist/es/transformer/node-names.js +2 -0
  31. package/dist/es/transformer/node-title.js +6 -0
  32. package/dist/es/version.js +1 -1
  33. package/dist/types/schema/index.d.ts +3 -0
  34. package/dist/types/schema/migration/migration-scripts/4.4.2.d.ts +8 -0
  35. package/dist/types/schema/migration/migration-scripts/index.d.ts +2 -1
  36. package/dist/types/schema/nodes/blockquote_element.d.ts +2 -3
  37. package/dist/types/schema/nodes/box_element.d.ts +1 -0
  38. package/dist/types/schema/nodes/headshot_element.d.ts +25 -0
  39. package/dist/types/schema/nodes/headshot_grid.d.ts +24 -0
  40. package/dist/types/schema/nodes/headshot_image.d.ts +26 -0
  41. package/dist/types/schema/nodes/hero_image.d.ts +1 -0
  42. package/dist/types/schema/nodes/pullquote_element.d.ts +3 -2
  43. package/dist/types/schema/nodes/table_element.d.ts +1 -0
  44. package/dist/types/schema/types.d.ts +1 -1
  45. package/dist/types/version.d.ts +1 -1
  46. package/package.json +2 -1
  47. package/src/jats/__tests__/__fixtures__/jats-import.xml +34 -2
  48. package/src/jats/__tests__/__snapshots__/jats-importer.test.ts.snap +350 -0
  49. package/src/jats/__tests__/__snapshots__/jats-roundtrip.test.ts.snap +1 -1
  50. package/src/jats/exporter/jats-exporter.ts +24 -6
  51. package/src/jats/importer/jats-dom-parser.ts +57 -3
  52. package/src/jats/importer/jats-transformations.ts +1 -1
  53. package/src/schema/index.ts +10 -1
  54. package/src/schema/migration/migration-scripts/4.4.2.ts +60 -0
  55. package/src/schema/migration/migration-scripts/index.ts +2 -0
  56. package/src/schema/nodes/blockquote_element.ts +3 -3
  57. package/src/schema/nodes/box_element.ts +6 -0
  58. package/src/schema/nodes/headshot_element.ts +48 -0
  59. package/src/schema/nodes/headshot_grid.ts +46 -0
  60. package/src/schema/nodes/headshot_image.ts +65 -0
  61. package/src/schema/nodes/hero_image.ts +3 -0
  62. package/src/schema/nodes/pullquote_element.ts +9 -3
  63. package/src/schema/nodes/table_element.ts +12 -8
  64. package/src/schema/types.ts +3 -0
  65. package/src/transformer/node-names.ts +2 -0
  66. package/src/transformer/node-title.ts +5 -0
  67. package/src/version.ts +1 -1
@@ -473,6 +473,9 @@ class JATSExporter {
473
473
  return ['trans-abstract', attrs, 0];
474
474
  },
475
475
  hero_image: () => '',
476
+ headshot_grid: () => ['p', { 'content-type': 'headshots' }, 0],
477
+ headshot_element: (node) => createImage(node),
478
+ headshot_image: () => '',
476
479
  alt_text: (node) => {
477
480
  if (node.textContent) {
478
481
  const altText = this.createElement('alt-text');
@@ -719,11 +722,11 @@ class JATSExporter {
719
722
  return this.createElement('boxed-text');
720
723
  },
721
724
  pullquote_element: (node) => {
722
- let type = 'pullquote';
723
- if (node.firstChild?.type === schema_1.schema.nodes.quote_image) {
724
- type = 'quote-with-image';
725
+ const attrs = {};
726
+ if (node.attrs.type) {
727
+ attrs['content-type'] = node.attrs.type;
725
728
  }
726
- return ['disp-quote', { 'content-type': type }, 0];
729
+ return ['disp-quote', attrs, 0];
727
730
  },
728
731
  quote_image: (node) => {
729
732
  const img = node;
@@ -757,6 +760,9 @@ class JATSExporter {
757
760
  table_element: (node) => {
758
761
  const element = createTableElement(node);
759
762
  element.setAttribute('position', 'anchor');
763
+ if (node.attrs.type) {
764
+ element.setAttribute('content-type', node.attrs.type);
765
+ }
760
766
  return element;
761
767
  },
762
768
  table_cell: (node) => [
@@ -870,6 +876,9 @@ class JATSExporter {
870
876
  };
871
877
  const createBoxElement = (node) => {
872
878
  const element = createElement(node, 'boxed-text');
879
+ if (node.attrs.type) {
880
+ element.setAttribute('content-type', node.attrs.type);
881
+ }
873
882
  appendLabels(element, node);
874
883
  const child = node.firstChild;
875
884
  if (child?.type === schema_1.schema.nodes.caption_title) {
@@ -885,6 +894,10 @@ class JATSExporter {
885
894
  return !!result;
886
895
  });
887
896
  };
897
+ const findParentHeroImage = (targetID) => {
898
+ const heroes = this.getChildrenOfType(schema_1.schema.nodes.hero_image);
899
+ return heroes.find((hero) => !!(0, prosemirror_utils_1.findChildrenByAttr)(hero, (attrs) => attrs.id === targetID)[0]);
900
+ };
888
901
  const createImage = (node) => {
889
902
  const graphicNode = node.content.firstChild;
890
903
  if (!graphicNode) {
@@ -903,8 +916,9 @@ class JATSExporter {
903
916
  const createGraphic = (node) => {
904
917
  const graphic = this.createElement('graphic');
905
918
  graphic.setAttributeNS(xml_1.XLINK_NAMESPACE, 'xlink:href', node.attrs.src);
906
- if (isChildOfNodeType(node.attrs.id, schema_1.schema.nodes.hero_image)) {
907
- graphic.setAttribute('content-type', 'leading');
919
+ const hero = findParentHeroImage(node.attrs.id);
920
+ if (hero) {
921
+ graphic.setAttribute('content-type', hero.attrs.type || 'leading');
908
922
  }
909
923
  else if (!isChildOfNodeType(node.attrs.id, schema_1.schema.nodes.figure_element) &&
910
924
  node.attrs.type) {
@@ -483,7 +483,7 @@ class JATSDOMParser {
483
483
  {
484
484
  tag: 'caption',
485
485
  node: 'caption',
486
- context: 'listing_element/|embed/|supplement/',
486
+ context: 'listing_element/|embed/|supplement/|headshot_element/',
487
487
  getContent: (node) => {
488
488
  const element = node;
489
489
  const title = element.querySelector('title');
@@ -551,6 +551,7 @@ class JATSDOMParser {
551
551
  const element = node;
552
552
  return {
553
553
  id: element.getAttribute('id'),
554
+ type: element.getAttribute('content-type'),
554
555
  };
555
556
  },
556
557
  },
@@ -604,6 +605,42 @@ class JATSDOMParser {
604
605
  };
605
606
  },
606
607
  },
608
+ {
609
+ tag: 'graphic',
610
+ node: 'headshot_image',
611
+ context: 'headshot_element/',
612
+ getAttrs: this.getFigAttrs,
613
+ },
614
+ {
615
+ tag: 'graphic',
616
+ node: 'headshot_element',
617
+ context: 'headshot_grid/',
618
+ getContent: (node) => {
619
+ const element = node;
620
+ const innerGraphic = element.cloneNode(false);
621
+ const wrapper = element.ownerDocument.createElement('div');
622
+ wrapper.appendChild(innerGraphic);
623
+ const caption = element.querySelector('caption');
624
+ if (caption)
625
+ wrapper.appendChild(caption);
626
+ const altText = element.querySelector('alt-text');
627
+ if (altText) {
628
+ if (altText.childNodes.length === 0) {
629
+ const title = caption?.querySelector(':scope > title');
630
+ if (title) {
631
+ altText.append(...Array.from(title.childNodes).map(n => n.cloneNode(true)));
632
+ }
633
+ }
634
+ wrapper.appendChild(altText);
635
+ }
636
+ const longDesc = element.querySelector('long-desc');
637
+ if (longDesc)
638
+ wrapper.appendChild(longDesc);
639
+ return this.parse(wrapper, {
640
+ topNode: this.schema.nodes.headshot_element.create(),
641
+ }).content;
642
+ }
643
+ },
607
644
  {
608
645
  tag: 'graphic[specific-use=MISSING]',
609
646
  node: 'missing_figure',
@@ -615,8 +652,14 @@ class JATSDOMParser {
615
652
  },
616
653
  },
617
654
  {
618
- tag: 'graphic[content-type=leading]',
655
+ tag: 'graphic[content-type^=leading]',
619
656
  node: 'hero_image',
657
+ getAttrs: (node) => {
658
+ const element = node;
659
+ return {
660
+ type: element.getAttribute('content-type'),
661
+ };
662
+ },
620
663
  getContent: this.getFigContent,
621
664
  },
622
665
  {
@@ -728,6 +771,10 @@ class JATSDOMParser {
728
771
  tag: 'list-item',
729
772
  node: 'list_item',
730
773
  },
774
+ {
775
+ tag: 'p[content-type="headshots"]',
776
+ node: 'headshot_grid',
777
+ },
731
778
  {
732
779
  tag: 'p',
733
780
  node: 'paragraph',
@@ -826,6 +873,7 @@ class JATSDOMParser {
826
873
  const element = node;
827
874
  return {
828
875
  id: element.getAttribute('id'),
876
+ type: element.getAttribute('content-type') ?? '',
829
877
  };
830
878
  },
831
879
  },
@@ -919,6 +967,7 @@ class JATSDOMParser {
919
967
  const element = node;
920
968
  return {
921
969
  id: element.getAttribute('id'),
970
+ type: element.getAttribute('content-type') ?? '',
922
971
  };
923
972
  },
924
973
  },
@@ -125,7 +125,7 @@ const moveAbstracts = (front, group, createElement, sectionCategories) => {
125
125
  };
126
126
  exports.moveAbstracts = moveAbstracts;
127
127
  const moveHeroImage = (doc) => {
128
- const heroImage = doc.querySelector('graphic[content-type="leading"]');
128
+ const heroImage = doc.querySelector('graphic[content-type^="leading"]');
129
129
  if (!heroImage) {
130
130
  return;
131
131
  }
@@ -74,6 +74,9 @@ const general_table_footnote_1 = require("./nodes/general_table_footnote");
74
74
  const graphical_abstract_section_1 = require("./nodes/graphical_abstract_section");
75
75
  const hard_break_1 = require("./nodes/hard_break");
76
76
  const hero_image_1 = require("./nodes/hero_image");
77
+ const headshot_grid_1 = require("./nodes/headshot_grid");
78
+ const headshot_element_1 = require("./nodes/headshot_element");
79
+ const headshot_image_1 = require("./nodes/headshot_image");
77
80
  const highlight_marker_1 = require("./nodes/highlight_marker");
78
81
  const image_element_1 = require("./nodes/image_element");
79
82
  const inline_equation_1 = require("./nodes/inline_equation");
@@ -148,6 +151,9 @@ __exportStar(require("./nodes/general_table_footnote"), exports);
148
151
  __exportStar(require("./nodes/graphical_abstract_section"), exports);
149
152
  __exportStar(require("./nodes/hard_break"), exports);
150
153
  __exportStar(require("./nodes/hero_image"), exports);
154
+ __exportStar(require("./nodes/headshot_grid"), exports);
155
+ __exportStar(require("./nodes/headshot_element"), exports);
156
+ __exportStar(require("./nodes/headshot_image"), exports);
151
157
  __exportStar(require("./nodes/highlight_marker"), exports);
152
158
  __exportStar(require("./nodes/image_element"), exports);
153
159
  __exportStar(require("./nodes/inline_equation"), exports);
@@ -278,6 +284,9 @@ exports.schema = new prosemirror_model_1.Schema({
278
284
  long_desc: long_desc_1.longDesc,
279
285
  quote_image: quote_image_1.quoteImage,
280
286
  hero_image: hero_image_1.heroImage,
287
+ headshot_grid: headshot_grid_1.headshotGrid,
288
+ headshot_element: headshot_element_1.headshotElement,
289
+ headshot_image: headshot_image_1.headshotImage,
281
290
  trans_abstract: trans_abstract_1.transAbstract,
282
291
  trans_graphical_abstract: trans_graphical_abstract_1.transGraphicalAbstract,
283
292
  subtitle: subtitle_1.subtitle,
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class Migration442 {
4
+ constructor() {
5
+ this.fromVersion = '4.4.1';
6
+ this.toVersion = '4.4.2';
7
+ }
8
+ migrateNode(node) {
9
+ switch (node.type) {
10
+ case 'hero_image':
11
+ if (!node.attrs || node.attrs.type === undefined) {
12
+ return {
13
+ ...node,
14
+ attrs: { ...(node.attrs ?? {}), type: 'leading' },
15
+ };
16
+ }
17
+ return node;
18
+ case 'pullquote_element':
19
+ if (!node.attrs || node.attrs.type === undefined) {
20
+ const hasImage = node.content?.[0]?.type === 'quote_image';
21
+ return {
22
+ ...node,
23
+ attrs: {
24
+ ...(node.attrs ?? {}),
25
+ type: hasImage ? 'quote-with-image' : 'pullquote',
26
+ },
27
+ };
28
+ }
29
+ return node;
30
+ case 'box_element':
31
+ case 'table_element':
32
+ if (!node.attrs || node.attrs.type === undefined) {
33
+ return {
34
+ ...node,
35
+ attrs: { ...(node.attrs ?? {}), type: '' },
36
+ };
37
+ }
38
+ return node;
39
+ default:
40
+ return node;
41
+ }
42
+ }
43
+ }
44
+ exports.default = Migration442;
@@ -32,6 +32,7 @@ const _4_2_15_1 = __importDefault(require("./4.2.15"));
32
32
  const _4_3_23_1 = __importDefault(require("./4.3.23"));
33
33
  const _4_3_34_1 = __importDefault(require("./4.3.34"));
34
34
  const _4_3_35_1 = __importDefault(require("./4.3.35"));
35
+ const _4_4_2_1 = __importDefault(require("./4.4.2"));
35
36
  const migrations = [
36
37
  new _1_2_5_1.default(),
37
38
  new _2_3_22_1.default(),
@@ -47,5 +48,6 @@ const migrations = [
47
48
  new _4_3_23_1.default(),
48
49
  new _4_3_34_1.default(),
49
50
  new _4_3_35_1.default(),
51
+ new _4_4_2_1.default(),
50
52
  ];
51
53
  exports.default = migrations;
@@ -20,6 +20,7 @@ exports.box_element = {
20
20
  content: 'caption_title? caption? section?',
21
21
  attrs: {
22
22
  id: { default: '' },
23
+ type: { default: '' },
23
24
  dataTracked: { default: null },
24
25
  },
25
26
  group: 'block element',
@@ -42,6 +43,9 @@ exports.box_element = {
42
43
  if (boxElementNode.attrs.id) {
43
44
  attrs.id = boxElementNode.attrs.id;
44
45
  }
46
+ if (boxElementNode.attrs.type) {
47
+ attrs['data-content-type'] = boxElementNode.attrs.type;
48
+ }
45
49
  return [
46
50
  'div',
47
51
  {
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ /*!
3
+ * © 2026 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.isHeadshotElementNode = exports.headshotElement = void 0;
19
+ exports.headshotElement = {
20
+ content: 'headshot_image caption_title caption alt_text long_desc',
21
+ attrs: {
22
+ id: { default: '' },
23
+ type: { default: '' },
24
+ dataTracked: { default: null },
25
+ },
26
+ group: 'block',
27
+ toDOM: (node) => {
28
+ return [
29
+ 'div',
30
+ {
31
+ class: 'headshot_element',
32
+ id: node.attrs.id,
33
+ },
34
+ ];
35
+ },
36
+ };
37
+ const isHeadshotElementNode = (node) => node.type === node.type.schema.nodes.headshot_element;
38
+ exports.isHeadshotElementNode = isHeadshotElementNode;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ /*!
3
+ * © 2026 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.isHeadshotGridNode = exports.headshotGrid = void 0;
19
+ exports.headshotGrid = {
20
+ content: 'headshot_element*',
21
+ attrs: {
22
+ id: { default: '' },
23
+ dataTracked: { default: null },
24
+ },
25
+ group: 'block element',
26
+ toDOM: (node) => {
27
+ return [
28
+ 'div',
29
+ {
30
+ class: 'headshot_grid',
31
+ id: node.attrs.id,
32
+ },
33
+ ];
34
+ },
35
+ };
36
+ const isHeadshotGridNode = (node) => node.type === node.type.schema.nodes.headshot_grid;
37
+ exports.isHeadshotGridNode = isHeadshotGridNode;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ /*!
3
+ * © 2026 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.headshotImage = void 0;
19
+ exports.headshotImage = {
20
+ attrs: {
21
+ id: { default: '' },
22
+ src: { default: '' },
23
+ type: { default: '' },
24
+ dataTracked: { default: null },
25
+ },
26
+ selectable: false,
27
+ group: 'block',
28
+ parseDOM: [
29
+ {
30
+ tag: 'figure',
31
+ context: 'headshot_element/',
32
+ getAttrs: (dom) => {
33
+ const element = dom;
34
+ return {
35
+ id: element.getAttribute('id'),
36
+ src: element.getAttribute('src'),
37
+ };
38
+ },
39
+ },
40
+ ],
41
+ toDOM: (node) => {
42
+ const imageNode = node;
43
+ return [
44
+ 'figure',
45
+ {
46
+ class: 'headshot-figure',
47
+ id: imageNode.attrs.id,
48
+ },
49
+ ];
50
+ },
51
+ };
@@ -20,6 +20,7 @@ exports.heroImage = {
20
20
  content: 'figure? alt_text long_desc',
21
21
  attrs: {
22
22
  id: { default: '' },
23
+ type: { default: 'leading' },
23
24
  dataTracked: { default: null },
24
25
  },
25
26
  group: 'block element',
@@ -29,6 +30,7 @@ exports.heroImage = {
29
30
  {
30
31
  class: 'hero_image',
31
32
  id: node.attrs.id,
33
+ 'data-content-type': node.attrs.type,
32
34
  },
33
35
  ];
34
36
  },
@@ -21,6 +21,7 @@ exports.pullquoteElement = {
21
21
  attrs: {
22
22
  id: { default: '' },
23
23
  placeholder: { default: '' },
24
+ type: { default: '' },
24
25
  dataTracked: { default: null },
25
26
  },
26
27
  group: 'block element',
@@ -51,6 +52,9 @@ exports.pullquoteElement = {
51
52
  if (pullquoteElementNode.attrs.placeholder) {
52
53
  attrs['data-placeholder-text'] = pullquoteElementNode.attrs.placeholder;
53
54
  }
55
+ if (pullquoteElementNode.attrs.type) {
56
+ attrs['data-content-type'] = pullquoteElementNode.attrs.type;
57
+ }
54
58
  return ['aside', attrs, 0];
55
59
  },
56
60
  };
@@ -20,6 +20,7 @@ exports.tableElement = {
20
20
  content: 'caption_title (table | placeholder) table_colgroup? table_element_footer? alt_text long_desc (listing | placeholder)',
21
21
  attrs: {
22
22
  id: { default: '' },
23
+ type: { default: '' },
23
24
  dataTracked: { default: null },
24
25
  },
25
26
  selectable: false,
@@ -37,14 +38,14 @@ exports.tableElement = {
37
38
  ],
38
39
  toDOM: (node) => {
39
40
  const tableElementNode = node;
40
- return [
41
- 'figure',
42
- {
43
- class: 'table',
44
- id: tableElementNode.attrs.id,
45
- },
46
- 0,
47
- ];
41
+ const attrs = {
42
+ class: 'table',
43
+ id: tableElementNode.attrs.id,
44
+ };
45
+ if (tableElementNode.attrs.type) {
46
+ attrs['data-content-type'] = tableElementNode.attrs.type;
47
+ }
48
+ return ['figure', attrs, 0];
48
49
  },
49
50
  };
50
51
  const isTableElementNode = (node) => node.type === node.type.schema.nodes.table_element;
@@ -32,6 +32,8 @@ exports.nodeNames = new Map([
32
32
  [schema_1.schema.nodes.figure_element, 'Figure'],
33
33
  [schema_1.schema.nodes.image_element, 'Image'],
34
34
  [schema_1.schema.nodes.hero_image, 'Hero Image'],
35
+ [schema_1.schema.nodes.headshot_grid, 'Headshot Panel'],
36
+ [schema_1.schema.nodes.headshot_element, 'Headshot'],
35
37
  [schema_1.schema.nodes.table_element, 'Table'],
36
38
  [schema_1.schema.nodes.table_cell, 'Table Cell'],
37
39
  [schema_1.schema.nodes.table_col, 'Table Column'],
@@ -28,6 +28,11 @@ const textSnippet = (node, max = 100) => {
28
28
  else if ((0, schema_1.isHighlightMarkerNode)(node)) {
29
29
  text += '';
30
30
  }
31
+ else if (node.type === schema_1.schema.nodes.headshot_element) {
32
+ if (child.type === schema_1.schema.nodes.caption_title) {
33
+ text += child.textContent;
34
+ }
35
+ }
31
36
  else {
32
37
  text += ' ';
33
38
  }
@@ -69,6 +74,7 @@ const nodeTitle = (node) => {
69
74
  case nodes.multi_graphic_figure_element:
70
75
  case nodes.image_element:
71
76
  case nodes.hero_image:
77
+ case nodes.headshot_grid:
72
78
  case nodes.box_element:
73
79
  case nodes.supplements:
74
80
  case nodes.attachments:
@@ -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.4.0";
4
+ exports.VERSION = "4.4.2";
@@ -433,6 +433,9 @@ export class JATSExporter {
433
433
  return ['trans-abstract', attrs, 0];
434
434
  },
435
435
  hero_image: () => '',
436
+ headshot_grid: () => ['p', { 'content-type': 'headshots' }, 0],
437
+ headshot_element: (node) => createImage(node),
438
+ headshot_image: () => '',
436
439
  alt_text: (node) => {
437
440
  if (node.textContent) {
438
441
  const altText = this.createElement('alt-text');
@@ -679,11 +682,11 @@ export class JATSExporter {
679
682
  return this.createElement('boxed-text');
680
683
  },
681
684
  pullquote_element: (node) => {
682
- let type = 'pullquote';
683
- if (node.firstChild?.type === schema.nodes.quote_image) {
684
- type = 'quote-with-image';
685
+ const attrs = {};
686
+ if (node.attrs.type) {
687
+ attrs['content-type'] = node.attrs.type;
685
688
  }
686
- return ['disp-quote', { 'content-type': type }, 0];
689
+ return ['disp-quote', attrs, 0];
687
690
  },
688
691
  quote_image: (node) => {
689
692
  const img = node;
@@ -717,6 +720,9 @@ export class JATSExporter {
717
720
  table_element: (node) => {
718
721
  const element = createTableElement(node);
719
722
  element.setAttribute('position', 'anchor');
723
+ if (node.attrs.type) {
724
+ element.setAttribute('content-type', node.attrs.type);
725
+ }
720
726
  return element;
721
727
  },
722
728
  table_cell: (node) => [
@@ -830,6 +836,9 @@ export class JATSExporter {
830
836
  };
831
837
  const createBoxElement = (node) => {
832
838
  const element = createElement(node, 'boxed-text');
839
+ if (node.attrs.type) {
840
+ element.setAttribute('content-type', node.attrs.type);
841
+ }
833
842
  appendLabels(element, node);
834
843
  const child = node.firstChild;
835
844
  if (child?.type === schema.nodes.caption_title) {
@@ -845,6 +854,10 @@ export class JATSExporter {
845
854
  return !!result;
846
855
  });
847
856
  };
857
+ const findParentHeroImage = (targetID) => {
858
+ const heroes = this.getChildrenOfType(schema.nodes.hero_image);
859
+ return heroes.find((hero) => !!findChildrenByAttr(hero, (attrs) => attrs.id === targetID)[0]);
860
+ };
848
861
  const createImage = (node) => {
849
862
  const graphicNode = node.content.firstChild;
850
863
  if (!graphicNode) {
@@ -863,8 +876,9 @@ export class JATSExporter {
863
876
  const createGraphic = (node) => {
864
877
  const graphic = this.createElement('graphic');
865
878
  graphic.setAttributeNS(XLINK_NAMESPACE, 'xlink:href', node.attrs.src);
866
- if (isChildOfNodeType(node.attrs.id, schema.nodes.hero_image)) {
867
- graphic.setAttribute('content-type', 'leading');
879
+ const hero = findParentHeroImage(node.attrs.id);
880
+ if (hero) {
881
+ graphic.setAttribute('content-type', hero.attrs.type || 'leading');
868
882
  }
869
883
  else if (!isChildOfNodeType(node.attrs.id, schema.nodes.figure_element) &&
870
884
  node.attrs.type) {