@manuscripts/transform 4.5.0 → 4.5.1

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 (36) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/jats/exporter/jats-exporter.js +2 -0
  3. package/dist/cjs/jats/exporter/labels.js +8 -1
  4. package/dist/cjs/jats/importer/jats-dom-parser.js +2 -2
  5. package/dist/cjs/schema/migration/migration-scripts/4.3.35.js +1 -3
  6. package/dist/cjs/schema/migration/migration-scripts/4.4.7.js +26 -0
  7. package/dist/cjs/schema/migration/migration-scripts/index.js +2 -0
  8. package/dist/cjs/schema/nodes/cross_reference.js +3 -0
  9. package/dist/cjs/version.js +1 -1
  10. package/dist/es/jats/exporter/jats-exporter.js +2 -0
  11. package/dist/es/jats/exporter/labels.js +8 -1
  12. package/dist/es/jats/importer/jats-dom-parser.js +2 -2
  13. package/dist/es/schema/migration/migration-scripts/4.3.35.js +1 -3
  14. package/dist/es/schema/migration/migration-scripts/4.4.7.js +24 -0
  15. package/dist/es/schema/migration/migration-scripts/index.js +2 -0
  16. package/dist/es/schema/nodes/cross_reference.js +3 -0
  17. package/dist/es/version.js +1 -1
  18. package/dist/types/jats/exporter/labels.d.ts +1 -0
  19. package/dist/types/schema/migration/migration-scripts/4.4.7.d.ts +8 -0
  20. package/dist/types/schema/migration/migration-scripts/index.d.ts +2 -1
  21. package/dist/types/schema/nodes/cross_reference.d.ts +1 -0
  22. package/dist/types/version.d.ts +1 -1
  23. package/package.json +1 -1
  24. package/src/jats/__tests__/__snapshots__/jats-importer.test.ts.snap +64 -0
  25. package/src/jats/exporter/jats-exporter.ts +4 -1
  26. package/src/jats/exporter/labels.ts +10 -2
  27. package/src/jats/importer/jats-dom-parser.ts +4 -2
  28. package/src/schema/index.ts +0 -1
  29. package/src/schema/migration/migration-scripts/4.3.34.ts +2 -1
  30. package/src/schema/migration/migration-scripts/4.3.35.ts +2 -4
  31. package/src/schema/migration/migration-scripts/4.4.7.ts +44 -0
  32. package/src/schema/migration/migration-scripts/index.ts +2 -0
  33. package/src/schema/nodes/cross_reference.ts +4 -0
  34. package/src/schema/nodes/headshot_element.ts +3 -1
  35. package/src/schema/nodes/headshot_grid.ts +3 -1
  36. package/src/version.ts +1 -1
package/README.md CHANGED
@@ -4,7 +4,7 @@ ProseMirror transformer for Manuscripts applications.
4
4
 
5
5
  It provides a way to import/export [Manuscript JSON Schema](https://gitlab.com/mpapp-public/manuscripts-json-schema) formatted data from and to other formats such as (JATS XML, STS XML, HTML, [ProseMirror Model](https://prosemirror.net/docs/guide/#doc))
6
6
 
7
- # Components
7
+ # Components
8
8
 
9
9
  **Decoder**: converts Manuscript JSON Schema to ProseMirror Model.
10
10
 
@@ -115,6 +115,8 @@ const chooseRefType = (type) => {
115
115
  case schema_1.schema.nodes.equation:
116
116
  case schema_1.schema.nodes.equation_element:
117
117
  return 'disp-formula';
118
+ case schema_1.schema.nodes.supplement:
119
+ return 'supplementary-material';
118
120
  }
119
121
  };
120
122
  const sortContributors = (a, b) => Number(a.attrs.priority) - Number(b.attrs.priority);
@@ -26,7 +26,9 @@ const labelledNodeTypes = [
26
26
  schema_1.schema.nodes.box_element,
27
27
  schema_1.schema.nodes.embed,
28
28
  schema_1.schema.nodes.image_element,
29
+ schema_1.schema.nodes.supplement,
29
30
  ];
31
+ const noLabelTypes = new Set([schema_1.schema.nodes.supplement.name]);
30
32
  const excludedTypes = [
31
33
  schema_1.schema.nodes.graphical_abstract_section,
32
34
  schema_1.schema.nodes.trans_graphical_abstract,
@@ -43,6 +45,9 @@ const buildTargets = (iterator) => {
43
45
  };
44
46
  }
45
47
  const buildLabel = (type) => {
48
+ if (noLabelTypes.has(type.name)) {
49
+ return '';
50
+ }
46
51
  const counter = counters[type.name];
47
52
  counter.index++;
48
53
  return `${counter.label} ${counter.index}`;
@@ -64,7 +69,9 @@ const buildTargets = (iterator) => {
64
69
  type: node.type.name,
65
70
  id: node.attrs.id,
66
71
  label,
67
- caption: node.textContent?.trim(),
72
+ caption: node.textBetween(0, node.content.size, ' ').trim(),
73
+ ...(node.attrs.href && { href: node.attrs.href }),
74
+ ...(node.attrs.extLink && { href: node.attrs.extLink }),
68
75
  });
69
76
  }
70
77
  });
@@ -628,7 +628,7 @@ class JATSDOMParser {
628
628
  if (altText.childNodes.length === 0) {
629
629
  const title = caption?.querySelector(':scope > title');
630
630
  if (title) {
631
- altText.append(...Array.from(title.childNodes).map(n => n.cloneNode(true)));
631
+ altText.append(...Array.from(title.childNodes).map((n) => n.cloneNode(true)));
632
632
  }
633
633
  }
634
634
  wrapper.appendChild(altText);
@@ -639,7 +639,7 @@ class JATSDOMParser {
639
639
  return this.parse(wrapper, {
640
640
  topNode: this.schema.nodes.headshot_element.create(),
641
641
  }).content;
642
- }
642
+ },
643
643
  },
644
644
  {
645
645
  tag: 'graphic[specific-use=MISSING]',
@@ -10,9 +10,7 @@ class Migration4335 {
10
10
  node.type === 'blockquote_element') {
11
11
  return {
12
12
  ...node,
13
- content: (node.content ?? []).map((child) => child.type === 'paragraph'
14
- ? { ...child, type: 'text_block' }
15
- : child),
13
+ content: (node.content ?? []).map((child) => child.type === 'paragraph' ? { ...child, type: 'text_block' } : child),
16
14
  };
17
15
  }
18
16
  return node;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const transformer_1 = require("../../../transformer");
4
+ const index_1 = require("../../index");
5
+ class Migration447 {
6
+ constructor() {
7
+ this.fromVersion = '4.4.6';
8
+ this.toVersion = '4.4.7';
9
+ }
10
+ migrateNode(node) {
11
+ if (node.type !== 'cross_reference') {
12
+ return node;
13
+ }
14
+ if (node.attrs?.id) {
15
+ return node;
16
+ }
17
+ return {
18
+ ...node,
19
+ attrs: {
20
+ ...(node.attrs ?? {}),
21
+ id: (0, transformer_1.generateNodeID)(index_1.schema.nodes.cross_reference),
22
+ },
23
+ };
24
+ }
25
+ }
26
+ exports.default = Migration447;
@@ -33,6 +33,7 @@ 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
35
  const _4_4_2_1 = __importDefault(require("./4.4.2"));
36
+ const _4_4_7_1 = __importDefault(require("./4.4.7"));
36
37
  const migrations = [
37
38
  new _1_2_5_1.default(),
38
39
  new _2_3_22_1.default(),
@@ -49,5 +50,6 @@ const migrations = [
49
50
  new _4_3_34_1.default(),
50
51
  new _4_3_35_1.default(),
51
52
  new _4_4_2_1.default(),
53
+ new _4_4_7_1.default(),
52
54
  ];
53
55
  exports.default = migrations;
@@ -22,6 +22,7 @@ exports.crossReference = {
22
22
  draggable: true,
23
23
  atom: true,
24
24
  attrs: {
25
+ id: { default: '' },
25
26
  rids: { default: [] },
26
27
  label: { default: '' },
27
28
  dataTracked: { default: null },
@@ -32,6 +33,7 @@ exports.crossReference = {
32
33
  getAttrs: (p) => {
33
34
  const dom = p;
34
35
  return {
36
+ id: dom.getAttribute('data-id'),
35
37
  rids: dom.getAttribute('data-reference-id')?.split(/\s+/) || [],
36
38
  };
37
39
  },
@@ -43,6 +45,7 @@ exports.crossReference = {
43
45
  'span',
44
46
  {
45
47
  class: 'cross-reference',
48
+ 'data-id': crossReferenceNode.attrs.id,
46
49
  'data-reference-id': crossReferenceNode.attrs.rids.join(' '),
47
50
  },
48
51
  crossReferenceNode.attrs.label,
@@ -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.5.0";
4
+ exports.VERSION = "4.5.1";
@@ -75,6 +75,8 @@ const chooseRefType = (type) => {
75
75
  case schema.nodes.equation:
76
76
  case schema.nodes.equation_element:
77
77
  return 'disp-formula';
78
+ case schema.nodes.supplement:
79
+ return 'supplementary-material';
78
80
  }
79
81
  };
80
82
  const sortContributors = (a, b) => Number(a.attrs.priority) - Number(b.attrs.priority);
@@ -23,7 +23,9 @@ const labelledNodeTypes = [
23
23
  schema.nodes.box_element,
24
24
  schema.nodes.embed,
25
25
  schema.nodes.image_element,
26
+ schema.nodes.supplement,
26
27
  ];
28
+ const noLabelTypes = new Set([schema.nodes.supplement.name]);
27
29
  const excludedTypes = [
28
30
  schema.nodes.graphical_abstract_section,
29
31
  schema.nodes.trans_graphical_abstract,
@@ -40,6 +42,9 @@ export const buildTargets = (iterator) => {
40
42
  };
41
43
  }
42
44
  const buildLabel = (type) => {
45
+ if (noLabelTypes.has(type.name)) {
46
+ return '';
47
+ }
43
48
  const counter = counters[type.name];
44
49
  counter.index++;
45
50
  return `${counter.label} ${counter.index}`;
@@ -61,7 +66,9 @@ export const buildTargets = (iterator) => {
61
66
  type: node.type.name,
62
67
  id: node.attrs.id,
63
68
  label,
64
- caption: node.textContent?.trim(),
69
+ caption: node.textBetween(0, node.content.size, ' ').trim(),
70
+ ...(node.attrs.href && { href: node.attrs.href }),
71
+ ...(node.attrs.extLink && { href: node.attrs.extLink }),
65
72
  });
66
73
  }
67
74
  });
@@ -625,7 +625,7 @@ export class JATSDOMParser {
625
625
  if (altText.childNodes.length === 0) {
626
626
  const title = caption?.querySelector(':scope > title');
627
627
  if (title) {
628
- altText.append(...Array.from(title.childNodes).map(n => n.cloneNode(true)));
628
+ altText.append(...Array.from(title.childNodes).map((n) => n.cloneNode(true)));
629
629
  }
630
630
  }
631
631
  wrapper.appendChild(altText);
@@ -636,7 +636,7 @@ export class JATSDOMParser {
636
636
  return this.parse(wrapper, {
637
637
  topNode: this.schema.nodes.headshot_element.create(),
638
638
  }).content;
639
- }
639
+ },
640
640
  },
641
641
  {
642
642
  tag: 'graphic[specific-use=MISSING]',
@@ -8,9 +8,7 @@ class Migration4335 {
8
8
  node.type === 'blockquote_element') {
9
9
  return {
10
10
  ...node,
11
- content: (node.content ?? []).map((child) => child.type === 'paragraph'
12
- ? { ...child, type: 'text_block' }
13
- : child),
11
+ content: (node.content ?? []).map((child) => child.type === 'paragraph' ? { ...child, type: 'text_block' } : child),
14
12
  };
15
13
  }
16
14
  return node;
@@ -0,0 +1,24 @@
1
+ import { generateNodeID } from '../../../transformer';
2
+ import { schema } from '../../index';
3
+ class Migration447 {
4
+ constructor() {
5
+ this.fromVersion = '4.4.6';
6
+ this.toVersion = '4.4.7';
7
+ }
8
+ migrateNode(node) {
9
+ if (node.type !== 'cross_reference') {
10
+ return node;
11
+ }
12
+ if (node.attrs?.id) {
13
+ return node;
14
+ }
15
+ return {
16
+ ...node,
17
+ attrs: {
18
+ ...(node.attrs ?? {}),
19
+ id: generateNodeID(schema.nodes.cross_reference),
20
+ },
21
+ };
22
+ }
23
+ }
24
+ export default Migration447;
@@ -28,6 +28,7 @@ import Migration4323 from './4.3.23';
28
28
  import Migration4334 from './4.3.34';
29
29
  import Migration4335 from './4.3.35';
30
30
  import Migration442 from './4.4.2';
31
+ import Migration447 from './4.4.7';
31
32
  const migrations = [
32
33
  new Migration125(),
33
34
  new Migration2322(),
@@ -44,5 +45,6 @@ const migrations = [
44
45
  new Migration4334(),
45
46
  new Migration4335(),
46
47
  new Migration442(),
48
+ new Migration447(),
47
49
  ];
48
50
  export default migrations;
@@ -19,6 +19,7 @@ export const crossReference = {
19
19
  draggable: true,
20
20
  atom: true,
21
21
  attrs: {
22
+ id: { default: '' },
22
23
  rids: { default: [] },
23
24
  label: { default: '' },
24
25
  dataTracked: { default: null },
@@ -29,6 +30,7 @@ export const crossReference = {
29
30
  getAttrs: (p) => {
30
31
  const dom = p;
31
32
  return {
33
+ id: dom.getAttribute('data-id'),
32
34
  rids: dom.getAttribute('data-reference-id')?.split(/\s+/) || [],
33
35
  };
34
36
  },
@@ -40,6 +42,7 @@ export const crossReference = {
40
42
  'span',
41
43
  {
42
44
  class: 'cross-reference',
45
+ 'data-id': crossReferenceNode.attrs.id,
43
46
  'data-reference-id': crossReferenceNode.attrs.rids.join(' '),
44
47
  },
45
48
  crossReferenceNode.attrs.label,
@@ -1 +1 @@
1
- export const VERSION = "4.5.0";
1
+ export const VERSION = "4.5.1";
@@ -19,6 +19,7 @@ export interface Target {
19
19
  id: string;
20
20
  label: string;
21
21
  caption: string;
22
+ href?: string;
22
23
  }
23
24
  type iterator = (node: ManuscriptNode, pos: number, parent: ManuscriptNode | null, index: number) => void | boolean;
24
25
  export declare const buildTargets: (iterator: (fn: iterator) => void) => Map<string, Target>;
@@ -0,0 +1,8 @@
1
+ import { JSONProsemirrorNode } from '../../../types';
2
+ import { MigrationScript } from '../migration-script';
3
+ declare class Migration447 implements MigrationScript {
4
+ fromVersion: string;
5
+ toVersion: string;
6
+ migrateNode(node: JSONProsemirrorNode): JSONProsemirrorNode;
7
+ }
8
+ export default Migration447;
@@ -28,5 +28,6 @@ import Migration4323 from './4.3.23';
28
28
  import Migration4334 from './4.3.34';
29
29
  import Migration4335 from './4.3.35';
30
30
  import Migration442 from './4.4.2';
31
- declare const migrations: (Migration125 | Migration2322 | Migration3012 | Migration3021 | Migration3030 | Migration3031 | Migration3041 | Migration3055 | Migration3056 | Migration4213 | Migration4215 | Migration4323 | Migration4334 | Migration4335 | Migration442)[];
31
+ import Migration447 from './4.4.7';
32
+ declare const migrations: (Migration125 | Migration2322 | Migration3012 | Migration3021 | Migration3030 | Migration3031 | Migration3041 | Migration3055 | Migration3056 | Migration4213 | Migration4215 | Migration4323 | Migration4334 | Migration4335 | Migration442 | Migration447)[];
32
33
  export default migrations;
@@ -16,6 +16,7 @@
16
16
  import { NodeSpec } from 'prosemirror-model';
17
17
  import { ManuscriptNode } from '../types';
18
18
  interface Attrs {
19
+ id: string;
19
20
  rids: string[];
20
21
  label: string;
21
22
  }
@@ -1 +1 @@
1
- export declare const VERSION = "4.5.0";
1
+ export declare const VERSION = "4.5.1";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@manuscripts/transform",
3
3
  "description": "ProseMirror transformer for Manuscripts applications",
4
- "version": "4.5.0",
4
+ "version": "4.5.1",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-transform",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -5395,6 +5395,7 @@ Object {
5395
5395
  Object {
5396
5396
  "attrs": Object {
5397
5397
  "dataTracked": null,
5398
+ "id": "MPCrossReference:test",
5398
5399
  "label": "",
5399
5400
  "rids": Array [
5400
5401
  "MPTableElement:test",
@@ -5425,6 +5426,7 @@ Object {
5425
5426
  Object {
5426
5427
  "attrs": Object {
5427
5428
  "dataTracked": null,
5429
+ "id": "MPCrossReference:test",
5428
5430
  "label": "",
5429
5431
  "rids": Array [
5430
5432
  "MPTableElement:test",
@@ -5439,6 +5441,7 @@ Object {
5439
5441
  Object {
5440
5442
  "attrs": Object {
5441
5443
  "dataTracked": null,
5444
+ "id": "MPCrossReference:test",
5442
5445
  "label": "",
5443
5446
  "rids": Array [
5444
5447
  "MPTableElement:test",
@@ -17948,6 +17951,7 @@ Object {
17948
17951
  Object {
17949
17952
  "attrs": Object {
17950
17953
  "dataTracked": null,
17954
+ "id": "MPCrossReference:test",
17951
17955
  "label": "",
17952
17956
  "rids": Array [
17953
17957
  "MPTableElement:test",
@@ -18030,6 +18034,7 @@ Object {
18030
18034
  Object {
18031
18035
  "attrs": Object {
18032
18036
  "dataTracked": null,
18037
+ "id": "MPCrossReference:test",
18033
18038
  "label": "",
18034
18039
  "rids": Array [
18035
18040
  "MPFigureElement:test",
@@ -18242,6 +18247,7 @@ Object {
18242
18247
  Object {
18243
18248
  "attrs": Object {
18244
18249
  "dataTracked": null,
18250
+ "id": "MPCrossReference:test",
18245
18251
  "label": "",
18246
18252
  "rids": Array [
18247
18253
  "MPFigureElement:test",
@@ -18434,6 +18440,7 @@ Object {
18434
18440
  Object {
18435
18441
  "attrs": Object {
18436
18442
  "dataTracked": null,
18443
+ "id": "MPCrossReference:test",
18437
18444
  "label": "",
18438
18445
  "rids": Array [
18439
18446
  "MPTableElement:test",
@@ -18484,6 +18491,7 @@ Object {
18484
18491
  Object {
18485
18492
  "attrs": Object {
18486
18493
  "dataTracked": null,
18494
+ "id": "MPCrossReference:test",
18487
18495
  "label": "",
18488
18496
  "rids": Array [
18489
18497
  "MPTableElement:test",
@@ -18534,6 +18542,7 @@ Object {
18534
18542
  Object {
18535
18543
  "attrs": Object {
18536
18544
  "dataTracked": null,
18545
+ "id": "MPCrossReference:test",
18537
18546
  "label": "",
18538
18547
  "rids": Array [
18539
18548
  "MPTableElement:test",
@@ -18548,6 +18557,7 @@ Object {
18548
18557
  Object {
18549
18558
  "attrs": Object {
18550
18559
  "dataTracked": null,
18560
+ "id": "MPCrossReference:test",
18551
18561
  "label": "",
18552
18562
  "rids": Array [
18553
18563
  "MPTableElement:test",
@@ -18630,6 +18640,7 @@ Object {
18630
18640
  Object {
18631
18641
  "attrs": Object {
18632
18642
  "dataTracked": null,
18643
+ "id": "MPCrossReference:test",
18633
18644
  "label": "",
18634
18645
  "rids": Array [
18635
18646
  "MPFigureElement:test",
@@ -18644,6 +18655,7 @@ Object {
18644
18655
  Object {
18645
18656
  "attrs": Object {
18646
18657
  "dataTracked": null,
18658
+ "id": "MPCrossReference:test",
18647
18659
  "label": "",
18648
18660
  "rids": Array [
18649
18661
  "MPFigureElement:test",
@@ -18709,6 +18721,7 @@ Object {
18709
18721
  Object {
18710
18722
  "attrs": Object {
18711
18723
  "dataTracked": null,
18724
+ "id": "MPCrossReference:test",
18712
18725
  "label": "",
18713
18726
  "rids": Array [
18714
18727
  "MPFigureElement:test",
@@ -18831,6 +18844,7 @@ Object {
18831
18844
  Object {
18832
18845
  "attrs": Object {
18833
18846
  "dataTracked": null,
18847
+ "id": "MPCrossReference:test",
18834
18848
  "label": "",
18835
18849
  "rids": Array [
18836
18850
  "MPTableElement:test",
@@ -18933,6 +18947,7 @@ Object {
18933
18947
  Object {
18934
18948
  "attrs": Object {
18935
18949
  "dataTracked": null,
18950
+ "id": "MPCrossReference:test",
18936
18951
  "label": "",
18937
18952
  "rids": Array [
18938
18953
  "MPFigureElement:test",
@@ -23345,6 +23360,7 @@ Object {
23345
23360
  Object {
23346
23361
  "attrs": Object {
23347
23362
  "dataTracked": null,
23363
+ "id": "MPCrossReference:test",
23348
23364
  "label": "",
23349
23365
  "rids": Array [
23350
23366
  "MPFigureElement:test",
@@ -23359,6 +23375,7 @@ Object {
23359
23375
  Object {
23360
23376
  "attrs": Object {
23361
23377
  "dataTracked": null,
23378
+ "id": "MPCrossReference:test",
23362
23379
  "label": "",
23363
23380
  "rids": Array [
23364
23381
  "MPTableElement:test",
@@ -27220,6 +27237,7 @@ Object {
27220
27237
  Object {
27221
27238
  "attrs": Object {
27222
27239
  "dataTracked": null,
27240
+ "id": "MPCrossReference:test",
27223
27241
  "label": "",
27224
27242
  "rids": Array [
27225
27243
  "MPFigureElement:test",
@@ -27375,6 +27393,7 @@ Object {
27375
27393
  Object {
27376
27394
  "attrs": Object {
27377
27395
  "dataTracked": null,
27396
+ "id": "MPCrossReference:test",
27378
27397
  "label": "",
27379
27398
  "rids": Array [
27380
27399
  "MPFigureElement:test",
@@ -27669,6 +27688,7 @@ Object {
27669
27688
  Object {
27670
27689
  "attrs": Object {
27671
27690
  "dataTracked": null,
27691
+ "id": "MPCrossReference:test",
27672
27692
  "label": "",
27673
27693
  "rids": Array [
27674
27694
  "MPTableElement:test",
@@ -31338,6 +31358,7 @@ Object {
31338
31358
  Object {
31339
31359
  "attrs": Object {
31340
31360
  "dataTracked": null,
31361
+ "id": "MPCrossReference:test",
31341
31362
  "label": "",
31342
31363
  "rids": Array [
31343
31364
  "eq1",
@@ -31352,6 +31373,7 @@ Object {
31352
31373
  Object {
31353
31374
  "attrs": Object {
31354
31375
  "dataTracked": null,
31376
+ "id": "MPCrossReference:test",
31355
31377
  "label": "",
31356
31378
  "rids": Array [
31357
31379
  "MPFigureElement:test",
@@ -31687,6 +31709,7 @@ Object {
31687
31709
  Object {
31688
31710
  "attrs": Object {
31689
31711
  "dataTracked": null,
31712
+ "id": "MPCrossReference:test",
31690
31713
  "label": "",
31691
31714
  "rids": Array [
31692
31715
  "MPBoxElement:test",
@@ -31701,6 +31724,7 @@ Object {
31701
31724
  Object {
31702
31725
  "attrs": Object {
31703
31726
  "dataTracked": null,
31727
+ "id": "MPCrossReference:test",
31704
31728
  "label": "",
31705
31729
  "rids": Array [
31706
31730
  "appA",
@@ -31835,6 +31859,7 @@ Object {
31835
31859
  Object {
31836
31860
  "attrs": Object {
31837
31861
  "dataTracked": null,
31862
+ "id": "MPCrossReference:test",
31838
31863
  "label": "",
31839
31864
  "rids": Array [
31840
31865
  "tbl1",
@@ -35119,6 +35144,7 @@ Object {
35119
35144
  Object {
35120
35145
  "attrs": Object {
35121
35146
  "dataTracked": null,
35147
+ "id": "MPCrossReference:test",
35122
35148
  "label": "",
35123
35149
  "rids": Array [
35124
35150
  "MPFigureElement:test",
@@ -35133,6 +35159,7 @@ Object {
35133
35159
  Object {
35134
35160
  "attrs": Object {
35135
35161
  "dataTracked": null,
35162
+ "id": "MPCrossReference:test",
35136
35163
  "label": "",
35137
35164
  "rids": Array [
35138
35165
  "MPTableElement:test",
@@ -39018,6 +39045,7 @@ Object {
39018
39045
  Object {
39019
39046
  "attrs": Object {
39020
39047
  "dataTracked": null,
39048
+ "id": "MPCrossReference:test",
39021
39049
  "label": "",
39022
39050
  "rids": Array [
39023
39051
  "MPFigureElement:test",
@@ -39173,6 +39201,7 @@ Object {
39173
39201
  Object {
39174
39202
  "attrs": Object {
39175
39203
  "dataTracked": null,
39204
+ "id": "MPCrossReference:test",
39176
39205
  "label": "",
39177
39206
  "rids": Array [
39178
39207
  "MPFigureElement:test",
@@ -39467,6 +39496,7 @@ Object {
39467
39496
  Object {
39468
39497
  "attrs": Object {
39469
39498
  "dataTracked": null,
39499
+ "id": "MPCrossReference:test",
39470
39500
  "label": "",
39471
39501
  "rids": Array [
39472
39502
  "MPTableElement:test",
@@ -45212,6 +45242,7 @@ Object {
45212
45242
  Object {
45213
45243
  "attrs": Object {
45214
45244
  "dataTracked": null,
45245
+ "id": "MPCrossReference:test",
45215
45246
  "label": "",
45216
45247
  "rids": Array [
45217
45248
  "MPFigureElement:test",
@@ -46995,6 +47026,7 @@ Object {
46995
47026
  Object {
46996
47027
  "attrs": Object {
46997
47028
  "dataTracked": null,
47029
+ "id": "MPCrossReference:test",
46998
47030
  "label": "",
46999
47031
  "rids": Array [
47000
47032
  "MPTableElement:test",
@@ -51381,6 +51413,7 @@ Object {
51381
51413
  Object {
51382
51414
  "attrs": Object {
51383
51415
  "dataTracked": null,
51416
+ "id": "MPCrossReference:test",
51384
51417
  "label": "",
51385
51418
  "rids": Array [
51386
51419
  "MPTableElement:test",
@@ -51552,6 +51585,7 @@ Object {
51552
51585
  Object {
51553
51586
  "attrs": Object {
51554
51587
  "dataTracked": null,
51588
+ "id": "MPCrossReference:test",
51555
51589
  "label": "",
51556
51590
  "rids": Array [
51557
51591
  "MPEquationElement:test",
@@ -51820,6 +51854,7 @@ Object {
51820
51854
  Object {
51821
51855
  "attrs": Object {
51822
51856
  "dataTracked": null,
51857
+ "id": "MPCrossReference:test",
51823
51858
  "label": "",
51824
51859
  "rids": Array [
51825
51860
  "MPEquationElement:test",
@@ -51834,6 +51869,7 @@ Object {
51834
51869
  Object {
51835
51870
  "attrs": Object {
51836
51871
  "dataTracked": null,
51872
+ "id": "MPCrossReference:test",
51837
51873
  "label": "",
51838
51874
  "rids": Array [
51839
51875
  "MPEquationElement:test",
@@ -51848,6 +51884,7 @@ Object {
51848
51884
  Object {
51849
51885
  "attrs": Object {
51850
51886
  "dataTracked": null,
51887
+ "id": "MPCrossReference:test",
51851
51888
  "label": "",
51852
51889
  "rids": Array [
51853
51890
  "MPFigureElement:test",
@@ -52104,6 +52141,7 @@ Object {
52104
52141
  Object {
52105
52142
  "attrs": Object {
52106
52143
  "dataTracked": null,
52144
+ "id": "MPCrossReference:test",
52107
52145
  "label": "",
52108
52146
  "rids": Array [
52109
52147
  "MPTableElement:test",
@@ -52274,6 +52312,7 @@ Object {
52274
52312
  Object {
52275
52313
  "attrs": Object {
52276
52314
  "dataTracked": null,
52315
+ "id": "MPCrossReference:test",
52277
52316
  "label": "",
52278
52317
  "rids": Array [
52279
52318
  "MPFigureElement:test",
@@ -52288,6 +52327,7 @@ Object {
52288
52327
  Object {
52289
52328
  "attrs": Object {
52290
52329
  "dataTracked": null,
52330
+ "id": "MPCrossReference:test",
52291
52331
  "label": "",
52292
52332
  "rids": Array [
52293
52333
  "MPFigureElement:test",
@@ -52316,6 +52356,7 @@ Object {
52316
52356
  Object {
52317
52357
  "attrs": Object {
52318
52358
  "dataTracked": null,
52359
+ "id": "MPCrossReference:test",
52319
52360
  "label": "",
52320
52361
  "rids": Array [
52321
52362
  "MPEquationElement:test",
@@ -52330,6 +52371,7 @@ Object {
52330
52371
  Object {
52331
52372
  "attrs": Object {
52332
52373
  "dataTracked": null,
52374
+ "id": "MPCrossReference:test",
52333
52375
  "label": "",
52334
52376
  "rids": Array [
52335
52377
  "MPEquationElement:test",
@@ -52359,6 +52401,7 @@ Object {
52359
52401
  Object {
52360
52402
  "attrs": Object {
52361
52403
  "dataTracked": null,
52404
+ "id": "MPCrossReference:test",
52362
52405
  "label": "",
52363
52406
  "rids": Array [
52364
52407
  "MPFigureElement:test",
@@ -52630,6 +52673,7 @@ Object {
52630
52673
  Object {
52631
52674
  "attrs": Object {
52632
52675
  "dataTracked": null,
52676
+ "id": "MPCrossReference:test",
52633
52677
  "label": "",
52634
52678
  "rids": Array [
52635
52679
  "MPTableElement:test",
@@ -52815,6 +52859,7 @@ Object {
52815
52859
  Object {
52816
52860
  "attrs": Object {
52817
52861
  "dataTracked": null,
52862
+ "id": "MPCrossReference:test",
52818
52863
  "label": "",
52819
52864
  "rids": Array [
52820
52865
  "MPFigureElement:test",
@@ -52829,6 +52874,7 @@ Object {
52829
52874
  Object {
52830
52875
  "attrs": Object {
52831
52876
  "dataTracked": null,
52877
+ "id": "MPCrossReference:test",
52832
52878
  "label": "",
52833
52879
  "rids": Array [
52834
52880
  "MPFigureElement:test",
@@ -52887,6 +52933,7 @@ Object {
52887
52933
  Object {
52888
52934
  "attrs": Object {
52889
52935
  "dataTracked": null,
52936
+ "id": "MPCrossReference:test",
52890
52937
  "label": "",
52891
52938
  "rids": Array [
52892
52939
  "MPEquationElement:test",
@@ -52901,6 +52948,7 @@ Object {
52901
52948
  Object {
52902
52949
  "attrs": Object {
52903
52950
  "dataTracked": null,
52951
+ "id": "MPCrossReference:test",
52904
52952
  "label": "",
52905
52953
  "rids": Array [
52906
52954
  "MPEquationElement:test",
@@ -52915,6 +52963,7 @@ Object {
52915
52963
  Object {
52916
52964
  "attrs": Object {
52917
52965
  "dataTracked": null,
52966
+ "id": "MPCrossReference:test",
52918
52967
  "label": "",
52919
52968
  "rids": Array [
52920
52969
  "MPFigureElement:test",
@@ -53205,6 +53254,7 @@ Object {
53205
53254
  Object {
53206
53255
  "attrs": Object {
53207
53256
  "dataTracked": null,
53257
+ "id": "MPCrossReference:test",
53208
53258
  "label": "",
53209
53259
  "rids": Array [
53210
53260
  "MPTableElement:test",
@@ -53431,6 +53481,7 @@ Object {
53431
53481
  Object {
53432
53482
  "attrs": Object {
53433
53483
  "dataTracked": null,
53484
+ "id": "MPCrossReference:test",
53434
53485
  "label": "",
53435
53486
  "rids": Array [
53436
53487
  "MPFigureElement:test",
@@ -53459,6 +53510,7 @@ Object {
53459
53510
  Object {
53460
53511
  "attrs": Object {
53461
53512
  "dataTracked": null,
53513
+ "id": "MPCrossReference:test",
53462
53514
  "label": "",
53463
53515
  "rids": Array [
53464
53516
  "MPFigureElement:test",
@@ -53473,6 +53525,7 @@ Object {
53473
53525
  Object {
53474
53526
  "attrs": Object {
53475
53527
  "dataTracked": null,
53528
+ "id": "MPCrossReference:test",
53476
53529
  "label": "",
53477
53530
  "rids": Array [
53478
53531
  "MPFigureElement:test",
@@ -53551,6 +53604,7 @@ Object {
53551
53604
  Object {
53552
53605
  "attrs": Object {
53553
53606
  "dataTracked": null,
53607
+ "id": "MPCrossReference:test",
53554
53608
  "label": "",
53555
53609
  "rids": Array [
53556
53610
  "MPEquationElement:test",
@@ -53565,6 +53619,7 @@ Object {
53565
53619
  Object {
53566
53620
  "attrs": Object {
53567
53621
  "dataTracked": null,
53622
+ "id": "MPCrossReference:test",
53568
53623
  "label": "",
53569
53624
  "rids": Array [
53570
53625
  "MPFigureElement:test",
@@ -53788,6 +53843,7 @@ Object {
53788
53843
  Object {
53789
53844
  "attrs": Object {
53790
53845
  "dataTracked": null,
53846
+ "id": "MPCrossReference:test",
53791
53847
  "label": "",
53792
53848
  "rids": Array [
53793
53849
  "MPTableElement:test",
@@ -53958,6 +54014,7 @@ Object {
53958
54014
  Object {
53959
54015
  "attrs": Object {
53960
54016
  "dataTracked": null,
54017
+ "id": "MPCrossReference:test",
53961
54018
  "label": "",
53962
54019
  "rids": Array [
53963
54020
  "MPEquationElement:test",
@@ -53972,6 +54029,7 @@ Object {
53972
54029
  Object {
53973
54030
  "attrs": Object {
53974
54031
  "dataTracked": null,
54032
+ "id": "MPCrossReference:test",
53975
54033
  "label": "",
53976
54034
  "rids": Array [
53977
54035
  "MPFigureElement:test",
@@ -54195,6 +54253,7 @@ Object {
54195
54253
  Object {
54196
54254
  "attrs": Object {
54197
54255
  "dataTracked": null,
54256
+ "id": "MPCrossReference:test",
54198
54257
  "label": "",
54199
54258
  "rids": Array [
54200
54259
  "MPTableElement:test",
@@ -54459,6 +54518,7 @@ Object {
54459
54518
  Object {
54460
54519
  "attrs": Object {
54461
54520
  "dataTracked": null,
54521
+ "id": "MPCrossReference:test",
54462
54522
  "label": "",
54463
54523
  "rids": Array [
54464
54524
  "MPEquationElement:test",
@@ -54473,6 +54533,7 @@ Object {
54473
54533
  Object {
54474
54534
  "attrs": Object {
54475
54535
  "dataTracked": null,
54536
+ "id": "MPCrossReference:test",
54476
54537
  "label": "",
54477
54538
  "rids": Array [
54478
54539
  "MPFigureElement:test",
@@ -54696,6 +54757,7 @@ Object {
54696
54757
  Object {
54697
54758
  "attrs": Object {
54698
54759
  "dataTracked": null,
54760
+ "id": "MPCrossReference:test",
54699
54761
  "label": "",
54700
54762
  "rids": Array [
54701
54763
  "MPTableElement:test",
@@ -54917,6 +54979,7 @@ Object {
54917
54979
  Object {
54918
54980
  "attrs": Object {
54919
54981
  "dataTracked": null,
54982
+ "id": "MPCrossReference:test",
54920
54983
  "label": "",
54921
54984
  "rids": Array [
54922
54985
  "MPFigureElement:test",
@@ -55140,6 +55203,7 @@ Object {
55140
55203
  Object {
55141
55204
  "attrs": Object {
55142
55205
  "dataTracked": null,
55206
+ "id": "MPCrossReference:test",
55143
55207
  "label": "",
55144
55208
  "rids": Array [
55145
55209
  "MPTableElement:test",
@@ -134,6 +134,9 @@ const chooseRefType = (type: ManuscriptNodeType): string | undefined => {
134
134
  case schema.nodes.equation:
135
135
  case schema.nodes.equation_element:
136
136
  return 'disp-formula'
137
+
138
+ case schema.nodes.supplement:
139
+ return 'supplementary-material'
137
140
  }
138
141
  }
139
142
 
@@ -711,7 +714,7 @@ export class JATSExporter {
711
714
  return ['trans-abstract', attrs, 0]
712
715
  },
713
716
  hero_image: () => '',
714
- headshot_grid: () => ['p', { 'content-type': 'headshots'}, 0],
717
+ headshot_grid: () => ['p', { 'content-type': 'headshots' }, 0],
715
718
  headshot_element: (node) => createImage(node),
716
719
  headshot_image: () => '',
717
720
  alt_text: (node) => {
@@ -22,6 +22,7 @@ export interface Target {
22
22
  id: string
23
23
  label: string
24
24
  caption: string
25
+ href?: string
25
26
  }
26
27
 
27
28
  interface Counter {
@@ -41,8 +42,11 @@ const labelledNodeTypes: ManuscriptNodeType[] = [
41
42
  schema.nodes.box_element,
42
43
  schema.nodes.embed,
43
44
  schema.nodes.image_element,
45
+ schema.nodes.supplement,
44
46
  ]
45
47
 
48
+ const noLabelTypes = new Set([schema.nodes.supplement.name])
49
+
46
50
  const excludedTypes = [
47
51
  schema.nodes.graphical_abstract_section,
48
52
  schema.nodes.trans_graphical_abstract,
@@ -72,6 +76,9 @@ export const buildTargets = (
72
76
  }
73
77
 
74
78
  const buildLabel = (type: ManuscriptNodeType) => {
79
+ if (noLabelTypes.has(type.name)) {
80
+ return ''
81
+ }
75
82
  const counter = counters[type.name]
76
83
  counter.index++
77
84
  return `${counter.label} ${counter.index}`
@@ -91,12 +98,13 @@ export const buildTargets = (
91
98
  }
92
99
  }
93
100
  const label = buildLabel(node.type)
94
-
95
101
  targets.set(node.attrs.id, {
96
102
  type: node.type.name,
97
103
  id: node.attrs.id,
98
104
  label,
99
- caption: node.textContent?.trim(), // TODO: HTML?
105
+ caption: node.textBetween(0, node.content.size, ' ').trim(),
106
+ ...(node.attrs.href && { href: node.attrs.href }),
107
+ ...(node.attrs.extLink && { href: node.attrs.extLink }),
100
108
  })
101
109
  }
102
110
  })
@@ -816,7 +816,9 @@ export class JATSDOMParser {
816
816
  // fill empty alt-text with `caption > title` content
817
817
  const title = caption?.querySelector(':scope > title')
818
818
  if (title) {
819
- altText.append(...Array.from(title.childNodes).map(n => n.cloneNode(true)))
819
+ altText.append(
820
+ ...Array.from(title.childNodes).map((n) => n.cloneNode(true))
821
+ )
820
822
  }
821
823
  }
822
824
  wrapper.appendChild(altText)
@@ -828,7 +830,7 @@ export class JATSDOMParser {
828
830
  return this.parse(wrapper, {
829
831
  topNode: this.schema.nodes.headshot_element.create(),
830
832
  }).content
831
- }
833
+ },
832
834
  },
833
835
  {
834
836
  tag: 'graphic[specific-use=MISSING]',
@@ -292,4 +292,3 @@ export const schema = new Schema<Nodes, Marks>({
292
292
  subtitles: subtitles,
293
293
  },
294
294
  })
295
-
@@ -83,7 +83,8 @@ class Migration4334 implements MigrationScript {
83
83
  (n) => n.type === 'caption_title'
84
84
  )
85
85
  const captionNodes = (figCaption?.content || []).filter(
86
- (node) => node.type === 'caption')
86
+ (node) => node.type === 'caption'
87
+ )
87
88
  const foundCaption = getCaptionNode(
88
89
  captionNodes,
89
90
  config.caption === 'required'
@@ -28,9 +28,7 @@ class Migration4335 implements MigrationScript {
28
28
  return {
29
29
  ...node,
30
30
  content: (node.content ?? []).map((child) =>
31
- child.type === 'paragraph'
32
- ? { ...child, type: 'text_block' }
33
- : child
31
+ child.type === 'paragraph' ? { ...child, type: 'text_block' } : child
34
32
  ),
35
33
  }
36
34
  }
@@ -38,4 +36,4 @@ class Migration4335 implements MigrationScript {
38
36
  }
39
37
  }
40
38
 
41
- export default Migration4335
39
+ export default Migration4335
@@ -0,0 +1,44 @@
1
+ /*!
2
+ * © 2026 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 { generateNodeID } from '../../../transformer'
17
+ import { JSONProsemirrorNode } from '../../../types'
18
+ import { schema } from '../../index'
19
+ import { MigrationScript } from '../migration-script'
20
+
21
+ class Migration447 implements MigrationScript {
22
+ fromVersion = '4.4.6'
23
+ toVersion = '4.4.7'
24
+
25
+ migrateNode(node: JSONProsemirrorNode): JSONProsemirrorNode {
26
+ if (node.type !== 'cross_reference') {
27
+ return node
28
+ }
29
+
30
+ if (node.attrs?.id) {
31
+ return node
32
+ }
33
+
34
+ return {
35
+ ...node,
36
+ attrs: {
37
+ ...(node.attrs ?? {}),
38
+ id: generateNodeID(schema.nodes.cross_reference),
39
+ },
40
+ }
41
+ }
42
+ }
43
+
44
+ export default Migration447
@@ -29,6 +29,7 @@ import Migration4323 from './4.3.23'
29
29
  import Migration4334 from './4.3.34'
30
30
  import Migration4335 from './4.3.35'
31
31
  import Migration442 from './4.4.2'
32
+ import Migration447 from './4.4.7'
32
33
 
33
34
  const migrations = [
34
35
  new Migration125(),
@@ -46,6 +47,7 @@ const migrations = [
46
47
  new Migration4334(),
47
48
  new Migration4335(),
48
49
  new Migration442(),
50
+ new Migration447(),
49
51
  ]
50
52
 
51
53
  export default migrations
@@ -19,6 +19,7 @@ import { NodeSpec } from 'prosemirror-model'
19
19
  import { ManuscriptNode } from '../types'
20
20
 
21
21
  interface Attrs {
22
+ id: string
22
23
  rids: string[]
23
24
  label: string
24
25
  }
@@ -33,6 +34,7 @@ export const crossReference: NodeSpec = {
33
34
  draggable: true,
34
35
  atom: true,
35
36
  attrs: {
37
+ id: { default: '' },
36
38
  rids: { default: [] },
37
39
  label: { default: '' },
38
40
  dataTracked: { default: null },
@@ -44,6 +46,7 @@ export const crossReference: NodeSpec = {
44
46
  const dom = p as HTMLSpanElement
45
47
 
46
48
  return {
49
+ id: dom.getAttribute('data-id'),
47
50
  rids: dom.getAttribute('data-reference-id')?.split(/\s+/) || [],
48
51
  }
49
52
  },
@@ -56,6 +59,7 @@ export const crossReference: NodeSpec = {
56
59
  'span',
57
60
  {
58
61
  class: 'cross-reference',
62
+ 'data-id': crossReferenceNode.attrs.id,
59
63
  'data-reference-id': crossReferenceNode.attrs.rids.join(' '),
60
64
  },
61
65
  crossReferenceNode.attrs.label,
@@ -44,5 +44,7 @@ export const headshotElement: NodeSpec = {
44
44
  },
45
45
  }
46
46
 
47
- export const isHeadshotElementNode = (node: ManuscriptNode): node is HeadshotElementNode =>
47
+ export const isHeadshotElementNode = (
48
+ node: ManuscriptNode
49
+ ): node is HeadshotElementNode =>
48
50
  node.type === node.type.schema.nodes.headshot_element
@@ -42,5 +42,7 @@ export const headshotGrid: NodeSpec = {
42
42
  },
43
43
  }
44
44
 
45
- export const isHeadshotGridNode = (node: ManuscriptNode): node is HeadshotGridNode =>
45
+ export const isHeadshotGridNode = (
46
+ node: ManuscriptNode
47
+ ): node is HeadshotGridNode =>
46
48
  node.type === node.type.schema.nodes.headshot_grid
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = "4.5.0";
1
+ export const VERSION = "4.5.1";