@manuscripts/transform 2.1.5 → 2.1.6-LEAN-3446-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 +39 -1
- package/dist/cjs/jats/importer/parse-jats-article.js +3 -6
- package/dist/cjs/jats/jats-exporter.js +66 -45
- package/dist/cjs/schema/index.js +3 -1
- 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 +11 -7
- package/dist/cjs/transformer/decode.js +13 -1
- package/dist/cjs/transformer/encode.js +3 -0
- package/dist/cjs/transformer/node-types.js +1 -0
- package/dist/es/jats/importer/jats-body-transformations.js +3 -1
- package/dist/es/jats/importer/jats-front-parser.js +40 -2
- package/dist/es/jats/importer/parse-jats-article.js +3 -6
- package/dist/es/jats/jats-exporter.js +69 -48
- package/dist/es/schema/index.js +3 -1
- 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 +9 -6
- package/dist/es/transformer/decode.js +13 -1
- package/dist/es/transformer/encode.js +3 -0
- package/dist/es/transformer/node-types.js +1 -0
- package/dist/types/jats/importer/jats-front-parser.d.ts +10 -1
- package/dist/types/jats/jats-exporter.d.ts +5 -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 +3 -2
- package/package.json +3 -3
|
@@ -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');
|
|
@@ -179,7 +179,45 @@ exports.jatsFrontParser = {
|
|
|
179
179
|
affiliationIDs,
|
|
180
180
|
};
|
|
181
181
|
},
|
|
182
|
-
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) {
|
|
183
221
|
const footnoteIDs = new Map();
|
|
184
222
|
const footnotes = elements.map((element) => {
|
|
185
223
|
const fn = (0, transformer_1.buildFootnote)('', element.innerHTML);
|
|
@@ -35,12 +35,7 @@ const parseJATSFront = (doc, front) => {
|
|
|
35
35
|
const { affiliations, affiliationIDs } = jats_front_parser_1.jatsFrontParser.parseAffiliations([
|
|
36
36
|
...front.querySelectorAll('article-meta > contrib-group > aff'),
|
|
37
37
|
]);
|
|
38
|
-
const { footnotes, footnoteIDs } = jats_front_parser_1.jatsFrontParser.parseAuthorNotes(
|
|
39
|
-
...front.querySelectorAll('article-meta > author-notes > fn:not([fn-type])'),
|
|
40
|
-
]);
|
|
41
|
-
const { correspondingList, correspondingIDs } = jats_front_parser_1.jatsFrontParser.parseCorresp([
|
|
42
|
-
...front.querySelectorAll('article-meta > author-notes > corresp'),
|
|
43
|
-
]);
|
|
38
|
+
const { footnotes, footnoteIDs, authorNotes, authorNotesParagraphs, correspondingIDs, correspondingList, } = jats_front_parser_1.jatsFrontParser.parseAuthorNotes(front.querySelector('article-meta > author-notes'));
|
|
44
39
|
const authors = jats_front_parser_1.jatsFrontParser.parseContributors([
|
|
45
40
|
...front.querySelectorAll('article-meta > contrib-group > contrib[contrib-type="author"]'),
|
|
46
41
|
], affiliationIDs, footnoteIDs, correspondingIDs);
|
|
@@ -51,6 +46,8 @@ const parseJATSFront = (doc, front) => {
|
|
|
51
46
|
manuscript,
|
|
52
47
|
titles,
|
|
53
48
|
journal,
|
|
49
|
+
...authorNotesParagraphs,
|
|
50
|
+
...authorNotes,
|
|
54
51
|
...footnotes,
|
|
55
52
|
...authors,
|
|
56
53
|
...affiliations,
|
|
@@ -154,6 +154,7 @@ class JATSExporter {
|
|
|
154
154
|
this.moveFloatsGroup(body, article);
|
|
155
155
|
this.removeBackContainer(body);
|
|
156
156
|
this.updateFootnoteTypes(front, back);
|
|
157
|
+
this.fillEmptyFootnotes(article);
|
|
157
158
|
}
|
|
158
159
|
await this.rewriteIDs(idGenerator);
|
|
159
160
|
if (mediaPathGenerator) {
|
|
@@ -615,6 +616,7 @@ class JATSExporter {
|
|
|
615
616
|
this.createSerializer = () => {
|
|
616
617
|
const getModel = (id) => id ? this.modelMap.get(id) : undefined;
|
|
617
618
|
const nodes = {
|
|
619
|
+
author_notes: () => ['author-notes', 0],
|
|
618
620
|
title: () => '',
|
|
619
621
|
affiliations: () => '',
|
|
620
622
|
contributors: () => '',
|
|
@@ -1035,6 +1037,7 @@ class JATSExporter {
|
|
|
1035
1037
|
}
|
|
1036
1038
|
};
|
|
1037
1039
|
this.buildContributors = (articleMeta) => {
|
|
1040
|
+
var _a;
|
|
1038
1041
|
const contributors = this.models.filter(isContributor);
|
|
1039
1042
|
const authorContributors = contributors
|
|
1040
1043
|
.filter((contributor) => contributor.role === 'author')
|
|
@@ -1253,56 +1256,61 @@ class JATSExporter {
|
|
|
1253
1256
|
}
|
|
1254
1257
|
});
|
|
1255
1258
|
}
|
|
1256
|
-
const
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
const authorNotesEl = this.document.createElement('author-notes');
|
|
1277
|
-
const usedFootnotes = footnotes.filter((footnote) => {
|
|
1278
|
-
return noteIDs.includes(footnote._id);
|
|
1279
|
-
});
|
|
1280
|
-
const usedCorrespodings = correspodings.filter((corresp) => {
|
|
1281
|
-
return noteIDs.includes(corresp._id);
|
|
1282
|
-
});
|
|
1283
|
-
usedFootnotes.forEach((footnote) => {
|
|
1284
|
-
const authorFootNote = this.document.createElement('fn');
|
|
1285
|
-
authorFootNote.setAttribute('id', normalizeID(footnote._id));
|
|
1286
|
-
authorFootNote.innerHTML = footnote.contents;
|
|
1287
|
-
authorNotesEl.appendChild(authorFootNote);
|
|
1288
|
-
});
|
|
1289
|
-
usedCorrespodings.forEach((corresponding) => {
|
|
1290
|
-
const correspondingEl = this.document.createElement('corresp');
|
|
1291
|
-
correspondingEl.setAttribute('id', normalizeID(corresponding._id));
|
|
1292
|
-
if (corresponding.label) {
|
|
1293
|
-
const labelEl = this.document.createElement('label');
|
|
1294
|
-
labelEl.textContent = corresponding.label;
|
|
1295
|
-
correspondingEl.appendChild(labelEl);
|
|
1259
|
+
const authorNotesEl = this.document.createElement('author-notes');
|
|
1260
|
+
const usedCorrespodings = this.getUsedCorrespondings([
|
|
1261
|
+
...authorContributors,
|
|
1262
|
+
...otherContributors,
|
|
1263
|
+
]);
|
|
1264
|
+
usedCorrespodings.forEach((corresp) => {
|
|
1265
|
+
this.appendCorrespondingToElement(corresp, authorNotesEl);
|
|
1266
|
+
});
|
|
1267
|
+
const authorNotes = (_a = (0, json_schema_1.getModelsByType)(this.modelMap, json_schema_1.ObjectTypes.AuthorNotes)) === null || _a === void 0 ? void 0 : _a[0];
|
|
1268
|
+
if (authorNotes) {
|
|
1269
|
+
authorNotes.containedObjectIDs.forEach((id) => {
|
|
1270
|
+
const model = this.modelMap.get(id);
|
|
1271
|
+
if (!model) {
|
|
1272
|
+
return;
|
|
1273
|
+
}
|
|
1274
|
+
if (id.startsWith('MPParagraphElement')) {
|
|
1275
|
+
this.appendParagraphToElement(model, authorNotesEl);
|
|
1276
|
+
}
|
|
1277
|
+
else if (id.startsWith('MPFootnote')) {
|
|
1278
|
+
this.appendFootnoteToElement(model, authorNotesEl);
|
|
1296
1279
|
}
|
|
1297
|
-
correspondingEl.append(corresponding.contents);
|
|
1298
|
-
authorNotesEl.appendChild(correspondingEl);
|
|
1299
1280
|
});
|
|
1300
|
-
if (authorNotesEl.childNodes.length > 0) {
|
|
1301
|
-
articleMeta.insertBefore(authorNotesEl, contribGroup.nextSibling);
|
|
1302
|
-
}
|
|
1303
1281
|
}
|
|
1282
|
+
if (authorNotesEl.childNodes.length > 0) {
|
|
1283
|
+
articleMeta.insertBefore(authorNotesEl, contribGroup.nextSibling);
|
|
1284
|
+
}
|
|
1285
|
+
}
|
|
1286
|
+
};
|
|
1287
|
+
this.appendCorrespondingToElement = (corresponding, element) => {
|
|
1288
|
+
const correspondingEl = this.document.createElement('corresp');
|
|
1289
|
+
correspondingEl.setAttribute('id', normalizeID(corresponding._id));
|
|
1290
|
+
if (corresponding.label) {
|
|
1291
|
+
const labelEl = this.document.createElement('label');
|
|
1292
|
+
labelEl.textContent = corresponding.label;
|
|
1293
|
+
correspondingEl.appendChild(labelEl);
|
|
1294
|
+
}
|
|
1295
|
+
correspondingEl.append(corresponding.contents);
|
|
1296
|
+
element.appendChild(correspondingEl);
|
|
1297
|
+
};
|
|
1298
|
+
this.appendParagraphToElement = (paragraph, element) => {
|
|
1299
|
+
const parsedDoc = new DOMParser().parseFromString(paragraph.contents, 'text/html');
|
|
1300
|
+
const parsedParagraph = parsedDoc.body.querySelector('p');
|
|
1301
|
+
if (parsedParagraph) {
|
|
1302
|
+
const paragraphEl = this.document.createElement('p');
|
|
1303
|
+
paragraphEl.innerHTML = parsedParagraph.innerHTML;
|
|
1304
|
+
paragraphEl.setAttribute('id', normalizeID(paragraph._id));
|
|
1305
|
+
element.appendChild(paragraphEl);
|
|
1304
1306
|
}
|
|
1305
1307
|
};
|
|
1308
|
+
this.appendFootnoteToElement = (footnote, element) => {
|
|
1309
|
+
const footnoteEl = this.document.createElement('fn');
|
|
1310
|
+
footnoteEl.setAttribute('id', normalizeID(footnote._id));
|
|
1311
|
+
footnoteEl.innerHTML = footnote.contents;
|
|
1312
|
+
element.appendChild(footnoteEl);
|
|
1313
|
+
};
|
|
1306
1314
|
this.fixBody = (body, fragment) => {
|
|
1307
1315
|
fragment.descendants((node) => {
|
|
1308
1316
|
if (node.attrs.id) {
|
|
@@ -1605,6 +1613,12 @@ class JATSExporter {
|
|
|
1605
1613
|
return mathml;
|
|
1606
1614
|
}
|
|
1607
1615
|
}
|
|
1616
|
+
getUsedCorrespondings(contributors) {
|
|
1617
|
+
return contributors
|
|
1618
|
+
.flatMap((c) => { var _a; return (_a = c.corresp) !== null && _a !== void 0 ? _a : []; })
|
|
1619
|
+
.map((corresp) => this.modelMap.get(corresp.correspID))
|
|
1620
|
+
.filter((corresp) => !!corresp);
|
|
1621
|
+
}
|
|
1608
1622
|
buildKeywords(articleMeta) {
|
|
1609
1623
|
const keywords = [...this.modelMap.values()].filter((model) => model.objectType === json_schema_1.ObjectTypes.Keyword);
|
|
1610
1624
|
const keywordGroups = new Map();
|
|
@@ -1676,6 +1690,9 @@ class JATSExporter {
|
|
|
1676
1690
|
}
|
|
1677
1691
|
}
|
|
1678
1692
|
}
|
|
1693
|
+
if (!fnGroup.hasChildNodes()) {
|
|
1694
|
+
fnGroup.remove();
|
|
1695
|
+
}
|
|
1679
1696
|
}
|
|
1680
1697
|
}
|
|
1681
1698
|
});
|
|
@@ -1690,5 +1707,9 @@ class JATSExporter {
|
|
|
1690
1707
|
}
|
|
1691
1708
|
});
|
|
1692
1709
|
}
|
|
1710
|
+
fillEmptyFootnotes(articleElement) {
|
|
1711
|
+
const emptyFootnotes = Array.from(articleElement.querySelectorAll('fn')).filter((fn) => { var _a; return !((_a = fn.textContent) === null || _a === void 0 ? void 0 : _a.trim()); });
|
|
1712
|
+
emptyFootnotes.forEach((fn) => fn.appendChild(this.document.createElement('p')));
|
|
1713
|
+
}
|
|
1693
1714
|
}
|
|
1694
1715
|
exports.JATSExporter = JATSExporter;
|
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");
|
|
@@ -215,6 +216,7 @@ exports.schema = new prosemirror_model_1.Schema({
|
|
|
215
216
|
table_row: table_1.tableRow,
|
|
216
217
|
table_col: table_col_1.tableCol,
|
|
217
218
|
table_colgroup: table_col_1.tableColGroup,
|
|
219
|
+
table_header: table_1.tableHeader,
|
|
218
220
|
text: text_1.text,
|
|
219
221
|
toc_element: toc_element_1.tocElement,
|
|
220
222
|
toc_section: toc_section_1.tocSection,
|
|
@@ -226,6 +228,6 @@ exports.schema = new prosemirror_model_1.Schema({
|
|
|
226
228
|
contributors: contributors_1.contributors,
|
|
227
229
|
supplements: supplements_1.supplements,
|
|
228
230
|
supplement: supplement_1.supplement,
|
|
229
|
-
|
|
231
|
+
author_notes: author_notes_1.authorNotes,
|
|
230
232
|
},
|
|
231
233
|
});
|
|
@@ -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.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.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");
|
|
@@ -123,6 +123,12 @@ const buildFootnote = (containingObject, contents, kind = 'footnote') => ({
|
|
|
123
123
|
kind,
|
|
124
124
|
});
|
|
125
125
|
exports.buildFootnote = buildFootnote;
|
|
126
|
+
const buildAuthorNotes = (containedObjectIDs) => ({
|
|
127
|
+
_id: (0, id_1.generateID)(json_schema_1.ObjectTypes.AuthorNotes),
|
|
128
|
+
objectType: json_schema_1.ObjectTypes.AuthorNotes,
|
|
129
|
+
containedObjectIDs: containedObjectIDs,
|
|
130
|
+
});
|
|
131
|
+
exports.buildAuthorNotes = buildAuthorNotes;
|
|
126
132
|
const buildFootnotesOrder = (footnotesList, containedObjectID) => ({
|
|
127
133
|
_id: (0, id_1.generateID)(json_schema_1.ObjectTypes.FootnotesOrder),
|
|
128
134
|
objectType: json_schema_1.ObjectTypes.FootnotesOrder,
|
|
@@ -146,13 +152,12 @@ const buildSection = (priority = 0, path = []) => {
|
|
|
146
152
|
};
|
|
147
153
|
};
|
|
148
154
|
exports.buildSection = buildSection;
|
|
149
|
-
const buildParagraph = (
|
|
155
|
+
const buildParagraph = (innerHTML = '') => {
|
|
150
156
|
const _id = (0, id_1.generateID)(json_schema_1.ObjectTypes.ParagraphElement);
|
|
151
|
-
const element = document.createElementNS(
|
|
157
|
+
const element = document.createElementNS(null, 'p');
|
|
152
158
|
element.setAttribute('id', _id);
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
element.setAttribute('data-placeholder-text', placeholderInnerHTML);
|
|
159
|
+
if (innerHTML) {
|
|
160
|
+
element.innerHTML = innerHTML;
|
|
156
161
|
}
|
|
157
162
|
const contents = (0, w3c_xmlserializer_1.default)(element);
|
|
158
163
|
return {
|
|
@@ -160,7 +165,6 @@ const buildParagraph = (placeholderInnerHTML) => {
|
|
|
160
165
|
objectType: json_schema_1.ObjectTypes.ParagraphElement,
|
|
161
166
|
elementType: 'p',
|
|
162
167
|
contents,
|
|
163
|
-
placeholderInnerHTML,
|
|
164
168
|
};
|
|
165
169
|
};
|
|
166
170
|
exports.buildParagraph = buildParagraph;
|
|
@@ -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)
|
|
@@ -489,6 +494,13 @@ class Decoder {
|
|
|
489
494
|
id: model._id,
|
|
490
495
|
}, content);
|
|
491
496
|
},
|
|
497
|
+
[json_schema_1.ObjectTypes.AuthorNotes]: (data) => {
|
|
498
|
+
const model = data;
|
|
499
|
+
const content = model.containedObjectIDs.map((id) => this.decode(this.modelMap.get(id)));
|
|
500
|
+
return schema_1.schema.nodes.author_notes.create({
|
|
501
|
+
id: model._id,
|
|
502
|
+
}, content);
|
|
503
|
+
},
|
|
492
504
|
[json_schema_1.ObjectTypes.Section]: (data) => {
|
|
493
505
|
const model = data;
|
|
494
506
|
const elements = [];
|
|
@@ -383,6 +383,9 @@ const encoders = {
|
|
|
383
383
|
table_element_footer: (node) => ({
|
|
384
384
|
containedObjectIDs: containedObjectIDs(node),
|
|
385
385
|
}),
|
|
386
|
+
author_notes: (node) => ({
|
|
387
|
+
containedObjectIDs: containedObjectIDs(node),
|
|
388
|
+
}),
|
|
386
389
|
footnotes_section: (node, parent, path, priority) => ({
|
|
387
390
|
category: (0, section_category_1.buildSectionCategory)(node),
|
|
388
391
|
priority: priority.value++,
|
|
@@ -61,6 +61,7 @@ exports.nodeTypesMap = new Map([
|
|
|
61
61
|
[schema_1.schema.nodes.affiliations, json_schema_1.ObjectTypes.Section],
|
|
62
62
|
[schema_1.schema.nodes.title, json_schema_1.ObjectTypes.Titles],
|
|
63
63
|
[schema_1.schema.nodes.supplement, json_schema_1.ObjectTypes.Supplement],
|
|
64
|
+
[schema_1.schema.nodes.author_notes, json_schema_1.ObjectTypes.AuthorNotes],
|
|
64
65
|
]);
|
|
65
66
|
const isExecutableNodeType = (type) => (0, schema_1.hasGroup)(type, schema_1.GROUP_EXECUTABLE);
|
|
66
67
|
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');
|
|
@@ -173,7 +173,45 @@ export const jatsFrontParser = {
|
|
|
173
173
|
affiliationIDs,
|
|
174
174
|
};
|
|
175
175
|
},
|
|
176
|
-
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) {
|
|
177
215
|
const footnoteIDs = new Map();
|
|
178
216
|
const footnotes = elements.map((element) => {
|
|
179
217
|
const fn = buildFootnote('', element.innerHTML);
|
|
@@ -32,12 +32,7 @@ export const parseJATSFront = (doc, front) => {
|
|
|
32
32
|
const { affiliations, affiliationIDs } = jatsFrontParser.parseAffiliations([
|
|
33
33
|
...front.querySelectorAll('article-meta > contrib-group > aff'),
|
|
34
34
|
]);
|
|
35
|
-
const { footnotes, footnoteIDs } = jatsFrontParser.parseAuthorNotes(
|
|
36
|
-
...front.querySelectorAll('article-meta > author-notes > fn:not([fn-type])'),
|
|
37
|
-
]);
|
|
38
|
-
const { correspondingList, correspondingIDs } = jatsFrontParser.parseCorresp([
|
|
39
|
-
...front.querySelectorAll('article-meta > author-notes > corresp'),
|
|
40
|
-
]);
|
|
35
|
+
const { footnotes, footnoteIDs, authorNotes, authorNotesParagraphs, correspondingIDs, correspondingList, } = jatsFrontParser.parseAuthorNotes(front.querySelector('article-meta > author-notes'));
|
|
41
36
|
const authors = jatsFrontParser.parseContributors([
|
|
42
37
|
...front.querySelectorAll('article-meta > contrib-group > contrib[contrib-type="author"]'),
|
|
43
38
|
], affiliationIDs, footnoteIDs, correspondingIDs);
|
|
@@ -48,6 +43,8 @@ export const parseJATSFront = (doc, front) => {
|
|
|
48
43
|
manuscript,
|
|
49
44
|
titles,
|
|
50
45
|
journal,
|
|
46
|
+
...authorNotesParagraphs,
|
|
47
|
+
...authorNotes,
|
|
51
48
|
...footnotes,
|
|
52
49
|
...authors,
|
|
53
50
|
...affiliations,
|
|
@@ -13,10 +13,10 @@
|
|
|
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
|
-
import { DOMParser, DOMSerializer } from 'prosemirror-model';
|
|
19
|
+
import { DOMParser as ProsemirrorDOMParser, DOMSerializer, } from 'prosemirror-model';
|
|
20
20
|
import serializeToXML from 'w3c-xmlserializer';
|
|
21
21
|
import { nodeFromHTML, textFromHTML } from '../lib/html';
|
|
22
22
|
import { normalizeStyleName } from '../lib/styled-content';
|
|
@@ -32,7 +32,7 @@ import { selectVersionIds } from './jats-versions';
|
|
|
32
32
|
const warn = debug('manuscripts-transform');
|
|
33
33
|
const XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
|
|
34
34
|
const normalizeID = (id) => id.replace(/:/g, '_');
|
|
35
|
-
const parser =
|
|
35
|
+
const parser = ProsemirrorDOMParser.fromSchema(schema);
|
|
36
36
|
const findChildNodeOfType = (node, nodeType) => {
|
|
37
37
|
for (const child of iterateChildren(node)) {
|
|
38
38
|
if (child.type === nodeType) {
|
|
@@ -146,6 +146,7 @@ export class JATSExporter {
|
|
|
146
146
|
this.moveFloatsGroup(body, article);
|
|
147
147
|
this.removeBackContainer(body);
|
|
148
148
|
this.updateFootnoteTypes(front, back);
|
|
149
|
+
this.fillEmptyFootnotes(article);
|
|
149
150
|
}
|
|
150
151
|
await this.rewriteIDs(idGenerator);
|
|
151
152
|
if (mediaPathGenerator) {
|
|
@@ -607,6 +608,7 @@ export class JATSExporter {
|
|
|
607
608
|
this.createSerializer = () => {
|
|
608
609
|
const getModel = (id) => id ? this.modelMap.get(id) : undefined;
|
|
609
610
|
const nodes = {
|
|
611
|
+
author_notes: () => ['author-notes', 0],
|
|
610
612
|
title: () => '',
|
|
611
613
|
affiliations: () => '',
|
|
612
614
|
contributors: () => '',
|
|
@@ -1027,6 +1029,7 @@ export class JATSExporter {
|
|
|
1027
1029
|
}
|
|
1028
1030
|
};
|
|
1029
1031
|
this.buildContributors = (articleMeta) => {
|
|
1032
|
+
var _a;
|
|
1030
1033
|
const contributors = this.models.filter(isContributor);
|
|
1031
1034
|
const authorContributors = contributors
|
|
1032
1035
|
.filter((contributor) => contributor.role === 'author')
|
|
@@ -1245,56 +1248,61 @@ export class JATSExporter {
|
|
|
1245
1248
|
}
|
|
1246
1249
|
});
|
|
1247
1250
|
}
|
|
1248
|
-
const
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
const authorNotesEl = this.document.createElement('author-notes');
|
|
1269
|
-
const usedFootnotes = footnotes.filter((footnote) => {
|
|
1270
|
-
return noteIDs.includes(footnote._id);
|
|
1271
|
-
});
|
|
1272
|
-
const usedCorrespodings = correspodings.filter((corresp) => {
|
|
1273
|
-
return noteIDs.includes(corresp._id);
|
|
1274
|
-
});
|
|
1275
|
-
usedFootnotes.forEach((footnote) => {
|
|
1276
|
-
const authorFootNote = this.document.createElement('fn');
|
|
1277
|
-
authorFootNote.setAttribute('id', normalizeID(footnote._id));
|
|
1278
|
-
authorFootNote.innerHTML = footnote.contents;
|
|
1279
|
-
authorNotesEl.appendChild(authorFootNote);
|
|
1280
|
-
});
|
|
1281
|
-
usedCorrespodings.forEach((corresponding) => {
|
|
1282
|
-
const correspondingEl = this.document.createElement('corresp');
|
|
1283
|
-
correspondingEl.setAttribute('id', normalizeID(corresponding._id));
|
|
1284
|
-
if (corresponding.label) {
|
|
1285
|
-
const labelEl = this.document.createElement('label');
|
|
1286
|
-
labelEl.textContent = corresponding.label;
|
|
1287
|
-
correspondingEl.appendChild(labelEl);
|
|
1251
|
+
const authorNotesEl = this.document.createElement('author-notes');
|
|
1252
|
+
const usedCorrespodings = this.getUsedCorrespondings([
|
|
1253
|
+
...authorContributors,
|
|
1254
|
+
...otherContributors,
|
|
1255
|
+
]);
|
|
1256
|
+
usedCorrespodings.forEach((corresp) => {
|
|
1257
|
+
this.appendCorrespondingToElement(corresp, authorNotesEl);
|
|
1258
|
+
});
|
|
1259
|
+
const authorNotes = (_a = getModelsByType(this.modelMap, ObjectTypes.AuthorNotes)) === null || _a === void 0 ? void 0 : _a[0];
|
|
1260
|
+
if (authorNotes) {
|
|
1261
|
+
authorNotes.containedObjectIDs.forEach((id) => {
|
|
1262
|
+
const model = this.modelMap.get(id);
|
|
1263
|
+
if (!model) {
|
|
1264
|
+
return;
|
|
1265
|
+
}
|
|
1266
|
+
if (id.startsWith('MPParagraphElement')) {
|
|
1267
|
+
this.appendParagraphToElement(model, authorNotesEl);
|
|
1268
|
+
}
|
|
1269
|
+
else if (id.startsWith('MPFootnote')) {
|
|
1270
|
+
this.appendFootnoteToElement(model, authorNotesEl);
|
|
1288
1271
|
}
|
|
1289
|
-
correspondingEl.append(corresponding.contents);
|
|
1290
|
-
authorNotesEl.appendChild(correspondingEl);
|
|
1291
1272
|
});
|
|
1292
|
-
if (authorNotesEl.childNodes.length > 0) {
|
|
1293
|
-
articleMeta.insertBefore(authorNotesEl, contribGroup.nextSibling);
|
|
1294
|
-
}
|
|
1295
1273
|
}
|
|
1274
|
+
if (authorNotesEl.childNodes.length > 0) {
|
|
1275
|
+
articleMeta.insertBefore(authorNotesEl, contribGroup.nextSibling);
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
};
|
|
1279
|
+
this.appendCorrespondingToElement = (corresponding, element) => {
|
|
1280
|
+
const correspondingEl = this.document.createElement('corresp');
|
|
1281
|
+
correspondingEl.setAttribute('id', normalizeID(corresponding._id));
|
|
1282
|
+
if (corresponding.label) {
|
|
1283
|
+
const labelEl = this.document.createElement('label');
|
|
1284
|
+
labelEl.textContent = corresponding.label;
|
|
1285
|
+
correspondingEl.appendChild(labelEl);
|
|
1286
|
+
}
|
|
1287
|
+
correspondingEl.append(corresponding.contents);
|
|
1288
|
+
element.appendChild(correspondingEl);
|
|
1289
|
+
};
|
|
1290
|
+
this.appendParagraphToElement = (paragraph, element) => {
|
|
1291
|
+
const parsedDoc = new DOMParser().parseFromString(paragraph.contents, 'text/html');
|
|
1292
|
+
const parsedParagraph = parsedDoc.body.querySelector('p');
|
|
1293
|
+
if (parsedParagraph) {
|
|
1294
|
+
const paragraphEl = this.document.createElement('p');
|
|
1295
|
+
paragraphEl.innerHTML = parsedParagraph.innerHTML;
|
|
1296
|
+
paragraphEl.setAttribute('id', normalizeID(paragraph._id));
|
|
1297
|
+
element.appendChild(paragraphEl);
|
|
1296
1298
|
}
|
|
1297
1299
|
};
|
|
1300
|
+
this.appendFootnoteToElement = (footnote, element) => {
|
|
1301
|
+
const footnoteEl = this.document.createElement('fn');
|
|
1302
|
+
footnoteEl.setAttribute('id', normalizeID(footnote._id));
|
|
1303
|
+
footnoteEl.innerHTML = footnote.contents;
|
|
1304
|
+
element.appendChild(footnoteEl);
|
|
1305
|
+
};
|
|
1298
1306
|
this.fixBody = (body, fragment) => {
|
|
1299
1307
|
fragment.descendants((node) => {
|
|
1300
1308
|
if (node.attrs.id) {
|
|
@@ -1597,6 +1605,12 @@ export class JATSExporter {
|
|
|
1597
1605
|
return mathml;
|
|
1598
1606
|
}
|
|
1599
1607
|
}
|
|
1608
|
+
getUsedCorrespondings(contributors) {
|
|
1609
|
+
return contributors
|
|
1610
|
+
.flatMap((c) => { var _a; return (_a = c.corresp) !== null && _a !== void 0 ? _a : []; })
|
|
1611
|
+
.map((corresp) => this.modelMap.get(corresp.correspID))
|
|
1612
|
+
.filter((corresp) => !!corresp);
|
|
1613
|
+
}
|
|
1600
1614
|
buildKeywords(articleMeta) {
|
|
1601
1615
|
const keywords = [...this.modelMap.values()].filter((model) => model.objectType === ObjectTypes.Keyword);
|
|
1602
1616
|
const keywordGroups = new Map();
|
|
@@ -1668,6 +1682,9 @@ export class JATSExporter {
|
|
|
1668
1682
|
}
|
|
1669
1683
|
}
|
|
1670
1684
|
}
|
|
1685
|
+
if (!fnGroup.hasChildNodes()) {
|
|
1686
|
+
fnGroup.remove();
|
|
1687
|
+
}
|
|
1671
1688
|
}
|
|
1672
1689
|
}
|
|
1673
1690
|
});
|
|
@@ -1682,4 +1699,8 @@ export class JATSExporter {
|
|
|
1682
1699
|
}
|
|
1683
1700
|
});
|
|
1684
1701
|
}
|
|
1702
|
+
fillEmptyFootnotes(articleElement) {
|
|
1703
|
+
const emptyFootnotes = Array.from(articleElement.querySelectorAll('fn')).filter((fn) => { var _a; return !((_a = fn.textContent) === null || _a === void 0 ? void 0 : _a.trim()); });
|
|
1704
|
+
emptyFootnotes.forEach((fn) => fn.appendChild(this.document.createElement('p')));
|
|
1705
|
+
}
|
|
1685
1706
|
}
|
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';
|
|
@@ -198,6 +199,7 @@ export const schema = new Schema({
|
|
|
198
199
|
table_row: tableRow,
|
|
199
200
|
table_col: tableCol,
|
|
200
201
|
table_colgroup: tableColGroup,
|
|
202
|
+
table_header: tableHeader,
|
|
201
203
|
text,
|
|
202
204
|
toc_element: tocElement,
|
|
203
205
|
toc_section: tocSection,
|
|
@@ -209,6 +211,6 @@ export const schema = new Schema({
|
|
|
209
211
|
contributors,
|
|
210
212
|
supplements,
|
|
211
213
|
supplement,
|
|
212
|
-
|
|
214
|
+
author_notes: authorNotes,
|
|
213
215
|
},
|
|
214
216
|
});
|
|
@@ -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
|
+
};
|
|
@@ -102,6 +102,11 @@ export const buildFootnote = (containingObject, contents, kind = 'footnote') =>
|
|
|
102
102
|
contents,
|
|
103
103
|
kind,
|
|
104
104
|
});
|
|
105
|
+
export const buildAuthorNotes = (containedObjectIDs) => ({
|
|
106
|
+
_id: generateID(ObjectTypes.AuthorNotes),
|
|
107
|
+
objectType: ObjectTypes.AuthorNotes,
|
|
108
|
+
containedObjectIDs: containedObjectIDs,
|
|
109
|
+
});
|
|
105
110
|
export const buildFootnotesOrder = (footnotesList, containedObjectID) => ({
|
|
106
111
|
_id: generateID(ObjectTypes.FootnotesOrder),
|
|
107
112
|
objectType: ObjectTypes.FootnotesOrder,
|
|
@@ -122,13 +127,12 @@ export const buildSection = (priority = 0, path = []) => {
|
|
|
122
127
|
path: path.concat(id),
|
|
123
128
|
};
|
|
124
129
|
};
|
|
125
|
-
export const buildParagraph = (
|
|
130
|
+
export const buildParagraph = (innerHTML = '') => {
|
|
126
131
|
const _id = generateID(ObjectTypes.ParagraphElement);
|
|
127
|
-
const element = document.createElementNS(
|
|
132
|
+
const element = document.createElementNS(null, 'p');
|
|
128
133
|
element.setAttribute('id', _id);
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
element.setAttribute('data-placeholder-text', placeholderInnerHTML);
|
|
134
|
+
if (innerHTML) {
|
|
135
|
+
element.innerHTML = innerHTML;
|
|
132
136
|
}
|
|
133
137
|
const contents = serializeToXML(element);
|
|
134
138
|
return {
|
|
@@ -136,7 +140,6 @@ export const buildParagraph = (placeholderInnerHTML) => {
|
|
|
136
140
|
objectType: ObjectTypes.ParagraphElement,
|
|
137
141
|
elementType: 'p',
|
|
138
142
|
contents,
|
|
139
|
-
placeholderInnerHTML,
|
|
140
143
|
};
|
|
141
144
|
};
|
|
142
145
|
export const buildColor = (value, priority) => ({
|
|
@@ -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)
|
|
@@ -480,6 +485,13 @@ export class Decoder {
|
|
|
480
485
|
id: model._id,
|
|
481
486
|
}, content);
|
|
482
487
|
},
|
|
488
|
+
[ObjectTypes.AuthorNotes]: (data) => {
|
|
489
|
+
const model = data;
|
|
490
|
+
const content = model.containedObjectIDs.map((id) => this.decode(this.modelMap.get(id)));
|
|
491
|
+
return schema.nodes.author_notes.create({
|
|
492
|
+
id: model._id,
|
|
493
|
+
}, content);
|
|
494
|
+
},
|
|
483
495
|
[ObjectTypes.Section]: (data) => {
|
|
484
496
|
const model = data;
|
|
485
497
|
const elements = [];
|
|
@@ -375,6 +375,9 @@ const encoders = {
|
|
|
375
375
|
table_element_footer: (node) => ({
|
|
376
376
|
containedObjectIDs: containedObjectIDs(node),
|
|
377
377
|
}),
|
|
378
|
+
author_notes: (node) => ({
|
|
379
|
+
containedObjectIDs: containedObjectIDs(node),
|
|
380
|
+
}),
|
|
378
381
|
footnotes_section: (node, parent, path, priority) => ({
|
|
379
382
|
category: buildSectionCategory(node),
|
|
380
383
|
priority: priority.value++,
|
|
@@ -58,6 +58,7 @@ export const nodeTypesMap = new Map([
|
|
|
58
58
|
[schema.nodes.affiliations, ObjectTypes.Section],
|
|
59
59
|
[schema.nodes.title, ObjectTypes.Titles],
|
|
60
60
|
[schema.nodes.supplement, ObjectTypes.Supplement],
|
|
61
|
+
[schema.nodes.author_notes, ObjectTypes.AuthorNotes],
|
|
61
62
|
]);
|
|
62
63
|
export const isExecutableNodeType = (type) => hasGroup(type, GROUP_EXECUTABLE);
|
|
63
64
|
export const isElementNodeType = (type) => hasGroup(type, GROUP_ELEMENT);
|
|
@@ -63,7 +63,16 @@ export declare const jatsFrontParser: {
|
|
|
63
63
|
affiliations: import("../../transformer").Build<import("@manuscripts/json-schema/dist/types").Affiliation>[];
|
|
64
64
|
affiliationIDs: Map<string, string>;
|
|
65
65
|
};
|
|
66
|
-
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[]): {
|
|
67
76
|
footnotes: import("../../transformer").Build<import("@manuscripts/json-schema/dist/types").Footnote>[];
|
|
68
77
|
footnoteIDs: Map<string, string>;
|
|
69
78
|
};
|
|
@@ -87,6 +87,10 @@ export declare class JATSExporter {
|
|
|
87
87
|
protected serializeNode: (node: ManuscriptNode) => Node;
|
|
88
88
|
private validateContributor;
|
|
89
89
|
private buildContributors;
|
|
90
|
+
private appendCorrespondingToElement;
|
|
91
|
+
private getUsedCorrespondings;
|
|
92
|
+
private appendParagraphToElement;
|
|
93
|
+
private appendFootnoteToElement;
|
|
90
94
|
private buildKeywords;
|
|
91
95
|
private fixBody;
|
|
92
96
|
private changeTag;
|
|
@@ -100,5 +104,6 @@ export declare class JATSExporter {
|
|
|
100
104
|
private buildContributorName;
|
|
101
105
|
private moveCoiStatementToAuthorNotes;
|
|
102
106
|
private updateFootnoteTypes;
|
|
107
|
+
private fillEmptyFootnotes;
|
|
103
108
|
}
|
|
104
109
|
export {};
|
|
@@ -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_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_cell' | 'table_element' | 'table_row' | 'table_colgroup' | 'table_col' | 'table_header' | '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, 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, 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>> & {
|
|
@@ -45,10 +45,11 @@ export declare const buildSupplementaryMaterial: (title: string, href: string) =
|
|
|
45
45
|
export declare const buildComment: (target: string, contents?: string, selector?: CommentSelector, contributions?: Contribution[], annotationColor?: string) => Build<CommentAnnotation>;
|
|
46
46
|
export declare const buildNote: (target: string, source: 'EMAIL' | 'EDITOR' | 'DASHBOARD', contents?: string) => Build<ManuscriptNote>;
|
|
47
47
|
export declare const buildFootnote: (containingObject: string, contents: string, kind?: 'footnote' | 'endnote') => Build<Footnote>;
|
|
48
|
+
export declare const buildAuthorNotes: (containedObjectIDs: string[]) => Build<AuthorNotes>;
|
|
48
49
|
export declare const buildFootnotesOrder: (footnotesList: FootnotesOrderIndexList, containedObjectID: string) => Build<FootnotesOrder>;
|
|
49
50
|
export declare const buildCorresp: (contents: string) => Build<Corresponding>;
|
|
50
51
|
export declare const buildSection: (priority?: number, path?: string[]) => Build<Section>;
|
|
51
|
-
export declare const buildParagraph: (
|
|
52
|
+
export declare const buildParagraph: (innerHTML?: string) => Build<ParagraphElement>;
|
|
52
53
|
export declare const buildColor: (value: string, priority: number) => Build<Color>;
|
|
53
54
|
export declare const buildContribution: (profileID: string) => Contribution;
|
|
54
55
|
export declare const buildContributorRole: (name: string) => Build<ContributorRole>;
|
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.6-LEAN-3446-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.
|
|
33
|
-
"@manuscripts/library": "^1.3.
|
|
32
|
+
"@manuscripts/json-schema": "^2.2.6",
|
|
33
|
+
"@manuscripts/library": "^1.3.5",
|
|
34
34
|
"debug": "^4.3.4",
|
|
35
35
|
"jszip": "^3.10.1",
|
|
36
36
|
"mime": "^3.0.0",
|