@manuscripts/transform 2.6.0 → 2.6.1-LEAN-3966.1
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/index.js +6 -6
- package/dist/cjs/jats/{jats-exporter.js → exporter/jats-exporter.js} +305 -416
- package/dist/cjs/jats/{jats-versions.js → exporter/jats-versions.js} +1 -3
- package/dist/cjs/{transformer → jats/exporter}/labels.js +4 -4
- package/dist/cjs/{transformer/filename.js → jats/importer/create-article-node.js} +10 -9
- package/dist/cjs/jats/importer/jats-comments.js +32 -111
- package/dist/cjs/jats/importer/{jats-body-dom-parser.js → jats-dom-parser.js} +350 -10
- package/dist/cjs/jats/importer/jats-journal-meta-parser.js +11 -1
- package/dist/cjs/jats/importer/jats-parser-utils.js +76 -9
- package/dist/cjs/jats/importer/jats-transformations.js +397 -0
- package/dist/cjs/jats/importer/parse-jats-article.js +44 -101
- package/dist/cjs/jats/index.js +7 -7
- package/dist/cjs/{transformer/models.js → lib/deafults.js} +3 -1
- package/dist/cjs/lib/utils.js +3 -1
- package/dist/cjs/schema/nodes/highlight_marker.js +0 -4
- package/dist/cjs/transformer/id.js +1 -5
- package/dist/cjs/transformer/index.js +0 -18
- package/dist/cjs/version.js +1 -1
- package/dist/es/index.js +5 -5
- package/dist/es/jats/{jats-exporter.js → exporter/jats-exporter.js} +300 -411
- package/dist/es/jats/{jats-versions.js → exporter/jats-versions.js} +0 -1
- package/dist/es/{transformer → jats/exporter}/labels.js +4 -4
- package/dist/{cjs/transformer/model-map.js → es/jats/importer/create-article-node.js} +8 -10
- package/dist/es/jats/importer/jats-comments.js +32 -107
- package/dist/es/jats/importer/{jats-body-dom-parser.js → jats-dom-parser.js} +350 -10
- package/dist/es/jats/importer/jats-journal-meta-parser.js +9 -0
- package/dist/es/jats/importer/jats-parser-utils.js +78 -11
- package/dist/es/jats/importer/jats-transformations.js +377 -0
- package/dist/es/jats/importer/parse-jats-article.js +44 -99
- package/dist/es/jats/index.js +5 -3
- package/dist/{types/transformer/timestamp.d.ts → es/lib/deafults.js} +2 -2
- package/dist/es/lib/utils.js +1 -0
- package/dist/es/schema/nodes/highlight_marker.js +0 -4
- package/dist/es/transformer/id.js +0 -3
- package/dist/es/transformer/index.js +0 -16
- package/dist/es/version.js +1 -1
- package/dist/types/index.d.ts +6 -6
- package/dist/types/jats/{jats-exporter.d.ts → exporter/jats-exporter.d.ts} +16 -29
- package/dist/types/jats/{jats-versions.d.ts → exporter/jats-versions.d.ts} +0 -1
- package/dist/types/{transformer → jats/exporter}/labels.d.ts +2 -2
- package/dist/{es/transformer/footnote-category.js → types/jats/importer/create-article-node.d.ts} +3 -2
- package/dist/types/jats/importer/jats-comments.d.ts +2 -15
- package/dist/types/jats/importer/{jats-body-dom-parser.d.ts → jats-dom-parser.d.ts} +1 -1
- package/dist/types/jats/importer/jats-journal-meta-parser.d.ts +9 -0
- package/dist/types/jats/importer/jats-parser-utils.d.ts +2 -2
- package/dist/types/jats/importer/jats-transformations.d.ts +33 -0
- package/dist/types/jats/importer/parse-jats-article.d.ts +12 -5
- package/dist/types/jats/index.d.ts +5 -3
- package/dist/types/jats/types.d.ts +1 -0
- package/dist/{es/transformer/models.js → types/lib/deafults.d.ts} +2 -2
- package/dist/types/lib/utils.d.ts +1 -0
- package/dist/types/schema/nodes/bibliography_item.d.ts +3 -3
- package/dist/types/schema/nodes/contributor.d.ts +10 -0
- package/dist/types/schema/nodes/highlight_marker.d.ts +0 -2
- package/dist/types/schema/nodes/keyword_group.d.ts +1 -0
- package/dist/types/schema/nodes/manuscript.d.ts +8 -7
- package/dist/types/schema/nodes/title.d.ts +0 -3
- package/dist/types/transformer/id.d.ts +0 -3
- package/dist/types/transformer/index.d.ts +0 -16
- package/dist/types/version.d.ts +1 -1
- package/package.json +2 -1
- package/dist/cjs/__tests__/data/project-dump.json +0 -825
- package/dist/cjs/jats/importer/index.js +0 -22
- package/dist/cjs/jats/importer/jats-front-parser.js +0 -321
- package/dist/cjs/jats/importer/jats-reference-parser.js +0 -130
- package/dist/cjs/jats/importer/jats-references.js +0 -34
- package/dist/cjs/transformer/__tests__/__helpers__/doc.js +0 -37
- package/dist/cjs/transformer/builders.js +0 -219
- package/dist/cjs/transformer/decode.js +0 -898
- package/dist/cjs/transformer/document-object-types.js +0 -31
- package/dist/cjs/transformer/encode.js +0 -674
- package/dist/cjs/transformer/footnote-category.js +0 -20
- package/dist/cjs/transformer/footnotes-order.js +0 -60
- package/dist/cjs/transformer/highlight-markers.js +0 -138
- package/dist/cjs/transformer/html.js +0 -400
- package/dist/cjs/transformer/manuscript-dependencies.js +0 -21
- package/dist/cjs/transformer/object-types.js +0 -57
- package/dist/cjs/transformer/project-bundle.js +0 -94
- package/dist/cjs/transformer/serializer.js +0 -23
- package/dist/cjs/transformer/timestamp.js +0 -20
- package/dist/cjs/transformer/update-identifiers.js +0 -93
- package/dist/es/__tests__/data/project-dump.json +0 -825
- package/dist/es/jats/importer/index.js +0 -16
- package/dist/es/jats/importer/jats-front-parser.js +0 -315
- package/dist/es/jats/importer/jats-reference-parser.js +0 -127
- package/dist/es/jats/importer/jats-references.js +0 -30
- package/dist/es/transformer/__tests__/__helpers__/doc.js +0 -29
- package/dist/es/transformer/builders.js +0 -186
- package/dist/es/transformer/decode.js +0 -888
- package/dist/es/transformer/document-object-types.js +0 -28
- package/dist/es/transformer/encode.js +0 -664
- package/dist/es/transformer/filename.js +0 -23
- package/dist/es/transformer/footnotes-order.js +0 -55
- package/dist/es/transformer/highlight-markers.js +0 -132
- package/dist/es/transformer/html.js +0 -393
- package/dist/es/transformer/manuscript-dependencies.js +0 -17
- package/dist/es/transformer/model-map.js +0 -22
- package/dist/es/transformer/object-types.js +0 -52
- package/dist/es/transformer/project-bundle.js +0 -85
- package/dist/es/transformer/serializer.js +0 -17
- package/dist/es/transformer/timestamp.js +0 -16
- package/dist/es/transformer/update-identifiers.js +0 -87
- package/dist/types/jats/importer/index.d.ts +0 -16
- package/dist/types/jats/importer/jats-front-parser.d.ts +0 -84
- package/dist/types/jats/importer/jats-reference-parser.d.ts +0 -19
- package/dist/types/jats/importer/jats-references.d.ts +0 -12
- package/dist/types/transformer/__tests__/__helpers__/doc.d.ts +0 -18
- package/dist/types/transformer/builders.d.ts +0 -61
- package/dist/types/transformer/decode.d.ts +0 -52
- package/dist/types/transformer/document-object-types.d.ts +0 -17
- package/dist/types/transformer/encode.d.ts +0 -29
- package/dist/types/transformer/filename.d.ts +0 -16
- package/dist/types/transformer/footnote-category.d.ts +0 -17
- package/dist/types/transformer/footnotes-order.d.ts +0 -22
- package/dist/types/transformer/highlight-markers.d.ts +0 -31
- package/dist/types/transformer/html.d.ts +0 -36
- package/dist/types/transformer/manuscript-dependencies.d.ts +0 -4
- package/dist/types/transformer/model-map.d.ts +0 -19
- package/dist/types/transformer/models.d.ts +0 -48
- package/dist/types/transformer/object-types.d.ts +0 -30
- package/dist/types/transformer/project-bundle.d.ts +0 -30
- package/dist/types/transformer/serializer.d.ts +0 -19
- package/dist/types/transformer/update-identifiers.d.ts +0 -23
- package/dist/types/types.d.ts +0 -2
- /package/dist/cjs/{types.js → jats/types.js} +0 -0
- /package/dist/es/{types.js → jats/types.js} +0 -0
|
@@ -23,44 +23,17 @@ const json_schema_1 = require("@manuscripts/json-schema");
|
|
|
23
23
|
const library_1 = require("@manuscripts/library");
|
|
24
24
|
const debug_1 = __importDefault(require("debug"));
|
|
25
25
|
const prosemirror_model_1 = require("prosemirror-model");
|
|
26
|
+
const prosemirror_utils_1 = require("prosemirror-utils");
|
|
26
27
|
const w3c_xmlserializer_1 = __importDefault(require("w3c-xmlserializer"));
|
|
27
|
-
const html_1 = require("
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const schema_1 = require("../schema");
|
|
31
|
-
const filename_1 = require("../transformer/filename");
|
|
32
|
-
const labels_1 = require("../transformer/labels");
|
|
33
|
-
const node_types_1 = require("../transformer/node-types");
|
|
34
|
-
const object_types_1 = require("../transformer/object-types");
|
|
35
|
-
const project_bundle_1 = require("../transformer/project-bundle");
|
|
36
|
-
const section_category_1 = require("../transformer/section-category");
|
|
28
|
+
const html_1 = require("../../lib/html");
|
|
29
|
+
const schema_1 = require("../../schema");
|
|
30
|
+
const transformer_1 = require("../../transformer");
|
|
37
31
|
const jats_versions_1 = require("./jats-versions");
|
|
32
|
+
const labels_1 = require("./labels");
|
|
38
33
|
const warn = (0, debug_1.default)('manuscripts-transform');
|
|
39
34
|
const XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
|
|
40
35
|
const normalizeID = (id) => id.replace(/:/g, '_');
|
|
41
36
|
const parser = prosemirror_model_1.DOMParser.fromSchema(schema_1.schema);
|
|
42
|
-
const findChildNodeOfType = (node, nodeType) => {
|
|
43
|
-
for (const child of (0, utils_1.iterateChildren)(node)) {
|
|
44
|
-
if (child.type === nodeType) {
|
|
45
|
-
return child;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
const isContributor = (0, object_types_1.hasObjectType)(json_schema_1.ObjectTypes.Contributor);
|
|
50
|
-
const CREDIT_VOCAB_IDENTIFIER = 'https://dictionary.casrai.org/Contributor_Roles';
|
|
51
|
-
const chooseRoleVocabAttributes = (role) => {
|
|
52
|
-
if (role.uri && role.uri.startsWith(CREDIT_VOCAB_IDENTIFIER)) {
|
|
53
|
-
return {
|
|
54
|
-
vocab: 'credit',
|
|
55
|
-
'vocab-identifier': CREDIT_VOCAB_IDENTIFIER,
|
|
56
|
-
'vocab-term': role.name,
|
|
57
|
-
'vocab-term-identifier': role.uri,
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
return {
|
|
61
|
-
vocab: 'uncontrolled',
|
|
62
|
-
};
|
|
63
|
-
};
|
|
64
37
|
const insertAbstractNode = (articleMeta, abstractNode) => {
|
|
65
38
|
const siblings = [
|
|
66
39
|
'kwd-group',
|
|
@@ -98,24 +71,24 @@ const createDefaultIdGenerator = () => {
|
|
|
98
71
|
return `${element.localName}-${value}`;
|
|
99
72
|
};
|
|
100
73
|
};
|
|
101
|
-
const chooseRefType = (
|
|
102
|
-
switch (
|
|
103
|
-
case
|
|
104
|
-
case
|
|
74
|
+
const chooseRefType = (type) => {
|
|
75
|
+
switch (type) {
|
|
76
|
+
case schema_1.schema.nodes.figure:
|
|
77
|
+
case schema_1.schema.nodes.figure_element:
|
|
105
78
|
return 'fig';
|
|
106
|
-
case
|
|
79
|
+
case schema_1.schema.nodes.footnote:
|
|
107
80
|
return 'fn';
|
|
108
|
-
case
|
|
109
|
-
case
|
|
81
|
+
case schema_1.schema.nodes.table:
|
|
82
|
+
case schema_1.schema.nodes.table_element:
|
|
110
83
|
return 'table';
|
|
111
|
-
case
|
|
84
|
+
case schema_1.schema.nodes.section:
|
|
112
85
|
return 'sec';
|
|
113
|
-
case
|
|
114
|
-
case
|
|
86
|
+
case schema_1.schema.nodes.equation:
|
|
87
|
+
case schema_1.schema.nodes.equation_element:
|
|
115
88
|
return 'disp-formula';
|
|
116
89
|
}
|
|
117
90
|
};
|
|
118
|
-
const sortContributors = (a, b) => Number(a.priority) - Number(b.priority);
|
|
91
|
+
const sortContributors = (a, b) => Number(a.attrs.priority) - Number(b.attrs.priority);
|
|
119
92
|
const buildCitations = (citations) => citations.map((citation) => ({
|
|
120
93
|
citationID: citation.attrs.id,
|
|
121
94
|
citationItems: citation.attrs.rids.map((rid) => ({
|
|
@@ -128,39 +101,58 @@ const buildCitations = (citations) => citations.map((citation) => ({
|
|
|
128
101
|
exports.buildCitations = buildCitations;
|
|
129
102
|
class JATSExporter {
|
|
130
103
|
constructor() {
|
|
131
|
-
this.
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
104
|
+
this.getLibraryItem = (manuscriptID) => {
|
|
105
|
+
return (id) => {
|
|
106
|
+
var _a;
|
|
107
|
+
const node = (_a = (0, prosemirror_utils_1.findChildrenByAttr)(this.manuscriptNode, (attrs) => attrs.id === id)[0]) === null || _a === void 0 ? void 0 : _a.node;
|
|
108
|
+
if (!node) {
|
|
109
|
+
return undefined;
|
|
110
|
+
}
|
|
111
|
+
return {
|
|
112
|
+
_id: node.attrs.id,
|
|
113
|
+
issued: node.attrs.issued,
|
|
114
|
+
DOI: node.attrs.doi,
|
|
115
|
+
manuscriptID,
|
|
116
|
+
objectType: json_schema_1.ObjectTypes.BibliographyItem,
|
|
117
|
+
author: node.attrs.author,
|
|
118
|
+
'container-title': node.attrs.containerTitle,
|
|
119
|
+
volume: node.attrs.volume,
|
|
120
|
+
issue: node.attrs.issue,
|
|
121
|
+
supplement: node.attrs.supplement,
|
|
122
|
+
page: node.attrs.page,
|
|
123
|
+
title: node.attrs.title,
|
|
124
|
+
literal: node.attrs.literal,
|
|
125
|
+
type: node.attrs.type,
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
this.serializeToJATS = async (manuscriptNode, options) => {
|
|
130
|
+
var _a;
|
|
131
|
+
this.manuscriptNode = manuscriptNode;
|
|
132
|
+
this.generateCitationTexts(options.csl, manuscriptNode.attrs.id);
|
|
136
133
|
this.createSerializer();
|
|
137
|
-
const versionIds = (0, jats_versions_1.selectVersionIds)(version);
|
|
134
|
+
const versionIds = (0, jats_versions_1.selectVersionIds)((_a = options.version) !== null && _a !== void 0 ? _a : '1.2');
|
|
138
135
|
this.document = document.implementation.createDocument(null, 'article', document.implementation.createDocumentType('article', versionIds.publicId, versionIds.systemId));
|
|
139
136
|
const article = this.document.documentElement;
|
|
140
137
|
article.setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:xlink', XLINK_NAMESPACE);
|
|
141
|
-
const front = this.buildFront(
|
|
138
|
+
const front = this.buildFront(options.journal);
|
|
142
139
|
article.appendChild(front);
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
}
|
|
160
|
-
await this.rewriteIDs(idGenerator);
|
|
161
|
-
if (mediaPathGenerator) {
|
|
162
|
-
await this.rewriteMediaPaths(mediaPathGenerator);
|
|
163
|
-
}
|
|
140
|
+
article.setAttribute('article-type', manuscriptNode.attrs.articleType || 'other');
|
|
141
|
+
this.labelTargets = (0, labels_1.buildTargets)(manuscriptNode);
|
|
142
|
+
const body = this.buildBody();
|
|
143
|
+
article.appendChild(body);
|
|
144
|
+
const back = this.buildBack(body);
|
|
145
|
+
this.moveCoiStatementToAuthorNotes(back, front);
|
|
146
|
+
article.appendChild(back);
|
|
147
|
+
this.unwrapBody(body);
|
|
148
|
+
this.moveAbstracts(front, body);
|
|
149
|
+
this.moveFloatsGroup(body, article);
|
|
150
|
+
this.removeBackContainer(body);
|
|
151
|
+
this.updateFootnoteTypes(front, back);
|
|
152
|
+
this.fillEmptyTableFooters(article);
|
|
153
|
+
this.fillEmptyFootnotes(article);
|
|
154
|
+
this.moveAwards(front, body);
|
|
155
|
+
await this.rewriteIDs();
|
|
164
156
|
return (0, w3c_xmlserializer_1.default)(this.document);
|
|
165
157
|
};
|
|
166
158
|
this.nodeFromJATS = (JATSFragment) => {
|
|
@@ -173,19 +165,6 @@ class JATSExporter {
|
|
|
173
165
|
template.innerHTML = JATSFragment;
|
|
174
166
|
return template.firstChild;
|
|
175
167
|
};
|
|
176
|
-
this.rewriteMediaPaths = async (generator) => {
|
|
177
|
-
const doc = this.document;
|
|
178
|
-
for (const fig of doc.querySelectorAll('fig')) {
|
|
179
|
-
for (const graphic of fig.querySelectorAll('graphic')) {
|
|
180
|
-
const newHref = await generator(graphic, fig.id);
|
|
181
|
-
graphic.setAttributeNS(XLINK_NAMESPACE, 'href', newHref);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
for (const suppl of doc.querySelectorAll('supplementary-material')) {
|
|
185
|
-
const newHref = await generator(suppl, suppl.id);
|
|
186
|
-
suppl.setAttributeNS(XLINK_NAMESPACE, 'href', newHref);
|
|
187
|
-
}
|
|
188
|
-
};
|
|
189
168
|
this.rewriteIDs = async (generator = createDefaultIdGenerator()) => {
|
|
190
169
|
const ids = new Map();
|
|
191
170
|
for (const element of this.document.querySelectorAll('[id]')) {
|
|
@@ -227,16 +206,14 @@ class JATSExporter {
|
|
|
227
206
|
}
|
|
228
207
|
}
|
|
229
208
|
};
|
|
230
|
-
this.buildFront = (
|
|
231
|
-
var _a
|
|
232
|
-
const
|
|
233
|
-
const titles = (0, project_bundle_1.findTitles)(this.modelMap);
|
|
209
|
+
this.buildFront = (journal) => {
|
|
210
|
+
var _a;
|
|
211
|
+
const titleNode = (_a = (0, prosemirror_utils_1.findChildrenByType)(this.manuscriptNode, schema_1.schema.nodes.title)[0]) === null || _a === void 0 ? void 0 : _a.node;
|
|
234
212
|
const front = this.document.createElement('front');
|
|
235
213
|
const journalMeta = this.document.createElement('journal-meta');
|
|
236
214
|
front.appendChild(journalMeta);
|
|
237
215
|
const articleMeta = this.document.createElement('article-meta');
|
|
238
216
|
front.appendChild(articleMeta);
|
|
239
|
-
const journal = [...this.modelMap.values()].find((model) => model.objectType === json_schema_1.ObjectTypes.Journal);
|
|
240
217
|
if (journal) {
|
|
241
218
|
if (journal.journalIdentifiers) {
|
|
242
219
|
for (const item of journal.journalIdentifiers) {
|
|
@@ -285,109 +262,47 @@ class JATSExporter {
|
|
|
285
262
|
journalMeta.appendChild(publisher);
|
|
286
263
|
}
|
|
287
264
|
}
|
|
288
|
-
if (
|
|
289
|
-
const articleID = this.document.createElement('article-id');
|
|
290
|
-
articleID.setAttribute('pub-id-type', 'publisher-id');
|
|
291
|
-
articleID.textContent = id;
|
|
292
|
-
articleMeta.appendChild(articleID);
|
|
293
|
-
}
|
|
294
|
-
if (doi || manuscript.DOI) {
|
|
265
|
+
if (this.manuscriptNode.attrs.doi) {
|
|
295
266
|
const articleID = this.document.createElement('article-id');
|
|
296
267
|
articleID.setAttribute('pub-id-type', 'doi');
|
|
297
|
-
articleID.textContent =
|
|
268
|
+
articleID.textContent = this.manuscriptNode.attrs.doi;
|
|
298
269
|
articleMeta.appendChild(articleID);
|
|
299
270
|
}
|
|
300
271
|
const titleGroup = this.document.createElement('title-group');
|
|
301
272
|
articleMeta.appendChild(titleGroup);
|
|
302
273
|
this.buildContributors(articleMeta);
|
|
303
|
-
if (
|
|
304
|
-
for (const [key, value] of Object.entries(links.self)) {
|
|
305
|
-
const link = this.document.createElement('self-uri');
|
|
306
|
-
link.setAttribute('content-type', key);
|
|
307
|
-
link.setAttributeNS(XLINK_NAMESPACE, 'href', value);
|
|
308
|
-
articleMeta.appendChild(link);
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
if (titles.title) {
|
|
274
|
+
if (titleNode) {
|
|
312
275
|
const element = this.document.createElement('article-title');
|
|
313
|
-
this.setTitleContent(element,
|
|
314
|
-
titleGroup.appendChild(element);
|
|
315
|
-
}
|
|
316
|
-
if (titles.subtitle) {
|
|
317
|
-
const element = this.document.createElement('subtitle');
|
|
318
|
-
this.setTitleContent(element, titles.subtitle);
|
|
319
|
-
titleGroup.appendChild(element);
|
|
320
|
-
}
|
|
321
|
-
if (titles.runningTitle) {
|
|
322
|
-
const element = this.document.createElement('alt-title');
|
|
323
|
-
element.setAttribute('alt-title-type', 'right-running');
|
|
324
|
-
this.setTitleContent(element, titles.runningTitle);
|
|
276
|
+
this.setTitleContent(element, titleNode.textContent);
|
|
325
277
|
titleGroup.appendChild(element);
|
|
326
278
|
}
|
|
327
|
-
const
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
articleMeta.append(supplementaryMaterial);
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
const history = articleMeta.querySelector('history') ||
|
|
346
|
-
this.document.createElement('history');
|
|
347
|
-
if (manuscript.acceptanceDate) {
|
|
348
|
-
const date = this.buildDateElement(manuscript.acceptanceDate, 'accepted');
|
|
349
|
-
history.appendChild(date);
|
|
350
|
-
}
|
|
351
|
-
if (manuscript.correctionDate) {
|
|
352
|
-
const date = this.buildDateElement(manuscript.correctionDate, 'corrected');
|
|
353
|
-
history.appendChild(date);
|
|
354
|
-
}
|
|
355
|
-
if (manuscript.retractionDate) {
|
|
356
|
-
const date = this.buildDateElement(manuscript.retractionDate, 'retracted');
|
|
357
|
-
history.appendChild(date);
|
|
358
|
-
}
|
|
359
|
-
if (manuscript.receiveDate) {
|
|
360
|
-
const date = this.buildDateElement(manuscript.receiveDate, 'received');
|
|
361
|
-
history.appendChild(date);
|
|
362
|
-
}
|
|
363
|
-
if (manuscript.revisionReceiveDate) {
|
|
364
|
-
const date = this.buildDateElement(manuscript.revisionReceiveDate, 'rev-recd');
|
|
365
|
-
history.appendChild(date);
|
|
366
|
-
}
|
|
367
|
-
if (manuscript.revisionRequestDate) {
|
|
368
|
-
const date = this.buildDateElement(manuscript.revisionRequestDate, 'rev-request');
|
|
369
|
-
history.appendChild(date);
|
|
370
|
-
}
|
|
371
|
-
if (history.childElementCount) {
|
|
372
|
-
articleMeta.appendChild(history);
|
|
373
|
-
}
|
|
279
|
+
const supplementsNodes = (0, prosemirror_utils_1.findChildrenByType)(this.manuscriptNode, schema_1.schema.nodes.supplement);
|
|
280
|
+
supplementsNodes.forEach(({ node }) => {
|
|
281
|
+
var _a, _b, _c, _d;
|
|
282
|
+
const supplementaryMaterial = this.document.createElement('supplementary-material');
|
|
283
|
+
supplementaryMaterial.setAttribute('id', normalizeID(node.attrs.id));
|
|
284
|
+
supplementaryMaterial.setAttributeNS(XLINK_NAMESPACE, 'href', (_a = node.attrs.href) !== null && _a !== void 0 ? _a : '');
|
|
285
|
+
supplementaryMaterial.setAttribute('mimetype', (_b = node.attrs.mimeType) !== null && _b !== void 0 ? _b : '');
|
|
286
|
+
supplementaryMaterial.setAttribute('mime-subtype', (_c = node.attrs.mimeSubType) !== null && _c !== void 0 ? _c : '');
|
|
287
|
+
const caption = this.document.createElement('caption');
|
|
288
|
+
const title = this.document.createElement('title');
|
|
289
|
+
title.textContent = (_d = node.attrs.title) !== null && _d !== void 0 ? _d : '';
|
|
290
|
+
caption.append(title);
|
|
291
|
+
supplementaryMaterial.append(caption);
|
|
292
|
+
articleMeta.append(supplementaryMaterial);
|
|
293
|
+
});
|
|
374
294
|
this.buildKeywords(articleMeta);
|
|
375
295
|
let countingElements = [];
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
countingElements.push(this.buildCountingElement('fig-count', manuscript.figureCount));
|
|
387
|
-
countingElements.push(this.buildCountingElement('table-count', manuscript.tableCount));
|
|
388
|
-
countingElements.push(this.buildCountingElement('equation-count', manuscript.equationCount));
|
|
389
|
-
countingElements.push(this.buildCountingElement('ref-count', manuscript.referencesCount));
|
|
390
|
-
countingElements.push(this.buildCountingElement('word-count', manuscript.wordCount));
|
|
296
|
+
const figureCount = (0, prosemirror_utils_1.findChildrenByType)(this.manuscriptNode, schema_1.schema.nodes.figure).length;
|
|
297
|
+
countingElements.push(this.buildCountingElement('fig-count', figureCount));
|
|
298
|
+
const equationCount = (0, prosemirror_utils_1.findChildrenByType)(this.manuscriptNode, schema_1.schema.nodes.equation_element).length;
|
|
299
|
+
countingElements.push(this.buildCountingElement('equation-count', equationCount));
|
|
300
|
+
const tableCount = (0, prosemirror_utils_1.findChildrenByType)(this.manuscriptNode, schema_1.schema.nodes.table).length;
|
|
301
|
+
countingElements.push(this.buildCountingElement('table-count', tableCount));
|
|
302
|
+
const referencesCount = (0, prosemirror_utils_1.findChildrenByType)(this.manuscriptNode, schema_1.schema.nodes.bibliography_item).length;
|
|
303
|
+
countingElements.push(this.buildCountingElement('ref-count', referencesCount));
|
|
304
|
+
const wordCount = this.manuscriptNode.textContent.split(/\s+/).length;
|
|
305
|
+
countingElements.push(this.buildCountingElement('word-count', wordCount));
|
|
391
306
|
countingElements = countingElements.filter((el) => el);
|
|
392
307
|
if (countingElements.length > 0) {
|
|
393
308
|
const counts = this.document.createElement('counts');
|
|
@@ -422,13 +337,13 @@ class JATSExporter {
|
|
|
422
337
|
return wordCount;
|
|
423
338
|
}
|
|
424
339
|
};
|
|
425
|
-
this.buildBody = (
|
|
340
|
+
this.buildBody = () => {
|
|
426
341
|
const body = this.document.createElement('body');
|
|
427
|
-
|
|
342
|
+
this.manuscriptNode.forEach((cFragment) => {
|
|
428
343
|
const serializedNode = this.serializeNode(cFragment);
|
|
429
344
|
body.append(...serializedNode.childNodes);
|
|
430
345
|
});
|
|
431
|
-
this.fixBody(body
|
|
346
|
+
this.fixBody(body);
|
|
432
347
|
return body;
|
|
433
348
|
};
|
|
434
349
|
this.buildBack = (body) => {
|
|
@@ -454,11 +369,15 @@ class JATSExporter {
|
|
|
454
369
|
refList = this.document.createElement('ref-list');
|
|
455
370
|
}
|
|
456
371
|
back.appendChild(refList);
|
|
372
|
+
const bibliographyItems = (0, prosemirror_utils_1.findChildrenByType)(this.manuscriptNode, schema_1.schema.nodes.bibliography_item).map((n) => n.node);
|
|
457
373
|
const [meta] = this.citationProvider.makeBibliography();
|
|
458
|
-
for (const id of meta.entry_ids) {
|
|
459
|
-
const bibliographyItem =
|
|
374
|
+
for (const [id] of meta.entry_ids) {
|
|
375
|
+
const bibliographyItem = bibliographyItems.find((n) => n.attrs.id === id);
|
|
376
|
+
if (!bibliographyItem) {
|
|
377
|
+
continue;
|
|
378
|
+
}
|
|
460
379
|
const ref = this.document.createElement('ref');
|
|
461
|
-
ref.setAttribute('id', normalizeID(id
|
|
380
|
+
ref.setAttribute('id', normalizeID(id));
|
|
462
381
|
const updateCitationPubType = (citationEl, pubType) => {
|
|
463
382
|
if (pubType) {
|
|
464
383
|
switch (pubType) {
|
|
@@ -475,21 +394,21 @@ class JATSExporter {
|
|
|
475
394
|
citationEl.setAttribute('publication-type', 'journal');
|
|
476
395
|
}
|
|
477
396
|
};
|
|
478
|
-
if (bibliographyItem.literal) {
|
|
397
|
+
if (bibliographyItem.attrs.literal) {
|
|
479
398
|
const mixedCitation = this.document.createElement('mixed-citation');
|
|
480
|
-
updateCitationPubType(mixedCitation, bibliographyItem.type);
|
|
481
|
-
mixedCitation.textContent = bibliographyItem.literal;
|
|
399
|
+
updateCitationPubType(mixedCitation, bibliographyItem.attrs.type);
|
|
400
|
+
mixedCitation.textContent = bibliographyItem.attrs.literal;
|
|
482
401
|
ref.appendChild(mixedCitation);
|
|
483
402
|
refList.appendChild(ref);
|
|
484
403
|
}
|
|
485
404
|
else {
|
|
486
405
|
const citation = this.document.createElement('element-citation');
|
|
487
|
-
updateCitationPubType(citation, bibliographyItem.type);
|
|
488
|
-
if (bibliographyItem.author) {
|
|
406
|
+
updateCitationPubType(citation, bibliographyItem.attrs.type);
|
|
407
|
+
if (bibliographyItem.attrs.author) {
|
|
489
408
|
const personGroupNode = this.document.createElement('person-group');
|
|
490
409
|
personGroupNode.setAttribute('person-group-type', 'author');
|
|
491
410
|
citation.appendChild(personGroupNode);
|
|
492
|
-
bibliographyItem.author.forEach((author) => {
|
|
411
|
+
bibliographyItem.attrs.author.forEach((author) => {
|
|
493
412
|
const name = this.document.createElement('string-name');
|
|
494
413
|
if (author.family) {
|
|
495
414
|
const node = this.document.createElement('surname');
|
|
@@ -511,8 +430,8 @@ class JATSExporter {
|
|
|
511
430
|
}
|
|
512
431
|
});
|
|
513
432
|
}
|
|
514
|
-
if (bibliographyItem.issued) {
|
|
515
|
-
const dateParts = bibliographyItem.issued['date-parts'];
|
|
433
|
+
if (bibliographyItem.attrs.issued) {
|
|
434
|
+
const dateParts = bibliographyItem.attrs.issued['date-parts'];
|
|
516
435
|
if (dateParts && dateParts.length) {
|
|
517
436
|
const [[year, month, day]] = dateParts;
|
|
518
437
|
if (year) {
|
|
@@ -532,33 +451,33 @@ class JATSExporter {
|
|
|
532
451
|
}
|
|
533
452
|
}
|
|
534
453
|
}
|
|
535
|
-
if (bibliographyItem.title) {
|
|
454
|
+
if (bibliographyItem.attrs.title) {
|
|
536
455
|
const node = this.document.createElement('article-title');
|
|
537
|
-
this.setTitleContent(node, bibliographyItem.title);
|
|
456
|
+
this.setTitleContent(node, bibliographyItem.attrs.title);
|
|
538
457
|
citation.appendChild(node);
|
|
539
458
|
}
|
|
540
|
-
if (bibliographyItem
|
|
459
|
+
if (bibliographyItem.attrs.containerTitle) {
|
|
541
460
|
const node = this.document.createElement('source');
|
|
542
|
-
node
|
|
461
|
+
this.setTitleContent(node, bibliographyItem.attrs.containerTitle);
|
|
543
462
|
citation.appendChild(node);
|
|
544
463
|
}
|
|
545
|
-
if (bibliographyItem.volume) {
|
|
464
|
+
if (bibliographyItem.attrs.volume) {
|
|
546
465
|
const node = this.document.createElement('volume');
|
|
547
|
-
node.textContent = String(bibliographyItem.volume);
|
|
466
|
+
node.textContent = String(bibliographyItem.attrs.volume);
|
|
548
467
|
citation.appendChild(node);
|
|
549
468
|
}
|
|
550
|
-
if (bibliographyItem.issue) {
|
|
469
|
+
if (bibliographyItem.attrs.issue) {
|
|
551
470
|
const node = this.document.createElement('issue');
|
|
552
|
-
node.textContent = String(bibliographyItem.issue);
|
|
471
|
+
node.textContent = String(bibliographyItem.attrs.issue);
|
|
553
472
|
citation.appendChild(node);
|
|
554
473
|
}
|
|
555
|
-
if (bibliographyItem.supplement) {
|
|
474
|
+
if (bibliographyItem.attrs.supplement) {
|
|
556
475
|
const node = this.document.createElement('supplement');
|
|
557
|
-
node.textContent = bibliographyItem.supplement;
|
|
476
|
+
node.textContent = bibliographyItem.attrs.supplement;
|
|
558
477
|
citation.appendChild(node);
|
|
559
478
|
}
|
|
560
|
-
if (bibliographyItem.page) {
|
|
561
|
-
const pageString = String(bibliographyItem.page);
|
|
479
|
+
if (bibliographyItem.attrs.page) {
|
|
480
|
+
const pageString = String(bibliographyItem.attrs.page);
|
|
562
481
|
if (/^\d+$/.test(pageString)) {
|
|
563
482
|
const node = this.document.createElement('fpage');
|
|
564
483
|
node.textContent = pageString;
|
|
@@ -579,10 +498,10 @@ class JATSExporter {
|
|
|
579
498
|
citation.appendChild(node);
|
|
580
499
|
}
|
|
581
500
|
}
|
|
582
|
-
if (bibliographyItem.
|
|
501
|
+
if (bibliographyItem.attrs.doi) {
|
|
583
502
|
const node = this.document.createElement('pub-id');
|
|
584
503
|
node.setAttribute('pub-id-type', 'doi');
|
|
585
|
-
node.textContent = String(bibliographyItem.
|
|
504
|
+
node.textContent = String(bibliographyItem.attrs.doi);
|
|
586
505
|
citation.appendChild(node);
|
|
587
506
|
}
|
|
588
507
|
ref.appendChild(citation);
|
|
@@ -592,10 +511,19 @@ class JATSExporter {
|
|
|
592
511
|
return back;
|
|
593
512
|
};
|
|
594
513
|
this.createSerializer = () => {
|
|
595
|
-
const getModel = (id) => id ? this.modelMap.get(id) : undefined;
|
|
596
514
|
const nodes = {
|
|
597
|
-
|
|
598
|
-
|
|
515
|
+
awards: () => ['funding-group', 0],
|
|
516
|
+
award: (node) => {
|
|
517
|
+
const awardGroup = node;
|
|
518
|
+
const awardGroupElement = this.document.createElement('award-group');
|
|
519
|
+
awardGroupElement.setAttribute('id', normalizeID(awardGroup.attrs.id));
|
|
520
|
+
appendChildIfPresent(awardGroupElement, 'funding-source', awardGroup.attrs.source);
|
|
521
|
+
awardGroup.attrs.code
|
|
522
|
+
.split(';')
|
|
523
|
+
.forEach((code) => appendChildIfPresent(awardGroupElement, 'award-id', code));
|
|
524
|
+
appendChildIfPresent(awardGroupElement, 'principal-award-recipient', awardGroup.attrs.recipient);
|
|
525
|
+
return awardGroupElement;
|
|
526
|
+
},
|
|
599
527
|
box_element: (node) => createBoxElement(node),
|
|
600
528
|
author_notes: () => '',
|
|
601
529
|
corresp: () => '',
|
|
@@ -617,11 +545,7 @@ class JATSExporter {
|
|
|
617
545
|
backmatter: () => ['backmatter', 0],
|
|
618
546
|
supplement: () => '',
|
|
619
547
|
supplements: () => '',
|
|
620
|
-
bibliography_section: (
|
|
621
|
-
'ref-list',
|
|
622
|
-
{ id: normalizeID(node.attrs.id) },
|
|
623
|
-
0,
|
|
624
|
-
],
|
|
548
|
+
bibliography_section: () => '',
|
|
625
549
|
blockquote_element: () => ['disp-quote', { 'content-type': 'quote' }, 0],
|
|
626
550
|
list: (node) => {
|
|
627
551
|
var _a;
|
|
@@ -657,24 +581,25 @@ class JATSExporter {
|
|
|
657
581
|
return xref;
|
|
658
582
|
},
|
|
659
583
|
cross_reference: (node) => {
|
|
584
|
+
var _a;
|
|
660
585
|
const cross = node;
|
|
661
586
|
const rids = cross.attrs.rids;
|
|
662
587
|
if (!rids.length) {
|
|
663
588
|
return cross.attrs.label;
|
|
664
589
|
}
|
|
665
590
|
const text = cross.attrs.customLabel || cross.attrs.label;
|
|
666
|
-
const
|
|
667
|
-
if (!
|
|
591
|
+
const target = (_a = (0, prosemirror_utils_1.findChildrenByAttr)(this.manuscriptNode, (attrs) => attrs.id === rids[0])[0]) === null || _a === void 0 ? void 0 : _a.node;
|
|
592
|
+
if (!target) {
|
|
668
593
|
warn('');
|
|
669
594
|
return text;
|
|
670
595
|
}
|
|
671
596
|
const xref = this.document.createElement('xref');
|
|
672
|
-
const type = chooseRefType(
|
|
597
|
+
const type = chooseRefType(target.type);
|
|
673
598
|
if (type) {
|
|
674
599
|
xref.setAttribute('ref-type', type);
|
|
675
600
|
}
|
|
676
601
|
else {
|
|
677
|
-
warn(`Unset ref-type for
|
|
602
|
+
warn(`Unset ref-type for schema type ${target.type.name}`);
|
|
678
603
|
}
|
|
679
604
|
xref.setAttribute('rid', normalizeID(rids.join(' ')));
|
|
680
605
|
xref.textContent = text;
|
|
@@ -746,7 +671,10 @@ class JATSExporter {
|
|
|
746
671
|
hard_break: () => '',
|
|
747
672
|
highlight_marker: () => '',
|
|
748
673
|
inline_footnote: (node) => {
|
|
749
|
-
const rids = node.attrs.rids.filter(
|
|
674
|
+
const rids = node.attrs.rids.filter((rid) => {
|
|
675
|
+
var _a;
|
|
676
|
+
return (_a = (0, prosemirror_utils_1.findChildrenByAttr)(this.manuscriptNode, (attrs) => attrs.id === rid)[0]) === null || _a === void 0 ? void 0 : _a.node;
|
|
677
|
+
});
|
|
750
678
|
if (rids.length == 0) {
|
|
751
679
|
return '';
|
|
752
680
|
}
|
|
@@ -828,7 +756,7 @@ class JATSExporter {
|
|
|
828
756
|
id: normalizeID(node.attrs.id),
|
|
829
757
|
};
|
|
830
758
|
if (node.attrs.category) {
|
|
831
|
-
attrs['sec-type'] = (0,
|
|
759
|
+
attrs['sec-type'] = (0, transformer_1.chooseSecType)(node.attrs.category);
|
|
832
760
|
}
|
|
833
761
|
return ['sec', attrs, 0];
|
|
834
762
|
},
|
|
@@ -865,14 +793,7 @@ class JATSExporter {
|
|
|
865
793
|
italic: () => ['italic'],
|
|
866
794
|
smallcaps: () => ['sc'],
|
|
867
795
|
strikethrough: () => ['strike'],
|
|
868
|
-
styled: (
|
|
869
|
-
const inlineStyle = getModel(mark.attrs.rid);
|
|
870
|
-
const attrs = {};
|
|
871
|
-
if (inlineStyle && inlineStyle.title) {
|
|
872
|
-
attrs.style = (0, styled_content_1.normalizeStyleName)(inlineStyle.title);
|
|
873
|
-
}
|
|
874
|
-
return ['styled-content', attrs];
|
|
875
|
-
},
|
|
796
|
+
styled: () => ['styled-content'],
|
|
876
797
|
superscript: () => ['sup'],
|
|
877
798
|
subscript: () => ['sub'],
|
|
878
799
|
underline: () => ['underline'],
|
|
@@ -880,6 +801,14 @@ class JATSExporter {
|
|
|
880
801
|
tracked_delete: () => ['del'],
|
|
881
802
|
};
|
|
882
803
|
this.serializer = new prosemirror_model_1.DOMSerializer(nodes, marks);
|
|
804
|
+
const appendChildIfPresent = (parent, tagName, textContent) => {
|
|
805
|
+
if (!textContent) {
|
|
806
|
+
return;
|
|
807
|
+
}
|
|
808
|
+
const element = this.document.createElement(tagName);
|
|
809
|
+
element.textContent = textContent;
|
|
810
|
+
parent.appendChild(element);
|
|
811
|
+
};
|
|
883
812
|
const processChildNodes = (element, node, contentNodeType) => {
|
|
884
813
|
node.forEach((childNode) => {
|
|
885
814
|
if (childNode.type === contentNodeType) {
|
|
@@ -923,14 +852,16 @@ class JATSExporter {
|
|
|
923
852
|
}
|
|
924
853
|
};
|
|
925
854
|
const appendChildNodeOfType = (element, node, type) => {
|
|
926
|
-
|
|
855
|
+
var _a;
|
|
856
|
+
const childNode = (_a = (0, prosemirror_utils_1.findChildrenByType)(node, type)[0]) === null || _a === void 0 ? void 0 : _a.node;
|
|
927
857
|
if (childNode) {
|
|
928
858
|
element.appendChild(this.serializeNode(childNode));
|
|
929
859
|
}
|
|
930
860
|
};
|
|
931
861
|
const appendTable = (element, node) => {
|
|
932
|
-
|
|
933
|
-
const
|
|
862
|
+
var _a, _b;
|
|
863
|
+
const tableNode = (_a = (0, prosemirror_utils_1.findChildrenByType)(node, node.type.schema.nodes.table)[0]) === null || _a === void 0 ? void 0 : _a.node;
|
|
864
|
+
const colGroupNode = (_b = (0, prosemirror_utils_1.findChildrenByType)(node, node.type.schema.nodes.table_colgroup)[0]) === null || _b === void 0 ? void 0 : _b.node;
|
|
934
865
|
if (!tableNode) {
|
|
935
866
|
return;
|
|
936
867
|
}
|
|
@@ -965,7 +896,7 @@ class JATSExporter {
|
|
|
965
896
|
appendChildNodeOfType(element, node, node.type.schema.nodes.footnotes_element);
|
|
966
897
|
processChildNodes(element, node, contentNodeType);
|
|
967
898
|
appendAttributions(element, node);
|
|
968
|
-
if ((0,
|
|
899
|
+
if ((0, transformer_1.isExecutableNodeType)(node.type)) {
|
|
969
900
|
processExecutableNode(node, element);
|
|
970
901
|
}
|
|
971
902
|
return element;
|
|
@@ -977,13 +908,14 @@ class JATSExporter {
|
|
|
977
908
|
appendChildNodeOfType(element, node, node.type.schema.nodes.figcaption);
|
|
978
909
|
appendTable(element, node);
|
|
979
910
|
appendChildNodeOfType(element, node, node.type.schema.nodes.table_element_footer);
|
|
980
|
-
if ((0,
|
|
911
|
+
if ((0, transformer_1.isExecutableNodeType)(node.type)) {
|
|
981
912
|
processExecutableNode(node, element);
|
|
982
913
|
}
|
|
983
914
|
return element;
|
|
984
915
|
};
|
|
985
916
|
const processExecutableNode = (node, element) => {
|
|
986
|
-
|
|
917
|
+
var _a;
|
|
918
|
+
const listingNode = (_a = (0, prosemirror_utils_1.findChildrenByType)(node, node.type.schema.nodes.listing)[0]) === null || _a === void 0 ? void 0 : _a.node;
|
|
987
919
|
if (listingNode) {
|
|
988
920
|
const { contents, languageKey } = listingNode.attrs;
|
|
989
921
|
if (contents && languageKey) {
|
|
@@ -995,47 +927,29 @@ class JATSExporter {
|
|
|
995
927
|
code.setAttribute('language', languageKey);
|
|
996
928
|
code.textContent = contents;
|
|
997
929
|
listing.appendChild(code);
|
|
998
|
-
const caption = this.document.createElement('caption');
|
|
999
|
-
listing.appendChild(caption);
|
|
1000
|
-
const attachments = [];
|
|
1001
|
-
for (const attachment of attachments) {
|
|
1002
|
-
const p = this.document.createElement('p');
|
|
1003
|
-
caption.appendChild(p);
|
|
1004
|
-
const filename = (0, filename_1.generateAttachmentFilename)(`${listingNode.attrs.id}:${attachment.id}`, attachment.type);
|
|
1005
|
-
const supp = this.document.createElement('supplementary-material');
|
|
1006
|
-
supp.setAttributeNS(XLINK_NAMESPACE, 'xlink:href', `suppl/${filename}`);
|
|
1007
|
-
const [mimeType, mimeSubType] = attachment.type.split('/');
|
|
1008
|
-
if (mimeType) {
|
|
1009
|
-
supp.setAttribute('mimetype', mimeType);
|
|
1010
|
-
if (mimeSubType) {
|
|
1011
|
-
supp.setAttribute('mime-subtype', mimeSubType);
|
|
1012
|
-
}
|
|
1013
|
-
}
|
|
1014
|
-
p.appendChild(supp);
|
|
1015
|
-
}
|
|
1016
930
|
}
|
|
1017
931
|
}
|
|
1018
932
|
};
|
|
1019
933
|
};
|
|
1020
|
-
this.serializeFragment = (fragment) => this.serializer.serializeFragment(fragment, {
|
|
1021
|
-
document: this.document,
|
|
1022
|
-
});
|
|
1023
934
|
this.serializeNode = (node) => this.serializer.serializeNode(node, {
|
|
1024
935
|
document: this.document,
|
|
1025
936
|
});
|
|
1026
937
|
this.validateContributor = (contributor) => {
|
|
1027
|
-
if (!contributor.bibliographicName) {
|
|
1028
|
-
throw new Error(`${contributor.
|
|
938
|
+
if (!contributor.attrs.bibliographicName) {
|
|
939
|
+
throw new Error(`${contributor.attrs.id} has no bibliographicName`);
|
|
1029
940
|
}
|
|
1030
|
-
const { family, given } = contributor.bibliographicName;
|
|
941
|
+
const { family, given } = contributor.attrs.bibliographicName;
|
|
1031
942
|
if (!family && !given) {
|
|
1032
|
-
throw new Error(`${contributor.
|
|
943
|
+
throw new Error(`${contributor.attrs.id} has neither family nor given name`);
|
|
1033
944
|
}
|
|
1034
945
|
};
|
|
1035
946
|
this.buildContributors = (articleMeta) => {
|
|
1036
|
-
const
|
|
1037
|
-
const
|
|
1038
|
-
.filter((
|
|
947
|
+
const contributorNodes = (0, prosemirror_utils_1.findChildrenByType)(this.manuscriptNode, schema_1.schema.nodes.contributor).map((result) => result.node);
|
|
948
|
+
const authorContributorNodes = contributorNodes
|
|
949
|
+
.filter((n) => n.attrs.role === 'author')
|
|
950
|
+
.sort(sortContributors);
|
|
951
|
+
const otherContributorsNodes = contributorNodes
|
|
952
|
+
.filter((n) => n.attrs.role !== 'author')
|
|
1039
953
|
.sort(sortContributors);
|
|
1040
954
|
const affiliationLabels = new Map();
|
|
1041
955
|
const creatAffiliationLabel = (rid) => {
|
|
@@ -1053,11 +967,11 @@ class JATSExporter {
|
|
|
1053
967
|
sup.textContent = String(content);
|
|
1054
968
|
return sup;
|
|
1055
969
|
};
|
|
1056
|
-
if (
|
|
970
|
+
if (authorContributorNodes.length) {
|
|
1057
971
|
const contribGroup = this.document.createElement('contrib-group');
|
|
1058
972
|
contribGroup.setAttribute('content-type', 'authors');
|
|
1059
973
|
articleMeta.appendChild(contribGroup);
|
|
1060
|
-
|
|
974
|
+
authorContributorNodes.forEach((contributor) => {
|
|
1061
975
|
try {
|
|
1062
976
|
this.validateContributor(contributor);
|
|
1063
977
|
}
|
|
@@ -1067,39 +981,25 @@ class JATSExporter {
|
|
|
1067
981
|
}
|
|
1068
982
|
const contrib = this.document.createElement('contrib');
|
|
1069
983
|
contrib.setAttribute('contrib-type', 'author');
|
|
1070
|
-
contrib.setAttribute('id', normalizeID(contributor.
|
|
1071
|
-
if (contributor.isCorresponding) {
|
|
984
|
+
contrib.setAttribute('id', normalizeID(contributor.attrs.id));
|
|
985
|
+
if (contributor.attrs.isCorresponding) {
|
|
1072
986
|
contrib.setAttribute('corresp', 'yes');
|
|
1073
987
|
}
|
|
1074
|
-
if (contributor.ORCIDIdentifier) {
|
|
988
|
+
if (contributor.attrs.ORCIDIdentifier) {
|
|
1075
989
|
const identifier = this.document.createElement('contrib-id');
|
|
1076
990
|
identifier.setAttribute('contrib-id-type', 'orcid');
|
|
1077
|
-
identifier.textContent = contributor.ORCIDIdentifier;
|
|
991
|
+
identifier.textContent = contributor.attrs.ORCIDIdentifier;
|
|
1078
992
|
contrib.appendChild(identifier);
|
|
1079
993
|
}
|
|
1080
994
|
const name = this.buildContributorName(contributor);
|
|
1081
995
|
contrib.appendChild(name);
|
|
1082
|
-
if (contributor.email) {
|
|
996
|
+
if (contributor.attrs.email) {
|
|
1083
997
|
const email = this.document.createElement('email');
|
|
1084
|
-
email.textContent = contributor.email;
|
|
998
|
+
email.textContent = contributor.attrs.email;
|
|
1085
999
|
contrib.appendChild(email);
|
|
1086
1000
|
}
|
|
1087
|
-
if (contributor.
|
|
1088
|
-
contributor.
|
|
1089
|
-
const contributorRole = this.modelMap.get(rid);
|
|
1090
|
-
if (contributorRole) {
|
|
1091
|
-
const role = this.document.createElement('role');
|
|
1092
|
-
const attributes = chooseRoleVocabAttributes(contributorRole);
|
|
1093
|
-
for (const [key, value] of Object.entries(attributes)) {
|
|
1094
|
-
role.setAttribute(key, value);
|
|
1095
|
-
}
|
|
1096
|
-
role.textContent = contributorRole.name;
|
|
1097
|
-
contrib.appendChild(role);
|
|
1098
|
-
}
|
|
1099
|
-
});
|
|
1100
|
-
}
|
|
1101
|
-
if (contributor.affiliations) {
|
|
1102
|
-
contributor.affiliations.forEach((rid) => {
|
|
1001
|
+
if (contributor.attrs.affiliations) {
|
|
1002
|
+
contributor.attrs.affiliations.forEach((rid) => {
|
|
1103
1003
|
const xref = this.document.createElement('xref');
|
|
1104
1004
|
xref.setAttribute('ref-type', 'aff');
|
|
1105
1005
|
xref.setAttribute('rid', normalizeID(rid));
|
|
@@ -1107,8 +1007,8 @@ class JATSExporter {
|
|
|
1107
1007
|
contrib.appendChild(xref);
|
|
1108
1008
|
});
|
|
1109
1009
|
}
|
|
1110
|
-
if (contributor.footnote) {
|
|
1111
|
-
contributor.footnote.map((note) => {
|
|
1010
|
+
if (contributor.attrs.footnote) {
|
|
1011
|
+
contributor.attrs.footnote.map((note) => {
|
|
1112
1012
|
const xref = this.document.createElement('xref');
|
|
1113
1013
|
xref.setAttribute('ref-type', 'fn');
|
|
1114
1014
|
xref.setAttribute('rid', normalizeID(note.noteID));
|
|
@@ -1116,8 +1016,8 @@ class JATSExporter {
|
|
|
1116
1016
|
contrib.appendChild(xref);
|
|
1117
1017
|
});
|
|
1118
1018
|
}
|
|
1119
|
-
if (contributor.corresp) {
|
|
1120
|
-
contributor.corresp.map((corresp) => {
|
|
1019
|
+
if (contributor.attrs.corresp) {
|
|
1020
|
+
contributor.attrs.corresp.map((corresp) => {
|
|
1121
1021
|
const xref = this.document.createElement('xref');
|
|
1122
1022
|
xref.setAttribute('ref-type', 'corresp');
|
|
1123
1023
|
xref.setAttribute('rid', normalizeID(corresp.correspID));
|
|
@@ -1127,13 +1027,10 @@ class JATSExporter {
|
|
|
1127
1027
|
}
|
|
1128
1028
|
contribGroup.appendChild(contrib);
|
|
1129
1029
|
});
|
|
1130
|
-
|
|
1131
|
-
.filter((contributor) => contributor.role !== 'author')
|
|
1132
|
-
.sort(sortContributors);
|
|
1133
|
-
if (otherContributors.length) {
|
|
1030
|
+
if (otherContributorsNodes.length) {
|
|
1134
1031
|
const contribGroup = this.document.createElement('contrib-group');
|
|
1135
1032
|
articleMeta.appendChild(contribGroup);
|
|
1136
|
-
|
|
1033
|
+
otherContributorsNodes.forEach((contributor) => {
|
|
1137
1034
|
try {
|
|
1138
1035
|
this.validateContributor(contributor);
|
|
1139
1036
|
}
|
|
@@ -1142,30 +1039,16 @@ class JATSExporter {
|
|
|
1142
1039
|
return;
|
|
1143
1040
|
}
|
|
1144
1041
|
const contrib = this.document.createElement('contrib');
|
|
1145
|
-
contrib.setAttribute('id', normalizeID(contributor.
|
|
1042
|
+
contrib.setAttribute('id', normalizeID(contributor.attrs.id));
|
|
1146
1043
|
const name = this.buildContributorName(contributor);
|
|
1147
1044
|
contrib.appendChild(name);
|
|
1148
|
-
if (contributor.email) {
|
|
1045
|
+
if (contributor.attrs.email) {
|
|
1149
1046
|
const email = this.document.createElement('email');
|
|
1150
|
-
email.textContent = contributor.email;
|
|
1047
|
+
email.textContent = contributor.attrs.email;
|
|
1151
1048
|
contrib.appendChild(email);
|
|
1152
1049
|
}
|
|
1153
|
-
if (contributor.
|
|
1154
|
-
contributor.
|
|
1155
|
-
const contributorRole = this.modelMap.get(rid);
|
|
1156
|
-
if (contributorRole) {
|
|
1157
|
-
const role = this.document.createElement('role');
|
|
1158
|
-
const attributes = chooseRoleVocabAttributes(contributorRole);
|
|
1159
|
-
for (const [key, value] of Object.entries(attributes)) {
|
|
1160
|
-
role.setAttribute(key, value);
|
|
1161
|
-
}
|
|
1162
|
-
role.textContent = contributorRole.name;
|
|
1163
|
-
contrib.appendChild(role);
|
|
1164
|
-
}
|
|
1165
|
-
});
|
|
1166
|
-
}
|
|
1167
|
-
if (contributor.affiliations) {
|
|
1168
|
-
contributor.affiliations.forEach((rid) => {
|
|
1050
|
+
if (contributor.attrs.affiliations) {
|
|
1051
|
+
contributor.attrs.affiliations.forEach((rid) => {
|
|
1169
1052
|
const xref = this.document.createElement('xref');
|
|
1170
1053
|
xref.setAttribute('ref-type', 'aff');
|
|
1171
1054
|
xref.setAttribute('rid', normalizeID(rid));
|
|
@@ -1173,8 +1056,8 @@ class JATSExporter {
|
|
|
1173
1056
|
contrib.appendChild(xref);
|
|
1174
1057
|
});
|
|
1175
1058
|
}
|
|
1176
|
-
if (contributor.footnote) {
|
|
1177
|
-
contributor.footnote.map((note) => {
|
|
1059
|
+
if (contributor.attrs.footnote) {
|
|
1060
|
+
contributor.attrs.footnote.map((note) => {
|
|
1178
1061
|
const xref = this.document.createElement('xref');
|
|
1179
1062
|
xref.setAttribute('ref-type', 'fn');
|
|
1180
1063
|
xref.setAttribute('rid', normalizeID(note.noteID));
|
|
@@ -1186,64 +1069,68 @@ class JATSExporter {
|
|
|
1186
1069
|
});
|
|
1187
1070
|
}
|
|
1188
1071
|
const affiliationRIDs = [];
|
|
1189
|
-
const sortedContributors = [
|
|
1072
|
+
const sortedContributors = [
|
|
1073
|
+
...authorContributorNodes,
|
|
1074
|
+
...otherContributorsNodes,
|
|
1075
|
+
];
|
|
1190
1076
|
for (const contributor of sortedContributors) {
|
|
1191
|
-
if (contributor.affiliations) {
|
|
1192
|
-
affiliationRIDs.push(...contributor.affiliations);
|
|
1077
|
+
if (contributor.attrs.affiliations) {
|
|
1078
|
+
affiliationRIDs.push(...contributor.attrs.affiliations);
|
|
1193
1079
|
}
|
|
1194
1080
|
}
|
|
1195
|
-
const affiliations =
|
|
1081
|
+
const affiliations = (0, prosemirror_utils_1.findChildrenByType)(this.manuscriptNode, schema_1.schema.nodes.affiliation).map((result) => result.node);
|
|
1196
1082
|
if (affiliations) {
|
|
1197
|
-
const usedAffiliations = affiliations.filter((affiliation) => affiliationRIDs.includes(affiliation.
|
|
1198
|
-
usedAffiliations.sort((a, b) => affiliationRIDs.indexOf(a.
|
|
1083
|
+
const usedAffiliations = affiliations.filter((affiliation) => affiliationRIDs.includes(affiliation.attrs.id));
|
|
1084
|
+
usedAffiliations.sort((a, b) => affiliationRIDs.indexOf(a.attrs.id) -
|
|
1085
|
+
affiliationRIDs.indexOf(b.attrs.id));
|
|
1199
1086
|
usedAffiliations.forEach((affiliation) => {
|
|
1200
1087
|
var _a, _b;
|
|
1201
1088
|
const aff = this.document.createElement('aff');
|
|
1202
|
-
aff.setAttribute('id', normalizeID(affiliation.
|
|
1089
|
+
aff.setAttribute('id', normalizeID(affiliation.attrs.id));
|
|
1203
1090
|
contribGroup.appendChild(aff);
|
|
1204
|
-
if (affiliation.department) {
|
|
1091
|
+
if (affiliation.attrs.department) {
|
|
1205
1092
|
const department = this.document.createElement('institution');
|
|
1206
1093
|
department.setAttribute('content-type', 'dept');
|
|
1207
|
-
department.textContent = affiliation.department;
|
|
1094
|
+
department.textContent = affiliation.attrs.department;
|
|
1208
1095
|
aff.appendChild(department);
|
|
1209
1096
|
}
|
|
1210
|
-
if (affiliation.institution) {
|
|
1097
|
+
if (affiliation.attrs.institution) {
|
|
1211
1098
|
const institution = this.document.createElement('institution');
|
|
1212
|
-
institution.textContent = affiliation.institution;
|
|
1099
|
+
institution.textContent = affiliation.attrs.institution;
|
|
1213
1100
|
aff.appendChild(institution);
|
|
1214
1101
|
}
|
|
1215
|
-
if (affiliation.addressLine1) {
|
|
1102
|
+
if (affiliation.attrs.addressLine1) {
|
|
1216
1103
|
const addressLine = this.document.createElement('addr-line');
|
|
1217
|
-
addressLine.textContent = affiliation.addressLine1;
|
|
1104
|
+
addressLine.textContent = affiliation.attrs.addressLine1;
|
|
1218
1105
|
aff.appendChild(addressLine);
|
|
1219
1106
|
}
|
|
1220
|
-
if (affiliation.addressLine2) {
|
|
1107
|
+
if (affiliation.attrs.addressLine2) {
|
|
1221
1108
|
const addressLine = this.document.createElement('addr-line');
|
|
1222
|
-
addressLine.textContent = affiliation.addressLine2;
|
|
1109
|
+
addressLine.textContent = affiliation.attrs.addressLine2;
|
|
1223
1110
|
aff.appendChild(addressLine);
|
|
1224
1111
|
}
|
|
1225
|
-
if (affiliation.addressLine3) {
|
|
1112
|
+
if (affiliation.attrs.addressLine3) {
|
|
1226
1113
|
const addressLine = this.document.createElement('addr-line');
|
|
1227
|
-
addressLine.textContent = affiliation.addressLine3;
|
|
1114
|
+
addressLine.textContent = affiliation.attrs.addressLine3;
|
|
1228
1115
|
aff.appendChild(addressLine);
|
|
1229
1116
|
}
|
|
1230
|
-
if (affiliation.city) {
|
|
1117
|
+
if (affiliation.attrs.city) {
|
|
1231
1118
|
const city = this.document.createElement('city');
|
|
1232
|
-
city.textContent = affiliation.city;
|
|
1119
|
+
city.textContent = affiliation.attrs.city;
|
|
1233
1120
|
aff.appendChild(city);
|
|
1234
1121
|
}
|
|
1235
|
-
if (affiliation.country) {
|
|
1122
|
+
if (affiliation.attrs.country) {
|
|
1236
1123
|
const country = this.document.createElement('country');
|
|
1237
|
-
country.textContent = affiliation.country;
|
|
1124
|
+
country.textContent = affiliation.attrs.country;
|
|
1238
1125
|
aff.appendChild(country);
|
|
1239
1126
|
}
|
|
1240
|
-
if (affiliation.email) {
|
|
1127
|
+
if (affiliation.attrs.email) {
|
|
1241
1128
|
const email = this.document.createElement('email');
|
|
1242
|
-
email.setAttributeNS(XLINK_NAMESPACE, 'href', (_a = affiliation.email.href) !== null && _a !== void 0 ? _a : '');
|
|
1243
|
-
email.textContent = (_b = affiliation.email.text) !== null && _b !== void 0 ? _b : '';
|
|
1129
|
+
email.setAttributeNS(XLINK_NAMESPACE, 'href', (_a = affiliation.attrs.email.href) !== null && _a !== void 0 ? _a : '');
|
|
1130
|
+
email.textContent = (_b = affiliation.attrs.email.text) !== null && _b !== void 0 ? _b : '';
|
|
1244
1131
|
aff.appendChild(email);
|
|
1245
1132
|
}
|
|
1246
|
-
const labelNumber = affiliationLabels.get(affiliation.
|
|
1133
|
+
const labelNumber = affiliationLabels.get(affiliation.attrs.id);
|
|
1247
1134
|
if (labelNumber) {
|
|
1248
1135
|
const label = this.document.createElement('label');
|
|
1249
1136
|
label.textContent = String(labelNumber);
|
|
@@ -1260,41 +1147,48 @@ class JATSExporter {
|
|
|
1260
1147
|
this.createAuthorNotesElement = () => {
|
|
1261
1148
|
var _a;
|
|
1262
1149
|
const authorNotesEl = this.document.createElement('author-notes');
|
|
1263
|
-
const
|
|
1264
|
-
if (
|
|
1265
|
-
this.appendModelsToAuthorNotes(authorNotesEl,
|
|
1150
|
+
const authorNotesNode = (_a = (0, prosemirror_utils_1.findChildrenByType)(this.manuscriptNode, schema_1.schema.nodes.author_notes)[0]) === null || _a === void 0 ? void 0 : _a.node;
|
|
1151
|
+
if (authorNotesNode) {
|
|
1152
|
+
this.appendModelsToAuthorNotes(authorNotesEl, authorNotesNode);
|
|
1266
1153
|
}
|
|
1267
1154
|
return authorNotesEl;
|
|
1268
1155
|
};
|
|
1269
1156
|
this.appendCorrespondingToElement = (corresponding, element) => {
|
|
1270
1157
|
const correspondingEl = this.document.createElement('corresp');
|
|
1271
|
-
correspondingEl.setAttribute('id', normalizeID(corresponding.
|
|
1272
|
-
if (corresponding.label) {
|
|
1158
|
+
correspondingEl.setAttribute('id', normalizeID(corresponding.attrs.id));
|
|
1159
|
+
if (corresponding.attrs.label) {
|
|
1273
1160
|
const labelEl = this.document.createElement('label');
|
|
1274
|
-
labelEl.textContent = corresponding.label;
|
|
1161
|
+
labelEl.textContent = corresponding.attrs.label;
|
|
1275
1162
|
correspondingEl.appendChild(labelEl);
|
|
1276
1163
|
}
|
|
1277
|
-
correspondingEl.append(corresponding.
|
|
1164
|
+
correspondingEl.append(corresponding.textContent);
|
|
1278
1165
|
element.appendChild(correspondingEl);
|
|
1279
1166
|
};
|
|
1280
1167
|
this.appendParagraphToElement = (paragraph, element) => {
|
|
1281
|
-
const parsedDoc = new DOMParser().parseFromString(paragraph.
|
|
1168
|
+
const parsedDoc = new DOMParser().parseFromString(paragraph.textContent, 'text/html');
|
|
1282
1169
|
const parsedParagraph = parsedDoc.body.querySelector('p');
|
|
1283
1170
|
if (parsedParagraph) {
|
|
1284
1171
|
const paragraphEl = this.document.createElement('p');
|
|
1285
1172
|
paragraphEl.innerHTML = parsedParagraph.innerHTML;
|
|
1286
|
-
paragraphEl.setAttribute('id', normalizeID(paragraph.
|
|
1173
|
+
paragraphEl.setAttribute('id', normalizeID(paragraph.attrs.id));
|
|
1287
1174
|
element.appendChild(paragraphEl);
|
|
1288
1175
|
}
|
|
1289
1176
|
};
|
|
1290
1177
|
this.appendFootnoteToElement = (footnote, element) => {
|
|
1291
1178
|
const footnoteEl = this.document.createElement('fn');
|
|
1292
|
-
footnoteEl.setAttribute('id', normalizeID(footnote.
|
|
1293
|
-
|
|
1179
|
+
footnoteEl.setAttribute('id', normalizeID(footnote.attrs.id));
|
|
1180
|
+
if (!footnote.textContent.includes('<p>')) {
|
|
1181
|
+
const p = this.document.createElement('p');
|
|
1182
|
+
p.innerHTML = footnote.textContent;
|
|
1183
|
+
footnoteEl.appendChild(p);
|
|
1184
|
+
}
|
|
1185
|
+
else {
|
|
1186
|
+
footnoteEl.innerHTML = footnote.textContent;
|
|
1187
|
+
}
|
|
1294
1188
|
element.appendChild(footnoteEl);
|
|
1295
1189
|
};
|
|
1296
|
-
this.fixBody = (body
|
|
1297
|
-
|
|
1190
|
+
this.fixBody = (body) => {
|
|
1191
|
+
this.manuscriptNode.descendants((node) => {
|
|
1298
1192
|
if (node.attrs.id) {
|
|
1299
1193
|
if (node.attrs.titleSuppressed) {
|
|
1300
1194
|
const title = body.querySelector(`#${normalizeID(node.attrs.id)} > title`);
|
|
@@ -1312,7 +1206,7 @@ class JATSExporter {
|
|
|
1312
1206
|
label.remove();
|
|
1313
1207
|
}
|
|
1314
1208
|
}
|
|
1315
|
-
if ((0,
|
|
1209
|
+
if ((0, transformer_1.isNodeType)(node, 'general_table_footnote')) {
|
|
1316
1210
|
const generalTableFootnote = body.querySelector(`#${normalizeID(node.attrs.id)}`);
|
|
1317
1211
|
if (generalTableFootnote) {
|
|
1318
1212
|
Array.from(generalTableFootnote.childNodes).forEach((cn) => {
|
|
@@ -1321,7 +1215,7 @@ class JATSExporter {
|
|
|
1321
1215
|
generalTableFootnote.remove();
|
|
1322
1216
|
}
|
|
1323
1217
|
}
|
|
1324
|
-
if ((0,
|
|
1218
|
+
if ((0, transformer_1.isNodeType)(node, 'table_element')) {
|
|
1325
1219
|
const tableElement = body.querySelector(`#${normalizeID(node.attrs.id)}`);
|
|
1326
1220
|
if (tableElement) {
|
|
1327
1221
|
for (const childNode of tableElement.childNodes) {
|
|
@@ -1422,6 +1316,23 @@ class JATSExporter {
|
|
|
1422
1316
|
}
|
|
1423
1317
|
body.removeChild(container);
|
|
1424
1318
|
};
|
|
1319
|
+
this.moveAwards = (front, body) => {
|
|
1320
|
+
const awardGroups = body.querySelectorAll(':scope > award-group');
|
|
1321
|
+
if (!awardGroups.length) {
|
|
1322
|
+
return;
|
|
1323
|
+
}
|
|
1324
|
+
const fundingGroup = this.document.createElement('funding-group');
|
|
1325
|
+
awardGroups.forEach((award) => {
|
|
1326
|
+
fundingGroup.appendChild(award);
|
|
1327
|
+
});
|
|
1328
|
+
const articleMeta = front.querySelector(':scope > article-meta');
|
|
1329
|
+
if (articleMeta) {
|
|
1330
|
+
const insertBeforeElement = articleMeta.querySelector(':scope > support-group, :scope > conference, :scope > counts, :scope > custom-meta-group');
|
|
1331
|
+
insertBeforeElement
|
|
1332
|
+
? articleMeta.insertBefore(fundingGroup, insertBeforeElement)
|
|
1333
|
+
: articleMeta.appendChild(fundingGroup);
|
|
1334
|
+
}
|
|
1335
|
+
};
|
|
1425
1336
|
this.moveAbstracts = (front, body) => {
|
|
1426
1337
|
const container = body.querySelector(':scope > sec[sec-type="abstracts"]');
|
|
1427
1338
|
let abstractSections;
|
|
@@ -1555,36 +1466,36 @@ class JATSExporter {
|
|
|
1555
1466
|
};
|
|
1556
1467
|
this.buildContributorName = (contributor) => {
|
|
1557
1468
|
const name = this.document.createElement('name');
|
|
1558
|
-
if (contributor.bibliographicName.family) {
|
|
1469
|
+
if (contributor.attrs.bibliographicName.family) {
|
|
1559
1470
|
const surname = this.document.createElement('surname');
|
|
1560
|
-
surname.textContent = contributor.bibliographicName.family;
|
|
1471
|
+
surname.textContent = contributor.attrs.bibliographicName.family;
|
|
1561
1472
|
name.appendChild(surname);
|
|
1562
1473
|
}
|
|
1563
|
-
if (contributor.bibliographicName.given) {
|
|
1474
|
+
if (contributor.attrs.bibliographicName.given) {
|
|
1564
1475
|
const givenNames = this.document.createElement('given-names');
|
|
1565
|
-
givenNames.textContent = contributor.bibliographicName.given;
|
|
1476
|
+
givenNames.textContent = contributor.attrs.bibliographicName.given;
|
|
1566
1477
|
name.appendChild(givenNames);
|
|
1567
1478
|
}
|
|
1568
1479
|
return name;
|
|
1569
1480
|
};
|
|
1570
1481
|
}
|
|
1571
|
-
generateCitations(
|
|
1482
|
+
generateCitations() {
|
|
1572
1483
|
const nodes = [];
|
|
1573
|
-
|
|
1484
|
+
this.manuscriptNode.descendants((node) => {
|
|
1574
1485
|
if ((0, schema_1.isCitationNode)(node)) {
|
|
1575
1486
|
nodes.push(node);
|
|
1576
1487
|
}
|
|
1577
1488
|
});
|
|
1578
1489
|
return (0, exports.buildCitations)(nodes);
|
|
1579
1490
|
}
|
|
1580
|
-
generateCitationTexts(
|
|
1491
|
+
generateCitationTexts(csl, manuscriptID) {
|
|
1581
1492
|
this.citationTexts = new Map();
|
|
1582
1493
|
this.citationProvider = new library_1.CitationProvider({
|
|
1583
|
-
getLibraryItem:
|
|
1494
|
+
getLibraryItem: this.getLibraryItem(manuscriptID),
|
|
1584
1495
|
locale: csl.locale,
|
|
1585
1496
|
citationStyle: csl.style,
|
|
1586
1497
|
});
|
|
1587
|
-
const citations = this.generateCitations(
|
|
1498
|
+
const citations = this.generateCitations();
|
|
1588
1499
|
this.citationProvider.rebuildState(citations).forEach(([id, , output]) => {
|
|
1589
1500
|
this.citationTexts.set(id, output);
|
|
1590
1501
|
});
|
|
@@ -1611,72 +1522,50 @@ class JATSExporter {
|
|
|
1611
1522
|
return mathml;
|
|
1612
1523
|
}
|
|
1613
1524
|
}
|
|
1614
|
-
appendModelsToAuthorNotes(authorNotesEl,
|
|
1615
|
-
const
|
|
1616
|
-
const usedCorrespondings = this.getUsedCorrespondings(
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
}
|
|
1622
|
-
switch (model.objectType) {
|
|
1623
|
-
case json_schema_1.ObjectTypes.ParagraphElement:
|
|
1624
|
-
this.appendParagraphToElement(model, authorNotesEl);
|
|
1525
|
+
appendModelsToAuthorNotes(authorNotesEl, authorNotesNode) {
|
|
1526
|
+
const contributorsNodes = (0, prosemirror_utils_1.findChildrenByType)(this.manuscriptNode, schema_1.schema.nodes.contributor).map((result) => result.node);
|
|
1527
|
+
const usedCorrespondings = this.getUsedCorrespondings(contributorsNodes);
|
|
1528
|
+
authorNotesNode.descendants((node) => {
|
|
1529
|
+
switch (node.type) {
|
|
1530
|
+
case schema_1.schema.nodes.paragraph:
|
|
1531
|
+
this.appendParagraphToElement(node, authorNotesEl);
|
|
1625
1532
|
break;
|
|
1626
|
-
case
|
|
1627
|
-
this.appendFootnoteToElement(
|
|
1533
|
+
case schema_1.schema.nodes.footnote:
|
|
1534
|
+
this.appendFootnoteToElement(node, authorNotesEl);
|
|
1628
1535
|
break;
|
|
1629
|
-
case
|
|
1630
|
-
if (usedCorrespondings.includes(
|
|
1631
|
-
this.appendCorrespondingToElement(
|
|
1536
|
+
case schema_1.schema.nodes.corresp:
|
|
1537
|
+
if (usedCorrespondings.includes(node)) {
|
|
1538
|
+
this.appendCorrespondingToElement(node, authorNotesEl);
|
|
1632
1539
|
}
|
|
1633
1540
|
break;
|
|
1634
1541
|
}
|
|
1542
|
+
return false;
|
|
1635
1543
|
});
|
|
1636
1544
|
}
|
|
1637
1545
|
getUsedCorrespondings(contributors) {
|
|
1638
1546
|
return contributors
|
|
1639
|
-
.flatMap((c) => { var _a; return (_a = c.corresp) !== null && _a !== void 0 ? _a : []; })
|
|
1640
|
-
.map((corresp) =>
|
|
1547
|
+
.flatMap((c) => { var _a; return (_a = c.attrs.corresp) !== null && _a !== void 0 ? _a : []; })
|
|
1548
|
+
.map((corresp) => {
|
|
1549
|
+
var _a;
|
|
1550
|
+
return (_a = (0, prosemirror_utils_1.findChildrenByAttr)(this.manuscriptNode, (attr) => attr.id === corresp.correspID)[0]) === null || _a === void 0 ? void 0 : _a.node;
|
|
1551
|
+
})
|
|
1641
1552
|
.filter((corresp) => !!corresp);
|
|
1642
1553
|
}
|
|
1643
1554
|
buildKeywords(articleMeta) {
|
|
1644
|
-
const
|
|
1645
|
-
|
|
1646
|
-
keywords.forEach((keyword) => {
|
|
1647
|
-
const containedGroup = keyword.containedGroup || '';
|
|
1648
|
-
const group = keywordGroups.get(containedGroup);
|
|
1649
|
-
if (group) {
|
|
1650
|
-
group.push(keyword);
|
|
1651
|
-
}
|
|
1652
|
-
else {
|
|
1653
|
-
keywordGroups.set(containedGroup, [keyword]);
|
|
1654
|
-
}
|
|
1655
|
-
});
|
|
1656
|
-
for (const [groupID, keywords] of keywordGroups) {
|
|
1657
|
-
const keywordGroup = (this.modelMap.get(groupID) || {});
|
|
1555
|
+
const keywordGroups = (0, prosemirror_utils_1.findChildrenByType)(this.manuscriptNode, schema_1.schema.nodes.keyword_group).map((result) => result.node);
|
|
1556
|
+
keywordGroups.forEach((group) => {
|
|
1658
1557
|
const kwdGroup = this.document.createElement('kwd-group');
|
|
1659
|
-
if (
|
|
1660
|
-
kwdGroup.setAttribute('kwd-group-type',
|
|
1661
|
-
}
|
|
1662
|
-
if (keywordGroup.label) {
|
|
1663
|
-
const label = this.document.createElement('label');
|
|
1664
|
-
label.textContent = keywordGroup.label;
|
|
1665
|
-
kwdGroup.appendChild(label);
|
|
1666
|
-
}
|
|
1667
|
-
if (keywordGroup.title) {
|
|
1668
|
-
const title = this.document.createElement('title');
|
|
1669
|
-
title.textContent = keywordGroup.title;
|
|
1670
|
-
kwdGroup.appendChild(title);
|
|
1558
|
+
if (group.attrs.type) {
|
|
1559
|
+
kwdGroup.setAttribute('kwd-group-type', group.attrs.type);
|
|
1671
1560
|
}
|
|
1672
1561
|
articleMeta.appendChild(kwdGroup);
|
|
1673
|
-
|
|
1562
|
+
group.content.forEach((keyword) => {
|
|
1674
1563
|
const kwd = this.document.createElement('kwd');
|
|
1675
|
-
kwd.textContent = keyword.
|
|
1564
|
+
kwd.textContent = keyword.textContent;
|
|
1676
1565
|
kwdGroup.appendChild(kwd);
|
|
1677
|
-
}
|
|
1566
|
+
});
|
|
1678
1567
|
articleMeta.appendChild(kwdGroup);
|
|
1679
|
-
}
|
|
1568
|
+
});
|
|
1680
1569
|
}
|
|
1681
1570
|
moveCoiStatementToAuthorNotes(back, front) {
|
|
1682
1571
|
const fnGroups = back.querySelectorAll('fn-group');
|
|
@@ -1724,7 +1613,7 @@ class JATSExporter {
|
|
|
1724
1613
|
footnotes.forEach((fn) => {
|
|
1725
1614
|
const fnType = fn.getAttribute('fn-type');
|
|
1726
1615
|
if (fnType) {
|
|
1727
|
-
fn.setAttribute('fn-type', (0,
|
|
1616
|
+
fn.setAttribute('fn-type', (0, transformer_1.chooseJatsFnType)(fnType));
|
|
1728
1617
|
}
|
|
1729
1618
|
});
|
|
1730
1619
|
}
|