@manuscripts/transform 2.1.2 → 2.1.3-LEAN-3376-0
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-transformations.js +3 -1
- package/dist/cjs/jats/importer/jats-front-parser.js +44 -1
- package/dist/cjs/jats/importer/parse-jats-article.js +5 -7
- package/dist/cjs/jats/jats-exporter.js +33 -48
- package/dist/cjs/schema/index.js +2 -0
- package/dist/cjs/schema/nodes/author_notes.js +27 -0
- package/dist/cjs/schema/nodes/contributors.js +1 -1
- package/dist/cjs/transformer/builders.js +7 -1
- package/dist/cjs/transformer/decode.js +13 -1
- package/dist/cjs/transformer/encode.js +3 -0
- package/dist/cjs/transformer/node-types.js +2 -0
- package/dist/es/jats/importer/jats-body-transformations.js +3 -1
- package/dist/es/jats/importer/jats-front-parser.js +45 -2
- package/dist/es/jats/importer/parse-jats-article.js +5 -7
- package/dist/es/jats/jats-exporter.js +34 -49
- package/dist/es/schema/index.js +2 -0
- package/dist/es/schema/nodes/author_notes.js +24 -0
- package/dist/es/schema/nodes/contributors.js +1 -1
- package/dist/es/transformer/builders.js +5 -0
- package/dist/es/transformer/decode.js +13 -1
- package/dist/es/transformer/encode.js +3 -0
- package/dist/es/transformer/node-types.js +2 -0
- package/dist/types/jats/importer/jats-front-parser.d.ts +11 -1
- package/dist/types/jats/jats-exporter.d.ts +2 -0
- package/dist/types/schema/nodes/author_notes.d.ts +25 -0
- package/dist/types/schema/types.d.ts +1 -1
- package/dist/types/transformer/builders.d.ts +2 -1
- package/package.json +4 -4
|
@@ -202,7 +202,9 @@ exports.jatsBodyTransformations = {
|
|
|
202
202
|
}
|
|
203
203
|
},
|
|
204
204
|
moveFootnotes(doc, group, createElement) {
|
|
205
|
-
const footnotes = [
|
|
205
|
+
const footnotes = [
|
|
206
|
+
...doc.querySelectorAll('fn:not(table-wrap-foot fn, author-notes fn)'),
|
|
207
|
+
];
|
|
206
208
|
const footnotesSection = doc.querySelector('sec[sec-type="endnotes"]');
|
|
207
209
|
const footnotesSectionGroup = footnotesSection === null || footnotesSection === void 0 ? void 0 : footnotesSection.querySelector('fn-group');
|
|
208
210
|
const containingGroup = footnotesSectionGroup || createElement('fn-group');
|
|
@@ -45,6 +45,11 @@ exports.jatsFrontParser = {
|
|
|
45
45
|
}
|
|
46
46
|
return titles;
|
|
47
47
|
},
|
|
48
|
+
parseDOI(front) {
|
|
49
|
+
var _a;
|
|
50
|
+
const doi = front === null || front === void 0 ? void 0 : front.querySelector('article-meta > article-id[pub-id-type="doi"]');
|
|
51
|
+
return (_a = doi === null || doi === void 0 ? void 0 : doi.textContent) !== null && _a !== void 0 ? _a : undefined;
|
|
52
|
+
},
|
|
48
53
|
parseCounts(counts) {
|
|
49
54
|
var _a, _b, _c, _d, _e;
|
|
50
55
|
if (counts) {
|
|
@@ -174,7 +179,45 @@ exports.jatsFrontParser = {
|
|
|
174
179
|
affiliationIDs,
|
|
175
180
|
};
|
|
176
181
|
},
|
|
177
|
-
parseAuthorNotes(
|
|
182
|
+
parseAuthorNotes(element) {
|
|
183
|
+
if (!element) {
|
|
184
|
+
return {
|
|
185
|
+
footnotes: [],
|
|
186
|
+
footnoteIDs: new Map(),
|
|
187
|
+
authorNotes: [],
|
|
188
|
+
authorNotesParagraphs: [],
|
|
189
|
+
correspondingIDs: new Map(),
|
|
190
|
+
correspondingList: [],
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
const { footnotes, footnoteIDs } = this.parseFootnotes([
|
|
194
|
+
...element.querySelectorAll('fn:not([fn-type])'),
|
|
195
|
+
]);
|
|
196
|
+
const authorNotesParagraphs = this.parseParagraphs([
|
|
197
|
+
...element.querySelectorAll(':scope > p'),
|
|
198
|
+
]);
|
|
199
|
+
const { correspondingList, correspondingIDs } = this.parseCorresp([
|
|
200
|
+
...element.querySelectorAll('corresp'),
|
|
201
|
+
]);
|
|
202
|
+
const authorNotes = [
|
|
203
|
+
(0, transformer_1.buildAuthorNotes)([
|
|
204
|
+
...footnoteIDs.values(),
|
|
205
|
+
...authorNotesParagraphs.map((p) => p._id),
|
|
206
|
+
]),
|
|
207
|
+
];
|
|
208
|
+
return {
|
|
209
|
+
footnotes,
|
|
210
|
+
footnoteIDs,
|
|
211
|
+
authorNotesParagraphs,
|
|
212
|
+
authorNotes,
|
|
213
|
+
correspondingIDs,
|
|
214
|
+
correspondingList,
|
|
215
|
+
};
|
|
216
|
+
},
|
|
217
|
+
parseParagraphs(elements) {
|
|
218
|
+
return elements.map((p) => (0, transformer_1.buildParagraph)(p.innerHTML));
|
|
219
|
+
},
|
|
220
|
+
parseFootnotes(elements) {
|
|
178
221
|
const footnoteIDs = new Map();
|
|
179
222
|
const footnotes = elements.map((element) => {
|
|
180
223
|
const fn = (0, transformer_1.buildFootnote)('', element.innerHTML);
|
|
@@ -31,25 +31,23 @@ const parseJATSFront = (doc, front) => {
|
|
|
31
31
|
const createElement = createElementFn(doc);
|
|
32
32
|
const journal = jats_front_parser_1.jatsFrontParser.parseJournal(front.querySelector('journal-meta'));
|
|
33
33
|
const titles = jats_front_parser_1.jatsFrontParser.parseTitles(front.querySelector('article-meta > title-group'), createElement);
|
|
34
|
+
const DOI = jats_front_parser_1.jatsFrontParser.parseDOI(front);
|
|
34
35
|
const { affiliations, affiliationIDs } = jats_front_parser_1.jatsFrontParser.parseAffiliations([
|
|
35
36
|
...front.querySelectorAll('article-meta > contrib-group > aff'),
|
|
36
37
|
]);
|
|
37
|
-
const { footnotes, footnoteIDs } = jats_front_parser_1.jatsFrontParser.parseAuthorNotes(
|
|
38
|
-
...front.querySelectorAll('article-meta > author-notes > fn:not([fn-type])'),
|
|
39
|
-
]);
|
|
40
|
-
const { correspondingList, correspondingIDs } = jats_front_parser_1.jatsFrontParser.parseCorresp([
|
|
41
|
-
...front.querySelectorAll('article-meta > author-notes > corresp'),
|
|
42
|
-
]);
|
|
38
|
+
const { footnotes, footnoteIDs, authorNotes, authorNotesParagraphs, correspondingIDs, correspondingList, } = jats_front_parser_1.jatsFrontParser.parseAuthorNotes(front.querySelector('article-meta > author-notes'));
|
|
43
39
|
const authors = jats_front_parser_1.jatsFrontParser.parseContributors([
|
|
44
40
|
...front.querySelectorAll('article-meta > contrib-group > contrib[contrib-type="author"]'),
|
|
45
41
|
], affiliationIDs, footnoteIDs, correspondingIDs);
|
|
46
42
|
const history = jats_front_parser_1.jatsFrontParser.parseDates(front.querySelector('article-meta > history'));
|
|
47
43
|
const counts = jats_front_parser_1.jatsFrontParser.parseCounts(front.querySelector('article-meta counts'));
|
|
48
|
-
const manuscript = Object.assign(Object.assign(Object.assign({}, (0, builders_1.buildManuscript)()), counts), history);
|
|
44
|
+
const manuscript = Object.assign(Object.assign(Object.assign(Object.assign({}, (0, builders_1.buildManuscript)()), counts), history), { DOI });
|
|
49
45
|
return generateIDs([
|
|
50
46
|
manuscript,
|
|
51
47
|
titles,
|
|
52
48
|
journal,
|
|
49
|
+
...authorNotesParagraphs,
|
|
50
|
+
...authorNotes,
|
|
53
51
|
...footnotes,
|
|
54
52
|
...authors,
|
|
55
53
|
...affiliations,
|
|
@@ -248,7 +248,7 @@ class JATSExporter {
|
|
|
248
248
|
}
|
|
249
249
|
};
|
|
250
250
|
this.buildFront = (doi, id, links) => {
|
|
251
|
-
var _a, _b, _c, _d;
|
|
251
|
+
var _a, _b, _c, _d, _e;
|
|
252
252
|
const manuscript = (0, project_bundle_1.findManuscript)(this.modelMap);
|
|
253
253
|
const titles = (0, project_bundle_1.findTitles)(this.modelMap);
|
|
254
254
|
const front = this.document.createElement('front');
|
|
@@ -311,10 +311,10 @@ class JATSExporter {
|
|
|
311
311
|
articleID.textContent = id;
|
|
312
312
|
articleMeta.appendChild(articleID);
|
|
313
313
|
}
|
|
314
|
-
if (doi) {
|
|
314
|
+
if (doi || manuscript.DOI) {
|
|
315
315
|
const articleID = this.document.createElement('article-id');
|
|
316
316
|
articleID.setAttribute('pub-id-type', 'doi');
|
|
317
|
-
articleID.textContent = doi;
|
|
317
|
+
articleID.textContent = (_a = manuscript.DOI) !== null && _a !== void 0 ? _a : doi;
|
|
318
318
|
articleMeta.appendChild(articleID);
|
|
319
319
|
}
|
|
320
320
|
const titleGroup = this.document.createElement('title-group');
|
|
@@ -349,14 +349,14 @@ class JATSExporter {
|
|
|
349
349
|
for (const supplement of supplements) {
|
|
350
350
|
const supplementaryMaterial = this.document.createElement('supplementary-material');
|
|
351
351
|
supplementaryMaterial.setAttribute('id', normalizeID(supplement._id));
|
|
352
|
-
supplementaryMaterial.setAttributeNS(XLINK_NAMESPACE, 'href', (
|
|
353
|
-
const mimeType = (
|
|
354
|
-
const mimeSubType = (
|
|
352
|
+
supplementaryMaterial.setAttributeNS(XLINK_NAMESPACE, 'href', (_b = supplement.href) !== null && _b !== void 0 ? _b : '');
|
|
353
|
+
const mimeType = (_c = supplement.MIME) === null || _c === void 0 ? void 0 : _c.split('/')[0];
|
|
354
|
+
const mimeSubType = (_d = supplement.MIME) === null || _d === void 0 ? void 0 : _d.split('/')[1];
|
|
355
355
|
supplementaryMaterial.setAttribute('mimetype', mimeType !== null && mimeType !== void 0 ? mimeType : '');
|
|
356
356
|
supplementaryMaterial.setAttribute('mime-subtype', mimeSubType !== null && mimeSubType !== void 0 ? mimeSubType : '');
|
|
357
357
|
const caption = this.document.createElement('caption');
|
|
358
358
|
const title = this.document.createElement('title');
|
|
359
|
-
title.textContent = (
|
|
359
|
+
title.textContent = (_e = supplement.title) !== null && _e !== void 0 ? _e : '';
|
|
360
360
|
caption.append(title);
|
|
361
361
|
supplementaryMaterial.append(caption);
|
|
362
362
|
articleMeta.append(supplementaryMaterial);
|
|
@@ -614,6 +614,7 @@ class JATSExporter {
|
|
|
614
614
|
this.createSerializer = () => {
|
|
615
615
|
const getModel = (id) => id ? this.modelMap.get(id) : undefined;
|
|
616
616
|
const nodes = {
|
|
617
|
+
author_notes: () => ['author-notes', 0],
|
|
617
618
|
title: () => '',
|
|
618
619
|
affiliations: () => '',
|
|
619
620
|
contributors: () => '',
|
|
@@ -1034,6 +1035,7 @@ class JATSExporter {
|
|
|
1034
1035
|
}
|
|
1035
1036
|
};
|
|
1036
1037
|
this.buildContributors = (articleMeta) => {
|
|
1038
|
+
var _a;
|
|
1037
1039
|
const contributors = this.models.filter(isContributor);
|
|
1038
1040
|
const authorContributors = contributors
|
|
1039
1041
|
.filter((contributor) => contributor.role === 'author')
|
|
@@ -1252,49 +1254,20 @@ class JATSExporter {
|
|
|
1252
1254
|
}
|
|
1253
1255
|
});
|
|
1254
1256
|
}
|
|
1255
|
-
const
|
|
1256
|
-
|
|
1257
|
-
if (contributor.footnote) {
|
|
1258
|
-
const ids = contributor.footnote.map((note) => {
|
|
1259
|
-
return note.noteID;
|
|
1260
|
-
});
|
|
1261
|
-
noteIDs.push(...ids);
|
|
1262
|
-
}
|
|
1263
|
-
if (contributor.corresp) {
|
|
1264
|
-
const ids = contributor.corresp.map((corresp) => {
|
|
1265
|
-
return corresp.correspID;
|
|
1266
|
-
});
|
|
1267
|
-
noteIDs.push(...ids);
|
|
1268
|
-
}
|
|
1269
|
-
}
|
|
1270
|
-
const footnotes = [];
|
|
1271
|
-
footnotes.push(...this.models.filter((0, object_types_1.hasObjectType)(json_schema_1.ObjectTypes.Footnote)));
|
|
1272
|
-
const correspodings = [];
|
|
1273
|
-
correspodings.push(...this.models.filter((0, object_types_1.hasObjectType)(json_schema_1.ObjectTypes.Corresponding)));
|
|
1274
|
-
if (footnotes || correspodings) {
|
|
1257
|
+
const authorNotes = (_a = (0, json_schema_1.getModelsByType)(this.modelMap, json_schema_1.ObjectTypes.AuthorNotes)) === null || _a === void 0 ? void 0 : _a[0];
|
|
1258
|
+
if (authorNotes) {
|
|
1275
1259
|
const authorNotesEl = this.document.createElement('author-notes');
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
authorNotesEl.appendChild(authorFootNote);
|
|
1287
|
-
});
|
|
1288
|
-
usedCorrespodings.forEach((corresponding) => {
|
|
1289
|
-
const correspondingEl = this.document.createElement('corresp');
|
|
1290
|
-
correspondingEl.setAttribute('id', normalizeID(corresponding._id));
|
|
1291
|
-
if (corresponding.label) {
|
|
1292
|
-
const labelEl = this.document.createElement('label');
|
|
1293
|
-
labelEl.textContent = corresponding.label;
|
|
1294
|
-
correspondingEl.appendChild(labelEl);
|
|
1260
|
+
authorNotes.containedObjectIDs.forEach((id) => {
|
|
1261
|
+
const model = this.modelMap.get(id);
|
|
1262
|
+
if (!model) {
|
|
1263
|
+
return;
|
|
1264
|
+
}
|
|
1265
|
+
if (id.startsWith('MPParagraphElement')) {
|
|
1266
|
+
this.appendParagraphToElement(model, authorNotesEl);
|
|
1267
|
+
}
|
|
1268
|
+
else if (id.startsWith('MPFootnote')) {
|
|
1269
|
+
this.appendFootnoteToElement(model, authorNotesEl);
|
|
1295
1270
|
}
|
|
1296
|
-
correspondingEl.append(corresponding.contents);
|
|
1297
|
-
authorNotesEl.appendChild(correspondingEl);
|
|
1298
1271
|
});
|
|
1299
1272
|
if (authorNotesEl.childNodes.length > 0) {
|
|
1300
1273
|
articleMeta.insertBefore(authorNotesEl, contribGroup.nextSibling);
|
|
@@ -1302,6 +1275,18 @@ class JATSExporter {
|
|
|
1302
1275
|
}
|
|
1303
1276
|
}
|
|
1304
1277
|
};
|
|
1278
|
+
this.appendParagraphToElement = (paragraph, element) => {
|
|
1279
|
+
const paragraphEl = this.document.createElement('p');
|
|
1280
|
+
paragraphEl.setAttribute('id', normalizeID(paragraph._id));
|
|
1281
|
+
paragraphEl.innerHTML = paragraph.contents;
|
|
1282
|
+
element.appendChild(paragraphEl);
|
|
1283
|
+
};
|
|
1284
|
+
this.appendFootnoteToElement = (footnote, element) => {
|
|
1285
|
+
const footnoteEl = this.document.createElement('fn');
|
|
1286
|
+
footnoteEl.setAttribute('id', normalizeID(footnote._id));
|
|
1287
|
+
footnoteEl.innerHTML = footnote.contents;
|
|
1288
|
+
element.appendChild(footnoteEl);
|
|
1289
|
+
};
|
|
1305
1290
|
this.fixBody = (body, fragment) => {
|
|
1306
1291
|
fragment.descendants((node) => {
|
|
1307
1292
|
if (node.attrs.id) {
|
package/dist/cjs/schema/index.js
CHANGED
|
@@ -36,6 +36,7 @@ const abstracts_1 = require("./nodes/abstracts");
|
|
|
36
36
|
const affiliation_1 = require("./nodes/affiliation");
|
|
37
37
|
const affiliations_1 = require("./nodes/affiliations");
|
|
38
38
|
const attribution_1 = require("./nodes/attribution");
|
|
39
|
+
const author_notes_1 = require("./nodes/author_notes");
|
|
39
40
|
const backmatter_1 = require("./nodes/backmatter");
|
|
40
41
|
const bibliography_element_1 = require("./nodes/bibliography_element");
|
|
41
42
|
const bibliography_item_1 = require("./nodes/bibliography_item");
|
|
@@ -230,5 +231,6 @@ exports.schema = new prosemirror_model_1.Schema({
|
|
|
230
231
|
contributors: contributors_1.contributors,
|
|
231
232
|
supplements: supplements_1.supplements,
|
|
232
233
|
supplement: supplement_1.supplement,
|
|
234
|
+
author_notes: author_notes_1.authorNotes,
|
|
233
235
|
},
|
|
234
236
|
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* © 2019 Atypon Systems LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.authorNotes = void 0;
|
|
19
|
+
exports.authorNotes = {
|
|
20
|
+
attrs: {
|
|
21
|
+
id: { default: '' },
|
|
22
|
+
dataTracked: { default: null },
|
|
23
|
+
},
|
|
24
|
+
content: '(footnote | paragraph)+',
|
|
25
|
+
group: 'block element',
|
|
26
|
+
toDOM: () => ['author-notes', 0],
|
|
27
|
+
};
|
|
@@ -18,7 +18,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
18
18
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
19
|
};
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.buildTitles = exports.buildElementsOrder = exports.auxiliaryObjectTypes = exports.buildJournal = exports.buildAttribution = exports.buildContributorRole = exports.buildContribution = exports.buildColor = exports.buildParagraph = exports.buildSection = exports.buildCorresp = exports.buildFootnotesOrder = exports.buildFootnote = exports.buildInlineMathFragment = exports.buildNote = exports.buildComment = exports.buildSupplementaryMaterial = exports.buildAffiliation = exports.buildFigure = exports.buildKeywordGroup = exports.buildKeyword = exports.buildBibliographyElement = exports.buildBibliographicDate = exports.buildBibliographicName = exports.buildBibliographyItem = exports.buildContributor = exports.buildManuscript = exports.buildProject = void 0;
|
|
21
|
+
exports.buildTitles = exports.buildElementsOrder = exports.auxiliaryObjectTypes = exports.buildJournal = exports.buildAttribution = exports.buildContributorRole = exports.buildContribution = exports.buildColor = exports.buildParagraph = exports.buildSection = exports.buildCorresp = exports.buildFootnotesOrder = exports.buildAuthorNotes = exports.buildFootnote = exports.buildInlineMathFragment = exports.buildNote = exports.buildComment = exports.buildSupplementaryMaterial = exports.buildAffiliation = exports.buildFigure = exports.buildKeywordGroup = exports.buildKeyword = exports.buildBibliographyElement = exports.buildBibliographicDate = exports.buildBibliographicName = exports.buildBibliographyItem = exports.buildContributor = exports.buildManuscript = exports.buildProject = void 0;
|
|
22
22
|
const json_schema_1 = require("@manuscripts/json-schema");
|
|
23
23
|
const w3c_xmlserializer_1 = __importDefault(require("w3c-xmlserializer"));
|
|
24
24
|
const schema_1 = require("../schema");
|
|
@@ -130,6 +130,12 @@ const buildFootnote = (containingObject, contents, kind = 'footnote') => ({
|
|
|
130
130
|
kind,
|
|
131
131
|
});
|
|
132
132
|
exports.buildFootnote = buildFootnote;
|
|
133
|
+
const buildAuthorNotes = (containedObjectIDs) => ({
|
|
134
|
+
_id: (0, id_1.generateID)(json_schema_1.ObjectTypes.AuthorNotes),
|
|
135
|
+
objectType: json_schema_1.ObjectTypes.AuthorNotes,
|
|
136
|
+
containedObjectIDs: containedObjectIDs,
|
|
137
|
+
});
|
|
138
|
+
exports.buildAuthorNotes = buildAuthorNotes;
|
|
133
139
|
const buildFootnotesOrder = (footnotesList, containedObjectID) => ({
|
|
134
140
|
_id: (0, id_1.generateID)(json_schema_1.ObjectTypes.FootnotesOrder),
|
|
135
141
|
objectType: json_schema_1.ObjectTypes.FootnotesOrder,
|
|
@@ -62,6 +62,7 @@ const sortSectionsByPriority = (a, b) => a.priority === b.priority ? 0 : Number(
|
|
|
62
62
|
exports.sortSectionsByPriority = sortSectionsByPriority;
|
|
63
63
|
const getSections = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.Section).sort(exports.sortSectionsByPriority);
|
|
64
64
|
const getAffiliations = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.Affiliation);
|
|
65
|
+
const getAuthorNotes = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.AuthorNotes);
|
|
65
66
|
const getContributors = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.Contributor);
|
|
66
67
|
const getKeywordElements = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.KeywordsElement);
|
|
67
68
|
const getSupplements = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.Supplement);
|
|
@@ -91,7 +92,11 @@ class Decoder {
|
|
|
91
92
|
const contributors = getContributors(this.modelMap)
|
|
92
93
|
.map((c) => this.decode(c))
|
|
93
94
|
.filter(Boolean);
|
|
94
|
-
|
|
95
|
+
const authorNotes = getAuthorNotes(this.modelMap)
|
|
96
|
+
.map((authorNote) => this.decode(authorNote))
|
|
97
|
+
.filter(Boolean);
|
|
98
|
+
const content = [...contributors, ...authorNotes];
|
|
99
|
+
return schema_1.schema.nodes.contributors.createAndFill({}, content);
|
|
95
100
|
}
|
|
96
101
|
createKeywordsNode() {
|
|
97
102
|
const elements = getKeywordElements(this.modelMap)
|
|
@@ -492,6 +497,13 @@ class Decoder {
|
|
|
492
497
|
id: model._id,
|
|
493
498
|
}, content);
|
|
494
499
|
},
|
|
500
|
+
[json_schema_1.ObjectTypes.AuthorNotes]: (data) => {
|
|
501
|
+
const model = data;
|
|
502
|
+
const content = model.containedObjectIDs.map((id) => this.decode(this.modelMap.get(id)));
|
|
503
|
+
return schema_1.schema.nodes.author_notes.create({
|
|
504
|
+
id: model._id,
|
|
505
|
+
}, content);
|
|
506
|
+
},
|
|
495
507
|
[json_schema_1.ObjectTypes.Section]: (data) => {
|
|
496
508
|
const model = data;
|
|
497
509
|
const elements = [];
|
|
@@ -395,6 +395,9 @@ const encoders = {
|
|
|
395
395
|
table_element_footer: (node) => ({
|
|
396
396
|
containedObjectIDs: containedObjectIDs(node),
|
|
397
397
|
}),
|
|
398
|
+
author_notes: (node) => ({
|
|
399
|
+
containedObjectIDs: containedObjectIDs(node),
|
|
400
|
+
}),
|
|
398
401
|
footnotes_section: (node, parent, path, priority) => ({
|
|
399
402
|
category: (0, section_category_1.buildSectionCategory)(node),
|
|
400
403
|
priority: priority.value++,
|
|
@@ -62,6 +62,8 @@ exports.nodeTypesMap = new Map([
|
|
|
62
62
|
[schema_1.schema.nodes.affiliations, json_schema_1.ObjectTypes.Section],
|
|
63
63
|
[schema_1.schema.nodes.title, json_schema_1.ObjectTypes.Titles],
|
|
64
64
|
[schema_1.schema.nodes.supplement, json_schema_1.ObjectTypes.Supplement],
|
|
65
|
+
[schema_1.schema.nodes.author_notes, json_schema_1.ObjectTypes.AuthorNotes],
|
|
66
|
+
[schema_1.schema.nodes.corresp, json_schema_1.ObjectTypes.Corresponding],
|
|
65
67
|
]);
|
|
66
68
|
const isExecutableNodeType = (type) => (0, schema_1.hasGroup)(type, schema_1.GROUP_EXECUTABLE);
|
|
67
69
|
exports.isExecutableNodeType = isExecutableNodeType;
|
|
@@ -199,7 +199,9 @@ export const jatsBodyTransformations = {
|
|
|
199
199
|
}
|
|
200
200
|
},
|
|
201
201
|
moveFootnotes(doc, group, createElement) {
|
|
202
|
-
const footnotes = [
|
|
202
|
+
const footnotes = [
|
|
203
|
+
...doc.querySelectorAll('fn:not(table-wrap-foot fn, author-notes fn)'),
|
|
204
|
+
];
|
|
203
205
|
const footnotesSection = doc.querySelector('sec[sec-type="endnotes"]');
|
|
204
206
|
const footnotesSectionGroup = footnotesSection === null || footnotesSection === void 0 ? void 0 : footnotesSection.querySelector('fn-group');
|
|
205
207
|
const containingGroup = footnotesSectionGroup || createElement('fn-group');
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import debug from 'debug';
|
|
17
17
|
import { getTrimmedTextContent } from '../../lib/utils';
|
|
18
|
-
import { buildAffiliation, buildBibliographicName, buildContributor, buildCorresp, buildFootnote, buildJournal, buildTitles, } from '../../transformer';
|
|
18
|
+
import { buildAffiliation, buildAuthorNotes, buildBibliographicName, buildContributor, buildCorresp, buildFootnote, buildJournal, buildParagraph, buildTitles, } from '../../transformer';
|
|
19
19
|
import { parseJournalMeta } from './jats-journal-meta-parser';
|
|
20
20
|
import { htmlFromJatsNode } from './jats-parser-utils';
|
|
21
21
|
const warn = debug('manuscripts-transform');
|
|
@@ -39,6 +39,11 @@ export const jatsFrontParser = {
|
|
|
39
39
|
}
|
|
40
40
|
return titles;
|
|
41
41
|
},
|
|
42
|
+
parseDOI(front) {
|
|
43
|
+
var _a;
|
|
44
|
+
const doi = front === null || front === void 0 ? void 0 : front.querySelector('article-meta > article-id[pub-id-type="doi"]');
|
|
45
|
+
return (_a = doi === null || doi === void 0 ? void 0 : doi.textContent) !== null && _a !== void 0 ? _a : undefined;
|
|
46
|
+
},
|
|
42
47
|
parseCounts(counts) {
|
|
43
48
|
var _a, _b, _c, _d, _e;
|
|
44
49
|
if (counts) {
|
|
@@ -168,7 +173,45 @@ export const jatsFrontParser = {
|
|
|
168
173
|
affiliationIDs,
|
|
169
174
|
};
|
|
170
175
|
},
|
|
171
|
-
parseAuthorNotes(
|
|
176
|
+
parseAuthorNotes(element) {
|
|
177
|
+
if (!element) {
|
|
178
|
+
return {
|
|
179
|
+
footnotes: [],
|
|
180
|
+
footnoteIDs: new Map(),
|
|
181
|
+
authorNotes: [],
|
|
182
|
+
authorNotesParagraphs: [],
|
|
183
|
+
correspondingIDs: new Map(),
|
|
184
|
+
correspondingList: [],
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
const { footnotes, footnoteIDs } = this.parseFootnotes([
|
|
188
|
+
...element.querySelectorAll('fn:not([fn-type])'),
|
|
189
|
+
]);
|
|
190
|
+
const authorNotesParagraphs = this.parseParagraphs([
|
|
191
|
+
...element.querySelectorAll(':scope > p'),
|
|
192
|
+
]);
|
|
193
|
+
const { correspondingList, correspondingIDs } = this.parseCorresp([
|
|
194
|
+
...element.querySelectorAll('corresp'),
|
|
195
|
+
]);
|
|
196
|
+
const authorNotes = [
|
|
197
|
+
buildAuthorNotes([
|
|
198
|
+
...footnoteIDs.values(),
|
|
199
|
+
...authorNotesParagraphs.map((p) => p._id),
|
|
200
|
+
]),
|
|
201
|
+
];
|
|
202
|
+
return {
|
|
203
|
+
footnotes,
|
|
204
|
+
footnoteIDs,
|
|
205
|
+
authorNotesParagraphs,
|
|
206
|
+
authorNotes,
|
|
207
|
+
correspondingIDs,
|
|
208
|
+
correspondingList,
|
|
209
|
+
};
|
|
210
|
+
},
|
|
211
|
+
parseParagraphs(elements) {
|
|
212
|
+
return elements.map((p) => buildParagraph(p.innerHTML));
|
|
213
|
+
},
|
|
214
|
+
parseFootnotes(elements) {
|
|
172
215
|
const footnoteIDs = new Map();
|
|
173
216
|
const footnotes = elements.map((element) => {
|
|
174
217
|
const fn = buildFootnote('', element.innerHTML);
|
|
@@ -28,25 +28,23 @@ export const parseJATSFront = (doc, front) => {
|
|
|
28
28
|
const createElement = createElementFn(doc);
|
|
29
29
|
const journal = jatsFrontParser.parseJournal(front.querySelector('journal-meta'));
|
|
30
30
|
const titles = jatsFrontParser.parseTitles(front.querySelector('article-meta > title-group'), createElement);
|
|
31
|
+
const DOI = jatsFrontParser.parseDOI(front);
|
|
31
32
|
const { affiliations, affiliationIDs } = jatsFrontParser.parseAffiliations([
|
|
32
33
|
...front.querySelectorAll('article-meta > contrib-group > aff'),
|
|
33
34
|
]);
|
|
34
|
-
const { footnotes, footnoteIDs } = jatsFrontParser.parseAuthorNotes(
|
|
35
|
-
...front.querySelectorAll('article-meta > author-notes > fn:not([fn-type])'),
|
|
36
|
-
]);
|
|
37
|
-
const { correspondingList, correspondingIDs } = jatsFrontParser.parseCorresp([
|
|
38
|
-
...front.querySelectorAll('article-meta > author-notes > corresp'),
|
|
39
|
-
]);
|
|
35
|
+
const { footnotes, footnoteIDs, authorNotes, authorNotesParagraphs, correspondingIDs, correspondingList, } = jatsFrontParser.parseAuthorNotes(front.querySelector('article-meta > author-notes'));
|
|
40
36
|
const authors = jatsFrontParser.parseContributors([
|
|
41
37
|
...front.querySelectorAll('article-meta > contrib-group > contrib[contrib-type="author"]'),
|
|
42
38
|
], affiliationIDs, footnoteIDs, correspondingIDs);
|
|
43
39
|
const history = jatsFrontParser.parseDates(front.querySelector('article-meta > history'));
|
|
44
40
|
const counts = jatsFrontParser.parseCounts(front.querySelector('article-meta counts'));
|
|
45
|
-
const manuscript = Object.assign(Object.assign(Object.assign({}, buildManuscript()), counts), history);
|
|
41
|
+
const manuscript = Object.assign(Object.assign(Object.assign(Object.assign({}, buildManuscript()), counts), history), { DOI });
|
|
46
42
|
return generateIDs([
|
|
47
43
|
manuscript,
|
|
48
44
|
titles,
|
|
49
45
|
journal,
|
|
46
|
+
...authorNotesParagraphs,
|
|
47
|
+
...authorNotes,
|
|
50
48
|
...footnotes,
|
|
51
49
|
...authors,
|
|
52
50
|
...affiliations,
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { ObjectTypes, } from '@manuscripts/json-schema';
|
|
16
|
+
import { getModelsByType, ObjectTypes, } from '@manuscripts/json-schema';
|
|
17
17
|
import { CitationProvider } from '@manuscripts/library';
|
|
18
18
|
import debug from 'debug';
|
|
19
19
|
import { DOMParser, DOMSerializer } from 'prosemirror-model';
|
|
@@ -240,7 +240,7 @@ export class JATSExporter {
|
|
|
240
240
|
}
|
|
241
241
|
};
|
|
242
242
|
this.buildFront = (doi, id, links) => {
|
|
243
|
-
var _a, _b, _c, _d;
|
|
243
|
+
var _a, _b, _c, _d, _e;
|
|
244
244
|
const manuscript = findManuscript(this.modelMap);
|
|
245
245
|
const titles = findTitles(this.modelMap);
|
|
246
246
|
const front = this.document.createElement('front');
|
|
@@ -303,10 +303,10 @@ export class JATSExporter {
|
|
|
303
303
|
articleID.textContent = id;
|
|
304
304
|
articleMeta.appendChild(articleID);
|
|
305
305
|
}
|
|
306
|
-
if (doi) {
|
|
306
|
+
if (doi || manuscript.DOI) {
|
|
307
307
|
const articleID = this.document.createElement('article-id');
|
|
308
308
|
articleID.setAttribute('pub-id-type', 'doi');
|
|
309
|
-
articleID.textContent = doi;
|
|
309
|
+
articleID.textContent = (_a = manuscript.DOI) !== null && _a !== void 0 ? _a : doi;
|
|
310
310
|
articleMeta.appendChild(articleID);
|
|
311
311
|
}
|
|
312
312
|
const titleGroup = this.document.createElement('title-group');
|
|
@@ -341,14 +341,14 @@ export class JATSExporter {
|
|
|
341
341
|
for (const supplement of supplements) {
|
|
342
342
|
const supplementaryMaterial = this.document.createElement('supplementary-material');
|
|
343
343
|
supplementaryMaterial.setAttribute('id', normalizeID(supplement._id));
|
|
344
|
-
supplementaryMaterial.setAttributeNS(XLINK_NAMESPACE, 'href', (
|
|
345
|
-
const mimeType = (
|
|
346
|
-
const mimeSubType = (
|
|
344
|
+
supplementaryMaterial.setAttributeNS(XLINK_NAMESPACE, 'href', (_b = supplement.href) !== null && _b !== void 0 ? _b : '');
|
|
345
|
+
const mimeType = (_c = supplement.MIME) === null || _c === void 0 ? void 0 : _c.split('/')[0];
|
|
346
|
+
const mimeSubType = (_d = supplement.MIME) === null || _d === void 0 ? void 0 : _d.split('/')[1];
|
|
347
347
|
supplementaryMaterial.setAttribute('mimetype', mimeType !== null && mimeType !== void 0 ? mimeType : '');
|
|
348
348
|
supplementaryMaterial.setAttribute('mime-subtype', mimeSubType !== null && mimeSubType !== void 0 ? mimeSubType : '');
|
|
349
349
|
const caption = this.document.createElement('caption');
|
|
350
350
|
const title = this.document.createElement('title');
|
|
351
|
-
title.textContent = (
|
|
351
|
+
title.textContent = (_e = supplement.title) !== null && _e !== void 0 ? _e : '';
|
|
352
352
|
caption.append(title);
|
|
353
353
|
supplementaryMaterial.append(caption);
|
|
354
354
|
articleMeta.append(supplementaryMaterial);
|
|
@@ -606,6 +606,7 @@ export class JATSExporter {
|
|
|
606
606
|
this.createSerializer = () => {
|
|
607
607
|
const getModel = (id) => id ? this.modelMap.get(id) : undefined;
|
|
608
608
|
const nodes = {
|
|
609
|
+
author_notes: () => ['author-notes', 0],
|
|
609
610
|
title: () => '',
|
|
610
611
|
affiliations: () => '',
|
|
611
612
|
contributors: () => '',
|
|
@@ -1026,6 +1027,7 @@ export class JATSExporter {
|
|
|
1026
1027
|
}
|
|
1027
1028
|
};
|
|
1028
1029
|
this.buildContributors = (articleMeta) => {
|
|
1030
|
+
var _a;
|
|
1029
1031
|
const contributors = this.models.filter(isContributor);
|
|
1030
1032
|
const authorContributors = contributors
|
|
1031
1033
|
.filter((contributor) => contributor.role === 'author')
|
|
@@ -1244,49 +1246,20 @@ export class JATSExporter {
|
|
|
1244
1246
|
}
|
|
1245
1247
|
});
|
|
1246
1248
|
}
|
|
1247
|
-
const
|
|
1248
|
-
|
|
1249
|
-
if (contributor.footnote) {
|
|
1250
|
-
const ids = contributor.footnote.map((note) => {
|
|
1251
|
-
return note.noteID;
|
|
1252
|
-
});
|
|
1253
|
-
noteIDs.push(...ids);
|
|
1254
|
-
}
|
|
1255
|
-
if (contributor.corresp) {
|
|
1256
|
-
const ids = contributor.corresp.map((corresp) => {
|
|
1257
|
-
return corresp.correspID;
|
|
1258
|
-
});
|
|
1259
|
-
noteIDs.push(...ids);
|
|
1260
|
-
}
|
|
1261
|
-
}
|
|
1262
|
-
const footnotes = [];
|
|
1263
|
-
footnotes.push(...this.models.filter(hasObjectType(ObjectTypes.Footnote)));
|
|
1264
|
-
const correspodings = [];
|
|
1265
|
-
correspodings.push(...this.models.filter(hasObjectType(ObjectTypes.Corresponding)));
|
|
1266
|
-
if (footnotes || correspodings) {
|
|
1249
|
+
const authorNotes = (_a = getModelsByType(this.modelMap, ObjectTypes.AuthorNotes)) === null || _a === void 0 ? void 0 : _a[0];
|
|
1250
|
+
if (authorNotes) {
|
|
1267
1251
|
const authorNotesEl = this.document.createElement('author-notes');
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
authorNotesEl.appendChild(authorFootNote);
|
|
1279
|
-
});
|
|
1280
|
-
usedCorrespodings.forEach((corresponding) => {
|
|
1281
|
-
const correspondingEl = this.document.createElement('corresp');
|
|
1282
|
-
correspondingEl.setAttribute('id', normalizeID(corresponding._id));
|
|
1283
|
-
if (corresponding.label) {
|
|
1284
|
-
const labelEl = this.document.createElement('label');
|
|
1285
|
-
labelEl.textContent = corresponding.label;
|
|
1286
|
-
correspondingEl.appendChild(labelEl);
|
|
1252
|
+
authorNotes.containedObjectIDs.forEach((id) => {
|
|
1253
|
+
const model = this.modelMap.get(id);
|
|
1254
|
+
if (!model) {
|
|
1255
|
+
return;
|
|
1256
|
+
}
|
|
1257
|
+
if (id.startsWith('MPParagraphElement')) {
|
|
1258
|
+
this.appendParagraphToElement(model, authorNotesEl);
|
|
1259
|
+
}
|
|
1260
|
+
else if (id.startsWith('MPFootnote')) {
|
|
1261
|
+
this.appendFootnoteToElement(model, authorNotesEl);
|
|
1287
1262
|
}
|
|
1288
|
-
correspondingEl.append(corresponding.contents);
|
|
1289
|
-
authorNotesEl.appendChild(correspondingEl);
|
|
1290
1263
|
});
|
|
1291
1264
|
if (authorNotesEl.childNodes.length > 0) {
|
|
1292
1265
|
articleMeta.insertBefore(authorNotesEl, contribGroup.nextSibling);
|
|
@@ -1294,6 +1267,18 @@ export class JATSExporter {
|
|
|
1294
1267
|
}
|
|
1295
1268
|
}
|
|
1296
1269
|
};
|
|
1270
|
+
this.appendParagraphToElement = (paragraph, element) => {
|
|
1271
|
+
const paragraphEl = this.document.createElement('p');
|
|
1272
|
+
paragraphEl.setAttribute('id', normalizeID(paragraph._id));
|
|
1273
|
+
paragraphEl.innerHTML = paragraph.contents;
|
|
1274
|
+
element.appendChild(paragraphEl);
|
|
1275
|
+
};
|
|
1276
|
+
this.appendFootnoteToElement = (footnote, element) => {
|
|
1277
|
+
const footnoteEl = this.document.createElement('fn');
|
|
1278
|
+
footnoteEl.setAttribute('id', normalizeID(footnote._id));
|
|
1279
|
+
footnoteEl.innerHTML = footnote.contents;
|
|
1280
|
+
element.appendChild(footnoteEl);
|
|
1281
|
+
};
|
|
1297
1282
|
this.fixBody = (body, fragment) => {
|
|
1298
1283
|
fragment.descendants((node) => {
|
|
1299
1284
|
if (node.attrs.id) {
|
package/dist/es/schema/index.js
CHANGED
|
@@ -19,6 +19,7 @@ import { abstracts } from './nodes/abstracts';
|
|
|
19
19
|
import { affiliation } from './nodes/affiliation';
|
|
20
20
|
import { affiliations } from './nodes/affiliations';
|
|
21
21
|
import { attribution } from './nodes/attribution';
|
|
22
|
+
import { authorNotes } from './nodes/author_notes';
|
|
22
23
|
import { backmatter } from './nodes/backmatter';
|
|
23
24
|
import { bibliographyElement } from './nodes/bibliography_element';
|
|
24
25
|
import { bibliographyItem } from './nodes/bibliography_item';
|
|
@@ -213,5 +214,6 @@ export const schema = new Schema({
|
|
|
213
214
|
contributors,
|
|
214
215
|
supplements,
|
|
215
216
|
supplement,
|
|
217
|
+
author_notes: authorNotes,
|
|
216
218
|
},
|
|
217
219
|
});
|
|
@@ -0,0 +1,24 @@
|
|
|
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 authorNotes = {
|
|
17
|
+
attrs: {
|
|
18
|
+
id: { default: '' },
|
|
19
|
+
dataTracked: { default: null },
|
|
20
|
+
},
|
|
21
|
+
content: '(footnote | paragraph)+',
|
|
22
|
+
group: 'block element',
|
|
23
|
+
toDOM: () => ['author-notes', 0],
|
|
24
|
+
};
|
|
@@ -108,6 +108,11 @@ export const buildFootnote = (containingObject, contents, kind = 'footnote') =>
|
|
|
108
108
|
contents,
|
|
109
109
|
kind,
|
|
110
110
|
});
|
|
111
|
+
export const buildAuthorNotes = (containedObjectIDs) => ({
|
|
112
|
+
_id: generateID(ObjectTypes.AuthorNotes),
|
|
113
|
+
objectType: ObjectTypes.AuthorNotes,
|
|
114
|
+
containedObjectIDs: containedObjectIDs,
|
|
115
|
+
});
|
|
111
116
|
export const buildFootnotesOrder = (footnotesList, containedObjectID) => ({
|
|
112
117
|
_id: generateID(ObjectTypes.FootnotesOrder),
|
|
113
118
|
objectType: ObjectTypes.FootnotesOrder,
|
|
@@ -53,6 +53,7 @@ export const getModelsByType = (modelMap, objectType) => {
|
|
|
53
53
|
export const sortSectionsByPriority = (a, b) => a.priority === b.priority ? 0 : Number(a.priority) - Number(b.priority);
|
|
54
54
|
const getSections = (modelMap) => getModelsByType(modelMap, ObjectTypes.Section).sort(sortSectionsByPriority);
|
|
55
55
|
const getAffiliations = (modelMap) => getModelsByType(modelMap, ObjectTypes.Affiliation);
|
|
56
|
+
const getAuthorNotes = (modelMap) => getModelsByType(modelMap, ObjectTypes.AuthorNotes);
|
|
56
57
|
const getContributors = (modelMap) => getModelsByType(modelMap, ObjectTypes.Contributor);
|
|
57
58
|
const getKeywordElements = (modelMap) => getModelsByType(modelMap, ObjectTypes.KeywordsElement);
|
|
58
59
|
const getSupplements = (modelMap) => getModelsByType(modelMap, ObjectTypes.Supplement);
|
|
@@ -82,7 +83,11 @@ export class Decoder {
|
|
|
82
83
|
const contributors = getContributors(this.modelMap)
|
|
83
84
|
.map((c) => this.decode(c))
|
|
84
85
|
.filter(Boolean);
|
|
85
|
-
|
|
86
|
+
const authorNotes = getAuthorNotes(this.modelMap)
|
|
87
|
+
.map((authorNote) => this.decode(authorNote))
|
|
88
|
+
.filter(Boolean);
|
|
89
|
+
const content = [...contributors, ...authorNotes];
|
|
90
|
+
return schema.nodes.contributors.createAndFill({}, content);
|
|
86
91
|
}
|
|
87
92
|
createKeywordsNode() {
|
|
88
93
|
const elements = getKeywordElements(this.modelMap)
|
|
@@ -483,6 +488,13 @@ export class Decoder {
|
|
|
483
488
|
id: model._id,
|
|
484
489
|
}, content);
|
|
485
490
|
},
|
|
491
|
+
[ObjectTypes.AuthorNotes]: (data) => {
|
|
492
|
+
const model = data;
|
|
493
|
+
const content = model.containedObjectIDs.map((id) => this.decode(this.modelMap.get(id)));
|
|
494
|
+
return schema.nodes.author_notes.create({
|
|
495
|
+
id: model._id,
|
|
496
|
+
}, content);
|
|
497
|
+
},
|
|
486
498
|
[ObjectTypes.Section]: (data) => {
|
|
487
499
|
const model = data;
|
|
488
500
|
const elements = [];
|
|
@@ -387,6 +387,9 @@ const encoders = {
|
|
|
387
387
|
table_element_footer: (node) => ({
|
|
388
388
|
containedObjectIDs: containedObjectIDs(node),
|
|
389
389
|
}),
|
|
390
|
+
author_notes: (node) => ({
|
|
391
|
+
containedObjectIDs: containedObjectIDs(node),
|
|
392
|
+
}),
|
|
390
393
|
footnotes_section: (node, parent, path, priority) => ({
|
|
391
394
|
category: buildSectionCategory(node),
|
|
392
395
|
priority: priority.value++,
|
|
@@ -59,6 +59,8 @@ export const nodeTypesMap = new Map([
|
|
|
59
59
|
[schema.nodes.affiliations, ObjectTypes.Section],
|
|
60
60
|
[schema.nodes.title, ObjectTypes.Titles],
|
|
61
61
|
[schema.nodes.supplement, ObjectTypes.Supplement],
|
|
62
|
+
[schema.nodes.author_notes, ObjectTypes.AuthorNotes],
|
|
63
|
+
[schema.nodes.corresp, ObjectTypes.Corresponding],
|
|
62
64
|
]);
|
|
63
65
|
export const isExecutableNodeType = (type) => hasGroup(type, GROUP_EXECUTABLE);
|
|
64
66
|
export const isElementNodeType = (type) => hasGroup(type, GROUP_ELEMENT);
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
export declare const jatsFrontParser: {
|
|
17
17
|
parseTitles(element: Element | null, createElement: (tagName: string) => HTMLElement): import("../../transformer").Build<import("@manuscripts/json-schema/dist/types").Titles>;
|
|
18
|
+
parseDOI(front: Element | null): string | undefined;
|
|
18
19
|
parseCounts(counts: Element | null): {
|
|
19
20
|
wordCount: number | undefined;
|
|
20
21
|
figureCount: number | undefined;
|
|
@@ -62,7 +63,16 @@ export declare const jatsFrontParser: {
|
|
|
62
63
|
affiliations: import("../../transformer").Build<import("@manuscripts/json-schema/dist/types").Affiliation>[];
|
|
63
64
|
affiliationIDs: Map<string, string>;
|
|
64
65
|
};
|
|
65
|
-
parseAuthorNotes(
|
|
66
|
+
parseAuthorNotes(element: Element | null): {
|
|
67
|
+
footnotes: import("../../transformer").Build<import("@manuscripts/json-schema/dist/types").Footnote>[];
|
|
68
|
+
footnoteIDs: Map<string, string>;
|
|
69
|
+
authorNotesParagraphs: import("../../transformer").Build<import("@manuscripts/json-schema/dist/types").ParagraphElement>[];
|
|
70
|
+
authorNotes: import("../../transformer").Build<import("@manuscripts/json-schema/dist/types").AuthorNotes>[];
|
|
71
|
+
correspondingIDs: Map<string, string>;
|
|
72
|
+
correspondingList: import("../../transformer").Build<import("@manuscripts/json-schema/dist/types").Corresponding>[];
|
|
73
|
+
};
|
|
74
|
+
parseParagraphs(elements: Element[]): import("../../transformer").Build<import("@manuscripts/json-schema/dist/types").ParagraphElement>[];
|
|
75
|
+
parseFootnotes(elements: Element[]): {
|
|
66
76
|
footnotes: import("../../transformer").Build<import("@manuscripts/json-schema/dist/types").Footnote>[];
|
|
67
77
|
footnoteIDs: Map<string, string>;
|
|
68
78
|
};
|
|
@@ -86,6 +86,8 @@ export declare class JATSExporter {
|
|
|
86
86
|
protected serializeNode: (node: ManuscriptNode) => Node;
|
|
87
87
|
private validateContributor;
|
|
88
88
|
private buildContributors;
|
|
89
|
+
private appendParagraphToElement;
|
|
90
|
+
private appendFootnoteToElement;
|
|
89
91
|
private buildKeywords;
|
|
90
92
|
private fixBody;
|
|
91
93
|
private changeTag;
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
import { NodeSpec } from 'prosemirror-model';
|
|
17
|
+
import { ManuscriptNode } from '../types';
|
|
18
|
+
interface Attrs {
|
|
19
|
+
id: string;
|
|
20
|
+
}
|
|
21
|
+
export interface AuthorNotesNode extends ManuscriptNode {
|
|
22
|
+
attrs: Attrs;
|
|
23
|
+
}
|
|
24
|
+
export declare const authorNotes: NodeSpec;
|
|
25
|
+
export {};
|
|
@@ -17,7 +17,7 @@ import { Fragment, Mark as ProsemirrorMark, MarkType, Node as ProsemirrorNode, N
|
|
|
17
17
|
import { EditorState, NodeSelection, Plugin, TextSelection, Transaction } from 'prosemirror-state';
|
|
18
18
|
import { EditorView, NodeView } from 'prosemirror-view';
|
|
19
19
|
export type Marks = 'bold' | 'code' | 'italic' | 'smallcaps' | 'strikethrough' | 'styled' | 'subscript' | 'superscript' | 'underline' | 'tracked_insert' | 'tracked_delete';
|
|
20
|
-
export type Nodes = 'attribution' | 'bibliography_item' | 'bibliography_element' | 'bibliography_section' | 'blockquote_element' | 'bullet_list' | 'caption' | 'caption_title' | 'comment' | 'comments' | 'citation' | 'cross_reference' | 'doc' | 'equation' | 'equation_element' | 'figcaption' | 'figure' | 'graphical_abstract_section' | 'figure_element' | 'footnote' | 'footnotes_element' | 'footnotes_section' | 'hard_break' | 'highlight_marker' | 'inline_equation' | 'inline_footnote' | 'keyword' | 'keywords_element' | 'keyword_group' | 'keywords' | 'link' | 'list_item' | 'listing' | 'listing_element' | 'manuscript' | 'abstracts' | 'body' | 'backmatter' | 'missing_figure' | 'ordered_list' | 'paragraph' | 'placeholder' | 'placeholder_element' | 'pullquote_element' | 'section' | 'section_label' | 'section_title' | 'section_title_plain' | 'table' | 'table_body' | 'table_cell' | 'table_element' | 'table_row' | 'table_colgroup' | 'table_col' | 'text' | 'toc_element' | 'toc_section' | 'affiliation' | 'contributor' | 'table_element_footer' | 'title' | 'affiliations' | 'contributors' | 'supplements' | 'supplement';
|
|
20
|
+
export type Nodes = 'attribution' | 'bibliography_item' | 'bibliography_element' | 'bibliography_section' | 'blockquote_element' | 'bullet_list' | 'caption' | 'caption_title' | 'comment' | 'comments' | 'citation' | 'cross_reference' | 'doc' | 'equation' | 'equation_element' | 'figcaption' | 'figure' | 'graphical_abstract_section' | 'figure_element' | 'footnote' | 'footnotes_element' | 'footnotes_section' | 'hard_break' | 'highlight_marker' | 'inline_equation' | 'inline_footnote' | 'keyword' | 'keywords_element' | 'keyword_group' | 'keywords' | 'link' | 'list_item' | 'listing' | 'listing_element' | 'manuscript' | 'abstracts' | 'body' | 'backmatter' | 'missing_figure' | 'ordered_list' | 'paragraph' | 'placeholder' | 'placeholder_element' | 'pullquote_element' | 'section' | 'section_label' | 'section_title' | 'section_title_plain' | 'table' | 'table_body' | 'table_cell' | 'table_element' | 'table_row' | 'table_colgroup' | 'table_col' | 'text' | 'toc_element' | 'toc_section' | 'affiliation' | 'contributor' | 'table_element_footer' | 'title' | 'affiliations' | 'contributors' | 'supplements' | 'supplement' | 'author_notes';
|
|
21
21
|
export type ManuscriptSchema = Schema<Nodes, Marks>;
|
|
22
22
|
export type ManuscriptEditorState = EditorState;
|
|
23
23
|
export type ManuscriptEditorView = EditorView;
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { Affiliation, Attribution, BibliographicDate, BibliographicName, BibliographyElement, BibliographyItem, Color, CommentAnnotation, Contribution, Contributor, ContributorRole, Corresponding, ElementsOrder, EmbeddedModel, Figure, Footnote, FootnotesOrder, InlineMathFragment, Journal, Keyword, KeywordGroup, Manuscript, ManuscriptNote, ObjectTypes, ParagraphElement, Project, Section, Supplement, Titles } from '@manuscripts/json-schema';
|
|
16
|
+
import { Affiliation, Attribution, AuthorNotes, BibliographicDate, BibliographicName, BibliographyElement, BibliographyItem, Color, CommentAnnotation, Contribution, Contributor, ContributorRole, Corresponding, ElementsOrder, EmbeddedModel, Figure, Footnote, FootnotesOrder, InlineMathFragment, Journal, Keyword, KeywordGroup, Manuscript, ManuscriptNote, ObjectTypes, ParagraphElement, Project, Section, Supplement, Titles } from '@manuscripts/json-schema';
|
|
17
17
|
import { FootnotesOrderIndexList } from './footnotes-order';
|
|
18
18
|
import { CommentSelector, ManuscriptModel, ModelAttachment } from './models';
|
|
19
19
|
export type Build<T> = Pick<T, Exclude<keyof T, keyof ManuscriptModel>> & {
|
|
@@ -46,6 +46,7 @@ export declare const buildComment: (target: string, contents?: string, selector?
|
|
|
46
46
|
export declare const buildNote: (target: string, source: 'EMAIL' | 'EDITOR' | 'DASHBOARD', contents?: string) => Build<ManuscriptNote>;
|
|
47
47
|
export declare const buildInlineMathFragment: (containingObject: string, TeXRepresentation: string) => Build<InlineMathFragment>;
|
|
48
48
|
export declare const buildFootnote: (containingObject: string, contents: string, kind?: 'footnote' | 'endnote') => Build<Footnote>;
|
|
49
|
+
export declare const buildAuthorNotes: (containedObjectIDs: string[]) => Build<AuthorNotes>;
|
|
49
50
|
export declare const buildFootnotesOrder: (footnotesList: FootnotesOrderIndexList, containedObjectID: string) => Build<FootnotesOrder>;
|
|
50
51
|
export declare const buildCorresp: (contents: string) => Build<Corresponding>;
|
|
51
52
|
export declare const buildSection: (priority?: number, path?: string[]) => Build<Section>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@manuscripts/transform",
|
|
3
3
|
"description": "ProseMirror transformer for Manuscripts applications",
|
|
4
|
-
"version": "2.1.
|
|
4
|
+
"version": "2.1.3-LEAN-3376-0",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-transform",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"version": "yarn build"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@manuscripts/json-schema": "^2.2.4",
|
|
33
|
-
"@manuscripts/library": "^1.3.3",
|
|
32
|
+
"@manuscripts/json-schema": "^2.2.4-LEAN-3376-0",
|
|
33
|
+
"@manuscripts/library": "^1.3.3-LEAN-3376-0",
|
|
34
34
|
"debug": "^4.3.4",
|
|
35
35
|
"jszip": "^3.10.1",
|
|
36
36
|
"mathjax-full": "^3.2.2",
|
|
@@ -78,4 +78,4 @@
|
|
|
78
78
|
"rimraf": "^3.0.2",
|
|
79
79
|
"typescript": "^4.0.5"
|
|
80
80
|
}
|
|
81
|
-
}
|
|
81
|
+
}
|