@manuscripts/transform 1.3.12 → 1.4.1-LEAN-2737
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 +6 -1
- package/dist/cjs/jats/importer/jats-reference-parser.js +1 -0
- package/dist/cjs/jats/jats-exporter.js +8 -1
- package/dist/cjs/schema/nodes/bibliography_element.js +1 -1
- package/dist/cjs/schema/nodes/citation.js +10 -1
- package/dist/cjs/schema/nodes/list.js +3 -0
- package/dist/cjs/transformer/decode.js +4 -0
- package/dist/cjs/transformer/encode.js +1 -0
- package/dist/cjs/transformer/node-types.js +6 -1
- package/dist/es/jats/importer/jats-body-dom-parser.js +6 -1
- package/dist/es/jats/importer/jats-reference-parser.js +1 -0
- package/dist/es/jats/jats-exporter.js +8 -1
- package/dist/es/schema/nodes/bibliography_element.js +1 -1
- package/dist/es/schema/nodes/citation.js +10 -1
- package/dist/es/schema/nodes/list.js +3 -0
- package/dist/es/transformer/decode.js +4 -0
- package/dist/es/transformer/encode.js +1 -0
- package/dist/es/transformer/node-types.js +4 -0
- package/dist/types/schema/nodes/citation.d.ts +4 -0
- package/dist/types/schema/nodes/list.d.ts +1 -0
- package/dist/types/transformer/node-types.d.ts +1 -0
- package/package.json +2 -2
|
@@ -456,12 +456,13 @@ const nodes = [
|
|
|
456
456
|
},
|
|
457
457
|
},
|
|
458
458
|
{
|
|
459
|
-
tag: 'list[list-type
|
|
459
|
+
tag: 'list[list-type]',
|
|
460
460
|
node: 'ordered_list',
|
|
461
461
|
getAttrs: (node) => {
|
|
462
462
|
const element = node;
|
|
463
463
|
return {
|
|
464
464
|
id: element.getAttribute('id'),
|
|
465
|
+
listStyleType: element.getAttribute('list-type'),
|
|
465
466
|
};
|
|
466
467
|
},
|
|
467
468
|
},
|
|
@@ -650,9 +651,13 @@ const nodes = [
|
|
|
650
651
|
getAttrs: (node) => {
|
|
651
652
|
var _a;
|
|
652
653
|
const element = node;
|
|
654
|
+
const embeddedCitationAttr = element.getAttribute('data-reference-embedded-citation');
|
|
653
655
|
return {
|
|
654
656
|
rid: element.getAttribute('rid'),
|
|
655
657
|
contents: (_a = element.textContent) === null || _a === void 0 ? void 0 : _a.trim(),
|
|
658
|
+
embeddedCitationItems: embeddedCitationAttr
|
|
659
|
+
? JSON.parse(embeddedCitationAttr)
|
|
660
|
+
: null,
|
|
656
661
|
};
|
|
657
662
|
},
|
|
658
663
|
},
|
|
@@ -158,6 +158,7 @@ exports.jatsReferenceParser = {
|
|
|
158
158
|
const citation = (0, builders_1.buildCitation)('', rids);
|
|
159
159
|
modelNodes.push(citation);
|
|
160
160
|
crossReferenceNode.setAttribute('rid', citation._id);
|
|
161
|
+
crossReferenceNode.setAttribute('data-reference-embedded-citation', JSON.stringify(citation.embeddedCitationItems));
|
|
161
162
|
}
|
|
162
163
|
else {
|
|
163
164
|
crossReferenceNode.removeAttribute('rid');
|
|
@@ -825,7 +825,14 @@ class JATSExporter {
|
|
|
825
825
|
graphic.setAttributeNS(XLINK_NAMESPACE, 'xlink:href', '');
|
|
826
826
|
return graphic;
|
|
827
827
|
},
|
|
828
|
-
ordered_list: () =>
|
|
828
|
+
ordered_list: (node) => {
|
|
829
|
+
var _a;
|
|
830
|
+
return [
|
|
831
|
+
'list',
|
|
832
|
+
{ 'list-type': (_a = node.attrs.listStyleType) !== null && _a !== void 0 ? _a : 'order' },
|
|
833
|
+
0,
|
|
834
|
+
];
|
|
835
|
+
},
|
|
829
836
|
paragraph: (node) => {
|
|
830
837
|
if (!node.childCount) {
|
|
831
838
|
return '';
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.bibliographyElement = void 0;
|
|
19
19
|
exports.bibliographyElement = {
|
|
20
|
-
content: '(bibliography_item | placeholder)
|
|
20
|
+
content: '(bibliography_item | placeholder)*',
|
|
21
21
|
attrs: {
|
|
22
22
|
id: { default: '' },
|
|
23
23
|
contents: { default: '' },
|
|
@@ -26,16 +26,22 @@ exports.citation = {
|
|
|
26
26
|
contents: { default: '' },
|
|
27
27
|
selectedText: { default: '' },
|
|
28
28
|
dataTracked: { default: null },
|
|
29
|
+
embeddedCitationItems: { default: null },
|
|
29
30
|
},
|
|
30
31
|
parseDOM: [
|
|
31
32
|
{
|
|
32
33
|
tag: 'span.citation[data-reference-id]',
|
|
33
34
|
getAttrs: (p) => {
|
|
34
35
|
const dom = p;
|
|
35
|
-
|
|
36
|
+
const attr = {
|
|
36
37
|
rid: dom.getAttribute('data-reference-id'),
|
|
37
38
|
contents: dom.innerHTML,
|
|
38
39
|
};
|
|
40
|
+
const embeddedCitationAttr = dom.getAttribute('data-reference-embedded-citation');
|
|
41
|
+
if (embeddedCitationAttr) {
|
|
42
|
+
attr['embeddedCitationItems'] = JSON.parse(embeddedCitationAttr);
|
|
43
|
+
}
|
|
44
|
+
return attr;
|
|
39
45
|
},
|
|
40
46
|
},
|
|
41
47
|
],
|
|
@@ -44,6 +50,9 @@ exports.citation = {
|
|
|
44
50
|
const dom = document.createElement('span');
|
|
45
51
|
dom.className = 'citation';
|
|
46
52
|
dom.setAttribute('data-reference-id', citationNode.attrs.rid);
|
|
53
|
+
if (citationNode.attrs.embeddedCitationItems) {
|
|
54
|
+
dom.setAttribute('data-reference-embedded-citation', JSON.stringify(citationNode.attrs.embeddedCitationItems));
|
|
55
|
+
}
|
|
47
56
|
dom.innerHTML = citationNode.attrs.contents;
|
|
48
57
|
return dom;
|
|
49
58
|
},
|
|
@@ -57,6 +57,7 @@ exports.orderedList = {
|
|
|
57
57
|
group: 'block list element',
|
|
58
58
|
attrs: {
|
|
59
59
|
id: { default: '' },
|
|
60
|
+
listStyleType: { default: null },
|
|
60
61
|
paragraphStyle: { default: '' },
|
|
61
62
|
dataTracked: { default: null },
|
|
62
63
|
},
|
|
@@ -67,6 +68,7 @@ exports.orderedList = {
|
|
|
67
68
|
const dom = p;
|
|
68
69
|
return {
|
|
69
70
|
id: dom.getAttribute('id'),
|
|
71
|
+
listStyleType: dom.getAttribute('list-type'),
|
|
70
72
|
};
|
|
71
73
|
},
|
|
72
74
|
},
|
|
@@ -78,6 +80,7 @@ exports.orderedList = {
|
|
|
78
80
|
'ol',
|
|
79
81
|
{
|
|
80
82
|
id: orderedListNode.attrs.id,
|
|
83
|
+
'list-type': orderedListNode.attrs.listStyleType,
|
|
81
84
|
class: (0, attributes_1.buildElementClass)(orderedListNode.attrs),
|
|
82
85
|
'data-object-type': json_schema_1.ObjectTypes.ListElement,
|
|
83
86
|
},
|
|
@@ -151,6 +151,8 @@ class Decoder {
|
|
|
151
151
|
},
|
|
152
152
|
[json_schema_1.ObjectTypes.BibliographyItem]: (data) => {
|
|
153
153
|
const model = data;
|
|
154
|
+
const commentNodes = this.createCommentsNode(model);
|
|
155
|
+
commentNodes.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
154
156
|
return schema_1.schema.nodes.bibliography_item.create({
|
|
155
157
|
id: model._id,
|
|
156
158
|
type: model.type,
|
|
@@ -164,6 +166,7 @@ class Decoder {
|
|
|
164
166
|
page: model.page,
|
|
165
167
|
title: model.title,
|
|
166
168
|
literal: model.literal,
|
|
169
|
+
comments: commentNodes.map((c) => c.attrs.id),
|
|
167
170
|
});
|
|
168
171
|
},
|
|
169
172
|
[object_types_1.ExtraObjectTypes.PlaceholderElement]: (data) => {
|
|
@@ -330,6 +333,7 @@ class Decoder {
|
|
|
330
333
|
return this.parseContents(model.contents || '<ol></ol>', undefined, this.getComments(model), {
|
|
331
334
|
topNode: schema_1.schema.nodes.ordered_list.create({
|
|
332
335
|
id: model._id,
|
|
336
|
+
listStyleType: model.listStyleType,
|
|
333
337
|
paragraphStyle: model.paragraphStyle,
|
|
334
338
|
comments: commentNodes.map((c) => c.attrs.id),
|
|
335
339
|
}),
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.isNodeType = exports.isSectionNodeType = exports.isElementNodeType = exports.isExecutableNodeType = exports.nodeTypesMap = void 0;
|
|
18
|
+
exports.isMetaNode = exports.isNodeType = exports.isSectionNodeType = exports.isElementNodeType = exports.isExecutableNodeType = exports.nodeTypesMap = void 0;
|
|
19
19
|
const json_schema_1 = require("@manuscripts/json-schema");
|
|
20
20
|
const schema_1 = require("../schema");
|
|
21
21
|
exports.nodeTypesMap = new Map([
|
|
@@ -66,3 +66,8 @@ const isSectionNodeType = (type) => (0, schema_1.hasGroup)(type, schema_1.GROUP_
|
|
|
66
66
|
exports.isSectionNodeType = isSectionNodeType;
|
|
67
67
|
const isNodeType = (node, type) => node.type === node.type.schema.nodes[type];
|
|
68
68
|
exports.isNodeType = isNodeType;
|
|
69
|
+
const isMetaNode = (nodeType) => nodeType === schema_1.schema.nodes.bibliography_item.name ||
|
|
70
|
+
nodeType === schema_1.schema.nodes.affiliation.name ||
|
|
71
|
+
nodeType === schema_1.schema.nodes.contributor.name ||
|
|
72
|
+
nodeType === schema_1.schema.nodes.manuscript.name;
|
|
73
|
+
exports.isMetaNode = isMetaNode;
|
|
@@ -450,12 +450,13 @@ const nodes = [
|
|
|
450
450
|
},
|
|
451
451
|
},
|
|
452
452
|
{
|
|
453
|
-
tag: 'list[list-type
|
|
453
|
+
tag: 'list[list-type]',
|
|
454
454
|
node: 'ordered_list',
|
|
455
455
|
getAttrs: (node) => {
|
|
456
456
|
const element = node;
|
|
457
457
|
return {
|
|
458
458
|
id: element.getAttribute('id'),
|
|
459
|
+
listStyleType: element.getAttribute('list-type'),
|
|
459
460
|
};
|
|
460
461
|
},
|
|
461
462
|
},
|
|
@@ -644,9 +645,13 @@ const nodes = [
|
|
|
644
645
|
getAttrs: (node) => {
|
|
645
646
|
var _a;
|
|
646
647
|
const element = node;
|
|
648
|
+
const embeddedCitationAttr = element.getAttribute('data-reference-embedded-citation');
|
|
647
649
|
return {
|
|
648
650
|
rid: element.getAttribute('rid'),
|
|
649
651
|
contents: (_a = element.textContent) === null || _a === void 0 ? void 0 : _a.trim(),
|
|
652
|
+
embeddedCitationItems: embeddedCitationAttr
|
|
653
|
+
? JSON.parse(embeddedCitationAttr)
|
|
654
|
+
: null,
|
|
650
655
|
};
|
|
651
656
|
},
|
|
652
657
|
},
|
|
@@ -155,6 +155,7 @@ export const jatsReferenceParser = {
|
|
|
155
155
|
const citation = buildCitation('', rids);
|
|
156
156
|
modelNodes.push(citation);
|
|
157
157
|
crossReferenceNode.setAttribute('rid', citation._id);
|
|
158
|
+
crossReferenceNode.setAttribute('data-reference-embedded-citation', JSON.stringify(citation.embeddedCitationItems));
|
|
158
159
|
}
|
|
159
160
|
else {
|
|
160
161
|
crossReferenceNode.removeAttribute('rid');
|
|
@@ -818,7 +818,14 @@ export class JATSExporter {
|
|
|
818
818
|
graphic.setAttributeNS(XLINK_NAMESPACE, 'xlink:href', '');
|
|
819
819
|
return graphic;
|
|
820
820
|
},
|
|
821
|
-
ordered_list: () =>
|
|
821
|
+
ordered_list: (node) => {
|
|
822
|
+
var _a;
|
|
823
|
+
return [
|
|
824
|
+
'list',
|
|
825
|
+
{ 'list-type': (_a = node.attrs.listStyleType) !== null && _a !== void 0 ? _a : 'order' },
|
|
826
|
+
0,
|
|
827
|
+
];
|
|
828
|
+
},
|
|
822
829
|
paragraph: (node) => {
|
|
823
830
|
if (!node.childCount) {
|
|
824
831
|
return '';
|
|
@@ -23,16 +23,22 @@ export const citation = {
|
|
|
23
23
|
contents: { default: '' },
|
|
24
24
|
selectedText: { default: '' },
|
|
25
25
|
dataTracked: { default: null },
|
|
26
|
+
embeddedCitationItems: { default: null },
|
|
26
27
|
},
|
|
27
28
|
parseDOM: [
|
|
28
29
|
{
|
|
29
30
|
tag: 'span.citation[data-reference-id]',
|
|
30
31
|
getAttrs: (p) => {
|
|
31
32
|
const dom = p;
|
|
32
|
-
|
|
33
|
+
const attr = {
|
|
33
34
|
rid: dom.getAttribute('data-reference-id'),
|
|
34
35
|
contents: dom.innerHTML,
|
|
35
36
|
};
|
|
37
|
+
const embeddedCitationAttr = dom.getAttribute('data-reference-embedded-citation');
|
|
38
|
+
if (embeddedCitationAttr) {
|
|
39
|
+
attr['embeddedCitationItems'] = JSON.parse(embeddedCitationAttr);
|
|
40
|
+
}
|
|
41
|
+
return attr;
|
|
36
42
|
},
|
|
37
43
|
},
|
|
38
44
|
],
|
|
@@ -41,6 +47,9 @@ export const citation = {
|
|
|
41
47
|
const dom = document.createElement('span');
|
|
42
48
|
dom.className = 'citation';
|
|
43
49
|
dom.setAttribute('data-reference-id', citationNode.attrs.rid);
|
|
50
|
+
if (citationNode.attrs.embeddedCitationItems) {
|
|
51
|
+
dom.setAttribute('data-reference-embedded-citation', JSON.stringify(citationNode.attrs.embeddedCitationItems));
|
|
52
|
+
}
|
|
44
53
|
dom.innerHTML = citationNode.attrs.contents;
|
|
45
54
|
return dom;
|
|
46
55
|
},
|
|
@@ -54,6 +54,7 @@ export const orderedList = {
|
|
|
54
54
|
group: 'block list element',
|
|
55
55
|
attrs: {
|
|
56
56
|
id: { default: '' },
|
|
57
|
+
listStyleType: { default: null },
|
|
57
58
|
paragraphStyle: { default: '' },
|
|
58
59
|
dataTracked: { default: null },
|
|
59
60
|
},
|
|
@@ -64,6 +65,7 @@ export const orderedList = {
|
|
|
64
65
|
const dom = p;
|
|
65
66
|
return {
|
|
66
67
|
id: dom.getAttribute('id'),
|
|
68
|
+
listStyleType: dom.getAttribute('list-type'),
|
|
67
69
|
};
|
|
68
70
|
},
|
|
69
71
|
},
|
|
@@ -75,6 +77,7 @@ export const orderedList = {
|
|
|
75
77
|
'ol',
|
|
76
78
|
{
|
|
77
79
|
id: orderedListNode.attrs.id,
|
|
80
|
+
'list-type': orderedListNode.attrs.listStyleType,
|
|
78
81
|
class: buildElementClass(orderedListNode.attrs),
|
|
79
82
|
'data-object-type': ObjectTypes.ListElement,
|
|
80
83
|
},
|
|
@@ -141,6 +141,8 @@ export class Decoder {
|
|
|
141
141
|
},
|
|
142
142
|
[ObjectTypes.BibliographyItem]: (data) => {
|
|
143
143
|
const model = data;
|
|
144
|
+
const commentNodes = this.createCommentsNode(model);
|
|
145
|
+
commentNodes.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
144
146
|
return schema.nodes.bibliography_item.create({
|
|
145
147
|
id: model._id,
|
|
146
148
|
type: model.type,
|
|
@@ -154,6 +156,7 @@ export class Decoder {
|
|
|
154
156
|
page: model.page,
|
|
155
157
|
title: model.title,
|
|
156
158
|
literal: model.literal,
|
|
159
|
+
comments: commentNodes.map((c) => c.attrs.id),
|
|
157
160
|
});
|
|
158
161
|
},
|
|
159
162
|
[ExtraObjectTypes.PlaceholderElement]: (data) => {
|
|
@@ -320,6 +323,7 @@ export class Decoder {
|
|
|
320
323
|
return this.parseContents(model.contents || '<ol></ol>', undefined, this.getComments(model), {
|
|
321
324
|
topNode: schema.nodes.ordered_list.create({
|
|
322
325
|
id: model._id,
|
|
326
|
+
listStyleType: model.listStyleType,
|
|
323
327
|
paragraphStyle: model.paragraphStyle,
|
|
324
328
|
comments: commentNodes.map((c) => c.attrs.id),
|
|
325
329
|
}),
|
|
@@ -59,3 +59,7 @@ export const isExecutableNodeType = (type) => hasGroup(type, GROUP_EXECUTABLE);
|
|
|
59
59
|
export const isElementNodeType = (type) => hasGroup(type, GROUP_ELEMENT);
|
|
60
60
|
export const isSectionNodeType = (type) => hasGroup(type, GROUP_SECTION);
|
|
61
61
|
export const isNodeType = (node, type) => node.type === node.type.schema.nodes[type];
|
|
62
|
+
export const isMetaNode = (nodeType) => nodeType === schema.nodes.bibliography_item.name ||
|
|
63
|
+
nodeType === schema.nodes.affiliation.name ||
|
|
64
|
+
nodeType === schema.nodes.contributor.name ||
|
|
65
|
+
nodeType === schema.nodes.manuscript.name;
|
|
@@ -18,6 +18,10 @@ import { ManuscriptNode } from '../types';
|
|
|
18
18
|
interface Attrs {
|
|
19
19
|
rid: string;
|
|
20
20
|
contents: string;
|
|
21
|
+
embeddedCitationItems: {
|
|
22
|
+
id: string;
|
|
23
|
+
bibliographyItem: string;
|
|
24
|
+
}[];
|
|
21
25
|
}
|
|
22
26
|
export interface CitationNode extends ManuscriptNode {
|
|
23
27
|
attrs: Attrs;
|
|
@@ -20,3 +20,4 @@ export declare const isExecutableNodeType: (type: ManuscriptNodeType) => boolean
|
|
|
20
20
|
export declare const isElementNodeType: (type: ManuscriptNodeType) => boolean;
|
|
21
21
|
export declare const isSectionNodeType: (type: ManuscriptNodeType) => boolean;
|
|
22
22
|
export declare const isNodeType: <T extends import("prosemirror-model").Node>(node: ManuscriptNode, type: Nodes) => node is T;
|
|
23
|
+
export declare const isMetaNode: (nodeType: string) => boolean;
|
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": "1.
|
|
4
|
+
"version": "1.4.1-LEAN-2737",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-transform",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"version": "yarn build"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@manuscripts/json-schema": "^2.
|
|
32
|
+
"@manuscripts/json-schema": "^2.2.0",
|
|
33
33
|
"debug": "^4.3.4",
|
|
34
34
|
"jszip": "^3.10.1",
|
|
35
35
|
"mathjax-full": "^3.2.2",
|