@manuscripts/transform 2.3.8-LEAN-1330.1 → 2.3.8
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 +2 -13
- package/dist/cjs/jats/jats-exporter.js +4 -10
- package/dist/cjs/schema/index.js +1 -2
- package/dist/cjs/schema/nodes/list.js +36 -58
- package/dist/cjs/schema/nodes/manuscript.js +0 -1
- package/dist/cjs/transformer/decode.js +4 -12
- package/dist/cjs/transformer/encode.js +2 -8
- 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/version.js +1 -1
- package/dist/es/jats/importer/jats-body-dom-parser.js +2 -13
- package/dist/es/jats/jats-exporter.js +4 -10
- package/dist/es/schema/index.js +2 -3
- package/dist/es/schema/nodes/list.js +34 -57
- package/dist/es/schema/nodes/manuscript.js +0 -1
- package/dist/es/transformer/decode.js +4 -12
- package/dist/es/transformer/encode.js +3 -9
- 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/version.js +1 -1
- package/dist/types/schema/nodes/list.d.ts +9 -26
- package/dist/types/schema/nodes/manuscript.d.ts +0 -1
- package/dist/types/schema/types.d.ts +1 -1
- package/dist/types/transformer/decode.d.ts +0 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -1
|
@@ -354,19 +354,8 @@ const nodes = [
|
|
|
354
354
|
ignore: true,
|
|
355
355
|
},
|
|
356
356
|
{
|
|
357
|
-
tag: 'list
|
|
358
|
-
node: '
|
|
359
|
-
getAttrs: (node) => {
|
|
360
|
-
const element = node;
|
|
361
|
-
return {
|
|
362
|
-
id: element.getAttribute('id'),
|
|
363
|
-
listStyleType: element.getAttribute('list-type'),
|
|
364
|
-
};
|
|
365
|
-
},
|
|
366
|
-
},
|
|
367
|
-
{
|
|
368
|
-
tag: 'list[list-type]',
|
|
369
|
-
node: 'ordered_list',
|
|
357
|
+
tag: 'list',
|
|
358
|
+
node: 'list',
|
|
370
359
|
getAttrs: (node) => {
|
|
371
360
|
const element = node;
|
|
372
361
|
return {
|
|
@@ -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
|
},
|
|
@@ -787,14 +789,6 @@ class JATSExporter {
|
|
|
787
789
|
graphic.setAttributeNS(XLINK_NAMESPACE, 'xlink:href', '');
|
|
788
790
|
return graphic;
|
|
789
791
|
},
|
|
790
|
-
ordered_list: (node) => {
|
|
791
|
-
var _a;
|
|
792
|
-
return [
|
|
793
|
-
'list',
|
|
794
|
-
{ 'list-type': (_a = node.attrs.listStyleType) !== null && _a !== void 0 ? _a : 'order' },
|
|
795
|
-
0,
|
|
796
|
-
];
|
|
797
|
-
},
|
|
798
792
|
paragraph: (node) => {
|
|
799
793
|
if (!node.childCount) {
|
|
800
794
|
return '';
|
package/dist/cjs/schema/index.js
CHANGED
|
@@ -172,7 +172,7 @@ exports.schema = new prosemirror_model_1.Schema({
|
|
|
172
172
|
bibliography_element: bibliography_element_1.bibliographyElement,
|
|
173
173
|
bibliography_section: bibliography_section_1.bibliographySection,
|
|
174
174
|
blockquote_element: blockquote_element_1.blockquoteElement,
|
|
175
|
-
|
|
175
|
+
list: list_1.list,
|
|
176
176
|
caption: caption_1.caption,
|
|
177
177
|
caption_title: caption_title_1.captionTitle,
|
|
178
178
|
citation: citation_1.citation,
|
|
@@ -205,7 +205,6 @@ exports.schema = new prosemirror_model_1.Schema({
|
|
|
205
205
|
listing_element: listing_element_1.listingElement,
|
|
206
206
|
manuscript: manuscript_1.manuscript,
|
|
207
207
|
missing_figure: missing_figure_1.missingFigure,
|
|
208
|
-
ordered_list: list_1.orderedList,
|
|
209
208
|
paragraph: paragraph_1.paragraph,
|
|
210
209
|
placeholder: placeholder_1.placeholder,
|
|
211
210
|
placeholder_element: placeholder_element_1.placeholderElement,
|
|
@@ -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;
|
|
@@ -391,18 +391,18 @@ class Decoder {
|
|
|
391
391
|
switch (model.elementType) {
|
|
392
392
|
case 'ol':
|
|
393
393
|
return this.parseContents(model.contents || '<ol></ol>', undefined, this.getComments(model), {
|
|
394
|
-
topNode: schema_1.schema.nodes.
|
|
394
|
+
topNode: schema_1.schema.nodes.list.create({
|
|
395
395
|
id: model._id,
|
|
396
|
-
listStyleType: model.listStyleType,
|
|
396
|
+
listStyleType: model.listStyleType || 'order',
|
|
397
397
|
paragraphStyle: model.paragraphStyle,
|
|
398
398
|
comments: comments.map((c) => c.attrs.id),
|
|
399
399
|
}),
|
|
400
400
|
});
|
|
401
401
|
case 'ul':
|
|
402
402
|
return this.parseContents(model.contents || '<ul></ul>', undefined, this.getComments(model), {
|
|
403
|
-
topNode: schema_1.schema.nodes.
|
|
403
|
+
topNode: schema_1.schema.nodes.list.create({
|
|
404
404
|
id: model._id,
|
|
405
|
-
listStyleType: model.listStyleType,
|
|
405
|
+
listStyleType: model.listStyleType || 'bullet',
|
|
406
406
|
paragraphStyle: model.paragraphStyle,
|
|
407
407
|
}),
|
|
408
408
|
});
|
|
@@ -736,7 +736,6 @@ class Decoder {
|
|
|
736
736
|
];
|
|
737
737
|
return schema_1.schema.nodes.manuscript.create({
|
|
738
738
|
id: manuscriptID || this.getManuscriptID(),
|
|
739
|
-
doi: this.getManuscriptDOI() || '',
|
|
740
739
|
}, contents);
|
|
741
740
|
};
|
|
742
741
|
this.addGeneratedLabels = (sections) => {
|
|
@@ -782,13 +781,6 @@ class Decoder {
|
|
|
782
781
|
}
|
|
783
782
|
}
|
|
784
783
|
};
|
|
785
|
-
this.getManuscriptDOI = () => {
|
|
786
|
-
for (const item of this.modelMap.values()) {
|
|
787
|
-
if ((0, object_types_1.isManuscript)(item)) {
|
|
788
|
-
return item.DOI;
|
|
789
|
-
}
|
|
790
|
-
}
|
|
791
|
-
};
|
|
792
784
|
this.getFigcaption = (model) => {
|
|
793
785
|
const titleNode = schema_1.schema.nodes.caption_title.create();
|
|
794
786
|
const captionTitle = model.title
|
|
@@ -338,8 +338,8 @@ const encoders = {
|
|
|
338
338
|
placeholderInnerHTML: node.attrs.placeholder || '',
|
|
339
339
|
quoteType: 'block',
|
|
340
340
|
}),
|
|
341
|
-
|
|
342
|
-
elementType:
|
|
341
|
+
list: (node) => ({
|
|
342
|
+
elementType: (0, schema_1.getListType)(node.attrs.listStyleType).type,
|
|
343
343
|
contents: listContents(node),
|
|
344
344
|
listStyleType: node.attrs.listStyleType,
|
|
345
345
|
paragraphStyle: node.attrs.paragraphStyle || undefined,
|
|
@@ -432,12 +432,6 @@ const encoders = {
|
|
|
432
432
|
missing_figure: (node) => ({
|
|
433
433
|
position: node.attrs.position || undefined,
|
|
434
434
|
}),
|
|
435
|
-
ordered_list: (node) => ({
|
|
436
|
-
elementType: 'ol',
|
|
437
|
-
contents: listContents(node),
|
|
438
|
-
listStyleType: node.attrs.listStyleType,
|
|
439
|
-
paragraphStyle: node.attrs.paragraphStyle || undefined,
|
|
440
|
-
}),
|
|
441
435
|
paragraph: (node) => ({
|
|
442
436
|
elementType: 'p',
|
|
443
437
|
contents: contents(node),
|
|
@@ -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],
|
package/dist/cjs/version.js
CHANGED
|
@@ -348,19 +348,8 @@ const nodes = [
|
|
|
348
348
|
ignore: true,
|
|
349
349
|
},
|
|
350
350
|
{
|
|
351
|
-
tag: 'list
|
|
352
|
-
node: '
|
|
353
|
-
getAttrs: (node) => {
|
|
354
|
-
const element = node;
|
|
355
|
-
return {
|
|
356
|
-
id: element.getAttribute('id'),
|
|
357
|
-
listStyleType: element.getAttribute('list-type'),
|
|
358
|
-
};
|
|
359
|
-
},
|
|
360
|
-
},
|
|
361
|
-
{
|
|
362
|
-
tag: 'list[list-type]',
|
|
363
|
-
node: 'ordered_list',
|
|
351
|
+
tag: 'list',
|
|
352
|
+
node: 'list',
|
|
364
353
|
getAttrs: (node) => {
|
|
365
354
|
const element = node;
|
|
366
355
|
return {
|
|
@@ -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
|
},
|
|
@@ -779,14 +781,6 @@ export class JATSExporter {
|
|
|
779
781
|
graphic.setAttributeNS(XLINK_NAMESPACE, 'xlink:href', '');
|
|
780
782
|
return graphic;
|
|
781
783
|
},
|
|
782
|
-
ordered_list: (node) => {
|
|
783
|
-
var _a;
|
|
784
|
-
return [
|
|
785
|
-
'list',
|
|
786
|
-
{ 'list-type': (_a = node.attrs.listStyleType) !== null && _a !== void 0 ? _a : 'order' },
|
|
787
|
-
0,
|
|
788
|
-
];
|
|
789
|
-
},
|
|
790
784
|
paragraph: (node) => {
|
|
791
785
|
if (!node.childCount) {
|
|
792
786
|
return '';
|
package/dist/es/schema/index.js
CHANGED
|
@@ -55,7 +55,7 @@ import { keywordGroup } from './nodes/keyword_group';
|
|
|
55
55
|
import { keywords } from './nodes/keywords';
|
|
56
56
|
import { keywordsElement } from './nodes/keywords_element';
|
|
57
57
|
import { link } from './nodes/link';
|
|
58
|
-
import {
|
|
58
|
+
import { list, listItem } from './nodes/list';
|
|
59
59
|
import { listing } from './nodes/listing';
|
|
60
60
|
import { listingElement } from './nodes/listing_element';
|
|
61
61
|
import { manuscript } from './nodes/manuscript';
|
|
@@ -155,7 +155,7 @@ export const schema = new Schema({
|
|
|
155
155
|
bibliography_element: bibliographyElement,
|
|
156
156
|
bibliography_section: bibliographySection,
|
|
157
157
|
blockquote_element: blockquoteElement,
|
|
158
|
-
|
|
158
|
+
list: list,
|
|
159
159
|
caption,
|
|
160
160
|
caption_title: captionTitle,
|
|
161
161
|
citation,
|
|
@@ -188,7 +188,6 @@ export const schema = new Schema({
|
|
|
188
188
|
listing_element: listingElement,
|
|
189
189
|
manuscript,
|
|
190
190
|
missing_figure: missingFigure,
|
|
191
|
-
ordered_list: orderedList,
|
|
192
191
|
paragraph,
|
|
193
192
|
placeholder,
|
|
194
193
|
placeholder_element: placeholderElement,
|
|
@@ -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
|
};
|
|
@@ -382,18 +382,18 @@ export class Decoder {
|
|
|
382
382
|
switch (model.elementType) {
|
|
383
383
|
case 'ol':
|
|
384
384
|
return this.parseContents(model.contents || '<ol></ol>', undefined, this.getComments(model), {
|
|
385
|
-
topNode: schema.nodes.
|
|
385
|
+
topNode: schema.nodes.list.create({
|
|
386
386
|
id: model._id,
|
|
387
|
-
listStyleType: model.listStyleType,
|
|
387
|
+
listStyleType: model.listStyleType || 'order',
|
|
388
388
|
paragraphStyle: model.paragraphStyle,
|
|
389
389
|
comments: comments.map((c) => c.attrs.id),
|
|
390
390
|
}),
|
|
391
391
|
});
|
|
392
392
|
case 'ul':
|
|
393
393
|
return this.parseContents(model.contents || '<ul></ul>', undefined, this.getComments(model), {
|
|
394
|
-
topNode: schema.nodes.
|
|
394
|
+
topNode: schema.nodes.list.create({
|
|
395
395
|
id: model._id,
|
|
396
|
-
listStyleType: model.listStyleType,
|
|
396
|
+
listStyleType: model.listStyleType || 'bullet',
|
|
397
397
|
paragraphStyle: model.paragraphStyle,
|
|
398
398
|
}),
|
|
399
399
|
});
|
|
@@ -727,7 +727,6 @@ export class Decoder {
|
|
|
727
727
|
];
|
|
728
728
|
return schema.nodes.manuscript.create({
|
|
729
729
|
id: manuscriptID || this.getManuscriptID(),
|
|
730
|
-
doi: this.getManuscriptDOI() || '',
|
|
731
730
|
}, contents);
|
|
732
731
|
};
|
|
733
732
|
this.addGeneratedLabels = (sections) => {
|
|
@@ -773,13 +772,6 @@ export class Decoder {
|
|
|
773
772
|
}
|
|
774
773
|
}
|
|
775
774
|
};
|
|
776
|
-
this.getManuscriptDOI = () => {
|
|
777
|
-
for (const item of this.modelMap.values()) {
|
|
778
|
-
if (isManuscript(item)) {
|
|
779
|
-
return item.DOI;
|
|
780
|
-
}
|
|
781
|
-
}
|
|
782
|
-
};
|
|
783
775
|
this.getFigcaption = (model) => {
|
|
784
776
|
const titleNode = schema.nodes.caption_title.create();
|
|
785
777
|
const captionTitle = model.title
|
|
@@ -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';
|
|
@@ -330,8 +330,8 @@ const encoders = {
|
|
|
330
330
|
placeholderInnerHTML: node.attrs.placeholder || '',
|
|
331
331
|
quoteType: 'block',
|
|
332
332
|
}),
|
|
333
|
-
|
|
334
|
-
elementType:
|
|
333
|
+
list: (node) => ({
|
|
334
|
+
elementType: getListType(node.attrs.listStyleType).type,
|
|
335
335
|
contents: listContents(node),
|
|
336
336
|
listStyleType: node.attrs.listStyleType,
|
|
337
337
|
paragraphStyle: node.attrs.paragraphStyle || undefined,
|
|
@@ -424,12 +424,6 @@ const encoders = {
|
|
|
424
424
|
missing_figure: (node) => ({
|
|
425
425
|
position: node.attrs.position || undefined,
|
|
426
426
|
}),
|
|
427
|
-
ordered_list: (node) => ({
|
|
428
|
-
elementType: 'ol',
|
|
429
|
-
contents: listContents(node),
|
|
430
|
-
listStyleType: node.attrs.listStyleType,
|
|
431
|
-
paragraphStyle: node.attrs.paragraphStyle || undefined,
|
|
432
|
-
}),
|
|
433
427
|
paragraph: (node) => ({
|
|
434
428
|
elementType: 'p',
|
|
435
429
|
contents: contents(node),
|
|
@@ -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],
|
package/dist/es/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "2.3.8
|
|
1
|
+
export const VERSION = "2.3.8";
|
|
@@ -1,41 +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
1
|
import { NodeSpec } from 'prosemirror-model';
|
|
17
2
|
import { ManuscriptNode } from '../types';
|
|
18
|
-
export
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
listStyleType: string;
|
|
23
|
-
};
|
|
3
|
+
export type JatsStyleType = 'simple' | 'bullet' | 'order' | 'alpha-lower' | 'alpha-upper' | 'roman-lower' | 'roman-upper';
|
|
4
|
+
interface ListTypeInfo {
|
|
5
|
+
type: 'ul' | 'ol';
|
|
6
|
+
style: string;
|
|
24
7
|
}
|
|
25
|
-
export declare const
|
|
26
|
-
export interface
|
|
8
|
+
export declare const getListType: (style: JatsStyleType) => ListTypeInfo;
|
|
9
|
+
export interface ListNode extends ManuscriptNode {
|
|
27
10
|
attrs: {
|
|
28
11
|
id: string;
|
|
29
|
-
listStyleType: string;
|
|
30
12
|
paragraphStyle: string;
|
|
13
|
+
listStyleType: string;
|
|
31
14
|
};
|
|
32
15
|
}
|
|
33
|
-
export declare const
|
|
16
|
+
export declare const list: NodeSpec;
|
|
34
17
|
export interface ListItemNode extends ManuscriptNode {
|
|
35
18
|
attrs: {
|
|
36
19
|
placeholder: string;
|
|
37
20
|
};
|
|
38
21
|
}
|
|
39
22
|
export declare const listItem: NodeSpec;
|
|
40
|
-
export type ListNode = BulletListNode | OrderedListNode;
|
|
41
23
|
export declare const isListNode: (node: ManuscriptNode) => node is ListNode;
|
|
24
|
+
export {};
|
|
@@ -17,7 +17,7 @@ import { Fragment, Mark as ProsemirrorMark, MarkType, Node as ProsemirrorNode, N
|
|
|
17
17
|
import { EditorState, NodeSelection, Plugin, TextSelection, Transaction } from 'prosemirror-state';
|
|
18
18
|
import { EditorView, NodeView } from 'prosemirror-view';
|
|
19
19
|
export type Marks = 'bold' | 'code' | 'italic' | 'smallcaps' | 'strikethrough' | 'styled' | 'subscript' | 'superscript' | 'underline' | 'tracked_insert' | 'tracked_delete';
|
|
20
|
-
export type Nodes = 'attribution' | 'bibliography_item' | 'bibliography_element' | 'bibliography_section' | 'blockquote_element' | '
|
|
20
|
+
export type Nodes = 'attribution' | 'bibliography_item' | 'bibliography_element' | 'bibliography_section' | 'blockquote_element' | 'list' | 'caption' | 'caption_title' | 'comment' | 'comments' | 'citation' | 'cross_reference' | 'doc' | 'equation' | 'equation_element' | 'figcaption' | 'figure' | 'graphical_abstract_section' | 'figure_element' | 'footnote' | 'footnotes_element' | 'footnotes_section' | 'hard_break' | 'highlight_marker' | 'inline_equation' | 'inline_footnote' | 'keyword' | 'keywords_element' | 'keyword_group' | 'keywords' | 'link' | 'list_item' | 'listing' | 'listing_element' | 'manuscript' | 'abstracts' | 'body' | 'backmatter' | 'missing_figure' | 'paragraph' | 'placeholder' | 'placeholder_element' | 'pullquote_element' | 'section' | 'section_label' | 'section_title' | 'section_title_plain' | 'table' | 'table_cell' | 'table_element' | 'table_row' | 'table_colgroup' | 'table_col' | 'table_header' | 'text' | 'toc_element' | 'toc_section' | 'affiliation' | 'contributor' | 'table_element_footer' | 'title' | 'affiliations' | 'contributors' | 'supplements' | 'supplement' | 'author_notes' | 'corresp' | 'general_table_footnote';
|
|
21
21
|
export type ManuscriptSchema = Schema<Nodes, Marks>;
|
|
22
22
|
export type ManuscriptEditorState = EditorState;
|
|
23
23
|
export type ManuscriptEditorView = EditorView;
|
|
@@ -41,7 +41,6 @@ export declare class Decoder {
|
|
|
41
41
|
addGeneratedLabels: (sections: Section[]) => Section[];
|
|
42
42
|
parseContents: (contents: string, wrapper?: string, commentAnnotations?: CommentAnnotation[], options?: ParseOptions) => ManuscriptNode;
|
|
43
43
|
private getManuscriptID;
|
|
44
|
-
private getManuscriptDOI;
|
|
45
44
|
private getFigcaption;
|
|
46
45
|
private createTable;
|
|
47
46
|
private createTableColGroup;
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "2.3.8
|
|
1
|
+
export declare const VERSION = "2.3.8";
|
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": "2.3.8
|
|
4
|
+
"version": "2.3.8",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-transform",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|