@manuscripts/transform 2.1.1-LEAN-3376-2 → 2.1.2
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 +11 -3
- package/dist/cjs/jats/importer/jats-front-parser.js +0 -7
- package/dist/cjs/jats/importer/parse-jats-article.js +1 -6
- package/dist/cjs/jats/jats-exporter.js +41 -39
- package/dist/cjs/schema/index.js +0 -2
- package/dist/cjs/schema/nodes/contributors.js +1 -1
- package/dist/cjs/transformer/builders.js +3 -8
- package/dist/cjs/transformer/decode.js +19 -30
- package/dist/cjs/transformer/encode.js +9 -3
- package/dist/cjs/transformer/footnotes-order.js +1 -4
- package/dist/cjs/transformer/node-types.js +0 -2
- package/dist/es/jats/importer/jats-body-transformations.js +11 -3
- package/dist/es/jats/importer/jats-front-parser.js +1 -8
- package/dist/es/jats/importer/parse-jats-article.js +2 -7
- package/dist/es/jats/jats-exporter.js +41 -39
- package/dist/es/schema/index.js +0 -2
- package/dist/es/schema/nodes/contributors.js +1 -1
- package/dist/es/transformer/builders.js +2 -6
- package/dist/es/transformer/decode.js +20 -31
- package/dist/es/transformer/encode.js +10 -4
- package/dist/es/transformer/footnotes-order.js +0 -2
- package/dist/es/transformer/node-types.js +0 -2
- package/dist/types/jats/importer/jats-body-transformations.d.ts +1 -0
- package/dist/types/jats/importer/jats-front-parser.d.ts +6 -9
- package/dist/types/jats/jats-exporter.d.ts +0 -3
- package/dist/types/schema/types.d.ts +1 -1
- package/dist/types/transformer/builders.d.ts +2 -3
- package/dist/types/transformer/footnotes-order.d.ts +0 -1
- package/package.json +4 -4
- package/dist/cjs/schema/nodes/author_notes.js +0 -27
- package/dist/es/schema/nodes/author_notes.js +0 -24
- package/dist/types/schema/nodes/author_notes.d.ts +0 -25
|
@@ -202,9 +202,7 @@ exports.jatsBodyTransformations = {
|
|
|
202
202
|
}
|
|
203
203
|
},
|
|
204
204
|
moveFootnotes(doc, group, createElement) {
|
|
205
|
-
const footnotes = [
|
|
206
|
-
...doc.querySelectorAll('fn:not(table-wrap-foot fn):not(author-notes fn)'),
|
|
207
|
-
];
|
|
205
|
+
const footnotes = [...doc.querySelectorAll('fn:not(table-wrap-foot fn)')];
|
|
208
206
|
const footnotesSection = doc.querySelector('sec[sec-type="endnotes"]');
|
|
209
207
|
const footnotesSectionGroup = footnotesSection === null || footnotesSection === void 0 ? void 0 : footnotesSection.querySelector('fn-group');
|
|
210
208
|
const containingGroup = footnotesSectionGroup || createElement('fn-group');
|
|
@@ -267,6 +265,16 @@ exports.jatsBodyTransformations = {
|
|
|
267
265
|
}
|
|
268
266
|
});
|
|
269
267
|
},
|
|
268
|
+
orderTableFootnote(doc, body) {
|
|
269
|
+
const tableInlineFootnotesIds = new Set(Array.from(body.querySelectorAll('tbody > tr > td > xref[ref-type="fn"]').values()).map((inlineFootnote) => inlineFootnote.getAttribute('rid')));
|
|
270
|
+
const fnGroups = doc.querySelectorAll('table-wrap-foot > fn-group');
|
|
271
|
+
fnGroups.forEach((fnGroup) => {
|
|
272
|
+
const orderedFootnotes = Array.from(fnGroup.querySelectorAll('fn')).sort((fn) => tableInlineFootnotesIds.has(fn.getAttribute('id'))
|
|
273
|
+
? -1
|
|
274
|
+
: 0);
|
|
275
|
+
fnGroup.replaceChildren(...orderedFootnotes);
|
|
276
|
+
});
|
|
277
|
+
},
|
|
270
278
|
moveFloatsGroupToBody(doc, body, createElement) {
|
|
271
279
|
const group = doc.querySelector('floats-group');
|
|
272
280
|
if (group) {
|
|
@@ -189,13 +189,6 @@ exports.jatsFrontParser = {
|
|
|
189
189
|
footnoteIDs,
|
|
190
190
|
};
|
|
191
191
|
},
|
|
192
|
-
parseAuthorNotesParagraphs(elements) {
|
|
193
|
-
const paragraphs = [];
|
|
194
|
-
elements.forEach((p) => {
|
|
195
|
-
paragraphs.push((0, transformer_1.buildParagraph)(p.innerHTML));
|
|
196
|
-
});
|
|
197
|
-
return paragraphs;
|
|
198
|
-
},
|
|
199
192
|
parseCorresp(elements) {
|
|
200
193
|
const correspondingIDs = new Map();
|
|
201
194
|
const correspondingList = elements.map((element) => {
|
|
@@ -40,10 +40,6 @@ const parseJATSFront = (doc, front) => {
|
|
|
40
40
|
const { correspondingList, correspondingIDs } = jats_front_parser_1.jatsFrontParser.parseCorresp([
|
|
41
41
|
...front.querySelectorAll('article-meta > author-notes > corresp'),
|
|
42
42
|
]);
|
|
43
|
-
const authorNotesParagraphs = jats_front_parser_1.jatsFrontParser.parseAuthorNotesParagraphs([
|
|
44
|
-
...front.querySelectorAll('article-meta > author-notes > p'),
|
|
45
|
-
]);
|
|
46
|
-
const authorNotes = (0, transformer_1.buildAuthorNotes)(Array.from(footnoteIDs.values()).concat(authorNotesParagraphs.map((p) => p._id)));
|
|
47
43
|
const authors = jats_front_parser_1.jatsFrontParser.parseContributors([
|
|
48
44
|
...front.querySelectorAll('article-meta > contrib-group > contrib[contrib-type="author"]'),
|
|
49
45
|
], affiliationIDs, footnoteIDs, correspondingIDs);
|
|
@@ -54,8 +50,6 @@ const parseJATSFront = (doc, front) => {
|
|
|
54
50
|
manuscript,
|
|
55
51
|
titles,
|
|
56
52
|
journal,
|
|
57
|
-
...authorNotesParagraphs,
|
|
58
|
-
authorNotes,
|
|
59
53
|
...footnotes,
|
|
60
54
|
...authors,
|
|
61
55
|
...affiliations,
|
|
@@ -73,6 +67,7 @@ const parseJATSBody = (doc, body, references) => {
|
|
|
73
67
|
jats_body_transformations_1.jatsBodyTransformations.createBackmatter(doc, body, createElement);
|
|
74
68
|
jats_body_transformations_1.jatsBodyTransformations.createSuppleMaterials(doc, body, createElement);
|
|
75
69
|
jats_body_transformations_1.jatsBodyTransformations.createKeywords(doc, body, createElement);
|
|
70
|
+
jats_body_transformations_1.jatsBodyTransformations.orderTableFootnote(doc, body);
|
|
76
71
|
const node = jats_body_dom_parser_1.jatsBodyDOMParser.parse(body).firstChild;
|
|
77
72
|
if (!node) {
|
|
78
73
|
throw new Error('No content was parsed from the JATS article body');
|
|
@@ -614,7 +614,6 @@ 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],
|
|
618
617
|
title: () => '',
|
|
619
618
|
affiliations: () => '',
|
|
620
619
|
contributors: () => '',
|
|
@@ -1253,23 +1252,49 @@ class JATSExporter {
|
|
|
1253
1252
|
}
|
|
1254
1253
|
});
|
|
1255
1254
|
}
|
|
1256
|
-
const
|
|
1257
|
-
|
|
1255
|
+
const noteIDs = [];
|
|
1256
|
+
for (const contributor of [...authorContributors, ...otherContributors]) {
|
|
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) {
|
|
1258
1275
|
const authorNotesEl = this.document.createElement('author-notes');
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1276
|
+
const usedFootnotes = footnotes.filter((footnote) => {
|
|
1277
|
+
return noteIDs.includes(footnote._id);
|
|
1278
|
+
});
|
|
1279
|
+
const usedCorrespodings = correspodings.filter((corresp) => {
|
|
1280
|
+
return noteIDs.includes(corresp._id);
|
|
1281
|
+
});
|
|
1282
|
+
usedFootnotes.forEach((footnote) => {
|
|
1283
|
+
const authorFootNote = this.document.createElement('fn');
|
|
1284
|
+
authorFootNote.setAttribute('id', normalizeID(footnote._id));
|
|
1285
|
+
authorFootNote.innerHTML = footnote.contents;
|
|
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);
|
|
1272
1295
|
}
|
|
1296
|
+
correspondingEl.append(corresponding.contents);
|
|
1297
|
+
authorNotesEl.appendChild(correspondingEl);
|
|
1273
1298
|
});
|
|
1274
1299
|
if (authorNotesEl.childNodes.length > 0) {
|
|
1275
1300
|
articleMeta.insertBefore(authorNotesEl, contribGroup.nextSibling);
|
|
@@ -1277,29 +1302,6 @@ class JATSExporter {
|
|
|
1277
1302
|
}
|
|
1278
1303
|
}
|
|
1279
1304
|
};
|
|
1280
|
-
this.appendParagraphToElement = (paragraph, element) => {
|
|
1281
|
-
const paragraphEl = this.document.createElement('p');
|
|
1282
|
-
paragraphEl.setAttribute('id', normalizeID(paragraph._id));
|
|
1283
|
-
paragraphEl.innerHTML = paragraph.contents;
|
|
1284
|
-
element.appendChild(paragraphEl);
|
|
1285
|
-
};
|
|
1286
|
-
this.appendCorrespondingToElement = (corresponding, element) => {
|
|
1287
|
-
const correspondingEl = this.document.createElement('corresp');
|
|
1288
|
-
correspondingEl.setAttribute('id', normalizeID(corresponding._id));
|
|
1289
|
-
if (corresponding.label) {
|
|
1290
|
-
const labelEl = this.document.createElement('label');
|
|
1291
|
-
labelEl.textContent = corresponding.label;
|
|
1292
|
-
correspondingEl.appendChild(labelEl);
|
|
1293
|
-
}
|
|
1294
|
-
correspondingEl.append(corresponding.contents);
|
|
1295
|
-
element.appendChild(correspondingEl);
|
|
1296
|
-
};
|
|
1297
|
-
this.appendFootnoteToElement = (footnote, element) => {
|
|
1298
|
-
const footnoteEl = this.document.createElement('fn');
|
|
1299
|
-
footnoteEl.setAttribute('id', normalizeID(footnote._id));
|
|
1300
|
-
footnoteEl.innerHTML = footnote.contents;
|
|
1301
|
-
element.appendChild(footnoteEl);
|
|
1302
|
-
};
|
|
1303
1305
|
this.fixBody = (body, fragment) => {
|
|
1304
1306
|
fragment.descendants((node) => {
|
|
1305
1307
|
if (node.attrs.id) {
|
package/dist/cjs/schema/index.js
CHANGED
|
@@ -36,7 +36,6 @@ 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");
|
|
40
39
|
const backmatter_1 = require("./nodes/backmatter");
|
|
41
40
|
const bibliography_element_1 = require("./nodes/bibliography_element");
|
|
42
41
|
const bibliography_item_1 = require("./nodes/bibliography_item");
|
|
@@ -231,6 +230,5 @@ exports.schema = new prosemirror_model_1.Schema({
|
|
|
231
230
|
contributors: contributors_1.contributors,
|
|
232
231
|
supplements: supplements_1.supplements,
|
|
233
232
|
supplement: supplement_1.supplement,
|
|
234
|
-
author_notes: author_notes_1.authorNotes,
|
|
235
233
|
},
|
|
236
234
|
});
|
|
@@ -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.
|
|
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;
|
|
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,16 +130,11 @@ const buildFootnote = (containingObject, contents, kind = 'footnote') => ({
|
|
|
130
130
|
kind,
|
|
131
131
|
});
|
|
132
132
|
exports.buildFootnote = buildFootnote;
|
|
133
|
-
const
|
|
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;
|
|
139
|
-
const buildFootnotesOrder = (footnotesList) => ({
|
|
133
|
+
const buildFootnotesOrder = (footnotesList, containedObjectID) => ({
|
|
140
134
|
_id: (0, id_1.generateID)(json_schema_1.ObjectTypes.FootnotesOrder),
|
|
141
135
|
objectType: json_schema_1.ObjectTypes.FootnotesOrder,
|
|
142
136
|
footnotesList,
|
|
137
|
+
containedObjectID,
|
|
143
138
|
});
|
|
144
139
|
exports.buildFootnotesOrder = buildFootnotesOrder;
|
|
145
140
|
const buildCorresp = (contents) => ({
|
|
@@ -62,14 +62,12 @@ 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);
|
|
66
65
|
const getContributors = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.Contributor);
|
|
67
66
|
const getKeywordElements = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.KeywordsElement);
|
|
68
67
|
const getSupplements = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.Supplement);
|
|
69
68
|
const getKeywordGroups = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.KeywordGroup);
|
|
70
69
|
const getKeywords = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.Keyword);
|
|
71
70
|
const getTitles = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.Titles)[0];
|
|
72
|
-
const isFootnote = (0, object_types_1.hasObjectType)(json_schema_1.ObjectTypes.Footnote);
|
|
73
71
|
const hasParentSection = (id) => (section) => section.path &&
|
|
74
72
|
section.path.length > 1 &&
|
|
75
73
|
section.path[section.path.length - 2] === id;
|
|
@@ -93,11 +91,7 @@ class Decoder {
|
|
|
93
91
|
const contributors = getContributors(this.modelMap)
|
|
94
92
|
.map((c) => this.decode(c))
|
|
95
93
|
.filter(Boolean);
|
|
96
|
-
|
|
97
|
-
.map((authorNote) => this.decode(authorNote))
|
|
98
|
-
.filter(Boolean);
|
|
99
|
-
const content = [...contributors, ...authorNotes];
|
|
100
|
-
return schema_1.schema.nodes.contributors.createAndFill({}, content);
|
|
94
|
+
return schema_1.schema.nodes.contributors.createAndFill({}, contributors);
|
|
101
95
|
}
|
|
102
96
|
createKeywordsNode() {
|
|
103
97
|
const elements = getKeywordElements(this.modelMap)
|
|
@@ -316,23 +310,25 @@ class Decoder {
|
|
|
316
310
|
},
|
|
317
311
|
[json_schema_1.ObjectTypes.FootnotesElement]: (data) => {
|
|
318
312
|
const foonotesElementModel = data;
|
|
319
|
-
const collateByKind = foonotesElementModel.collateByKind || 'footnote';
|
|
320
313
|
const footnotesOfKind = [];
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
model
|
|
325
|
-
const
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
314
|
+
const footnoteOrder = (0, exports.getModelsByType)(this.modelMap, json_schema_1.ObjectTypes.FootnotesOrder).find((model) => model.containedObjectID === data._id);
|
|
315
|
+
if (footnoteOrder) {
|
|
316
|
+
footnoteOrder.footnotesList.map(({ id }) => {
|
|
317
|
+
const model = this.modelMap.get(id);
|
|
318
|
+
const collateByKind = foonotesElementModel.collateByKind || 'footnote';
|
|
319
|
+
if (model.kind === collateByKind) {
|
|
320
|
+
const comments = this.createCommentNodes(model);
|
|
321
|
+
comments.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
322
|
+
const footnote = this.parseContents(model.contents || '<div></div>', undefined, this.getComments(model), {
|
|
323
|
+
topNode: schema_1.schema.nodes.footnote.create({
|
|
324
|
+
id: model._id,
|
|
325
|
+
kind: model.kind,
|
|
326
|
+
comments: comments.map((c) => c.attrs.id),
|
|
327
|
+
}),
|
|
328
|
+
});
|
|
329
|
+
footnotesOfKind.push(footnote);
|
|
330
|
+
}
|
|
331
|
+
});
|
|
336
332
|
}
|
|
337
333
|
return schema_1.schema.nodes.footnotes_element.create({
|
|
338
334
|
id: foonotesElementModel._id,
|
|
@@ -496,13 +492,6 @@ class Decoder {
|
|
|
496
492
|
id: model._id,
|
|
497
493
|
}, content);
|
|
498
494
|
},
|
|
499
|
-
[json_schema_1.ObjectTypes.AuthorNotes]: (data) => {
|
|
500
|
-
const model = data;
|
|
501
|
-
const content = model.containedObjectIDs.map((id) => this.decode(this.modelMap.get(id)));
|
|
502
|
-
return schema_1.schema.nodes.author_notes.create({
|
|
503
|
-
id: model._id,
|
|
504
|
-
}, content);
|
|
505
|
-
},
|
|
506
495
|
[json_schema_1.ObjectTypes.Section]: (data) => {
|
|
507
496
|
const model = data;
|
|
508
497
|
const elements = [];
|
|
@@ -395,9 +395,6 @@ const encoders = {
|
|
|
395
395
|
table_element_footer: (node) => ({
|
|
396
396
|
containedObjectIDs: containedObjectIDs(node),
|
|
397
397
|
}),
|
|
398
|
-
author_notes: (node) => ({
|
|
399
|
-
containedObjectIDs: containedObjectIDs(node),
|
|
400
|
-
}),
|
|
401
398
|
footnotes_section: (node, parent, path, priority) => ({
|
|
402
399
|
category: (0, section_category_1.buildSectionCategory)(node),
|
|
403
400
|
priority: priority.value++,
|
|
@@ -599,6 +596,9 @@ const encode = (node) => {
|
|
|
599
596
|
child.type !== schema_1.schema.nodes.inline_equation) {
|
|
600
597
|
return;
|
|
601
598
|
}
|
|
599
|
+
if (child.type === schema_1.schema.nodes.footnotes_element) {
|
|
600
|
+
addFootnotesOrderModel(child, models);
|
|
601
|
+
}
|
|
602
602
|
const { model, markers } = (0, exports.modelFromNode)(child, parent, path, priority);
|
|
603
603
|
markers.forEach((marker) => {
|
|
604
604
|
const comment = models.get(marker._id);
|
|
@@ -650,3 +650,9 @@ const generateElementOrder = (node, nodeType) => {
|
|
|
650
650
|
order.elements = ids;
|
|
651
651
|
return order;
|
|
652
652
|
};
|
|
653
|
+
const addFootnotesOrderModel = (child, models) => {
|
|
654
|
+
const footnoteList = [];
|
|
655
|
+
child.forEach((footnote, _, index) => footnoteList.push({ id: footnote.attrs.id, index }));
|
|
656
|
+
const footnotesOrder = (0, builders_1.buildFootnotesOrder)(footnoteList, child.attrs.id);
|
|
657
|
+
models.set(footnotesOrder._id, footnotesOrder);
|
|
658
|
+
};
|
|
@@ -15,8 +15,7 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.
|
|
19
|
-
const builders_1 = require("./builders");
|
|
18
|
+
exports.handleFootnotesOrder = exports.createOrderedFootnotesIDs = void 0;
|
|
20
19
|
const createOrderedFootnotesIDs = (doc) => {
|
|
21
20
|
const footnotesRefs = [...doc.querySelectorAll('xref[ref-type="fn"][rid]')];
|
|
22
21
|
const footnotes = [...doc.querySelectorAll('fn:not([fn-type])')];
|
|
@@ -59,5 +58,3 @@ const handleFootnotesOrder = (orderedFootnotesIDs, replacements, footnotesOrder)
|
|
|
59
58
|
footnotesOrder.footnotesList = footnotesList;
|
|
60
59
|
};
|
|
61
60
|
exports.handleFootnotesOrder = handleFootnotesOrder;
|
|
62
|
-
const createEmptyFootnotesOrder = () => (0, builders_1.buildFootnotesOrder)([]);
|
|
63
|
-
exports.createEmptyFootnotesOrder = createEmptyFootnotesOrder;
|
|
@@ -62,8 +62,6 @@ 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],
|
|
67
65
|
]);
|
|
68
66
|
const isExecutableNodeType = (type) => (0, schema_1.hasGroup)(type, schema_1.GROUP_EXECUTABLE);
|
|
69
67
|
exports.isExecutableNodeType = isExecutableNodeType;
|
|
@@ -199,9 +199,7 @@ export const jatsBodyTransformations = {
|
|
|
199
199
|
}
|
|
200
200
|
},
|
|
201
201
|
moveFootnotes(doc, group, createElement) {
|
|
202
|
-
const footnotes = [
|
|
203
|
-
...doc.querySelectorAll('fn:not(table-wrap-foot fn):not(author-notes fn)'),
|
|
204
|
-
];
|
|
202
|
+
const footnotes = [...doc.querySelectorAll('fn:not(table-wrap-foot fn)')];
|
|
205
203
|
const footnotesSection = doc.querySelector('sec[sec-type="endnotes"]');
|
|
206
204
|
const footnotesSectionGroup = footnotesSection === null || footnotesSection === void 0 ? void 0 : footnotesSection.querySelector('fn-group');
|
|
207
205
|
const containingGroup = footnotesSectionGroup || createElement('fn-group');
|
|
@@ -264,6 +262,16 @@ export const jatsBodyTransformations = {
|
|
|
264
262
|
}
|
|
265
263
|
});
|
|
266
264
|
},
|
|
265
|
+
orderTableFootnote(doc, body) {
|
|
266
|
+
const tableInlineFootnotesIds = new Set(Array.from(body.querySelectorAll('tbody > tr > td > xref[ref-type="fn"]').values()).map((inlineFootnote) => inlineFootnote.getAttribute('rid')));
|
|
267
|
+
const fnGroups = doc.querySelectorAll('table-wrap-foot > fn-group');
|
|
268
|
+
fnGroups.forEach((fnGroup) => {
|
|
269
|
+
const orderedFootnotes = Array.from(fnGroup.querySelectorAll('fn')).sort((fn) => tableInlineFootnotesIds.has(fn.getAttribute('id'))
|
|
270
|
+
? -1
|
|
271
|
+
: 0);
|
|
272
|
+
fnGroup.replaceChildren(...orderedFootnotes);
|
|
273
|
+
});
|
|
274
|
+
},
|
|
267
275
|
moveFloatsGroupToBody(doc, body, createElement) {
|
|
268
276
|
const group = doc.querySelector('floats-group');
|
|
269
277
|
if (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,
|
|
18
|
+
import { buildAffiliation, buildBibliographicName, buildContributor, buildCorresp, buildFootnote, buildJournal, 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');
|
|
@@ -183,13 +183,6 @@ export const jatsFrontParser = {
|
|
|
183
183
|
footnoteIDs,
|
|
184
184
|
};
|
|
185
185
|
},
|
|
186
|
-
parseAuthorNotesParagraphs(elements) {
|
|
187
|
-
const paragraphs = [];
|
|
188
|
-
elements.forEach((p) => {
|
|
189
|
-
paragraphs.push(buildParagraph(p.innerHTML));
|
|
190
|
-
});
|
|
191
|
-
return paragraphs;
|
|
192
|
-
},
|
|
193
186
|
parseCorresp(elements) {
|
|
194
187
|
const correspondingIDs = new Map();
|
|
195
188
|
const correspondingList = elements.map((element) => {
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import { InvalidInput } from '../../errors';
|
|
17
|
-
import {
|
|
17
|
+
import { buildBibliographyElement, buildSection, encode, } from '../../transformer';
|
|
18
18
|
import { buildManuscript } from '../../transformer/builders';
|
|
19
19
|
import { generateID } from '../../transformer/id';
|
|
20
20
|
import { findManuscript } from '../../transformer/project-bundle';
|
|
@@ -37,10 +37,6 @@ export const parseJATSFront = (doc, front) => {
|
|
|
37
37
|
const { correspondingList, correspondingIDs } = jatsFrontParser.parseCorresp([
|
|
38
38
|
...front.querySelectorAll('article-meta > author-notes > corresp'),
|
|
39
39
|
]);
|
|
40
|
-
const authorNotesParagraphs = jatsFrontParser.parseAuthorNotesParagraphs([
|
|
41
|
-
...front.querySelectorAll('article-meta > author-notes > p'),
|
|
42
|
-
]);
|
|
43
|
-
const authorNotes = buildAuthorNotes(Array.from(footnoteIDs.values()).concat(authorNotesParagraphs.map((p) => p._id)));
|
|
44
40
|
const authors = jatsFrontParser.parseContributors([
|
|
45
41
|
...front.querySelectorAll('article-meta > contrib-group > contrib[contrib-type="author"]'),
|
|
46
42
|
], affiliationIDs, footnoteIDs, correspondingIDs);
|
|
@@ -51,8 +47,6 @@ export const parseJATSFront = (doc, front) => {
|
|
|
51
47
|
manuscript,
|
|
52
48
|
titles,
|
|
53
49
|
journal,
|
|
54
|
-
...authorNotesParagraphs,
|
|
55
|
-
authorNotes,
|
|
56
50
|
...footnotes,
|
|
57
51
|
...authors,
|
|
58
52
|
...affiliations,
|
|
@@ -69,6 +63,7 @@ export const parseJATSBody = (doc, body, references) => {
|
|
|
69
63
|
jatsBodyTransformations.createBackmatter(doc, body, createElement);
|
|
70
64
|
jatsBodyTransformations.createSuppleMaterials(doc, body, createElement);
|
|
71
65
|
jatsBodyTransformations.createKeywords(doc, body, createElement);
|
|
66
|
+
jatsBodyTransformations.orderTableFootnote(doc, body);
|
|
72
67
|
const node = jatsBodyDOMParser.parse(body).firstChild;
|
|
73
68
|
if (!node) {
|
|
74
69
|
throw new Error('No content was parsed from the JATS article body');
|
|
@@ -606,7 +606,6 @@ 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],
|
|
610
609
|
title: () => '',
|
|
611
610
|
affiliations: () => '',
|
|
612
611
|
contributors: () => '',
|
|
@@ -1245,23 +1244,49 @@ export class JATSExporter {
|
|
|
1245
1244
|
}
|
|
1246
1245
|
});
|
|
1247
1246
|
}
|
|
1248
|
-
const
|
|
1249
|
-
|
|
1247
|
+
const noteIDs = [];
|
|
1248
|
+
for (const contributor of [...authorContributors, ...otherContributors]) {
|
|
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) {
|
|
1250
1267
|
const authorNotesEl = this.document.createElement('author-notes');
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1268
|
+
const usedFootnotes = footnotes.filter((footnote) => {
|
|
1269
|
+
return noteIDs.includes(footnote._id);
|
|
1270
|
+
});
|
|
1271
|
+
const usedCorrespodings = correspodings.filter((corresp) => {
|
|
1272
|
+
return noteIDs.includes(corresp._id);
|
|
1273
|
+
});
|
|
1274
|
+
usedFootnotes.forEach((footnote) => {
|
|
1275
|
+
const authorFootNote = this.document.createElement('fn');
|
|
1276
|
+
authorFootNote.setAttribute('id', normalizeID(footnote._id));
|
|
1277
|
+
authorFootNote.innerHTML = footnote.contents;
|
|
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);
|
|
1264
1287
|
}
|
|
1288
|
+
correspondingEl.append(corresponding.contents);
|
|
1289
|
+
authorNotesEl.appendChild(correspondingEl);
|
|
1265
1290
|
});
|
|
1266
1291
|
if (authorNotesEl.childNodes.length > 0) {
|
|
1267
1292
|
articleMeta.insertBefore(authorNotesEl, contribGroup.nextSibling);
|
|
@@ -1269,29 +1294,6 @@ export class JATSExporter {
|
|
|
1269
1294
|
}
|
|
1270
1295
|
}
|
|
1271
1296
|
};
|
|
1272
|
-
this.appendParagraphToElement = (paragraph, element) => {
|
|
1273
|
-
const paragraphEl = this.document.createElement('p');
|
|
1274
|
-
paragraphEl.setAttribute('id', normalizeID(paragraph._id));
|
|
1275
|
-
paragraphEl.innerHTML = paragraph.contents;
|
|
1276
|
-
element.appendChild(paragraphEl);
|
|
1277
|
-
};
|
|
1278
|
-
this.appendCorrespondingToElement = (corresponding, element) => {
|
|
1279
|
-
const correspondingEl = this.document.createElement('corresp');
|
|
1280
|
-
correspondingEl.setAttribute('id', normalizeID(corresponding._id));
|
|
1281
|
-
if (corresponding.label) {
|
|
1282
|
-
const labelEl = this.document.createElement('label');
|
|
1283
|
-
labelEl.textContent = corresponding.label;
|
|
1284
|
-
correspondingEl.appendChild(labelEl);
|
|
1285
|
-
}
|
|
1286
|
-
correspondingEl.append(corresponding.contents);
|
|
1287
|
-
element.appendChild(correspondingEl);
|
|
1288
|
-
};
|
|
1289
|
-
this.appendFootnoteToElement = (footnote, element) => {
|
|
1290
|
-
const footnoteEl = this.document.createElement('fn');
|
|
1291
|
-
footnoteEl.setAttribute('id', normalizeID(footnote._id));
|
|
1292
|
-
footnoteEl.innerHTML = footnote.contents;
|
|
1293
|
-
element.appendChild(footnoteEl);
|
|
1294
|
-
};
|
|
1295
1297
|
this.fixBody = (body, fragment) => {
|
|
1296
1298
|
fragment.descendants((node) => {
|
|
1297
1299
|
if (node.attrs.id) {
|
package/dist/es/schema/index.js
CHANGED
|
@@ -19,7 +19,6 @@ 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';
|
|
23
22
|
import { backmatter } from './nodes/backmatter';
|
|
24
23
|
import { bibliographyElement } from './nodes/bibliography_element';
|
|
25
24
|
import { bibliographyItem } from './nodes/bibliography_item';
|
|
@@ -214,6 +213,5 @@ export const schema = new Schema({
|
|
|
214
213
|
contributors,
|
|
215
214
|
supplements,
|
|
216
215
|
supplement,
|
|
217
|
-
author_notes: authorNotes,
|
|
218
216
|
},
|
|
219
217
|
});
|
|
@@ -108,15 +108,11 @@ export const buildFootnote = (containingObject, contents, kind = 'footnote') =>
|
|
|
108
108
|
contents,
|
|
109
109
|
kind,
|
|
110
110
|
});
|
|
111
|
-
export const
|
|
112
|
-
_id: generateID(ObjectTypes.AuthorNotes),
|
|
113
|
-
objectType: ObjectTypes.AuthorNotes,
|
|
114
|
-
containedObjectIDs: containedObjectIDs,
|
|
115
|
-
});
|
|
116
|
-
export const buildFootnotesOrder = (footnotesList) => ({
|
|
111
|
+
export const buildFootnotesOrder = (footnotesList, containedObjectID) => ({
|
|
117
112
|
_id: generateID(ObjectTypes.FootnotesOrder),
|
|
118
113
|
objectType: ObjectTypes.FootnotesOrder,
|
|
119
114
|
footnotesList,
|
|
115
|
+
containedObjectID,
|
|
120
116
|
});
|
|
121
117
|
export const buildCorresp = (contents) => ({
|
|
122
118
|
_id: generateID(ObjectTypes.Corresponding),
|
|
@@ -32,7 +32,7 @@ import { abstractsType, backmatterType, bodyType, } from '../lib/section-group-t
|
|
|
32
32
|
import { schema, } from '../schema';
|
|
33
33
|
import { buildTitles } from './builders';
|
|
34
34
|
import { insertHighlightMarkers } from './highlight-markers';
|
|
35
|
-
import { ExtraObjectTypes,
|
|
35
|
+
import { ExtraObjectTypes, isCommentAnnotation, isManuscript, } from './object-types';
|
|
36
36
|
import { chooseSectionLableName, chooseSectionNodeType, chooseSecType, getSectionGroupType, guessSectionCategory, } from './section-category';
|
|
37
37
|
import { timestamp } from './timestamp';
|
|
38
38
|
const warn = debug('manuscripts-transform');
|
|
@@ -53,14 +53,12 @@ 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);
|
|
57
56
|
const getContributors = (modelMap) => getModelsByType(modelMap, ObjectTypes.Contributor);
|
|
58
57
|
const getKeywordElements = (modelMap) => getModelsByType(modelMap, ObjectTypes.KeywordsElement);
|
|
59
58
|
const getSupplements = (modelMap) => getModelsByType(modelMap, ObjectTypes.Supplement);
|
|
60
59
|
const getKeywordGroups = (modelMap) => getModelsByType(modelMap, ObjectTypes.KeywordGroup);
|
|
61
60
|
const getKeywords = (modelMap) => getModelsByType(modelMap, ObjectTypes.Keyword);
|
|
62
61
|
const getTitles = (modelMap) => getModelsByType(modelMap, ObjectTypes.Titles)[0];
|
|
63
|
-
const isFootnote = hasObjectType(ObjectTypes.Footnote);
|
|
64
62
|
const hasParentSection = (id) => (section) => section.path &&
|
|
65
63
|
section.path.length > 1 &&
|
|
66
64
|
section.path[section.path.length - 2] === id;
|
|
@@ -84,11 +82,7 @@ export class Decoder {
|
|
|
84
82
|
const contributors = getContributors(this.modelMap)
|
|
85
83
|
.map((c) => this.decode(c))
|
|
86
84
|
.filter(Boolean);
|
|
87
|
-
|
|
88
|
-
.map((authorNote) => this.decode(authorNote))
|
|
89
|
-
.filter(Boolean);
|
|
90
|
-
const content = [...contributors, ...authorNotes];
|
|
91
|
-
return schema.nodes.contributors.createAndFill({}, content);
|
|
85
|
+
return schema.nodes.contributors.createAndFill({}, contributors);
|
|
92
86
|
}
|
|
93
87
|
createKeywordsNode() {
|
|
94
88
|
const elements = getKeywordElements(this.modelMap)
|
|
@@ -307,23 +301,25 @@ export class Decoder {
|
|
|
307
301
|
},
|
|
308
302
|
[ObjectTypes.FootnotesElement]: (data) => {
|
|
309
303
|
const foonotesElementModel = data;
|
|
310
|
-
const collateByKind = foonotesElementModel.collateByKind || 'footnote';
|
|
311
304
|
const footnotesOfKind = [];
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
model
|
|
316
|
-
const
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
305
|
+
const footnoteOrder = getModelsByType(this.modelMap, ObjectTypes.FootnotesOrder).find((model) => model.containedObjectID === data._id);
|
|
306
|
+
if (footnoteOrder) {
|
|
307
|
+
footnoteOrder.footnotesList.map(({ id }) => {
|
|
308
|
+
const model = this.modelMap.get(id);
|
|
309
|
+
const collateByKind = foonotesElementModel.collateByKind || 'footnote';
|
|
310
|
+
if (model.kind === collateByKind) {
|
|
311
|
+
const comments = this.createCommentNodes(model);
|
|
312
|
+
comments.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
313
|
+
const footnote = this.parseContents(model.contents || '<div></div>', undefined, this.getComments(model), {
|
|
314
|
+
topNode: schema.nodes.footnote.create({
|
|
315
|
+
id: model._id,
|
|
316
|
+
kind: model.kind,
|
|
317
|
+
comments: comments.map((c) => c.attrs.id),
|
|
318
|
+
}),
|
|
319
|
+
});
|
|
320
|
+
footnotesOfKind.push(footnote);
|
|
321
|
+
}
|
|
322
|
+
});
|
|
327
323
|
}
|
|
328
324
|
return schema.nodes.footnotes_element.create({
|
|
329
325
|
id: foonotesElementModel._id,
|
|
@@ -487,13 +483,6 @@ export class Decoder {
|
|
|
487
483
|
id: model._id,
|
|
488
484
|
}, content);
|
|
489
485
|
},
|
|
490
|
-
[ObjectTypes.AuthorNotes]: (data) => {
|
|
491
|
-
const model = data;
|
|
492
|
-
const content = model.containedObjectIDs.map((id) => this.decode(this.modelMap.get(id)));
|
|
493
|
-
return schema.nodes.author_notes.create({
|
|
494
|
-
id: model._id,
|
|
495
|
-
}, content);
|
|
496
|
-
},
|
|
497
486
|
[ObjectTypes.Section]: (data) => {
|
|
498
487
|
const model = data;
|
|
499
488
|
const elements = [];
|
|
@@ -17,7 +17,7 @@ import { DOMSerializer } from 'prosemirror-model';
|
|
|
17
17
|
import serializeToXML from 'w3c-xmlserializer';
|
|
18
18
|
import { iterateChildren } from '../lib/utils';
|
|
19
19
|
import { hasGroup, isHighlightMarkerNode, isManuscriptNode, isSectionNode, schema, } from '../schema';
|
|
20
|
-
import { auxiliaryObjectTypes, buildAttribution, buildElementsOrder, } from './builders';
|
|
20
|
+
import { auxiliaryObjectTypes, buildAttribution, buildElementsOrder, buildFootnotesOrder, } from './builders';
|
|
21
21
|
import { extractCommentMarkers } from './highlight-markers';
|
|
22
22
|
import { nodeTypesMap } from './node-types';
|
|
23
23
|
import { buildSectionCategory } from './section-category';
|
|
@@ -387,9 +387,6 @@ const encoders = {
|
|
|
387
387
|
table_element_footer: (node) => ({
|
|
388
388
|
containedObjectIDs: containedObjectIDs(node),
|
|
389
389
|
}),
|
|
390
|
-
author_notes: (node) => ({
|
|
391
|
-
containedObjectIDs: containedObjectIDs(node),
|
|
392
|
-
}),
|
|
393
390
|
footnotes_section: (node, parent, path, priority) => ({
|
|
394
391
|
category: buildSectionCategory(node),
|
|
395
392
|
priority: priority.value++,
|
|
@@ -590,6 +587,9 @@ export const encode = (node) => {
|
|
|
590
587
|
child.type !== schema.nodes.inline_equation) {
|
|
591
588
|
return;
|
|
592
589
|
}
|
|
590
|
+
if (child.type === schema.nodes.footnotes_element) {
|
|
591
|
+
addFootnotesOrderModel(child, models);
|
|
592
|
+
}
|
|
593
593
|
const { model, markers } = modelFromNode(child, parent, path, priority);
|
|
594
594
|
markers.forEach((marker) => {
|
|
595
595
|
const comment = models.get(marker._id);
|
|
@@ -640,3 +640,9 @@ const generateElementOrder = (node, nodeType) => {
|
|
|
640
640
|
order.elements = ids;
|
|
641
641
|
return order;
|
|
642
642
|
};
|
|
643
|
+
const addFootnotesOrderModel = (child, models) => {
|
|
644
|
+
const footnoteList = [];
|
|
645
|
+
child.forEach((footnote, _, index) => footnoteList.push({ id: footnote.attrs.id, index }));
|
|
646
|
+
const footnotesOrder = buildFootnotesOrder(footnoteList, child.attrs.id);
|
|
647
|
+
models.set(footnotesOrder._id, footnotesOrder);
|
|
648
|
+
};
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { buildFootnotesOrder } from './builders';
|
|
17
16
|
export const createOrderedFootnotesIDs = (doc) => {
|
|
18
17
|
const footnotesRefs = [...doc.querySelectorAll('xref[ref-type="fn"][rid]')];
|
|
19
18
|
const footnotes = [...doc.querySelectorAll('fn:not([fn-type])')];
|
|
@@ -54,4 +53,3 @@ export const handleFootnotesOrder = (orderedFootnotesIDs, replacements, footnote
|
|
|
54
53
|
});
|
|
55
54
|
footnotesOrder.footnotesList = footnotesList;
|
|
56
55
|
};
|
|
57
|
-
export const createEmptyFootnotesOrder = () => buildFootnotesOrder([]);
|
|
@@ -59,8 +59,6 @@ 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],
|
|
64
62
|
]);
|
|
65
63
|
export const isExecutableNodeType = (type) => hasGroup(type, GROUP_EXECUTABLE);
|
|
66
64
|
export const isElementNodeType = (type) => hasGroup(type, GROUP_ELEMENT);
|
|
@@ -32,6 +32,7 @@ export declare const jatsBodyTransformations: {
|
|
|
32
32
|
moveFootnotes(doc: Document, group: Element, createElement: (tagName: string) => HTMLElement): void;
|
|
33
33
|
moveCaptionsToEnd(body: Element): void;
|
|
34
34
|
fixTables(body: Element, createElement: (tagName: string) => HTMLElement): void;
|
|
35
|
+
orderTableFootnote(doc: Document, body: Element): void;
|
|
35
36
|
moveFloatsGroupToBody(doc: Document, body: Element, createElement: (tagName: string) => HTMLElement): void;
|
|
36
37
|
createKeywords(document: Document, body: Element, createElement: (tagName: string) => HTMLElement): void;
|
|
37
38
|
createSuppleMaterials(document: Document, body: Element, createElement: (tagName: string) => HTMLElement): void;
|
|
@@ -13,10 +13,8 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { ParagraphElement } from '@manuscripts/json-schema';
|
|
17
|
-
import { Build } from '../../transformer';
|
|
18
16
|
export declare const jatsFrontParser: {
|
|
19
|
-
parseTitles(element: Element | null, createElement: (tagName: string) => HTMLElement): Build<import("@manuscripts/json-schema").Titles>;
|
|
17
|
+
parseTitles(element: Element | null, createElement: (tagName: string) => HTMLElement): import("../../transformer").Build<import("@manuscripts/json-schema/dist/types").Titles>;
|
|
20
18
|
parseCounts(counts: Element | null): {
|
|
21
19
|
wordCount: number | undefined;
|
|
22
20
|
figureCount: number | undefined;
|
|
@@ -50,7 +48,7 @@ export declare const jatsFrontParser: {
|
|
|
50
48
|
publisherName: string | undefined;
|
|
51
49
|
_id: string;
|
|
52
50
|
objectType: string;
|
|
53
|
-
contributions?: import("@manuscripts/json-schema").Contribution[] | undefined;
|
|
51
|
+
contributions?: import("@manuscripts/json-schema/dist/types").Contribution[] | undefined;
|
|
54
52
|
};
|
|
55
53
|
parseDates(historyNode: Element | null): {
|
|
56
54
|
acceptanceDate?: number | undefined;
|
|
@@ -61,17 +59,16 @@ export declare const jatsFrontParser: {
|
|
|
61
59
|
receiveDate?: number | undefined;
|
|
62
60
|
} | undefined;
|
|
63
61
|
parseAffiliations(elements: Element[]): {
|
|
64
|
-
affiliations: Build<import("@manuscripts/json-schema").Affiliation>[];
|
|
62
|
+
affiliations: import("../../transformer").Build<import("@manuscripts/json-schema/dist/types").Affiliation>[];
|
|
65
63
|
affiliationIDs: Map<string, string>;
|
|
66
64
|
};
|
|
67
65
|
parseAuthorNotes(elements: Element[]): {
|
|
68
|
-
footnotes: Build<import("@manuscripts/json-schema").Footnote>[];
|
|
66
|
+
footnotes: import("../../transformer").Build<import("@manuscripts/json-schema/dist/types").Footnote>[];
|
|
69
67
|
footnoteIDs: Map<string, string>;
|
|
70
68
|
};
|
|
71
|
-
parseAuthorNotesParagraphs(elements: Element[]): Build<ParagraphElement>[];
|
|
72
69
|
parseCorresp(elements: Element[]): {
|
|
73
|
-
correspondingList: Build<import("@manuscripts/json-schema").Corresponding>[];
|
|
70
|
+
correspondingList: import("../../transformer").Build<import("@manuscripts/json-schema/dist/types").Corresponding>[];
|
|
74
71
|
correspondingIDs: Map<string, string>;
|
|
75
72
|
};
|
|
76
|
-
parseContributors(elements: Element[], affiliationIDs: Map<string, string>, footnoteIDs: Map<string, string>, correspondingIDs: Map<string, string>): Build<import("@manuscripts/json-schema").Contributor>[];
|
|
73
|
+
parseContributors(elements: Element[], affiliationIDs: Map<string, string>, footnoteIDs: Map<string, string>, correspondingIDs: Map<string, string>): import("../../transformer").Build<import("@manuscripts/json-schema/dist/types").Contributor>[];
|
|
77
74
|
};
|
|
@@ -86,9 +86,6 @@ export declare class JATSExporter {
|
|
|
86
86
|
protected serializeNode: (node: ManuscriptNode) => Node;
|
|
87
87
|
private validateContributor;
|
|
88
88
|
private buildContributors;
|
|
89
|
-
private appendParagraphToElement;
|
|
90
|
-
private appendCorrespondingToElement;
|
|
91
|
-
private appendFootnoteToElement;
|
|
92
89
|
private buildKeywords;
|
|
93
90
|
private fixBody;
|
|
94
91
|
private changeTag;
|
|
@@ -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';
|
|
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,
|
|
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';
|
|
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,8 +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
|
|
50
|
-
export declare const buildFootnotesOrder: (footnotesList: FootnotesOrderIndexList) => Build<FootnotesOrder>;
|
|
49
|
+
export declare const buildFootnotesOrder: (footnotesList: FootnotesOrderIndexList, containedObjectID: string) => Build<FootnotesOrder>;
|
|
51
50
|
export declare const buildCorresp: (contents: string) => Build<Corresponding>;
|
|
52
51
|
export declare const buildSection: (priority?: number, path?: string[]) => Build<Section>;
|
|
53
52
|
export declare const buildParagraph: (placeholderInnerHTML: string) => Build<ParagraphElement>;
|
|
@@ -20,4 +20,3 @@ export type FootnotesOrderIndexList = {
|
|
|
20
20
|
}[];
|
|
21
21
|
export declare const createOrderedFootnotesIDs: (doc: Document) => string[];
|
|
22
22
|
export declare const handleFootnotesOrder: (orderedFootnotesIDs: Array<string>, replacements: Map<string, string>, footnotesOrder: FootnotesOrder) => void;
|
|
23
|
-
export declare const createEmptyFootnotesOrder: () => import("./builders").Build<FootnotesOrder>;
|
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.2",
|
|
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.
|
|
33
|
-
"@manuscripts/library": "1.3.
|
|
32
|
+
"@manuscripts/json-schema": "^2.2.4",
|
|
33
|
+
"@manuscripts/library": "^1.3.3",
|
|
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
|
+
}
|
|
@@ -1,27 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
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 {};
|