@manuscripts/transform 1.3.11-LEAN-2715-1 → 1.3.11-LEAN-2147
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-dom-parser.js +4 -3
- package/dist/cjs/jats/importer/jats-body-transformations.js +1 -1
- package/dist/cjs/jats/jats-exporter.js +27 -53
- package/dist/cjs/schema/index.js +0 -3
- package/dist/cjs/schema/nodes/cross_reference.js +6 -1
- package/dist/cjs/schema/nodes/table_element.js +1 -1
- package/dist/cjs/transformer/decode.js +56 -75
- package/dist/cjs/transformer/encode.js +1 -5
- package/dist/cjs/transformer/footnotes-order.js +1 -5
- package/dist/cjs/transformer/html.js +2 -1
- package/dist/cjs/transformer/node-types.js +0 -1
- package/dist/es/jats/importer/jats-body-dom-parser.js +4 -3
- package/dist/es/jats/importer/jats-body-transformations.js +1 -1
- package/dist/es/jats/jats-exporter.js +27 -53
- package/dist/es/schema/index.js +0 -3
- package/dist/es/schema/nodes/cross_reference.js +6 -1
- package/dist/es/schema/nodes/table_element.js +1 -1
- package/dist/es/transformer/decode.js +56 -75
- package/dist/es/transformer/encode.js +1 -5
- package/dist/es/transformer/footnotes-order.js +1 -5
- package/dist/es/transformer/html.js +2 -1
- package/dist/es/transformer/node-types.js +0 -1
- package/dist/types/schema/index.d.ts +0 -1
- package/dist/types/schema/nodes/cross_reference.d.ts +1 -0
- package/dist/types/schema/types.d.ts +1 -1
- package/dist/types/transformer/decode.d.ts +0 -3
- package/package.json +3 -3
- package/dist/cjs/schema/nodes/table_element_footer.js +0 -26
- package/dist/es/schema/nodes/table_element_footer.js +0 -23
- package/dist/types/schema/nodes/table_element_footer.d.ts +0 -25
|
@@ -410,7 +410,7 @@ const nodes = [
|
|
|
410
410
|
{
|
|
411
411
|
tag: 'fn-group',
|
|
412
412
|
node: 'footnotes_element',
|
|
413
|
-
context: 'footnotes_section
|
|
413
|
+
context: 'footnotes_section/',
|
|
414
414
|
getAttrs: (node) => {
|
|
415
415
|
const element = node;
|
|
416
416
|
return {
|
|
@@ -421,18 +421,19 @@ const nodes = [
|
|
|
421
421
|
},
|
|
422
422
|
{
|
|
423
423
|
tag: 'table-wrap-foot',
|
|
424
|
-
node: '
|
|
424
|
+
node: 'footnotes_element',
|
|
425
425
|
getAttrs: (node) => {
|
|
426
426
|
const element = node;
|
|
427
427
|
return {
|
|
428
428
|
id: element.getAttribute('id'),
|
|
429
|
+
kind: 'table_footnote',
|
|
429
430
|
};
|
|
430
431
|
},
|
|
431
432
|
},
|
|
432
433
|
{
|
|
433
434
|
tag: 'fn',
|
|
434
435
|
node: 'footnote',
|
|
435
|
-
context: 'footnotes_element
|
|
436
|
+
context: 'footnotes_element/',
|
|
436
437
|
getAttrs: (node) => {
|
|
437
438
|
const element = node;
|
|
438
439
|
return {
|
|
@@ -240,7 +240,7 @@ exports.jatsBodyTransformations = {
|
|
|
240
240
|
backmatterContainer.append(section);
|
|
241
241
|
}
|
|
242
242
|
}
|
|
243
|
-
const footnotes = [...doc.querySelectorAll('fn
|
|
243
|
+
const footnotes = [...doc.querySelectorAll('fn')];
|
|
244
244
|
const footnotesSection = doc.querySelector('sec[sec-type="endnotes"]');
|
|
245
245
|
const footnotesSectionGroup = footnotesSection === null || footnotesSection === void 0 ? void 0 : footnotesSection.querySelector('fn-group');
|
|
246
246
|
const containingGroup = footnotesSectionGroup || createElement('fn-group');
|
|
@@ -598,7 +598,6 @@ class JATSExporter {
|
|
|
598
598
|
this.createSerializer = () => {
|
|
599
599
|
const getModel = (id) => id ? this.modelMap.get(id) : undefined;
|
|
600
600
|
const nodes = {
|
|
601
|
-
table_element_footer: () => ['table-wrap-foot', 0],
|
|
602
601
|
contributor_list: () => '',
|
|
603
602
|
contributor: () => '',
|
|
604
603
|
affiliation_list: () => '',
|
|
@@ -690,7 +689,7 @@ class JATSExporter {
|
|
|
690
689
|
const rid = getReferencedObjectId(auxiliaryObjectReference.referencedObject);
|
|
691
690
|
xref.setAttribute('rid', rid);
|
|
692
691
|
}
|
|
693
|
-
xref.textContent = node.attrs.label;
|
|
692
|
+
xref.textContent = node.attrs.customLabel || node.attrs.label;
|
|
694
693
|
return xref;
|
|
695
694
|
},
|
|
696
695
|
doc: () => '',
|
|
@@ -871,7 +870,7 @@ class JATSExporter {
|
|
|
871
870
|
section_title_plain: () => ['title', 0],
|
|
872
871
|
table: (node) => ['table', { id: normalizeID(node.attrs.id) }, 0],
|
|
873
872
|
table_element: (node) => {
|
|
874
|
-
const element =
|
|
873
|
+
const element = createFigureElement(node, 'table-wrap', node.type.schema.nodes.table);
|
|
875
874
|
element.setAttribute('position', 'anchor');
|
|
876
875
|
return element;
|
|
877
876
|
},
|
|
@@ -910,27 +909,12 @@ class JATSExporter {
|
|
|
910
909
|
tracked_delete: () => ['del'],
|
|
911
910
|
};
|
|
912
911
|
this.serializer = new prosemirror_model_1.DOMSerializer(nodes, marks);
|
|
913
|
-
const
|
|
914
|
-
node.forEach((childNode) => {
|
|
915
|
-
if (childNode.type === contentNodeType) {
|
|
916
|
-
if (childNode.attrs.id) {
|
|
917
|
-
element.appendChild(this.serializeNode(childNode));
|
|
918
|
-
}
|
|
919
|
-
}
|
|
920
|
-
else if (childNode.type === node.type.schema.nodes.paragraph) {
|
|
921
|
-
element.appendChild(this.serializeNode(childNode));
|
|
922
|
-
}
|
|
923
|
-
else if (childNode.type === node.type.schema.nodes.missing_figure) {
|
|
924
|
-
element.appendChild(this.serializeNode(childNode));
|
|
925
|
-
}
|
|
926
|
-
});
|
|
927
|
-
};
|
|
928
|
-
const createElement = (node, nodeName) => {
|
|
912
|
+
const createFigureElement = (node, nodeName, contentNodeType, figType) => {
|
|
929
913
|
const element = this.document.createElement(nodeName);
|
|
930
914
|
element.setAttribute('id', normalizeID(node.attrs.id));
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
915
|
+
if (figType) {
|
|
916
|
+
element.setAttribute('fig-type', figType);
|
|
917
|
+
}
|
|
934
918
|
if (node.attrs.label) {
|
|
935
919
|
const label = this.document.createElement('label');
|
|
936
920
|
label.textContent = node.attrs.label;
|
|
@@ -944,42 +928,32 @@ class JATSExporter {
|
|
|
944
928
|
element.appendChild(label);
|
|
945
929
|
}
|
|
946
930
|
}
|
|
947
|
-
|
|
948
|
-
|
|
931
|
+
const figcaptionNode = findChildNodeOfType(node, node.type.schema.nodes.figcaption);
|
|
932
|
+
if (figcaptionNode) {
|
|
933
|
+
element.appendChild(this.serializeNode(figcaptionNode));
|
|
934
|
+
}
|
|
935
|
+
const footnotesNode = findChildNodeOfType(node, node.type.schema.nodes.footnotes_element);
|
|
936
|
+
if (footnotesNode) {
|
|
937
|
+
element.appendChild(this.serializeNode(footnotesNode));
|
|
938
|
+
}
|
|
939
|
+
node.forEach((childNode) => {
|
|
940
|
+
if (childNode.type === contentNodeType) {
|
|
941
|
+
if (childNode.attrs.id) {
|
|
942
|
+
element.appendChild(this.serializeNode(childNode));
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
else if (childNode.type === node.type.schema.nodes.paragraph) {
|
|
946
|
+
element.appendChild(this.serializeNode(childNode));
|
|
947
|
+
}
|
|
948
|
+
else if (childNode.type === node.type.schema.nodes.missing_figure) {
|
|
949
|
+
element.appendChild(this.serializeNode(childNode));
|
|
950
|
+
}
|
|
951
|
+
});
|
|
949
952
|
if (node.attrs.attribution) {
|
|
950
953
|
const attribution = this.document.createElement('attrib');
|
|
951
954
|
attribution.textContent = node.attrs.attribution.literal;
|
|
952
955
|
element.appendChild(attribution);
|
|
953
956
|
}
|
|
954
|
-
};
|
|
955
|
-
const appendChildNodeOfType = (element, node, type) => {
|
|
956
|
-
const childNode = findChildNodeOfType(node, type);
|
|
957
|
-
if (childNode) {
|
|
958
|
-
element.appendChild(this.serializeNode(childNode));
|
|
959
|
-
}
|
|
960
|
-
};
|
|
961
|
-
const createFigureElement = (node, nodeName, contentNodeType, figType) => {
|
|
962
|
-
const element = createElement(node, nodeName);
|
|
963
|
-
if (figType) {
|
|
964
|
-
element.setAttribute('fig-type', figType);
|
|
965
|
-
}
|
|
966
|
-
appendLabels(element, node);
|
|
967
|
-
appendChildNodeOfType(element, node, node.type.schema.nodes.figcaption);
|
|
968
|
-
appendChildNodeOfType(element, node, node.type.schema.nodes.footnotes_element);
|
|
969
|
-
processChildNodes(element, node, contentNodeType);
|
|
970
|
-
appendAttributions(element, node);
|
|
971
|
-
if ((0, node_types_1.isExecutableNodeType)(node.type)) {
|
|
972
|
-
processExecutableNode(node, element);
|
|
973
|
-
}
|
|
974
|
-
return element;
|
|
975
|
-
};
|
|
976
|
-
const createTableElement = (node) => {
|
|
977
|
-
const nodeName = 'table-wrap';
|
|
978
|
-
const element = createElement(node, nodeName);
|
|
979
|
-
appendLabels(element, node);
|
|
980
|
-
appendChildNodeOfType(element, node, node.type.schema.nodes.figcaption);
|
|
981
|
-
appendChildNodeOfType(element, node, node.type.schema.nodes.table);
|
|
982
|
-
appendChildNodeOfType(element, node, node.type.schema.nodes.table_element_footer);
|
|
983
957
|
if ((0, node_types_1.isExecutableNodeType)(node.type)) {
|
|
984
958
|
processExecutableNode(node, element);
|
|
985
959
|
}
|
package/dist/cjs/schema/index.js
CHANGED
|
@@ -82,7 +82,6 @@ const section_title_1 = require("./nodes/section_title");
|
|
|
82
82
|
const table_1 = require("./nodes/table");
|
|
83
83
|
const table_col_1 = require("./nodes/table_col");
|
|
84
84
|
const table_element_1 = require("./nodes/table_element");
|
|
85
|
-
const table_element_footer_1 = require("./nodes/table_element_footer");
|
|
86
85
|
const table_row_1 = require("./nodes/table_row");
|
|
87
86
|
const text_1 = require("./nodes/text");
|
|
88
87
|
const toc_element_1 = require("./nodes/toc_element");
|
|
@@ -141,7 +140,6 @@ __exportStar(require("./nodes/affiliation_list"), exports);
|
|
|
141
140
|
__exportStar(require("./nodes/meta_section"), exports);
|
|
142
141
|
__exportStar(require("./nodes/contributor_list"), exports);
|
|
143
142
|
__exportStar(require("./nodes/contributor"), exports);
|
|
144
|
-
__exportStar(require("./nodes/table_element_footer"), exports);
|
|
145
143
|
exports.schema = new prosemirror_model_1.Schema({
|
|
146
144
|
marks: {
|
|
147
145
|
bold: marks_1.bold,
|
|
@@ -217,6 +215,5 @@ exports.schema = new prosemirror_model_1.Schema({
|
|
|
217
215
|
affiliation_list: affiliation_list_1.affiliationList,
|
|
218
216
|
contributor_list: contributor_list_1.contributorList,
|
|
219
217
|
contributor: contributor_1.contributor,
|
|
220
|
-
table_element_footer: table_element_footer_1.tableElementFooter,
|
|
221
218
|
},
|
|
222
219
|
});
|
|
@@ -24,6 +24,7 @@ exports.crossReference = {
|
|
|
24
24
|
attrs: {
|
|
25
25
|
rid: { default: '' },
|
|
26
26
|
label: { default: '' },
|
|
27
|
+
customLabel: { default: '' },
|
|
27
28
|
dataTracked: { default: null },
|
|
28
29
|
},
|
|
29
30
|
parseDOM: [
|
|
@@ -51,7 +52,11 @@ exports.crossReference = {
|
|
|
51
52
|
{
|
|
52
53
|
class: 'kind elementIndex',
|
|
53
54
|
},
|
|
54
|
-
[
|
|
55
|
+
[
|
|
56
|
+
'b',
|
|
57
|
+
crossReferenceNode.attrs.customLabel ||
|
|
58
|
+
crossReferenceNode.attrs.label,
|
|
59
|
+
],
|
|
55
60
|
],
|
|
56
61
|
];
|
|
57
62
|
},
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.tableElement = void 0;
|
|
19
19
|
exports.tableElement = {
|
|
20
|
-
content: '(table | placeholder) figcaption?
|
|
20
|
+
content: '(table | placeholder) figcaption? footnotes_element? (listing | placeholder)',
|
|
21
21
|
attrs: {
|
|
22
22
|
id: { default: '' },
|
|
23
23
|
paragraphStyle: { default: '' },
|
|
@@ -123,7 +123,21 @@ class Decoder {
|
|
|
123
123
|
}
|
|
124
124
|
extractListing(model) {
|
|
125
125
|
if (model.listingID) {
|
|
126
|
-
|
|
126
|
+
const listingModel = this.getModel(model.listingID);
|
|
127
|
+
let listing;
|
|
128
|
+
if (listingModel) {
|
|
129
|
+
listing = this.decode(listingModel);
|
|
130
|
+
}
|
|
131
|
+
else if (this.allowMissingElements) {
|
|
132
|
+
listing = schema_1.schema.nodes.placeholder.create({
|
|
133
|
+
id: model.listingID,
|
|
134
|
+
label: 'A listing',
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
throw new errors_1.MissingElement(model.listingID);
|
|
139
|
+
}
|
|
140
|
+
return listing;
|
|
127
141
|
}
|
|
128
142
|
}
|
|
129
143
|
constructor(modelMap, allowMissingElements = false) {
|
|
@@ -268,13 +282,11 @@ class Decoder {
|
|
|
268
282
|
}, [equation, figcaption]);
|
|
269
283
|
},
|
|
270
284
|
[json_schema_1.ObjectTypes.FootnotesElement]: (data) => {
|
|
271
|
-
const
|
|
272
|
-
const collateByKind =
|
|
285
|
+
const model = data;
|
|
286
|
+
const collateByKind = model.collateByKind || 'footnote';
|
|
273
287
|
const footnotesOfKind = [];
|
|
274
288
|
for (const model of this.modelMap.values()) {
|
|
275
|
-
if (isFootnote(model) &&
|
|
276
|
-
model.kind === collateByKind &&
|
|
277
|
-
model.containingObject === foonotesElementModel._id) {
|
|
289
|
+
if (isFootnote(model) && model.kind === collateByKind) {
|
|
278
290
|
const commentNodes = this.createCommentsNode(model);
|
|
279
291
|
commentNodes.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
280
292
|
const footnote = this.parseContents(model.contents || '<div></div>', undefined, this.getComments(model), {
|
|
@@ -288,21 +300,19 @@ class Decoder {
|
|
|
288
300
|
}
|
|
289
301
|
}
|
|
290
302
|
return schema_1.schema.nodes.footnotes_element.create({
|
|
291
|
-
id:
|
|
292
|
-
kind:
|
|
293
|
-
paragraphStyle:
|
|
303
|
+
id: model._id,
|
|
304
|
+
kind: model.collateByKind,
|
|
305
|
+
paragraphStyle: model.paragraphStyle,
|
|
294
306
|
}, footnotesOfKind);
|
|
295
307
|
},
|
|
296
308
|
[json_schema_1.ObjectTypes.Footnote]: (data) => {
|
|
297
|
-
const
|
|
298
|
-
const commentNodes = this.createCommentsNode(
|
|
309
|
+
const model = data;
|
|
310
|
+
const commentNodes = this.createCommentsNode(model);
|
|
299
311
|
commentNodes.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
300
|
-
return
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
comments: commentNodes.map((c) => c.attrs.id),
|
|
305
|
-
}),
|
|
312
|
+
return schema_1.schema.nodes.footnote.create({
|
|
313
|
+
id: model._id,
|
|
314
|
+
kind: model.kind,
|
|
315
|
+
comments: commentNodes.map((c) => c.attrs.id),
|
|
306
316
|
});
|
|
307
317
|
},
|
|
308
318
|
[json_schema_1.ObjectTypes.KeywordsElement]: (data) => {
|
|
@@ -426,13 +436,6 @@ class Decoder {
|
|
|
426
436
|
throw new Error('Unknown block type');
|
|
427
437
|
}
|
|
428
438
|
},
|
|
429
|
-
[json_schema_1.ObjectTypes.TableElementFooter]: (data) => {
|
|
430
|
-
const model = data;
|
|
431
|
-
const content = model.containedObjectIDs.map((id) => this.decode(this.modelMap.get(id)));
|
|
432
|
-
return schema_1.schema.nodes.table_element_footer.create({
|
|
433
|
-
id: model._id,
|
|
434
|
-
}, content);
|
|
435
|
-
},
|
|
436
439
|
[json_schema_1.ObjectTypes.Section]: (data) => {
|
|
437
440
|
const model = data;
|
|
438
441
|
const isKeywordsSection = model.category === 'MPSectionCategory:keywords';
|
|
@@ -516,16 +519,39 @@ class Decoder {
|
|
|
516
519
|
},
|
|
517
520
|
[json_schema_1.ObjectTypes.TableElement]: (data) => {
|
|
518
521
|
const model = data;
|
|
519
|
-
const
|
|
520
|
-
|
|
522
|
+
const tableModel = this.getModel(model.containedObjectID);
|
|
523
|
+
let table;
|
|
524
|
+
if (tableModel) {
|
|
525
|
+
table = this.decode(tableModel);
|
|
526
|
+
}
|
|
527
|
+
else if (this.allowMissingElements) {
|
|
528
|
+
table = schema_1.schema.nodes.placeholder.create({
|
|
529
|
+
id: model.containedObjectID,
|
|
530
|
+
label: 'A table',
|
|
531
|
+
});
|
|
532
|
+
}
|
|
533
|
+
else {
|
|
534
|
+
throw new errors_1.MissingElement(model.containedObjectID);
|
|
535
|
+
}
|
|
521
536
|
const figcaption = this.getFigcaption(model);
|
|
522
537
|
const commentNodes = this.createCommentsNode(model);
|
|
523
538
|
commentNodes.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
524
|
-
const content =
|
|
525
|
-
? [table, figcaption, tableElementFooter]
|
|
526
|
-
: [table, figcaption];
|
|
539
|
+
const content = [table, figcaption];
|
|
527
540
|
if (model.listingID) {
|
|
528
|
-
const
|
|
541
|
+
const listingModel = this.getModel(model.listingID);
|
|
542
|
+
let listing;
|
|
543
|
+
if (listingModel) {
|
|
544
|
+
listing = this.decode(listingModel);
|
|
545
|
+
}
|
|
546
|
+
else if (this.allowMissingElements) {
|
|
547
|
+
listing = schema_1.schema.nodes.placeholder.create({
|
|
548
|
+
id: model.listingID,
|
|
549
|
+
label: 'A listing',
|
|
550
|
+
});
|
|
551
|
+
}
|
|
552
|
+
else {
|
|
553
|
+
throw new errors_1.MissingElement(model.listingID);
|
|
554
|
+
}
|
|
529
555
|
content.push(listing);
|
|
530
556
|
}
|
|
531
557
|
else {
|
|
@@ -701,51 +727,6 @@ class Decoder {
|
|
|
701
727
|
this.modelMap = modelMap;
|
|
702
728
|
this.allowMissingElements = allowMissingElements;
|
|
703
729
|
}
|
|
704
|
-
createTable(model) {
|
|
705
|
-
const tableId = model.containedObjectID;
|
|
706
|
-
const tableModel = this.getModel(tableId);
|
|
707
|
-
let table;
|
|
708
|
-
if (tableModel) {
|
|
709
|
-
table = this.decode(tableModel);
|
|
710
|
-
}
|
|
711
|
-
else if (this.allowMissingElements) {
|
|
712
|
-
table = schema_1.schema.nodes.placeholder.create({
|
|
713
|
-
id: tableId,
|
|
714
|
-
label: 'A table',
|
|
715
|
-
});
|
|
716
|
-
}
|
|
717
|
-
else {
|
|
718
|
-
throw new errors_1.MissingElement(tableId);
|
|
719
|
-
}
|
|
720
|
-
return table;
|
|
721
|
-
}
|
|
722
|
-
createTableElementFooter(model) {
|
|
723
|
-
const tableElementFooterID = model.tableElementFooterID;
|
|
724
|
-
if (!tableElementFooterID) {
|
|
725
|
-
return undefined;
|
|
726
|
-
}
|
|
727
|
-
const tableElementFooterModel = this.getModel(tableElementFooterID);
|
|
728
|
-
return tableElementFooterModel
|
|
729
|
-
? this.decode(tableElementFooterModel)
|
|
730
|
-
: undefined;
|
|
731
|
-
}
|
|
732
|
-
createListing(model) {
|
|
733
|
-
const listingModel = this.getModel(model.listingID);
|
|
734
|
-
let listing;
|
|
735
|
-
if (listingModel) {
|
|
736
|
-
listing = this.decode(listingModel);
|
|
737
|
-
}
|
|
738
|
-
else if (this.allowMissingElements) {
|
|
739
|
-
listing = schema_1.schema.nodes.placeholder.create({
|
|
740
|
-
id: model.listingID,
|
|
741
|
-
label: 'A listing',
|
|
742
|
-
});
|
|
743
|
-
}
|
|
744
|
-
else {
|
|
745
|
-
throw new errors_1.MissingElement(model.listingID);
|
|
746
|
-
}
|
|
747
|
-
return listing;
|
|
748
|
-
}
|
|
749
730
|
getKeywordGroups() {
|
|
750
731
|
const kwdGroupNodes = [];
|
|
751
732
|
const kwdGroupsModels = [
|
|
@@ -219,7 +219,7 @@ const containedObjectIDs = (node, nodeTypes) => {
|
|
|
219
219
|
const ids = [];
|
|
220
220
|
for (let i = 0; i < node.childCount; i++) {
|
|
221
221
|
const childNode = node.child(i);
|
|
222
|
-
if (
|
|
222
|
+
if (nodeTypes.includes(childNode.type)) {
|
|
223
223
|
ids.push(childNode.attrs.id);
|
|
224
224
|
}
|
|
225
225
|
}
|
|
@@ -385,9 +385,6 @@ const encoders = {
|
|
|
385
385
|
elementType: 'div',
|
|
386
386
|
paragraphStyle: node.attrs.paragraphStyle || undefined,
|
|
387
387
|
}),
|
|
388
|
-
table_element_footer: (node) => ({
|
|
389
|
-
containedObjectIDs: containedObjectIDs(node),
|
|
390
|
-
}),
|
|
391
388
|
footnotes_section: (node, parent, path, priority) => ({
|
|
392
389
|
category: (0, section_category_1.buildSectionCategory)(node),
|
|
393
390
|
priority: priority.value++,
|
|
@@ -475,7 +472,6 @@ const encoders = {
|
|
|
475
472
|
}),
|
|
476
473
|
table_element: (node) => ({
|
|
477
474
|
containedObjectID: attributeOfNodeType(node, 'table', 'id'),
|
|
478
|
-
tableElementFooterID: attributeOfNodeType(node, 'table_element_footer', 'id'),
|
|
479
475
|
caption: inlineContentOfChildNodeType(node, node.type.schema.nodes.figcaption, node.type.schema.nodes.caption),
|
|
480
476
|
title: inlineContentOfChildNodeType(node, node.type.schema.nodes.figcaption, node.type.schema.nodes.caption_title, false),
|
|
481
477
|
elementType: 'table',
|
|
@@ -21,9 +21,6 @@ const createOrderedFootnotesIDs = (doc) => {
|
|
|
21
21
|
const footnotesRefs = [...doc.querySelectorAll('xref[ref-type="fn"][rid]')];
|
|
22
22
|
const footnotes = [...doc.querySelectorAll('fn:not([fn-type])')];
|
|
23
23
|
const authorNotesIDs = [...doc.querySelectorAll('author-notes > fn')].map((an) => an.getAttribute('id'));
|
|
24
|
-
const tableElementFooters = [
|
|
25
|
-
...doc.querySelectorAll('table-wrap-foot > fn'),
|
|
26
|
-
].map((footer) => footer.getAttribute('id'));
|
|
27
24
|
const orderedFootnotesIDs = [];
|
|
28
25
|
footnotesRefs.forEach((ref) => {
|
|
29
26
|
const refID = ref.getAttribute('rid');
|
|
@@ -35,8 +32,7 @@ const createOrderedFootnotesIDs = (doc) => {
|
|
|
35
32
|
const id = footnote.getAttribute('id');
|
|
36
33
|
if (id &&
|
|
37
34
|
!authorNotesIDs.includes(id) &&
|
|
38
|
-
!orderedFootnotesIDs.includes(id)
|
|
39
|
-
!tableElementFooters.includes(id)) {
|
|
35
|
+
!orderedFootnotesIDs.includes(id)) {
|
|
40
36
|
orderedFootnotesIDs.push(id);
|
|
41
37
|
}
|
|
42
38
|
});
|
|
@@ -228,7 +228,8 @@ class HTMLTransformer {
|
|
|
228
228
|
}
|
|
229
229
|
element.setAttribute('data-reference-ids', crossReferenceNode.attrs.rid);
|
|
230
230
|
}
|
|
231
|
-
element.textContent =
|
|
231
|
+
element.textContent =
|
|
232
|
+
crossReferenceNode.attrs.customLabel || crossReferenceNode.attrs.label;
|
|
232
233
|
return element;
|
|
233
234
|
};
|
|
234
235
|
nodes.listing = (node) => {
|
|
@@ -56,7 +56,6 @@ exports.nodeTypesMap = new Map([
|
|
|
56
56
|
[schema_1.schema.nodes.meta_section, json_schema_1.ObjectTypes.MetaSection],
|
|
57
57
|
[schema_1.schema.nodes.affiliation, json_schema_1.ObjectTypes.Affiliation],
|
|
58
58
|
[schema_1.schema.nodes.contributor, json_schema_1.ObjectTypes.Contributor],
|
|
59
|
-
[schema_1.schema.nodes.table_element_footer, json_schema_1.ObjectTypes.TableElementFooter],
|
|
60
59
|
]);
|
|
61
60
|
const isExecutableNodeType = (type) => (0, schema_1.hasGroup)(type, schema_1.GROUP_EXECUTABLE);
|
|
62
61
|
exports.isExecutableNodeType = isExecutableNodeType;
|
|
@@ -404,7 +404,7 @@ const nodes = [
|
|
|
404
404
|
{
|
|
405
405
|
tag: 'fn-group',
|
|
406
406
|
node: 'footnotes_element',
|
|
407
|
-
context: 'footnotes_section
|
|
407
|
+
context: 'footnotes_section/',
|
|
408
408
|
getAttrs: (node) => {
|
|
409
409
|
const element = node;
|
|
410
410
|
return {
|
|
@@ -415,18 +415,19 @@ const nodes = [
|
|
|
415
415
|
},
|
|
416
416
|
{
|
|
417
417
|
tag: 'table-wrap-foot',
|
|
418
|
-
node: '
|
|
418
|
+
node: 'footnotes_element',
|
|
419
419
|
getAttrs: (node) => {
|
|
420
420
|
const element = node;
|
|
421
421
|
return {
|
|
422
422
|
id: element.getAttribute('id'),
|
|
423
|
+
kind: 'table_footnote',
|
|
423
424
|
};
|
|
424
425
|
},
|
|
425
426
|
},
|
|
426
427
|
{
|
|
427
428
|
tag: 'fn',
|
|
428
429
|
node: 'footnote',
|
|
429
|
-
context: 'footnotes_element
|
|
430
|
+
context: 'footnotes_element/',
|
|
430
431
|
getAttrs: (node) => {
|
|
431
432
|
const element = node;
|
|
432
433
|
return {
|
|
@@ -237,7 +237,7 @@ export const jatsBodyTransformations = {
|
|
|
237
237
|
backmatterContainer.append(section);
|
|
238
238
|
}
|
|
239
239
|
}
|
|
240
|
-
const footnotes = [...doc.querySelectorAll('fn
|
|
240
|
+
const footnotes = [...doc.querySelectorAll('fn')];
|
|
241
241
|
const footnotesSection = doc.querySelector('sec[sec-type="endnotes"]');
|
|
242
242
|
const footnotesSectionGroup = footnotesSection === null || footnotesSection === void 0 ? void 0 : footnotesSection.querySelector('fn-group');
|
|
243
243
|
const containingGroup = footnotesSectionGroup || createElement('fn-group');
|
|
@@ -591,7 +591,6 @@ export class JATSExporter {
|
|
|
591
591
|
this.createSerializer = () => {
|
|
592
592
|
const getModel = (id) => id ? this.modelMap.get(id) : undefined;
|
|
593
593
|
const nodes = {
|
|
594
|
-
table_element_footer: () => ['table-wrap-foot', 0],
|
|
595
594
|
contributor_list: () => '',
|
|
596
595
|
contributor: () => '',
|
|
597
596
|
affiliation_list: () => '',
|
|
@@ -683,7 +682,7 @@ export class JATSExporter {
|
|
|
683
682
|
const rid = getReferencedObjectId(auxiliaryObjectReference.referencedObject);
|
|
684
683
|
xref.setAttribute('rid', rid);
|
|
685
684
|
}
|
|
686
|
-
xref.textContent = node.attrs.label;
|
|
685
|
+
xref.textContent = node.attrs.customLabel || node.attrs.label;
|
|
687
686
|
return xref;
|
|
688
687
|
},
|
|
689
688
|
doc: () => '',
|
|
@@ -864,7 +863,7 @@ export class JATSExporter {
|
|
|
864
863
|
section_title_plain: () => ['title', 0],
|
|
865
864
|
table: (node) => ['table', { id: normalizeID(node.attrs.id) }, 0],
|
|
866
865
|
table_element: (node) => {
|
|
867
|
-
const element =
|
|
866
|
+
const element = createFigureElement(node, 'table-wrap', node.type.schema.nodes.table);
|
|
868
867
|
element.setAttribute('position', 'anchor');
|
|
869
868
|
return element;
|
|
870
869
|
},
|
|
@@ -903,27 +902,12 @@ export class JATSExporter {
|
|
|
903
902
|
tracked_delete: () => ['del'],
|
|
904
903
|
};
|
|
905
904
|
this.serializer = new DOMSerializer(nodes, marks);
|
|
906
|
-
const
|
|
907
|
-
node.forEach((childNode) => {
|
|
908
|
-
if (childNode.type === contentNodeType) {
|
|
909
|
-
if (childNode.attrs.id) {
|
|
910
|
-
element.appendChild(this.serializeNode(childNode));
|
|
911
|
-
}
|
|
912
|
-
}
|
|
913
|
-
else if (childNode.type === node.type.schema.nodes.paragraph) {
|
|
914
|
-
element.appendChild(this.serializeNode(childNode));
|
|
915
|
-
}
|
|
916
|
-
else if (childNode.type === node.type.schema.nodes.missing_figure) {
|
|
917
|
-
element.appendChild(this.serializeNode(childNode));
|
|
918
|
-
}
|
|
919
|
-
});
|
|
920
|
-
};
|
|
921
|
-
const createElement = (node, nodeName) => {
|
|
905
|
+
const createFigureElement = (node, nodeName, contentNodeType, figType) => {
|
|
922
906
|
const element = this.document.createElement(nodeName);
|
|
923
907
|
element.setAttribute('id', normalizeID(node.attrs.id));
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
908
|
+
if (figType) {
|
|
909
|
+
element.setAttribute('fig-type', figType);
|
|
910
|
+
}
|
|
927
911
|
if (node.attrs.label) {
|
|
928
912
|
const label = this.document.createElement('label');
|
|
929
913
|
label.textContent = node.attrs.label;
|
|
@@ -937,42 +921,32 @@ export class JATSExporter {
|
|
|
937
921
|
element.appendChild(label);
|
|
938
922
|
}
|
|
939
923
|
}
|
|
940
|
-
|
|
941
|
-
|
|
924
|
+
const figcaptionNode = findChildNodeOfType(node, node.type.schema.nodes.figcaption);
|
|
925
|
+
if (figcaptionNode) {
|
|
926
|
+
element.appendChild(this.serializeNode(figcaptionNode));
|
|
927
|
+
}
|
|
928
|
+
const footnotesNode = findChildNodeOfType(node, node.type.schema.nodes.footnotes_element);
|
|
929
|
+
if (footnotesNode) {
|
|
930
|
+
element.appendChild(this.serializeNode(footnotesNode));
|
|
931
|
+
}
|
|
932
|
+
node.forEach((childNode) => {
|
|
933
|
+
if (childNode.type === contentNodeType) {
|
|
934
|
+
if (childNode.attrs.id) {
|
|
935
|
+
element.appendChild(this.serializeNode(childNode));
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
else if (childNode.type === node.type.schema.nodes.paragraph) {
|
|
939
|
+
element.appendChild(this.serializeNode(childNode));
|
|
940
|
+
}
|
|
941
|
+
else if (childNode.type === node.type.schema.nodes.missing_figure) {
|
|
942
|
+
element.appendChild(this.serializeNode(childNode));
|
|
943
|
+
}
|
|
944
|
+
});
|
|
942
945
|
if (node.attrs.attribution) {
|
|
943
946
|
const attribution = this.document.createElement('attrib');
|
|
944
947
|
attribution.textContent = node.attrs.attribution.literal;
|
|
945
948
|
element.appendChild(attribution);
|
|
946
949
|
}
|
|
947
|
-
};
|
|
948
|
-
const appendChildNodeOfType = (element, node, type) => {
|
|
949
|
-
const childNode = findChildNodeOfType(node, type);
|
|
950
|
-
if (childNode) {
|
|
951
|
-
element.appendChild(this.serializeNode(childNode));
|
|
952
|
-
}
|
|
953
|
-
};
|
|
954
|
-
const createFigureElement = (node, nodeName, contentNodeType, figType) => {
|
|
955
|
-
const element = createElement(node, nodeName);
|
|
956
|
-
if (figType) {
|
|
957
|
-
element.setAttribute('fig-type', figType);
|
|
958
|
-
}
|
|
959
|
-
appendLabels(element, node);
|
|
960
|
-
appendChildNodeOfType(element, node, node.type.schema.nodes.figcaption);
|
|
961
|
-
appendChildNodeOfType(element, node, node.type.schema.nodes.footnotes_element);
|
|
962
|
-
processChildNodes(element, node, contentNodeType);
|
|
963
|
-
appendAttributions(element, node);
|
|
964
|
-
if (isExecutableNodeType(node.type)) {
|
|
965
|
-
processExecutableNode(node, element);
|
|
966
|
-
}
|
|
967
|
-
return element;
|
|
968
|
-
};
|
|
969
|
-
const createTableElement = (node) => {
|
|
970
|
-
const nodeName = 'table-wrap';
|
|
971
|
-
const element = createElement(node, nodeName);
|
|
972
|
-
appendLabels(element, node);
|
|
973
|
-
appendChildNodeOfType(element, node, node.type.schema.nodes.figcaption);
|
|
974
|
-
appendChildNodeOfType(element, node, node.type.schema.nodes.table);
|
|
975
|
-
appendChildNodeOfType(element, node, node.type.schema.nodes.table_element_footer);
|
|
976
950
|
if (isExecutableNodeType(node.type)) {
|
|
977
951
|
processExecutableNode(node, element);
|
|
978
952
|
}
|
package/dist/es/schema/index.js
CHANGED
|
@@ -65,7 +65,6 @@ import { sectionTitle } from './nodes/section_title';
|
|
|
65
65
|
import { table, tableBody } from './nodes/table';
|
|
66
66
|
import { tableCol, tableColGroup } from './nodes/table_col';
|
|
67
67
|
import { tableElement } from './nodes/table_element';
|
|
68
|
-
import { tableElementFooter } from './nodes/table_element_footer';
|
|
69
68
|
import { tableCell, tableRow } from './nodes/table_row';
|
|
70
69
|
import { text } from './nodes/text';
|
|
71
70
|
import { tocElement } from './nodes/toc_element';
|
|
@@ -124,7 +123,6 @@ export * from './nodes/affiliation_list';
|
|
|
124
123
|
export * from './nodes/meta_section';
|
|
125
124
|
export * from './nodes/contributor_list';
|
|
126
125
|
export * from './nodes/contributor';
|
|
127
|
-
export * from './nodes/table_element_footer';
|
|
128
126
|
export const schema = new Schema({
|
|
129
127
|
marks: {
|
|
130
128
|
bold,
|
|
@@ -200,6 +198,5 @@ export const schema = new Schema({
|
|
|
200
198
|
affiliation_list: affiliationList,
|
|
201
199
|
contributor_list: contributorList,
|
|
202
200
|
contributor: contributor,
|
|
203
|
-
table_element_footer: tableElementFooter,
|
|
204
201
|
},
|
|
205
202
|
});
|
|
@@ -21,6 +21,7 @@ export const crossReference = {
|
|
|
21
21
|
attrs: {
|
|
22
22
|
rid: { default: '' },
|
|
23
23
|
label: { default: '' },
|
|
24
|
+
customLabel: { default: '' },
|
|
24
25
|
dataTracked: { default: null },
|
|
25
26
|
},
|
|
26
27
|
parseDOM: [
|
|
@@ -48,7 +49,11 @@ export const crossReference = {
|
|
|
48
49
|
{
|
|
49
50
|
class: 'kind elementIndex',
|
|
50
51
|
},
|
|
51
|
-
[
|
|
52
|
+
[
|
|
53
|
+
'b',
|
|
54
|
+
crossReferenceNode.attrs.customLabel ||
|
|
55
|
+
crossReferenceNode.attrs.label,
|
|
56
|
+
],
|
|
52
57
|
],
|
|
53
58
|
];
|
|
54
59
|
},
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
export const tableElement = {
|
|
17
|
-
content: '(table | placeholder) figcaption?
|
|
17
|
+
content: '(table | placeholder) figcaption? footnotes_element? (listing | placeholder)',
|
|
18
18
|
attrs: {
|
|
19
19
|
id: { default: '' },
|
|
20
20
|
paragraphStyle: { default: '' },
|
|
@@ -113,7 +113,21 @@ export class Decoder {
|
|
|
113
113
|
}
|
|
114
114
|
extractListing(model) {
|
|
115
115
|
if (model.listingID) {
|
|
116
|
-
|
|
116
|
+
const listingModel = this.getModel(model.listingID);
|
|
117
|
+
let listing;
|
|
118
|
+
if (listingModel) {
|
|
119
|
+
listing = this.decode(listingModel);
|
|
120
|
+
}
|
|
121
|
+
else if (this.allowMissingElements) {
|
|
122
|
+
listing = schema.nodes.placeholder.create({
|
|
123
|
+
id: model.listingID,
|
|
124
|
+
label: 'A listing',
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
throw new MissingElement(model.listingID);
|
|
129
|
+
}
|
|
130
|
+
return listing;
|
|
117
131
|
}
|
|
118
132
|
}
|
|
119
133
|
constructor(modelMap, allowMissingElements = false) {
|
|
@@ -258,13 +272,11 @@ export class Decoder {
|
|
|
258
272
|
}, [equation, figcaption]);
|
|
259
273
|
},
|
|
260
274
|
[ObjectTypes.FootnotesElement]: (data) => {
|
|
261
|
-
const
|
|
262
|
-
const collateByKind =
|
|
275
|
+
const model = data;
|
|
276
|
+
const collateByKind = model.collateByKind || 'footnote';
|
|
263
277
|
const footnotesOfKind = [];
|
|
264
278
|
for (const model of this.modelMap.values()) {
|
|
265
|
-
if (isFootnote(model) &&
|
|
266
|
-
model.kind === collateByKind &&
|
|
267
|
-
model.containingObject === foonotesElementModel._id) {
|
|
279
|
+
if (isFootnote(model) && model.kind === collateByKind) {
|
|
268
280
|
const commentNodes = this.createCommentsNode(model);
|
|
269
281
|
commentNodes.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
270
282
|
const footnote = this.parseContents(model.contents || '<div></div>', undefined, this.getComments(model), {
|
|
@@ -278,21 +290,19 @@ export class Decoder {
|
|
|
278
290
|
}
|
|
279
291
|
}
|
|
280
292
|
return schema.nodes.footnotes_element.create({
|
|
281
|
-
id:
|
|
282
|
-
kind:
|
|
283
|
-
paragraphStyle:
|
|
293
|
+
id: model._id,
|
|
294
|
+
kind: model.collateByKind,
|
|
295
|
+
paragraphStyle: model.paragraphStyle,
|
|
284
296
|
}, footnotesOfKind);
|
|
285
297
|
},
|
|
286
298
|
[ObjectTypes.Footnote]: (data) => {
|
|
287
|
-
const
|
|
288
|
-
const commentNodes = this.createCommentsNode(
|
|
299
|
+
const model = data;
|
|
300
|
+
const commentNodes = this.createCommentsNode(model);
|
|
289
301
|
commentNodes.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
290
|
-
return
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
comments: commentNodes.map((c) => c.attrs.id),
|
|
295
|
-
}),
|
|
302
|
+
return schema.nodes.footnote.create({
|
|
303
|
+
id: model._id,
|
|
304
|
+
kind: model.kind,
|
|
305
|
+
comments: commentNodes.map((c) => c.attrs.id),
|
|
296
306
|
});
|
|
297
307
|
},
|
|
298
308
|
[ObjectTypes.KeywordsElement]: (data) => {
|
|
@@ -416,13 +426,6 @@ export class Decoder {
|
|
|
416
426
|
throw new Error('Unknown block type');
|
|
417
427
|
}
|
|
418
428
|
},
|
|
419
|
-
[ObjectTypes.TableElementFooter]: (data) => {
|
|
420
|
-
const model = data;
|
|
421
|
-
const content = model.containedObjectIDs.map((id) => this.decode(this.modelMap.get(id)));
|
|
422
|
-
return schema.nodes.table_element_footer.create({
|
|
423
|
-
id: model._id,
|
|
424
|
-
}, content);
|
|
425
|
-
},
|
|
426
429
|
[ObjectTypes.Section]: (data) => {
|
|
427
430
|
const model = data;
|
|
428
431
|
const isKeywordsSection = model.category === 'MPSectionCategory:keywords';
|
|
@@ -506,16 +509,39 @@ export class Decoder {
|
|
|
506
509
|
},
|
|
507
510
|
[ObjectTypes.TableElement]: (data) => {
|
|
508
511
|
const model = data;
|
|
509
|
-
const
|
|
510
|
-
|
|
512
|
+
const tableModel = this.getModel(model.containedObjectID);
|
|
513
|
+
let table;
|
|
514
|
+
if (tableModel) {
|
|
515
|
+
table = this.decode(tableModel);
|
|
516
|
+
}
|
|
517
|
+
else if (this.allowMissingElements) {
|
|
518
|
+
table = schema.nodes.placeholder.create({
|
|
519
|
+
id: model.containedObjectID,
|
|
520
|
+
label: 'A table',
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
else {
|
|
524
|
+
throw new MissingElement(model.containedObjectID);
|
|
525
|
+
}
|
|
511
526
|
const figcaption = this.getFigcaption(model);
|
|
512
527
|
const commentNodes = this.createCommentsNode(model);
|
|
513
528
|
commentNodes.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
514
|
-
const content =
|
|
515
|
-
? [table, figcaption, tableElementFooter]
|
|
516
|
-
: [table, figcaption];
|
|
529
|
+
const content = [table, figcaption];
|
|
517
530
|
if (model.listingID) {
|
|
518
|
-
const
|
|
531
|
+
const listingModel = this.getModel(model.listingID);
|
|
532
|
+
let listing;
|
|
533
|
+
if (listingModel) {
|
|
534
|
+
listing = this.decode(listingModel);
|
|
535
|
+
}
|
|
536
|
+
else if (this.allowMissingElements) {
|
|
537
|
+
listing = schema.nodes.placeholder.create({
|
|
538
|
+
id: model.listingID,
|
|
539
|
+
label: 'A listing',
|
|
540
|
+
});
|
|
541
|
+
}
|
|
542
|
+
else {
|
|
543
|
+
throw new MissingElement(model.listingID);
|
|
544
|
+
}
|
|
519
545
|
content.push(listing);
|
|
520
546
|
}
|
|
521
547
|
else {
|
|
@@ -691,51 +717,6 @@ export class Decoder {
|
|
|
691
717
|
this.modelMap = modelMap;
|
|
692
718
|
this.allowMissingElements = allowMissingElements;
|
|
693
719
|
}
|
|
694
|
-
createTable(model) {
|
|
695
|
-
const tableId = model.containedObjectID;
|
|
696
|
-
const tableModel = this.getModel(tableId);
|
|
697
|
-
let table;
|
|
698
|
-
if (tableModel) {
|
|
699
|
-
table = this.decode(tableModel);
|
|
700
|
-
}
|
|
701
|
-
else if (this.allowMissingElements) {
|
|
702
|
-
table = schema.nodes.placeholder.create({
|
|
703
|
-
id: tableId,
|
|
704
|
-
label: 'A table',
|
|
705
|
-
});
|
|
706
|
-
}
|
|
707
|
-
else {
|
|
708
|
-
throw new MissingElement(tableId);
|
|
709
|
-
}
|
|
710
|
-
return table;
|
|
711
|
-
}
|
|
712
|
-
createTableElementFooter(model) {
|
|
713
|
-
const tableElementFooterID = model.tableElementFooterID;
|
|
714
|
-
if (!tableElementFooterID) {
|
|
715
|
-
return undefined;
|
|
716
|
-
}
|
|
717
|
-
const tableElementFooterModel = this.getModel(tableElementFooterID);
|
|
718
|
-
return tableElementFooterModel
|
|
719
|
-
? this.decode(tableElementFooterModel)
|
|
720
|
-
: undefined;
|
|
721
|
-
}
|
|
722
|
-
createListing(model) {
|
|
723
|
-
const listingModel = this.getModel(model.listingID);
|
|
724
|
-
let listing;
|
|
725
|
-
if (listingModel) {
|
|
726
|
-
listing = this.decode(listingModel);
|
|
727
|
-
}
|
|
728
|
-
else if (this.allowMissingElements) {
|
|
729
|
-
listing = schema.nodes.placeholder.create({
|
|
730
|
-
id: model.listingID,
|
|
731
|
-
label: 'A listing',
|
|
732
|
-
});
|
|
733
|
-
}
|
|
734
|
-
else {
|
|
735
|
-
throw new MissingElement(model.listingID);
|
|
736
|
-
}
|
|
737
|
-
return listing;
|
|
738
|
-
}
|
|
739
720
|
getKeywordGroups() {
|
|
740
721
|
const kwdGroupNodes = [];
|
|
741
722
|
const kwdGroupsModels = [
|
|
@@ -211,7 +211,7 @@ const containedObjectIDs = (node, nodeTypes) => {
|
|
|
211
211
|
const ids = [];
|
|
212
212
|
for (let i = 0; i < node.childCount; i++) {
|
|
213
213
|
const childNode = node.child(i);
|
|
214
|
-
if (
|
|
214
|
+
if (nodeTypes.includes(childNode.type)) {
|
|
215
215
|
ids.push(childNode.attrs.id);
|
|
216
216
|
}
|
|
217
217
|
}
|
|
@@ -377,9 +377,6 @@ const encoders = {
|
|
|
377
377
|
elementType: 'div',
|
|
378
378
|
paragraphStyle: node.attrs.paragraphStyle || undefined,
|
|
379
379
|
}),
|
|
380
|
-
table_element_footer: (node) => ({
|
|
381
|
-
containedObjectIDs: containedObjectIDs(node),
|
|
382
|
-
}),
|
|
383
380
|
footnotes_section: (node, parent, path, priority) => ({
|
|
384
381
|
category: buildSectionCategory(node),
|
|
385
382
|
priority: priority.value++,
|
|
@@ -467,7 +464,6 @@ const encoders = {
|
|
|
467
464
|
}),
|
|
468
465
|
table_element: (node) => ({
|
|
469
466
|
containedObjectID: attributeOfNodeType(node, 'table', 'id'),
|
|
470
|
-
tableElementFooterID: attributeOfNodeType(node, 'table_element_footer', 'id'),
|
|
471
467
|
caption: inlineContentOfChildNodeType(node, node.type.schema.nodes.figcaption, node.type.schema.nodes.caption),
|
|
472
468
|
title: inlineContentOfChildNodeType(node, node.type.schema.nodes.figcaption, node.type.schema.nodes.caption_title, false),
|
|
473
469
|
elementType: 'table',
|
|
@@ -18,9 +18,6 @@ export const createOrderedFootnotesIDs = (doc) => {
|
|
|
18
18
|
const footnotesRefs = [...doc.querySelectorAll('xref[ref-type="fn"][rid]')];
|
|
19
19
|
const footnotes = [...doc.querySelectorAll('fn:not([fn-type])')];
|
|
20
20
|
const authorNotesIDs = [...doc.querySelectorAll('author-notes > fn')].map((an) => an.getAttribute('id'));
|
|
21
|
-
const tableElementFooters = [
|
|
22
|
-
...doc.querySelectorAll('table-wrap-foot > fn'),
|
|
23
|
-
].map((footer) => footer.getAttribute('id'));
|
|
24
21
|
const orderedFootnotesIDs = [];
|
|
25
22
|
footnotesRefs.forEach((ref) => {
|
|
26
23
|
const refID = ref.getAttribute('rid');
|
|
@@ -32,8 +29,7 @@ export const createOrderedFootnotesIDs = (doc) => {
|
|
|
32
29
|
const id = footnote.getAttribute('id');
|
|
33
30
|
if (id &&
|
|
34
31
|
!authorNotesIDs.includes(id) &&
|
|
35
|
-
!orderedFootnotesIDs.includes(id)
|
|
36
|
-
!tableElementFooters.includes(id)) {
|
|
32
|
+
!orderedFootnotesIDs.includes(id)) {
|
|
37
33
|
orderedFootnotesIDs.push(id);
|
|
38
34
|
}
|
|
39
35
|
});
|
|
@@ -222,7 +222,8 @@ export class HTMLTransformer {
|
|
|
222
222
|
}
|
|
223
223
|
element.setAttribute('data-reference-ids', crossReferenceNode.attrs.rid);
|
|
224
224
|
}
|
|
225
|
-
element.textContent =
|
|
225
|
+
element.textContent =
|
|
226
|
+
crossReferenceNode.attrs.customLabel || crossReferenceNode.attrs.label;
|
|
226
227
|
return element;
|
|
227
228
|
};
|
|
228
229
|
nodes.listing = (node) => {
|
|
@@ -53,7 +53,6 @@ export const nodeTypesMap = new Map([
|
|
|
53
53
|
[schema.nodes.meta_section, ObjectTypes.MetaSection],
|
|
54
54
|
[schema.nodes.affiliation, ObjectTypes.Affiliation],
|
|
55
55
|
[schema.nodes.contributor, ObjectTypes.Contributor],
|
|
56
|
-
[schema.nodes.table_element_footer, ObjectTypes.TableElementFooter],
|
|
57
56
|
]);
|
|
58
57
|
export const isExecutableNodeType = (type) => hasGroup(type, GROUP_EXECUTABLE);
|
|
59
58
|
export const isElementNodeType = (type) => hasGroup(type, GROUP_ELEMENT);
|
|
@@ -69,5 +69,4 @@ export * from './nodes/affiliation_list';
|
|
|
69
69
|
export * from './nodes/meta_section';
|
|
70
70
|
export * from './nodes/contributor_list';
|
|
71
71
|
export * from './nodes/contributor';
|
|
72
|
-
export * from './nodes/table_element_footer';
|
|
73
72
|
export declare const schema: Schema<Nodes, Marks>;
|
|
@@ -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' | 'comment_list' | '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' | 'keywords_group' | 'keywords_section' | 'link' | 'list_item' | 'listing' | 'listing_element' | 'manuscript' | 'missing_figure' | 'ordered_list' | 'paragraph' | 'placeholder' | 'placeholder_element' | 'pullquote_element' | 'section' | 'section_label' | 'section_title' | 'section_title_plain' | 'table' | 'table_body' | 'table_cell' | 'table_element' | 'table_row' | 'table_colgroup' | 'table_col' | 'text' | 'toc_element' | 'toc_section' | 'affiliation' | 'meta_section' | 'affiliation_list' | 'contributor_list' | 'contributor'
|
|
20
|
+
export type Nodes = 'attribution' | 'bibliography_item' | 'bibliography_element' | 'bibliography_section' | 'blockquote_element' | 'bullet_list' | 'caption' | 'caption_title' | 'comment' | 'comment_list' | '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' | 'keywords_group' | 'keywords_section' | 'link' | 'list_item' | 'listing' | 'listing_element' | 'manuscript' | 'missing_figure' | 'ordered_list' | 'paragraph' | 'placeholder' | 'placeholder_element' | 'pullquote_element' | 'section' | 'section_label' | 'section_title' | 'section_title_plain' | 'table' | 'table_body' | 'table_cell' | 'table_element' | 'table_row' | 'table_colgroup' | 'table_col' | 'text' | 'toc_element' | 'toc_section' | 'affiliation' | 'meta_section' | 'affiliation_list' | 'contributor_list' | 'contributor';
|
|
21
21
|
export type ManuscriptSchema = Schema<Nodes, Marks>;
|
|
22
22
|
export type ManuscriptEditorState = EditorState;
|
|
23
23
|
export type ManuscriptEditorView = EditorView;
|
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": "1.3.11-LEAN-
|
|
4
|
+
"version": "1.3.11-LEAN-2147",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-transform",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"version": "yarn build"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@manuscripts/json-schema": "2.1.1
|
|
32
|
+
"@manuscripts/json-schema": "^2.1.1",
|
|
33
33
|
"debug": "^4.3.4",
|
|
34
34
|
"jszip": "^3.10.1",
|
|
35
35
|
"mathjax-full": "^3.2.2",
|
|
@@ -82,4 +82,4 @@
|
|
|
82
82
|
"prosemirror-state": "^1.4.2",
|
|
83
83
|
"prosemirror-view": "^1.29.1"
|
|
84
84
|
}
|
|
85
|
-
}
|
|
85
|
+
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*!
|
|
3
|
-
* © 2019 Atypon Systems LLC
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.tableElementFooter = void 0;
|
|
19
|
-
exports.tableElementFooter = {
|
|
20
|
-
attrs: {
|
|
21
|
-
id: { default: '' },
|
|
22
|
-
},
|
|
23
|
-
content: '(paragraph | footnotes_element)+',
|
|
24
|
-
group: 'block element',
|
|
25
|
-
toDOM: () => ['table-wrap-foot', 0],
|
|
26
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* © 2019 Atypon Systems LLC
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
export const tableElementFooter = {
|
|
17
|
-
attrs: {
|
|
18
|
-
id: { default: '' },
|
|
19
|
-
},
|
|
20
|
-
content: '(paragraph | footnotes_element)+',
|
|
21
|
-
group: 'block element',
|
|
22
|
-
toDOM: () => ['table-wrap-foot', 0],
|
|
23
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* © 2019 Atypon Systems LLC
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import { NodeSpec } from 'prosemirror-model';
|
|
17
|
-
import { ManuscriptNode } from '../types';
|
|
18
|
-
interface Attrs {
|
|
19
|
-
id: string;
|
|
20
|
-
}
|
|
21
|
-
export interface TableElementFooterNode extends ManuscriptNode {
|
|
22
|
-
attrs: Attrs;
|
|
23
|
-
}
|
|
24
|
-
export declare const tableElementFooter: NodeSpec;
|
|
25
|
-
export {};
|