@manuscripts/transform 2.1.1-LEAN-3336-24 → 2.1.1-LEAN-3376-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/jats/importer/jats-body-dom-parser.js +16 -2
- package/dist/cjs/jats/importer/jats-body-transformations.js +19 -8
- package/dist/cjs/jats/importer/jats-front-parser.js +7 -0
- package/dist/cjs/jats/importer/parse-jats-article.js +6 -0
- package/dist/cjs/jats/jats-exporter.js +42 -68
- package/dist/cjs/schema/index.js +7 -3
- package/dist/cjs/schema/nodes/author_notes.js +27 -0
- package/dist/cjs/schema/nodes/contributors.js +1 -1
- package/dist/cjs/schema/nodes/table.js +30 -52
- package/dist/cjs/schema/nodes/table_element.js +1 -1
- package/dist/cjs/schema/nodes/table_row.js +123 -0
- package/dist/cjs/transformer/builders.js +7 -1
- package/dist/cjs/transformer/decode.js +30 -27
- package/dist/cjs/transformer/encode.js +4 -2
- package/dist/cjs/transformer/node-types.js +2 -0
- package/dist/es/jats/importer/jats-body-dom-parser.js +16 -2
- package/dist/es/jats/importer/jats-body-transformations.js +19 -8
- package/dist/es/jats/importer/jats-front-parser.js +8 -1
- package/dist/es/jats/importer/parse-jats-article.js +7 -1
- package/dist/es/jats/jats-exporter.js +42 -68
- package/dist/es/schema/index.js +6 -2
- package/dist/es/schema/nodes/author_notes.js +24 -0
- package/dist/es/schema/nodes/contributors.js +1 -1
- package/dist/es/schema/nodes/table.js +29 -51
- package/dist/es/schema/nodes/table_element.js +1 -1
- package/dist/es/schema/nodes/table_row.js +120 -0
- package/dist/es/transformer/builders.js +5 -0
- package/dist/es/transformer/decode.js +30 -27
- package/dist/es/transformer/encode.js +4 -2
- package/dist/es/transformer/node-types.js +2 -0
- package/dist/types/jats/importer/jats-front-parser.d.ts +9 -6
- package/dist/types/jats/jats-exporter.d.ts +3 -0
- package/dist/types/schema/index.d.ts +1 -0
- package/dist/types/schema/nodes/author_notes.d.ts +25 -0
- package/dist/types/schema/nodes/table.d.ts +12 -5
- package/dist/types/schema/nodes/table_row.d.ts +41 -0
- package/dist/types/schema/types.d.ts +1 -1
- package/dist/types/transformer/builders.d.ts +2 -1
- package/dist/types/transformer/decode.d.ts +0 -1
- package/package.json +4 -5
|
@@ -525,9 +525,23 @@ const nodes = [
|
|
|
525
525
|
const element = node;
|
|
526
526
|
return {
|
|
527
527
|
id: element.getAttribute('id'),
|
|
528
|
+
suppressFooter: !element.querySelector('table > tfoot > tr'),
|
|
529
|
+
suppressHeader: !element.querySelector('table > thead > tr'),
|
|
528
530
|
};
|
|
529
531
|
},
|
|
530
532
|
},
|
|
533
|
+
{
|
|
534
|
+
tag: 'tbody',
|
|
535
|
+
skip: true,
|
|
536
|
+
},
|
|
537
|
+
{
|
|
538
|
+
tag: 'tfoot',
|
|
539
|
+
skip: true,
|
|
540
|
+
},
|
|
541
|
+
{
|
|
542
|
+
tag: 'thead',
|
|
543
|
+
skip: true,
|
|
544
|
+
},
|
|
531
545
|
{
|
|
532
546
|
tag: 'title',
|
|
533
547
|
node: 'section_title',
|
|
@@ -554,12 +568,12 @@ const nodes = [
|
|
|
554
568
|
},
|
|
555
569
|
{
|
|
556
570
|
tag: 'th',
|
|
557
|
-
node: '
|
|
571
|
+
node: 'table_cell',
|
|
558
572
|
getAttrs: (node) => {
|
|
559
573
|
const element = node;
|
|
560
574
|
const colspan = element.getAttribute('colspan');
|
|
561
575
|
const rowspan = element.getAttribute('rowspan');
|
|
562
|
-
return Object.assign(Object.assign(Object.assign({}, (colspan && { colspan })), (rowspan && { rowspan })), { valign: element.getAttribute('valign'), align: element.getAttribute('align'), scope: element.getAttribute('scope'), style: element.getAttribute('style') });
|
|
576
|
+
return Object.assign(Object.assign(Object.assign({ celltype: 'th' }, (colspan && { colspan })), (rowspan && { rowspan })), { valign: element.getAttribute('valign'), align: element.getAttribute('align'), scope: element.getAttribute('scope'), style: element.getAttribute('style') });
|
|
563
577
|
},
|
|
564
578
|
},
|
|
565
579
|
{
|
|
@@ -202,7 +202,9 @@ exports.jatsBodyTransformations = {
|
|
|
202
202
|
}
|
|
203
203
|
},
|
|
204
204
|
moveFootnotes(doc, group, createElement) {
|
|
205
|
-
const footnotes = [
|
|
205
|
+
const footnotes = [
|
|
206
|
+
...doc.querySelectorAll('fn:not(table-wrap-foot fn):not(author-notes fn)'),
|
|
207
|
+
];
|
|
206
208
|
const footnotesSection = doc.querySelector('sec[sec-type="endnotes"]');
|
|
207
209
|
const footnotesSectionGroup = footnotesSection === null || footnotesSection === void 0 ? void 0 : footnotesSection.querySelector('fn-group');
|
|
208
210
|
const containingGroup = footnotesSectionGroup || createElement('fn-group');
|
|
@@ -239,12 +241,8 @@ exports.jatsBodyTransformations = {
|
|
|
239
241
|
}
|
|
240
242
|
},
|
|
241
243
|
fixTables(body, createElement) {
|
|
242
|
-
const
|
|
243
|
-
|
|
244
|
-
const table = tableWrap.querySelector('table');
|
|
245
|
-
if (!table) {
|
|
246
|
-
return;
|
|
247
|
-
}
|
|
244
|
+
const tables = body.querySelectorAll('table-wrap > table');
|
|
245
|
+
tables.forEach((table) => {
|
|
248
246
|
const colgroup = table.querySelector('colgroup');
|
|
249
247
|
const cols = table.querySelectorAll('col');
|
|
250
248
|
if (!colgroup && table.firstChild && cols.length > 0) {
|
|
@@ -252,7 +250,20 @@ exports.jatsBodyTransformations = {
|
|
|
252
250
|
for (const col of cols) {
|
|
253
251
|
colgroup.appendChild(col);
|
|
254
252
|
}
|
|
255
|
-
|
|
253
|
+
table.insertBefore(colgroup, table.firstChild);
|
|
254
|
+
}
|
|
255
|
+
const tbody = table.querySelector('tbody');
|
|
256
|
+
if (tbody) {
|
|
257
|
+
const headerRow = table.querySelector('thead > tr');
|
|
258
|
+
if (!headerRow) {
|
|
259
|
+
const tr = createElement('tr');
|
|
260
|
+
tbody.insertBefore(tr, tbody.firstElementChild);
|
|
261
|
+
}
|
|
262
|
+
const footerRow = table.querySelector('tfoot > tr');
|
|
263
|
+
if (!footerRow) {
|
|
264
|
+
const tr = createElement('tr');
|
|
265
|
+
tbody.appendChild(tr);
|
|
266
|
+
}
|
|
256
267
|
}
|
|
257
268
|
});
|
|
258
269
|
},
|
|
@@ -189,6 +189,13 @@ exports.jatsFrontParser = {
|
|
|
189
189
|
footnoteIDs,
|
|
190
190
|
};
|
|
191
191
|
},
|
|
192
|
+
parseAuthorNotesParagraphs(elements) {
|
|
193
|
+
const paragraphs = [];
|
|
194
|
+
elements.forEach((p) => {
|
|
195
|
+
paragraphs.push((0, transformer_1.buildParagraph)(p.innerHTML));
|
|
196
|
+
});
|
|
197
|
+
return paragraphs;
|
|
198
|
+
},
|
|
192
199
|
parseCorresp(elements) {
|
|
193
200
|
const correspondingIDs = new Map();
|
|
194
201
|
const correspondingList = elements.map((element) => {
|
|
@@ -40,6 +40,10 @@ const parseJATSFront = (doc, front) => {
|
|
|
40
40
|
const { correspondingList, correspondingIDs } = jats_front_parser_1.jatsFrontParser.parseCorresp([
|
|
41
41
|
...front.querySelectorAll('article-meta > author-notes > corresp'),
|
|
42
42
|
]);
|
|
43
|
+
const authorNotesParagraphs = jats_front_parser_1.jatsFrontParser.parseAuthorNotesParagraphs([
|
|
44
|
+
...front.querySelectorAll('article-meta > author-notes > p'),
|
|
45
|
+
]);
|
|
46
|
+
const authorNotes = (0, transformer_1.buildAuthorNotes)(Array.from(footnoteIDs.values()).concat(authorNotesParagraphs.map((p) => p._id)));
|
|
43
47
|
const authors = jats_front_parser_1.jatsFrontParser.parseContributors([
|
|
44
48
|
...front.querySelectorAll('article-meta > contrib-group > contrib[contrib-type="author"]'),
|
|
45
49
|
], affiliationIDs, footnoteIDs, correspondingIDs);
|
|
@@ -50,6 +54,8 @@ const parseJATSFront = (doc, front) => {
|
|
|
50
54
|
manuscript,
|
|
51
55
|
titles,
|
|
52
56
|
journal,
|
|
57
|
+
...authorNotesParagraphs,
|
|
58
|
+
authorNotes,
|
|
53
59
|
...footnotes,
|
|
54
60
|
...authors,
|
|
55
61
|
...affiliations,
|
|
@@ -614,6 +614,7 @@ class JATSExporter {
|
|
|
614
614
|
this.createSerializer = () => {
|
|
615
615
|
const getModel = (id) => id ? this.modelMap.get(id) : undefined;
|
|
616
616
|
const nodes = {
|
|
617
|
+
author_notes: () => ['author-notes', 0],
|
|
617
618
|
title: () => '',
|
|
618
619
|
affiliations: () => '',
|
|
619
620
|
contributors: () => '',
|
|
@@ -873,13 +874,9 @@ class JATSExporter {
|
|
|
873
874
|
element.setAttribute('position', 'anchor');
|
|
874
875
|
return element;
|
|
875
876
|
},
|
|
877
|
+
table_body: () => ['tbody', 0],
|
|
876
878
|
table_cell: (node) => [
|
|
877
|
-
|
|
878
|
-
Object.assign(Object.assign({ valign: node.attrs.valign, align: node.attrs.align, scope: node.attrs.scope, style: node.attrs.style }, (node.attrs.rowspan > 1 && { rowspan: node.attrs.rowspan })), (node.attrs.colspan > 1 && { colspan: node.attrs.colspan })),
|
|
879
|
-
0,
|
|
880
|
-
],
|
|
881
|
-
table_header: (node) => [
|
|
882
|
-
'th',
|
|
879
|
+
node.attrs.celltype,
|
|
883
880
|
Object.assign(Object.assign({ valign: node.attrs.valign, align: node.attrs.align, scope: node.attrs.scope, style: node.attrs.style }, (node.attrs.rowspan > 1 && { rowspan: node.attrs.rowspan })), (node.attrs.colspan > 1 && { colspan: node.attrs.colspan })),
|
|
884
881
|
0,
|
|
885
882
|
],
|
|
@@ -960,26 +957,6 @@ class JATSExporter {
|
|
|
960
957
|
element.appendChild(this.serializeNode(childNode));
|
|
961
958
|
}
|
|
962
959
|
};
|
|
963
|
-
const appendTable = (element, node) => {
|
|
964
|
-
const tableNode = findChildNodeOfType(node, node.type.schema.nodes.table);
|
|
965
|
-
const colGroupNode = findChildNodeOfType(node, node.type.schema.nodes.table_colgroup);
|
|
966
|
-
if (!tableNode) {
|
|
967
|
-
return;
|
|
968
|
-
}
|
|
969
|
-
const table = this.serializeNode(tableNode);
|
|
970
|
-
const tbodyElement = this.document.createElement('tbody');
|
|
971
|
-
while (table.firstChild) {
|
|
972
|
-
const child = table.firstChild;
|
|
973
|
-
table.removeChild(child);
|
|
974
|
-
tbodyElement.appendChild(child);
|
|
975
|
-
}
|
|
976
|
-
table.appendChild(tbodyElement);
|
|
977
|
-
if (colGroupNode) {
|
|
978
|
-
const colGroup = this.serializeNode(colGroupNode);
|
|
979
|
-
table.insertBefore(colGroup, table.firstChild);
|
|
980
|
-
}
|
|
981
|
-
element.appendChild(table);
|
|
982
|
-
};
|
|
983
960
|
const createFigureElement = (node, nodeName, contentNodeType, figType) => {
|
|
984
961
|
const element = createElement(node, nodeName);
|
|
985
962
|
if (figType) {
|
|
@@ -1000,7 +977,7 @@ class JATSExporter {
|
|
|
1000
977
|
const element = createElement(node, nodeName);
|
|
1001
978
|
appendLabels(element, node);
|
|
1002
979
|
appendChildNodeOfType(element, node, node.type.schema.nodes.figcaption);
|
|
1003
|
-
|
|
980
|
+
appendChildNodeOfType(element, node, node.type.schema.nodes.table);
|
|
1004
981
|
appendChildNodeOfType(element, node, node.type.schema.nodes.table_element_footer);
|
|
1005
982
|
if ((0, node_types_1.isExecutableNodeType)(node.type)) {
|
|
1006
983
|
processExecutableNode(node, element);
|
|
@@ -1276,49 +1253,23 @@ class JATSExporter {
|
|
|
1276
1253
|
}
|
|
1277
1254
|
});
|
|
1278
1255
|
}
|
|
1279
|
-
const
|
|
1280
|
-
|
|
1281
|
-
if (contributor.footnote) {
|
|
1282
|
-
const ids = contributor.footnote.map((note) => {
|
|
1283
|
-
return note.noteID;
|
|
1284
|
-
});
|
|
1285
|
-
noteIDs.push(...ids);
|
|
1286
|
-
}
|
|
1287
|
-
if (contributor.corresp) {
|
|
1288
|
-
const ids = contributor.corresp.map((corresp) => {
|
|
1289
|
-
return corresp.correspID;
|
|
1290
|
-
});
|
|
1291
|
-
noteIDs.push(...ids);
|
|
1292
|
-
}
|
|
1293
|
-
}
|
|
1294
|
-
const footnotes = [];
|
|
1295
|
-
footnotes.push(...this.models.filter((0, object_types_1.hasObjectType)(json_schema_1.ObjectTypes.Footnote)));
|
|
1296
|
-
const correspodings = [];
|
|
1297
|
-
correspodings.push(...this.models.filter((0, object_types_1.hasObjectType)(json_schema_1.ObjectTypes.Corresponding)));
|
|
1298
|
-
if (footnotes || correspodings) {
|
|
1256
|
+
const authorNotes = this.models.find((0, object_types_1.hasObjectType)(json_schema_1.ObjectTypes.AuthorNotes));
|
|
1257
|
+
if (authorNotes) {
|
|
1299
1258
|
const authorNotesEl = this.document.createElement('author-notes');
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
const correspondingEl = this.document.createElement('corresp');
|
|
1314
|
-
correspondingEl.setAttribute('id', normalizeID(corresponding._id));
|
|
1315
|
-
if (corresponding.label) {
|
|
1316
|
-
const labelEl = this.document.createElement('label');
|
|
1317
|
-
labelEl.textContent = corresponding.label;
|
|
1318
|
-
correspondingEl.appendChild(labelEl);
|
|
1259
|
+
authorNotes.containedObjectIDs.forEach((id) => {
|
|
1260
|
+
const model = this.modelMap.get(id);
|
|
1261
|
+
if (!model) {
|
|
1262
|
+
return;
|
|
1263
|
+
}
|
|
1264
|
+
if (id.startsWith('MPParagraphElement')) {
|
|
1265
|
+
this.appendParagraphToElement(model, authorNotesEl);
|
|
1266
|
+
}
|
|
1267
|
+
else if (id.startsWith('MPCorresponding')) {
|
|
1268
|
+
this.appendCorrespondingToElement(model, authorNotesEl);
|
|
1269
|
+
}
|
|
1270
|
+
else if (id.startsWith('MPFootnote')) {
|
|
1271
|
+
this.appendFootnoteToElement(model, authorNotesEl);
|
|
1319
1272
|
}
|
|
1320
|
-
correspondingEl.append(corresponding.contents);
|
|
1321
|
-
authorNotesEl.appendChild(correspondingEl);
|
|
1322
1273
|
});
|
|
1323
1274
|
if (authorNotesEl.childNodes.length > 0) {
|
|
1324
1275
|
articleMeta.insertBefore(authorNotesEl, contribGroup.nextSibling);
|
|
@@ -1326,6 +1277,29 @@ class JATSExporter {
|
|
|
1326
1277
|
}
|
|
1327
1278
|
}
|
|
1328
1279
|
};
|
|
1280
|
+
this.appendParagraphToElement = (paragraph, element) => {
|
|
1281
|
+
const paragraphEl = this.document.createElement('p');
|
|
1282
|
+
paragraphEl.setAttribute('id', normalizeID(paragraph._id));
|
|
1283
|
+
paragraphEl.innerHTML = paragraph.contents;
|
|
1284
|
+
element.appendChild(paragraphEl);
|
|
1285
|
+
};
|
|
1286
|
+
this.appendCorrespondingToElement = (corresponding, element) => {
|
|
1287
|
+
const correspondingEl = this.document.createElement('corresp');
|
|
1288
|
+
correspondingEl.setAttribute('id', normalizeID(corresponding._id));
|
|
1289
|
+
if (corresponding.label) {
|
|
1290
|
+
const labelEl = this.document.createElement('label');
|
|
1291
|
+
labelEl.textContent = corresponding.label;
|
|
1292
|
+
correspondingEl.appendChild(labelEl);
|
|
1293
|
+
}
|
|
1294
|
+
correspondingEl.append(corresponding.contents);
|
|
1295
|
+
element.appendChild(correspondingEl);
|
|
1296
|
+
};
|
|
1297
|
+
this.appendFootnoteToElement = (footnote, element) => {
|
|
1298
|
+
const footnoteEl = this.document.createElement('fn');
|
|
1299
|
+
footnoteEl.setAttribute('id', normalizeID(footnote._id));
|
|
1300
|
+
footnoteEl.innerHTML = footnote.contents;
|
|
1301
|
+
element.appendChild(footnoteEl);
|
|
1302
|
+
};
|
|
1329
1303
|
this.fixBody = (body, fragment) => {
|
|
1330
1304
|
fragment.descendants((node) => {
|
|
1331
1305
|
if (node.attrs.id) {
|
package/dist/cjs/schema/index.js
CHANGED
|
@@ -36,6 +36,7 @@ const abstracts_1 = require("./nodes/abstracts");
|
|
|
36
36
|
const affiliation_1 = require("./nodes/affiliation");
|
|
37
37
|
const affiliations_1 = require("./nodes/affiliations");
|
|
38
38
|
const attribution_1 = require("./nodes/attribution");
|
|
39
|
+
const author_notes_1 = require("./nodes/author_notes");
|
|
39
40
|
const backmatter_1 = require("./nodes/backmatter");
|
|
40
41
|
const bibliography_element_1 = require("./nodes/bibliography_element");
|
|
41
42
|
const bibliography_item_1 = require("./nodes/bibliography_item");
|
|
@@ -87,6 +88,7 @@ const table_1 = require("./nodes/table");
|
|
|
87
88
|
const table_col_1 = require("./nodes/table_col");
|
|
88
89
|
const table_element_1 = require("./nodes/table_element");
|
|
89
90
|
const table_element_footer_1 = require("./nodes/table_element_footer");
|
|
91
|
+
const table_row_1 = require("./nodes/table_row");
|
|
90
92
|
const text_1 = require("./nodes/text");
|
|
91
93
|
const title_1 = require("./nodes/title");
|
|
92
94
|
const toc_element_1 = require("./nodes/toc_element");
|
|
@@ -136,6 +138,7 @@ __exportStar(require("./nodes/section_title"), exports);
|
|
|
136
138
|
__exportStar(require("./nodes/table"), exports);
|
|
137
139
|
__exportStar(require("./nodes/table_col"), exports);
|
|
138
140
|
__exportStar(require("./nodes/table_element"), exports);
|
|
141
|
+
__exportStar(require("./nodes/table_row"), exports);
|
|
139
142
|
__exportStar(require("./nodes/text"), exports);
|
|
140
143
|
__exportStar(require("./nodes/toc_element"), exports);
|
|
141
144
|
__exportStar(require("./nodes/toc_section"), exports);
|
|
@@ -211,9 +214,10 @@ exports.schema = new prosemirror_model_1.Schema({
|
|
|
211
214
|
section_title: section_title_1.sectionTitle,
|
|
212
215
|
section_title_plain: section_title_1.sectionTitle,
|
|
213
216
|
table: table_1.table,
|
|
214
|
-
|
|
217
|
+
table_body: table_1.tableBody,
|
|
218
|
+
table_cell: table_row_1.tableCell,
|
|
215
219
|
table_element: table_element_1.tableElement,
|
|
216
|
-
table_row:
|
|
220
|
+
table_row: table_row_1.tableRow,
|
|
217
221
|
table_col: table_col_1.tableCol,
|
|
218
222
|
table_colgroup: table_col_1.tableColGroup,
|
|
219
223
|
text: text_1.text,
|
|
@@ -227,6 +231,6 @@ exports.schema = new prosemirror_model_1.Schema({
|
|
|
227
231
|
contributors: contributors_1.contributors,
|
|
228
232
|
supplements: supplements_1.supplements,
|
|
229
233
|
supplement: supplement_1.supplement,
|
|
230
|
-
|
|
234
|
+
author_notes: author_notes_1.authorNotes,
|
|
231
235
|
},
|
|
232
236
|
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* © 2019 Atypon Systems LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.authorNotes = void 0;
|
|
19
|
+
exports.authorNotes = {
|
|
20
|
+
attrs: {
|
|
21
|
+
id: { default: '' },
|
|
22
|
+
dataTracked: { default: null },
|
|
23
|
+
},
|
|
24
|
+
content: '(footnote | paragraph)+',
|
|
25
|
+
group: 'block element',
|
|
26
|
+
toDOM: () => ['author-notes', 0],
|
|
27
|
+
};
|
|
@@ -15,57 +15,20 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.
|
|
19
|
-
const prosemirror_tables_1 = require("prosemirror-tables");
|
|
20
|
-
function createCellAttribute(attributeName, defaultValue = null, customGetFromDOM, customSetDOMAttr) {
|
|
21
|
-
return {
|
|
22
|
-
default: defaultValue,
|
|
23
|
-
getFromDOM(dom) {
|
|
24
|
-
if (customGetFromDOM) {
|
|
25
|
-
return customGetFromDOM(dom);
|
|
26
|
-
}
|
|
27
|
-
return dom.getAttribute(attributeName);
|
|
28
|
-
},
|
|
29
|
-
setDOMAttr(value, attrs) {
|
|
30
|
-
if (customSetDOMAttr) {
|
|
31
|
-
customSetDOMAttr(value, attrs);
|
|
32
|
-
}
|
|
33
|
-
else if (value) {
|
|
34
|
-
attrs[attributeName] = value;
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
const tableOptions = {
|
|
40
|
-
cellContent: 'inline*',
|
|
41
|
-
cellAttributes: {
|
|
42
|
-
placeholder: createCellAttribute('data-placeholder-text', 'Data', (dom) => dom.getAttribute('data-placeholder-text') || ''),
|
|
43
|
-
valign: createCellAttribute('valign'),
|
|
44
|
-
align: createCellAttribute('align'),
|
|
45
|
-
scope: createCellAttribute('scope'),
|
|
46
|
-
style: createCellAttribute('style'),
|
|
47
|
-
colspan: createCellAttribute('colspan', 1, (dom) => Number(dom.getAttribute('colspan') || 1), (value, attrs) => {
|
|
48
|
-
if (value && value !== 1) {
|
|
49
|
-
attrs['colspan'] = String(value);
|
|
50
|
-
}
|
|
51
|
-
}),
|
|
52
|
-
rowspan: createCellAttribute('rowspan', 1, (dom) => Number(dom.getAttribute('rowspan') || 1), (value, attrs) => {
|
|
53
|
-
if (value && value !== 1) {
|
|
54
|
-
attrs['rowspan'] = String(value);
|
|
55
|
-
}
|
|
56
|
-
}),
|
|
57
|
-
},
|
|
58
|
-
};
|
|
59
|
-
const tableNodes = (0, prosemirror_tables_1.tableNodes)(tableOptions);
|
|
18
|
+
exports.tableBody = exports.table = void 0;
|
|
60
19
|
exports.table = {
|
|
20
|
+
content: 'table_colgroup? table_body',
|
|
21
|
+
tableRole: 'table',
|
|
22
|
+
isolating: true,
|
|
23
|
+
group: 'block',
|
|
24
|
+
selectable: false,
|
|
61
25
|
attrs: {
|
|
62
26
|
id: { default: '' },
|
|
27
|
+
headerRows: { default: 1 },
|
|
28
|
+
footerRows: { default: 1 },
|
|
63
29
|
dataTracked: { default: null },
|
|
30
|
+
comments: { default: null },
|
|
64
31
|
},
|
|
65
|
-
content: 'table_row+',
|
|
66
|
-
tableRole: 'table',
|
|
67
|
-
isolating: true,
|
|
68
|
-
group: 'block',
|
|
69
32
|
parseDOM: [
|
|
70
33
|
{
|
|
71
34
|
tag: 'table',
|
|
@@ -73,20 +36,35 @@ exports.table = {
|
|
|
73
36
|
const dom = p;
|
|
74
37
|
return {
|
|
75
38
|
id: dom.getAttribute('id'),
|
|
39
|
+
headerRows: dom.dataset && dom.dataset['header-rows'],
|
|
40
|
+
footerRows: dom.dataset && dom.dataset['footer-rows'],
|
|
76
41
|
};
|
|
77
42
|
},
|
|
78
43
|
},
|
|
79
44
|
],
|
|
80
|
-
toDOM(node) {
|
|
45
|
+
toDOM: (node) => {
|
|
46
|
+
const tableNode = node;
|
|
81
47
|
return [
|
|
82
48
|
'table',
|
|
83
49
|
{
|
|
84
|
-
id:
|
|
50
|
+
id: tableNode.attrs.id,
|
|
51
|
+
'data-header-rows': String(node.attrs.headerRows),
|
|
52
|
+
'data-footer-rows': String(node.attrs.footerRows),
|
|
85
53
|
},
|
|
86
|
-
|
|
54
|
+
0,
|
|
87
55
|
];
|
|
88
56
|
},
|
|
89
57
|
};
|
|
90
|
-
exports.
|
|
91
|
-
|
|
92
|
-
|
|
58
|
+
exports.tableBody = {
|
|
59
|
+
content: 'table_row+',
|
|
60
|
+
group: 'block',
|
|
61
|
+
tableRole: 'table',
|
|
62
|
+
parseDOM: [
|
|
63
|
+
{
|
|
64
|
+
tag: 'tbody',
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
toDOM() {
|
|
68
|
+
return ['tbody', 0];
|
|
69
|
+
},
|
|
70
|
+
};
|
|
@@ -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)
|
|
20
|
+
content: '(table | placeholder) table_element_footer? figcaption? (listing | placeholder)',
|
|
21
21
|
attrs: {
|
|
22
22
|
id: { default: '' },
|
|
23
23
|
paragraphStyle: { default: '' },
|
|
@@ -0,0 +1,123 @@
|
|
|
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.tableCell = exports.tableRow = void 0;
|
|
19
|
+
const table_cell_styles_1 = require("../../lib/table-cell-styles");
|
|
20
|
+
const getCellAttrs = (p) => {
|
|
21
|
+
const dom = p;
|
|
22
|
+
const celltype = dom.tagName.toLowerCase();
|
|
23
|
+
const widthAttr = dom.getAttribute('data-colwidth');
|
|
24
|
+
const widths = widthAttr && /^\d+(,\d+)*$/.test(widthAttr)
|
|
25
|
+
? widthAttr.split(',').map((s) => Number(s))
|
|
26
|
+
: null;
|
|
27
|
+
const colspan = Number(dom.getAttribute('colspan') || 1);
|
|
28
|
+
const valign = dom.getAttribute('valign');
|
|
29
|
+
const align = dom.getAttribute('align');
|
|
30
|
+
const scope = dom.getAttribute('scope');
|
|
31
|
+
const style = dom.getAttribute('style');
|
|
32
|
+
return {
|
|
33
|
+
celltype,
|
|
34
|
+
colspan,
|
|
35
|
+
rowspan: Number(dom.getAttribute('rowspan') || 1),
|
|
36
|
+
colwidth: widths && widths.length === colspan ? widths : null,
|
|
37
|
+
placeholder: dom.getAttribute('data-placeholder-text') || '',
|
|
38
|
+
styles: (0, table_cell_styles_1.getTableCellStyles)(dom.style),
|
|
39
|
+
valign,
|
|
40
|
+
align,
|
|
41
|
+
scope,
|
|
42
|
+
style,
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
exports.tableRow = {
|
|
46
|
+
content: 'table_cell+',
|
|
47
|
+
tableRole: 'row',
|
|
48
|
+
attrs: {
|
|
49
|
+
placeholder: { default: '' },
|
|
50
|
+
},
|
|
51
|
+
parseDOM: [
|
|
52
|
+
{
|
|
53
|
+
tag: 'tr',
|
|
54
|
+
priority: 80,
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
toDOM: (node) => {
|
|
58
|
+
const tableRowNode = node;
|
|
59
|
+
const attrs = {};
|
|
60
|
+
if (tableRowNode.attrs.placeholder) {
|
|
61
|
+
attrs['data-placeholder-text'] = tableRowNode.attrs.placeholder;
|
|
62
|
+
}
|
|
63
|
+
return ['tr', attrs, 0];
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
exports.tableCell = {
|
|
67
|
+
content: 'inline*',
|
|
68
|
+
attrs: {
|
|
69
|
+
celltype: { default: 'td' },
|
|
70
|
+
colspan: { default: 1 },
|
|
71
|
+
rowspan: { default: 1 },
|
|
72
|
+
colwidth: { default: null },
|
|
73
|
+
placeholder: { default: 'Data' },
|
|
74
|
+
styles: { default: {} },
|
|
75
|
+
valign: { default: null },
|
|
76
|
+
align: { default: null },
|
|
77
|
+
scope: { default: null },
|
|
78
|
+
style: { default: null },
|
|
79
|
+
},
|
|
80
|
+
tableRole: 'cell',
|
|
81
|
+
isolating: true,
|
|
82
|
+
parseDOM: [
|
|
83
|
+
{ tag: 'td', getAttrs: getCellAttrs },
|
|
84
|
+
{ tag: 'th', getAttrs: getCellAttrs },
|
|
85
|
+
],
|
|
86
|
+
toDOM: (node) => {
|
|
87
|
+
const tableCellNode = node;
|
|
88
|
+
const attrs = {};
|
|
89
|
+
const tag = tableCellNode.attrs.celltype;
|
|
90
|
+
if (tableCellNode.attrs.colspan && tableCellNode.attrs.colspan !== 1) {
|
|
91
|
+
attrs.colspan = String(tableCellNode.attrs.colspan);
|
|
92
|
+
}
|
|
93
|
+
if (tableCellNode.attrs.rowspan && tableCellNode.attrs.rowspan !== 1) {
|
|
94
|
+
attrs.rowspan = String(tableCellNode.attrs.rowspan);
|
|
95
|
+
}
|
|
96
|
+
if (tableCellNode.attrs.colwidth) {
|
|
97
|
+
attrs['data-colwidth'] = tableCellNode.attrs.colwidth.join(',');
|
|
98
|
+
}
|
|
99
|
+
if (tableCellNode.attrs.placeholder) {
|
|
100
|
+
attrs['data-placeholder-text'] = tableCellNode.attrs.placeholder;
|
|
101
|
+
}
|
|
102
|
+
if (!tableCellNode.textContent) {
|
|
103
|
+
attrs.class = 'placeholder';
|
|
104
|
+
}
|
|
105
|
+
const styleString = (0, table_cell_styles_1.serializeTableCellStyles)(tableCellNode.attrs.styles);
|
|
106
|
+
if (styleString) {
|
|
107
|
+
attrs.style = styleString;
|
|
108
|
+
}
|
|
109
|
+
if (tableCellNode.attrs.valign) {
|
|
110
|
+
attrs.valign = tableCellNode.attrs.valign;
|
|
111
|
+
}
|
|
112
|
+
if (tableCellNode.attrs.align) {
|
|
113
|
+
attrs.align = tableCellNode.attrs.align;
|
|
114
|
+
}
|
|
115
|
+
if (tableCellNode.attrs.scope) {
|
|
116
|
+
attrs.scope = tableCellNode.attrs.scope;
|
|
117
|
+
}
|
|
118
|
+
if (tableCellNode.attrs.style) {
|
|
119
|
+
attrs.style = tableCellNode.attrs.style;
|
|
120
|
+
}
|
|
121
|
+
return [tag, attrs, 0];
|
|
122
|
+
},
|
|
123
|
+
};
|
|
@@ -18,7 +18,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
18
18
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
19
|
};
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.buildTitles = exports.buildElementsOrder = exports.auxiliaryObjectTypes = exports.buildJournal = exports.buildAttribution = exports.buildContributorRole = exports.buildContribution = exports.buildColor = exports.buildParagraph = exports.buildSection = exports.buildCorresp = exports.buildFootnotesOrder = exports.buildFootnote = exports.buildInlineMathFragment = exports.buildNote = exports.buildComment = exports.buildSupplementaryMaterial = exports.buildAffiliation = exports.buildFigure = exports.buildKeywordGroup = exports.buildKeyword = exports.buildBibliographyElement = exports.buildBibliographicDate = exports.buildBibliographicName = exports.buildBibliographyItem = exports.buildContributor = exports.buildManuscript = exports.buildProject = void 0;
|
|
21
|
+
exports.buildTitles = exports.buildElementsOrder = exports.auxiliaryObjectTypes = exports.buildJournal = exports.buildAttribution = exports.buildContributorRole = exports.buildContribution = exports.buildColor = exports.buildParagraph = exports.buildSection = exports.buildCorresp = exports.buildFootnotesOrder = exports.buildAuthorNotes = exports.buildFootnote = exports.buildInlineMathFragment = exports.buildNote = exports.buildComment = exports.buildSupplementaryMaterial = exports.buildAffiliation = exports.buildFigure = exports.buildKeywordGroup = exports.buildKeyword = exports.buildBibliographyElement = exports.buildBibliographicDate = exports.buildBibliographicName = exports.buildBibliographyItem = exports.buildContributor = exports.buildManuscript = exports.buildProject = void 0;
|
|
22
22
|
const json_schema_1 = require("@manuscripts/json-schema");
|
|
23
23
|
const w3c_xmlserializer_1 = __importDefault(require("w3c-xmlserializer"));
|
|
24
24
|
const schema_1 = require("../schema");
|
|
@@ -130,6 +130,12 @@ const buildFootnote = (containingObject, contents, kind = 'footnote') => ({
|
|
|
130
130
|
kind,
|
|
131
131
|
});
|
|
132
132
|
exports.buildFootnote = buildFootnote;
|
|
133
|
+
const buildAuthorNotes = (containedObjectIDs) => ({
|
|
134
|
+
_id: (0, id_1.generateID)(json_schema_1.ObjectTypes.AuthorNotes),
|
|
135
|
+
objectType: json_schema_1.ObjectTypes.AuthorNotes,
|
|
136
|
+
containedObjectIDs: containedObjectIDs,
|
|
137
|
+
});
|
|
138
|
+
exports.buildAuthorNotes = buildAuthorNotes;
|
|
133
139
|
const buildFootnotesOrder = (footnotesList) => ({
|
|
134
140
|
_id: (0, id_1.generateID)(json_schema_1.ObjectTypes.FootnotesOrder),
|
|
135
141
|
objectType: json_schema_1.ObjectTypes.FootnotesOrder,
|