@manuscripts/transform 2.3.5-LEAN-3608.6 → 2.3.5
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 +13 -2
- package/dist/cjs/jats/jats-exporter.js +10 -5
- package/dist/cjs/schema/index.js +2 -1
- package/dist/cjs/schema/nodes/list.js +58 -36
- package/dist/cjs/transformer/decode.js +4 -4
- package/dist/cjs/transformer/encode.js +8 -2
- package/dist/cjs/transformer/node-names.js +2 -1
- package/dist/cjs/transformer/node-title.js +2 -1
- package/dist/cjs/transformer/node-types.js +2 -1
- package/dist/es/jats/importer/jats-body-dom-parser.js +13 -2
- package/dist/es/jats/jats-exporter.js +10 -5
- package/dist/es/schema/index.js +3 -2
- package/dist/es/schema/nodes/list.js +57 -34
- package/dist/es/transformer/decode.js +4 -4
- package/dist/es/transformer/encode.js +9 -3
- package/dist/es/transformer/node-names.js +2 -1
- package/dist/es/transformer/node-title.js +2 -1
- package/dist/es/transformer/node-types.js +2 -1
- package/dist/types/schema/nodes/list.d.ts +26 -9
- package/dist/types/schema/types.d.ts +1 -1
- package/package.json +5 -5
|
@@ -332,8 +332,19 @@ const nodes = [
|
|
|
332
332
|
ignore: true,
|
|
333
333
|
},
|
|
334
334
|
{
|
|
335
|
-
tag: 'list',
|
|
336
|
-
node: '
|
|
335
|
+
tag: 'list[list-type=bullet]',
|
|
336
|
+
node: 'bullet_list',
|
|
337
|
+
getAttrs: (node) => {
|
|
338
|
+
const element = node;
|
|
339
|
+
return {
|
|
340
|
+
id: element.getAttribute('id'),
|
|
341
|
+
listStyleType: element.getAttribute('list-type'),
|
|
342
|
+
};
|
|
343
|
+
},
|
|
344
|
+
},
|
|
345
|
+
{
|
|
346
|
+
tag: 'list[list-type]',
|
|
347
|
+
node: 'ordered_list',
|
|
337
348
|
getAttrs: (node) => {
|
|
338
349
|
const element = node;
|
|
339
350
|
return {
|
|
@@ -620,14 +620,11 @@ class JATSExporter {
|
|
|
620
620
|
0,
|
|
621
621
|
],
|
|
622
622
|
blockquote_element: () => ['disp-quote', { 'content-type': 'quote' }, 0],
|
|
623
|
-
|
|
623
|
+
bullet_list: (node) => {
|
|
624
624
|
var _a;
|
|
625
625
|
return [
|
|
626
626
|
'list',
|
|
627
|
-
{
|
|
628
|
-
'list-type': (_a = node.attrs.listStyleType) !== null && _a !== void 0 ? _a : 'bullet',
|
|
629
|
-
type: node.attrs.type,
|
|
630
|
-
},
|
|
627
|
+
{ 'list-type': (_a = node.attrs.listStyleType) !== null && _a !== void 0 ? _a : 'bullet' },
|
|
631
628
|
0,
|
|
632
629
|
];
|
|
633
630
|
},
|
|
@@ -784,6 +781,14 @@ class JATSExporter {
|
|
|
784
781
|
graphic.setAttributeNS(XLINK_NAMESPACE, 'xlink:href', '');
|
|
785
782
|
return graphic;
|
|
786
783
|
},
|
|
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
|
+
},
|
|
787
792
|
paragraph: (node) => {
|
|
788
793
|
if (!node.childCount) {
|
|
789
794
|
return '';
|
package/dist/cjs/schema/index.js
CHANGED
|
@@ -170,7 +170,7 @@ exports.schema = new prosemirror_model_1.Schema({
|
|
|
170
170
|
bibliography_element: bibliography_element_1.bibliographyElement,
|
|
171
171
|
bibliography_section: bibliography_section_1.bibliographySection,
|
|
172
172
|
blockquote_element: blockquote_element_1.blockquoteElement,
|
|
173
|
-
|
|
173
|
+
bullet_list: list_1.bulletList,
|
|
174
174
|
caption: caption_1.caption,
|
|
175
175
|
caption_title: caption_title_1.captionTitle,
|
|
176
176
|
citation: citation_1.citation,
|
|
@@ -202,6 +202,7 @@ exports.schema = new prosemirror_model_1.Schema({
|
|
|
202
202
|
listing_element: listing_element_1.listingElement,
|
|
203
203
|
manuscript: manuscript_1.manuscript,
|
|
204
204
|
missing_figure: missing_figure_1.missingFigure,
|
|
205
|
+
ordered_list: list_1.orderedList,
|
|
205
206
|
paragraph: paragraph_1.paragraph,
|
|
206
207
|
placeholder: placeholder_1.placeholder,
|
|
207
208
|
placeholder_element: placeholder_element_1.placeholderElement,
|
|
@@ -1,30 +1,24 @@
|
|
|
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
|
+
*/
|
|
2
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isListNode = exports.listItem = exports.
|
|
18
|
+
exports.isListNode = exports.listItem = exports.orderedList = exports.bulletList = void 0;
|
|
4
19
|
const json_schema_1 = require("@manuscripts/json-schema");
|
|
5
20
|
const attributes_1 = require("../../lib/attributes");
|
|
6
|
-
|
|
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: 'ol', style: 'decimal' };
|
|
14
|
-
case 'alpha-lower':
|
|
15
|
-
return { type: 'ol', style: 'lower-alpha' };
|
|
16
|
-
case 'alpha-upper':
|
|
17
|
-
return { type: 'ol', style: 'upper-alpha' };
|
|
18
|
-
case 'roman-lower':
|
|
19
|
-
return { type: 'ol', style: 'lower-roman' };
|
|
20
|
-
case 'roman-upper':
|
|
21
|
-
return { type: 'ol', style: 'upper-roman' };
|
|
22
|
-
default:
|
|
23
|
-
throw new Error(`Unsupported style type: ${style}`);
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
exports.getListType = getListType;
|
|
27
|
-
exports.list = {
|
|
21
|
+
exports.bulletList = {
|
|
28
22
|
content: 'list_item+',
|
|
29
23
|
group: 'block list element',
|
|
30
24
|
attrs: {
|
|
@@ -44,6 +38,33 @@ exports.list = {
|
|
|
44
38
|
};
|
|
45
39
|
},
|
|
46
40
|
},
|
|
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: [
|
|
47
68
|
{
|
|
48
69
|
tag: 'ol',
|
|
49
70
|
getAttrs: (p) => {
|
|
@@ -56,18 +77,19 @@ exports.list = {
|
|
|
56
77
|
},
|
|
57
78
|
],
|
|
58
79
|
toDOM: (node) => {
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
80
|
+
const orderedListNode = node;
|
|
81
|
+
return orderedListNode.attrs.id
|
|
82
|
+
? [
|
|
83
|
+
'ol',
|
|
84
|
+
{
|
|
85
|
+
id: orderedListNode.attrs.id,
|
|
86
|
+
'list-type': orderedListNode.attrs.listStyleType,
|
|
87
|
+
class: (0, attributes_1.buildElementClass)(orderedListNode.attrs),
|
|
88
|
+
'data-object-type': json_schema_1.ObjectTypes.ListElement,
|
|
89
|
+
},
|
|
90
|
+
0,
|
|
91
|
+
]
|
|
92
|
+
: ['ol', 0];
|
|
71
93
|
},
|
|
72
94
|
};
|
|
73
95
|
exports.listItem = {
|
|
@@ -100,6 +122,6 @@ exports.listItem = {
|
|
|
100
122
|
};
|
|
101
123
|
const isListNode = (node) => {
|
|
102
124
|
const { nodes } = node.type.schema;
|
|
103
|
-
return node.type === nodes.
|
|
125
|
+
return node.type === nodes.bullet_list || node.type === nodes.ordered_list;
|
|
104
126
|
};
|
|
105
127
|
exports.isListNode = isListNode;
|
|
@@ -390,18 +390,18 @@ class Decoder {
|
|
|
390
390
|
switch (model.elementType) {
|
|
391
391
|
case 'ol':
|
|
392
392
|
return this.parseContents(model.contents || '<ol></ol>', undefined, this.getComments(model), {
|
|
393
|
-
topNode: schema_1.schema.nodes.
|
|
393
|
+
topNode: schema_1.schema.nodes.ordered_list.create({
|
|
394
394
|
id: model._id,
|
|
395
|
-
listStyleType: model.listStyleType
|
|
395
|
+
listStyleType: model.listStyleType,
|
|
396
396
|
paragraphStyle: model.paragraphStyle,
|
|
397
397
|
comments: comments.map((c) => c.attrs.id),
|
|
398
398
|
}),
|
|
399
399
|
});
|
|
400
400
|
case 'ul':
|
|
401
401
|
return this.parseContents(model.contents || '<ul></ul>', undefined, this.getComments(model), {
|
|
402
|
-
topNode: schema_1.schema.nodes.
|
|
402
|
+
topNode: schema_1.schema.nodes.bullet_list.create({
|
|
403
403
|
id: model._id,
|
|
404
|
-
listStyleType: model.listStyleType
|
|
404
|
+
listStyleType: model.listStyleType,
|
|
405
405
|
paragraphStyle: model.paragraphStyle,
|
|
406
406
|
}),
|
|
407
407
|
});
|
|
@@ -326,8 +326,8 @@ const encoders = {
|
|
|
326
326
|
placeholderInnerHTML: node.attrs.placeholder || '',
|
|
327
327
|
quoteType: 'block',
|
|
328
328
|
}),
|
|
329
|
-
|
|
330
|
-
elementType:
|
|
329
|
+
bullet_list: (node) => ({
|
|
330
|
+
elementType: 'ul',
|
|
331
331
|
contents: listContents(node),
|
|
332
332
|
listStyleType: node.attrs.listStyleType,
|
|
333
333
|
paragraphStyle: node.attrs.paragraphStyle || undefined,
|
|
@@ -420,6 +420,12 @@ const encoders = {
|
|
|
420
420
|
missing_figure: (node) => ({
|
|
421
421
|
position: node.attrs.position || undefined,
|
|
422
422
|
}),
|
|
423
|
+
ordered_list: (node) => ({
|
|
424
|
+
elementType: 'ol',
|
|
425
|
+
contents: listContents(node),
|
|
426
|
+
listStyleType: node.attrs.listStyleType,
|
|
427
|
+
paragraphStyle: node.attrs.paragraphStyle || undefined,
|
|
428
|
+
}),
|
|
423
429
|
paragraph: (node) => ({
|
|
424
430
|
elementType: 'p',
|
|
425
431
|
contents: contents(node),
|
|
@@ -27,7 +27,8 @@ 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.
|
|
30
|
+
[schema_1.schema.nodes.bullet_list, 'Bullet List'],
|
|
31
|
+
[schema_1.schema.nodes.ordered_list, 'Ordered List'],
|
|
31
32
|
[schema_1.schema.nodes.manuscript, 'Manuscript'],
|
|
32
33
|
[schema_1.schema.nodes.paragraph, 'Paragraph'],
|
|
33
34
|
[schema_1.schema.nodes.section, 'Section'],
|
|
@@ -56,7 +56,8 @@ 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.
|
|
59
|
+
case nodes.ordered_list:
|
|
60
|
+
case nodes.bullet_list:
|
|
60
61
|
case nodes.blockquote_element:
|
|
61
62
|
case nodes.footnote:
|
|
62
63
|
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.bullet_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,6 +46,7 @@ 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],
|
|
49
50
|
[schema_1.schema.nodes.paragraph, json_schema_1.ObjectTypes.ParagraphElement],
|
|
50
51
|
[schema_1.schema.nodes.pullquote_element, json_schema_1.ObjectTypes.QuoteElement],
|
|
51
52
|
[schema_1.schema.nodes.section, json_schema_1.ObjectTypes.Section],
|
|
@@ -326,8 +326,19 @@ const nodes = [
|
|
|
326
326
|
ignore: true,
|
|
327
327
|
},
|
|
328
328
|
{
|
|
329
|
-
tag: 'list',
|
|
330
|
-
node: '
|
|
329
|
+
tag: 'list[list-type=bullet]',
|
|
330
|
+
node: 'bullet_list',
|
|
331
|
+
getAttrs: (node) => {
|
|
332
|
+
const element = node;
|
|
333
|
+
return {
|
|
334
|
+
id: element.getAttribute('id'),
|
|
335
|
+
listStyleType: element.getAttribute('list-type'),
|
|
336
|
+
};
|
|
337
|
+
},
|
|
338
|
+
},
|
|
339
|
+
{
|
|
340
|
+
tag: 'list[list-type]',
|
|
341
|
+
node: 'ordered_list',
|
|
331
342
|
getAttrs: (node) => {
|
|
332
343
|
const element = node;
|
|
333
344
|
return {
|
|
@@ -612,14 +612,11 @@ export class JATSExporter {
|
|
|
612
612
|
0,
|
|
613
613
|
],
|
|
614
614
|
blockquote_element: () => ['disp-quote', { 'content-type': 'quote' }, 0],
|
|
615
|
-
|
|
615
|
+
bullet_list: (node) => {
|
|
616
616
|
var _a;
|
|
617
617
|
return [
|
|
618
618
|
'list',
|
|
619
|
-
{
|
|
620
|
-
'list-type': (_a = node.attrs.listStyleType) !== null && _a !== void 0 ? _a : 'bullet',
|
|
621
|
-
type: node.attrs.type,
|
|
622
|
-
},
|
|
619
|
+
{ 'list-type': (_a = node.attrs.listStyleType) !== null && _a !== void 0 ? _a : 'bullet' },
|
|
623
620
|
0,
|
|
624
621
|
];
|
|
625
622
|
},
|
|
@@ -776,6 +773,14 @@ export class JATSExporter {
|
|
|
776
773
|
graphic.setAttributeNS(XLINK_NAMESPACE, 'xlink:href', '');
|
|
777
774
|
return graphic;
|
|
778
775
|
},
|
|
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
|
+
},
|
|
779
784
|
paragraph: (node) => {
|
|
780
785
|
if (!node.childCount) {
|
|
781
786
|
return '';
|
package/dist/es/schema/index.js
CHANGED
|
@@ -54,7 +54,7 @@ import { keywordGroup } from './nodes/keyword_group';
|
|
|
54
54
|
import { keywords } from './nodes/keywords';
|
|
55
55
|
import { keywordsElement } from './nodes/keywords_element';
|
|
56
56
|
import { link } from './nodes/link';
|
|
57
|
-
import {
|
|
57
|
+
import { bulletList, listItem, orderedList } from './nodes/list';
|
|
58
58
|
import { listing } from './nodes/listing';
|
|
59
59
|
import { listingElement } from './nodes/listing_element';
|
|
60
60
|
import { manuscript } from './nodes/manuscript';
|
|
@@ -153,7 +153,7 @@ export const schema = new Schema({
|
|
|
153
153
|
bibliography_element: bibliographyElement,
|
|
154
154
|
bibliography_section: bibliographySection,
|
|
155
155
|
blockquote_element: blockquoteElement,
|
|
156
|
-
|
|
156
|
+
bullet_list: bulletList,
|
|
157
157
|
caption,
|
|
158
158
|
caption_title: captionTitle,
|
|
159
159
|
citation,
|
|
@@ -185,6 +185,7 @@ export const schema = new Schema({
|
|
|
185
185
|
listing_element: listingElement,
|
|
186
186
|
manuscript,
|
|
187
187
|
missing_figure: missingFigure,
|
|
188
|
+
ordered_list: orderedList,
|
|
188
189
|
paragraph,
|
|
189
190
|
placeholder,
|
|
190
191
|
placeholder_element: placeholderElement,
|
|
@@ -1,26 +1,21 @@
|
|
|
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
|
+
*/
|
|
1
16
|
import { ObjectTypes } from '@manuscripts/json-schema';
|
|
2
17
|
import { buildElementClass } from '../../lib/attributes';
|
|
3
|
-
export const
|
|
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: 'ol', style: 'decimal' };
|
|
11
|
-
case 'alpha-lower':
|
|
12
|
-
return { type: 'ol', style: 'lower-alpha' };
|
|
13
|
-
case 'alpha-upper':
|
|
14
|
-
return { type: 'ol', style: 'upper-alpha' };
|
|
15
|
-
case 'roman-lower':
|
|
16
|
-
return { type: 'ol', style: 'lower-roman' };
|
|
17
|
-
case 'roman-upper':
|
|
18
|
-
return { type: 'ol', style: 'upper-roman' };
|
|
19
|
-
default:
|
|
20
|
-
throw new Error(`Unsupported style type: ${style}`);
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
export const list = {
|
|
18
|
+
export const bulletList = {
|
|
24
19
|
content: 'list_item+',
|
|
25
20
|
group: 'block list element',
|
|
26
21
|
attrs: {
|
|
@@ -40,6 +35,33 @@ export const list = {
|
|
|
40
35
|
};
|
|
41
36
|
},
|
|
42
37
|
},
|
|
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: [
|
|
43
65
|
{
|
|
44
66
|
tag: 'ol',
|
|
45
67
|
getAttrs: (p) => {
|
|
@@ -52,18 +74,19 @@ export const list = {
|
|
|
52
74
|
},
|
|
53
75
|
],
|
|
54
76
|
toDOM: (node) => {
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
77
|
+
const orderedListNode = node;
|
|
78
|
+
return orderedListNode.attrs.id
|
|
79
|
+
? [
|
|
80
|
+
'ol',
|
|
81
|
+
{
|
|
82
|
+
id: orderedListNode.attrs.id,
|
|
83
|
+
'list-type': orderedListNode.attrs.listStyleType,
|
|
84
|
+
class: buildElementClass(orderedListNode.attrs),
|
|
85
|
+
'data-object-type': ObjectTypes.ListElement,
|
|
86
|
+
},
|
|
87
|
+
0,
|
|
88
|
+
]
|
|
89
|
+
: ['ol', 0];
|
|
67
90
|
},
|
|
68
91
|
};
|
|
69
92
|
export const listItem = {
|
|
@@ -96,5 +119,5 @@ export const listItem = {
|
|
|
96
119
|
};
|
|
97
120
|
export const isListNode = (node) => {
|
|
98
121
|
const { nodes } = node.type.schema;
|
|
99
|
-
return node.type === nodes.
|
|
122
|
+
return node.type === nodes.bullet_list || node.type === nodes.ordered_list;
|
|
100
123
|
};
|
|
@@ -381,18 +381,18 @@ export class Decoder {
|
|
|
381
381
|
switch (model.elementType) {
|
|
382
382
|
case 'ol':
|
|
383
383
|
return this.parseContents(model.contents || '<ol></ol>', undefined, this.getComments(model), {
|
|
384
|
-
topNode: schema.nodes.
|
|
384
|
+
topNode: schema.nodes.ordered_list.create({
|
|
385
385
|
id: model._id,
|
|
386
|
-
listStyleType: model.listStyleType
|
|
386
|
+
listStyleType: model.listStyleType,
|
|
387
387
|
paragraphStyle: model.paragraphStyle,
|
|
388
388
|
comments: comments.map((c) => c.attrs.id),
|
|
389
389
|
}),
|
|
390
390
|
});
|
|
391
391
|
case 'ul':
|
|
392
392
|
return this.parseContents(model.contents || '<ul></ul>', undefined, this.getComments(model), {
|
|
393
|
-
topNode: schema.nodes.
|
|
393
|
+
topNode: schema.nodes.bullet_list.create({
|
|
394
394
|
id: model._id,
|
|
395
|
-
listStyleType: model.listStyleType
|
|
395
|
+
listStyleType: model.listStyleType,
|
|
396
396
|
paragraphStyle: model.paragraphStyle,
|
|
397
397
|
}),
|
|
398
398
|
});
|
|
@@ -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 {
|
|
19
|
+
import { 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';
|
|
@@ -318,8 +318,8 @@ const encoders = {
|
|
|
318
318
|
placeholderInnerHTML: node.attrs.placeholder || '',
|
|
319
319
|
quoteType: 'block',
|
|
320
320
|
}),
|
|
321
|
-
|
|
322
|
-
elementType:
|
|
321
|
+
bullet_list: (node) => ({
|
|
322
|
+
elementType: 'ul',
|
|
323
323
|
contents: listContents(node),
|
|
324
324
|
listStyleType: node.attrs.listStyleType,
|
|
325
325
|
paragraphStyle: node.attrs.paragraphStyle || undefined,
|
|
@@ -412,6 +412,12 @@ const encoders = {
|
|
|
412
412
|
missing_figure: (node) => ({
|
|
413
413
|
position: node.attrs.position || undefined,
|
|
414
414
|
}),
|
|
415
|
+
ordered_list: (node) => ({
|
|
416
|
+
elementType: 'ol',
|
|
417
|
+
contents: listContents(node),
|
|
418
|
+
listStyleType: node.attrs.listStyleType,
|
|
419
|
+
paragraphStyle: node.attrs.paragraphStyle || undefined,
|
|
420
|
+
}),
|
|
415
421
|
paragraph: (node) => ({
|
|
416
422
|
elementType: 'p',
|
|
417
423
|
contents: contents(node),
|
|
@@ -24,7 +24,8 @@ 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.
|
|
27
|
+
[schema.nodes.bullet_list, 'Bullet List'],
|
|
28
|
+
[schema.nodes.ordered_list, 'Ordered List'],
|
|
28
29
|
[schema.nodes.manuscript, 'Manuscript'],
|
|
29
30
|
[schema.nodes.paragraph, 'Paragraph'],
|
|
30
31
|
[schema.nodes.section, 'Section'],
|
|
@@ -53,7 +53,8 @@ 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.
|
|
56
|
+
case nodes.ordered_list:
|
|
57
|
+
case nodes.bullet_list:
|
|
57
58
|
case nodes.blockquote_element:
|
|
58
59
|
case nodes.footnote:
|
|
59
60
|
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.bullet_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,6 +43,7 @@ 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],
|
|
46
47
|
[schema.nodes.paragraph, ObjectTypes.ParagraphElement],
|
|
47
48
|
[schema.nodes.pullquote_element, ObjectTypes.QuoteElement],
|
|
48
49
|
[schema.nodes.section, ObjectTypes.Section],
|
|
@@ -1,24 +1,41 @@
|
|
|
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
|
+
*/
|
|
1
16
|
import { NodeSpec } from 'prosemirror-model';
|
|
2
17
|
import { ManuscriptNode } from '../types';
|
|
3
|
-
export
|
|
4
|
-
interface ListTypeInfo {
|
|
5
|
-
type: 'ul' | 'ol';
|
|
6
|
-
style: string;
|
|
7
|
-
}
|
|
8
|
-
export declare const getListType: (style: JatsStyleType) => ListTypeInfo;
|
|
9
|
-
export interface ListNode extends ManuscriptNode {
|
|
18
|
+
export interface BulletListNode extends ManuscriptNode {
|
|
10
19
|
attrs: {
|
|
11
20
|
id: string;
|
|
12
21
|
paragraphStyle: string;
|
|
13
22
|
listStyleType: string;
|
|
14
23
|
};
|
|
15
24
|
}
|
|
16
|
-
export declare const
|
|
25
|
+
export declare const bulletList: NodeSpec;
|
|
26
|
+
export interface OrderedListNode extends ManuscriptNode {
|
|
27
|
+
attrs: {
|
|
28
|
+
id: string;
|
|
29
|
+
listStyleType: string;
|
|
30
|
+
paragraphStyle: string;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export declare const orderedList: NodeSpec;
|
|
17
34
|
export interface ListItemNode extends ManuscriptNode {
|
|
18
35
|
attrs: {
|
|
19
36
|
placeholder: string;
|
|
20
37
|
};
|
|
21
38
|
}
|
|
22
39
|
export declare const listItem: NodeSpec;
|
|
40
|
+
export type ListNode = BulletListNode | OrderedListNode;
|
|
23
41
|
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' | 'bullet_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' | 'ordered_list' | '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';
|
|
21
21
|
export type ManuscriptSchema = Schema<Nodes, Marks>;
|
|
22
22
|
export type ManuscriptEditorState = EditorState;
|
|
23
23
|
export type ManuscriptEditorView = EditorView;
|
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.5
|
|
4
|
+
"version": "2.3.5",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-transform",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"version": "yarn build"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@manuscripts/json-schema": "
|
|
33
|
-
"@manuscripts/library": "
|
|
32
|
+
"@manuscripts/json-schema": "2.2.8",
|
|
33
|
+
"@manuscripts/library": "1.3.7",
|
|
34
34
|
"debug": "^4.3.4",
|
|
35
35
|
"jszip": "^3.10.1",
|
|
36
36
|
"mime": "^3.0.0",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"husky": "^8.0.2",
|
|
71
71
|
"jest": "^29.3.1",
|
|
72
72
|
"jest-environment-jsdom": "^29.3.1",
|
|
73
|
-
"libxmljs2": "^0.
|
|
73
|
+
"libxmljs2": "^0.33.0",
|
|
74
74
|
"npm-run-all": "^4.1.5",
|
|
75
75
|
"prettier": "^2.8.1",
|
|
76
76
|
"prosemirror-state": "^1.4.2",
|
|
@@ -78,4 +78,4 @@
|
|
|
78
78
|
"rimraf": "^3.0.2",
|
|
79
79
|
"typescript": "^4.0.5"
|
|
80
80
|
}
|
|
81
|
-
}
|
|
81
|
+
}
|