@manuscripts/transform 2.3.7-LEAN-3307.3 → 2.3.8-LEAN-3608.0
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.
- package/dist/cjs/jats/importer/jats-body-dom-parser.js +24 -13
- package/dist/cjs/jats/importer/jats-body-transformations.js +12 -0
- package/dist/cjs/jats/importer/jats-parser-utils.js +4 -0
- package/dist/cjs/jats/jats-exporter.js +19 -10
- package/dist/cjs/schema/index.js +4 -2
- package/dist/cjs/schema/nodes/backmatter.js +2 -3
- package/dist/cjs/schema/nodes/contributors.js +0 -1
- package/dist/cjs/schema/nodes/general_table_footnote.js +27 -0
- package/dist/cjs/schema/nodes/list.js +36 -58
- package/dist/cjs/schema/nodes/table_element_footer.js +1 -1
- package/dist/cjs/schema/nodes/title.js +0 -1
- package/dist/cjs/transformer/decode.js +49 -28
- package/dist/cjs/transformer/encode.js +16 -10
- package/dist/cjs/transformer/node-names.js +1 -2
- package/dist/cjs/transformer/node-title.js +1 -2
- package/dist/cjs/transformer/node-types.js +1 -2
- package/dist/cjs/transformer/object-types.js +1 -0
- package/dist/cjs/version.js +1 -1
- package/dist/es/jats/importer/jats-body-dom-parser.js +25 -14
- package/dist/es/jats/importer/jats-body-transformations.js +12 -0
- package/dist/es/jats/importer/jats-parser-utils.js +4 -0
- package/dist/es/jats/jats-exporter.js +19 -10
- package/dist/es/schema/index.js +5 -3
- package/dist/es/schema/nodes/backmatter.js +2 -3
- package/dist/es/schema/nodes/contributors.js +0 -1
- package/dist/es/schema/nodes/general_table_footnote.js +24 -0
- package/dist/es/schema/nodes/list.js +34 -57
- package/dist/es/schema/nodes/table_element_footer.js +1 -1
- package/dist/es/schema/nodes/title.js +0 -1
- package/dist/es/transformer/decode.js +49 -28
- package/dist/es/transformer/encode.js +17 -11
- package/dist/es/transformer/node-names.js +1 -2
- package/dist/es/transformer/node-title.js +1 -2
- package/dist/es/transformer/node-types.js +1 -2
- package/dist/es/transformer/object-types.js +1 -0
- package/dist/es/version.js +1 -1
- package/dist/types/lib/table-cell-styles.d.ts +1 -1
- package/dist/types/schema/index.d.ts +1 -0
- package/dist/types/schema/nodes/general_table_footnote.d.ts +25 -0
- package/dist/types/schema/nodes/list.d.ts +9 -26
- package/dist/types/schema/nodes/title.d.ts +0 -1
- package/dist/types/schema/types.d.ts +1 -1
- package/dist/types/transformer/object-types.d.ts +2 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +3 -3
|
@@ -316,35 +316,46 @@ const nodes = [
|
|
|
316
316
|
},
|
|
317
317
|
},
|
|
318
318
|
{
|
|
319
|
-
tag: '
|
|
320
|
-
node: '
|
|
321
|
-
context: '
|
|
319
|
+
tag: 'general-table-footnote',
|
|
320
|
+
node: 'general_table_footnote',
|
|
321
|
+
context: 'table_element_footer/',
|
|
322
322
|
getAttrs: (node) => {
|
|
323
323
|
const element = node;
|
|
324
324
|
return {
|
|
325
325
|
id: element.getAttribute('id'),
|
|
326
|
-
kind: 'footnote',
|
|
327
326
|
};
|
|
328
327
|
},
|
|
328
|
+
getContent: (node) => {
|
|
329
|
+
const paragraphs = [];
|
|
330
|
+
node.childNodes.forEach((p) => {
|
|
331
|
+
const paragraph = schema_1.schema.nodes.paragraph.create();
|
|
332
|
+
const content = exports.jatsBodyDOMParser.parse(p, {
|
|
333
|
+
topNode: paragraph,
|
|
334
|
+
});
|
|
335
|
+
paragraphs.push(content);
|
|
336
|
+
});
|
|
337
|
+
return prosemirror_model_1.Fragment.from([...paragraphs]);
|
|
338
|
+
},
|
|
329
339
|
},
|
|
330
340
|
{
|
|
331
|
-
tag: '
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
{
|
|
335
|
-
tag: 'list[list-type=bullet]',
|
|
336
|
-
node: 'bullet_list',
|
|
341
|
+
tag: 'fn',
|
|
342
|
+
node: 'footnote',
|
|
343
|
+
context: 'footnotes_element/|table_element_footer/',
|
|
337
344
|
getAttrs: (node) => {
|
|
338
345
|
const element = node;
|
|
339
346
|
return {
|
|
340
347
|
id: element.getAttribute('id'),
|
|
341
|
-
|
|
348
|
+
kind: 'footnote',
|
|
342
349
|
};
|
|
343
350
|
},
|
|
344
351
|
},
|
|
345
352
|
{
|
|
346
|
-
tag: '
|
|
347
|
-
|
|
353
|
+
tag: 'front',
|
|
354
|
+
ignore: true,
|
|
355
|
+
},
|
|
356
|
+
{
|
|
357
|
+
tag: 'list',
|
|
358
|
+
node: 'list',
|
|
348
359
|
getAttrs: (node) => {
|
|
349
360
|
const element = node;
|
|
350
361
|
return {
|
|
@@ -242,6 +242,18 @@ exports.jatsBodyTransformations = {
|
|
|
242
242
|
}
|
|
243
243
|
tableWrap.insertBefore(colgroup, table.nextSibling);
|
|
244
244
|
}
|
|
245
|
+
const tableFootWrap = tableWrap.querySelector('table-wrap-foot');
|
|
246
|
+
if (tableFootWrap) {
|
|
247
|
+
const paragraphs = tableFootWrap.querySelectorAll(':scope > p');
|
|
248
|
+
if (paragraphs.length) {
|
|
249
|
+
const generalTableFootnote = createElement('general-table-footnote');
|
|
250
|
+
for (const paragraph of paragraphs) {
|
|
251
|
+
removeNodeFromParent(paragraph);
|
|
252
|
+
generalTableFootnote.append(paragraph);
|
|
253
|
+
}
|
|
254
|
+
tableFootWrap.prepend(generalTableFootnote);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
245
257
|
});
|
|
246
258
|
},
|
|
247
259
|
orderTableFootnote(doc, body) {
|
|
@@ -36,6 +36,10 @@ const updateNodeID = (node, replacements, warnings) => {
|
|
|
36
36
|
node.attrs = Object.assign(Object.assign({}, node.attrs), { id: `InlineMathFragment:${(0, uuid_1.v4)()}` });
|
|
37
37
|
return;
|
|
38
38
|
}
|
|
39
|
+
if (node.type === schema_1.schema.nodes.general_table_footnote) {
|
|
40
|
+
node.attrs = Object.assign(Object.assign({}, node.attrs), { id: `GeneralTableFootnote:${(0, uuid_1.v4)()}` });
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
39
43
|
if (!('id' in node.attrs)) {
|
|
40
44
|
return;
|
|
41
45
|
}
|
|
@@ -620,11 +620,13 @@ class JATSExporter {
|
|
|
620
620
|
0,
|
|
621
621
|
],
|
|
622
622
|
blockquote_element: () => ['disp-quote', { 'content-type': 'quote' }, 0],
|
|
623
|
-
|
|
623
|
+
list: (node) => {
|
|
624
624
|
var _a;
|
|
625
625
|
return [
|
|
626
626
|
'list',
|
|
627
|
-
{
|
|
627
|
+
{
|
|
628
|
+
'list-type': (_a = node.attrs.listStyleType) !== null && _a !== void 0 ? _a : 'bullet',
|
|
629
|
+
},
|
|
628
630
|
0,
|
|
629
631
|
];
|
|
630
632
|
},
|
|
@@ -679,6 +681,12 @@ class JATSExporter {
|
|
|
679
681
|
equation: (node) => {
|
|
680
682
|
return this.createEquation(node);
|
|
681
683
|
},
|
|
684
|
+
general_table_footnote: (node) => {
|
|
685
|
+
const el = this.document.createElement('general-table-footnote');
|
|
686
|
+
el.setAttribute('id', normalizeID(node.attrs.id));
|
|
687
|
+
processChildNodes(el, node, schema_1.schema.nodes.general_table_footnote);
|
|
688
|
+
return el;
|
|
689
|
+
},
|
|
682
690
|
inline_equation: (node) => {
|
|
683
691
|
const eqElement = this.document.createElement('inline-formula');
|
|
684
692
|
const equation = this.createEquation(node, true);
|
|
@@ -781,14 +789,6 @@ class JATSExporter {
|
|
|
781
789
|
graphic.setAttributeNS(XLINK_NAMESPACE, 'xlink:href', '');
|
|
782
790
|
return graphic;
|
|
783
791
|
},
|
|
784
|
-
ordered_list: (node) => {
|
|
785
|
-
var _a;
|
|
786
|
-
return [
|
|
787
|
-
'list',
|
|
788
|
-
{ 'list-type': (_a = node.attrs.listStyleType) !== null && _a !== void 0 ? _a : 'order' },
|
|
789
|
-
0,
|
|
790
|
-
];
|
|
791
|
-
},
|
|
792
792
|
paragraph: (node) => {
|
|
793
793
|
if (!node.childCount) {
|
|
794
794
|
return '';
|
|
@@ -1302,6 +1302,15 @@ class JATSExporter {
|
|
|
1302
1302
|
label.remove();
|
|
1303
1303
|
}
|
|
1304
1304
|
}
|
|
1305
|
+
if ((0, node_types_1.isNodeType)(node, 'general_table_footnote')) {
|
|
1306
|
+
const generalTableFootnote = body.querySelector(`#${normalizeID(node.attrs.id)}`);
|
|
1307
|
+
if (generalTableFootnote) {
|
|
1308
|
+
Array.from(generalTableFootnote.childNodes).forEach((cn) => {
|
|
1309
|
+
generalTableFootnote.before(cn);
|
|
1310
|
+
});
|
|
1311
|
+
generalTableFootnote.remove();
|
|
1312
|
+
}
|
|
1313
|
+
}
|
|
1305
1314
|
if ((0, node_types_1.isNodeType)(node, 'table_element')) {
|
|
1306
1315
|
const tableElement = body.querySelector(`#${normalizeID(node.attrs.id)}`);
|
|
1307
1316
|
if (tableElement) {
|
package/dist/cjs/schema/index.js
CHANGED
|
@@ -61,6 +61,7 @@ const figure_element_1 = require("./nodes/figure_element");
|
|
|
61
61
|
const footnote_1 = require("./nodes/footnote");
|
|
62
62
|
const footnotes_element_1 = require("./nodes/footnotes_element");
|
|
63
63
|
const footnotes_section_1 = require("./nodes/footnotes_section");
|
|
64
|
+
const general_table_footnote_1 = require("./nodes/general_table_footnote");
|
|
64
65
|
const graphical_abstract_section_1 = require("./nodes/graphical_abstract_section");
|
|
65
66
|
const hard_break_1 = require("./nodes/hard_break");
|
|
66
67
|
const highlight_marker_1 = require("./nodes/highlight_marker");
|
|
@@ -112,6 +113,7 @@ __exportStar(require("./nodes/equation_element"), exports);
|
|
|
112
113
|
__exportStar(require("./nodes/figcaption"), exports);
|
|
113
114
|
__exportStar(require("./nodes/figure"), exports);
|
|
114
115
|
__exportStar(require("./nodes/figure_element"), exports);
|
|
116
|
+
__exportStar(require("./nodes/general_table_footnote"), exports);
|
|
115
117
|
__exportStar(require("./nodes/footnote"), exports);
|
|
116
118
|
__exportStar(require("./nodes/footnotes_element"), exports);
|
|
117
119
|
__exportStar(require("./nodes/footnotes_section"), exports);
|
|
@@ -170,7 +172,7 @@ exports.schema = new prosemirror_model_1.Schema({
|
|
|
170
172
|
bibliography_element: bibliography_element_1.bibliographyElement,
|
|
171
173
|
bibliography_section: bibliography_section_1.bibliographySection,
|
|
172
174
|
blockquote_element: blockquote_element_1.blockquoteElement,
|
|
173
|
-
|
|
175
|
+
list: list_1.list,
|
|
174
176
|
caption: caption_1.caption,
|
|
175
177
|
caption_title: caption_title_1.captionTitle,
|
|
176
178
|
citation: citation_1.citation,
|
|
@@ -187,6 +189,7 @@ exports.schema = new prosemirror_model_1.Schema({
|
|
|
187
189
|
footnote: footnote_1.footnote,
|
|
188
190
|
footnotes_element: footnotes_element_1.footnotesElement,
|
|
189
191
|
footnotes_section: footnotes_section_1.footnotesSection,
|
|
192
|
+
general_table_footnote: general_table_footnote_1.generalTableFootnote,
|
|
190
193
|
graphical_abstract_section: graphical_abstract_section_1.graphicalAbstractSection,
|
|
191
194
|
hard_break: hard_break_1.hardBreak,
|
|
192
195
|
highlight_marker: highlight_marker_1.highlightMarker,
|
|
@@ -202,7 +205,6 @@ exports.schema = new prosemirror_model_1.Schema({
|
|
|
202
205
|
listing_element: listing_element_1.listingElement,
|
|
203
206
|
manuscript: manuscript_1.manuscript,
|
|
204
207
|
missing_figure: missing_figure_1.missingFigure,
|
|
205
|
-
ordered_list: list_1.orderedList,
|
|
206
208
|
paragraph: paragraph_1.paragraph,
|
|
207
209
|
placeholder: placeholder_1.placeholder,
|
|
208
210
|
placeholder_element: placeholder_element_1.placeholderElement,
|
|
@@ -18,11 +18,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
18
18
|
exports.backmatter = void 0;
|
|
19
19
|
exports.backmatter = {
|
|
20
20
|
content: 'sections*',
|
|
21
|
+
atom: true,
|
|
21
22
|
attrs: {
|
|
22
23
|
id: { default: '' },
|
|
23
|
-
placeholder: { default: ' ' },
|
|
24
24
|
},
|
|
25
|
-
group: 'block
|
|
26
|
-
parseDOM: [{ tag: 'div.backmatter' }],
|
|
25
|
+
group: 'block',
|
|
27
26
|
toDOM: () => ['div', { class: 'backmatter' }, 0],
|
|
28
27
|
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* © 2019 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.generalTableFootnote = void 0;
|
|
19
|
+
exports.generalTableFootnote = {
|
|
20
|
+
content: 'paragraph*',
|
|
21
|
+
attrs: {
|
|
22
|
+
id: { default: '' },
|
|
23
|
+
dataTracked: { default: null },
|
|
24
|
+
},
|
|
25
|
+
group: 'block',
|
|
26
|
+
toDOM: () => ['div', { class: 'general-table-footnote' }, 0],
|
|
27
|
+
};
|
|
@@ -1,24 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/*!
|
|
3
|
-
* © 2019 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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.isListNode = exports.listItem = exports.
|
|
3
|
+
exports.isListNode = exports.listItem = exports.list = exports.getListType = void 0;
|
|
19
4
|
const json_schema_1 = require("@manuscripts/json-schema");
|
|
20
5
|
const attributes_1 = require("../../lib/attributes");
|
|
21
|
-
|
|
6
|
+
const getListType = (style) => {
|
|
7
|
+
switch (style) {
|
|
8
|
+
case 'simple':
|
|
9
|
+
return { type: 'ul', style: 'none' };
|
|
10
|
+
case 'bullet':
|
|
11
|
+
return { type: 'ul', style: 'disc' };
|
|
12
|
+
case 'order':
|
|
13
|
+
return { type: 'ul', style: 'decimal' };
|
|
14
|
+
case 'alpha-lower':
|
|
15
|
+
return { type: 'ul', style: 'lower-alpha' };
|
|
16
|
+
case 'alpha-upper':
|
|
17
|
+
return { type: 'ul', style: 'upper-alpha' };
|
|
18
|
+
case 'roman-lower':
|
|
19
|
+
return { type: 'ul', style: 'lower-roman' };
|
|
20
|
+
case 'roman-upper':
|
|
21
|
+
return { type: 'ul', style: 'upper-roman' };
|
|
22
|
+
default:
|
|
23
|
+
throw new Error(`Unsupported style type: ${style}`);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
exports.getListType = getListType;
|
|
27
|
+
exports.list = {
|
|
22
28
|
content: 'list_item+',
|
|
23
29
|
group: 'block list element',
|
|
24
30
|
attrs: {
|
|
@@ -38,33 +44,6 @@ exports.bulletList = {
|
|
|
38
44
|
};
|
|
39
45
|
},
|
|
40
46
|
},
|
|
41
|
-
],
|
|
42
|
-
toDOM: (node) => {
|
|
43
|
-
const bulletListNode = node;
|
|
44
|
-
return bulletListNode.attrs.id
|
|
45
|
-
? [
|
|
46
|
-
'ul',
|
|
47
|
-
{
|
|
48
|
-
id: bulletListNode.attrs.id,
|
|
49
|
-
'list-type': bulletListNode.attrs.listStyleType,
|
|
50
|
-
class: (0, attributes_1.buildElementClass)(bulletListNode.attrs),
|
|
51
|
-
'data-object-type': json_schema_1.ObjectTypes.ListElement,
|
|
52
|
-
},
|
|
53
|
-
0,
|
|
54
|
-
]
|
|
55
|
-
: ['ul', 0];
|
|
56
|
-
},
|
|
57
|
-
};
|
|
58
|
-
exports.orderedList = {
|
|
59
|
-
content: 'list_item+',
|
|
60
|
-
group: 'block list element',
|
|
61
|
-
attrs: {
|
|
62
|
-
id: { default: '' },
|
|
63
|
-
listStyleType: { default: null },
|
|
64
|
-
paragraphStyle: { default: '' },
|
|
65
|
-
dataTracked: { default: null },
|
|
66
|
-
},
|
|
67
|
-
parseDOM: [
|
|
68
47
|
{
|
|
69
48
|
tag: 'ol',
|
|
70
49
|
getAttrs: (p) => {
|
|
@@ -77,19 +56,18 @@ exports.orderedList = {
|
|
|
77
56
|
},
|
|
78
57
|
],
|
|
79
58
|
toDOM: (node) => {
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
: ['ol', 0];
|
|
59
|
+
const list = node;
|
|
60
|
+
const { type } = (0, exports.getListType)(list.attrs.listStyleType);
|
|
61
|
+
return [
|
|
62
|
+
type,
|
|
63
|
+
{
|
|
64
|
+
id: list.attrs.id,
|
|
65
|
+
'list-type': list.attrs.listStyleType,
|
|
66
|
+
class: (0, attributes_1.buildElementClass)(list.attrs),
|
|
67
|
+
'data-object-type': json_schema_1.ObjectTypes.ListElement,
|
|
68
|
+
},
|
|
69
|
+
0,
|
|
70
|
+
];
|
|
93
71
|
},
|
|
94
72
|
};
|
|
95
73
|
exports.listItem = {
|
|
@@ -122,6 +100,6 @@ exports.listItem = {
|
|
|
122
100
|
};
|
|
123
101
|
const isListNode = (node) => {
|
|
124
102
|
const { nodes } = node.type.schema;
|
|
125
|
-
return node.type === nodes.
|
|
103
|
+
return node.type === nodes.list;
|
|
126
104
|
};
|
|
127
105
|
exports.isListNode = isListNode;
|
|
@@ -21,7 +21,7 @@ exports.tableElementFooter = {
|
|
|
21
21
|
id: { default: '' },
|
|
22
22
|
dataTracked: { default: null },
|
|
23
23
|
},
|
|
24
|
-
content: '
|
|
24
|
+
content: 'general_table_footnote? footnotes_element?',
|
|
25
25
|
group: 'block element',
|
|
26
26
|
toDOM: () => ['table-wrap-foot', 0],
|
|
27
27
|
};
|
|
@@ -38,6 +38,7 @@ const section_group_type_1 = require("../lib/section-group-type");
|
|
|
38
38
|
const schema_1 = require("../schema");
|
|
39
39
|
const builders_1 = require("./builders");
|
|
40
40
|
const highlight_markers_1 = require("./highlight-markers");
|
|
41
|
+
const id_1 = require("./id");
|
|
41
42
|
const object_types_1 = require("./object-types");
|
|
42
43
|
const section_category_1 = require("./section-category");
|
|
43
44
|
const timestamp_1 = require("./timestamp");
|
|
@@ -86,9 +87,6 @@ class Decoder {
|
|
|
86
87
|
const affiliations = getAffiliations(this.modelMap)
|
|
87
88
|
.map((a) => this.decode(a))
|
|
88
89
|
.filter(Boolean);
|
|
89
|
-
if (!affiliations.length) {
|
|
90
|
-
return false;
|
|
91
|
-
}
|
|
92
90
|
return schema_1.schema.nodes.affiliations.createAndFill({}, affiliations);
|
|
93
91
|
}
|
|
94
92
|
createContributorsNode() {
|
|
@@ -99,18 +97,12 @@ class Decoder {
|
|
|
99
97
|
.map((authorNote) => this.decode(authorNote))
|
|
100
98
|
.filter(Boolean);
|
|
101
99
|
const content = [...contributors, ...authorNotes];
|
|
102
|
-
if (!content.length) {
|
|
103
|
-
return false;
|
|
104
|
-
}
|
|
105
100
|
return schema_1.schema.nodes.contributors.createAndFill({}, content);
|
|
106
101
|
}
|
|
107
102
|
createKeywordsNode() {
|
|
108
103
|
const elements = getKeywordElements(this.modelMap)
|
|
109
104
|
.map((e) => this.decode(e))
|
|
110
105
|
.filter(Boolean);
|
|
111
|
-
if (!elements.length) {
|
|
112
|
-
return false;
|
|
113
|
-
}
|
|
114
106
|
return schema_1.schema.nodes.keywords.createAndFill({}, [
|
|
115
107
|
schema_1.schema.nodes.section_title.create({}, schema_1.schema.text('Keywords')),
|
|
116
108
|
...elements,
|
|
@@ -120,9 +112,6 @@ class Decoder {
|
|
|
120
112
|
const elements = getSupplements(this.modelMap)
|
|
121
113
|
.map((e) => this.decode(e))
|
|
122
114
|
.filter(Boolean);
|
|
123
|
-
if (!elements.length) {
|
|
124
|
-
return false;
|
|
125
|
-
}
|
|
126
115
|
return schema_1.schema.nodes.supplements.createAndFill({}, [
|
|
127
116
|
schema_1.schema.nodes.section_title.create({}, schema_1.schema.text('SupplementaryMaterials')),
|
|
128
117
|
...elements,
|
|
@@ -155,7 +144,11 @@ class Decoder {
|
|
|
155
144
|
const abstracts = schema_1.schema.nodes.abstracts.createAndFill({}, groups[section_group_type_1.abstractsType._id]);
|
|
156
145
|
const body = schema_1.schema.nodes.body.createAndFill({}, groups[section_group_type_1.bodyType._id]);
|
|
157
146
|
const backmatter = schema_1.schema.nodes.backmatter.createAndFill({}, groups[section_group_type_1.backmatterType._id]);
|
|
158
|
-
return
|
|
147
|
+
return {
|
|
148
|
+
abstracts,
|
|
149
|
+
body,
|
|
150
|
+
backmatter,
|
|
151
|
+
};
|
|
159
152
|
}
|
|
160
153
|
createCommentNodes(model) {
|
|
161
154
|
const comments = [];
|
|
@@ -398,18 +391,18 @@ class Decoder {
|
|
|
398
391
|
switch (model.elementType) {
|
|
399
392
|
case 'ol':
|
|
400
393
|
return this.parseContents(model.contents || '<ol></ol>', undefined, this.getComments(model), {
|
|
401
|
-
topNode: schema_1.schema.nodes.
|
|
394
|
+
topNode: schema_1.schema.nodes.list.create({
|
|
402
395
|
id: model._id,
|
|
403
|
-
listStyleType: model.listStyleType,
|
|
396
|
+
listStyleType: model.listStyleType || 'order',
|
|
404
397
|
paragraphStyle: model.paragraphStyle,
|
|
405
398
|
comments: comments.map((c) => c.attrs.id),
|
|
406
399
|
}),
|
|
407
400
|
});
|
|
408
401
|
case 'ul':
|
|
409
402
|
return this.parseContents(model.contents || '<ul></ul>', undefined, this.getComments(model), {
|
|
410
|
-
topNode: schema_1.schema.nodes.
|
|
403
|
+
topNode: schema_1.schema.nodes.list.create({
|
|
411
404
|
id: model._id,
|
|
412
|
-
listStyleType: model.listStyleType,
|
|
405
|
+
listStyleType: model.listStyleType || 'bullet',
|
|
413
406
|
paragraphStyle: model.paragraphStyle,
|
|
414
407
|
}),
|
|
415
408
|
});
|
|
@@ -500,10 +493,30 @@ class Decoder {
|
|
|
500
493
|
},
|
|
501
494
|
[json_schema_1.ObjectTypes.TableElementFooter]: (data) => {
|
|
502
495
|
const model = data;
|
|
503
|
-
const
|
|
496
|
+
const contents = [];
|
|
497
|
+
const generalTableFootnotes = [];
|
|
498
|
+
const footnotesElements = [];
|
|
499
|
+
for (const containedObjectID of model.containedObjectIDs) {
|
|
500
|
+
const model = this.modelMap.get(containedObjectID);
|
|
501
|
+
if (model.objectType === json_schema_1.ObjectTypes.ParagraphElement) {
|
|
502
|
+
const paragraph = this.decode(model);
|
|
503
|
+
if (paragraph) {
|
|
504
|
+
generalTableFootnotes.push(paragraph);
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
else {
|
|
508
|
+
footnotesElements.push(this.decode(model));
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
if (generalTableFootnotes && generalTableFootnotes.length) {
|
|
512
|
+
contents.push(schema_1.schema.nodes.general_table_footnote.create({ id: (0, id_1.generateID)(object_types_1.ExtraObjectTypes.GeneralTableFootnote) }, [...generalTableFootnotes]));
|
|
513
|
+
}
|
|
514
|
+
if (footnotesElements && footnotesElements.length) {
|
|
515
|
+
contents.push(...footnotesElements);
|
|
516
|
+
}
|
|
504
517
|
return schema_1.schema.nodes.table_element_footer.create({
|
|
505
518
|
id: model._id,
|
|
506
|
-
},
|
|
519
|
+
}, contents);
|
|
507
520
|
},
|
|
508
521
|
[json_schema_1.ObjectTypes.AuthorNotes]: (data) => {
|
|
509
522
|
const model = data;
|
|
@@ -703,16 +716,24 @@ class Decoder {
|
|
|
703
716
|
};
|
|
704
717
|
this.getModel = (id) => this.modelMap.get(id);
|
|
705
718
|
this.createArticleNode = (manuscriptID) => {
|
|
706
|
-
const
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
719
|
+
const title = this.createTitleNode();
|
|
720
|
+
const contributors = this.createContributorsNode();
|
|
721
|
+
const affiliations = this.createAffiliationsNode();
|
|
722
|
+
const keywords = this.createKeywordsNode();
|
|
723
|
+
const suppl = this.createSupplementsNode();
|
|
724
|
+
const { abstracts, body, backmatter } = this.createContentSections();
|
|
725
|
+
const comments = this.createCommentsNode();
|
|
726
|
+
const contents = [
|
|
727
|
+
title,
|
|
728
|
+
contributors,
|
|
729
|
+
affiliations,
|
|
730
|
+
keywords,
|
|
731
|
+
suppl,
|
|
732
|
+
abstracts,
|
|
733
|
+
body,
|
|
734
|
+
backmatter,
|
|
735
|
+
comments,
|
|
714
736
|
];
|
|
715
|
-
const contents = nodes.filter((node) => node !== false);
|
|
716
737
|
return schema_1.schema.nodes.manuscript.create({
|
|
717
738
|
id: manuscriptID || this.getManuscriptID(),
|
|
718
739
|
}, contents);
|
|
@@ -210,6 +210,18 @@ const containedBibliographyItemIDs = (node) => {
|
|
|
210
210
|
const bibliographyItemNodeType = node.type.schema.nodes.bibliography_item;
|
|
211
211
|
return containedObjectIDs(node, [bibliographyItemNodeType]);
|
|
212
212
|
};
|
|
213
|
+
const tableElementFooterContainedIDs = (node) => {
|
|
214
|
+
const containedGeneralTableFootnoteIDs = containedObjectIDs(node, [
|
|
215
|
+
schema_1.schema.nodes.footnotes_element,
|
|
216
|
+
]);
|
|
217
|
+
for (let i = 0; i < node.childCount; i++) {
|
|
218
|
+
const childNode = node.child(i);
|
|
219
|
+
if (childNode.type === schema_1.schema.nodes.general_table_footnote) {
|
|
220
|
+
containedGeneralTableFootnoteIDs.push(...containedObjectIDs(childNode));
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
return containedGeneralTableFootnoteIDs;
|
|
224
|
+
};
|
|
213
225
|
const containedObjectIDs = (node, nodeTypes) => {
|
|
214
226
|
const ids = [];
|
|
215
227
|
for (let i = 0; i < node.childCount; i++) {
|
|
@@ -262,7 +274,6 @@ const encoders = {
|
|
|
262
274
|
title: (0, exports.inlineContents)(node),
|
|
263
275
|
subtitle: node.attrs.subtitle,
|
|
264
276
|
runningTitle: node.attrs.runningTitle,
|
|
265
|
-
placeholder: node.attrs.placeholder,
|
|
266
277
|
_id: node.attrs._id,
|
|
267
278
|
}),
|
|
268
279
|
bibliography_element: (node) => ({
|
|
@@ -327,8 +338,8 @@ const encoders = {
|
|
|
327
338
|
placeholderInnerHTML: node.attrs.placeholder || '',
|
|
328
339
|
quoteType: 'block',
|
|
329
340
|
}),
|
|
330
|
-
|
|
331
|
-
elementType:
|
|
341
|
+
list: (node) => ({
|
|
342
|
+
elementType: (0, schema_1.getListType)(node.attrs.listStyleType).type,
|
|
332
343
|
contents: listContents(node),
|
|
333
344
|
listStyleType: node.attrs.listStyleType,
|
|
334
345
|
paragraphStyle: node.attrs.paragraphStyle || undefined,
|
|
@@ -383,7 +394,7 @@ const encoders = {
|
|
|
383
394
|
paragraphStyle: node.attrs.paragraphStyle || undefined,
|
|
384
395
|
}),
|
|
385
396
|
table_element_footer: (node) => ({
|
|
386
|
-
containedObjectIDs:
|
|
397
|
+
containedObjectIDs: tableElementFooterContainedIDs(node),
|
|
387
398
|
}),
|
|
388
399
|
author_notes: (node) => ({
|
|
389
400
|
containedObjectIDs: containedObjectIDs(node),
|
|
@@ -421,12 +432,6 @@ const encoders = {
|
|
|
421
432
|
missing_figure: (node) => ({
|
|
422
433
|
position: node.attrs.position || undefined,
|
|
423
434
|
}),
|
|
424
|
-
ordered_list: (node) => ({
|
|
425
|
-
elementType: 'ol',
|
|
426
|
-
contents: listContents(node),
|
|
427
|
-
listStyleType: node.attrs.listStyleType,
|
|
428
|
-
paragraphStyle: node.attrs.paragraphStyle || undefined,
|
|
429
|
-
}),
|
|
430
435
|
paragraph: (node) => ({
|
|
431
436
|
elementType: 'p',
|
|
432
437
|
contents: contents(node),
|
|
@@ -559,6 +564,7 @@ const containerTypes = [
|
|
|
559
564
|
schema_1.schema.nodes.abstracts,
|
|
560
565
|
schema_1.schema.nodes.body,
|
|
561
566
|
schema_1.schema.nodes.backmatter,
|
|
567
|
+
schema_1.schema.nodes.general_table_footnote,
|
|
562
568
|
];
|
|
563
569
|
const placeholderTypes = [
|
|
564
570
|
schema_1.schema.nodes.placeholder,
|
|
@@ -27,8 +27,7 @@ exports.nodeNames = new Map([
|
|
|
27
27
|
[schema_1.schema.nodes.figure_element, 'Figure'],
|
|
28
28
|
[schema_1.schema.nodes.footnote, 'Footnote'],
|
|
29
29
|
[schema_1.schema.nodes.footnotes_element, 'Notes'],
|
|
30
|
-
[schema_1.schema.nodes.
|
|
31
|
-
[schema_1.schema.nodes.ordered_list, 'Ordered List'],
|
|
30
|
+
[schema_1.schema.nodes.list, 'List'],
|
|
32
31
|
[schema_1.schema.nodes.manuscript, 'Manuscript'],
|
|
33
32
|
[schema_1.schema.nodes.paragraph, 'Paragraph'],
|
|
34
33
|
[schema_1.schema.nodes.section, 'Section'],
|
|
@@ -56,8 +56,7 @@ const nodeTitle = (node) => {
|
|
|
56
56
|
return snippetOfNodeType(node, nodes.section_title);
|
|
57
57
|
case nodes.footnotes_element:
|
|
58
58
|
return node.attrs.collateByKind === 'footnote' ? 'Footnotes' : 'Endnotes';
|
|
59
|
-
case nodes.
|
|
60
|
-
case nodes.bullet_list:
|
|
59
|
+
case nodes.list:
|
|
61
60
|
case nodes.blockquote_element:
|
|
62
61
|
case nodes.footnote:
|
|
63
62
|
case nodes.pullquote_element:
|
|
@@ -27,7 +27,7 @@ exports.nodeTypesMap = new Map([
|
|
|
27
27
|
[schema_1.schema.nodes.bibliography_element, json_schema_1.ObjectTypes.BibliographyElement],
|
|
28
28
|
[schema_1.schema.nodes.bibliography_section, json_schema_1.ObjectTypes.Section],
|
|
29
29
|
[schema_1.schema.nodes.blockquote_element, json_schema_1.ObjectTypes.QuoteElement],
|
|
30
|
-
[schema_1.schema.nodes.
|
|
30
|
+
[schema_1.schema.nodes.list, json_schema_1.ObjectTypes.ListElement],
|
|
31
31
|
[schema_1.schema.nodes.citation, json_schema_1.ObjectTypes.Citation],
|
|
32
32
|
[schema_1.schema.nodes.equation, json_schema_1.ObjectTypes.Equation],
|
|
33
33
|
[schema_1.schema.nodes.equation_element, json_schema_1.ObjectTypes.EquationElement],
|
|
@@ -46,7 +46,6 @@ exports.nodeTypesMap = new Map([
|
|
|
46
46
|
[schema_1.schema.nodes.listing, json_schema_1.ObjectTypes.Listing],
|
|
47
47
|
[schema_1.schema.nodes.listing_element, json_schema_1.ObjectTypes.ListingElement],
|
|
48
48
|
[schema_1.schema.nodes.manuscript, json_schema_1.ObjectTypes.Manuscript],
|
|
49
|
-
[schema_1.schema.nodes.ordered_list, json_schema_1.ObjectTypes.ListElement],
|
|
50
49
|
[schema_1.schema.nodes.paragraph, json_schema_1.ObjectTypes.ParagraphElement],
|
|
51
50
|
[schema_1.schema.nodes.pullquote_element, json_schema_1.ObjectTypes.QuoteElement],
|
|
52
51
|
[schema_1.schema.nodes.section, json_schema_1.ObjectTypes.Section],
|
|
@@ -20,6 +20,7 @@ const json_schema_1 = require("@manuscripts/json-schema");
|
|
|
20
20
|
var ExtraObjectTypes;
|
|
21
21
|
(function (ExtraObjectTypes) {
|
|
22
22
|
ExtraObjectTypes["PlaceholderElement"] = "MPPlaceholderElement";
|
|
23
|
+
ExtraObjectTypes["GeneralTableFootnote"] = "MPGeneralTableFootnote";
|
|
23
24
|
})(ExtraObjectTypes = exports.ExtraObjectTypes || (exports.ExtraObjectTypes = {}));
|
|
24
25
|
exports.elementObjects = [
|
|
25
26
|
json_schema_1.ObjectTypes.BibliographyElement,
|
package/dist/cjs/version.js
CHANGED