@manuscripts/transform 4.2.20 → 4.3.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.
@@ -540,7 +540,7 @@ class JATSExporter {
540
540
  awardGroupElement.setAttribute('id', normalizeID(awardGroup.attrs.id));
541
541
  appendChildIfPresent(awardGroupElement, 'funding-source', awardGroup.attrs.source);
542
542
  awardGroup.attrs.code
543
- .split(';')
543
+ ?.split(';')
544
544
  .forEach((code) => appendChildIfPresent(awardGroupElement, 'award-id', code));
545
545
  appendChildIfPresent(awardGroupElement, 'principal-award-recipient', awardGroup.attrs.recipient);
546
546
  return awardGroupElement;
@@ -625,7 +625,7 @@ class JATSExporter {
625
625
  },
626
626
  doc: () => '',
627
627
  equation: (node) => {
628
- return this.createEquation(node);
628
+ return node.attrs.contents ? this.createEquation(node) : '';
629
629
  },
630
630
  general_table_footnote: (node) => {
631
631
  const el = this.createElement('general-table-footnote');
@@ -634,6 +634,9 @@ class JATSExporter {
634
634
  return el;
635
635
  },
636
636
  inline_equation: (node) => {
637
+ if (!node.attrs.contents) {
638
+ return '';
639
+ }
637
640
  const eqElement = this.createElement('inline-formula');
638
641
  const equation = this.createEquation(node, true);
639
642
  eqElement.append(equation);
@@ -16,7 +16,21 @@
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.tracked_delete = exports.tracked_insert = exports.underline = exports.superscript = exports.subscript = exports.styled = exports.strikethrough = exports.smallcaps = exports.italic = exports.code = exports.bold = void 0;
19
+ function getTrackedMarkAttrs(el) {
20
+ const dataTracked = Array.isArray(el.attrs.dataTracked)
21
+ ? el.attrs.dataTracked[0]
22
+ : null;
23
+ return dataTracked
24
+ ? {
25
+ 'data-track-status': dataTracked.status,
26
+ 'data-track-op': dataTracked.operation,
27
+ }
28
+ : {};
29
+ }
19
30
  exports.bold = {
31
+ attrs: {
32
+ dataTracked: { default: null },
33
+ },
20
34
  parseDOM: [
21
35
  {
22
36
  getAttrs: (dom) => dom.style.fontWeight !== 'normal' && null,
@@ -31,15 +45,28 @@ exports.bold = {
31
45
  style: 'font-weight',
32
46
  },
33
47
  ],
34
- toDOM: () => ['b'],
48
+ toDOM: (el) => {
49
+ const attrs = {
50
+ ...getTrackedMarkAttrs(el),
51
+ };
52
+ return ['b', attrs];
53
+ },
35
54
  };
36
55
  exports.code = {
37
56
  parseDOM: [{ tag: 'code' }],
38
57
  toDOM: () => ['code'],
39
58
  };
40
59
  exports.italic = {
60
+ attrs: {
61
+ dataTracked: { default: null },
62
+ },
41
63
  parseDOM: [{ tag: 'i' }, { tag: 'em' }, { style: 'font-style=italic' }],
42
- toDOM: () => ['i'],
64
+ toDOM: (el) => {
65
+ const attrs = {
66
+ ...getTrackedMarkAttrs(el),
67
+ };
68
+ return ['i', attrs];
69
+ },
43
70
  };
44
71
  exports.smallcaps = {
45
72
  parseDOM: [
@@ -54,13 +81,21 @@ exports.smallcaps = {
54
81
  ],
55
82
  };
56
83
  exports.strikethrough = {
84
+ attrs: {
85
+ dataTracked: { default: null },
86
+ },
57
87
  parseDOM: [
58
88
  { tag: 's' },
59
89
  { tag: 'strike' },
60
90
  { style: 'text-decoration=line-through' },
61
91
  { style: 'text-decoration-line=line-through' },
62
92
  ],
63
- toDOM: () => ['s'],
93
+ toDOM: (el) => {
94
+ const attrs = {
95
+ ...getTrackedMarkAttrs(el),
96
+ };
97
+ return ['s', attrs];
98
+ },
64
99
  };
65
100
  exports.styled = {
66
101
  attrs: {
@@ -86,20 +121,44 @@ exports.styled = {
86
121
  },
87
122
  };
88
123
  exports.subscript = {
124
+ attrs: {
125
+ dataTracked: { default: null },
126
+ },
89
127
  excludes: 'superscript',
90
128
  group: 'position',
91
129
  parseDOM: [{ tag: 'sub' }, { style: 'vertical-align=sub' }],
92
- toDOM: () => ['sub'],
130
+ toDOM: (el) => {
131
+ const attrs = {
132
+ ...getTrackedMarkAttrs(el),
133
+ };
134
+ return ['sub', attrs];
135
+ },
93
136
  };
94
137
  exports.superscript = {
138
+ attrs: {
139
+ dataTracked: { default: null },
140
+ },
95
141
  excludes: 'subscript',
96
142
  group: 'position',
97
143
  parseDOM: [{ tag: 'sup' }, { style: 'vertical-align=super' }],
98
- toDOM: () => ['sup'],
144
+ toDOM: (el) => {
145
+ const attrs = {
146
+ ...getTrackedMarkAttrs(el),
147
+ };
148
+ return ['sup', attrs];
149
+ },
99
150
  };
100
151
  exports.underline = {
152
+ attrs: {
153
+ dataTracked: { default: null },
154
+ },
101
155
  parseDOM: [{ tag: 'u' }, { style: 'text-decoration=underline' }],
102
- toDOM: () => ['u'],
156
+ toDOM: (el) => {
157
+ const attrs = {
158
+ ...getTrackedMarkAttrs(el),
159
+ };
160
+ return ['u', attrs];
161
+ },
103
162
  };
104
163
  exports.tracked_insert = {
105
164
  excludes: 'tracked_insert tracked_delete',
@@ -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.2.20";
4
+ exports.VERSION = "4.3.1";
@@ -500,7 +500,7 @@ export class JATSExporter {
500
500
  awardGroupElement.setAttribute('id', normalizeID(awardGroup.attrs.id));
501
501
  appendChildIfPresent(awardGroupElement, 'funding-source', awardGroup.attrs.source);
502
502
  awardGroup.attrs.code
503
- .split(';')
503
+ ?.split(';')
504
504
  .forEach((code) => appendChildIfPresent(awardGroupElement, 'award-id', code));
505
505
  appendChildIfPresent(awardGroupElement, 'principal-award-recipient', awardGroup.attrs.recipient);
506
506
  return awardGroupElement;
@@ -585,7 +585,7 @@ export class JATSExporter {
585
585
  },
586
586
  doc: () => '',
587
587
  equation: (node) => {
588
- return this.createEquation(node);
588
+ return node.attrs.contents ? this.createEquation(node) : '';
589
589
  },
590
590
  general_table_footnote: (node) => {
591
591
  const el = this.createElement('general-table-footnote');
@@ -594,6 +594,9 @@ export class JATSExporter {
594
594
  return el;
595
595
  },
596
596
  inline_equation: (node) => {
597
+ if (!node.attrs.contents) {
598
+ return '';
599
+ }
597
600
  const eqElement = this.createElement('inline-formula');
598
601
  const equation = this.createEquation(node, true);
599
602
  eqElement.append(equation);
@@ -13,7 +13,21 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ function getTrackedMarkAttrs(el) {
17
+ const dataTracked = Array.isArray(el.attrs.dataTracked)
18
+ ? el.attrs.dataTracked[0]
19
+ : null;
20
+ return dataTracked
21
+ ? {
22
+ 'data-track-status': dataTracked.status,
23
+ 'data-track-op': dataTracked.operation,
24
+ }
25
+ : {};
26
+ }
16
27
  export const bold = {
28
+ attrs: {
29
+ dataTracked: { default: null },
30
+ },
17
31
  parseDOM: [
18
32
  {
19
33
  getAttrs: (dom) => dom.style.fontWeight !== 'normal' && null,
@@ -28,15 +42,28 @@ export const bold = {
28
42
  style: 'font-weight',
29
43
  },
30
44
  ],
31
- toDOM: () => ['b'],
45
+ toDOM: (el) => {
46
+ const attrs = {
47
+ ...getTrackedMarkAttrs(el),
48
+ };
49
+ return ['b', attrs];
50
+ },
32
51
  };
33
52
  export const code = {
34
53
  parseDOM: [{ tag: 'code' }],
35
54
  toDOM: () => ['code'],
36
55
  };
37
56
  export const italic = {
57
+ attrs: {
58
+ dataTracked: { default: null },
59
+ },
38
60
  parseDOM: [{ tag: 'i' }, { tag: 'em' }, { style: 'font-style=italic' }],
39
- toDOM: () => ['i'],
61
+ toDOM: (el) => {
62
+ const attrs = {
63
+ ...getTrackedMarkAttrs(el),
64
+ };
65
+ return ['i', attrs];
66
+ },
40
67
  };
41
68
  export const smallcaps = {
42
69
  parseDOM: [
@@ -51,13 +78,21 @@ export const smallcaps = {
51
78
  ],
52
79
  };
53
80
  export const strikethrough = {
81
+ attrs: {
82
+ dataTracked: { default: null },
83
+ },
54
84
  parseDOM: [
55
85
  { tag: 's' },
56
86
  { tag: 'strike' },
57
87
  { style: 'text-decoration=line-through' },
58
88
  { style: 'text-decoration-line=line-through' },
59
89
  ],
60
- toDOM: () => ['s'],
90
+ toDOM: (el) => {
91
+ const attrs = {
92
+ ...getTrackedMarkAttrs(el),
93
+ };
94
+ return ['s', attrs];
95
+ },
61
96
  };
62
97
  export const styled = {
63
98
  attrs: {
@@ -83,20 +118,44 @@ export const styled = {
83
118
  },
84
119
  };
85
120
  export const subscript = {
121
+ attrs: {
122
+ dataTracked: { default: null },
123
+ },
86
124
  excludes: 'superscript',
87
125
  group: 'position',
88
126
  parseDOM: [{ tag: 'sub' }, { style: 'vertical-align=sub' }],
89
- toDOM: () => ['sub'],
127
+ toDOM: (el) => {
128
+ const attrs = {
129
+ ...getTrackedMarkAttrs(el),
130
+ };
131
+ return ['sub', attrs];
132
+ },
90
133
  };
91
134
  export const superscript = {
135
+ attrs: {
136
+ dataTracked: { default: null },
137
+ },
92
138
  excludes: 'subscript',
93
139
  group: 'position',
94
140
  parseDOM: [{ tag: 'sup' }, { style: 'vertical-align=super' }],
95
- toDOM: () => ['sup'],
141
+ toDOM: (el) => {
142
+ const attrs = {
143
+ ...getTrackedMarkAttrs(el),
144
+ };
145
+ return ['sup', attrs];
146
+ },
96
147
  };
97
148
  export const underline = {
149
+ attrs: {
150
+ dataTracked: { default: null },
151
+ },
98
152
  parseDOM: [{ tag: 'u' }, { style: 'text-decoration=underline' }],
99
- toDOM: () => ['u'],
153
+ toDOM: (el) => {
154
+ const attrs = {
155
+ ...getTrackedMarkAttrs(el),
156
+ };
157
+ return ['u', attrs];
158
+ },
100
159
  };
101
160
  export const tracked_insert = {
102
161
  excludes: 'tracked_insert tracked_delete',
@@ -1 +1 @@
1
- export const VERSION = "4.2.20";
1
+ export const VERSION = "4.3.1";
@@ -1 +1 @@
1
- export declare const VERSION = "4.2.20";
1
+ export declare const VERSION = "4.3.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.2.20",
4
+ "version": "4.3.1",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-transform",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",