@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
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.chooseSectionCategoryFromTitle = exports.chooseSectionCategory = exports.chooseSectionCategoryByType = exports.chooseSecType = exports.buildSectionCategory = exports.guessSectionCategory = exports.chooseSectionLableName = exports.chooseSectionNodeType = exports.isAnySectionNode = void 0;
|
|
19
|
-
const
|
|
19
|
+
const json_schema_1 = require("@manuscripts/json-schema");
|
|
20
20
|
const schema_1 = require("../schema");
|
|
21
21
|
const sectionNodeTypes = [
|
|
22
22
|
schema_1.schema.nodes.bibliography_section,
|
|
@@ -58,13 +58,13 @@ const guessSectionCategory = (elements) => {
|
|
|
58
58
|
return undefined;
|
|
59
59
|
}
|
|
60
60
|
switch (elements[0].objectType) {
|
|
61
|
-
case
|
|
61
|
+
case json_schema_1.ObjectTypes.BibliographyElement:
|
|
62
62
|
return 'MPSectionCategory:bibliography';
|
|
63
|
-
case
|
|
63
|
+
case json_schema_1.ObjectTypes.FootnotesElement:
|
|
64
64
|
return 'MPSectionCategory:endnotes';
|
|
65
|
-
case
|
|
65
|
+
case json_schema_1.ObjectTypes.KeywordsElement:
|
|
66
66
|
return 'MPSectionCategory:keywords';
|
|
67
|
-
case
|
|
67
|
+
case json_schema_1.ObjectTypes.TOCElement:
|
|
68
68
|
return 'MPSectionCategory:toc';
|
|
69
69
|
default:
|
|
70
70
|
return undefined;
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { ObjectTypes, } from '@manuscripts/
|
|
16
|
+
import { ObjectTypes, } from '@manuscripts/json-schema';
|
|
17
17
|
import { generateID, hasObjectType, nodeTypesMap } from '../../transformer';
|
|
18
18
|
const isAuxiliaryObjectReference = hasObjectType(ObjectTypes.AuxiliaryObjectReference);
|
|
19
19
|
export function flatten(arrays) {
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { ObjectTypes, } from '@manuscripts/
|
|
16
|
+
import { ObjectTypes, } from '@manuscripts/json-schema';
|
|
17
17
|
import debug from 'debug';
|
|
18
18
|
import { DOMParser, DOMSerializer } from 'prosemirror-model';
|
|
19
19
|
import serializeToXML from 'w3c-xmlserializer';
|
|
@@ -616,6 +616,7 @@ export class JATSExporter {
|
|
|
616
616
|
attribution: () => ['attrib', 0],
|
|
617
617
|
bibliography_element: () => '',
|
|
618
618
|
bibliography_item: () => '',
|
|
619
|
+
comment_list: () => '',
|
|
619
620
|
bibliography_section: (node) => [
|
|
620
621
|
'ref-list',
|
|
621
622
|
{ id: normalizeID(node.attrs.id) },
|
package/dist/es/schema/index.js
CHANGED
|
@@ -24,6 +24,7 @@ import { caption } from './nodes/caption';
|
|
|
24
24
|
import { captionTitle } from './nodes/caption_title';
|
|
25
25
|
import { citation } from './nodes/citation';
|
|
26
26
|
import { comment } from './nodes/comment';
|
|
27
|
+
import { commentList } from './nodes/comment_list';
|
|
27
28
|
import { crossReference } from './nodes/cross_reference';
|
|
28
29
|
import { doc } from './nodes/doc';
|
|
29
30
|
import { equation } from './nodes/equation';
|
|
@@ -124,6 +125,7 @@ export const schema = new Schema({
|
|
|
124
125
|
},
|
|
125
126
|
nodes: {
|
|
126
127
|
comment,
|
|
128
|
+
comment_list: commentList,
|
|
127
129
|
attribution,
|
|
128
130
|
bibliography_item: bibliographyItem,
|
|
129
131
|
bibliography_element: bibliographyElement,
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { ObjectTypes } from '@manuscripts/
|
|
16
|
+
import { ObjectTypes } from '@manuscripts/json-schema';
|
|
17
17
|
import { buildElementClass } from '../../lib/attributes';
|
|
18
18
|
export const blockquoteElement = {
|
|
19
19
|
content: 'paragraph+ attribution',
|
|
@@ -0,0 +1,21 @@
|
|
|
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 commentList = {
|
|
17
|
+
content: 'comment*',
|
|
18
|
+
attrs: {
|
|
19
|
+
id: { default: '' },
|
|
20
|
+
},
|
|
21
|
+
};
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { ObjectTypes } from '@manuscripts/
|
|
16
|
+
import { ObjectTypes } from '@manuscripts/json-schema';
|
|
17
17
|
export const equation = {
|
|
18
18
|
attrs: {
|
|
19
19
|
id: { default: '' },
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { ObjectTypes } from '@manuscripts/
|
|
16
|
+
import { ObjectTypes } from '@manuscripts/json-schema';
|
|
17
17
|
export const inlineEquation = {
|
|
18
18
|
attrs: {
|
|
19
19
|
id: { default: '' },
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { ObjectTypes } from '@manuscripts/
|
|
16
|
+
import { ObjectTypes } from '@manuscripts/json-schema';
|
|
17
17
|
import { buildElementClass } from '../../lib/attributes';
|
|
18
18
|
export const bulletList = {
|
|
19
19
|
content: 'list_item+',
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { ObjectTypes } from '@manuscripts/
|
|
16
|
+
import { ObjectTypes } from '@manuscripts/json-schema';
|
|
17
17
|
export const listing = {
|
|
18
18
|
attrs: {
|
|
19
19
|
id: { default: '' },
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { ObjectTypes } from '@manuscripts/
|
|
16
|
+
import { ObjectTypes } from '@manuscripts/json-schema';
|
|
17
17
|
import { buildElementClass } from '../../lib/attributes';
|
|
18
18
|
export const paragraph = {
|
|
19
19
|
content: 'inline*',
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { ObjectTypes } from '@manuscripts/
|
|
16
|
+
import { ObjectTypes } from '@manuscripts/json-schema';
|
|
17
17
|
import { buildElementClass } from '../../lib/attributes';
|
|
18
18
|
export const pullquoteElement = {
|
|
19
19
|
content: 'paragraph+ attribution',
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { ObjectTypes, } from '@manuscripts/
|
|
16
|
+
import { ObjectTypes, } from '@manuscripts/json-schema';
|
|
17
17
|
import serializeToXML from 'w3c-xmlserializer';
|
|
18
18
|
import { schema } from '../schema';
|
|
19
19
|
import { generateID } from './id';
|
|
@@ -24,7 +24,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
24
24
|
}
|
|
25
25
|
return t;
|
|
26
26
|
};
|
|
27
|
-
import { ObjectTypes, } from '@manuscripts/
|
|
27
|
+
import { ObjectTypes, } from '@manuscripts/json-schema';
|
|
28
28
|
import debug from 'debug';
|
|
29
29
|
import { DOMParser } from 'prosemirror-model';
|
|
30
30
|
import { MissingElement } from '../errors';
|
|
@@ -88,6 +88,7 @@ export class Decoder {
|
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
constructor(modelMap, allowMissingElements = false) {
|
|
91
|
+
this.comments = new Map();
|
|
91
92
|
this.creators = {
|
|
92
93
|
[ObjectTypes.BibliographyElement]: (data) => {
|
|
93
94
|
var _a;
|
|
@@ -134,12 +135,14 @@ export class Decoder {
|
|
|
134
135
|
},
|
|
135
136
|
[ObjectTypes.Figure]: (data) => {
|
|
136
137
|
const model = data;
|
|
138
|
+
const commentNodes = this.createCommentsNode(model);
|
|
139
|
+
commentNodes.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
137
140
|
return schema.nodes.figure.create({
|
|
138
141
|
id: model._id,
|
|
139
142
|
contentType: model.contentType,
|
|
140
143
|
src: model.src,
|
|
141
144
|
position: model.position,
|
|
142
|
-
comments:
|
|
145
|
+
comments: commentNodes.map((c) => c.attrs.id),
|
|
143
146
|
});
|
|
144
147
|
},
|
|
145
148
|
[ObjectTypes.FigureElement]: (data) => {
|
|
@@ -168,6 +171,8 @@ export class Decoder {
|
|
|
168
171
|
figures.push(schema.nodes.figure.createAndFill());
|
|
169
172
|
}
|
|
170
173
|
const figcaption = this.getFigcaption(model);
|
|
174
|
+
const commentNodes = this.createCommentsNode(model);
|
|
175
|
+
commentNodes.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
171
176
|
const content = [...paragraphs, ...figures, figcaption];
|
|
172
177
|
const listing = this.extractListing(model);
|
|
173
178
|
if (listing) {
|
|
@@ -188,7 +193,7 @@ export class Decoder {
|
|
|
188
193
|
suppressTitle: Boolean(model.suppressTitle === undefined ? true : model.suppressTitle),
|
|
189
194
|
attribution: model.attribution,
|
|
190
195
|
alternatives: model.alternatives,
|
|
191
|
-
comments:
|
|
196
|
+
comments: commentNodes.map((c) => c.attrs.id),
|
|
192
197
|
}, content);
|
|
193
198
|
},
|
|
194
199
|
[ObjectTypes.Equation]: (data) => {
|
|
@@ -229,11 +234,13 @@ export class Decoder {
|
|
|
229
234
|
const footnotesOfKind = [];
|
|
230
235
|
for (const model of this.modelMap.values()) {
|
|
231
236
|
if (isFootnote(model) && model.kind === collateByKind) {
|
|
237
|
+
const commentNodes = this.createCommentsNode(model);
|
|
238
|
+
commentNodes.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
232
239
|
const footnote = this.parseContents(model.contents || '<div></div>', undefined, this.getComments(model), {
|
|
233
240
|
topNode: schema.nodes.footnote.create({
|
|
234
241
|
id: model._id,
|
|
235
242
|
kind: model.kind,
|
|
236
|
-
comments:
|
|
243
|
+
comments: commentNodes.map((c) => c.attrs.id),
|
|
237
244
|
}),
|
|
238
245
|
});
|
|
239
246
|
footnotesOfKind.push(footnote);
|
|
@@ -247,10 +254,12 @@ export class Decoder {
|
|
|
247
254
|
},
|
|
248
255
|
[ObjectTypes.Footnote]: (data) => {
|
|
249
256
|
const model = data;
|
|
257
|
+
const commentNodes = this.createCommentsNode(model);
|
|
258
|
+
commentNodes.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
250
259
|
return schema.nodes.footnote.create({
|
|
251
260
|
id: model._id,
|
|
252
261
|
kind: model.kind,
|
|
253
|
-
comments:
|
|
262
|
+
comments: commentNodes.map((c) => c.attrs.id),
|
|
254
263
|
});
|
|
255
264
|
},
|
|
256
265
|
[ObjectTypes.KeywordsElement]: (data) => {
|
|
@@ -265,13 +274,15 @@ export class Decoder {
|
|
|
265
274
|
},
|
|
266
275
|
[ObjectTypes.ListElement]: (data) => {
|
|
267
276
|
const model = data;
|
|
277
|
+
const commentNodes = this.createCommentsNode(model);
|
|
278
|
+
commentNodes.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
268
279
|
switch (model.elementType) {
|
|
269
280
|
case 'ol':
|
|
270
281
|
return this.parseContents(model.contents || '<ol></ol>', undefined, this.getComments(model), {
|
|
271
282
|
topNode: schema.nodes.ordered_list.create({
|
|
272
283
|
id: model._id,
|
|
273
284
|
paragraphStyle: model.paragraphStyle,
|
|
274
|
-
comments:
|
|
285
|
+
comments: commentNodes.map((c) => c.attrs.id),
|
|
275
286
|
}),
|
|
276
287
|
});
|
|
277
288
|
case 'ul':
|
|
@@ -287,12 +298,14 @@ export class Decoder {
|
|
|
287
298
|
},
|
|
288
299
|
[ObjectTypes.Listing]: (data) => {
|
|
289
300
|
const model = data;
|
|
301
|
+
const commentNodes = this.createCommentsNode(model);
|
|
302
|
+
commentNodes.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
290
303
|
return schema.nodes.listing.createChecked({
|
|
291
304
|
id: model._id,
|
|
292
305
|
contents: model.contents,
|
|
293
306
|
language: model.language,
|
|
294
307
|
languageKey: model.languageKey,
|
|
295
|
-
comments:
|
|
308
|
+
comments: commentNodes.map((c) => c.attrs.id),
|
|
296
309
|
});
|
|
297
310
|
},
|
|
298
311
|
[ObjectTypes.ListingElement]: (data) => {
|
|
@@ -312,11 +325,13 @@ export class Decoder {
|
|
|
312
325
|
throw new MissingElement(model.containedObjectID);
|
|
313
326
|
}
|
|
314
327
|
const figcaption = this.getFigcaption(model);
|
|
328
|
+
const commentNodes = this.createCommentsNode(model);
|
|
329
|
+
commentNodes.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
315
330
|
return schema.nodes.listing_element.createChecked({
|
|
316
331
|
id: model._id,
|
|
317
332
|
suppressCaption: model.suppressCaption,
|
|
318
333
|
suppressTitle: Boolean(model.suppressTitle === undefined ? true : model.suppressTitle),
|
|
319
|
-
comments:
|
|
334
|
+
comments: commentNodes.map((c) => c.attrs.id),
|
|
320
335
|
}, [listing, figcaption]);
|
|
321
336
|
},
|
|
322
337
|
[ObjectTypes.MissingFigure]: (data) => {
|
|
@@ -328,12 +343,14 @@ export class Decoder {
|
|
|
328
343
|
},
|
|
329
344
|
[ObjectTypes.ParagraphElement]: (data) => {
|
|
330
345
|
const model = data;
|
|
346
|
+
const commentNodes = this.createCommentsNode(model);
|
|
347
|
+
commentNodes.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
331
348
|
return this.parseContents(model.contents || '<p></p>', undefined, this.getComments(model), {
|
|
332
349
|
topNode: schema.nodes.paragraph.create({
|
|
333
350
|
id: model._id,
|
|
334
351
|
paragraphStyle: model.paragraphStyle,
|
|
335
352
|
placeholder: model.placeholderInnerHTML,
|
|
336
|
-
comments:
|
|
353
|
+
comments: commentNodes.map((c) => c.attrs.id),
|
|
337
354
|
}),
|
|
338
355
|
});
|
|
339
356
|
},
|
|
@@ -408,6 +425,8 @@ export class Decoder {
|
|
|
408
425
|
.map(this.creators[ObjectTypes.Section]);
|
|
409
426
|
const sectionCategory = model.category || guessSectionCategory(elements);
|
|
410
427
|
const sectionNodeType = chooseSectionNodeType(sectionCategory);
|
|
428
|
+
const commentNodes = this.createCommentsNode(model);
|
|
429
|
+
commentNodes.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
411
430
|
const content = (sectionLabelNode
|
|
412
431
|
? [sectionLabelNode, sectionTitleNode]
|
|
413
432
|
: [sectionTitleNode])
|
|
@@ -419,7 +438,7 @@ export class Decoder {
|
|
|
419
438
|
titleSuppressed: model.titleSuppressed,
|
|
420
439
|
pageBreakStyle: model.pageBreakStyle,
|
|
421
440
|
generatedLabel: model.generatedLabel,
|
|
422
|
-
comments:
|
|
441
|
+
comments: commentNodes.map((c) => c.attrs.id),
|
|
423
442
|
}, content);
|
|
424
443
|
if (!sectionNode) {
|
|
425
444
|
console.error(model);
|
|
@@ -429,10 +448,12 @@ export class Decoder {
|
|
|
429
448
|
},
|
|
430
449
|
[ObjectTypes.Table]: (data) => {
|
|
431
450
|
const model = data;
|
|
451
|
+
const commentNodes = this.createCommentsNode(model);
|
|
452
|
+
commentNodes.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
432
453
|
return this.parseContents(model.contents, undefined, this.getComments(model), {
|
|
433
454
|
topNode: schema.nodes.table.create({
|
|
434
455
|
id: model._id,
|
|
435
|
-
comments:
|
|
456
|
+
comments: commentNodes.map((c) => c.attrs.id),
|
|
436
457
|
}),
|
|
437
458
|
});
|
|
438
459
|
},
|
|
@@ -453,6 +474,8 @@ export class Decoder {
|
|
|
453
474
|
throw new MissingElement(model.containedObjectID);
|
|
454
475
|
}
|
|
455
476
|
const figcaption = this.getFigcaption(model);
|
|
477
|
+
const commentNodes = this.createCommentsNode(model);
|
|
478
|
+
commentNodes.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
456
479
|
const content = [table, figcaption];
|
|
457
480
|
if (model.listingID) {
|
|
458
481
|
const listingModel = this.getModel(model.listingID);
|
|
@@ -484,7 +507,7 @@ export class Decoder {
|
|
|
484
507
|
suppressHeader: model.suppressHeader,
|
|
485
508
|
tableStyle: model.tableStyle,
|
|
486
509
|
paragraphStyle: model.paragraphStyle,
|
|
487
|
-
comments:
|
|
510
|
+
comments: commentNodes.map((c) => c.attrs.id),
|
|
488
511
|
}, content);
|
|
489
512
|
},
|
|
490
513
|
[ObjectTypes.TOCElement]: (data) => {
|
|
@@ -526,9 +549,16 @@ export class Decoder {
|
|
|
526
549
|
id: generateNodeID(schema.nodes.section),
|
|
527
550
|
}));
|
|
528
551
|
}
|
|
552
|
+
const contents = rootSectionNodes;
|
|
553
|
+
if (this.comments.size) {
|
|
554
|
+
const comments = schema.nodes.comment_list.createAndFill({
|
|
555
|
+
id: generateNodeID(schema.nodes.comment_list),
|
|
556
|
+
}, [...this.comments.values()]);
|
|
557
|
+
contents.push(comments);
|
|
558
|
+
}
|
|
529
559
|
return schema.nodes.manuscript.create({
|
|
530
560
|
id: manuscriptID || this.getManuscriptID(),
|
|
531
|
-
},
|
|
561
|
+
}, contents);
|
|
532
562
|
};
|
|
533
563
|
this.addGeneratedLabels = (sections) => {
|
|
534
564
|
const nextLableCount = { Appendix: 1 };
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { ObjectTypes } from '@manuscripts/
|
|
16
|
+
import { ObjectTypes } from '@manuscripts/json-schema';
|
|
17
17
|
export const documentObjectTypes = [
|
|
18
18
|
ObjectTypes.BibliographyElement,
|
|
19
19
|
ObjectTypes.EquationElement,
|
|
@@ -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 { isHighlightMarkerNode, isSectionNode, schema, } from '../schema';
|
|
20
|
-
import { buildAttribution
|
|
20
|
+
import { buildAttribution } from './builders';
|
|
21
21
|
import { extractHighlightMarkers, isHighlightableModel, } from './highlight-markers';
|
|
22
22
|
import { nodeTypesMap } from './node-types';
|
|
23
23
|
import { buildSectionCategory } from './section-category';
|
|
@@ -493,16 +493,6 @@ export const modelFromNode = (node, parent, path, priority) => {
|
|
|
493
493
|
const model = data;
|
|
494
494
|
if (isHighlightableModel(model)) {
|
|
495
495
|
extractHighlightMarkers(model, commentAnnotationsMap);
|
|
496
|
-
if (node.attrs.comments) {
|
|
497
|
-
const commentNodes = node.attrs.comments;
|
|
498
|
-
commentNodes
|
|
499
|
-
.filter((commentNode) => !commentNode.attrs.selector)
|
|
500
|
-
.forEach((c) => {
|
|
501
|
-
const commentAnnotation = buildComment(model._id, c.attrs.contents, c.attrs.selector);
|
|
502
|
-
commentAnnotation._id = c.attrs.id;
|
|
503
|
-
commentAnnotationsMap.set(commentAnnotation._id, commentAnnotation);
|
|
504
|
-
});
|
|
505
|
-
}
|
|
506
496
|
}
|
|
507
497
|
return { model, commentAnnotationsMap };
|
|
508
498
|
};
|
|
@@ -519,6 +509,9 @@ export const encode = (node) => {
|
|
|
519
509
|
if (isHighlightMarkerNode(child)) {
|
|
520
510
|
return;
|
|
521
511
|
}
|
|
512
|
+
if (child.type === schema.nodes.comment_list) {
|
|
513
|
+
return;
|
|
514
|
+
}
|
|
522
515
|
if (placeholders.includes(child.type.name)) {
|
|
523
516
|
return;
|
|
524
517
|
}
|
|
@@ -530,6 +523,14 @@ export const encode = (node) => {
|
|
|
530
523
|
commentAnnotationsMap.forEach((val, key) => models.set(key, val));
|
|
531
524
|
child.forEach(addModel(path.concat(child.attrs.id), child));
|
|
532
525
|
};
|
|
526
|
+
node.forEach((cNode) => {
|
|
527
|
+
if (cNode.type === schema.nodes.comment_list) {
|
|
528
|
+
cNode.forEach((child) => {
|
|
529
|
+
const { model } = modelFromNode(child, cNode, [], priority);
|
|
530
|
+
models.set(model._id, model);
|
|
531
|
+
});
|
|
532
|
+
}
|
|
533
|
+
});
|
|
533
534
|
node.forEach(addModel([], node));
|
|
534
535
|
return models;
|
|
535
536
|
};
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { ObjectTypes, } from '@manuscripts/
|
|
16
|
+
import { ObjectTypes, } from '@manuscripts/json-schema';
|
|
17
17
|
import { DOMSerializer } from 'prosemirror-model';
|
|
18
18
|
import serializeToXML from 'w3c-xmlserializer';
|
|
19
19
|
import { createCounter } from '../jats/jats-exporter';
|
|
@@ -46,8 +46,7 @@ export const buildTargets = (fragment, manuscript) => {
|
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
48
|
const buildLabel = (type) => {
|
|
49
|
-
const
|
|
50
|
-
const counter = counters[viewLabel.name];
|
|
49
|
+
const counter = counters[type.name];
|
|
51
50
|
counter.index++;
|
|
52
51
|
return `${counter.label} ${counter.index}`;
|
|
53
52
|
};
|
|
@@ -9,7 +9,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import { ObjectTypes, } from '@manuscripts/
|
|
12
|
+
import { ObjectTypes, } from '@manuscripts/json-schema';
|
|
13
13
|
import { generateID } from './id';
|
|
14
14
|
import { hasObjectType } from './object-types';
|
|
15
15
|
import { loadSharedData } from './shared-data';
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { ObjectTypes } from '@manuscripts/
|
|
16
|
+
import { ObjectTypes } from '@manuscripts/json-schema';
|
|
17
17
|
import { GROUP_ELEMENT, GROUP_EXECUTABLE, GROUP_SECTION, hasGroup, schema, } from '../schema';
|
|
18
18
|
export const nodeTypesMap = new Map([
|
|
19
19
|
[schema.nodes.comment, ObjectTypes.CommentAnnotation],
|
|
@@ -48,6 +48,7 @@ export const nodeTypesMap = new Map([
|
|
|
48
48
|
[schema.nodes.table_element, ObjectTypes.TableElement],
|
|
49
49
|
[schema.nodes.toc_element, ObjectTypes.TOCElement],
|
|
50
50
|
[schema.nodes.toc_section, ObjectTypes.Section],
|
|
51
|
+
[schema.nodes.comment_list, ObjectTypes.MetaSection],
|
|
51
52
|
]);
|
|
52
53
|
export const isExecutableNodeType = (type) => hasGroup(type, GROUP_EXECUTABLE);
|
|
53
54
|
export const isElementNodeType = (type) => hasGroup(type, GROUP_ELEMENT);
|
|
@@ -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 { manuscriptIDTypes, ObjectTypes, } from '@manuscripts/
|
|
16
|
+
import { manuscriptIDTypes, ObjectTypes, } from '@manuscripts/json-schema';
|
|
17
17
|
export var ExtraObjectTypes;
|
|
18
18
|
(function (ExtraObjectTypes) {
|
|
19
19
|
ExtraObjectTypes["PlaceholderElement"] = "MPPlaceholderElement";
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { ObjectTypes, } from '@manuscripts/
|
|
16
|
+
import { ObjectTypes, } from '@manuscripts/json-schema';
|
|
17
17
|
import { Decoder } from './decode';
|
|
18
18
|
import { hasObjectType } from './object-types';
|
|
19
19
|
export const parseProjectBundle = (projectBundle, manuscriptID) => {
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { ObjectTypes } from '@manuscripts/
|
|
16
|
+
import { ObjectTypes } from '@manuscripts/json-schema';
|
|
17
17
|
import { schema } from '../schema';
|
|
18
18
|
const sectionNodeTypes = [
|
|
19
19
|
schema.nodes.bibliography_section,
|
|
@@ -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 { BibliographyItem } from '@manuscripts/
|
|
16
|
+
import { BibliographyItem } from '@manuscripts/json-schema';
|
|
17
17
|
export declare const jatsBodyTransformations: {
|
|
18
18
|
ensureSection(body: Element, createElement: (tagName: string) => HTMLElement): void;
|
|
19
19
|
createAbstract(abstractNode: Element, createElement: (tagName: string) => HTMLElement): HTMLElement;
|
|
@@ -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 { BibliographyItem, CommentAnnotation, Model } from '@manuscripts/
|
|
16
|
+
import { BibliographyItem, CommentAnnotation, Model } from '@manuscripts/json-schema';
|
|
17
17
|
import { Build } from '../../transformer';
|
|
18
18
|
type ProcessingInstruction = {
|
|
19
19
|
id: string;
|
|
@@ -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 { Bundle, Journal, Keyword, KeywordGroup } from '@manuscripts/
|
|
16
|
+
import { Bundle, Journal, Keyword, KeywordGroup } from '@manuscripts/json-schema';
|
|
17
17
|
import { Build } from '../../transformer/builders';
|
|
18
18
|
import { ISSN } from './jats-journal-meta-parser';
|
|
19
19
|
export declare const jatsFrontParser: {
|
|
@@ -45,18 +45,18 @@ export declare const jatsFrontParser: {
|
|
|
45
45
|
revisionReceiveDate?: number | undefined;
|
|
46
46
|
receiveDate?: number | undefined;
|
|
47
47
|
} | undefined;
|
|
48
|
-
parseSupplements(supplementNodes: Element[] | null): Build<import("@manuscripts/
|
|
48
|
+
parseSupplements(supplementNodes: Element[] | null): Build<import("@manuscripts/json-schema").Supplement>[];
|
|
49
49
|
parseAffiliationNodes(affiliationNodes: Element[]): {
|
|
50
|
-
affiliations: Build<import("@manuscripts/
|
|
50
|
+
affiliations: Build<import("@manuscripts/json-schema").Affiliation>[];
|
|
51
51
|
affiliationIDs: Map<string, string>;
|
|
52
52
|
};
|
|
53
53
|
parseFootnoteNodes(footnoteNodes: Element[]): {
|
|
54
|
-
footnotes: Build<import("@manuscripts/
|
|
54
|
+
footnotes: Build<import("@manuscripts/json-schema").Footnote>[];
|
|
55
55
|
footnoteIDs: Map<string, string>;
|
|
56
56
|
};
|
|
57
57
|
parseCorrespNodes(correspNodes: Element[]): {
|
|
58
|
-
correspondingList: Build<import("@manuscripts/
|
|
58
|
+
correspondingList: Build<import("@manuscripts/json-schema").Corresponding>[];
|
|
59
59
|
correspondingIDs: Map<string, string>;
|
|
60
60
|
};
|
|
61
|
-
parseAuthorNodes(authorNodes: Element[], affiliationIDs: Map<string, string>, footnoteIDs: Map<string, string>, correspondingIDs: Map<string, string>): Build<import("@manuscripts/
|
|
61
|
+
parseAuthorNodes(authorNodes: Element[], affiliationIDs: Map<string, string>, footnoteIDs: Map<string, string>, correspondingIDs: Map<string, string>): Build<import("@manuscripts/json-schema").Contributor>[];
|
|
62
62
|
};
|
|
@@ -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 { Model } from '@manuscripts/
|
|
16
|
+
import { Model } from '@manuscripts/json-schema';
|
|
17
17
|
import { ManuscriptNode } from '../../schema';
|
|
18
18
|
export declare function flatten<T>(arrays: T[][]): T[];
|
|
19
19
|
export declare const fixBodyPMNode: (output: ManuscriptNode, models: Model[], referenceIdsMap?: Map<string, string>) => {
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
*/
|
|
16
16
|
export declare const jatsReferenceParser: {
|
|
17
17
|
parseReferences(referenceNodes: Element[], createElement: (tagName: string) => HTMLElement): {
|
|
18
|
-
references: import("../../transformer/builders").Build<import("@manuscripts/
|
|
18
|
+
references: import("../../transformer/builders").Build<import("@manuscripts/json-schema").BibliographyItem>[];
|
|
19
19
|
referenceIDs: Map<string, string>;
|
|
20
20
|
referenceQueries: Map<string, string[]>;
|
|
21
21
|
};
|
|
22
|
-
parseCrossReferences(crossReferenceNodes: Element[], referenceIDs: Map<string, string>): (import("../../transformer/builders").Build<import("@manuscripts/
|
|
22
|
+
parseCrossReferences(crossReferenceNodes: Element[], referenceIDs: Map<string, string>): (import("../../transformer/builders").Build<import("@manuscripts/json-schema").AuxiliaryObjectReference> | import("../../transformer/builders").Build<import("@manuscripts/json-schema").Citation>)[];
|
|
23
23
|
};
|
|
@@ -13,11 +13,11 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { BibliographyItem, ElementsOrder, FootnotesOrder, Model } from '@manuscripts/
|
|
16
|
+
import { BibliographyItem, ElementsOrder, FootnotesOrder, Model } from '@manuscripts/json-schema';
|
|
17
17
|
import { ManuscriptNode } from '../../schema';
|
|
18
18
|
export declare const parseJATSFront: (front: Element) => Promise<{
|
|
19
19
|
models: Model[];
|
|
20
|
-
bundles: import("@manuscripts/
|
|
20
|
+
bundles: import("@manuscripts/json-schema").Bundle[];
|
|
21
21
|
}>;
|
|
22
22
|
export declare const parseJATSReferences: (back: Element | null, body: Element | null, createElement: (tagName: string) => HTMLElement) => {
|
|
23
23
|
references: Model[];
|