@manuscripts/transform 4.4.1 → 4.4.3

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 (43) hide show
  1. package/dist/cjs/jats/exporter/jats-exporter.js +17 -6
  2. package/dist/cjs/jats/importer/jats-dom-parser.js +10 -1
  3. package/dist/cjs/jats/importer/jats-transformations.js +1 -1
  4. package/dist/cjs/schema/migration/migration-scripts/4.4.2.js +44 -0
  5. package/dist/cjs/schema/migration/migration-scripts/index.js +2 -0
  6. package/dist/cjs/schema/nodes/box_element.js +4 -0
  7. package/dist/cjs/schema/nodes/hero_image.js +2 -0
  8. package/dist/cjs/schema/nodes/pullquote_element.js +4 -0
  9. package/dist/cjs/schema/nodes/table_element.js +9 -8
  10. package/dist/cjs/version.js +1 -1
  11. package/dist/es/jats/exporter/jats-exporter.js +17 -6
  12. package/dist/es/jats/importer/jats-dom-parser.js +10 -1
  13. package/dist/es/jats/importer/jats-transformations.js +1 -1
  14. package/dist/es/schema/migration/migration-scripts/4.4.2.js +42 -0
  15. package/dist/es/schema/migration/migration-scripts/index.js +2 -0
  16. package/dist/es/schema/nodes/box_element.js +4 -0
  17. package/dist/es/schema/nodes/hero_image.js +2 -0
  18. package/dist/es/schema/nodes/pullquote_element.js +4 -0
  19. package/dist/es/schema/nodes/table_element.js +9 -8
  20. package/dist/es/version.js +1 -1
  21. package/dist/types/schema/migration/migration-scripts/4.4.2.d.ts +8 -0
  22. package/dist/types/schema/migration/migration-scripts/index.d.ts +2 -1
  23. package/dist/types/schema/nodes/blockquote_element.d.ts +2 -3
  24. package/dist/types/schema/nodes/box_element.d.ts +1 -0
  25. package/dist/types/schema/nodes/hero_image.d.ts +1 -0
  26. package/dist/types/schema/nodes/pullquote_element.d.ts +3 -2
  27. package/dist/types/schema/nodes/table_element.d.ts +1 -0
  28. package/dist/types/version.d.ts +1 -1
  29. package/package.json +2 -1
  30. package/src/jats/__tests__/__fixtures__/jats-import.xml +17 -2
  31. package/src/jats/__tests__/__snapshots__/jats-importer.test.ts.snap +159 -0
  32. package/src/jats/__tests__/__snapshots__/jats-roundtrip.test.ts.snap +1 -1
  33. package/src/jats/exporter/jats-exporter.ts +21 -6
  34. package/src/jats/importer/jats-dom-parser.ts +10 -2
  35. package/src/jats/importer/jats-transformations.ts +1 -1
  36. package/src/schema/migration/migration-scripts/4.4.2.ts +60 -0
  37. package/src/schema/migration/migration-scripts/index.ts +2 -0
  38. package/src/schema/nodes/blockquote_element.ts +3 -3
  39. package/src/schema/nodes/box_element.ts +6 -0
  40. package/src/schema/nodes/hero_image.ts +3 -0
  41. package/src/schema/nodes/pullquote_element.ts +9 -3
  42. package/src/schema/nodes/table_element.ts +12 -8
  43. package/src/version.ts +1 -1
@@ -20,6 +20,7 @@ import { ManuscriptNode } from '../types'
20
20
 
21
21
  export interface BoxElementAttrs {
22
22
  id: string
23
+ type: string
23
24
  }
24
25
 
25
26
  export interface BoxElementNode extends ManuscriptNode {
@@ -30,6 +31,7 @@ export const box_element: NodeSpec = {
30
31
  content: 'caption_title? caption? section?',
31
32
  attrs: {
32
33
  id: { default: '' },
34
+ type: { default: '' },
33
35
  dataTracked: { default: null },
34
36
  },
35
37
  group: 'block element',
@@ -56,6 +58,10 @@ export const box_element: NodeSpec = {
56
58
  attrs.id = boxElementNode.attrs.id
57
59
  }
58
60
 
61
+ if (boxElementNode.attrs.type) {
62
+ attrs['data-content-type'] = boxElementNode.attrs.type
63
+ }
64
+
59
65
  return [
60
66
  'div',
61
67
  {
@@ -21,6 +21,7 @@ import { ManuscriptNode } from '../types'
21
21
  export interface HeroImageNode extends ManuscriptNode {
22
22
  attrs: {
23
23
  id: string
24
+ type: string
24
25
  }
25
26
  }
26
27
 
@@ -28,6 +29,7 @@ export const heroImage: NodeSpec = {
28
29
  content: 'figure? alt_text long_desc',
29
30
  attrs: {
30
31
  id: { default: '' },
32
+ type: { default: 'leading' },
31
33
  dataTracked: { default: null },
32
34
  },
33
35
  group: 'block element',
@@ -37,6 +39,7 @@ export const heroImage: NodeSpec = {
37
39
  {
38
40
  class: 'hero_image',
39
41
  id: node.attrs.id,
42
+ 'data-content-type': node.attrs.type,
40
43
  },
41
44
  ]
42
45
  },
@@ -18,13 +18,14 @@ import { NodeSpec } from 'prosemirror-model'
18
18
 
19
19
  import { ManuscriptNode } from '../types'
20
20
 
21
- interface Attrs {
21
+ interface PullquoteElementAttrs {
22
22
  id: string
23
23
  placeholder: string
24
+ type: string
24
25
  }
25
26
 
26
27
  export interface PullquoteElementNode extends ManuscriptNode {
27
- attrs: Attrs
28
+ attrs: PullquoteElementAttrs
28
29
  }
29
30
 
30
31
  export const pullquoteElement: NodeSpec = {
@@ -32,6 +33,7 @@ export const pullquoteElement: NodeSpec = {
32
33
  attrs: {
33
34
  id: { default: '' },
34
35
  placeholder: { default: '' },
36
+ type: { default: '' },
35
37
  dataTracked: { default: null },
36
38
  },
37
39
  group: 'block element',
@@ -42,7 +44,7 @@ export const pullquoteElement: NodeSpec = {
42
44
  getAttrs: (aside) => {
43
45
  const dom = aside as HTMLElement
44
46
 
45
- const attrs: Partial<Attrs> = {
47
+ const attrs: Partial<PullquoteElementAttrs> = {
46
48
  id: dom.getAttribute('id') || undefined,
47
49
  }
48
50
 
@@ -71,6 +73,10 @@ export const pullquoteElement: NodeSpec = {
71
73
  attrs['data-placeholder-text'] = pullquoteElementNode.attrs.placeholder
72
74
  }
73
75
 
76
+ if (pullquoteElementNode.attrs.type) {
77
+ attrs['data-content-type'] = pullquoteElementNode.attrs.type
78
+ }
79
+
74
80
  return ['aside', attrs, 0]
75
81
  },
76
82
  }
@@ -20,6 +20,7 @@ import { ManuscriptNode } from '../types'
20
20
 
21
21
  export interface TableAttrs {
22
22
  id: string
23
+ type: string
23
24
  }
24
25
 
25
26
  export interface TableElementNode extends ManuscriptNode {
@@ -31,6 +32,7 @@ export const tableElement: NodeSpec = {
31
32
  'caption_title (table | placeholder) table_colgroup? table_element_footer? alt_text long_desc (listing | placeholder)',
32
33
  attrs: {
33
34
  id: { default: '' },
35
+ type: { default: '' },
34
36
  dataTracked: { default: null },
35
37
  },
36
38
  selectable: false,
@@ -50,14 +52,16 @@ export const tableElement: NodeSpec = {
50
52
  toDOM: (node) => {
51
53
  const tableElementNode = node as TableElementNode
52
54
 
53
- return [
54
- 'figure',
55
- {
56
- class: 'table', // TODO: suppress-header, suppress-footer?
57
- id: tableElementNode.attrs.id,
58
- },
59
- 0,
60
- ]
55
+ const attrs: { [key: string]: string } = {
56
+ class: 'table',
57
+ id: tableElementNode.attrs.id,
58
+ }
59
+
60
+ if (tableElementNode.attrs.type) {
61
+ attrs['data-content-type'] = tableElementNode.attrs.type
62
+ }
63
+
64
+ return ['figure', attrs, 0]
61
65
  },
62
66
  }
63
67
 
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = "4.4.1";
1
+ export const VERSION = "4.4.3";