@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
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import mime from 'mime';
|
|
17
17
|
import { DOMParser, Fragment } from 'prosemirror-model';
|
|
18
|
-
import { schema } from '../../schema';
|
|
18
|
+
import { schema, } from '../../schema';
|
|
19
19
|
import { chooseSectionCategory } from '../../transformer';
|
|
20
20
|
const XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
|
|
21
21
|
const chooseContentType = (graphicNode) => {
|
|
@@ -310,35 +310,46 @@ const nodes = [
|
|
|
310
310
|
},
|
|
311
311
|
},
|
|
312
312
|
{
|
|
313
|
-
tag: '
|
|
314
|
-
node: '
|
|
315
|
-
context: '
|
|
313
|
+
tag: 'general-table-footnote',
|
|
314
|
+
node: 'general_table_footnote',
|
|
315
|
+
context: 'table_element_footer/',
|
|
316
316
|
getAttrs: (node) => {
|
|
317
317
|
const element = node;
|
|
318
318
|
return {
|
|
319
319
|
id: element.getAttribute('id'),
|
|
320
|
-
kind: 'footnote',
|
|
321
320
|
};
|
|
322
321
|
},
|
|
322
|
+
getContent: (node) => {
|
|
323
|
+
const paragraphs = [];
|
|
324
|
+
node.childNodes.forEach((p) => {
|
|
325
|
+
const paragraph = schema.nodes.paragraph.create();
|
|
326
|
+
const content = jatsBodyDOMParser.parse(p, {
|
|
327
|
+
topNode: paragraph,
|
|
328
|
+
});
|
|
329
|
+
paragraphs.push(content);
|
|
330
|
+
});
|
|
331
|
+
return Fragment.from([...paragraphs]);
|
|
332
|
+
},
|
|
323
333
|
},
|
|
324
334
|
{
|
|
325
|
-
tag: '
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
{
|
|
329
|
-
tag: 'list[list-type=bullet]',
|
|
330
|
-
node: 'bullet_list',
|
|
335
|
+
tag: 'fn',
|
|
336
|
+
node: 'footnote',
|
|
337
|
+
context: 'footnotes_element/|table_element_footer/',
|
|
331
338
|
getAttrs: (node) => {
|
|
332
339
|
const element = node;
|
|
333
340
|
return {
|
|
334
341
|
id: element.getAttribute('id'),
|
|
335
|
-
|
|
342
|
+
kind: 'footnote',
|
|
336
343
|
};
|
|
337
344
|
},
|
|
338
345
|
},
|
|
339
346
|
{
|
|
340
|
-
tag: '
|
|
341
|
-
|
|
347
|
+
tag: 'front',
|
|
348
|
+
ignore: true,
|
|
349
|
+
},
|
|
350
|
+
{
|
|
351
|
+
tag: 'list',
|
|
352
|
+
node: 'list',
|
|
342
353
|
getAttrs: (node) => {
|
|
343
354
|
const element = node;
|
|
344
355
|
return {
|
|
@@ -239,6 +239,18 @@ export const jatsBodyTransformations = {
|
|
|
239
239
|
}
|
|
240
240
|
tableWrap.insertBefore(colgroup, table.nextSibling);
|
|
241
241
|
}
|
|
242
|
+
const tableFootWrap = tableWrap.querySelector('table-wrap-foot');
|
|
243
|
+
if (tableFootWrap) {
|
|
244
|
+
const paragraphs = tableFootWrap.querySelectorAll(':scope > p');
|
|
245
|
+
if (paragraphs.length) {
|
|
246
|
+
const generalTableFootnote = createElement('general-table-footnote');
|
|
247
|
+
for (const paragraph of paragraphs) {
|
|
248
|
+
removeNodeFromParent(paragraph);
|
|
249
|
+
generalTableFootnote.append(paragraph);
|
|
250
|
+
}
|
|
251
|
+
tableFootWrap.prepend(generalTableFootnote);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
242
254
|
});
|
|
243
255
|
},
|
|
244
256
|
orderTableFootnote(doc, body) {
|
|
@@ -32,6 +32,10 @@ const updateNodeID = (node, replacements, warnings) => {
|
|
|
32
32
|
node.attrs = Object.assign(Object.assign({}, node.attrs), { id: `InlineMathFragment:${uuidv4()}` });
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
|
+
if (node.type === schema.nodes.general_table_footnote) {
|
|
36
|
+
node.attrs = Object.assign(Object.assign({}, node.attrs), { id: `GeneralTableFootnote:${uuidv4()}` });
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
35
39
|
if (!('id' in node.attrs)) {
|
|
36
40
|
return;
|
|
37
41
|
}
|
|
@@ -612,11 +612,13 @@ export class JATSExporter {
|
|
|
612
612
|
0,
|
|
613
613
|
],
|
|
614
614
|
blockquote_element: () => ['disp-quote', { 'content-type': 'quote' }, 0],
|
|
615
|
-
|
|
615
|
+
list: (node) => {
|
|
616
616
|
var _a;
|
|
617
617
|
return [
|
|
618
618
|
'list',
|
|
619
|
-
{
|
|
619
|
+
{
|
|
620
|
+
'list-type': (_a = node.attrs.listStyleType) !== null && _a !== void 0 ? _a : 'bullet',
|
|
621
|
+
},
|
|
620
622
|
0,
|
|
621
623
|
];
|
|
622
624
|
},
|
|
@@ -671,6 +673,12 @@ export class JATSExporter {
|
|
|
671
673
|
equation: (node) => {
|
|
672
674
|
return this.createEquation(node);
|
|
673
675
|
},
|
|
676
|
+
general_table_footnote: (node) => {
|
|
677
|
+
const el = this.document.createElement('general-table-footnote');
|
|
678
|
+
el.setAttribute('id', normalizeID(node.attrs.id));
|
|
679
|
+
processChildNodes(el, node, schema.nodes.general_table_footnote);
|
|
680
|
+
return el;
|
|
681
|
+
},
|
|
674
682
|
inline_equation: (node) => {
|
|
675
683
|
const eqElement = this.document.createElement('inline-formula');
|
|
676
684
|
const equation = this.createEquation(node, true);
|
|
@@ -773,14 +781,6 @@ export class JATSExporter {
|
|
|
773
781
|
graphic.setAttributeNS(XLINK_NAMESPACE, 'xlink:href', '');
|
|
774
782
|
return graphic;
|
|
775
783
|
},
|
|
776
|
-
ordered_list: (node) => {
|
|
777
|
-
var _a;
|
|
778
|
-
return [
|
|
779
|
-
'list',
|
|
780
|
-
{ 'list-type': (_a = node.attrs.listStyleType) !== null && _a !== void 0 ? _a : 'order' },
|
|
781
|
-
0,
|
|
782
|
-
];
|
|
783
|
-
},
|
|
784
784
|
paragraph: (node) => {
|
|
785
785
|
if (!node.childCount) {
|
|
786
786
|
return '';
|
|
@@ -1294,6 +1294,15 @@ export class JATSExporter {
|
|
|
1294
1294
|
label.remove();
|
|
1295
1295
|
}
|
|
1296
1296
|
}
|
|
1297
|
+
if (isNodeType(node, 'general_table_footnote')) {
|
|
1298
|
+
const generalTableFootnote = body.querySelector(`#${normalizeID(node.attrs.id)}`);
|
|
1299
|
+
if (generalTableFootnote) {
|
|
1300
|
+
Array.from(generalTableFootnote.childNodes).forEach((cn) => {
|
|
1301
|
+
generalTableFootnote.before(cn);
|
|
1302
|
+
});
|
|
1303
|
+
generalTableFootnote.remove();
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
1297
1306
|
if (isNodeType(node, 'table_element')) {
|
|
1298
1307
|
const tableElement = body.querySelector(`#${normalizeID(node.attrs.id)}`);
|
|
1299
1308
|
if (tableElement) {
|
package/dist/es/schema/index.js
CHANGED
|
@@ -44,6 +44,7 @@ import { figureElement } from './nodes/figure_element';
|
|
|
44
44
|
import { footnote } from './nodes/footnote';
|
|
45
45
|
import { footnotesElement } from './nodes/footnotes_element';
|
|
46
46
|
import { footnotesSection } from './nodes/footnotes_section';
|
|
47
|
+
import { generalTableFootnote } from './nodes/general_table_footnote';
|
|
47
48
|
import { graphicalAbstractSection } from './nodes/graphical_abstract_section';
|
|
48
49
|
import { hardBreak } from './nodes/hard_break';
|
|
49
50
|
import { highlightMarker } from './nodes/highlight_marker';
|
|
@@ -54,7 +55,7 @@ import { keywordGroup } from './nodes/keyword_group';
|
|
|
54
55
|
import { keywords } from './nodes/keywords';
|
|
55
56
|
import { keywordsElement } from './nodes/keywords_element';
|
|
56
57
|
import { link } from './nodes/link';
|
|
57
|
-
import {
|
|
58
|
+
import { list, listItem } from './nodes/list';
|
|
58
59
|
import { listing } from './nodes/listing';
|
|
59
60
|
import { listingElement } from './nodes/listing_element';
|
|
60
61
|
import { manuscript } from './nodes/manuscript';
|
|
@@ -95,6 +96,7 @@ export * from './nodes/equation_element';
|
|
|
95
96
|
export * from './nodes/figcaption';
|
|
96
97
|
export * from './nodes/figure';
|
|
97
98
|
export * from './nodes/figure_element';
|
|
99
|
+
export * from './nodes/general_table_footnote';
|
|
98
100
|
export * from './nodes/footnote';
|
|
99
101
|
export * from './nodes/footnotes_element';
|
|
100
102
|
export * from './nodes/footnotes_section';
|
|
@@ -153,7 +155,7 @@ export const schema = new Schema({
|
|
|
153
155
|
bibliography_element: bibliographyElement,
|
|
154
156
|
bibliography_section: bibliographySection,
|
|
155
157
|
blockquote_element: blockquoteElement,
|
|
156
|
-
|
|
158
|
+
list: list,
|
|
157
159
|
caption,
|
|
158
160
|
caption_title: captionTitle,
|
|
159
161
|
citation,
|
|
@@ -170,6 +172,7 @@ export const schema = new Schema({
|
|
|
170
172
|
footnote,
|
|
171
173
|
footnotes_element: footnotesElement,
|
|
172
174
|
footnotes_section: footnotesSection,
|
|
175
|
+
general_table_footnote: generalTableFootnote,
|
|
173
176
|
graphical_abstract_section: graphicalAbstractSection,
|
|
174
177
|
hard_break: hardBreak,
|
|
175
178
|
highlight_marker: highlightMarker,
|
|
@@ -185,7 +188,6 @@ export const schema = new Schema({
|
|
|
185
188
|
listing_element: listingElement,
|
|
186
189
|
manuscript,
|
|
187
190
|
missing_figure: missingFigure,
|
|
188
|
-
ordered_list: orderedList,
|
|
189
191
|
paragraph,
|
|
190
192
|
placeholder,
|
|
191
193
|
placeholder_element: placeholderElement,
|
|
@@ -15,11 +15,10 @@
|
|
|
15
15
|
*/
|
|
16
16
|
export const backmatter = {
|
|
17
17
|
content: 'sections*',
|
|
18
|
+
atom: true,
|
|
18
19
|
attrs: {
|
|
19
20
|
id: { default: '' },
|
|
20
|
-
placeholder: { default: ' ' },
|
|
21
21
|
},
|
|
22
|
-
group: 'block
|
|
23
|
-
parseDOM: [{ tag: 'div.backmatter' }],
|
|
22
|
+
group: 'block',
|
|
24
23
|
toDOM: () => ['div', { class: 'backmatter' }, 0],
|
|
25
24
|
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* © 2019 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
|
+
export const generalTableFootnote = {
|
|
17
|
+
content: 'paragraph*',
|
|
18
|
+
attrs: {
|
|
19
|
+
id: { default: '' },
|
|
20
|
+
dataTracked: { default: null },
|
|
21
|
+
},
|
|
22
|
+
group: 'block',
|
|
23
|
+
toDOM: () => ['div', { class: 'general-table-footnote' }, 0],
|
|
24
|
+
};
|
|
@@ -1,21 +1,26 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* © 2019 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
1
|
import { ObjectTypes } from '@manuscripts/json-schema';
|
|
17
2
|
import { buildElementClass } from '../../lib/attributes';
|
|
18
|
-
export const
|
|
3
|
+
export const getListType = (style) => {
|
|
4
|
+
switch (style) {
|
|
5
|
+
case 'simple':
|
|
6
|
+
return { type: 'ul', style: 'none' };
|
|
7
|
+
case 'bullet':
|
|
8
|
+
return { type: 'ul', style: 'disc' };
|
|
9
|
+
case 'order':
|
|
10
|
+
return { type: 'ul', style: 'decimal' };
|
|
11
|
+
case 'alpha-lower':
|
|
12
|
+
return { type: 'ul', style: 'lower-alpha' };
|
|
13
|
+
case 'alpha-upper':
|
|
14
|
+
return { type: 'ul', style: 'upper-alpha' };
|
|
15
|
+
case 'roman-lower':
|
|
16
|
+
return { type: 'ul', style: 'lower-roman' };
|
|
17
|
+
case 'roman-upper':
|
|
18
|
+
return { type: 'ul', style: 'upper-roman' };
|
|
19
|
+
default:
|
|
20
|
+
throw new Error(`Unsupported style type: ${style}`);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
export const list = {
|
|
19
24
|
content: 'list_item+',
|
|
20
25
|
group: 'block list element',
|
|
21
26
|
attrs: {
|
|
@@ -35,33 +40,6 @@ export const bulletList = {
|
|
|
35
40
|
};
|
|
36
41
|
},
|
|
37
42
|
},
|
|
38
|
-
],
|
|
39
|
-
toDOM: (node) => {
|
|
40
|
-
const bulletListNode = node;
|
|
41
|
-
return bulletListNode.attrs.id
|
|
42
|
-
? [
|
|
43
|
-
'ul',
|
|
44
|
-
{
|
|
45
|
-
id: bulletListNode.attrs.id,
|
|
46
|
-
'list-type': bulletListNode.attrs.listStyleType,
|
|
47
|
-
class: buildElementClass(bulletListNode.attrs),
|
|
48
|
-
'data-object-type': ObjectTypes.ListElement,
|
|
49
|
-
},
|
|
50
|
-
0,
|
|
51
|
-
]
|
|
52
|
-
: ['ul', 0];
|
|
53
|
-
},
|
|
54
|
-
};
|
|
55
|
-
export const orderedList = {
|
|
56
|
-
content: 'list_item+',
|
|
57
|
-
group: 'block list element',
|
|
58
|
-
attrs: {
|
|
59
|
-
id: { default: '' },
|
|
60
|
-
listStyleType: { default: null },
|
|
61
|
-
paragraphStyle: { default: '' },
|
|
62
|
-
dataTracked: { default: null },
|
|
63
|
-
},
|
|
64
|
-
parseDOM: [
|
|
65
43
|
{
|
|
66
44
|
tag: 'ol',
|
|
67
45
|
getAttrs: (p) => {
|
|
@@ -74,19 +52,18 @@ export const orderedList = {
|
|
|
74
52
|
},
|
|
75
53
|
],
|
|
76
54
|
toDOM: (node) => {
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
: ['ol', 0];
|
|
55
|
+
const list = node;
|
|
56
|
+
const { type } = getListType(list.attrs.listStyleType);
|
|
57
|
+
return [
|
|
58
|
+
type,
|
|
59
|
+
{
|
|
60
|
+
id: list.attrs.id,
|
|
61
|
+
'list-type': list.attrs.listStyleType,
|
|
62
|
+
class: buildElementClass(list.attrs),
|
|
63
|
+
'data-object-type': ObjectTypes.ListElement,
|
|
64
|
+
},
|
|
65
|
+
0,
|
|
66
|
+
];
|
|
90
67
|
},
|
|
91
68
|
};
|
|
92
69
|
export const listItem = {
|
|
@@ -119,5 +96,5 @@ export const listItem = {
|
|
|
119
96
|
};
|
|
120
97
|
export const isListNode = (node) => {
|
|
121
98
|
const { nodes } = node.type.schema;
|
|
122
|
-
return node.type === nodes.
|
|
99
|
+
return node.type === nodes.list;
|
|
123
100
|
};
|
|
@@ -18,7 +18,7 @@ export const tableElementFooter = {
|
|
|
18
18
|
id: { default: '' },
|
|
19
19
|
dataTracked: { default: null },
|
|
20
20
|
},
|
|
21
|
-
content: '
|
|
21
|
+
content: 'general_table_footnote? footnotes_element?',
|
|
22
22
|
group: 'block element',
|
|
23
23
|
toDOM: () => ['table-wrap-foot', 0],
|
|
24
24
|
};
|
|
@@ -32,6 +32,7 @@ import { abstractsType, backmatterType, bodyType, } from '../lib/section-group-t
|
|
|
32
32
|
import { schema, } from '../schema';
|
|
33
33
|
import { buildTitles } from './builders';
|
|
34
34
|
import { insertHighlightMarkers } from './highlight-markers';
|
|
35
|
+
import { generateID } from './id';
|
|
35
36
|
import { ExtraObjectTypes, isCommentAnnotation, isManuscript, } from './object-types';
|
|
36
37
|
import { chooseSectionLableName, chooseSectionNodeType, chooseSecType, getSectionGroupType, guessSectionCategory, } from './section-category';
|
|
37
38
|
import { timestamp } from './timestamp';
|
|
@@ -77,9 +78,6 @@ export class Decoder {
|
|
|
77
78
|
const affiliations = getAffiliations(this.modelMap)
|
|
78
79
|
.map((a) => this.decode(a))
|
|
79
80
|
.filter(Boolean);
|
|
80
|
-
if (!affiliations.length) {
|
|
81
|
-
return false;
|
|
82
|
-
}
|
|
83
81
|
return schema.nodes.affiliations.createAndFill({}, affiliations);
|
|
84
82
|
}
|
|
85
83
|
createContributorsNode() {
|
|
@@ -90,18 +88,12 @@ export class Decoder {
|
|
|
90
88
|
.map((authorNote) => this.decode(authorNote))
|
|
91
89
|
.filter(Boolean);
|
|
92
90
|
const content = [...contributors, ...authorNotes];
|
|
93
|
-
if (!content.length) {
|
|
94
|
-
return false;
|
|
95
|
-
}
|
|
96
91
|
return schema.nodes.contributors.createAndFill({}, content);
|
|
97
92
|
}
|
|
98
93
|
createKeywordsNode() {
|
|
99
94
|
const elements = getKeywordElements(this.modelMap)
|
|
100
95
|
.map((e) => this.decode(e))
|
|
101
96
|
.filter(Boolean);
|
|
102
|
-
if (!elements.length) {
|
|
103
|
-
return false;
|
|
104
|
-
}
|
|
105
97
|
return schema.nodes.keywords.createAndFill({}, [
|
|
106
98
|
schema.nodes.section_title.create({}, schema.text('Keywords')),
|
|
107
99
|
...elements,
|
|
@@ -111,9 +103,6 @@ export class Decoder {
|
|
|
111
103
|
const elements = getSupplements(this.modelMap)
|
|
112
104
|
.map((e) => this.decode(e))
|
|
113
105
|
.filter(Boolean);
|
|
114
|
-
if (!elements.length) {
|
|
115
|
-
return false;
|
|
116
|
-
}
|
|
117
106
|
return schema.nodes.supplements.createAndFill({}, [
|
|
118
107
|
schema.nodes.section_title.create({}, schema.text('SupplementaryMaterials')),
|
|
119
108
|
...elements,
|
|
@@ -146,7 +135,11 @@ export class Decoder {
|
|
|
146
135
|
const abstracts = schema.nodes.abstracts.createAndFill({}, groups[abstractsType._id]);
|
|
147
136
|
const body = schema.nodes.body.createAndFill({}, groups[bodyType._id]);
|
|
148
137
|
const backmatter = schema.nodes.backmatter.createAndFill({}, groups[backmatterType._id]);
|
|
149
|
-
return
|
|
138
|
+
return {
|
|
139
|
+
abstracts,
|
|
140
|
+
body,
|
|
141
|
+
backmatter,
|
|
142
|
+
};
|
|
150
143
|
}
|
|
151
144
|
createCommentNodes(model) {
|
|
152
145
|
const comments = [];
|
|
@@ -389,18 +382,18 @@ export class Decoder {
|
|
|
389
382
|
switch (model.elementType) {
|
|
390
383
|
case 'ol':
|
|
391
384
|
return this.parseContents(model.contents || '<ol></ol>', undefined, this.getComments(model), {
|
|
392
|
-
topNode: schema.nodes.
|
|
385
|
+
topNode: schema.nodes.list.create({
|
|
393
386
|
id: model._id,
|
|
394
|
-
listStyleType: model.listStyleType,
|
|
387
|
+
listStyleType: model.listStyleType || 'order',
|
|
395
388
|
paragraphStyle: model.paragraphStyle,
|
|
396
389
|
comments: comments.map((c) => c.attrs.id),
|
|
397
390
|
}),
|
|
398
391
|
});
|
|
399
392
|
case 'ul':
|
|
400
393
|
return this.parseContents(model.contents || '<ul></ul>', undefined, this.getComments(model), {
|
|
401
|
-
topNode: schema.nodes.
|
|
394
|
+
topNode: schema.nodes.list.create({
|
|
402
395
|
id: model._id,
|
|
403
|
-
listStyleType: model.listStyleType,
|
|
396
|
+
listStyleType: model.listStyleType || 'bullet',
|
|
404
397
|
paragraphStyle: model.paragraphStyle,
|
|
405
398
|
}),
|
|
406
399
|
});
|
|
@@ -491,10 +484,30 @@ export class Decoder {
|
|
|
491
484
|
},
|
|
492
485
|
[ObjectTypes.TableElementFooter]: (data) => {
|
|
493
486
|
const model = data;
|
|
494
|
-
const
|
|
487
|
+
const contents = [];
|
|
488
|
+
const generalTableFootnotes = [];
|
|
489
|
+
const footnotesElements = [];
|
|
490
|
+
for (const containedObjectID of model.containedObjectIDs) {
|
|
491
|
+
const model = this.modelMap.get(containedObjectID);
|
|
492
|
+
if (model.objectType === ObjectTypes.ParagraphElement) {
|
|
493
|
+
const paragraph = this.decode(model);
|
|
494
|
+
if (paragraph) {
|
|
495
|
+
generalTableFootnotes.push(paragraph);
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
else {
|
|
499
|
+
footnotesElements.push(this.decode(model));
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
if (generalTableFootnotes && generalTableFootnotes.length) {
|
|
503
|
+
contents.push(schema.nodes.general_table_footnote.create({ id: generateID(ExtraObjectTypes.GeneralTableFootnote) }, [...generalTableFootnotes]));
|
|
504
|
+
}
|
|
505
|
+
if (footnotesElements && footnotesElements.length) {
|
|
506
|
+
contents.push(...footnotesElements);
|
|
507
|
+
}
|
|
495
508
|
return schema.nodes.table_element_footer.create({
|
|
496
509
|
id: model._id,
|
|
497
|
-
},
|
|
510
|
+
}, contents);
|
|
498
511
|
},
|
|
499
512
|
[ObjectTypes.AuthorNotes]: (data) => {
|
|
500
513
|
const model = data;
|
|
@@ -694,16 +707,24 @@ export class Decoder {
|
|
|
694
707
|
};
|
|
695
708
|
this.getModel = (id) => this.modelMap.get(id);
|
|
696
709
|
this.createArticleNode = (manuscriptID) => {
|
|
697
|
-
const
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
710
|
+
const title = this.createTitleNode();
|
|
711
|
+
const contributors = this.createContributorsNode();
|
|
712
|
+
const affiliations = this.createAffiliationsNode();
|
|
713
|
+
const keywords = this.createKeywordsNode();
|
|
714
|
+
const suppl = this.createSupplementsNode();
|
|
715
|
+
const { abstracts, body, backmatter } = this.createContentSections();
|
|
716
|
+
const comments = this.createCommentsNode();
|
|
717
|
+
const contents = [
|
|
718
|
+
title,
|
|
719
|
+
contributors,
|
|
720
|
+
affiliations,
|
|
721
|
+
keywords,
|
|
722
|
+
suppl,
|
|
723
|
+
abstracts,
|
|
724
|
+
body,
|
|
725
|
+
backmatter,
|
|
726
|
+
comments,
|
|
705
727
|
];
|
|
706
|
-
const contents = nodes.filter((node) => node !== false);
|
|
707
728
|
return schema.nodes.manuscript.create({
|
|
708
729
|
id: manuscriptID || this.getManuscriptID(),
|
|
709
730
|
}, contents);
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
import { DOMSerializer } from 'prosemirror-model';
|
|
17
17
|
import serializeToXML from 'w3c-xmlserializer';
|
|
18
18
|
import { iterateChildren } from '../lib/utils';
|
|
19
|
-
import { hasGroup, isHighlightMarkerNode, isManuscriptNode, isSectionNode, schema, } from '../schema';
|
|
19
|
+
import { getListType, hasGroup, isHighlightMarkerNode, isManuscriptNode, isSectionNode, schema, } from '../schema';
|
|
20
20
|
import { auxiliaryObjectTypes, buildAttribution, buildElementsOrder, buildFootnotesOrder, } from './builders';
|
|
21
21
|
import { extractCommentMarkers } from './highlight-markers';
|
|
22
22
|
import { nodeTypesMap } from './node-types';
|
|
@@ -202,6 +202,18 @@ const containedBibliographyItemIDs = (node) => {
|
|
|
202
202
|
const bibliographyItemNodeType = node.type.schema.nodes.bibliography_item;
|
|
203
203
|
return containedObjectIDs(node, [bibliographyItemNodeType]);
|
|
204
204
|
};
|
|
205
|
+
const tableElementFooterContainedIDs = (node) => {
|
|
206
|
+
const containedGeneralTableFootnoteIDs = containedObjectIDs(node, [
|
|
207
|
+
schema.nodes.footnotes_element,
|
|
208
|
+
]);
|
|
209
|
+
for (let i = 0; i < node.childCount; i++) {
|
|
210
|
+
const childNode = node.child(i);
|
|
211
|
+
if (childNode.type === schema.nodes.general_table_footnote) {
|
|
212
|
+
containedGeneralTableFootnoteIDs.push(...containedObjectIDs(childNode));
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
return containedGeneralTableFootnoteIDs;
|
|
216
|
+
};
|
|
205
217
|
const containedObjectIDs = (node, nodeTypes) => {
|
|
206
218
|
const ids = [];
|
|
207
219
|
for (let i = 0; i < node.childCount; i++) {
|
|
@@ -254,7 +266,6 @@ const encoders = {
|
|
|
254
266
|
title: inlineContents(node),
|
|
255
267
|
subtitle: node.attrs.subtitle,
|
|
256
268
|
runningTitle: node.attrs.runningTitle,
|
|
257
|
-
placeholder: node.attrs.placeholder,
|
|
258
269
|
_id: node.attrs._id,
|
|
259
270
|
}),
|
|
260
271
|
bibliography_element: (node) => ({
|
|
@@ -319,8 +330,8 @@ const encoders = {
|
|
|
319
330
|
placeholderInnerHTML: node.attrs.placeholder || '',
|
|
320
331
|
quoteType: 'block',
|
|
321
332
|
}),
|
|
322
|
-
|
|
323
|
-
elementType:
|
|
333
|
+
list: (node) => ({
|
|
334
|
+
elementType: getListType(node.attrs.listStyleType).type,
|
|
324
335
|
contents: listContents(node),
|
|
325
336
|
listStyleType: node.attrs.listStyleType,
|
|
326
337
|
paragraphStyle: node.attrs.paragraphStyle || undefined,
|
|
@@ -375,7 +386,7 @@ const encoders = {
|
|
|
375
386
|
paragraphStyle: node.attrs.paragraphStyle || undefined,
|
|
376
387
|
}),
|
|
377
388
|
table_element_footer: (node) => ({
|
|
378
|
-
containedObjectIDs:
|
|
389
|
+
containedObjectIDs: tableElementFooterContainedIDs(node),
|
|
379
390
|
}),
|
|
380
391
|
author_notes: (node) => ({
|
|
381
392
|
containedObjectIDs: containedObjectIDs(node),
|
|
@@ -413,12 +424,6 @@ const encoders = {
|
|
|
413
424
|
missing_figure: (node) => ({
|
|
414
425
|
position: node.attrs.position || undefined,
|
|
415
426
|
}),
|
|
416
|
-
ordered_list: (node) => ({
|
|
417
|
-
elementType: 'ol',
|
|
418
|
-
contents: listContents(node),
|
|
419
|
-
listStyleType: node.attrs.listStyleType,
|
|
420
|
-
paragraphStyle: node.attrs.paragraphStyle || undefined,
|
|
421
|
-
}),
|
|
422
427
|
paragraph: (node) => ({
|
|
423
428
|
elementType: 'p',
|
|
424
429
|
contents: contents(node),
|
|
@@ -550,6 +555,7 @@ const containerTypes = [
|
|
|
550
555
|
schema.nodes.abstracts,
|
|
551
556
|
schema.nodes.body,
|
|
552
557
|
schema.nodes.backmatter,
|
|
558
|
+
schema.nodes.general_table_footnote,
|
|
553
559
|
];
|
|
554
560
|
const placeholderTypes = [
|
|
555
561
|
schema.nodes.placeholder,
|
|
@@ -24,8 +24,7 @@ export const nodeNames = new Map([
|
|
|
24
24
|
[schema.nodes.figure_element, 'Figure'],
|
|
25
25
|
[schema.nodes.footnote, 'Footnote'],
|
|
26
26
|
[schema.nodes.footnotes_element, 'Notes'],
|
|
27
|
-
[schema.nodes.
|
|
28
|
-
[schema.nodes.ordered_list, 'Ordered List'],
|
|
27
|
+
[schema.nodes.list, 'List'],
|
|
29
28
|
[schema.nodes.manuscript, 'Manuscript'],
|
|
30
29
|
[schema.nodes.paragraph, 'Paragraph'],
|
|
31
30
|
[schema.nodes.section, 'Section'],
|
|
@@ -53,8 +53,7 @@ export const nodeTitle = (node) => {
|
|
|
53
53
|
return snippetOfNodeType(node, nodes.section_title);
|
|
54
54
|
case nodes.footnotes_element:
|
|
55
55
|
return node.attrs.collateByKind === 'footnote' ? 'Footnotes' : 'Endnotes';
|
|
56
|
-
case nodes.
|
|
57
|
-
case nodes.bullet_list:
|
|
56
|
+
case nodes.list:
|
|
58
57
|
case nodes.blockquote_element:
|
|
59
58
|
case nodes.footnote:
|
|
60
59
|
case nodes.pullquote_element:
|
|
@@ -24,7 +24,7 @@ export const nodeTypesMap = new Map([
|
|
|
24
24
|
[schema.nodes.bibliography_element, ObjectTypes.BibliographyElement],
|
|
25
25
|
[schema.nodes.bibliography_section, ObjectTypes.Section],
|
|
26
26
|
[schema.nodes.blockquote_element, ObjectTypes.QuoteElement],
|
|
27
|
-
[schema.nodes.
|
|
27
|
+
[schema.nodes.list, ObjectTypes.ListElement],
|
|
28
28
|
[schema.nodes.citation, ObjectTypes.Citation],
|
|
29
29
|
[schema.nodes.equation, ObjectTypes.Equation],
|
|
30
30
|
[schema.nodes.equation_element, ObjectTypes.EquationElement],
|
|
@@ -43,7 +43,6 @@ export const nodeTypesMap = new Map([
|
|
|
43
43
|
[schema.nodes.listing, ObjectTypes.Listing],
|
|
44
44
|
[schema.nodes.listing_element, ObjectTypes.ListingElement],
|
|
45
45
|
[schema.nodes.manuscript, ObjectTypes.Manuscript],
|
|
46
|
-
[schema.nodes.ordered_list, ObjectTypes.ListElement],
|
|
47
46
|
[schema.nodes.paragraph, ObjectTypes.ParagraphElement],
|
|
48
47
|
[schema.nodes.pullquote_element, ObjectTypes.QuoteElement],
|
|
49
48
|
[schema.nodes.section, ObjectTypes.Section],
|
|
@@ -17,6 +17,7 @@ import { manuscriptIDTypes, ObjectTypes, } from '@manuscripts/json-schema';
|
|
|
17
17
|
export var ExtraObjectTypes;
|
|
18
18
|
(function (ExtraObjectTypes) {
|
|
19
19
|
ExtraObjectTypes["PlaceholderElement"] = "MPPlaceholderElement";
|
|
20
|
+
ExtraObjectTypes["GeneralTableFootnote"] = "MPGeneralTableFootnote";
|
|
20
21
|
})(ExtraObjectTypes || (ExtraObjectTypes = {}));
|
|
21
22
|
export const elementObjects = [
|
|
22
23
|
ObjectTypes.BibliographyElement,
|