@manuscripts/transform 2.1.1-LEAN-3336-19 → 2.1.1-LEAN-3352-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/jats/importer/jats-body-dom-parser.js +6 -2
- package/dist/cjs/jats/importer/jats-front-parser.js +5 -0
- package/dist/cjs/jats/importer/parse-jats-article.js +2 -1
- package/dist/cjs/jats/jats-exporter.js +5 -29
- package/dist/cjs/schema/index.js +5 -3
- package/dist/cjs/schema/nodes/table.js +30 -73
- package/dist/cjs/schema/nodes/table_element.js +1 -1
- package/dist/cjs/schema/nodes/table_row.js +123 -0
- package/dist/cjs/transformer/decode.js +3 -19
- package/dist/cjs/transformer/encode.js +1 -2
- package/dist/es/jats/importer/jats-body-dom-parser.js +6 -2
- package/dist/es/jats/importer/jats-front-parser.js +5 -0
- package/dist/es/jats/importer/parse-jats-article.js +2 -1
- package/dist/es/jats/jats-exporter.js +5 -29
- package/dist/es/schema/index.js +4 -2
- package/dist/es/schema/nodes/table.js +29 -72
- package/dist/es/schema/nodes/table_element.js +1 -1
- package/dist/es/schema/nodes/table_row.js +120 -0
- package/dist/es/transformer/decode.js +3 -19
- package/dist/es/transformer/encode.js +1 -2
- package/dist/types/jats/importer/jats-front-parser.d.ts +1 -0
- package/dist/types/schema/index.d.ts +1 -0
- package/dist/types/schema/nodes/table.d.ts +10 -72
- package/dist/types/schema/nodes/table_row.d.ts +41 -0
- package/dist/types/schema/types.d.ts +1 -1
- package/dist/types/transformer/decode.d.ts +0 -1
- package/package.json +4 -5
|
@@ -530,6 +530,10 @@ const nodes = [
|
|
|
530
530
|
};
|
|
531
531
|
},
|
|
532
532
|
},
|
|
533
|
+
{
|
|
534
|
+
tag: 'tbody',
|
|
535
|
+
skip: true,
|
|
536
|
+
},
|
|
533
537
|
{
|
|
534
538
|
tag: 'tfoot',
|
|
535
539
|
skip: true,
|
|
@@ -564,12 +568,12 @@ const nodes = [
|
|
|
564
568
|
},
|
|
565
569
|
{
|
|
566
570
|
tag: 'th',
|
|
567
|
-
node: '
|
|
571
|
+
node: 'table_cell',
|
|
568
572
|
getAttrs: (node) => {
|
|
569
573
|
const element = node;
|
|
570
574
|
const colspan = element.getAttribute('colspan');
|
|
571
575
|
const rowspan = element.getAttribute('rowspan');
|
|
572
|
-
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') });
|
|
573
577
|
},
|
|
574
578
|
},
|
|
575
579
|
{
|
|
@@ -45,6 +45,11 @@ exports.jatsFrontParser = {
|
|
|
45
45
|
}
|
|
46
46
|
return titles;
|
|
47
47
|
},
|
|
48
|
+
parseDOI(front) {
|
|
49
|
+
var _a;
|
|
50
|
+
const doi = front === null || front === void 0 ? void 0 : front.querySelector('article-meta > article-id[pub-id-type="doi"]');
|
|
51
|
+
return (_a = doi === null || doi === void 0 ? void 0 : doi.textContent) !== null && _a !== void 0 ? _a : undefined;
|
|
52
|
+
},
|
|
48
53
|
parseCounts(counts) {
|
|
49
54
|
var _a, _b, _c, _d, _e;
|
|
50
55
|
if (counts) {
|
|
@@ -31,6 +31,7 @@ const parseJATSFront = (doc, front) => {
|
|
|
31
31
|
const createElement = createElementFn(doc);
|
|
32
32
|
const journal = jats_front_parser_1.jatsFrontParser.parseJournal(front.querySelector('journal-meta'));
|
|
33
33
|
const titles = jats_front_parser_1.jatsFrontParser.parseTitles(front.querySelector('article-meta > title-group'), createElement);
|
|
34
|
+
const DOI = jats_front_parser_1.jatsFrontParser.parseDOI(front);
|
|
34
35
|
const { affiliations, affiliationIDs } = jats_front_parser_1.jatsFrontParser.parseAffiliations([
|
|
35
36
|
...front.querySelectorAll('article-meta > contrib-group > aff'),
|
|
36
37
|
]);
|
|
@@ -45,7 +46,7 @@ const parseJATSFront = (doc, front) => {
|
|
|
45
46
|
], affiliationIDs, footnoteIDs, correspondingIDs);
|
|
46
47
|
const history = jats_front_parser_1.jatsFrontParser.parseDates(front.querySelector('article-meta > history'));
|
|
47
48
|
const counts = jats_front_parser_1.jatsFrontParser.parseCounts(front.querySelector('article-meta counts'));
|
|
48
|
-
const manuscript = Object.assign(Object.assign(Object.assign({}, (0, builders_1.buildManuscript)()), counts), history);
|
|
49
|
+
const manuscript = Object.assign(Object.assign(Object.assign(Object.assign({}, (0, builders_1.buildManuscript)()), counts), history), { DOI });
|
|
49
50
|
return generateIDs([
|
|
50
51
|
manuscript,
|
|
51
52
|
titles,
|
|
@@ -311,10 +311,10 @@ class JATSExporter {
|
|
|
311
311
|
articleID.textContent = id;
|
|
312
312
|
articleMeta.appendChild(articleID);
|
|
313
313
|
}
|
|
314
|
-
if (doi) {
|
|
314
|
+
if (doi || manuscript.DOI) {
|
|
315
315
|
const articleID = this.document.createElement('article-id');
|
|
316
316
|
articleID.setAttribute('pub-id-type', 'doi');
|
|
317
|
-
articleID.textContent = doi;
|
|
317
|
+
articleID.textContent = doi !== null && doi !== void 0 ? doi : manuscript.DOI;
|
|
318
318
|
articleMeta.appendChild(articleID);
|
|
319
319
|
}
|
|
320
320
|
const titleGroup = this.document.createElement('title-group');
|
|
@@ -614,11 +614,6 @@ class JATSExporter {
|
|
|
614
614
|
this.createSerializer = () => {
|
|
615
615
|
const getModel = (id) => id ? this.modelMap.get(id) : undefined;
|
|
616
616
|
const nodes = {
|
|
617
|
-
table_header: (node) => [
|
|
618
|
-
'th',
|
|
619
|
-
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 })),
|
|
620
|
-
0,
|
|
621
|
-
],
|
|
622
617
|
title: () => '',
|
|
623
618
|
affiliations: () => '',
|
|
624
619
|
contributors: () => '',
|
|
@@ -878,8 +873,9 @@ class JATSExporter {
|
|
|
878
873
|
element.setAttribute('position', 'anchor');
|
|
879
874
|
return element;
|
|
880
875
|
},
|
|
876
|
+
table_body: () => ['tbody', 0],
|
|
881
877
|
table_cell: (node) => [
|
|
882
|
-
|
|
878
|
+
node.attrs.celltype,
|
|
883
879
|
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
880
|
0,
|
|
885
881
|
],
|
|
@@ -960,26 +956,6 @@ class JATSExporter {
|
|
|
960
956
|
element.appendChild(this.serializeNode(childNode));
|
|
961
957
|
}
|
|
962
958
|
};
|
|
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
959
|
const createFigureElement = (node, nodeName, contentNodeType, figType) => {
|
|
984
960
|
const element = createElement(node, nodeName);
|
|
985
961
|
if (figType) {
|
|
@@ -1000,7 +976,7 @@ class JATSExporter {
|
|
|
1000
976
|
const element = createElement(node, nodeName);
|
|
1001
977
|
appendLabels(element, node);
|
|
1002
978
|
appendChildNodeOfType(element, node, node.type.schema.nodes.figcaption);
|
|
1003
|
-
|
|
979
|
+
appendChildNodeOfType(element, node, node.type.schema.nodes.table);
|
|
1004
980
|
appendChildNodeOfType(element, node, node.type.schema.nodes.table_element_footer);
|
|
1005
981
|
if ((0, node_types_1.isExecutableNodeType)(node.type)) {
|
|
1006
982
|
processExecutableNode(node, element);
|
package/dist/cjs/schema/index.js
CHANGED
|
@@ -87,6 +87,7 @@ const table_1 = require("./nodes/table");
|
|
|
87
87
|
const table_col_1 = require("./nodes/table_col");
|
|
88
88
|
const table_element_1 = require("./nodes/table_element");
|
|
89
89
|
const table_element_footer_1 = require("./nodes/table_element_footer");
|
|
90
|
+
const table_row_1 = require("./nodes/table_row");
|
|
90
91
|
const text_1 = require("./nodes/text");
|
|
91
92
|
const title_1 = require("./nodes/title");
|
|
92
93
|
const toc_element_1 = require("./nodes/toc_element");
|
|
@@ -136,6 +137,7 @@ __exportStar(require("./nodes/section_title"), exports);
|
|
|
136
137
|
__exportStar(require("./nodes/table"), exports);
|
|
137
138
|
__exportStar(require("./nodes/table_col"), exports);
|
|
138
139
|
__exportStar(require("./nodes/table_element"), exports);
|
|
140
|
+
__exportStar(require("./nodes/table_row"), exports);
|
|
139
141
|
__exportStar(require("./nodes/text"), exports);
|
|
140
142
|
__exportStar(require("./nodes/toc_element"), exports);
|
|
141
143
|
__exportStar(require("./nodes/toc_section"), exports);
|
|
@@ -211,9 +213,10 @@ exports.schema = new prosemirror_model_1.Schema({
|
|
|
211
213
|
section_title: section_title_1.sectionTitle,
|
|
212
214
|
section_title_plain: section_title_1.sectionTitle,
|
|
213
215
|
table: table_1.table,
|
|
214
|
-
|
|
216
|
+
table_body: table_1.tableBody,
|
|
217
|
+
table_cell: table_row_1.tableCell,
|
|
215
218
|
table_element: table_element_1.tableElement,
|
|
216
|
-
table_row:
|
|
219
|
+
table_row: table_row_1.tableRow,
|
|
217
220
|
table_col: table_col_1.tableCol,
|
|
218
221
|
table_colgroup: table_col_1.tableColGroup,
|
|
219
222
|
text: text_1.text,
|
|
@@ -227,6 +230,5 @@ exports.schema = new prosemirror_model_1.Schema({
|
|
|
227
230
|
contributors: contributors_1.contributors,
|
|
228
231
|
supplements: supplements_1.supplements,
|
|
229
232
|
supplement: supplement_1.supplement,
|
|
230
|
-
table_header: table_1.tableHeader,
|
|
231
233
|
},
|
|
232
234
|
});
|
|
@@ -15,78 +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
|
-
const tableOptions = {
|
|
21
|
-
cellContent: 'inline*',
|
|
22
|
-
cellAttributes: {
|
|
23
|
-
placeholder: {
|
|
24
|
-
default: 'Data',
|
|
25
|
-
getFromDOM(dom) {
|
|
26
|
-
return dom.getAttribute('data-placeholder-text') || '';
|
|
27
|
-
},
|
|
28
|
-
setDOMAttr(value, attrs) {
|
|
29
|
-
if (value) {
|
|
30
|
-
attrs['data-placeholder-text'] = value;
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
valign: {
|
|
35
|
-
default: null,
|
|
36
|
-
getFromDOM(dom) {
|
|
37
|
-
return dom.getAttribute('valign');
|
|
38
|
-
},
|
|
39
|
-
setDOMAttr(value, attrs) {
|
|
40
|
-
if (value) {
|
|
41
|
-
attrs['valign'] = value;
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
align: {
|
|
46
|
-
default: null,
|
|
47
|
-
getFromDOM(dom) {
|
|
48
|
-
return dom.getAttribute('align');
|
|
49
|
-
},
|
|
50
|
-
setDOMAttr(value, attrs) {
|
|
51
|
-
if (value) {
|
|
52
|
-
attrs['align'] = value;
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
scope: {
|
|
57
|
-
default: null,
|
|
58
|
-
getFromDOM(dom) {
|
|
59
|
-
return dom.getAttribute('scope');
|
|
60
|
-
},
|
|
61
|
-
setDOMAttr(value, attrs) {
|
|
62
|
-
if (value) {
|
|
63
|
-
attrs['scope'] = value;
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
style: {
|
|
68
|
-
default: null,
|
|
69
|
-
getFromDOM(dom) {
|
|
70
|
-
return dom.getAttribute('style');
|
|
71
|
-
},
|
|
72
|
-
setDOMAttr(value, attrs) {
|
|
73
|
-
if (value) {
|
|
74
|
-
attrs['style'] = value;
|
|
75
|
-
}
|
|
76
|
-
},
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
};
|
|
80
|
-
const tableNodes = (0, prosemirror_tables_1.tableNodes)(tableOptions);
|
|
18
|
+
exports.tableBody = exports.table = void 0;
|
|
81
19
|
exports.table = {
|
|
20
|
+
content: 'table_colgroup? table_body',
|
|
21
|
+
tableRole: 'table',
|
|
22
|
+
isolating: true,
|
|
23
|
+
group: 'block',
|
|
24
|
+
selectable: false,
|
|
82
25
|
attrs: {
|
|
83
26
|
id: { default: '' },
|
|
27
|
+
headerRows: { default: 1 },
|
|
28
|
+
footerRows: { default: 1 },
|
|
84
29
|
dataTracked: { default: null },
|
|
30
|
+
comments: { default: null },
|
|
85
31
|
},
|
|
86
|
-
content: 'table_row+',
|
|
87
|
-
tableRole: 'table',
|
|
88
|
-
isolating: true,
|
|
89
|
-
group: 'block',
|
|
90
32
|
parseDOM: [
|
|
91
33
|
{
|
|
92
34
|
tag: 'table',
|
|
@@ -94,20 +36,35 @@ exports.table = {
|
|
|
94
36
|
const dom = p;
|
|
95
37
|
return {
|
|
96
38
|
id: dom.getAttribute('id'),
|
|
39
|
+
headerRows: dom.dataset && dom.dataset['header-rows'],
|
|
40
|
+
footerRows: dom.dataset && dom.dataset['footer-rows'],
|
|
97
41
|
};
|
|
98
42
|
},
|
|
99
43
|
},
|
|
100
44
|
],
|
|
101
|
-
toDOM(node) {
|
|
45
|
+
toDOM: (node) => {
|
|
46
|
+
const tableNode = node;
|
|
102
47
|
return [
|
|
103
48
|
'table',
|
|
104
49
|
{
|
|
105
|
-
id:
|
|
50
|
+
id: tableNode.attrs.id,
|
|
51
|
+
'data-header-rows': String(node.attrs.headerRows),
|
|
52
|
+
'data-footer-rows': String(node.attrs.footerRows),
|
|
106
53
|
},
|
|
107
|
-
|
|
54
|
+
0,
|
|
108
55
|
];
|
|
109
56
|
},
|
|
110
57
|
};
|
|
111
|
-
exports.
|
|
112
|
-
|
|
113
|
-
|
|
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: '
|
|
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
|
+
};
|
|
@@ -569,19 +569,13 @@ class Decoder {
|
|
|
569
569
|
[json_schema_1.ObjectTypes.TableElement]: (data) => {
|
|
570
570
|
const model = data;
|
|
571
571
|
const table = this.createTable(model);
|
|
572
|
-
const tableColGroup = this.createTableColGroup(model);
|
|
573
572
|
const tableElementFooter = this.createTableElementFooter(model);
|
|
574
573
|
const figcaption = this.getFigcaption(model);
|
|
575
574
|
const comments = this.createCommentNodes(model);
|
|
576
575
|
comments.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
577
|
-
const content =
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
}
|
|
581
|
-
if (tableElementFooter) {
|
|
582
|
-
content.push(tableElementFooter);
|
|
583
|
-
}
|
|
584
|
-
content.push(figcaption);
|
|
576
|
+
const content = tableElementFooter
|
|
577
|
+
? [table, tableElementFooter, figcaption]
|
|
578
|
+
: [table, figcaption];
|
|
585
579
|
if (model.listingID) {
|
|
586
580
|
const listing = this.createListing(model.listingID);
|
|
587
581
|
content.push(listing);
|
|
@@ -795,16 +789,6 @@ class Decoder {
|
|
|
795
789
|
}
|
|
796
790
|
return table;
|
|
797
791
|
}
|
|
798
|
-
createTableColGroup(model) {
|
|
799
|
-
const tableId = model.containedObjectID;
|
|
800
|
-
const tableModel = this.getModel(tableId);
|
|
801
|
-
if (!tableModel || !tableModel.contents.includes('<colgroup>')) {
|
|
802
|
-
return undefined;
|
|
803
|
-
}
|
|
804
|
-
return this.parseContents(tableModel.contents, undefined, [], {
|
|
805
|
-
topNode: schema_1.schema.nodes.table_colgroup.create(),
|
|
806
|
-
});
|
|
807
|
-
}
|
|
808
792
|
createTableElementFooter(model) {
|
|
809
793
|
const tableElementFooterID = model.tableElementFooterID;
|
|
810
794
|
if (!tableElementFooterID) {
|
|
@@ -115,9 +115,8 @@ function buildTableColGroup(cols) {
|
|
|
115
115
|
}
|
|
116
116
|
const tableContents = (node, parent) => {
|
|
117
117
|
const input = serializer.serializeNode(node);
|
|
118
|
-
const parentInput = serializer.serializeNode(parent);
|
|
119
118
|
const output = document.createElement('table');
|
|
120
|
-
const colgroup = buildTableColGroup(Array.from(
|
|
119
|
+
const colgroup = buildTableColGroup(Array.from(input.querySelectorAll('col')));
|
|
121
120
|
if (colgroup) {
|
|
122
121
|
output.appendChild(colgroup);
|
|
123
122
|
}
|
|
@@ -524,6 +524,10 @@ const nodes = [
|
|
|
524
524
|
};
|
|
525
525
|
},
|
|
526
526
|
},
|
|
527
|
+
{
|
|
528
|
+
tag: 'tbody',
|
|
529
|
+
skip: true,
|
|
530
|
+
},
|
|
527
531
|
{
|
|
528
532
|
tag: 'tfoot',
|
|
529
533
|
skip: true,
|
|
@@ -558,12 +562,12 @@ const nodes = [
|
|
|
558
562
|
},
|
|
559
563
|
{
|
|
560
564
|
tag: 'th',
|
|
561
|
-
node: '
|
|
565
|
+
node: 'table_cell',
|
|
562
566
|
getAttrs: (node) => {
|
|
563
567
|
const element = node;
|
|
564
568
|
const colspan = element.getAttribute('colspan');
|
|
565
569
|
const rowspan = element.getAttribute('rowspan');
|
|
566
|
-
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') });
|
|
570
|
+
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') });
|
|
567
571
|
},
|
|
568
572
|
},
|
|
569
573
|
{
|
|
@@ -39,6 +39,11 @@ export const jatsFrontParser = {
|
|
|
39
39
|
}
|
|
40
40
|
return titles;
|
|
41
41
|
},
|
|
42
|
+
parseDOI(front) {
|
|
43
|
+
var _a;
|
|
44
|
+
const doi = front === null || front === void 0 ? void 0 : front.querySelector('article-meta > article-id[pub-id-type="doi"]');
|
|
45
|
+
return (_a = doi === null || doi === void 0 ? void 0 : doi.textContent) !== null && _a !== void 0 ? _a : undefined;
|
|
46
|
+
},
|
|
42
47
|
parseCounts(counts) {
|
|
43
48
|
var _a, _b, _c, _d, _e;
|
|
44
49
|
if (counts) {
|
|
@@ -28,6 +28,7 @@ export const parseJATSFront = (doc, front) => {
|
|
|
28
28
|
const createElement = createElementFn(doc);
|
|
29
29
|
const journal = jatsFrontParser.parseJournal(front.querySelector('journal-meta'));
|
|
30
30
|
const titles = jatsFrontParser.parseTitles(front.querySelector('article-meta > title-group'), createElement);
|
|
31
|
+
const DOI = jatsFrontParser.parseDOI(front);
|
|
31
32
|
const { affiliations, affiliationIDs } = jatsFrontParser.parseAffiliations([
|
|
32
33
|
...front.querySelectorAll('article-meta > contrib-group > aff'),
|
|
33
34
|
]);
|
|
@@ -42,7 +43,7 @@ export const parseJATSFront = (doc, front) => {
|
|
|
42
43
|
], affiliationIDs, footnoteIDs, correspondingIDs);
|
|
43
44
|
const history = jatsFrontParser.parseDates(front.querySelector('article-meta > history'));
|
|
44
45
|
const counts = jatsFrontParser.parseCounts(front.querySelector('article-meta counts'));
|
|
45
|
-
const manuscript = Object.assign(Object.assign(Object.assign({}, buildManuscript()), counts), history);
|
|
46
|
+
const manuscript = Object.assign(Object.assign(Object.assign(Object.assign({}, buildManuscript()), counts), history), { DOI });
|
|
46
47
|
return generateIDs([
|
|
47
48
|
manuscript,
|
|
48
49
|
titles,
|
|
@@ -303,10 +303,10 @@ export class JATSExporter {
|
|
|
303
303
|
articleID.textContent = id;
|
|
304
304
|
articleMeta.appendChild(articleID);
|
|
305
305
|
}
|
|
306
|
-
if (doi) {
|
|
306
|
+
if (doi || manuscript.DOI) {
|
|
307
307
|
const articleID = this.document.createElement('article-id');
|
|
308
308
|
articleID.setAttribute('pub-id-type', 'doi');
|
|
309
|
-
articleID.textContent = doi;
|
|
309
|
+
articleID.textContent = doi !== null && doi !== void 0 ? doi : manuscript.DOI;
|
|
310
310
|
articleMeta.appendChild(articleID);
|
|
311
311
|
}
|
|
312
312
|
const titleGroup = this.document.createElement('title-group');
|
|
@@ -606,11 +606,6 @@ export class JATSExporter {
|
|
|
606
606
|
this.createSerializer = () => {
|
|
607
607
|
const getModel = (id) => id ? this.modelMap.get(id) : undefined;
|
|
608
608
|
const nodes = {
|
|
609
|
-
table_header: (node) => [
|
|
610
|
-
'th',
|
|
611
|
-
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 })),
|
|
612
|
-
0,
|
|
613
|
-
],
|
|
614
609
|
title: () => '',
|
|
615
610
|
affiliations: () => '',
|
|
616
611
|
contributors: () => '',
|
|
@@ -870,8 +865,9 @@ export class JATSExporter {
|
|
|
870
865
|
element.setAttribute('position', 'anchor');
|
|
871
866
|
return element;
|
|
872
867
|
},
|
|
868
|
+
table_body: () => ['tbody', 0],
|
|
873
869
|
table_cell: (node) => [
|
|
874
|
-
|
|
870
|
+
node.attrs.celltype,
|
|
875
871
|
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 })),
|
|
876
872
|
0,
|
|
877
873
|
],
|
|
@@ -952,26 +948,6 @@ export class JATSExporter {
|
|
|
952
948
|
element.appendChild(this.serializeNode(childNode));
|
|
953
949
|
}
|
|
954
950
|
};
|
|
955
|
-
const appendTable = (element, node) => {
|
|
956
|
-
const tableNode = findChildNodeOfType(node, node.type.schema.nodes.table);
|
|
957
|
-
const colGroupNode = findChildNodeOfType(node, node.type.schema.nodes.table_colgroup);
|
|
958
|
-
if (!tableNode) {
|
|
959
|
-
return;
|
|
960
|
-
}
|
|
961
|
-
const table = this.serializeNode(tableNode);
|
|
962
|
-
const tbodyElement = this.document.createElement('tbody');
|
|
963
|
-
while (table.firstChild) {
|
|
964
|
-
const child = table.firstChild;
|
|
965
|
-
table.removeChild(child);
|
|
966
|
-
tbodyElement.appendChild(child);
|
|
967
|
-
}
|
|
968
|
-
table.appendChild(tbodyElement);
|
|
969
|
-
if (colGroupNode) {
|
|
970
|
-
const colGroup = this.serializeNode(colGroupNode);
|
|
971
|
-
table.insertBefore(colGroup, table.firstChild);
|
|
972
|
-
}
|
|
973
|
-
element.appendChild(table);
|
|
974
|
-
};
|
|
975
951
|
const createFigureElement = (node, nodeName, contentNodeType, figType) => {
|
|
976
952
|
const element = createElement(node, nodeName);
|
|
977
953
|
if (figType) {
|
|
@@ -992,7 +968,7 @@ export class JATSExporter {
|
|
|
992
968
|
const element = createElement(node, nodeName);
|
|
993
969
|
appendLabels(element, node);
|
|
994
970
|
appendChildNodeOfType(element, node, node.type.schema.nodes.figcaption);
|
|
995
|
-
|
|
971
|
+
appendChildNodeOfType(element, node, node.type.schema.nodes.table);
|
|
996
972
|
appendChildNodeOfType(element, node, node.type.schema.nodes.table_element_footer);
|
|
997
973
|
if (isExecutableNodeType(node.type)) {
|
|
998
974
|
processExecutableNode(node, element);
|
package/dist/es/schema/index.js
CHANGED
|
@@ -66,10 +66,11 @@ import { sectionLabel } from './nodes/section_label';
|
|
|
66
66
|
import { sectionTitle } from './nodes/section_title';
|
|
67
67
|
import { supplement } from './nodes/supplement';
|
|
68
68
|
import { supplements } from './nodes/supplements';
|
|
69
|
-
import { table,
|
|
69
|
+
import { table, tableBody } from './nodes/table';
|
|
70
70
|
import { tableCol, tableColGroup } from './nodes/table_col';
|
|
71
71
|
import { tableElement } from './nodes/table_element';
|
|
72
72
|
import { tableElementFooter } from './nodes/table_element_footer';
|
|
73
|
+
import { tableCell, tableRow } from './nodes/table_row';
|
|
73
74
|
import { text } from './nodes/text';
|
|
74
75
|
import { title } from './nodes/title';
|
|
75
76
|
import { tocElement } from './nodes/toc_element';
|
|
@@ -119,6 +120,7 @@ export * from './nodes/section_title';
|
|
|
119
120
|
export * from './nodes/table';
|
|
120
121
|
export * from './nodes/table_col';
|
|
121
122
|
export * from './nodes/table_element';
|
|
123
|
+
export * from './nodes/table_row';
|
|
122
124
|
export * from './nodes/text';
|
|
123
125
|
export * from './nodes/toc_element';
|
|
124
126
|
export * from './nodes/toc_section';
|
|
@@ -194,6 +196,7 @@ export const schema = new Schema({
|
|
|
194
196
|
section_title: sectionTitle,
|
|
195
197
|
section_title_plain: sectionTitle,
|
|
196
198
|
table,
|
|
199
|
+
table_body: tableBody,
|
|
197
200
|
table_cell: tableCell,
|
|
198
201
|
table_element: tableElement,
|
|
199
202
|
table_row: tableRow,
|
|
@@ -210,6 +213,5 @@ export const schema = new Schema({
|
|
|
210
213
|
contributors,
|
|
211
214
|
supplements,
|
|
212
215
|
supplement,
|
|
213
|
-
table_header: tableHeader,
|
|
214
216
|
},
|
|
215
217
|
});
|
|
@@ -13,77 +13,19 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { tableNodes as createTableNodes, } from 'prosemirror-tables';
|
|
17
|
-
const tableOptions = {
|
|
18
|
-
cellContent: 'inline*',
|
|
19
|
-
cellAttributes: {
|
|
20
|
-
placeholder: {
|
|
21
|
-
default: 'Data',
|
|
22
|
-
getFromDOM(dom) {
|
|
23
|
-
return dom.getAttribute('data-placeholder-text') || '';
|
|
24
|
-
},
|
|
25
|
-
setDOMAttr(value, attrs) {
|
|
26
|
-
if (value) {
|
|
27
|
-
attrs['data-placeholder-text'] = value;
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
valign: {
|
|
32
|
-
default: null,
|
|
33
|
-
getFromDOM(dom) {
|
|
34
|
-
return dom.getAttribute('valign');
|
|
35
|
-
},
|
|
36
|
-
setDOMAttr(value, attrs) {
|
|
37
|
-
if (value) {
|
|
38
|
-
attrs['valign'] = value;
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
align: {
|
|
43
|
-
default: null,
|
|
44
|
-
getFromDOM(dom) {
|
|
45
|
-
return dom.getAttribute('align');
|
|
46
|
-
},
|
|
47
|
-
setDOMAttr(value, attrs) {
|
|
48
|
-
if (value) {
|
|
49
|
-
attrs['align'] = value;
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
scope: {
|
|
54
|
-
default: null,
|
|
55
|
-
getFromDOM(dom) {
|
|
56
|
-
return dom.getAttribute('scope');
|
|
57
|
-
},
|
|
58
|
-
setDOMAttr(value, attrs) {
|
|
59
|
-
if (value) {
|
|
60
|
-
attrs['scope'] = value;
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
style: {
|
|
65
|
-
default: null,
|
|
66
|
-
getFromDOM(dom) {
|
|
67
|
-
return dom.getAttribute('style');
|
|
68
|
-
},
|
|
69
|
-
setDOMAttr(value, attrs) {
|
|
70
|
-
if (value) {
|
|
71
|
-
attrs['style'] = value;
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
};
|
|
77
|
-
const tableNodes = createTableNodes(tableOptions);
|
|
78
16
|
export const table = {
|
|
17
|
+
content: 'table_colgroup? table_body',
|
|
18
|
+
tableRole: 'table',
|
|
19
|
+
isolating: true,
|
|
20
|
+
group: 'block',
|
|
21
|
+
selectable: false,
|
|
79
22
|
attrs: {
|
|
80
23
|
id: { default: '' },
|
|
24
|
+
headerRows: { default: 1 },
|
|
25
|
+
footerRows: { default: 1 },
|
|
81
26
|
dataTracked: { default: null },
|
|
27
|
+
comments: { default: null },
|
|
82
28
|
},
|
|
83
|
-
content: 'table_row+',
|
|
84
|
-
tableRole: 'table',
|
|
85
|
-
isolating: true,
|
|
86
|
-
group: 'block',
|
|
87
29
|
parseDOM: [
|
|
88
30
|
{
|
|
89
31
|
tag: 'table',
|
|
@@ -91,20 +33,35 @@ export const table = {
|
|
|
91
33
|
const dom = p;
|
|
92
34
|
return {
|
|
93
35
|
id: dom.getAttribute('id'),
|
|
36
|
+
headerRows: dom.dataset && dom.dataset['header-rows'],
|
|
37
|
+
footerRows: dom.dataset && dom.dataset['footer-rows'],
|
|
94
38
|
};
|
|
95
39
|
},
|
|
96
40
|
},
|
|
97
41
|
],
|
|
98
|
-
toDOM(node) {
|
|
42
|
+
toDOM: (node) => {
|
|
43
|
+
const tableNode = node;
|
|
99
44
|
return [
|
|
100
45
|
'table',
|
|
101
46
|
{
|
|
102
|
-
id:
|
|
47
|
+
id: tableNode.attrs.id,
|
|
48
|
+
'data-header-rows': String(node.attrs.headerRows),
|
|
49
|
+
'data-footer-rows': String(node.attrs.footerRows),
|
|
103
50
|
},
|
|
104
|
-
|
|
51
|
+
0,
|
|
105
52
|
];
|
|
106
53
|
},
|
|
107
54
|
};
|
|
108
|
-
export const
|
|
109
|
-
|
|
110
|
-
|
|
55
|
+
export const tableBody = {
|
|
56
|
+
content: 'table_row+',
|
|
57
|
+
group: 'block',
|
|
58
|
+
tableRole: 'table',
|
|
59
|
+
parseDOM: [
|
|
60
|
+
{
|
|
61
|
+
tag: 'tbody',
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
toDOM() {
|
|
65
|
+
return ['tbody', 0];
|
|
66
|
+
},
|
|
67
|
+
};
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
export const tableElement = {
|
|
17
|
-
content: '
|
|
17
|
+
content: '(table | placeholder) table_element_footer? figcaption? (listing | placeholder)',
|
|
18
18
|
attrs: {
|
|
19
19
|
id: { default: '' },
|
|
20
20
|
paragraphStyle: { default: '' },
|
|
@@ -0,0 +1,120 @@
|
|
|
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 { getTableCellStyles, serializeTableCellStyles, } from '../../lib/table-cell-styles';
|
|
17
|
+
const getCellAttrs = (p) => {
|
|
18
|
+
const dom = p;
|
|
19
|
+
const celltype = dom.tagName.toLowerCase();
|
|
20
|
+
const widthAttr = dom.getAttribute('data-colwidth');
|
|
21
|
+
const widths = widthAttr && /^\d+(,\d+)*$/.test(widthAttr)
|
|
22
|
+
? widthAttr.split(',').map((s) => Number(s))
|
|
23
|
+
: null;
|
|
24
|
+
const colspan = Number(dom.getAttribute('colspan') || 1);
|
|
25
|
+
const valign = dom.getAttribute('valign');
|
|
26
|
+
const align = dom.getAttribute('align');
|
|
27
|
+
const scope = dom.getAttribute('scope');
|
|
28
|
+
const style = dom.getAttribute('style');
|
|
29
|
+
return {
|
|
30
|
+
celltype,
|
|
31
|
+
colspan,
|
|
32
|
+
rowspan: Number(dom.getAttribute('rowspan') || 1),
|
|
33
|
+
colwidth: widths && widths.length === colspan ? widths : null,
|
|
34
|
+
placeholder: dom.getAttribute('data-placeholder-text') || '',
|
|
35
|
+
styles: getTableCellStyles(dom.style),
|
|
36
|
+
valign,
|
|
37
|
+
align,
|
|
38
|
+
scope,
|
|
39
|
+
style,
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
export const tableRow = {
|
|
43
|
+
content: 'table_cell+',
|
|
44
|
+
tableRole: 'row',
|
|
45
|
+
attrs: {
|
|
46
|
+
placeholder: { default: '' },
|
|
47
|
+
},
|
|
48
|
+
parseDOM: [
|
|
49
|
+
{
|
|
50
|
+
tag: 'tr',
|
|
51
|
+
priority: 80,
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
toDOM: (node) => {
|
|
55
|
+
const tableRowNode = node;
|
|
56
|
+
const attrs = {};
|
|
57
|
+
if (tableRowNode.attrs.placeholder) {
|
|
58
|
+
attrs['data-placeholder-text'] = tableRowNode.attrs.placeholder;
|
|
59
|
+
}
|
|
60
|
+
return ['tr', attrs, 0];
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
export const tableCell = {
|
|
64
|
+
content: 'inline*',
|
|
65
|
+
attrs: {
|
|
66
|
+
celltype: { default: 'td' },
|
|
67
|
+
colspan: { default: 1 },
|
|
68
|
+
rowspan: { default: 1 },
|
|
69
|
+
colwidth: { default: null },
|
|
70
|
+
placeholder: { default: 'Data' },
|
|
71
|
+
styles: { default: {} },
|
|
72
|
+
valign: { default: null },
|
|
73
|
+
align: { default: null },
|
|
74
|
+
scope: { default: null },
|
|
75
|
+
style: { default: null },
|
|
76
|
+
},
|
|
77
|
+
tableRole: 'cell',
|
|
78
|
+
isolating: true,
|
|
79
|
+
parseDOM: [
|
|
80
|
+
{ tag: 'td', getAttrs: getCellAttrs },
|
|
81
|
+
{ tag: 'th', getAttrs: getCellAttrs },
|
|
82
|
+
],
|
|
83
|
+
toDOM: (node) => {
|
|
84
|
+
const tableCellNode = node;
|
|
85
|
+
const attrs = {};
|
|
86
|
+
const tag = tableCellNode.attrs.celltype;
|
|
87
|
+
if (tableCellNode.attrs.colspan && tableCellNode.attrs.colspan !== 1) {
|
|
88
|
+
attrs.colspan = String(tableCellNode.attrs.colspan);
|
|
89
|
+
}
|
|
90
|
+
if (tableCellNode.attrs.rowspan && tableCellNode.attrs.rowspan !== 1) {
|
|
91
|
+
attrs.rowspan = String(tableCellNode.attrs.rowspan);
|
|
92
|
+
}
|
|
93
|
+
if (tableCellNode.attrs.colwidth) {
|
|
94
|
+
attrs['data-colwidth'] = tableCellNode.attrs.colwidth.join(',');
|
|
95
|
+
}
|
|
96
|
+
if (tableCellNode.attrs.placeholder) {
|
|
97
|
+
attrs['data-placeholder-text'] = tableCellNode.attrs.placeholder;
|
|
98
|
+
}
|
|
99
|
+
if (!tableCellNode.textContent) {
|
|
100
|
+
attrs.class = 'placeholder';
|
|
101
|
+
}
|
|
102
|
+
const styleString = serializeTableCellStyles(tableCellNode.attrs.styles);
|
|
103
|
+
if (styleString) {
|
|
104
|
+
attrs.style = styleString;
|
|
105
|
+
}
|
|
106
|
+
if (tableCellNode.attrs.valign) {
|
|
107
|
+
attrs.valign = tableCellNode.attrs.valign;
|
|
108
|
+
}
|
|
109
|
+
if (tableCellNode.attrs.align) {
|
|
110
|
+
attrs.align = tableCellNode.attrs.align;
|
|
111
|
+
}
|
|
112
|
+
if (tableCellNode.attrs.scope) {
|
|
113
|
+
attrs.scope = tableCellNode.attrs.scope;
|
|
114
|
+
}
|
|
115
|
+
if (tableCellNode.attrs.style) {
|
|
116
|
+
attrs.style = tableCellNode.attrs.style;
|
|
117
|
+
}
|
|
118
|
+
return [tag, attrs, 0];
|
|
119
|
+
},
|
|
120
|
+
};
|
|
@@ -560,19 +560,13 @@ export class Decoder {
|
|
|
560
560
|
[ObjectTypes.TableElement]: (data) => {
|
|
561
561
|
const model = data;
|
|
562
562
|
const table = this.createTable(model);
|
|
563
|
-
const tableColGroup = this.createTableColGroup(model);
|
|
564
563
|
const tableElementFooter = this.createTableElementFooter(model);
|
|
565
564
|
const figcaption = this.getFigcaption(model);
|
|
566
565
|
const comments = this.createCommentNodes(model);
|
|
567
566
|
comments.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
568
|
-
const content =
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
}
|
|
572
|
-
if (tableElementFooter) {
|
|
573
|
-
content.push(tableElementFooter);
|
|
574
|
-
}
|
|
575
|
-
content.push(figcaption);
|
|
567
|
+
const content = tableElementFooter
|
|
568
|
+
? [table, tableElementFooter, figcaption]
|
|
569
|
+
: [table, figcaption];
|
|
576
570
|
if (model.listingID) {
|
|
577
571
|
const listing = this.createListing(model.listingID);
|
|
578
572
|
content.push(listing);
|
|
@@ -786,16 +780,6 @@ export class Decoder {
|
|
|
786
780
|
}
|
|
787
781
|
return table;
|
|
788
782
|
}
|
|
789
|
-
createTableColGroup(model) {
|
|
790
|
-
const tableId = model.containedObjectID;
|
|
791
|
-
const tableModel = this.getModel(tableId);
|
|
792
|
-
if (!tableModel || !tableModel.contents.includes('<colgroup>')) {
|
|
793
|
-
return undefined;
|
|
794
|
-
}
|
|
795
|
-
return this.parseContents(tableModel.contents, undefined, [], {
|
|
796
|
-
topNode: schema.nodes.table_colgroup.create(),
|
|
797
|
-
});
|
|
798
|
-
}
|
|
799
783
|
createTableElementFooter(model) {
|
|
800
784
|
const tableElementFooterID = model.tableElementFooterID;
|
|
801
785
|
if (!tableElementFooterID) {
|
|
@@ -107,9 +107,8 @@ function buildTableColGroup(cols) {
|
|
|
107
107
|
}
|
|
108
108
|
const tableContents = (node, parent) => {
|
|
109
109
|
const input = serializer.serializeNode(node);
|
|
110
|
-
const parentInput = serializer.serializeNode(parent);
|
|
111
110
|
const output = document.createElement('table');
|
|
112
|
-
const colgroup = buildTableColGroup(Array.from(
|
|
111
|
+
const colgroup = buildTableColGroup(Array.from(input.querySelectorAll('col')));
|
|
113
112
|
if (colgroup) {
|
|
114
113
|
output.appendChild(colgroup);
|
|
115
114
|
}
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
export declare const jatsFrontParser: {
|
|
17
17
|
parseTitles(element: Element | null, createElement: (tagName: string) => HTMLElement): import("../../transformer").Build<import("@manuscripts/json-schema/dist/types").Titles>;
|
|
18
|
+
parseDOI(front: Element | null): string | undefined;
|
|
18
19
|
parseCounts(counts: Element | null): {
|
|
19
20
|
wordCount: number | undefined;
|
|
20
21
|
figureCount: number | undefined;
|
|
@@ -60,6 +60,7 @@ export * from './nodes/section_title';
|
|
|
60
60
|
export * from './nodes/table';
|
|
61
61
|
export * from './nodes/table_col';
|
|
62
62
|
export * from './nodes/table_element';
|
|
63
|
+
export * from './nodes/table_row';
|
|
63
64
|
export * from './nodes/text';
|
|
64
65
|
export * from './nodes/toc_element';
|
|
65
66
|
export * from './nodes/toc_section';
|
|
@@ -13,77 +13,15 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
export
|
|
16
|
+
import { ManuscriptNode, TableNodeSpec } from '../types';
|
|
17
|
+
import { CommentNode } from './comment';
|
|
18
|
+
export interface TableNode extends ManuscriptNode {
|
|
19
19
|
attrs: {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
id: string;
|
|
21
|
+
headerRows: number;
|
|
22
|
+
footerRows: number;
|
|
23
|
+
comments?: CommentNode[];
|
|
23
24
|
};
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
inline?: boolean | undefined;
|
|
28
|
-
atom?: boolean | undefined;
|
|
29
|
-
selectable?: boolean | undefined;
|
|
30
|
-
draggable?: boolean | undefined;
|
|
31
|
-
code?: boolean | undefined;
|
|
32
|
-
whitespace?: "pre" | "normal" | undefined;
|
|
33
|
-
definingAsContext?: boolean | undefined;
|
|
34
|
-
definingForContent?: boolean | undefined;
|
|
35
|
-
defining?: boolean | undefined;
|
|
36
|
-
isolating?: boolean | undefined;
|
|
37
|
-
toDOM?: ((node: import("prosemirror-model").Node) => import("prosemirror-model").DOMOutputSpec) | undefined;
|
|
38
|
-
parseDOM?: readonly import("prosemirror-model").ParseRule[] | undefined;
|
|
39
|
-
toDebugString?: ((node: import("prosemirror-model").Node) => string) | undefined;
|
|
40
|
-
leafText?: ((node: import("prosemirror-model").Node) => string) | undefined;
|
|
41
|
-
};
|
|
42
|
-
export declare const tableCell: {
|
|
43
|
-
attrs: {
|
|
44
|
-
dataTracked: {
|
|
45
|
-
default: null;
|
|
46
|
-
};
|
|
47
|
-
};
|
|
48
|
-
content?: string | undefined;
|
|
49
|
-
marks?: string | undefined;
|
|
50
|
-
group?: string | undefined;
|
|
51
|
-
inline?: boolean | undefined;
|
|
52
|
-
atom?: boolean | undefined;
|
|
53
|
-
selectable?: boolean | undefined;
|
|
54
|
-
draggable?: boolean | undefined;
|
|
55
|
-
code?: boolean | undefined;
|
|
56
|
-
whitespace?: "pre" | "normal" | undefined;
|
|
57
|
-
definingAsContext?: boolean | undefined;
|
|
58
|
-
definingForContent?: boolean | undefined;
|
|
59
|
-
defining?: boolean | undefined;
|
|
60
|
-
isolating?: boolean | undefined;
|
|
61
|
-
toDOM?: ((node: import("prosemirror-model").Node) => import("prosemirror-model").DOMOutputSpec) | undefined;
|
|
62
|
-
parseDOM?: readonly import("prosemirror-model").ParseRule[] | undefined;
|
|
63
|
-
toDebugString?: ((node: import("prosemirror-model").Node) => string) | undefined;
|
|
64
|
-
leafText?: ((node: import("prosemirror-model").Node) => string) | undefined;
|
|
65
|
-
};
|
|
66
|
-
export declare const tableHeader: {
|
|
67
|
-
attrs: {
|
|
68
|
-
dataTracked: {
|
|
69
|
-
default: null;
|
|
70
|
-
};
|
|
71
|
-
};
|
|
72
|
-
content?: string | undefined;
|
|
73
|
-
marks?: string | undefined;
|
|
74
|
-
group?: string | undefined;
|
|
75
|
-
inline?: boolean | undefined;
|
|
76
|
-
atom?: boolean | undefined;
|
|
77
|
-
selectable?: boolean | undefined;
|
|
78
|
-
draggable?: boolean | undefined;
|
|
79
|
-
code?: boolean | undefined;
|
|
80
|
-
whitespace?: "pre" | "normal" | undefined;
|
|
81
|
-
definingAsContext?: boolean | undefined;
|
|
82
|
-
definingForContent?: boolean | undefined;
|
|
83
|
-
defining?: boolean | undefined;
|
|
84
|
-
isolating?: boolean | undefined;
|
|
85
|
-
toDOM?: ((node: import("prosemirror-model").Node) => import("prosemirror-model").DOMOutputSpec) | undefined;
|
|
86
|
-
parseDOM?: readonly import("prosemirror-model").ParseRule[] | undefined;
|
|
87
|
-
toDebugString?: ((node: import("prosemirror-model").Node) => string) | undefined;
|
|
88
|
-
leafText?: ((node: import("prosemirror-model").Node) => string) | undefined;
|
|
89
|
-
};
|
|
25
|
+
}
|
|
26
|
+
export declare const table: TableNodeSpec;
|
|
27
|
+
export declare const tableBody: TableNodeSpec;
|
|
@@ -0,0 +1,41 @@
|
|
|
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 { TableCellStyleKey } from '../../lib/table-cell-styles';
|
|
17
|
+
import { ManuscriptNode, TableNodeSpec } from '../types';
|
|
18
|
+
export interface TableRowNode extends ManuscriptNode {
|
|
19
|
+
attrs: {
|
|
20
|
+
placeholder: string;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export declare const tableRow: TableNodeSpec;
|
|
24
|
+
export type TableCellStyles = {
|
|
25
|
+
[key in TableCellStyleKey]?: string | null;
|
|
26
|
+
};
|
|
27
|
+
export interface TableCellNode extends ManuscriptNode {
|
|
28
|
+
attrs: {
|
|
29
|
+
celltype: 'td' | 'th';
|
|
30
|
+
colspan: number | null;
|
|
31
|
+
rowspan: number | null;
|
|
32
|
+
colwidth: number[] | null;
|
|
33
|
+
placeholder: string | null;
|
|
34
|
+
styles: TableCellStyles;
|
|
35
|
+
valign: string | null;
|
|
36
|
+
align: string | null;
|
|
37
|
+
scope: string | null;
|
|
38
|
+
style: string | null;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export declare const tableCell: TableNodeSpec;
|
|
@@ -17,7 +17,7 @@ import { Fragment, Mark as ProsemirrorMark, MarkType, Node as ProsemirrorNode, N
|
|
|
17
17
|
import { EditorState, NodeSelection, Plugin, TextSelection, Transaction } from 'prosemirror-state';
|
|
18
18
|
import { EditorView, NodeView } from 'prosemirror-view';
|
|
19
19
|
export type Marks = 'bold' | 'code' | 'italic' | 'smallcaps' | 'strikethrough' | 'styled' | 'subscript' | 'superscript' | 'underline' | 'tracked_insert' | 'tracked_delete';
|
|
20
|
-
export type Nodes = 'attribution' | 'bibliography_item' | 'bibliography_element' | 'bibliography_section' | 'blockquote_element' | 'bullet_list' | 'caption' | 'caption_title' | 'comment' | 'comments' | 'citation' | 'cross_reference' | 'doc' | 'equation' | 'equation_element' | 'figcaption' | 'figure' | 'graphical_abstract_section' | 'figure_element' | 'footnote' | 'footnotes_element' | 'footnotes_section' | 'hard_break' | 'highlight_marker' | 'inline_equation' | 'inline_footnote' | 'keyword' | 'keywords_element' | 'keyword_group' | 'keywords' | 'link' | 'list_item' | 'listing' | 'listing_element' | 'manuscript' | 'abstracts' | 'body' | 'backmatter' | 'missing_figure' | 'ordered_list' | 'paragraph' | 'placeholder' | 'placeholder_element' | 'pullquote_element' | 'section' | 'section_label' | 'section_title' | 'section_title_plain' | 'table' | 'table_cell' | 'table_element' | 'table_row' | 'table_colgroup' | 'table_col' | 'text' | 'toc_element' | 'toc_section' | 'affiliation' | 'contributor' | 'table_element_footer' | 'title' | 'affiliations' | 'contributors' | 'supplements' | 'supplement'
|
|
20
|
+
export type Nodes = 'attribution' | 'bibliography_item' | 'bibliography_element' | 'bibliography_section' | 'blockquote_element' | 'bullet_list' | 'caption' | 'caption_title' | 'comment' | 'comments' | 'citation' | 'cross_reference' | 'doc' | 'equation' | 'equation_element' | 'figcaption' | 'figure' | 'graphical_abstract_section' | 'figure_element' | 'footnote' | 'footnotes_element' | 'footnotes_section' | 'hard_break' | 'highlight_marker' | 'inline_equation' | 'inline_footnote' | 'keyword' | 'keywords_element' | 'keyword_group' | 'keywords' | 'link' | 'list_item' | 'listing' | 'listing_element' | 'manuscript' | 'abstracts' | 'body' | 'backmatter' | 'missing_figure' | 'ordered_list' | 'paragraph' | 'placeholder' | 'placeholder_element' | 'pullquote_element' | 'section' | 'section_label' | 'section_title' | 'section_title_plain' | 'table' | 'table_body' | 'table_cell' | 'table_element' | 'table_row' | 'table_colgroup' | 'table_col' | 'text' | 'toc_element' | 'toc_section' | 'affiliation' | 'contributor' | 'table_element_footer' | 'title' | 'affiliations' | 'contributors' | 'supplements' | 'supplement';
|
|
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": "2.1.1-LEAN-
|
|
4
|
+
"version": "2.1.1-LEAN-3352-0",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-transform",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|
|
@@ -35,8 +35,7 @@
|
|
|
35
35
|
"jszip": "^3.10.1",
|
|
36
36
|
"mathjax-full": "^3.2.2",
|
|
37
37
|
"mime": "^3.0.0",
|
|
38
|
-
"prosemirror-model": "^1.
|
|
39
|
-
"prosemirror-tables": "^1.3.5",
|
|
38
|
+
"prosemirror-model": "^1.18.3",
|
|
40
39
|
"uuid": "^9.0.0",
|
|
41
40
|
"w3c-xmlserializer": "^4.0.0"
|
|
42
41
|
},
|
|
@@ -65,9 +64,9 @@
|
|
|
65
64
|
"eslint-plugin-mdx": "^2.0.5",
|
|
66
65
|
"eslint-plugin-prettier": "^4.2.1",
|
|
67
66
|
"eslint-plugin-promise": "^6.1.1",
|
|
67
|
+
"eslint-plugin-simple-import-sort": "^8.0.0",
|
|
68
68
|
"eslint-plugin-react": "^7.31.11",
|
|
69
69
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
70
|
-
"eslint-plugin-simple-import-sort": "^8.0.0",
|
|
71
70
|
"husky": "^8.0.2",
|
|
72
71
|
"jest": "^29.3.1",
|
|
73
72
|
"jest-environment-jsdom": "^29.3.1",
|
|
@@ -79,4 +78,4 @@
|
|
|
79
78
|
"rimraf": "^3.0.2",
|
|
80
79
|
"typescript": "^4.0.5"
|
|
81
80
|
}
|
|
82
|
-
}
|
|
81
|
+
}
|