@manuscripts/transform 1.5.5 → 1.5.7-LEAN-3030
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 +23 -18
- package/dist/cjs/jats/importer/jats-body-transformations.js +3 -3
- package/dist/cjs/jats/jats-exporter.js +11 -6
- package/dist/cjs/lib/utils.js +10 -1
- package/dist/cjs/schema/index.js +15 -11
- package/dist/cjs/schema/nodes/{affiliations_section.js → affiliations.js} +9 -8
- package/dist/cjs/schema/nodes/{contributors_section.js → contributors.js} +8 -7
- package/dist/cjs/schema/nodes/core_section.js +27 -0
- package/dist/cjs/schema/nodes/graphical_abstract_section.js +1 -0
- package/dist/cjs/schema/nodes/keyword.js +0 -1
- package/dist/cjs/schema/nodes/{keywords_group.js → keyword_group.js} +6 -6
- package/dist/cjs/schema/nodes/{keywords_section.js → keywords.js} +7 -7
- package/dist/cjs/schema/nodes/keywords_element.js +1 -1
- package/dist/cjs/schema/nodes/manuscript.js +1 -1
- package/dist/cjs/transformer/decode.js +110 -113
- package/dist/cjs/transformer/encode.js +24 -28
- package/dist/cjs/transformer/node-names.js +1 -1
- package/dist/cjs/transformer/node-title.js +1 -1
- package/dist/cjs/transformer/node-types.js +7 -4
- package/dist/cjs/transformer/section-category.js +35 -8
- package/dist/es/jats/importer/jats-body-dom-parser.js +23 -18
- package/dist/es/jats/importer/jats-body-transformations.js +3 -3
- package/dist/es/jats/jats-exporter.js +11 -6
- package/dist/es/lib/utils.js +8 -0
- package/dist/es/schema/index.js +15 -11
- package/dist/es/schema/nodes/{affiliations_section.js → affiliations.js} +7 -6
- package/dist/es/schema/nodes/{contributors_section.js → contributors.js} +6 -5
- package/dist/es/schema/nodes/core_section.js +24 -0
- package/dist/es/schema/nodes/graphical_abstract_section.js +1 -0
- package/dist/es/schema/nodes/keyword.js +0 -1
- package/dist/es/schema/nodes/{keywords_group.js → keyword_group.js} +4 -4
- package/dist/es/schema/nodes/{keywords_section.js → keywords.js} +5 -5
- package/dist/es/schema/nodes/keywords_element.js +1 -1
- package/dist/es/schema/nodes/manuscript.js +1 -1
- package/dist/es/transformer/decode.js +111 -114
- package/dist/es/transformer/encode.js +24 -28
- package/dist/es/transformer/node-names.js +1 -1
- package/dist/es/transformer/node-title.js +1 -1
- package/dist/es/transformer/node-types.js +7 -4
- package/dist/es/transformer/section-category.js +33 -7
- package/dist/types/lib/utils.d.ts +1 -0
- package/dist/types/schema/index.d.ts +3 -3
- package/dist/types/schema/nodes/affiliations.d.ts +11 -0
- package/dist/types/schema/nodes/contributors.d.ts +12 -0
- package/dist/types/schema/nodes/core_section.d.ts +17 -0
- package/dist/types/schema/nodes/keyword.d.ts +0 -1
- package/dist/types/schema/nodes/{keywords_group.d.ts → keyword_group.d.ts} +3 -3
- package/dist/types/schema/nodes/{keywords_section.d.ts → keywords.d.ts} +3 -3
- package/dist/types/schema/types.d.ts +1 -1
- package/dist/types/transformer/decode.d.ts +6 -6
- package/dist/types/transformer/encode.d.ts +1 -1
- package/dist/types/transformer/section-category.d.ts +1 -0
- package/package.json +1 -1
- package/dist/types/schema/nodes/affiliations_section.d.ts +0 -11
- package/dist/types/schema/nodes/contributors_section.d.ts +0 -12
|
@@ -34,6 +34,7 @@ const json_schema_1 = require("@manuscripts/json-schema");
|
|
|
34
34
|
const debug_1 = __importDefault(require("debug"));
|
|
35
35
|
const prosemirror_model_1 = require("prosemirror-model");
|
|
36
36
|
const errors_1 = require("../errors");
|
|
37
|
+
const utils_1 = require("../lib/utils");
|
|
37
38
|
const schema_1 = require("../schema");
|
|
38
39
|
const builders_1 = require("./builders");
|
|
39
40
|
const highlight_markers_1 = require("./highlight-markers");
|
|
@@ -63,18 +64,42 @@ exports.sortSectionsByPriority = sortSectionsByPriority;
|
|
|
63
64
|
const getSections = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.Section).sort(exports.sortSectionsByPriority);
|
|
64
65
|
const getAffiliations = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.Affiliation);
|
|
65
66
|
const getContributors = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.Contributor);
|
|
67
|
+
const getKeywordElements = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.KeywordsElement);
|
|
68
|
+
const getKeywordGroups = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.KeywordGroup);
|
|
69
|
+
const getKeywords = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.Keyword);
|
|
70
|
+
const getTitles = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.Titles)[0];
|
|
66
71
|
const isManuscriptNode = (model) => model !== null;
|
|
67
72
|
exports.isManuscriptNode = isManuscriptNode;
|
|
68
|
-
const isParagraphElement = (0, object_types_1.hasObjectType)(json_schema_1.ObjectTypes.ParagraphElement);
|
|
69
73
|
const isFootnote = (0, object_types_1.hasObjectType)(json_schema_1.ObjectTypes.Footnote);
|
|
70
|
-
const isKeyword = (0, object_types_1.hasObjectType)(json_schema_1.ObjectTypes.Keyword);
|
|
71
|
-
const isKeywordsSection = (model) => model.category === 'MPSectionCategory:keywords';
|
|
72
|
-
const isAffiliationsSection = (model) => model.category === 'MPSectionCategory:affiliations';
|
|
73
|
-
const isContributorsSection = (model) => model.category === 'MPSectionCategory:contributors';
|
|
74
74
|
const hasParentSection = (id) => (section) => section.path &&
|
|
75
75
|
section.path.length > 1 &&
|
|
76
76
|
section.path[section.path.length - 2] === id;
|
|
77
77
|
class Decoder {
|
|
78
|
+
createTitleNode() {
|
|
79
|
+
const titles = getTitles(this.modelMap) || (0, builders_1.buildTitles)();
|
|
80
|
+
return this.decode(titles);
|
|
81
|
+
}
|
|
82
|
+
createAffiliationsNode() {
|
|
83
|
+
const affiliations = getAffiliations(this.modelMap)
|
|
84
|
+
.map((a) => this.decode(a))
|
|
85
|
+
.filter(Boolean);
|
|
86
|
+
return schema_1.schema.nodes.affiliations.createAndFill({}, affiliations);
|
|
87
|
+
}
|
|
88
|
+
createContributorsNode() {
|
|
89
|
+
const contributors = getContributors(this.modelMap)
|
|
90
|
+
.map((c) => this.decode(c))
|
|
91
|
+
.filter(Boolean);
|
|
92
|
+
return schema_1.schema.nodes.contributors.createAndFill({}, contributors);
|
|
93
|
+
}
|
|
94
|
+
createKeywordsNode() {
|
|
95
|
+
const elements = getKeywordElements(this.modelMap)
|
|
96
|
+
.map((e) => this.decode(e))
|
|
97
|
+
.filter(Boolean);
|
|
98
|
+
return schema_1.schema.nodes.keywords.createAndFill({}, [
|
|
99
|
+
schema_1.schema.nodes.section_title.create({}, schema_1.schema.text('Keywords')),
|
|
100
|
+
...elements,
|
|
101
|
+
]);
|
|
102
|
+
}
|
|
78
103
|
createMetaSectionNode() {
|
|
79
104
|
const commentListNode = this.createCommentListNode();
|
|
80
105
|
return schema_1.schema.nodes.meta_section.createAndFill({}, [
|
|
@@ -86,54 +111,51 @@ class Decoder {
|
|
|
86
111
|
...this.comments.values(),
|
|
87
112
|
]);
|
|
88
113
|
}
|
|
89
|
-
handleMissingRootSectionNodes(rootSectionNodes) {
|
|
90
|
-
if (!rootSectionNodes.find((node) => node.type.name === 'affiliations_section')) {
|
|
91
|
-
this.createAffiliationSectionNode(rootSectionNodes);
|
|
92
|
-
}
|
|
93
|
-
if (!rootSectionNodes.find((node) => node.type.name === 'contributors_section')) {
|
|
94
|
-
this.createContributorSectionNode(rootSectionNodes);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
createAffiliationSectionNode(rootSectionNodes) {
|
|
98
|
-
const affiliationNodes = getAffiliations(this.modelMap)
|
|
99
|
-
.map((affiliation) => this.decode(affiliation))
|
|
100
|
-
.filter(Boolean);
|
|
101
|
-
if (affiliationNodes.length) {
|
|
102
|
-
const node = schema_1.schema.nodes.affiliations_section.createAndFill({
|
|
103
|
-
id: (0, id_1.generateNodeID)(schema_1.schema.nodes.section),
|
|
104
|
-
}, affiliationNodes);
|
|
105
|
-
rootSectionNodes.unshift(node);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
createContributorSectionNode(rootSectionNodes) {
|
|
109
|
-
const contributorNodes = getContributors(this.modelMap)
|
|
110
|
-
.map((contributor) => this.decode(contributor))
|
|
111
|
-
.filter(Boolean);
|
|
112
|
-
if (contributorNodes.length) {
|
|
113
|
-
const node = schema_1.schema.nodes.contributors_section.createAndFill({
|
|
114
|
-
id: (0, id_1.generateNodeID)(schema_1.schema.nodes.section),
|
|
115
|
-
}, contributorNodes);
|
|
116
|
-
rootSectionNodes.unshift(node);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
createTitleNode() {
|
|
120
|
-
const titles = (0, exports.getModelsByType)(this.modelMap, json_schema_1.ObjectTypes.Titles)[0] ||
|
|
121
|
-
(0, builders_1.buildTitles)();
|
|
122
|
-
return this.decode(titles);
|
|
123
|
-
}
|
|
124
114
|
createRootSectionNodes() {
|
|
125
|
-
let rootSections = getSections(this.modelMap)
|
|
115
|
+
let rootSections = getSections(this.modelMap)
|
|
116
|
+
.filter((section) => !section.path || section.path.length <= 1)
|
|
117
|
+
.filter((section) => section.category !== 'MPSectionCategory:contributors' &&
|
|
118
|
+
section.category !== 'MPSectionCategory:affiliations' &&
|
|
119
|
+
section.category !== 'MPSectionCategory:keywords');
|
|
126
120
|
rootSections = this.addGeneratedLabels(rootSections);
|
|
127
|
-
const
|
|
121
|
+
const sectionGroups = (0, utils_1.groupBy)(rootSections, (sec) => {
|
|
122
|
+
var _a;
|
|
123
|
+
return (0, section_category_1.chooseCoreSectionBySection)((_a = sec.category) !== null && _a !== void 0 ? _a : '');
|
|
124
|
+
});
|
|
125
|
+
this.ensureCoreSectionsExist(sectionGroups);
|
|
126
|
+
const absSectionNode = sectionGroups['MPSectionCategory:abstracts']
|
|
127
|
+
.map(this.decode)
|
|
128
|
+
.filter(exports.isManuscriptNode);
|
|
129
|
+
const bodySectionNodes = sectionGroups['MPSectionCategory:body']
|
|
130
|
+
.map(this.decode)
|
|
131
|
+
.filter(exports.isManuscriptNode);
|
|
132
|
+
const backmatterSectionNodes = sectionGroups['MPSectionCategory:backmatter']
|
|
128
133
|
.map(this.decode)
|
|
129
134
|
.filter(exports.isManuscriptNode);
|
|
130
|
-
this.
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
+
const abstractCoreSectionNodes = this.createAndFill(schema_1.schema.nodes.abstracts, absSectionNode);
|
|
136
|
+
const bodyCoreSectionNodes = this.createAndFill(schema_1.schema.nodes.body, bodySectionNodes);
|
|
137
|
+
const backmatterCoreSectionNodes = this.createAndFill(schema_1.schema.nodes.backmatter, backmatterSectionNodes);
|
|
138
|
+
return {
|
|
139
|
+
abstracts: abstractCoreSectionNodes,
|
|
140
|
+
body: bodyCoreSectionNodes,
|
|
141
|
+
backmatter: backmatterCoreSectionNodes,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
ensureCoreSectionsExist(coreSections) {
|
|
145
|
+
if (!coreSections['MPSectionCategory:abstracts']) {
|
|
146
|
+
coreSections['MPSectionCategory:abstracts'] = [];
|
|
147
|
+
}
|
|
148
|
+
if (!coreSections['MPSectionCategory:body']) {
|
|
149
|
+
coreSections['MPSectionCategory:body'] = [];
|
|
135
150
|
}
|
|
136
|
-
|
|
151
|
+
if (!coreSections['MPSectionCategory:backmatter']) {
|
|
152
|
+
coreSections['MPSectionCategory:backmatter'] = [];
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
createAndFill(nodeType, content) {
|
|
156
|
+
return nodeType.createAndFill({
|
|
157
|
+
id: (0, id_1.generateNodeID)(nodeType),
|
|
158
|
+
}, content);
|
|
137
159
|
}
|
|
138
160
|
createCommentsNode(model) {
|
|
139
161
|
const comments = [];
|
|
@@ -339,19 +361,34 @@ class Decoder {
|
|
|
339
361
|
},
|
|
340
362
|
[json_schema_1.ObjectTypes.KeywordsElement]: (data) => {
|
|
341
363
|
const model = data;
|
|
342
|
-
const keywordGroups = this.
|
|
364
|
+
const keywordGroups = getKeywordGroups(this.modelMap).map((k) => this.decode(k));
|
|
343
365
|
return schema_1.schema.nodes.keywords_element.create({
|
|
344
366
|
id: model._id,
|
|
345
367
|
paragraphStyle: model.paragraphStyle,
|
|
346
368
|
}, keywordGroups);
|
|
347
369
|
},
|
|
370
|
+
[json_schema_1.ObjectTypes.KeywordGroup]: (data) => {
|
|
371
|
+
const keywordGroup = data;
|
|
372
|
+
const keywords = getKeywords(this.modelMap)
|
|
373
|
+
.filter((k) => k.containedGroup === keywordGroup._id)
|
|
374
|
+
.map((k) => this.decode(k));
|
|
375
|
+
const comments = this.createCommentsNode(keywordGroup);
|
|
376
|
+
comments.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
377
|
+
return schema_1.schema.nodes.keyword_group.create({
|
|
378
|
+
id: keywordGroup._id,
|
|
379
|
+
type: keywordGroup.type,
|
|
380
|
+
comments: comments.map((c) => c.attrs.id),
|
|
381
|
+
}, keywords);
|
|
382
|
+
},
|
|
348
383
|
[json_schema_1.ObjectTypes.Keyword]: (data) => {
|
|
349
|
-
const
|
|
384
|
+
const keyword = data;
|
|
385
|
+
const comments = this.createCommentsNode(keyword);
|
|
386
|
+
comments.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
350
387
|
return schema_1.schema.nodes.keyword.create({
|
|
351
|
-
id:
|
|
352
|
-
contents:
|
|
353
|
-
comments:
|
|
354
|
-
}, schema_1.schema.text(
|
|
388
|
+
id: keyword._id,
|
|
389
|
+
contents: keyword.name,
|
|
390
|
+
comments: comments.map((c) => c.attrs.id),
|
|
391
|
+
}, schema_1.schema.text(keyword.name));
|
|
355
392
|
},
|
|
356
393
|
[json_schema_1.ObjectTypes.ListElement]: (data) => {
|
|
357
394
|
const model = data;
|
|
@@ -473,9 +510,6 @@ class Decoder {
|
|
|
473
510
|
for (const id of model.elementIDs) {
|
|
474
511
|
const element = this.getModel(id);
|
|
475
512
|
if (element) {
|
|
476
|
-
if (isKeywordsSection(model) && isParagraphElement(element)) {
|
|
477
|
-
continue;
|
|
478
|
-
}
|
|
479
513
|
elements.push(element);
|
|
480
514
|
}
|
|
481
515
|
else if (this.allowMissingElements) {
|
|
@@ -516,17 +550,11 @@ class Decoder {
|
|
|
516
550
|
const sectionNodeType = (0, section_category_1.chooseSectionNodeType)(sectionCategory);
|
|
517
551
|
const commentNodes = this.createCommentsNode(model);
|
|
518
552
|
commentNodes.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
content = (sectionLabelNode
|
|
525
|
-
? [sectionLabelNode, sectionTitleNode]
|
|
526
|
-
: [sectionTitleNode])
|
|
527
|
-
.concat(elementNodes)
|
|
528
|
-
.concat(nestedSections);
|
|
529
|
-
}
|
|
553
|
+
const content = (sectionLabelNode
|
|
554
|
+
? [sectionLabelNode, sectionTitleNode]
|
|
555
|
+
: [sectionTitleNode])
|
|
556
|
+
.concat(elementNodes)
|
|
557
|
+
.concat(nestedSections);
|
|
530
558
|
const sectionNode = sectionNodeType.createAndFill({
|
|
531
559
|
id: model._id,
|
|
532
560
|
category: sectionCategory,
|
|
@@ -645,13 +673,21 @@ class Decoder {
|
|
|
645
673
|
};
|
|
646
674
|
this.getModel = (id) => this.modelMap.get(id);
|
|
647
675
|
this.createArticleNode = (manuscriptID) => {
|
|
648
|
-
const
|
|
649
|
-
const
|
|
650
|
-
const
|
|
676
|
+
const title = this.createTitleNode();
|
|
677
|
+
const contributors = this.createContributorsNode();
|
|
678
|
+
const affiliations = this.createAffiliationsNode();
|
|
679
|
+
const keywords = this.createKeywordsNode();
|
|
680
|
+
const { abstracts, body, backmatter } = this.createRootSectionNodes();
|
|
681
|
+
const meta = this.createMetaSectionNode();
|
|
651
682
|
const contents = [
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
683
|
+
title,
|
|
684
|
+
contributors,
|
|
685
|
+
affiliations,
|
|
686
|
+
keywords,
|
|
687
|
+
abstracts,
|
|
688
|
+
body,
|
|
689
|
+
backmatter,
|
|
690
|
+
meta,
|
|
655
691
|
];
|
|
656
692
|
return schema_1.schema.nodes.manuscript.create({
|
|
657
693
|
id: manuscriptID || this.getManuscriptID(),
|
|
@@ -693,23 +729,6 @@ class Decoder {
|
|
|
693
729
|
}
|
|
694
730
|
return parser.parse(template.content.firstElementChild, options);
|
|
695
731
|
};
|
|
696
|
-
this.getKeywords = (id) => {
|
|
697
|
-
const keywordsOfKind = [];
|
|
698
|
-
const keywordsByGroup = [...this.modelMap.values()].filter((m) => m.objectType === json_schema_1.ObjectTypes.Keyword &&
|
|
699
|
-
m.containedGroup === id);
|
|
700
|
-
for (const model of keywordsByGroup) {
|
|
701
|
-
if (isKeyword(model)) {
|
|
702
|
-
const keyword = this.parseContents(model.name || '', 'div', this.getComments(model), {
|
|
703
|
-
topNode: schema_1.schema.nodes.keyword.create({
|
|
704
|
-
id: model._id,
|
|
705
|
-
contents: model.name,
|
|
706
|
-
}),
|
|
707
|
-
});
|
|
708
|
-
keywordsOfKind.push(keyword);
|
|
709
|
-
}
|
|
710
|
-
}
|
|
711
|
-
return keywordsOfKind;
|
|
712
|
-
};
|
|
713
732
|
this.getManuscriptID = () => {
|
|
714
733
|
for (const item of this.modelMap.values()) {
|
|
715
734
|
if ((0, object_types_1.isManuscript)(item)) {
|
|
@@ -794,27 +813,5 @@ class Decoder {
|
|
|
794
813
|
}
|
|
795
814
|
return listing;
|
|
796
815
|
}
|
|
797
|
-
getKeywordGroups() {
|
|
798
|
-
const kwdGroupNodes = [];
|
|
799
|
-
const kwdGroupsModels = [
|
|
800
|
-
...this.modelMap.values(),
|
|
801
|
-
].filter((model) => model.objectType === json_schema_1.ObjectTypes.KeywordGroup);
|
|
802
|
-
if (kwdGroupsModels.length > 0) {
|
|
803
|
-
for (const kwdGroupModel of kwdGroupsModels) {
|
|
804
|
-
const keywords = this.getKeywords(kwdGroupModel._id);
|
|
805
|
-
const commentNodes = this.createCommentsNode(kwdGroupModel);
|
|
806
|
-
commentNodes.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
807
|
-
const contents = [];
|
|
808
|
-
contents.push(...keywords);
|
|
809
|
-
const kwdGroupNode = schema_1.schema.nodes.keywords_group.create({
|
|
810
|
-
id: kwdGroupModel._id,
|
|
811
|
-
type: kwdGroupModel.type,
|
|
812
|
-
comments: commentNodes.map((c) => c.attrs.id),
|
|
813
|
-
}, contents);
|
|
814
|
-
kwdGroupNodes.push(kwdGroupNode);
|
|
815
|
-
}
|
|
816
|
-
}
|
|
817
|
-
return kwdGroupNodes;
|
|
818
|
-
}
|
|
819
816
|
}
|
|
820
817
|
exports.Decoder = Decoder;
|
|
@@ -428,34 +428,9 @@ const encoders = {
|
|
|
428
428
|
elementType: 'div',
|
|
429
429
|
paragraphStyle: node.attrs.paragraphStyle || undefined,
|
|
430
430
|
}),
|
|
431
|
-
|
|
431
|
+
keyword_group: (node) => ({
|
|
432
432
|
type: node.attrs.type,
|
|
433
433
|
}),
|
|
434
|
-
keywords_section: (node, parent, path, priority) => ({
|
|
435
|
-
category: (0, section_category_1.buildSectionCategory)(node),
|
|
436
|
-
priority: priority.value++,
|
|
437
|
-
title: inlineContentsOfNodeType(node, node.type.schema.nodes.section_title),
|
|
438
|
-
path: path.concat([node.attrs.id]),
|
|
439
|
-
elementIDs: childElements(node)
|
|
440
|
-
.map((childNode) => childNode.attrs.id)
|
|
441
|
-
.filter((id) => id),
|
|
442
|
-
}),
|
|
443
|
-
affiliations_section: (node, parent, path, priority) => ({
|
|
444
|
-
category: (0, section_category_1.buildSectionCategory)(node),
|
|
445
|
-
priority: priority.value++,
|
|
446
|
-
path: path.concat([node.attrs.id]),
|
|
447
|
-
elementIDs: childElements(node)
|
|
448
|
-
.map((childNode) => childNode.attrs.id)
|
|
449
|
-
.filter((id) => id),
|
|
450
|
-
}),
|
|
451
|
-
contributors_section: (node, parent, path, priority) => ({
|
|
452
|
-
category: (0, section_category_1.buildSectionCategory)(node),
|
|
453
|
-
priority: priority.value++,
|
|
454
|
-
path: path.concat([node.attrs.id]),
|
|
455
|
-
elementIDs: childElements(node)
|
|
456
|
-
.map((childNode) => childNode.attrs.id)
|
|
457
|
-
.filter((id) => id),
|
|
458
|
-
}),
|
|
459
434
|
missing_figure: (node) => ({
|
|
460
435
|
position: node.attrs.position || undefined,
|
|
461
436
|
}),
|
|
@@ -573,9 +548,18 @@ const modelFromNode = (node, parent, path, priority) => {
|
|
|
573
548
|
if ((0, highlight_markers_1.isHighlightableModel)(model)) {
|
|
574
549
|
(0, highlight_markers_1.extractHighlightMarkers)(model, commentAnnotationsMap);
|
|
575
550
|
}
|
|
576
|
-
|
|
551
|
+
const comments = [...commentAnnotationsMap.values()];
|
|
552
|
+
return { model, comments };
|
|
577
553
|
};
|
|
578
554
|
exports.modelFromNode = modelFromNode;
|
|
555
|
+
function isCoreSection(child) {
|
|
556
|
+
return (child.type === schema_1.schema.nodes.abstracts ||
|
|
557
|
+
child.type === schema_1.schema.nodes.body ||
|
|
558
|
+
child.type === schema_1.schema.nodes.backmatter ||
|
|
559
|
+
child.type === schema_1.schema.nodes.affiliations ||
|
|
560
|
+
child.type === schema_1.schema.nodes.contributors ||
|
|
561
|
+
child.type === schema_1.schema.nodes.keywords);
|
|
562
|
+
}
|
|
579
563
|
const encode = (node) => {
|
|
580
564
|
const models = new Map();
|
|
581
565
|
const priority = {
|
|
@@ -583,6 +567,10 @@ const encode = (node) => {
|
|
|
583
567
|
};
|
|
584
568
|
const placeholders = ['placeholder', 'placeholder_element'];
|
|
585
569
|
const addModel = (path, parent) => (child) => {
|
|
570
|
+
if (isCoreSection(child)) {
|
|
571
|
+
child.forEach(addModel([], child));
|
|
572
|
+
return;
|
|
573
|
+
}
|
|
586
574
|
if (!child.attrs.id) {
|
|
587
575
|
return;
|
|
588
576
|
}
|
|
@@ -595,10 +583,18 @@ const encode = (node) => {
|
|
|
595
583
|
if (placeholders.includes(child.type.name)) {
|
|
596
584
|
return;
|
|
597
585
|
}
|
|
598
|
-
const { model } = (0, exports.modelFromNode)(child, parent, path, priority);
|
|
586
|
+
const { model, comments } = (0, exports.modelFromNode)(child, parent, path, priority);
|
|
599
587
|
if (models.has(model._id)) {
|
|
600
588
|
throw Error(`Encountered duplicate ids in models map while encoding: ${model._id}`);
|
|
601
589
|
}
|
|
590
|
+
comments.forEach((comment) => {
|
|
591
|
+
const proseMirrorComment = models.get(comment._id);
|
|
592
|
+
if (proseMirrorComment) {
|
|
593
|
+
;
|
|
594
|
+
proseMirrorComment.selector = comment.selector;
|
|
595
|
+
models.set(comment._id, proseMirrorComment);
|
|
596
|
+
}
|
|
597
|
+
});
|
|
602
598
|
models.set(model._id, model);
|
|
603
599
|
child.forEach(addModel(path.concat(child.attrs.id), child));
|
|
604
600
|
};
|
|
@@ -38,6 +38,6 @@ exports.nodeNames = new Map([
|
|
|
38
38
|
[schema_1.schema.nodes.table_element, 'Table'],
|
|
39
39
|
[schema_1.schema.nodes.blockquote_element, 'Block Quote'],
|
|
40
40
|
[schema_1.schema.nodes.pullquote_element, 'Pull Quote'],
|
|
41
|
-
[schema_1.schema.nodes.
|
|
41
|
+
[schema_1.schema.nodes.keywords, 'Section'],
|
|
42
42
|
[schema_1.schema.nodes.toc_section, 'Section'],
|
|
43
43
|
]);
|
|
@@ -50,7 +50,7 @@ const nodeTitle = (node) => {
|
|
|
50
50
|
case nodes.section:
|
|
51
51
|
case nodes.bibliography_section:
|
|
52
52
|
case nodes.footnotes_section:
|
|
53
|
-
case nodes.
|
|
53
|
+
case nodes.keywords:
|
|
54
54
|
case nodes.toc_section:
|
|
55
55
|
case nodes.graphical_abstract_section:
|
|
56
56
|
return snippetOfNodeType(node, nodes.section_title);
|
|
@@ -19,6 +19,9 @@ exports.isNodeType = exports.isSectionNodeType = exports.isElementNodeType = exp
|
|
|
19
19
|
const json_schema_1 = require("@manuscripts/json-schema");
|
|
20
20
|
const schema_1 = require("../schema");
|
|
21
21
|
exports.nodeTypesMap = new Map([
|
|
22
|
+
[schema_1.schema.nodes.abstracts, json_schema_1.ObjectTypes.Section],
|
|
23
|
+
[schema_1.schema.nodes.body, json_schema_1.ObjectTypes.Section],
|
|
24
|
+
[schema_1.schema.nodes.backmatter, json_schema_1.ObjectTypes.Section],
|
|
22
25
|
[schema_1.schema.nodes.comment, json_schema_1.ObjectTypes.CommentAnnotation],
|
|
23
26
|
[schema_1.schema.nodes.bibliography_item, json_schema_1.ObjectTypes.BibliographyItem],
|
|
24
27
|
[schema_1.schema.nodes.bibliography_element, json_schema_1.ObjectTypes.BibliographyElement],
|
|
@@ -40,8 +43,8 @@ exports.nodeTypesMap = new Map([
|
|
|
40
43
|
[schema_1.schema.nodes.inline_equation, json_schema_1.ObjectTypes.InlineMathFragment],
|
|
41
44
|
[schema_1.schema.nodes.keyword, json_schema_1.ObjectTypes.Keyword],
|
|
42
45
|
[schema_1.schema.nodes.keywords_element, json_schema_1.ObjectTypes.KeywordsElement],
|
|
43
|
-
[schema_1.schema.nodes.
|
|
44
|
-
[schema_1.schema.nodes.
|
|
46
|
+
[schema_1.schema.nodes.keywords, json_schema_1.ObjectTypes.Section],
|
|
47
|
+
[schema_1.schema.nodes.keyword_group, json_schema_1.ObjectTypes.KeywordGroup],
|
|
45
48
|
[schema_1.schema.nodes.listing, json_schema_1.ObjectTypes.Listing],
|
|
46
49
|
[schema_1.schema.nodes.listing_element, json_schema_1.ObjectTypes.ListingElement],
|
|
47
50
|
[schema_1.schema.nodes.manuscript, json_schema_1.ObjectTypes.Manuscript],
|
|
@@ -57,9 +60,9 @@ exports.nodeTypesMap = new Map([
|
|
|
57
60
|
[schema_1.schema.nodes.affiliation, json_schema_1.ObjectTypes.Affiliation],
|
|
58
61
|
[schema_1.schema.nodes.contributor, json_schema_1.ObjectTypes.Contributor],
|
|
59
62
|
[schema_1.schema.nodes.table_element_footer, json_schema_1.ObjectTypes.TableElementFooter],
|
|
63
|
+
[schema_1.schema.nodes.contributors, json_schema_1.ObjectTypes.Section],
|
|
64
|
+
[schema_1.schema.nodes.affiliations, json_schema_1.ObjectTypes.Section],
|
|
60
65
|
[schema_1.schema.nodes.title, json_schema_1.ObjectTypes.Titles],
|
|
61
|
-
[schema_1.schema.nodes.contributors_section, json_schema_1.ObjectTypes.Section],
|
|
62
|
-
[schema_1.schema.nodes.affiliations_section, json_schema_1.ObjectTypes.Section],
|
|
63
66
|
]);
|
|
64
67
|
const isExecutableNodeType = (type) => (0, schema_1.hasGroup)(type, schema_1.GROUP_EXECUTABLE);
|
|
65
68
|
exports.isExecutableNodeType = isExecutableNodeType;
|
|
@@ -15,14 +15,14 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.chooseSectionCategoryFromTitle = exports.chooseSectionCategory = exports.chooseSectionCategoryByType = exports.chooseSecType = exports.chooseJatsFnType = exports.buildSectionCategory = exports.guessSectionCategory = exports.chooseSectionLableName = exports.chooseSectionNodeType = exports.isAnySectionNode = exports.getCoreSectionTitles = void 0;
|
|
18
|
+
exports.chooseSectionCategoryFromTitle = exports.chooseSectionCategory = exports.chooseSectionCategoryByType = exports.chooseCoreSectionBySection = exports.chooseSecType = exports.chooseJatsFnType = exports.buildSectionCategory = exports.guessSectionCategory = exports.chooseSectionLableName = exports.chooseSectionNodeType = exports.isAnySectionNode = exports.getCoreSectionTitles = void 0;
|
|
19
19
|
const json_schema_1 = require("@manuscripts/json-schema");
|
|
20
20
|
const core_section_categories_1 = require("../lib/core-section-categories");
|
|
21
21
|
const schema_1 = require("../schema");
|
|
22
22
|
const sectionNodeTypes = [
|
|
23
23
|
schema_1.schema.nodes.bibliography_section,
|
|
24
24
|
schema_1.schema.nodes.footnotes_section,
|
|
25
|
-
schema_1.schema.nodes.
|
|
25
|
+
schema_1.schema.nodes.keywords,
|
|
26
26
|
schema_1.schema.nodes.section,
|
|
27
27
|
schema_1.schema.nodes.toc_section,
|
|
28
28
|
];
|
|
@@ -45,11 +45,11 @@ const chooseSectionNodeType = (category) => {
|
|
|
45
45
|
case 'MPSectionCategory:endnotes':
|
|
46
46
|
return schema_1.schema.nodes.footnotes_section;
|
|
47
47
|
case 'MPSectionCategory:keywords':
|
|
48
|
-
return schema_1.schema.nodes.
|
|
48
|
+
return schema_1.schema.nodes.keywords;
|
|
49
49
|
case 'MPSectionCategory:affiliations':
|
|
50
|
-
return schema_1.schema.nodes.
|
|
50
|
+
return schema_1.schema.nodes.affiliations;
|
|
51
51
|
case 'MPSectionCategory:contributors':
|
|
52
|
-
return schema_1.schema.nodes.
|
|
52
|
+
return schema_1.schema.nodes.contributors;
|
|
53
53
|
case 'MPSectionCategory:toc':
|
|
54
54
|
return schema_1.schema.nodes.toc_section;
|
|
55
55
|
default:
|
|
@@ -90,15 +90,15 @@ const buildSectionCategory = (node) => {
|
|
|
90
90
|
return 'MPSectionCategory:bibliography';
|
|
91
91
|
case schema_1.schema.nodes.footnotes_section:
|
|
92
92
|
return 'MPSectionCategory:endnotes';
|
|
93
|
-
case schema_1.schema.nodes.
|
|
93
|
+
case schema_1.schema.nodes.keywords:
|
|
94
94
|
return 'MPSectionCategory:keywords';
|
|
95
95
|
case schema_1.schema.nodes.toc_section:
|
|
96
96
|
return 'MPSectionCategory:toc';
|
|
97
97
|
case schema_1.schema.nodes.graphical_abstract_section:
|
|
98
98
|
return 'MPSectionCategory:abstract-graphical';
|
|
99
|
-
case schema_1.schema.nodes.
|
|
99
|
+
case schema_1.schema.nodes.affiliations:
|
|
100
100
|
return 'MPSectionCategory:affiliations';
|
|
101
|
-
case schema_1.schema.nodes.
|
|
101
|
+
case schema_1.schema.nodes.contributors:
|
|
102
102
|
return 'MPSectionCategory:contributors';
|
|
103
103
|
default:
|
|
104
104
|
return node.attrs.category || undefined;
|
|
@@ -128,6 +128,33 @@ const chooseSecType = (sectionCategory) => {
|
|
|
128
128
|
}
|
|
129
129
|
};
|
|
130
130
|
exports.chooseSecType = chooseSecType;
|
|
131
|
+
const chooseCoreSectionBySection = (section) => {
|
|
132
|
+
switch (section) {
|
|
133
|
+
case 'MPSectionCategory:abstract':
|
|
134
|
+
case 'MPSectionCategory:abstract-teaser':
|
|
135
|
+
case 'MPSectionCategory:abstract-graphical':
|
|
136
|
+
return 'MPSectionCategory:abstracts';
|
|
137
|
+
case 'MPSectionCategory:acknowledgement':
|
|
138
|
+
case 'MPSectionCategory:availability':
|
|
139
|
+
case 'MPSectionCategory:conclusions':
|
|
140
|
+
case 'MPSectionCategory:bibliography':
|
|
141
|
+
case 'MPSectionCategory:discussion':
|
|
142
|
+
case 'MPSectionCategory:endnotes':
|
|
143
|
+
case 'MPSectionCategory:appendices':
|
|
144
|
+
case 'MPSectionCategory:competing-interests':
|
|
145
|
+
case 'MPSectionCategory:con':
|
|
146
|
+
case 'MPSectionCategory:deceased':
|
|
147
|
+
case 'MPSectionCategory:ethics-statement':
|
|
148
|
+
case 'MPSectionCategory:financial-disclosure':
|
|
149
|
+
case 'MPSectionCategory:supplementary-material':
|
|
150
|
+
case 'MPSectionCategory:supported-by':
|
|
151
|
+
case 'MPSectionCategory:abbreviations':
|
|
152
|
+
case 'MPSectionCategory:results':
|
|
153
|
+
return 'MPSectionCategory:backmatter';
|
|
154
|
+
}
|
|
155
|
+
return 'MPSectionCategory:body';
|
|
156
|
+
};
|
|
157
|
+
exports.chooseCoreSectionBySection = chooseCoreSectionBySection;
|
|
131
158
|
const chooseSectionCategoryByType = (secType) => {
|
|
132
159
|
switch (secType) {
|
|
133
160
|
case 'abstract':
|
|
@@ -501,7 +501,7 @@ const nodes = [
|
|
|
501
501
|
},
|
|
502
502
|
{
|
|
503
503
|
tag: 'sec[sec-type="affiliations"]',
|
|
504
|
-
node: '
|
|
504
|
+
node: 'affiliations',
|
|
505
505
|
getAttrs: (node) => {
|
|
506
506
|
const element = node;
|
|
507
507
|
return {
|
|
@@ -513,7 +513,7 @@ const nodes = [
|
|
|
513
513
|
{
|
|
514
514
|
tag: 'aff',
|
|
515
515
|
node: 'affiliation',
|
|
516
|
-
context: '
|
|
516
|
+
context: 'affiliations/',
|
|
517
517
|
getAttrs: (node) => {
|
|
518
518
|
const element = node;
|
|
519
519
|
const aff = {
|
|
@@ -560,7 +560,7 @@ const nodes = [
|
|
|
560
560
|
},
|
|
561
561
|
{
|
|
562
562
|
tag: 'sec[sec-type="contributors"]',
|
|
563
|
-
node: '
|
|
563
|
+
node: 'contributors',
|
|
564
564
|
getAttrs: (node) => {
|
|
565
565
|
const element = node;
|
|
566
566
|
return {
|
|
@@ -572,7 +572,7 @@ const nodes = [
|
|
|
572
572
|
{
|
|
573
573
|
tag: 'contrib',
|
|
574
574
|
node: 'contributor',
|
|
575
|
-
context: '
|
|
575
|
+
context: 'contributors/',
|
|
576
576
|
getAttrs: (node) => {
|
|
577
577
|
const element = node;
|
|
578
578
|
const contrib = {
|
|
@@ -627,19 +627,19 @@ const nodes = [
|
|
|
627
627
|
},
|
|
628
628
|
{
|
|
629
629
|
tag: 'sec[sec-type="keywords"]',
|
|
630
|
-
node: '
|
|
631
|
-
getAttrs: (node) => {
|
|
632
|
-
const element = node;
|
|
633
|
-
return {
|
|
634
|
-
id: element.getAttribute('id'),
|
|
635
|
-
category: chooseSectionCategory(element),
|
|
636
|
-
};
|
|
637
|
-
},
|
|
630
|
+
node: 'keywords',
|
|
638
631
|
},
|
|
639
632
|
{
|
|
640
|
-
tag: '
|
|
641
|
-
|
|
642
|
-
|
|
633
|
+
tag: 'sec[sec-type="abstracts"]',
|
|
634
|
+
node: 'abstracts',
|
|
635
|
+
},
|
|
636
|
+
{
|
|
637
|
+
tag: 'sec[sec-type="body"]',
|
|
638
|
+
node: 'body',
|
|
639
|
+
},
|
|
640
|
+
{
|
|
641
|
+
tag: 'sec[sec-type="backmatter"]',
|
|
642
|
+
node: 'backmatter',
|
|
643
643
|
},
|
|
644
644
|
{
|
|
645
645
|
tag: 'sec',
|
|
@@ -652,10 +652,15 @@ const nodes = [
|
|
|
652
652
|
};
|
|
653
653
|
},
|
|
654
654
|
},
|
|
655
|
+
{
|
|
656
|
+
tag: 'kwd-group-list',
|
|
657
|
+
context: 'keywords/',
|
|
658
|
+
node: 'keywords_element',
|
|
659
|
+
},
|
|
655
660
|
{
|
|
656
661
|
tag: 'kwd-group',
|
|
657
662
|
context: 'keywords_element/',
|
|
658
|
-
node: '
|
|
663
|
+
node: 'keyword_group',
|
|
659
664
|
getAttrs: (node) => {
|
|
660
665
|
const element = node;
|
|
661
666
|
return {
|
|
@@ -665,7 +670,7 @@ const nodes = [
|
|
|
665
670
|
},
|
|
666
671
|
{
|
|
667
672
|
tag: 'kwd',
|
|
668
|
-
context: '
|
|
673
|
+
context: 'keyword_group//',
|
|
669
674
|
node: 'keyword',
|
|
670
675
|
},
|
|
671
676
|
{
|
|
@@ -720,7 +725,7 @@ const nodes = [
|
|
|
720
725
|
{
|
|
721
726
|
tag: 'title',
|
|
722
727
|
node: 'section_title',
|
|
723
|
-
context: 'section/|footnotes_section/|bibliography_section/|
|
|
728
|
+
context: 'section/|footnotes_section/|bibliography_section/|keywords/',
|
|
724
729
|
},
|
|
725
730
|
{
|
|
726
731
|
tag: 'title',
|
|
@@ -377,9 +377,9 @@ export const jatsBodyTransformations = {
|
|
|
377
377
|
const title = createElement('title');
|
|
378
378
|
title.textContent = 'Keywords';
|
|
379
379
|
section.append(title);
|
|
380
|
-
const
|
|
381
|
-
|
|
382
|
-
section.append(
|
|
380
|
+
const keywordsElement = createElement('kwd-group-list');
|
|
381
|
+
keywordsElement.append(keywordGroups[0]);
|
|
382
|
+
section.append(keywordsElement);
|
|
383
383
|
body.prepend(section);
|
|
384
384
|
}
|
|
385
385
|
},
|