@manuscripts/transform 1.4.6 → 1.5.0-LEAN-2852-9
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 +126 -0
- package/dist/cjs/jats/importer/jats-body-transformations.js +59 -0
- package/dist/cjs/jats/importer/jats-front-parser.js +7 -7
- package/dist/cjs/jats/importer/jats-parser-utils.js +4 -0
- package/dist/cjs/jats/importer/parse-jats-article.js +18 -7
- package/dist/cjs/jats/jats-exporter.js +10 -8
- package/dist/cjs/lib/core-section-categories.js +2 -2
- package/dist/cjs/schema/index.js +9 -6
- package/dist/cjs/schema/nodes/affiliation.js +3 -0
- package/dist/cjs/schema/nodes/affiliations_section.js +15 -0
- package/dist/cjs/schema/nodes/contributor.js +8 -1
- package/dist/cjs/schema/nodes/contributors_section.js +15 -0
- package/dist/cjs/schema/nodes/meta_section.js +1 -1
- package/dist/cjs/schema/nodes/titles.js +32 -0
- package/dist/cjs/transformer/builders.js +1 -2
- package/dist/cjs/transformer/decode.js +74 -23
- package/dist/cjs/transformer/encode.js +26 -0
- package/dist/cjs/transformer/html.js +6 -5
- package/dist/cjs/transformer/node-types.js +3 -0
- package/dist/cjs/transformer/project-bundle.js +22 -1
- package/dist/cjs/transformer/section-category.js +12 -0
- package/dist/es/jats/importer/jats-body-dom-parser.js +126 -0
- package/dist/es/jats/importer/jats-body-transformations.js +59 -0
- package/dist/es/jats/importer/jats-front-parser.js +1 -1
- package/dist/es/jats/importer/jats-parser-utils.js +4 -0
- package/dist/es/jats/importer/parse-jats-article.js +18 -7
- package/dist/es/jats/jats-exporter.js +11 -9
- package/dist/es/lib/core-section-categories.js +2 -2
- package/dist/es/schema/index.js +9 -6
- package/dist/es/schema/nodes/affiliation.js +3 -0
- package/dist/es/schema/nodes/affiliations_section.js +11 -0
- package/dist/es/schema/nodes/contributor.js +6 -0
- package/dist/es/schema/nodes/contributors_section.js +11 -0
- package/dist/es/schema/nodes/meta_section.js +1 -1
- package/dist/es/schema/nodes/titles.js +29 -0
- package/dist/es/transformer/builders.js +1 -2
- package/dist/es/transformer/decode.js +74 -23
- package/dist/es/transformer/encode.js +26 -0
- package/dist/es/transformer/html.js +7 -6
- package/dist/es/transformer/node-types.js +3 -0
- package/dist/es/transformer/project-bundle.js +20 -0
- package/dist/es/transformer/section-category.js +12 -0
- package/dist/types/jats/importer/jats-body-transformations.d.ts +4 -1
- package/dist/types/jats/importer/jats-front-parser.d.ts +5 -5
- package/dist/types/jats/importer/parse-jats-article.d.ts +5 -2
- package/dist/types/schema/index.d.ts +3 -2
- package/dist/types/schema/nodes/affiliation.d.ts +1 -0
- package/dist/types/schema/nodes/affiliations_section.d.ts +11 -0
- package/dist/types/schema/nodes/contributor.d.ts +2 -0
- package/dist/types/schema/nodes/contributors_section.d.ts +11 -0
- package/dist/types/schema/nodes/titles.d.ts +28 -0
- package/dist/types/schema/types.d.ts +1 -1
- package/dist/types/transformer/builders.d.ts +1 -1
- package/dist/types/transformer/decode.d.ts +4 -2
- package/dist/types/transformer/project-bundle.d.ts +2 -1
- package/dist/types/transformer/section-category.d.ts +2 -2
- package/package.json +3 -3
- package/dist/cjs/schema/nodes/affiliation_list.js +0 -10
- package/dist/cjs/schema/nodes/contributor_list.js +0 -10
- package/dist/es/schema/nodes/affiliation_list.js +0 -7
- package/dist/es/schema/nodes/contributor_list.js +0 -7
- package/dist/types/schema/nodes/affiliation_list.d.ts +0 -10
- package/dist/types/schema/nodes/contributor_list.d.ts +0 -10
|
@@ -25,7 +25,7 @@ import { generateAttachmentFilename } from '../transformer/filename';
|
|
|
25
25
|
import { buildTargets } from '../transformer/labels';
|
|
26
26
|
import { isExecutableNodeType, isNodeType } from '../transformer/node-types';
|
|
27
27
|
import { hasObjectType } from '../transformer/object-types';
|
|
28
|
-
import { findManuscript, findManuscriptById, } from '../transformer/project-bundle';
|
|
28
|
+
import { findManuscript, findManuscriptById, findTitles, } from '../transformer/project-bundle';
|
|
29
29
|
import { chooseJatsFnType, chooseSecType, } from '../transformer/section-category';
|
|
30
30
|
import { selectVersionIds } from './jats-versions';
|
|
31
31
|
const warn = debug('manuscripts-transform');
|
|
@@ -231,6 +231,7 @@ export class JATSExporter {
|
|
|
231
231
|
this.buildFront = (doi, id, links) => {
|
|
232
232
|
var _a, _b, _c, _d;
|
|
233
233
|
const manuscript = findManuscript(this.modelMap);
|
|
234
|
+
const titles = findTitles(this.modelMap);
|
|
234
235
|
const front = this.document.createElement('front');
|
|
235
236
|
const journalMeta = this.document.createElement('journal-meta');
|
|
236
237
|
front.appendChild(journalMeta);
|
|
@@ -308,20 +309,20 @@ export class JATSExporter {
|
|
|
308
309
|
articleMeta.appendChild(link);
|
|
309
310
|
}
|
|
310
311
|
}
|
|
311
|
-
if (
|
|
312
|
+
if (titles.title) {
|
|
312
313
|
const element = this.document.createElement('article-title');
|
|
313
|
-
this.setTitleContent(element,
|
|
314
|
+
this.setTitleContent(element, titles.title);
|
|
314
315
|
titleGroup.appendChild(element);
|
|
315
316
|
}
|
|
316
|
-
if (
|
|
317
|
+
if (titles.subtitle) {
|
|
317
318
|
const element = this.document.createElement('subtitle');
|
|
318
|
-
this.setTitleContent(element,
|
|
319
|
+
this.setTitleContent(element, titles.subtitle);
|
|
319
320
|
titleGroup.appendChild(element);
|
|
320
321
|
}
|
|
321
|
-
if (
|
|
322
|
+
if (titles.runningTitle) {
|
|
322
323
|
const element = this.document.createElement('alt-title');
|
|
323
324
|
element.setAttribute('alt-title-type', 'right-running');
|
|
324
|
-
this.setTitleContent(element,
|
|
325
|
+
this.setTitleContent(element, titles.runningTitle);
|
|
325
326
|
titleGroup.appendChild(element);
|
|
326
327
|
}
|
|
327
328
|
const supplements = [...this.modelMap.values()].filter((model) => model.objectType === ObjectTypes.Supplement);
|
|
@@ -591,10 +592,11 @@ export class JATSExporter {
|
|
|
591
592
|
this.createSerializer = () => {
|
|
592
593
|
const getModel = (id) => id ? this.modelMap.get(id) : undefined;
|
|
593
594
|
const nodes = {
|
|
595
|
+
titles: () => '',
|
|
596
|
+
affiliations_section: () => '',
|
|
597
|
+
contributors_section: () => '',
|
|
594
598
|
table_element_footer: () => ['table-wrap-foot', 0],
|
|
595
|
-
contributor_list: () => '',
|
|
596
599
|
contributor: () => '',
|
|
597
|
-
affiliation_list: () => '',
|
|
598
600
|
affiliation: () => '',
|
|
599
601
|
meta_section: () => '',
|
|
600
602
|
attribution: () => ['attrib', 0],
|
|
@@ -13,7 +13,7 @@ export const coreSectionCategories = [
|
|
|
13
13
|
desc: 'Backmatter section for grouping',
|
|
14
14
|
objectType: 'MPSectionCategory',
|
|
15
15
|
titles: [],
|
|
16
|
-
priority:
|
|
16
|
+
priority: 180,
|
|
17
17
|
},
|
|
18
18
|
{
|
|
19
19
|
_id: 'MPSectionCategory:body',
|
|
@@ -21,6 +21,6 @@ export const coreSectionCategories = [
|
|
|
21
21
|
desc: 'Body section for grouping',
|
|
22
22
|
objectType: 'MPSectionCategory',
|
|
23
23
|
titles: [],
|
|
24
|
-
priority:
|
|
24
|
+
priority: 200,
|
|
25
25
|
},
|
|
26
26
|
];
|
package/dist/es/schema/index.js
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
import { Schema } from 'prosemirror-model';
|
|
17
17
|
import { bold, code, italic, smallcaps, strikethrough, styled, subscript, superscript, tracked_delete, tracked_insert, underline, } from './marks';
|
|
18
18
|
import { affiliation } from './nodes/affiliation';
|
|
19
|
-
import {
|
|
19
|
+
import { affiliationsSection } from './nodes/affiliations_section';
|
|
20
20
|
import { attribution } from './nodes/attribution';
|
|
21
21
|
import { bibliographyElement } from './nodes/bibliography_element';
|
|
22
22
|
import { bibliographyItem } from './nodes/bibliography_item';
|
|
@@ -28,7 +28,7 @@ import { citation } from './nodes/citation';
|
|
|
28
28
|
import { comment } from './nodes/comment';
|
|
29
29
|
import { commentList } from './nodes/comment_list';
|
|
30
30
|
import { contributor } from './nodes/contributor';
|
|
31
|
-
import {
|
|
31
|
+
import { contributorsSection } from './nodes/contributors_section';
|
|
32
32
|
import { crossReference } from './nodes/cross_reference';
|
|
33
33
|
import { doc } from './nodes/doc';
|
|
34
34
|
import { equation } from './nodes/equation';
|
|
@@ -68,6 +68,7 @@ import { tableElement } from './nodes/table_element';
|
|
|
68
68
|
import { tableElementFooter } from './nodes/table_element_footer';
|
|
69
69
|
import { tableCell, tableRow } from './nodes/table_row';
|
|
70
70
|
import { text } from './nodes/text';
|
|
71
|
+
import { Titles } from './nodes/titles';
|
|
71
72
|
import { tocElement } from './nodes/toc_element';
|
|
72
73
|
import { tocSection } from './nodes/toc_section';
|
|
73
74
|
export * from './groups';
|
|
@@ -120,11 +121,12 @@ export * from './nodes/text';
|
|
|
120
121
|
export * from './nodes/toc_element';
|
|
121
122
|
export * from './nodes/toc_section';
|
|
122
123
|
export * from './nodes/affiliation';
|
|
123
|
-
export * from './nodes/affiliation_list';
|
|
124
124
|
export * from './nodes/meta_section';
|
|
125
|
-
export * from './nodes/contributor_list';
|
|
126
125
|
export * from './nodes/contributor';
|
|
127
126
|
export * from './nodes/table_element_footer';
|
|
127
|
+
export * from './nodes/titles';
|
|
128
|
+
export * from './nodes/affiliations_section';
|
|
129
|
+
export * from './nodes/contributors_section';
|
|
128
130
|
export const schema = new Schema({
|
|
129
131
|
marks: {
|
|
130
132
|
bold,
|
|
@@ -197,9 +199,10 @@ export const schema = new Schema({
|
|
|
197
199
|
toc_section: tocSection,
|
|
198
200
|
affiliation,
|
|
199
201
|
meta_section: metaSection,
|
|
200
|
-
affiliation_list: affiliationList,
|
|
201
|
-
contributor_list: contributorList,
|
|
202
202
|
contributor: contributor,
|
|
203
203
|
table_element_footer: tableElementFooter,
|
|
204
|
+
titles: Titles,
|
|
205
|
+
affiliations_section: affiliationsSection,
|
|
206
|
+
contributors_section: contributorsSection,
|
|
204
207
|
},
|
|
205
208
|
});
|
|
@@ -8,6 +8,7 @@ export const affiliation = {
|
|
|
8
8
|
addressLine3: { default: '' },
|
|
9
9
|
postCode: { default: '' },
|
|
10
10
|
country: { default: '' },
|
|
11
|
+
priority: { default: undefined },
|
|
11
12
|
email: {
|
|
12
13
|
default: {
|
|
13
14
|
href: undefined,
|
|
@@ -15,5 +16,7 @@ export const affiliation = {
|
|
|
15
16
|
},
|
|
16
17
|
},
|
|
17
18
|
},
|
|
19
|
+
group: 'block element',
|
|
20
|
+
toDOM: () => ['span'],
|
|
18
21
|
};
|
|
19
22
|
export const isAffiliationNode = (node) => node.type === node.type.schema.nodes.affiliation;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const affiliationsSection = {
|
|
2
|
+
content: 'section_title? affiliation*',
|
|
3
|
+
attrs: {
|
|
4
|
+
id: { default: '' },
|
|
5
|
+
dataTracked: { default: null },
|
|
6
|
+
},
|
|
7
|
+
group: 'block sections',
|
|
8
|
+
selectable: false,
|
|
9
|
+
toDOM: () => ['section', 0],
|
|
10
|
+
};
|
|
11
|
+
export const isAffiliationsSectionNode = (node) => node.type === node.type.schema.nodes.affiliations_section;
|
|
@@ -3,10 +3,16 @@ export const contributor = {
|
|
|
3
3
|
id: { default: '' },
|
|
4
4
|
role: { default: '' },
|
|
5
5
|
affiliations: { default: [] },
|
|
6
|
+
footnote: { default: undefined },
|
|
7
|
+
corresp: { default: undefined },
|
|
6
8
|
bibliographicName: { default: {} },
|
|
7
9
|
userID: { default: undefined },
|
|
8
10
|
invitationID: { default: undefined },
|
|
9
11
|
isCorresponding: { default: undefined },
|
|
10
12
|
ORCIDIdentifier: { default: undefined },
|
|
13
|
+
priority: { default: undefined },
|
|
11
14
|
},
|
|
15
|
+
group: 'block element',
|
|
16
|
+
toDOM: () => ['span'],
|
|
12
17
|
};
|
|
18
|
+
export const isContributorNode = (node) => node.type === node.type.schema.nodes.contributor;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const contributorsSection = {
|
|
2
|
+
content: 'section_title? contributor*',
|
|
3
|
+
attrs: {
|
|
4
|
+
id: { default: '' },
|
|
5
|
+
dataTracked: { default: null },
|
|
6
|
+
},
|
|
7
|
+
group: 'block sections',
|
|
8
|
+
selectable: false,
|
|
9
|
+
toDOM: () => ['section', 0],
|
|
10
|
+
};
|
|
11
|
+
export const isContributorsSectionNode = (node) => node.type === node.type.schema.nodes.contributors_section;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* © 2019 Atypon Systems LLC
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export const Titles = {
|
|
17
|
+
content: 'text*',
|
|
18
|
+
marks: 'italic smallcaps subscript superscript',
|
|
19
|
+
attrs: {
|
|
20
|
+
id: { default: '' },
|
|
21
|
+
title: { default: '' },
|
|
22
|
+
subtitle: { default: '' },
|
|
23
|
+
runningTitle: { default: '' },
|
|
24
|
+
dataTracked: { default: null },
|
|
25
|
+
},
|
|
26
|
+
group: 'block element',
|
|
27
|
+
parseDOM: [{ tag: 'div' }],
|
|
28
|
+
toDOM: () => ['div', 0],
|
|
29
|
+
};
|
|
@@ -28,10 +28,9 @@ export const buildProject = (owner) => ({
|
|
|
28
28
|
viewers: [],
|
|
29
29
|
title: '',
|
|
30
30
|
});
|
|
31
|
-
export const buildManuscript = (
|
|
31
|
+
export const buildManuscript = () => ({
|
|
32
32
|
_id: generateID(ObjectTypes.Manuscript),
|
|
33
33
|
objectType: ObjectTypes.Manuscript,
|
|
34
|
-
title,
|
|
35
34
|
});
|
|
36
35
|
export const buildContributor = (bibliographicName, role = 'author', priority = 0, userID, invitationID) => ({
|
|
37
36
|
_id: generateID(ObjectTypes.Contributor),
|
|
@@ -57,29 +57,16 @@ export const isManuscriptNode = (model) => model !== null;
|
|
|
57
57
|
const isParagraphElement = hasObjectType(ObjectTypes.ParagraphElement);
|
|
58
58
|
const isFootnote = hasObjectType(ObjectTypes.Footnote);
|
|
59
59
|
const isKeyword = hasObjectType(ObjectTypes.Keyword);
|
|
60
|
+
const isKeywordsSection = (model) => model.category === 'MPSectionCategory:keywords';
|
|
61
|
+
const isAffiliationsSection = (model) => model.category === 'MPSectionCategory:affiliations';
|
|
62
|
+
const isContributorsSection = (model) => model.category === 'MPSectionCategory:contributors';
|
|
60
63
|
const hasParentSection = (id) => (section) => section.path &&
|
|
61
64
|
section.path.length > 1 &&
|
|
62
65
|
section.path[section.path.length - 2] === id;
|
|
63
66
|
export class Decoder {
|
|
64
|
-
createAffiliationListNode() {
|
|
65
|
-
const affiliationNodes = getAffiliations(this.modelMap)
|
|
66
|
-
.map((affiliation) => this.decode(affiliation))
|
|
67
|
-
.filter(Boolean);
|
|
68
|
-
return schema.nodes.affiliation_list.createAndFill({}, affiliationNodes);
|
|
69
|
-
}
|
|
70
|
-
createContributorListNode() {
|
|
71
|
-
const contributorNodes = getContributors(this.modelMap)
|
|
72
|
-
.map((contributor) => this.decode(contributor))
|
|
73
|
-
.filter(Boolean);
|
|
74
|
-
return schema.nodes.contributor_list.createAndFill({}, contributorNodes);
|
|
75
|
-
}
|
|
76
67
|
createMetaSectionNode() {
|
|
77
|
-
const affiliationListNode = this.createAffiliationListNode();
|
|
78
|
-
const contributorListNode = this.createContributorListNode();
|
|
79
68
|
const commentListNode = this.createCommentListNode();
|
|
80
69
|
return schema.nodes.meta_section.createAndFill({}, [
|
|
81
|
-
affiliationListNode,
|
|
82
|
-
contributorListNode,
|
|
83
70
|
commentListNode,
|
|
84
71
|
]);
|
|
85
72
|
}
|
|
@@ -88,12 +75,53 @@ export class Decoder {
|
|
|
88
75
|
...this.comments.values(),
|
|
89
76
|
]);
|
|
90
77
|
}
|
|
78
|
+
handleMissingRootSectionNodes(rootSectionNodes) {
|
|
79
|
+
if (!rootSectionNodes.find((node) => node.type.name === 'affiliations_section')) {
|
|
80
|
+
this.createAffiliationSectionNode(rootSectionNodes);
|
|
81
|
+
}
|
|
82
|
+
if (!rootSectionNodes.find((node) => node.type.name === 'contributors_section')) {
|
|
83
|
+
this.createContributorSectionNode(rootSectionNodes);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
createAffiliationSectionNode(rootSectionNodes) {
|
|
87
|
+
const affiliationNodes = getAffiliations(this.modelMap)
|
|
88
|
+
.map((affiliation) => this.decode(affiliation))
|
|
89
|
+
.filter(Boolean);
|
|
90
|
+
if (affiliationNodes.length) {
|
|
91
|
+
const node = schema.nodes.affiliations_section.createAndFill({
|
|
92
|
+
id: generateNodeID(schema.nodes.section),
|
|
93
|
+
}, affiliationNodes);
|
|
94
|
+
rootSectionNodes.unshift(node);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
createContributorSectionNode(rootSectionNodes) {
|
|
98
|
+
const contributorNodes = getContributors(this.modelMap)
|
|
99
|
+
.map((contributor) => this.decode(contributor))
|
|
100
|
+
.filter(Boolean);
|
|
101
|
+
if (contributorNodes.length) {
|
|
102
|
+
const node = schema.nodes.contributors_section.createAndFill({
|
|
103
|
+
id: generateNodeID(schema.nodes.section),
|
|
104
|
+
}, contributorNodes);
|
|
105
|
+
rootSectionNodes.unshift(node);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
createTitlesNode() {
|
|
109
|
+
const titlesModel = getModelsByType(this.modelMap, ObjectTypes.Titles)[0];
|
|
110
|
+
if (titlesModel) {
|
|
111
|
+
const titlesNode = this.decode(titlesModel);
|
|
112
|
+
return titlesNode;
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
91
118
|
createRootSectionNodes() {
|
|
92
119
|
let rootSections = getSections(this.modelMap).filter((section) => !section.path || section.path.length <= 1);
|
|
93
120
|
rootSections = this.addGeneratedLabels(rootSections);
|
|
94
121
|
const rootSectionNodes = rootSections
|
|
95
122
|
.map(this.decode)
|
|
96
123
|
.filter(isManuscriptNode);
|
|
124
|
+
this.handleMissingRootSectionNodes(rootSectionNodes);
|
|
97
125
|
if (!rootSectionNodes.length) {
|
|
98
126
|
rootSectionNodes.push(schema.nodes.section.createAndFill({
|
|
99
127
|
id: generateNodeID(schema.nodes.section),
|
|
@@ -119,6 +147,15 @@ export class Decoder {
|
|
|
119
147
|
constructor(modelMap, allowMissingElements = false) {
|
|
120
148
|
this.comments = new Map();
|
|
121
149
|
this.creators = {
|
|
150
|
+
[ObjectTypes.Titles]: (data) => {
|
|
151
|
+
const model = data;
|
|
152
|
+
return schema.nodes.titles.create({
|
|
153
|
+
id: model._id,
|
|
154
|
+
title: model.title,
|
|
155
|
+
subtitle: model.subtitle,
|
|
156
|
+
runningTitle: model.runningTitle,
|
|
157
|
+
});
|
|
158
|
+
},
|
|
122
159
|
[ObjectTypes.BibliographyElement]: (data) => {
|
|
123
160
|
var _a;
|
|
124
161
|
const model = data;
|
|
@@ -426,13 +463,12 @@ export class Decoder {
|
|
|
426
463
|
},
|
|
427
464
|
[ObjectTypes.Section]: (data) => {
|
|
428
465
|
const model = data;
|
|
429
|
-
const isKeywordsSection = model.category === 'MPSectionCategory:keywords';
|
|
430
466
|
const elements = [];
|
|
431
467
|
if (model.elementIDs) {
|
|
432
468
|
for (const id of model.elementIDs) {
|
|
433
469
|
const element = this.getModel(id);
|
|
434
470
|
if (element) {
|
|
435
|
-
if (isKeywordsSection && isParagraphElement(element)) {
|
|
471
|
+
if (isKeywordsSection(model) && isParagraphElement(element)) {
|
|
436
472
|
continue;
|
|
437
473
|
}
|
|
438
474
|
elements.push(element);
|
|
@@ -475,11 +511,17 @@ export class Decoder {
|
|
|
475
511
|
const sectionNodeType = chooseSectionNodeType(sectionCategory);
|
|
476
512
|
const commentNodes = this.createCommentsNode(model);
|
|
477
513
|
commentNodes.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
514
|
+
let content;
|
|
515
|
+
if (isAffiliationsSection(model) || isContributorsSection(model)) {
|
|
516
|
+
content = elementNodes.concat(nestedSections);
|
|
517
|
+
}
|
|
518
|
+
else {
|
|
519
|
+
content = (sectionLabelNode
|
|
520
|
+
? [sectionLabelNode, sectionTitleNode]
|
|
521
|
+
: [sectionTitleNode])
|
|
522
|
+
.concat(elementNodes)
|
|
523
|
+
.concat(nestedSections);
|
|
524
|
+
}
|
|
483
525
|
const sectionNode = sectionNodeType.createAndFill({
|
|
484
526
|
id: model._id,
|
|
485
527
|
category: sectionCategory,
|
|
@@ -568,6 +610,8 @@ export class Decoder {
|
|
|
568
610
|
postCode: model.postCode,
|
|
569
611
|
country: model.country,
|
|
570
612
|
email: model.email,
|
|
613
|
+
department: model.department,
|
|
614
|
+
priority: model.priority,
|
|
571
615
|
});
|
|
572
616
|
},
|
|
573
617
|
[ObjectTypes.Contributor]: (data) => {
|
|
@@ -581,6 +625,9 @@ export class Decoder {
|
|
|
581
625
|
invitationID: model.invitationID,
|
|
582
626
|
isCorresponding: model.isCorresponding,
|
|
583
627
|
ORCIDIdentifier: model.ORCIDIdentifier,
|
|
628
|
+
footnote: model.footnote,
|
|
629
|
+
corresp: model.corresp,
|
|
630
|
+
priority: model.priority,
|
|
584
631
|
});
|
|
585
632
|
},
|
|
586
633
|
};
|
|
@@ -593,9 +640,13 @@ export class Decoder {
|
|
|
593
640
|
};
|
|
594
641
|
this.getModel = (id) => this.modelMap.get(id);
|
|
595
642
|
this.createArticleNode = (manuscriptID) => {
|
|
643
|
+
const titlesNode = this.createTitlesNode();
|
|
596
644
|
const rootSectionNodes = this.createRootSectionNodes();
|
|
597
645
|
const metaSectionNode = this.createMetaSectionNode();
|
|
598
646
|
const contents = [...rootSectionNodes, metaSectionNode];
|
|
647
|
+
if (titlesNode) {
|
|
648
|
+
contents.push(titlesNode);
|
|
649
|
+
}
|
|
599
650
|
return schema.nodes.manuscript.create({
|
|
600
651
|
id: manuscriptID || this.getManuscriptID(),
|
|
601
652
|
}, contents);
|
|
@@ -255,6 +255,12 @@ function figureElementEncoder(node) {
|
|
|
255
255
|
};
|
|
256
256
|
}
|
|
257
257
|
const encoders = {
|
|
258
|
+
titles: (node) => ({
|
|
259
|
+
title: node.attrs.title,
|
|
260
|
+
subtitle: node.attrs.subtitle,
|
|
261
|
+
runningTitle: node.attrs.runningTitle,
|
|
262
|
+
_id: node.attrs._id,
|
|
263
|
+
}),
|
|
258
264
|
bibliography_element: (node) => ({
|
|
259
265
|
elementType: 'div',
|
|
260
266
|
contents: '',
|
|
@@ -426,6 +432,22 @@ const encoders = {
|
|
|
426
432
|
.map((childNode) => childNode.attrs.id)
|
|
427
433
|
.filter((id) => id),
|
|
428
434
|
}),
|
|
435
|
+
affiliations_section: (node, parent, path, priority) => ({
|
|
436
|
+
category: buildSectionCategory(node),
|
|
437
|
+
priority: priority.value++,
|
|
438
|
+
path: path.concat([node.attrs.id]),
|
|
439
|
+
elementIDs: childElements(node)
|
|
440
|
+
.map((childNode) => childNode.attrs.id)
|
|
441
|
+
.filter((id) => id),
|
|
442
|
+
}),
|
|
443
|
+
contributors_section: (node, parent, path, priority) => ({
|
|
444
|
+
category: 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
|
+
}),
|
|
429
451
|
missing_figure: (node) => ({
|
|
430
452
|
position: node.attrs.position || undefined,
|
|
431
453
|
}),
|
|
@@ -506,6 +528,7 @@ const encoders = {
|
|
|
506
528
|
postCode: node.attrs.postCode,
|
|
507
529
|
country: node.attrs.country,
|
|
508
530
|
email: node.attrs.email,
|
|
531
|
+
priority: node.attrs.priority,
|
|
509
532
|
}),
|
|
510
533
|
contributor: (node) => ({
|
|
511
534
|
role: node.attrs.role,
|
|
@@ -515,6 +538,9 @@ const encoders = {
|
|
|
515
538
|
invitationID: node.attrs.invitationID,
|
|
516
539
|
isCorresponding: node.attrs.isCorresponding,
|
|
517
540
|
ORCIDIdentifier: node.attrs.ORCIDIdentifier,
|
|
541
|
+
footnote: node.attrs.footnote,
|
|
542
|
+
corresp: node.attrs.corresp,
|
|
543
|
+
priority: node.attrs.priority,
|
|
518
544
|
}),
|
|
519
545
|
};
|
|
520
546
|
const modelData = (node, parent, path, priority) => {
|
|
@@ -23,7 +23,7 @@ import { generateAttachmentFilename } from './filename';
|
|
|
23
23
|
import { buildTargets } from './labels';
|
|
24
24
|
import { isNodeType } from './node-types';
|
|
25
25
|
import { hasObjectType } from './object-types';
|
|
26
|
-
import { findJournal, findManuscript } from './project-bundle';
|
|
26
|
+
import { findJournal, findManuscript, findTitles } from './project-bundle';
|
|
27
27
|
import { chooseSecType } from './section-category';
|
|
28
28
|
const chooseNodeName = (element) => {
|
|
29
29
|
const nodeName = element.nodeName.toLowerCase();
|
|
@@ -146,6 +146,7 @@ export class HTMLTransformer {
|
|
|
146
146
|
this.buildFront = () => {
|
|
147
147
|
const manuscript = findManuscript(this.modelMap);
|
|
148
148
|
const journal = findJournal(this.modelMap);
|
|
149
|
+
const titles = findTitles(this.modelMap);
|
|
149
150
|
if (!manuscript) {
|
|
150
151
|
throw new Error('Manuscript not found in project modelMap');
|
|
151
152
|
}
|
|
@@ -164,14 +165,14 @@ export class HTMLTransformer {
|
|
|
164
165
|
}
|
|
165
166
|
const articleMeta = this.document.createElement('div');
|
|
166
167
|
front.appendChild(articleMeta);
|
|
167
|
-
const
|
|
168
|
-
if (
|
|
169
|
-
|
|
168
|
+
const title = this.document.createElement('h1');
|
|
169
|
+
if (titles.title) {
|
|
170
|
+
title.innerHTML = titles.title;
|
|
170
171
|
}
|
|
171
172
|
if (journal === null || journal === void 0 ? void 0 : journal.title) {
|
|
172
|
-
|
|
173
|
+
title.setAttribute('data-journal', journal.title);
|
|
173
174
|
}
|
|
174
|
-
articleMeta.appendChild(
|
|
175
|
+
articleMeta.appendChild(title);
|
|
175
176
|
if (manuscript.DOI) {
|
|
176
177
|
const articleID = this.document.createElement('article-id');
|
|
177
178
|
articleID.setAttribute('pub-id-type', 'doi');
|
|
@@ -54,6 +54,9 @@ export const nodeTypesMap = new Map([
|
|
|
54
54
|
[schema.nodes.affiliation, ObjectTypes.Affiliation],
|
|
55
55
|
[schema.nodes.contributor, ObjectTypes.Contributor],
|
|
56
56
|
[schema.nodes.table_element_footer, ObjectTypes.TableElementFooter],
|
|
57
|
+
[schema.nodes.titles, ObjectTypes.Titles],
|
|
58
|
+
[schema.nodes.contributors_section, ObjectTypes.Section],
|
|
59
|
+
[schema.nodes.affiliations_section, ObjectTypes.Section],
|
|
57
60
|
]);
|
|
58
61
|
export const isExecutableNodeType = (type) => hasGroup(type, GROUP_EXECUTABLE);
|
|
59
62
|
export const isElementNodeType = (type) => hasGroup(type, GROUP_ELEMENT);
|
|
@@ -63,3 +63,23 @@ export const findManuscriptById = (modelMap, manuscriptID) => {
|
|
|
63
63
|
}
|
|
64
64
|
throw new Error(`There is no manuscript found for the following _id (${manuscriptID})`);
|
|
65
65
|
};
|
|
66
|
+
const isTitle = hasObjectType(ObjectTypes.Titles);
|
|
67
|
+
export const findTitles = (modelMap) => {
|
|
68
|
+
for (const model of modelMap.values()) {
|
|
69
|
+
if (isTitle(model)) {
|
|
70
|
+
return model;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
const defaultTitle = {
|
|
74
|
+
_id: 'MPTitles:8EB79C14-9F61-483A-902F-A0B8EF5973C1',
|
|
75
|
+
createdAt: 1538472121.690101,
|
|
76
|
+
updatedAt: 1538472121.690101,
|
|
77
|
+
objectType: 'MPTitles',
|
|
78
|
+
title: 'main title',
|
|
79
|
+
subtitle: 'subtitle',
|
|
80
|
+
runningTitle: 'running title',
|
|
81
|
+
manuscriptID: 'MPManuscript:E3830344-E77B-42BA-BD77-3E95489712A0',
|
|
82
|
+
containerID: 'MPProject:1',
|
|
83
|
+
};
|
|
84
|
+
return defaultTitle;
|
|
85
|
+
};
|
|
@@ -41,6 +41,10 @@ export const chooseSectionNodeType = (category) => {
|
|
|
41
41
|
return schema.nodes.footnotes_section;
|
|
42
42
|
case 'MPSectionCategory:keywords':
|
|
43
43
|
return schema.nodes.keywords_section;
|
|
44
|
+
case 'MPSectionCategory:affiliations':
|
|
45
|
+
return schema.nodes.affiliations_section;
|
|
46
|
+
case 'MPSectionCategory:contributors':
|
|
47
|
+
return schema.nodes.contributors_section;
|
|
44
48
|
case 'MPSectionCategory:toc':
|
|
45
49
|
return schema.nodes.toc_section;
|
|
46
50
|
default:
|
|
@@ -84,6 +88,10 @@ export const buildSectionCategory = (node) => {
|
|
|
84
88
|
return 'MPSectionCategory:toc';
|
|
85
89
|
case schema.nodes.graphical_abstract_section:
|
|
86
90
|
return 'MPSectionCategory:abstract-graphical';
|
|
91
|
+
case schema.nodes.affiliations_section:
|
|
92
|
+
return 'MPSectionCategory:affiliations';
|
|
93
|
+
case schema.nodes.contributors_section:
|
|
94
|
+
return 'MPSectionCategory:contributors';
|
|
87
95
|
default:
|
|
88
96
|
return node.attrs.category || undefined;
|
|
89
97
|
}
|
|
@@ -174,6 +182,10 @@ export const chooseSectionCategoryByType = (secType) => {
|
|
|
174
182
|
return 'MPSectionCategory:backmatter';
|
|
175
183
|
case 'abstracts':
|
|
176
184
|
return 'MPSectionCategory:abstracts';
|
|
185
|
+
case 'affiliations':
|
|
186
|
+
return 'MPSectionCategory:affiliations';
|
|
187
|
+
case 'contributors':
|
|
188
|
+
return 'MPSectionCategory:contributors';
|
|
177
189
|
default:
|
|
178
190
|
return undefined;
|
|
179
191
|
}
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { BibliographyItem } from '@manuscripts/json-schema';
|
|
16
|
+
import { Affiliation, BibliographyItem, Contributor } from '@manuscripts/json-schema';
|
|
17
|
+
import { Build } from '../../transformer';
|
|
17
18
|
export declare const jatsBodyTransformations: {
|
|
18
19
|
ensureSection(body: Element, createElement: (tagName: string) => HTMLElement): void;
|
|
19
20
|
createAbstract(abstractNode: Element, createElement: (tagName: string) => HTMLElement): HTMLElement;
|
|
@@ -32,6 +33,8 @@ export declare const jatsBodyTransformations: {
|
|
|
32
33
|
mapFootnotesToSections(doc: Document, backmatterContainer: Element, createElement: (tagName: string) => HTMLElement): void;
|
|
33
34
|
moveCaptionsToEnd(body: Element): void;
|
|
34
35
|
moveTableFooterToEnd(body: Element): void;
|
|
36
|
+
moveAffiliationsToBody(doc: Document, affiliations: Build<Affiliation>[] | undefined, body: Element, createElement: (tagName: string) => HTMLElement): void;
|
|
37
|
+
moveAuthorsToBody(doc: Document, authors: Build<Contributor>[] | undefined, body: Element, createElement: (tagName: string) => HTMLElement): void;
|
|
35
38
|
moveFloatsGroupToBody(doc: Document, body: Element, createElement: (tagName: string) => HTMLElement): void;
|
|
36
39
|
moveBlockNodesFromParagraph(doc: Document, body: Element, createElement: (tagName: string) => HTMLElement): void;
|
|
37
40
|
moveKeywordsToBody(document: Document, body: Element, createElement: (tagName: string) => HTMLElement): void;
|
|
@@ -35,18 +35,18 @@ export declare const jatsFrontParser: {
|
|
|
35
35
|
revisionReceiveDate?: number | undefined;
|
|
36
36
|
receiveDate?: number | undefined;
|
|
37
37
|
} | undefined;
|
|
38
|
-
parseSupplements(supplementNodes: Element[] | null): import("../../transformer
|
|
38
|
+
parseSupplements(supplementNodes: Element[] | null): import("../../transformer").Build<import("@manuscripts/json-schema").Supplement>[];
|
|
39
39
|
parseAffiliationNodes(affiliationNodes: Element[]): {
|
|
40
|
-
affiliations: import("../../transformer
|
|
40
|
+
affiliations: import("../../transformer").Build<import("@manuscripts/json-schema").Affiliation>[];
|
|
41
41
|
affiliationIDs: Map<string, string>;
|
|
42
42
|
};
|
|
43
43
|
parseFootnoteNodes(footnoteNodes: Element[]): {
|
|
44
|
-
footnotes: import("../../transformer
|
|
44
|
+
footnotes: import("../../transformer").Build<import("@manuscripts/json-schema").Footnote>[];
|
|
45
45
|
footnoteIDs: Map<string, string>;
|
|
46
46
|
};
|
|
47
47
|
parseCorrespNodes(correspNodes: Element[]): {
|
|
48
|
-
correspondingList: import("../../transformer
|
|
48
|
+
correspondingList: import("../../transformer").Build<import("@manuscripts/json-schema").Corresponding>[];
|
|
49
49
|
correspondingIDs: Map<string, string>;
|
|
50
50
|
};
|
|
51
|
-
parseAuthorNodes(authorNodes: Element[], affiliationIDs: Map<string, string>, footnoteIDs: Map<string, string>, correspondingIDs: Map<string, string>): import("../../transformer
|
|
51
|
+
parseAuthorNodes(authorNodes: Element[], affiliationIDs: Map<string, string>, footnoteIDs: Map<string, string>, correspondingIDs: Map<string, string>): import("../../transformer").Build<import("@manuscripts/json-schema").Contributor>[];
|
|
52
52
|
};
|
|
@@ -13,10 +13,13 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { BibliographyItem, ElementsOrder, FootnotesOrder, Model } from '@manuscripts/json-schema';
|
|
16
|
+
import { Affiliation, BibliographyItem, Contributor, ElementsOrder, FootnotesOrder, Model } from '@manuscripts/json-schema';
|
|
17
17
|
import { ManuscriptNode } from '../../schema';
|
|
18
|
+
import { Build } from '../../transformer/builders';
|
|
18
19
|
export declare const parseJATSFront: (front: Element) => Promise<{
|
|
19
20
|
models: Model[];
|
|
21
|
+
authors: Build<Contributor>[];
|
|
22
|
+
affiliations: Build<Affiliation>[];
|
|
20
23
|
}>;
|
|
21
24
|
export declare const parseJATSReferences: (back: Element | null, body: Element | null, createElement: (tagName: string) => HTMLElement) => {
|
|
22
25
|
references: Model[];
|
|
@@ -24,6 +27,6 @@ export declare const parseJATSReferences: (back: Element | null, body: Element |
|
|
|
24
27
|
referenceQueriesMap: Map<string, string[]> | undefined;
|
|
25
28
|
referenceIdsMap: Map<string, string> | undefined;
|
|
26
29
|
};
|
|
27
|
-
export declare const parseJATSBody: (document: Document, body: Element, bibliographyItems: BibliographyItem[] | null, refModels: Model[], referenceIdsMap: Map<string, string> | undefined, footnotesOrder?: FootnotesOrder) => ManuscriptNode;
|
|
30
|
+
export declare const parseJATSBody: (document: Document, body: Element, bibliographyItems: BibliographyItem[] | null, authors: Build<Contributor>[], affiliations: Build<Affiliation>[], refModels: Model[], referenceIdsMap: Map<string, string> | undefined, footnotesOrder?: FootnotesOrder) => ManuscriptNode;
|
|
28
31
|
export declare const parseJATSArticle: (doc: Document) => Promise<Model[]>;
|
|
29
32
|
export declare const getElementsOrder: (node: ManuscriptNode) => ElementsOrder[];
|
|
@@ -65,9 +65,10 @@ export * from './nodes/text';
|
|
|
65
65
|
export * from './nodes/toc_element';
|
|
66
66
|
export * from './nodes/toc_section';
|
|
67
67
|
export * from './nodes/affiliation';
|
|
68
|
-
export * from './nodes/affiliation_list';
|
|
69
68
|
export * from './nodes/meta_section';
|
|
70
|
-
export * from './nodes/contributor_list';
|
|
71
69
|
export * from './nodes/contributor';
|
|
72
70
|
export * from './nodes/table_element_footer';
|
|
71
|
+
export * from './nodes/titles';
|
|
72
|
+
export * from './nodes/affiliations_section';
|
|
73
|
+
export * from './nodes/contributors_section';
|
|
73
74
|
export declare const schema: Schema<Nodes, Marks>;
|