@manuscripts/transform 1.0.0 → 1.0.1-LEAN-2105
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-parser-utils.js +2 -2
- package/dist/cjs/jats/jats-exporter.js +17 -16
- package/dist/cjs/schema/index.js +2 -0
- package/dist/cjs/schema/nodes/blockquote_element.js +2 -2
- package/dist/{types/transformer/tei-grobid-importer.d.ts → cjs/schema/nodes/comment_list.js} +10 -6
- package/dist/cjs/schema/nodes/equation.js +3 -3
- package/dist/cjs/schema/nodes/inline_equation.js +3 -3
- package/dist/cjs/schema/nodes/list.js +3 -3
- package/dist/cjs/schema/nodes/listing.js +3 -3
- package/dist/cjs/schema/nodes/manuscript.js +1 -1
- package/dist/cjs/schema/nodes/paragraph.js +2 -2
- package/dist/cjs/schema/nodes/pullquote_element.js +2 -2
- package/dist/cjs/transformer/builders.js +73 -73
- package/dist/cjs/transformer/decode.js +67 -37
- package/dist/cjs/transformer/document-object-types.js +11 -11
- package/dist/cjs/transformer/encode.js +11 -10
- package/dist/cjs/transformer/html.js +2 -2
- package/dist/cjs/transformer/index.js +0 -1
- package/dist/cjs/transformer/labels.js +1 -2
- package/dist/cjs/transformer/manuscript-dependencies.js +3 -3
- package/dist/cjs/transformer/node-types.js +34 -33
- package/dist/cjs/transformer/object-types.js +23 -23
- package/dist/cjs/transformer/project-bundle.js +4 -4
- package/dist/cjs/transformer/section-category.js +5 -5
- package/dist/es/jats/importer/jats-parser-utils.js +1 -1
- package/dist/es/jats/jats-exporter.js +2 -1
- package/dist/es/schema/index.js +2 -0
- package/dist/es/schema/nodes/blockquote_element.js +1 -1
- package/dist/es/schema/nodes/comment_list.js +21 -0
- package/dist/es/schema/nodes/equation.js +1 -1
- package/dist/es/schema/nodes/inline_equation.js +1 -1
- package/dist/es/schema/nodes/list.js +1 -1
- package/dist/es/schema/nodes/listing.js +1 -1
- package/dist/es/schema/nodes/manuscript.js +1 -1
- package/dist/es/schema/nodes/paragraph.js +1 -1
- package/dist/es/schema/nodes/pullquote_element.js +1 -1
- package/dist/es/transformer/builders.js +1 -1
- package/dist/es/transformer/decode.js +43 -13
- package/dist/es/transformer/document-object-types.js +1 -1
- package/dist/es/transformer/encode.js +12 -11
- package/dist/es/transformer/html.js +1 -1
- package/dist/es/transformer/index.js +0 -1
- package/dist/es/transformer/labels.js +1 -2
- package/dist/es/transformer/manuscript-dependencies.js +1 -1
- package/dist/es/transformer/node-types.js +2 -1
- package/dist/es/transformer/object-types.js +1 -1
- package/dist/es/transformer/project-bundle.js +1 -1
- package/dist/es/transformer/section-category.js +1 -1
- package/dist/types/jats/importer/jats-body-transformations.d.ts +1 -1
- package/dist/types/jats/importer/jats-comments.d.ts +1 -1
- package/dist/types/jats/importer/jats-front-parser.d.ts +6 -6
- package/dist/types/jats/importer/jats-parser-utils.d.ts +1 -1
- package/dist/types/jats/importer/jats-reference-parser.d.ts +2 -2
- package/dist/types/jats/importer/parse-jats-article.d.ts +2 -2
- package/dist/types/jats/jats-exporter.d.ts +1 -1
- package/dist/types/lib/styled-content.d.ts +1 -1
- package/dist/types/schema/nodes/comment_list.d.ts +25 -0
- package/dist/types/schema/types.d.ts +1 -1
- package/dist/types/transformer/builders.d.ts +1 -1
- package/dist/types/transformer/bundles-data.d.ts +1 -1
- package/dist/types/transformer/bundles.d.ts +1 -1
- package/dist/types/transformer/decode.d.ts +2 -1
- package/dist/types/transformer/document-object-types.d.ts +1 -1
- package/dist/types/transformer/encode.d.ts +1 -1
- package/dist/types/transformer/footnotes-order.d.ts +1 -1
- package/dist/types/transformer/highlight-markers.d.ts +1 -1
- package/dist/types/transformer/html.d.ts +1 -1
- package/dist/types/transformer/id.d.ts +1 -1
- package/dist/types/transformer/index.d.ts +0 -1
- package/dist/types/transformer/labels.d.ts +1 -1
- package/dist/types/transformer/manuscript-dependencies.d.ts +1 -1
- package/dist/types/transformer/model-map.d.ts +1 -1
- package/dist/types/transformer/models.d.ts +1 -1
- package/dist/types/transformer/node-types.d.ts +1 -1
- package/dist/types/transformer/object-types.d.ts +1 -1
- package/dist/types/transformer/project-bundle.d.ts +1 -1
- package/dist/types/transformer/section-category.d.ts +1 -1
- package/dist/types/transformer/shared-data.d.ts +1 -1
- package/dist/types/transformer/update-identifiers.d.ts +1 -1
- package/package.json +2 -2
- package/dist/cjs/transformer/tei-grobid-importer.js +0 -121
- package/dist/es/transformer/tei-grobid-importer.js +0 -115
|
@@ -30,7 +30,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
30
30
|
};
|
|
31
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
32
|
exports.Decoder = exports.isManuscriptNode = exports.sortSectionsByPriority = exports.getModelsByType = exports.getModelData = void 0;
|
|
33
|
-
const
|
|
33
|
+
const json_schema_1 = require("@manuscripts/json-schema");
|
|
34
34
|
const debug_1 = __importDefault(require("debug"));
|
|
35
35
|
const prosemirror_model_1 = require("prosemirror-model");
|
|
36
36
|
const errors_1 = require("../errors");
|
|
@@ -59,11 +59,11 @@ const getModelsByType = (modelMap, objectType) => {
|
|
|
59
59
|
exports.getModelsByType = getModelsByType;
|
|
60
60
|
const sortSectionsByPriority = (a, b) => a.priority === b.priority ? 0 : Number(a.priority) - Number(b.priority);
|
|
61
61
|
exports.sortSectionsByPriority = sortSectionsByPriority;
|
|
62
|
-
const getSections = (modelMap) => (0, exports.getModelsByType)(modelMap,
|
|
62
|
+
const getSections = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.Section).sort(exports.sortSectionsByPriority);
|
|
63
63
|
const isManuscriptNode = (model) => model !== null;
|
|
64
64
|
exports.isManuscriptNode = isManuscriptNode;
|
|
65
|
-
const isParagraphElement = (0, object_types_1.hasObjectType)(
|
|
66
|
-
const isFootnote = (0, object_types_1.hasObjectType)(
|
|
65
|
+
const isParagraphElement = (0, object_types_1.hasObjectType)(json_schema_1.ObjectTypes.ParagraphElement);
|
|
66
|
+
const isFootnote = (0, object_types_1.hasObjectType)(json_schema_1.ObjectTypes.Footnote);
|
|
67
67
|
const hasParentSection = (id) => (section) => section.path &&
|
|
68
68
|
section.path.length > 1 &&
|
|
69
69
|
section.path[section.path.length - 2] === id;
|
|
@@ -98,8 +98,9 @@ class Decoder {
|
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
constructor(modelMap, allowMissingElements = false) {
|
|
101
|
+
this.comments = new Map();
|
|
101
102
|
this.creators = {
|
|
102
|
-
[
|
|
103
|
+
[json_schema_1.ObjectTypes.BibliographyElement]: (data) => {
|
|
103
104
|
var _a;
|
|
104
105
|
const model = data;
|
|
105
106
|
const referenceIDs = (_a = model.containedObjectIDs) === null || _a === void 0 ? void 0 : _a.filter((i) => i.startsWith('MPBibliographyItem'));
|
|
@@ -119,7 +120,7 @@ class Decoder {
|
|
|
119
120
|
paragraphStyle: model.paragraphStyle,
|
|
120
121
|
}, references);
|
|
121
122
|
},
|
|
122
|
-
[
|
|
123
|
+
[json_schema_1.ObjectTypes.BibliographyItem]: (data) => {
|
|
123
124
|
const model = data;
|
|
124
125
|
return schema_1.schema.nodes.bibliography_item.create({
|
|
125
126
|
id: model._id,
|
|
@@ -142,17 +143,19 @@ class Decoder {
|
|
|
142
143
|
id: model._id,
|
|
143
144
|
});
|
|
144
145
|
},
|
|
145
|
-
[
|
|
146
|
+
[json_schema_1.ObjectTypes.Figure]: (data) => {
|
|
146
147
|
const model = data;
|
|
148
|
+
const commentNodes = this.createCommentsNode(model);
|
|
149
|
+
commentNodes.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
147
150
|
return schema_1.schema.nodes.figure.create({
|
|
148
151
|
id: model._id,
|
|
149
152
|
contentType: model.contentType,
|
|
150
153
|
src: model.src,
|
|
151
154
|
position: model.position,
|
|
152
|
-
comments:
|
|
155
|
+
comments: commentNodes.map((c) => c.attrs.id),
|
|
153
156
|
});
|
|
154
157
|
},
|
|
155
|
-
[
|
|
158
|
+
[json_schema_1.ObjectTypes.FigureElement]: (data) => {
|
|
156
159
|
const model = data;
|
|
157
160
|
const paragraphIDs = model.containedObjectIDs.filter((i) => i.startsWith('MPParagraphElement'));
|
|
158
161
|
const figureIDs = model.containedObjectIDs.filter((i) => i.startsWith('MPFigure') || i.startsWith('MPMissingFigure'));
|
|
@@ -178,6 +181,8 @@ class Decoder {
|
|
|
178
181
|
figures.push(schema_1.schema.nodes.figure.createAndFill());
|
|
179
182
|
}
|
|
180
183
|
const figcaption = this.getFigcaption(model);
|
|
184
|
+
const commentNodes = this.createCommentsNode(model);
|
|
185
|
+
commentNodes.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
181
186
|
const content = [...paragraphs, ...figures, figcaption];
|
|
182
187
|
const listing = this.extractListing(model);
|
|
183
188
|
if (listing) {
|
|
@@ -198,10 +203,10 @@ class Decoder {
|
|
|
198
203
|
suppressTitle: Boolean(model.suppressTitle === undefined ? true : model.suppressTitle),
|
|
199
204
|
attribution: model.attribution,
|
|
200
205
|
alternatives: model.alternatives,
|
|
201
|
-
comments:
|
|
206
|
+
comments: commentNodes.map((c) => c.attrs.id),
|
|
202
207
|
}, content);
|
|
203
208
|
},
|
|
204
|
-
[
|
|
209
|
+
[json_schema_1.ObjectTypes.Equation]: (data) => {
|
|
205
210
|
const model = data;
|
|
206
211
|
return schema_1.schema.nodes.equation.createChecked({
|
|
207
212
|
id: model._id,
|
|
@@ -210,7 +215,7 @@ class Decoder {
|
|
|
210
215
|
TeXRepresentation: model.TeXRepresentation,
|
|
211
216
|
});
|
|
212
217
|
},
|
|
213
|
-
[
|
|
218
|
+
[json_schema_1.ObjectTypes.EquationElement]: (data) => {
|
|
214
219
|
const model = data;
|
|
215
220
|
const equationModel = this.getModel(model.containedObjectID);
|
|
216
221
|
let equation;
|
|
@@ -233,17 +238,19 @@ class Decoder {
|
|
|
233
238
|
suppressTitle: Boolean(model.suppressTitle === undefined ? true : model.suppressTitle),
|
|
234
239
|
}, [equation, figcaption]);
|
|
235
240
|
},
|
|
236
|
-
[
|
|
241
|
+
[json_schema_1.ObjectTypes.FootnotesElement]: (data) => {
|
|
237
242
|
const model = data;
|
|
238
243
|
const collateByKind = model.collateByKind || 'footnote';
|
|
239
244
|
const footnotesOfKind = [];
|
|
240
245
|
for (const model of this.modelMap.values()) {
|
|
241
246
|
if (isFootnote(model) && model.kind === collateByKind) {
|
|
247
|
+
const commentNodes = this.createCommentsNode(model);
|
|
248
|
+
commentNodes.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
242
249
|
const footnote = this.parseContents(model.contents || '<div></div>', undefined, this.getComments(model), {
|
|
243
250
|
topNode: schema_1.schema.nodes.footnote.create({
|
|
244
251
|
id: model._id,
|
|
245
252
|
kind: model.kind,
|
|
246
|
-
comments:
|
|
253
|
+
comments: commentNodes.map((c) => c.attrs.id),
|
|
247
254
|
}),
|
|
248
255
|
});
|
|
249
256
|
footnotesOfKind.push(footnote);
|
|
@@ -255,15 +262,17 @@ class Decoder {
|
|
|
255
262
|
paragraphStyle: model.paragraphStyle,
|
|
256
263
|
}, footnotesOfKind);
|
|
257
264
|
},
|
|
258
|
-
[
|
|
265
|
+
[json_schema_1.ObjectTypes.Footnote]: (data) => {
|
|
259
266
|
const model = data;
|
|
267
|
+
const commentNodes = this.createCommentsNode(model);
|
|
268
|
+
commentNodes.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
260
269
|
return schema_1.schema.nodes.footnote.create({
|
|
261
270
|
id: model._id,
|
|
262
271
|
kind: model.kind,
|
|
263
|
-
comments:
|
|
272
|
+
comments: commentNodes.map((c) => c.attrs.id),
|
|
264
273
|
});
|
|
265
274
|
},
|
|
266
|
-
[
|
|
275
|
+
[json_schema_1.ObjectTypes.KeywordsElement]: (data) => {
|
|
267
276
|
const model = data;
|
|
268
277
|
return schema_1.schema.nodes.keywords_element.create({
|
|
269
278
|
id: model._id,
|
|
@@ -273,15 +282,17 @@ class Decoder {
|
|
|
273
282
|
paragraphStyle: model.paragraphStyle,
|
|
274
283
|
});
|
|
275
284
|
},
|
|
276
|
-
[
|
|
285
|
+
[json_schema_1.ObjectTypes.ListElement]: (data) => {
|
|
277
286
|
const model = data;
|
|
287
|
+
const commentNodes = this.createCommentsNode(model);
|
|
288
|
+
commentNodes.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
278
289
|
switch (model.elementType) {
|
|
279
290
|
case 'ol':
|
|
280
291
|
return this.parseContents(model.contents || '<ol></ol>', undefined, this.getComments(model), {
|
|
281
292
|
topNode: schema_1.schema.nodes.ordered_list.create({
|
|
282
293
|
id: model._id,
|
|
283
294
|
paragraphStyle: model.paragraphStyle,
|
|
284
|
-
comments:
|
|
295
|
+
comments: commentNodes.map((c) => c.attrs.id),
|
|
285
296
|
}),
|
|
286
297
|
});
|
|
287
298
|
case 'ul':
|
|
@@ -295,17 +306,19 @@ class Decoder {
|
|
|
295
306
|
throw new Error('Unknown list element type');
|
|
296
307
|
}
|
|
297
308
|
},
|
|
298
|
-
[
|
|
309
|
+
[json_schema_1.ObjectTypes.Listing]: (data) => {
|
|
299
310
|
const model = data;
|
|
311
|
+
const commentNodes = this.createCommentsNode(model);
|
|
312
|
+
commentNodes.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
300
313
|
return schema_1.schema.nodes.listing.createChecked({
|
|
301
314
|
id: model._id,
|
|
302
315
|
contents: model.contents,
|
|
303
316
|
language: model.language,
|
|
304
317
|
languageKey: model.languageKey,
|
|
305
|
-
comments:
|
|
318
|
+
comments: commentNodes.map((c) => c.attrs.id),
|
|
306
319
|
});
|
|
307
320
|
},
|
|
308
|
-
[
|
|
321
|
+
[json_schema_1.ObjectTypes.ListingElement]: (data) => {
|
|
309
322
|
const model = data;
|
|
310
323
|
const listingModel = this.getModel(model.containedObjectID);
|
|
311
324
|
let listing;
|
|
@@ -322,32 +335,36 @@ class Decoder {
|
|
|
322
335
|
throw new errors_1.MissingElement(model.containedObjectID);
|
|
323
336
|
}
|
|
324
337
|
const figcaption = this.getFigcaption(model);
|
|
338
|
+
const commentNodes = this.createCommentsNode(model);
|
|
339
|
+
commentNodes.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
325
340
|
return schema_1.schema.nodes.listing_element.createChecked({
|
|
326
341
|
id: model._id,
|
|
327
342
|
suppressCaption: model.suppressCaption,
|
|
328
343
|
suppressTitle: Boolean(model.suppressTitle === undefined ? true : model.suppressTitle),
|
|
329
|
-
comments:
|
|
344
|
+
comments: commentNodes.map((c) => c.attrs.id),
|
|
330
345
|
}, [listing, figcaption]);
|
|
331
346
|
},
|
|
332
|
-
[
|
|
347
|
+
[json_schema_1.ObjectTypes.MissingFigure]: (data) => {
|
|
333
348
|
const model = data;
|
|
334
349
|
return schema_1.schema.nodes.missing_figure.create({
|
|
335
350
|
id: model._id,
|
|
336
351
|
position: model.position,
|
|
337
352
|
});
|
|
338
353
|
},
|
|
339
|
-
[
|
|
354
|
+
[json_schema_1.ObjectTypes.ParagraphElement]: (data) => {
|
|
340
355
|
const model = data;
|
|
356
|
+
const commentNodes = this.createCommentsNode(model);
|
|
357
|
+
commentNodes.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
341
358
|
return this.parseContents(model.contents || '<p></p>', undefined, this.getComments(model), {
|
|
342
359
|
topNode: schema_1.schema.nodes.paragraph.create({
|
|
343
360
|
id: model._id,
|
|
344
361
|
paragraphStyle: model.paragraphStyle,
|
|
345
362
|
placeholder: model.placeholderInnerHTML,
|
|
346
|
-
comments:
|
|
363
|
+
comments: commentNodes.map((c) => c.attrs.id),
|
|
347
364
|
}),
|
|
348
365
|
});
|
|
349
366
|
},
|
|
350
|
-
[
|
|
367
|
+
[json_schema_1.ObjectTypes.QuoteElement]: (data) => {
|
|
351
368
|
const model = data;
|
|
352
369
|
switch (model.quoteType) {
|
|
353
370
|
case 'block':
|
|
@@ -370,7 +387,7 @@ class Decoder {
|
|
|
370
387
|
throw new Error('Unknown block type');
|
|
371
388
|
}
|
|
372
389
|
},
|
|
373
|
-
[
|
|
390
|
+
[json_schema_1.ObjectTypes.Section]: (data) => {
|
|
374
391
|
const model = data;
|
|
375
392
|
const isKeywordsSection = model.category === 'MPSectionCategory:keywords';
|
|
376
393
|
const elements = [];
|
|
@@ -415,9 +432,11 @@ class Decoder {
|
|
|
415
432
|
}
|
|
416
433
|
const nestedSections = getSections(this.modelMap)
|
|
417
434
|
.filter(hasParentSection(model._id))
|
|
418
|
-
.map(this.creators[
|
|
435
|
+
.map(this.creators[json_schema_1.ObjectTypes.Section]);
|
|
419
436
|
const sectionCategory = model.category || (0, section_category_1.guessSectionCategory)(elements);
|
|
420
437
|
const sectionNodeType = (0, section_category_1.chooseSectionNodeType)(sectionCategory);
|
|
438
|
+
const commentNodes = this.createCommentsNode(model);
|
|
439
|
+
commentNodes.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
421
440
|
const content = (sectionLabelNode
|
|
422
441
|
? [sectionLabelNode, sectionTitleNode]
|
|
423
442
|
: [sectionTitleNode])
|
|
@@ -429,7 +448,7 @@ class Decoder {
|
|
|
429
448
|
titleSuppressed: model.titleSuppressed,
|
|
430
449
|
pageBreakStyle: model.pageBreakStyle,
|
|
431
450
|
generatedLabel: model.generatedLabel,
|
|
432
|
-
comments:
|
|
451
|
+
comments: commentNodes.map((c) => c.attrs.id),
|
|
433
452
|
}, content);
|
|
434
453
|
if (!sectionNode) {
|
|
435
454
|
console.error(model);
|
|
@@ -437,16 +456,18 @@ class Decoder {
|
|
|
437
456
|
}
|
|
438
457
|
return sectionNode;
|
|
439
458
|
},
|
|
440
|
-
[
|
|
459
|
+
[json_schema_1.ObjectTypes.Table]: (data) => {
|
|
441
460
|
const model = data;
|
|
461
|
+
const commentNodes = this.createCommentsNode(model);
|
|
462
|
+
commentNodes.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
442
463
|
return this.parseContents(model.contents, undefined, this.getComments(model), {
|
|
443
464
|
topNode: schema_1.schema.nodes.table.create({
|
|
444
465
|
id: model._id,
|
|
445
|
-
comments:
|
|
466
|
+
comments: commentNodes.map((c) => c.attrs.id),
|
|
446
467
|
}),
|
|
447
468
|
});
|
|
448
469
|
},
|
|
449
|
-
[
|
|
470
|
+
[json_schema_1.ObjectTypes.TableElement]: (data) => {
|
|
450
471
|
const model = data;
|
|
451
472
|
const tableModel = this.getModel(model.containedObjectID);
|
|
452
473
|
let table;
|
|
@@ -463,6 +484,8 @@ class Decoder {
|
|
|
463
484
|
throw new errors_1.MissingElement(model.containedObjectID);
|
|
464
485
|
}
|
|
465
486
|
const figcaption = this.getFigcaption(model);
|
|
487
|
+
const commentNodes = this.createCommentsNode(model);
|
|
488
|
+
commentNodes.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
466
489
|
const content = [table, figcaption];
|
|
467
490
|
if (model.listingID) {
|
|
468
491
|
const listingModel = this.getModel(model.listingID);
|
|
@@ -494,10 +517,10 @@ class Decoder {
|
|
|
494
517
|
suppressHeader: model.suppressHeader,
|
|
495
518
|
tableStyle: model.tableStyle,
|
|
496
519
|
paragraphStyle: model.paragraphStyle,
|
|
497
|
-
comments:
|
|
520
|
+
comments: commentNodes.map((c) => c.attrs.id),
|
|
498
521
|
}, content);
|
|
499
522
|
},
|
|
500
|
-
[
|
|
523
|
+
[json_schema_1.ObjectTypes.TOCElement]: (data) => {
|
|
501
524
|
const model = data;
|
|
502
525
|
return schema_1.schema.nodes.toc_element.create({
|
|
503
526
|
id: model._id,
|
|
@@ -507,7 +530,7 @@ class Decoder {
|
|
|
507
530
|
paragraphStyle: model.paragraphStyle,
|
|
508
531
|
});
|
|
509
532
|
},
|
|
510
|
-
[
|
|
533
|
+
[json_schema_1.ObjectTypes.CommentAnnotation]: (data) => {
|
|
511
534
|
const model = data;
|
|
512
535
|
return schema_1.schema.nodes.comment.create({
|
|
513
536
|
id: model._id,
|
|
@@ -536,9 +559,16 @@ class Decoder {
|
|
|
536
559
|
id: (0, id_1.generateNodeID)(schema_1.schema.nodes.section),
|
|
537
560
|
}));
|
|
538
561
|
}
|
|
562
|
+
const contents = rootSectionNodes;
|
|
563
|
+
if (this.comments.size) {
|
|
564
|
+
const comments = schema_1.schema.nodes.comment_list.createAndFill({
|
|
565
|
+
id: (0, id_1.generateNodeID)(schema_1.schema.nodes.comment_list),
|
|
566
|
+
}, [...this.comments.values()]);
|
|
567
|
+
contents.push(comments);
|
|
568
|
+
}
|
|
539
569
|
return schema_1.schema.nodes.manuscript.create({
|
|
540
570
|
id: manuscriptID || this.getManuscriptID(),
|
|
541
|
-
},
|
|
571
|
+
}, contents);
|
|
542
572
|
};
|
|
543
573
|
this.addGeneratedLabels = (sections) => {
|
|
544
574
|
const nextLableCount = { Appendix: 1 };
|
|
@@ -16,16 +16,16 @@
|
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.documentObjectTypes = void 0;
|
|
19
|
-
const
|
|
19
|
+
const json_schema_1 = require("@manuscripts/json-schema");
|
|
20
20
|
exports.documentObjectTypes = [
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
21
|
+
json_schema_1.ObjectTypes.BibliographyElement,
|
|
22
|
+
json_schema_1.ObjectTypes.EquationElement,
|
|
23
|
+
json_schema_1.ObjectTypes.FigureElement,
|
|
24
|
+
json_schema_1.ObjectTypes.ListElement,
|
|
25
|
+
json_schema_1.ObjectTypes.ListingElement,
|
|
26
|
+
json_schema_1.ObjectTypes.Manuscript,
|
|
27
|
+
json_schema_1.ObjectTypes.ParagraphElement,
|
|
28
|
+
json_schema_1.ObjectTypes.Section,
|
|
29
|
+
json_schema_1.ObjectTypes.TableElement,
|
|
30
|
+
json_schema_1.ObjectTypes.TOCElement,
|
|
31
31
|
];
|
|
@@ -501,16 +501,6 @@ const modelFromNode = (node, parent, path, priority) => {
|
|
|
501
501
|
const model = data;
|
|
502
502
|
if ((0, highlight_markers_1.isHighlightableModel)(model)) {
|
|
503
503
|
(0, highlight_markers_1.extractHighlightMarkers)(model, commentAnnotationsMap);
|
|
504
|
-
if (node.attrs.comments) {
|
|
505
|
-
const commentNodes = node.attrs.comments;
|
|
506
|
-
commentNodes
|
|
507
|
-
.filter((commentNode) => !commentNode.attrs.selector)
|
|
508
|
-
.forEach((c) => {
|
|
509
|
-
const commentAnnotation = (0, builders_1.buildComment)(model._id, c.attrs.contents, c.attrs.selector);
|
|
510
|
-
commentAnnotation._id = c.attrs.id;
|
|
511
|
-
commentAnnotationsMap.set(commentAnnotation._id, commentAnnotation);
|
|
512
|
-
});
|
|
513
|
-
}
|
|
514
504
|
}
|
|
515
505
|
return { model, commentAnnotationsMap };
|
|
516
506
|
};
|
|
@@ -528,6 +518,9 @@ const encode = (node) => {
|
|
|
528
518
|
if ((0, schema_1.isHighlightMarkerNode)(child)) {
|
|
529
519
|
return;
|
|
530
520
|
}
|
|
521
|
+
if (child.type === schema_1.schema.nodes.comment_list) {
|
|
522
|
+
return;
|
|
523
|
+
}
|
|
531
524
|
if (placeholders.includes(child.type.name)) {
|
|
532
525
|
return;
|
|
533
526
|
}
|
|
@@ -539,6 +532,14 @@ const encode = (node) => {
|
|
|
539
532
|
commentAnnotationsMap.forEach((val, key) => models.set(key, val));
|
|
540
533
|
child.forEach(addModel(path.concat(child.attrs.id), child));
|
|
541
534
|
};
|
|
535
|
+
node.forEach((cNode) => {
|
|
536
|
+
if (cNode.type === schema_1.schema.nodes.comment_list) {
|
|
537
|
+
cNode.forEach((child) => {
|
|
538
|
+
const { model } = (0, exports.modelFromNode)(child, cNode, [], priority);
|
|
539
|
+
models.set(model._id, model);
|
|
540
|
+
});
|
|
541
|
+
}
|
|
542
|
+
});
|
|
542
543
|
node.forEach(addModel([], node));
|
|
543
544
|
return models;
|
|
544
545
|
};
|
|
@@ -19,7 +19,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
19
19
|
};
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
21
|
exports.HTMLTransformer = void 0;
|
|
22
|
-
const
|
|
22
|
+
const json_schema_1 = require("@manuscripts/json-schema");
|
|
23
23
|
const prosemirror_model_1 = require("prosemirror-model");
|
|
24
24
|
const w3c_xmlserializer_1 = __importDefault(require("w3c-xmlserializer"));
|
|
25
25
|
const jats_exporter_1 = require("../jats/jats-exporter");
|
|
@@ -334,7 +334,7 @@ class HTMLTransformer {
|
|
|
334
334
|
};
|
|
335
335
|
}
|
|
336
336
|
buildContributors(articleMeta) {
|
|
337
|
-
const contributors = Array.from(this.modelMap.values()).filter((0, object_types_1.hasObjectType)(
|
|
337
|
+
const contributors = Array.from(this.modelMap.values()).filter((0, object_types_1.hasObjectType)(json_schema_1.ObjectTypes.Contributor));
|
|
338
338
|
const affiliationIDs = [];
|
|
339
339
|
if (contributors && contributors.length) {
|
|
340
340
|
const contribGroup = this.document.createElement('div');
|
|
@@ -49,6 +49,5 @@ __exportStar(require("./project-bundle"), exports);
|
|
|
49
49
|
__exportStar(require("./section-category"), exports);
|
|
50
50
|
__exportStar(require("./serializer"), exports);
|
|
51
51
|
__exportStar(require("./shared-data"), exports);
|
|
52
|
-
__exportStar(require("./tei-grobid-importer"), exports);
|
|
53
52
|
__exportStar(require("./timestamp"), exports);
|
|
54
53
|
__exportStar(require("./update-identifiers"), exports);
|
|
@@ -49,8 +49,7 @@ const buildTargets = (fragment, manuscript) => {
|
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
51
|
const buildLabel = (type) => {
|
|
52
|
-
const
|
|
53
|
-
const counter = counters[viewLabel.name];
|
|
52
|
+
const counter = counters[type.name];
|
|
54
53
|
counter.index++;
|
|
55
54
|
return `${counter.label} ${counter.index}`;
|
|
56
55
|
};
|
|
@@ -12,11 +12,11 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
exports.updatedPageLayout = exports.getByPrototype = exports.fromPrototype = exports.loadBundledDependencies = exports.loadContributorRoles = exports.loadKeywords = exports.loadStyles = void 0;
|
|
15
|
-
const
|
|
15
|
+
const json_schema_1 = require("@manuscripts/json-schema");
|
|
16
16
|
const id_1 = require("./id");
|
|
17
17
|
const object_types_1 = require("./object-types");
|
|
18
18
|
const shared_data_1 = require("./shared-data");
|
|
19
|
-
const isStatusLabel = (0, object_types_1.hasObjectType)(
|
|
19
|
+
const isStatusLabel = (0, object_types_1.hasObjectType)(json_schema_1.ObjectTypes.StatusLabel);
|
|
20
20
|
const isBundledModel = (model) => model.bundled === true;
|
|
21
21
|
const loadBundledData = async (file) => {
|
|
22
22
|
const models = await (0, shared_data_1.loadSharedData)(file);
|
|
@@ -49,7 +49,7 @@ const getByPrototype = (modelMap, prototype) => {
|
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
51
|
exports.getByPrototype = getByPrototype;
|
|
52
|
-
const isParagraphStyle = (0, object_types_1.hasObjectType)(
|
|
52
|
+
const isParagraphStyle = (0, object_types_1.hasObjectType)(json_schema_1.ObjectTypes.ParagraphStyle);
|
|
53
53
|
const chooseNewDefaultParagraphStyle = (styles) => {
|
|
54
54
|
for (const style of styles.values()) {
|
|
55
55
|
if (isParagraphStyle(style)) {
|
|
@@ -16,41 +16,42 @@
|
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.isNodeType = exports.isSectionNodeType = exports.isElementNodeType = exports.isExecutableNodeType = exports.nodeTypesMap = void 0;
|
|
19
|
-
const
|
|
19
|
+
const json_schema_1 = require("@manuscripts/json-schema");
|
|
20
20
|
const schema_1 = require("../schema");
|
|
21
21
|
exports.nodeTypesMap = new Map([
|
|
22
|
-
[schema_1.schema.nodes.comment,
|
|
23
|
-
[schema_1.schema.nodes.bibliography_item,
|
|
24
|
-
[schema_1.schema.nodes.bibliography_element,
|
|
25
|
-
[schema_1.schema.nodes.bibliography_section,
|
|
26
|
-
[schema_1.schema.nodes.blockquote_element,
|
|
27
|
-
[schema_1.schema.nodes.bullet_list,
|
|
28
|
-
[schema_1.schema.nodes.citation,
|
|
29
|
-
[schema_1.schema.nodes.cross_reference,
|
|
30
|
-
[schema_1.schema.nodes.equation,
|
|
31
|
-
[schema_1.schema.nodes.equation_element,
|
|
32
|
-
[schema_1.schema.nodes.figure,
|
|
33
|
-
[schema_1.schema.nodes.missing_figure,
|
|
34
|
-
[schema_1.schema.nodes.figure_element,
|
|
35
|
-
[schema_1.schema.nodes.footnote,
|
|
36
|
-
[schema_1.schema.nodes.footnotes_element,
|
|
37
|
-
[schema_1.schema.nodes.footnotes_section,
|
|
38
|
-
[schema_1.schema.nodes.graphical_abstract_section,
|
|
39
|
-
[schema_1.schema.nodes.highlight_marker,
|
|
40
|
-
[schema_1.schema.nodes.inline_equation,
|
|
41
|
-
[schema_1.schema.nodes.keywords_element,
|
|
42
|
-
[schema_1.schema.nodes.keywords_section,
|
|
43
|
-
[schema_1.schema.nodes.listing,
|
|
44
|
-
[schema_1.schema.nodes.listing_element,
|
|
45
|
-
[schema_1.schema.nodes.manuscript,
|
|
46
|
-
[schema_1.schema.nodes.ordered_list,
|
|
47
|
-
[schema_1.schema.nodes.paragraph,
|
|
48
|
-
[schema_1.schema.nodes.pullquote_element,
|
|
49
|
-
[schema_1.schema.nodes.section,
|
|
50
|
-
[schema_1.schema.nodes.table,
|
|
51
|
-
[schema_1.schema.nodes.table_element,
|
|
52
|
-
[schema_1.schema.nodes.toc_element,
|
|
53
|
-
[schema_1.schema.nodes.toc_section,
|
|
22
|
+
[schema_1.schema.nodes.comment, json_schema_1.ObjectTypes.CommentAnnotation],
|
|
23
|
+
[schema_1.schema.nodes.bibliography_item, json_schema_1.ObjectTypes.BibliographyItem],
|
|
24
|
+
[schema_1.schema.nodes.bibliography_element, json_schema_1.ObjectTypes.BibliographyElement],
|
|
25
|
+
[schema_1.schema.nodes.bibliography_section, json_schema_1.ObjectTypes.Section],
|
|
26
|
+
[schema_1.schema.nodes.blockquote_element, json_schema_1.ObjectTypes.QuoteElement],
|
|
27
|
+
[schema_1.schema.nodes.bullet_list, json_schema_1.ObjectTypes.ListElement],
|
|
28
|
+
[schema_1.schema.nodes.citation, json_schema_1.ObjectTypes.Citation],
|
|
29
|
+
[schema_1.schema.nodes.cross_reference, json_schema_1.ObjectTypes.AuxiliaryObjectReference],
|
|
30
|
+
[schema_1.schema.nodes.equation, json_schema_1.ObjectTypes.Equation],
|
|
31
|
+
[schema_1.schema.nodes.equation_element, json_schema_1.ObjectTypes.EquationElement],
|
|
32
|
+
[schema_1.schema.nodes.figure, json_schema_1.ObjectTypes.Figure],
|
|
33
|
+
[schema_1.schema.nodes.missing_figure, json_schema_1.ObjectTypes.MissingFigure],
|
|
34
|
+
[schema_1.schema.nodes.figure_element, json_schema_1.ObjectTypes.FigureElement],
|
|
35
|
+
[schema_1.schema.nodes.footnote, json_schema_1.ObjectTypes.Footnote],
|
|
36
|
+
[schema_1.schema.nodes.footnotes_element, json_schema_1.ObjectTypes.FootnotesElement],
|
|
37
|
+
[schema_1.schema.nodes.footnotes_section, json_schema_1.ObjectTypes.Section],
|
|
38
|
+
[schema_1.schema.nodes.graphical_abstract_section, json_schema_1.ObjectTypes.Section],
|
|
39
|
+
[schema_1.schema.nodes.highlight_marker, json_schema_1.ObjectTypes.HighlightMarker],
|
|
40
|
+
[schema_1.schema.nodes.inline_equation, json_schema_1.ObjectTypes.InlineMathFragment],
|
|
41
|
+
[schema_1.schema.nodes.keywords_element, json_schema_1.ObjectTypes.KeywordsElement],
|
|
42
|
+
[schema_1.schema.nodes.keywords_section, json_schema_1.ObjectTypes.Section],
|
|
43
|
+
[schema_1.schema.nodes.listing, json_schema_1.ObjectTypes.Listing],
|
|
44
|
+
[schema_1.schema.nodes.listing_element, json_schema_1.ObjectTypes.ListingElement],
|
|
45
|
+
[schema_1.schema.nodes.manuscript, json_schema_1.ObjectTypes.Manuscript],
|
|
46
|
+
[schema_1.schema.nodes.ordered_list, json_schema_1.ObjectTypes.ListElement],
|
|
47
|
+
[schema_1.schema.nodes.paragraph, json_schema_1.ObjectTypes.ParagraphElement],
|
|
48
|
+
[schema_1.schema.nodes.pullquote_element, json_schema_1.ObjectTypes.QuoteElement],
|
|
49
|
+
[schema_1.schema.nodes.section, json_schema_1.ObjectTypes.Section],
|
|
50
|
+
[schema_1.schema.nodes.table, json_schema_1.ObjectTypes.Table],
|
|
51
|
+
[schema_1.schema.nodes.table_element, json_schema_1.ObjectTypes.TableElement],
|
|
52
|
+
[schema_1.schema.nodes.toc_element, json_schema_1.ObjectTypes.TOCElement],
|
|
53
|
+
[schema_1.schema.nodes.toc_section, json_schema_1.ObjectTypes.Section],
|
|
54
|
+
[schema_1.schema.nodes.comment_list, json_schema_1.ObjectTypes.MetaSection],
|
|
54
55
|
]);
|
|
55
56
|
const isExecutableNodeType = (type) => (0, schema_1.hasGroup)(type, schema_1.GROUP_EXECUTABLE);
|
|
56
57
|
exports.isExecutableNodeType = isExecutableNodeType;
|
|
@@ -16,42 +16,42 @@
|
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.isCommentAnnotation = exports.isUserProfile = exports.isTable = exports.isManuscript = exports.isFigure = exports.hasObjectType = exports.isManuscriptModel = exports.manuscriptObjects = exports.elementObjects = exports.ExtraObjectTypes = void 0;
|
|
19
|
-
const
|
|
19
|
+
const json_schema_1 = require("@manuscripts/json-schema");
|
|
20
20
|
var ExtraObjectTypes;
|
|
21
21
|
(function (ExtraObjectTypes) {
|
|
22
22
|
ExtraObjectTypes["PlaceholderElement"] = "MPPlaceholderElement";
|
|
23
23
|
})(ExtraObjectTypes = exports.ExtraObjectTypes || (exports.ExtraObjectTypes = {}));
|
|
24
24
|
exports.elementObjects = [
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
json_schema_1.ObjectTypes.BibliographyElement,
|
|
26
|
+
json_schema_1.ObjectTypes.EquationElement,
|
|
27
|
+
json_schema_1.ObjectTypes.FigureElement,
|
|
28
|
+
json_schema_1.ObjectTypes.FootnotesElement,
|
|
29
|
+
json_schema_1.ObjectTypes.ListElement,
|
|
30
|
+
json_schema_1.ObjectTypes.ListingElement,
|
|
31
|
+
json_schema_1.ObjectTypes.ParagraphElement,
|
|
32
|
+
json_schema_1.ObjectTypes.TableElement,
|
|
33
|
+
json_schema_1.ObjectTypes.TOCElement,
|
|
34
34
|
];
|
|
35
35
|
exports.manuscriptObjects = [
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
36
|
+
json_schema_1.ObjectTypes.Affiliation,
|
|
37
|
+
json_schema_1.ObjectTypes.Citation,
|
|
38
|
+
json_schema_1.ObjectTypes.CommentAnnotation,
|
|
39
|
+
json_schema_1.ObjectTypes.Contributor,
|
|
40
|
+
json_schema_1.ObjectTypes.Footnote,
|
|
41
|
+
json_schema_1.ObjectTypes.InlineMathFragment,
|
|
42
|
+
json_schema_1.ObjectTypes.Section,
|
|
43
43
|
].concat(exports.elementObjects);
|
|
44
44
|
const isManuscriptModel = (model) => {
|
|
45
45
|
if (!model.objectType) {
|
|
46
46
|
throw new Error('Model must have objectType');
|
|
47
47
|
}
|
|
48
|
-
return
|
|
48
|
+
return json_schema_1.manuscriptIDTypes.has(model.objectType);
|
|
49
49
|
};
|
|
50
50
|
exports.isManuscriptModel = isManuscriptModel;
|
|
51
51
|
const hasObjectType = (objectType) => (model) => model.objectType === objectType;
|
|
52
52
|
exports.hasObjectType = hasObjectType;
|
|
53
|
-
exports.isFigure = (0, exports.hasObjectType)(
|
|
54
|
-
exports.isManuscript = (0, exports.hasObjectType)(
|
|
55
|
-
exports.isTable = (0, exports.hasObjectType)(
|
|
56
|
-
exports.isUserProfile = (0, exports.hasObjectType)(
|
|
57
|
-
exports.isCommentAnnotation = (0, exports.hasObjectType)(
|
|
53
|
+
exports.isFigure = (0, exports.hasObjectType)(json_schema_1.ObjectTypes.Figure);
|
|
54
|
+
exports.isManuscript = (0, exports.hasObjectType)(json_schema_1.ObjectTypes.Manuscript);
|
|
55
|
+
exports.isTable = (0, exports.hasObjectType)(json_schema_1.ObjectTypes.Table);
|
|
56
|
+
exports.isUserProfile = (0, exports.hasObjectType)(json_schema_1.ObjectTypes.UserProfile);
|
|
57
|
+
exports.isCommentAnnotation = (0, exports.hasObjectType)(json_schema_1.ObjectTypes.CommentAnnotation);
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.findManuscriptById = exports.findLatestManuscriptSubmission = exports.findManuscriptModelByType = exports.findJournal = exports.findManuscript = exports.parseProjectBundle = void 0;
|
|
19
|
-
const
|
|
19
|
+
const json_schema_1 = require("@manuscripts/json-schema");
|
|
20
20
|
const decode_1 = require("./decode");
|
|
21
21
|
const object_types_1 = require("./object-types");
|
|
22
22
|
const parseProjectBundle = (projectBundle, manuscriptID) => {
|
|
@@ -32,7 +32,7 @@ const parseProjectBundle = (projectBundle, manuscriptID) => {
|
|
|
32
32
|
return { doc, modelMap };
|
|
33
33
|
};
|
|
34
34
|
exports.parseProjectBundle = parseProjectBundle;
|
|
35
|
-
const isManuscript = (0, object_types_1.hasObjectType)(
|
|
35
|
+
const isManuscript = (0, object_types_1.hasObjectType)(json_schema_1.ObjectTypes.Manuscript);
|
|
36
36
|
const findManuscript = (modelMap) => {
|
|
37
37
|
for (const model of modelMap.values()) {
|
|
38
38
|
if (isManuscript(model)) {
|
|
@@ -42,7 +42,7 @@ const findManuscript = (modelMap) => {
|
|
|
42
42
|
throw new Error('No manuscript found');
|
|
43
43
|
};
|
|
44
44
|
exports.findManuscript = findManuscript;
|
|
45
|
-
const isJournal = (0, object_types_1.hasObjectType)(
|
|
45
|
+
const isJournal = (0, object_types_1.hasObjectType)(json_schema_1.ObjectTypes.Journal);
|
|
46
46
|
const findJournal = (modelMap) => {
|
|
47
47
|
for (const model of modelMap.values()) {
|
|
48
48
|
if (isJournal(model)) {
|
|
@@ -63,7 +63,7 @@ const findManuscriptModelByType = (modelMap, manuscript, objectType) => {
|
|
|
63
63
|
}
|
|
64
64
|
};
|
|
65
65
|
exports.findManuscriptModelByType = findManuscriptModelByType;
|
|
66
|
-
const isSubmission = (0, object_types_1.hasObjectType)(
|
|
66
|
+
const isSubmission = (0, object_types_1.hasObjectType)(json_schema_1.ObjectTypes.Submission);
|
|
67
67
|
const newestFirst = (a, b) => b.createdAt - a.createdAt;
|
|
68
68
|
const findLatestManuscriptSubmission = (modelMap, manuscript) => {
|
|
69
69
|
const submissions = [];
|