@manuscripts/transform 1.5.2-LEAN-3032 → 1.5.2-LIT-528106
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 +7 -19
- package/dist/cjs/jats/jats-exporter.js +5 -10
- package/dist/cjs/lib/utils.js +13 -9
- package/dist/cjs/schema/index.js +3 -7
- package/dist/cjs/schema/nodes/affiliations_section.js +1 -1
- package/dist/cjs/schema/nodes/contributors_section.js +1 -1
- package/dist/cjs/schema/nodes/graphical_abstract_section.js +1 -0
- package/dist/cjs/schema/nodes/keywords_section.js +1 -1
- package/dist/cjs/schema/nodes/manuscript.js +1 -1
- package/dist/cjs/transformer/decode.js +19 -67
- package/dist/cjs/transformer/encode.js +35 -15
- 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 +3 -6
- package/dist/cjs/transformer/section-category.js +8 -35
- package/dist/es/jats/importer/jats-body-dom-parser.js +7 -19
- package/dist/es/jats/jats-exporter.js +5 -10
- package/dist/es/lib/utils.js +11 -7
- package/dist/es/schema/index.js +3 -7
- package/dist/es/schema/nodes/affiliations_section.js +1 -1
- package/dist/es/schema/nodes/contributors_section.js +1 -1
- package/dist/es/schema/nodes/graphical_abstract_section.js +1 -0
- package/dist/es/schema/nodes/keywords_section.js +1 -1
- package/dist/es/schema/nodes/manuscript.js +1 -1
- package/dist/es/transformer/decode.js +20 -68
- package/dist/es/transformer/encode.js +36 -16
- 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 +3 -6
- package/dist/es/transformer/section-category.js +7 -33
- package/dist/types/lib/utils.d.ts +2 -1
- package/dist/types/schema/types.d.ts +1 -1
- package/dist/types/transformer/decode.d.ts +0 -3
- package/dist/types/transformer/encode.d.ts +1 -1
- package/dist/types/transformer/section-category.d.ts +0 -1
- package/package.json +1 -1
- package/dist/cjs/schema/nodes/core_section.js +0 -27
- package/dist/es/schema/nodes/core_section.js +0 -24
- package/dist/types/schema/nodes/core_section.d.ts +0 -25
|
@@ -507,7 +507,7 @@ const nodes = [
|
|
|
507
507
|
},
|
|
508
508
|
{
|
|
509
509
|
tag: 'sec[sec-type="affiliations"]',
|
|
510
|
-
node: '
|
|
510
|
+
node: 'affiliations_section',
|
|
511
511
|
getAttrs: (node) => {
|
|
512
512
|
const element = node;
|
|
513
513
|
return {
|
|
@@ -519,7 +519,7 @@ const nodes = [
|
|
|
519
519
|
{
|
|
520
520
|
tag: 'aff',
|
|
521
521
|
node: 'affiliation',
|
|
522
|
-
context: '
|
|
522
|
+
context: 'affiliations_section/',
|
|
523
523
|
getAttrs: (node) => {
|
|
524
524
|
const element = node;
|
|
525
525
|
const aff = {
|
|
@@ -566,7 +566,7 @@ const nodes = [
|
|
|
566
566
|
},
|
|
567
567
|
{
|
|
568
568
|
tag: 'sec[sec-type="contributors"]',
|
|
569
|
-
node: '
|
|
569
|
+
node: 'contributors_section',
|
|
570
570
|
getAttrs: (node) => {
|
|
571
571
|
const element = node;
|
|
572
572
|
return {
|
|
@@ -578,7 +578,7 @@ const nodes = [
|
|
|
578
578
|
{
|
|
579
579
|
tag: 'contrib',
|
|
580
580
|
node: 'contributor',
|
|
581
|
-
context: '
|
|
581
|
+
context: 'contributors_section/',
|
|
582
582
|
getAttrs: (node) => {
|
|
583
583
|
const element = node;
|
|
584
584
|
const contrib = {
|
|
@@ -633,7 +633,7 @@ const nodes = [
|
|
|
633
633
|
},
|
|
634
634
|
{
|
|
635
635
|
tag: 'sec[sec-type="keywords"]',
|
|
636
|
-
node: '
|
|
636
|
+
node: 'keywords_section',
|
|
637
637
|
getAttrs: (node) => {
|
|
638
638
|
const element = node;
|
|
639
639
|
return {
|
|
@@ -644,21 +644,9 @@ const nodes = [
|
|
|
644
644
|
},
|
|
645
645
|
{
|
|
646
646
|
tag: 'kwd-group-list',
|
|
647
|
-
context: '
|
|
647
|
+
context: 'keywords_section/',
|
|
648
648
|
node: 'keywords_element',
|
|
649
649
|
},
|
|
650
|
-
{
|
|
651
|
-
tag: 'sec[sec-type="abstracts"]',
|
|
652
|
-
node: 'abstracts',
|
|
653
|
-
},
|
|
654
|
-
{
|
|
655
|
-
tag: 'sec[sec-type="body"]',
|
|
656
|
-
node: 'body',
|
|
657
|
-
},
|
|
658
|
-
{
|
|
659
|
-
tag: 'sec[sec-type="backmatter"]',
|
|
660
|
-
node: 'backmatter',
|
|
661
|
-
},
|
|
662
650
|
{
|
|
663
651
|
tag: 'sec',
|
|
664
652
|
node: 'section',
|
|
@@ -738,7 +726,7 @@ const nodes = [
|
|
|
738
726
|
{
|
|
739
727
|
tag: 'title',
|
|
740
728
|
node: 'section_title',
|
|
741
|
-
context: 'section/|footnotes_section/|bibliography_section/|
|
|
729
|
+
context: 'section/|footnotes_section/|bibliography_section/|keywords_section/',
|
|
742
730
|
},
|
|
743
731
|
{
|
|
744
732
|
tag: 'title',
|
|
@@ -430,11 +430,9 @@ class JATSExporter {
|
|
|
430
430
|
}
|
|
431
431
|
};
|
|
432
432
|
this.buildBody = (fragment) => {
|
|
433
|
+
const content = this.serializeFragment(fragment);
|
|
433
434
|
const body = this.document.createElement('body');
|
|
434
|
-
|
|
435
|
-
const serializedNode = this.serializeNode(cFragment);
|
|
436
|
-
body.append(...serializedNode.childNodes);
|
|
437
|
-
});
|
|
435
|
+
body.appendChild(content);
|
|
438
436
|
this.fixBody(body, fragment);
|
|
439
437
|
return body;
|
|
440
438
|
};
|
|
@@ -600,8 +598,8 @@ class JATSExporter {
|
|
|
600
598
|
this.createSerializer = () => {
|
|
601
599
|
const getModel = (id) => id ? this.modelMap.get(id) : undefined;
|
|
602
600
|
const nodes = {
|
|
603
|
-
|
|
604
|
-
|
|
601
|
+
affiliations_section: () => '',
|
|
602
|
+
contributors_section: () => '',
|
|
605
603
|
table_element_footer: () => ['table-wrap-foot', 0],
|
|
606
604
|
contributor: () => '',
|
|
607
605
|
affiliation: () => '',
|
|
@@ -611,9 +609,6 @@ class JATSExporter {
|
|
|
611
609
|
bibliography_item: () => '',
|
|
612
610
|
comment_list: () => '',
|
|
613
611
|
keywords_group: () => '',
|
|
614
|
-
body: () => ['body', 0],
|
|
615
|
-
abstracts: () => ['abstract', 0],
|
|
616
|
-
backmatter: () => ['backmatter', 0],
|
|
617
612
|
bibliography_section: (node) => [
|
|
618
613
|
'ref-list',
|
|
619
614
|
{ id: normalizeID(node.attrs.id) },
|
|
@@ -792,7 +787,7 @@ class JATSExporter {
|
|
|
792
787
|
},
|
|
793
788
|
keyword: () => '',
|
|
794
789
|
keywords_element: () => '',
|
|
795
|
-
|
|
790
|
+
keywords_section: () => '',
|
|
796
791
|
link: (node) => {
|
|
797
792
|
const text = node.textContent;
|
|
798
793
|
if (!text) {
|
package/dist/cjs/lib/utils.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.
|
|
18
|
+
exports.modelsEqual = exports.getTrimmedTextContent = exports.findParentNodeClosestToPos = exports.isInAbstractsSection = exports.isInBibliographySection = exports.isInGraphicalAbstractSection = exports.findNodePositions = exports.iterateChildren = void 0;
|
|
19
19
|
const bibliography_section_1 = require("../schema/nodes/bibliography_section");
|
|
20
20
|
const graphical_abstract_section_1 = require("../schema/nodes/graphical_abstract_section");
|
|
21
21
|
function* iterateChildren(node, recurse = false) {
|
|
@@ -94,12 +94,16 @@ const getTrimmedTextContent = (node, querySelector) => {
|
|
|
94
94
|
return (_b = (_a = node.querySelector(querySelector)) === null || _a === void 0 ? void 0 : _a.textContent) === null || _b === void 0 ? void 0 : _b.trim();
|
|
95
95
|
};
|
|
96
96
|
exports.getTrimmedTextContent = getTrimmedTextContent;
|
|
97
|
-
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
97
|
+
function modelsEqual(model, model2) {
|
|
98
|
+
for (const v in model) {
|
|
99
|
+
for (const v2 in model2) {
|
|
100
|
+
const prepV = typeof v == 'object' ? JSON.stringify(v) : v;
|
|
101
|
+
const prepV2 = typeof v2 == 'object' ? JSON.stringify(v2) : v2;
|
|
102
|
+
if (prepV !== prepV2) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
101
106
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
exports.groupBy = groupBy;
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
109
|
+
exports.modelsEqual = modelsEqual;
|
package/dist/cjs/schema/index.js
CHANGED
|
@@ -46,7 +46,6 @@ const comment_1 = require("./nodes/comment");
|
|
|
46
46
|
const comment_list_1 = require("./nodes/comment_list");
|
|
47
47
|
const contributor_1 = require("./nodes/contributor");
|
|
48
48
|
const contributors_section_1 = require("./nodes/contributors_section");
|
|
49
|
-
const core_section_1 = require("./nodes/core_section");
|
|
50
49
|
const cross_reference_1 = require("./nodes/cross_reference");
|
|
51
50
|
const doc_1 = require("./nodes/doc");
|
|
52
51
|
const equation_1 = require("./nodes/equation");
|
|
@@ -169,9 +168,6 @@ exports.schema = new prosemirror_model_1.Schema({
|
|
|
169
168
|
caption: caption_1.caption,
|
|
170
169
|
caption_title: caption_title_1.captionTitle,
|
|
171
170
|
citation: citation_1.citation,
|
|
172
|
-
abstracts: core_section_1.coreSection,
|
|
173
|
-
body: core_section_1.coreSection,
|
|
174
|
-
backmatter: core_section_1.coreSection,
|
|
175
171
|
cross_reference: cross_reference_1.crossReference,
|
|
176
172
|
doc: doc_1.doc,
|
|
177
173
|
equation: equation_1.equation,
|
|
@@ -189,7 +185,7 @@ exports.schema = new prosemirror_model_1.Schema({
|
|
|
189
185
|
inline_footnote: inline_footnote_1.inlineFootnote,
|
|
190
186
|
keyword: keyword_1.keyword,
|
|
191
187
|
keywords_element: keywords_element_1.keywordsElement,
|
|
192
|
-
|
|
188
|
+
keywords_section: keywords_section_1.keywordsSection,
|
|
193
189
|
keywords_group: keywords_group_1.keywordsGroup,
|
|
194
190
|
link: link_1.link,
|
|
195
191
|
list_item: list_1.listItem,
|
|
@@ -220,7 +216,7 @@ exports.schema = new prosemirror_model_1.Schema({
|
|
|
220
216
|
meta_section: meta_section_1.metaSection,
|
|
221
217
|
contributor: contributor_1.contributor,
|
|
222
218
|
table_element_footer: table_element_footer_1.tableElementFooter,
|
|
223
|
-
|
|
224
|
-
|
|
219
|
+
affiliations_section: affiliations_section_1.affiliationsSection,
|
|
220
|
+
contributors_section: contributors_section_1.contributorsSection,
|
|
225
221
|
},
|
|
226
222
|
});
|
|
@@ -11,5 +11,5 @@ exports.affiliationsSection = {
|
|
|
11
11
|
selectable: false,
|
|
12
12
|
toDOM: () => ['section', 0],
|
|
13
13
|
};
|
|
14
|
-
const isAffiliationsSectionNode = (node) => node.type === node.type.schema.nodes.
|
|
14
|
+
const isAffiliationsSectionNode = (node) => node.type === node.type.schema.nodes.affiliations_section;
|
|
15
15
|
exports.isAffiliationsSectionNode = isAffiliationsSectionNode;
|
|
@@ -11,5 +11,5 @@ exports.contributorsSection = {
|
|
|
11
11
|
selectable: false,
|
|
12
12
|
toDOM: () => ['section', 0],
|
|
13
13
|
};
|
|
14
|
-
const isContributorsSectionNode = (node) => node.type === node.type.schema.nodes.
|
|
14
|
+
const isContributorsSectionNode = (node) => node.type === node.type.schema.nodes.contributors_section;
|
|
15
15
|
exports.isContributorsSectionNode = isContributorsSectionNode;
|
|
@@ -43,5 +43,5 @@ exports.keywordsSection = {
|
|
|
43
43
|
];
|
|
44
44
|
},
|
|
45
45
|
};
|
|
46
|
-
const isKeywordsSectionNode = (node) => node.type === node.type.schema.nodes.
|
|
46
|
+
const isKeywordsSectionNode = (node) => node.type === node.type.schema.nodes.keywords_section;
|
|
47
47
|
exports.isKeywordsSectionNode = isKeywordsSectionNode;
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.manuscript = void 0;
|
|
19
19
|
exports.manuscript = {
|
|
20
|
-
content: '
|
|
20
|
+
content: '(section | sections)+ meta_section',
|
|
21
21
|
attrs: {
|
|
22
22
|
id: { default: '' },
|
|
23
23
|
},
|
|
@@ -34,7 +34,6 @@ 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");
|
|
38
37
|
const schema_1 = require("../schema");
|
|
39
38
|
const highlight_markers_1 = require("./highlight-markers");
|
|
40
39
|
const id_1 = require("./id");
|
|
@@ -63,7 +62,6 @@ exports.sortSectionsByPriority = sortSectionsByPriority;
|
|
|
63
62
|
const getSections = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.Section).sort(exports.sortSectionsByPriority);
|
|
64
63
|
const getAffiliations = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.Affiliation);
|
|
65
64
|
const getContributors = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.Contributor);
|
|
66
|
-
const getKeywordElements = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.KeywordsElement);
|
|
67
65
|
const isManuscriptNode = (model) => model !== null;
|
|
68
66
|
exports.isManuscriptNode = isManuscriptNode;
|
|
69
67
|
const isParagraphElement = (0, object_types_1.hasObjectType)(json_schema_1.ObjectTypes.ParagraphElement);
|
|
@@ -88,13 +86,10 @@ class Decoder {
|
|
|
88
86
|
]);
|
|
89
87
|
}
|
|
90
88
|
handleMissingRootSectionNodes(rootSectionNodes) {
|
|
91
|
-
if (!rootSectionNodes.find((node) => node.type.name === '
|
|
92
|
-
this.createKeywordsSectionNode(rootSectionNodes);
|
|
93
|
-
}
|
|
94
|
-
if (!rootSectionNodes.find((node) => node.type.name === 'affiliations')) {
|
|
89
|
+
if (!rootSectionNodes.find((node) => node.type.name === 'affiliations_section')) {
|
|
95
90
|
this.createAffiliationSectionNode(rootSectionNodes);
|
|
96
91
|
}
|
|
97
|
-
if (!rootSectionNodes.find((node) => node.type.name === '
|
|
92
|
+
if (!rootSectionNodes.find((node) => node.type.name === 'contributors_section')) {
|
|
98
93
|
this.createContributorSectionNode(rootSectionNodes);
|
|
99
94
|
}
|
|
100
95
|
}
|
|
@@ -102,79 +97,37 @@ class Decoder {
|
|
|
102
97
|
const affiliationNodes = getAffiliations(this.modelMap)
|
|
103
98
|
.map((affiliation) => this.decode(affiliation))
|
|
104
99
|
.filter(Boolean);
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
100
|
+
if (affiliationNodes.length) {
|
|
101
|
+
const node = schema_1.schema.nodes.affiliations_section.createAndFill({
|
|
102
|
+
id: (0, id_1.generateNodeID)(schema_1.schema.nodes.section),
|
|
103
|
+
}, affiliationNodes);
|
|
104
|
+
rootSectionNodes.unshift(node);
|
|
105
|
+
}
|
|
109
106
|
}
|
|
110
107
|
createContributorSectionNode(rootSectionNodes) {
|
|
111
108
|
const contributorNodes = getContributors(this.modelMap)
|
|
112
109
|
.map((contributor) => this.decode(contributor))
|
|
113
110
|
.filter(Boolean);
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}, contributorNodes);
|
|
117
|
-
rootSectionNodes.unshift(node);
|
|
118
|
-
}
|
|
119
|
-
createKeywordsSectionNode(rootSectionNodes) {
|
|
120
|
-
const keywordElementNodes = getKeywordElements(this.modelMap)
|
|
121
|
-
.map((keywordEl) => this.decode(keywordEl))
|
|
122
|
-
.filter(Boolean);
|
|
123
|
-
if (keywordElementNodes) {
|
|
124
|
-
const node = schema_1.schema.nodes.keywords.createAndFill({
|
|
111
|
+
if (contributorNodes.length) {
|
|
112
|
+
const node = schema_1.schema.nodes.contributors_section.createAndFill({
|
|
125
113
|
id: (0, id_1.generateNodeID)(schema_1.schema.nodes.section),
|
|
126
|
-
},
|
|
127
|
-
schema_1.schema.nodes.section_title.create({}, schema_1.schema.text('Keywords')),
|
|
128
|
-
...keywordElementNodes,
|
|
129
|
-
]);
|
|
114
|
+
}, contributorNodes);
|
|
130
115
|
rootSectionNodes.unshift(node);
|
|
131
116
|
}
|
|
132
117
|
}
|
|
133
118
|
createRootSectionNodes() {
|
|
134
|
-
let rootSections = getSections(this.modelMap)
|
|
135
|
-
.filter((section) => !section.path || section.path.length <= 1)
|
|
136
|
-
.filter((section) => section.category !== 'MPSectionCategory:contributors' &&
|
|
137
|
-
section.category !== 'MPSectionCategory:affiliations' &&
|
|
138
|
-
section.category !== 'MPSectionCategory:keywords');
|
|
119
|
+
let rootSections = getSections(this.modelMap).filter((section) => !section.path || section.path.length <= 1);
|
|
139
120
|
rootSections = this.addGeneratedLabels(rootSections);
|
|
140
|
-
const
|
|
141
|
-
var _a;
|
|
142
|
-
return (0, section_category_1.chooseCoreSectionBySection)((_a = sec.category) !== null && _a !== void 0 ? _a : '');
|
|
143
|
-
});
|
|
144
|
-
this.ensureCoreSectionsExist(sectionGroups);
|
|
145
|
-
const absSectionNode = sectionGroups['MPSectionCategory:abstracts']
|
|
146
|
-
.map(this.decode)
|
|
147
|
-
.filter(exports.isManuscriptNode);
|
|
148
|
-
const bodySectionNodes = sectionGroups['MPSectionCategory:body']
|
|
121
|
+
const rootSectionNodes = rootSections
|
|
149
122
|
.map(this.decode)
|
|
150
123
|
.filter(exports.isManuscriptNode);
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
.
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
const backmatterCoreSectionNodes = this.createAndFill(schema_1.schema.nodes.backmatter, backmatterSectionNodes);
|
|
157
|
-
return [
|
|
158
|
-
abstractCoreSectionNodes,
|
|
159
|
-
bodyCoreSectionNodes,
|
|
160
|
-
backmatterCoreSectionNodes,
|
|
161
|
-
];
|
|
162
|
-
}
|
|
163
|
-
ensureCoreSectionsExist(coreSections) {
|
|
164
|
-
if (!coreSections['MPSectionCategory:abstracts']) {
|
|
165
|
-
coreSections['MPSectionCategory:abstracts'] = [];
|
|
166
|
-
}
|
|
167
|
-
if (!coreSections['MPSectionCategory:body']) {
|
|
168
|
-
coreSections['MPSectionCategory:body'] = [];
|
|
169
|
-
}
|
|
170
|
-
if (!coreSections['MPSectionCategory:backmatter']) {
|
|
171
|
-
coreSections['MPSectionCategory:backmatter'] = [];
|
|
124
|
+
this.handleMissingRootSectionNodes(rootSectionNodes);
|
|
125
|
+
if (!rootSectionNodes.length) {
|
|
126
|
+
rootSectionNodes.push(schema_1.schema.nodes.section.createAndFill({
|
|
127
|
+
id: (0, id_1.generateNodeID)(schema_1.schema.nodes.section),
|
|
128
|
+
}));
|
|
172
129
|
}
|
|
173
|
-
|
|
174
|
-
createAndFill(nodeType, content) {
|
|
175
|
-
return nodeType.createAndFill({
|
|
176
|
-
id: (0, id_1.generateNodeID)(nodeType),
|
|
177
|
-
}, content);
|
|
130
|
+
return rootSectionNodes;
|
|
178
131
|
}
|
|
179
132
|
createCommentsNode(model) {
|
|
180
133
|
const comments = [];
|
|
@@ -679,7 +632,6 @@ class Decoder {
|
|
|
679
632
|
this.getModel = (id) => this.modelMap.get(id);
|
|
680
633
|
this.createArticleNode = (manuscriptID) => {
|
|
681
634
|
const rootSectionNodes = this.createRootSectionNodes();
|
|
682
|
-
this.handleMissingRootSectionNodes(rootSectionNodes);
|
|
683
635
|
const metaSectionNode = this.createMetaSectionNode();
|
|
684
636
|
const contents = [...rootSectionNodes, metaSectionNode];
|
|
685
637
|
return schema_1.schema.nodes.manuscript.create({
|
|
@@ -25,6 +25,7 @@ const utils_1 = require("../lib/utils");
|
|
|
25
25
|
const schema_1 = require("../schema");
|
|
26
26
|
const builders_1 = require("./builders");
|
|
27
27
|
const highlight_markers_1 = require("./highlight-markers");
|
|
28
|
+
const id_1 = require("./id");
|
|
28
29
|
const node_types_1 = require("./node-types");
|
|
29
30
|
const section_category_1 = require("./section-category");
|
|
30
31
|
const serializer = prosemirror_model_1.DOMSerializer.fromSchema(schema_1.schema);
|
|
@@ -425,6 +426,31 @@ const encoders = {
|
|
|
425
426
|
keywords_group: (node) => ({
|
|
426
427
|
type: node.attrs.type,
|
|
427
428
|
}),
|
|
429
|
+
keywords_section: (node, parent, path, priority) => ({
|
|
430
|
+
category: (0, section_category_1.buildSectionCategory)(node),
|
|
431
|
+
priority: priority.value++,
|
|
432
|
+
title: inlineContentsOfNodeType(node, node.type.schema.nodes.section_title),
|
|
433
|
+
path: path.concat([node.attrs.id]),
|
|
434
|
+
elementIDs: childElements(node)
|
|
435
|
+
.map((childNode) => childNode.attrs.id)
|
|
436
|
+
.filter((id) => id),
|
|
437
|
+
}),
|
|
438
|
+
affiliations_section: (node, parent, path, priority) => ({
|
|
439
|
+
category: (0, section_category_1.buildSectionCategory)(node),
|
|
440
|
+
priority: priority.value++,
|
|
441
|
+
path: path.concat([node.attrs.id]),
|
|
442
|
+
elementIDs: childElements(node)
|
|
443
|
+
.map((childNode) => childNode.attrs.id)
|
|
444
|
+
.filter((id) => id),
|
|
445
|
+
}),
|
|
446
|
+
contributors_section: (node, parent, path, priority) => ({
|
|
447
|
+
category: (0, section_category_1.buildSectionCategory)(node),
|
|
448
|
+
priority: priority.value++,
|
|
449
|
+
path: path.concat([node.attrs.id]),
|
|
450
|
+
elementIDs: childElements(node)
|
|
451
|
+
.map((childNode) => childNode.attrs.id)
|
|
452
|
+
.filter((id) => id),
|
|
453
|
+
}),
|
|
428
454
|
missing_figure: (node) => ({
|
|
429
455
|
position: node.attrs.position || undefined,
|
|
430
456
|
}),
|
|
@@ -545,25 +571,13 @@ const modelFromNode = (node, parent, path, priority) => {
|
|
|
545
571
|
return { model, commentAnnotationsMap };
|
|
546
572
|
};
|
|
547
573
|
exports.modelFromNode = modelFromNode;
|
|
548
|
-
|
|
549
|
-
return (child.type === schema_1.schema.nodes.abstracts ||
|
|
550
|
-
child.type === schema_1.schema.nodes.body ||
|
|
551
|
-
child.type === schema_1.schema.nodes.backmatter ||
|
|
552
|
-
child.type === schema_1.schema.nodes.affiliations ||
|
|
553
|
-
child.type === schema_1.schema.nodes.contributors ||
|
|
554
|
-
child.type === schema_1.schema.nodes.keywords);
|
|
555
|
-
}
|
|
556
|
-
const encode = (node) => {
|
|
574
|
+
const encode = (node, preserveWithRepeatedID = false) => {
|
|
557
575
|
const models = new Map();
|
|
558
576
|
const priority = {
|
|
559
577
|
value: 1,
|
|
560
578
|
};
|
|
561
579
|
const placeholders = ['placeholder', 'placeholder_element'];
|
|
562
580
|
const addModel = (path, parent) => (child) => {
|
|
563
|
-
if (isCoreSection(child)) {
|
|
564
|
-
child.forEach(addModel([], child));
|
|
565
|
-
return;
|
|
566
|
-
}
|
|
567
581
|
if (!child.attrs.id) {
|
|
568
582
|
return;
|
|
569
583
|
}
|
|
@@ -577,8 +591,14 @@ const encode = (node) => {
|
|
|
577
591
|
return;
|
|
578
592
|
}
|
|
579
593
|
const { model } = (0, exports.modelFromNode)(child, parent, path, priority);
|
|
580
|
-
|
|
581
|
-
|
|
594
|
+
const existingModel = models.get(model._id);
|
|
595
|
+
if (existingModel) {
|
|
596
|
+
if (preserveWithRepeatedID && !(0, utils_1.modelsEqual)(model, existingModel)) {
|
|
597
|
+
model._id = (0, id_1.generateID)(model.objectType);
|
|
598
|
+
}
|
|
599
|
+
else {
|
|
600
|
+
throw Error(`Encountered duplicate ids in models map while encoding: ${model._id}`);
|
|
601
|
+
}
|
|
582
602
|
}
|
|
583
603
|
models.set(model._id, model);
|
|
584
604
|
child.forEach(addModel(path.concat(child.attrs.id), child));
|
|
@@ -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, 'Section'],
|
|
42
42
|
[schema_1.schema.nodes.toc_section, 'Section'],
|
|
43
43
|
]);
|
|
@@ -48,7 +48,7 @@ const nodeTitle = (node) => {
|
|
|
48
48
|
case nodes.section:
|
|
49
49
|
case nodes.bibliography_section:
|
|
50
50
|
case nodes.footnotes_section:
|
|
51
|
-
case nodes.
|
|
51
|
+
case nodes.keywords_section:
|
|
52
52
|
case nodes.toc_section:
|
|
53
53
|
case nodes.graphical_abstract_section:
|
|
54
54
|
return snippetOfNodeType(node, nodes.section_title);
|
|
@@ -19,9 +19,6 @@ 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],
|
|
25
22
|
[schema_1.schema.nodes.comment, json_schema_1.ObjectTypes.CommentAnnotation],
|
|
26
23
|
[schema_1.schema.nodes.bibliography_item, json_schema_1.ObjectTypes.BibliographyItem],
|
|
27
24
|
[schema_1.schema.nodes.bibliography_element, json_schema_1.ObjectTypes.BibliographyElement],
|
|
@@ -43,7 +40,7 @@ exports.nodeTypesMap = new Map([
|
|
|
43
40
|
[schema_1.schema.nodes.inline_equation, json_schema_1.ObjectTypes.InlineMathFragment],
|
|
44
41
|
[schema_1.schema.nodes.keyword, json_schema_1.ObjectTypes.Keyword],
|
|
45
42
|
[schema_1.schema.nodes.keywords_element, json_schema_1.ObjectTypes.KeywordsElement],
|
|
46
|
-
[schema_1.schema.nodes.
|
|
43
|
+
[schema_1.schema.nodes.keywords_section, json_schema_1.ObjectTypes.Section],
|
|
47
44
|
[schema_1.schema.nodes.keywords_group, json_schema_1.ObjectTypes.KeywordGroup],
|
|
48
45
|
[schema_1.schema.nodes.listing, json_schema_1.ObjectTypes.Listing],
|
|
49
46
|
[schema_1.schema.nodes.listing_element, json_schema_1.ObjectTypes.ListingElement],
|
|
@@ -60,8 +57,8 @@ exports.nodeTypesMap = new Map([
|
|
|
60
57
|
[schema_1.schema.nodes.affiliation, json_schema_1.ObjectTypes.Affiliation],
|
|
61
58
|
[schema_1.schema.nodes.contributor, json_schema_1.ObjectTypes.Contributor],
|
|
62
59
|
[schema_1.schema.nodes.table_element_footer, json_schema_1.ObjectTypes.TableElementFooter],
|
|
63
|
-
[schema_1.schema.nodes.
|
|
64
|
-
[schema_1.schema.nodes.
|
|
60
|
+
[schema_1.schema.nodes.contributors_section, json_schema_1.ObjectTypes.Section],
|
|
61
|
+
[schema_1.schema.nodes.affiliations_section, json_schema_1.ObjectTypes.Section],
|
|
65
62
|
]);
|
|
66
63
|
const isExecutableNodeType = (type) => (0, schema_1.hasGroup)(type, schema_1.GROUP_EXECUTABLE);
|
|
67
64
|
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.
|
|
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;
|
|
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_section,
|
|
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_section;
|
|
49
49
|
case 'MPSectionCategory:affiliations':
|
|
50
|
-
return schema_1.schema.nodes.
|
|
50
|
+
return schema_1.schema.nodes.affiliations_section;
|
|
51
51
|
case 'MPSectionCategory:contributors':
|
|
52
|
-
return schema_1.schema.nodes.
|
|
52
|
+
return schema_1.schema.nodes.contributors_section;
|
|
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_section:
|
|
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_section:
|
|
100
100
|
return 'MPSectionCategory:affiliations';
|
|
101
|
-
case schema_1.schema.nodes.
|
|
101
|
+
case schema_1.schema.nodes.contributors_section:
|
|
102
102
|
return 'MPSectionCategory:contributors';
|
|
103
103
|
default:
|
|
104
104
|
return node.attrs.category || undefined;
|
|
@@ -128,33 +128,6 @@ 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;
|
|
158
131
|
const chooseSectionCategoryByType = (secType) => {
|
|
159
132
|
switch (secType) {
|
|
160
133
|
case 'abstract':
|