@manuscripts/transform 2.1.1-LEAN-3336-4 → 2.1.1-LEAN-3336-6
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 +0 -4
- package/dist/cjs/jats/importer/jats-body-transformations.js +0 -9
- package/dist/cjs/schema/index.js +3 -5
- package/dist/cjs/schema/nodes/table.js +17 -38
- package/dist/cjs/schema/nodes/table_row.js +1 -106
- package/dist/cjs/transformer/decode.js +1 -4
- package/dist/es/jats/importer/jats-body-dom-parser.js +0 -4
- package/dist/es/jats/importer/jats-body-transformations.js +0 -9
- package/dist/es/schema/index.js +1 -3
- package/dist/es/schema/nodes/table.js +16 -37
- package/dist/es/schema/nodes/table_row.js +2 -104
- package/dist/es/transformer/decode.js +1 -4
- package/dist/types/schema/index.d.ts +0 -1
- package/dist/types/schema/nodes/table.d.ts +27 -9
- package/dist/types/schema/nodes/table_row.d.ts +1 -28
- package/package.json +4 -3
|
@@ -241,15 +241,6 @@ exports.jatsBodyTransformations = {
|
|
|
241
241
|
fixTables(body, createElement) {
|
|
242
242
|
const tables = body.querySelectorAll('table-wrap > table');
|
|
243
243
|
tables.forEach((table) => {
|
|
244
|
-
const colgroup = table.querySelector('colgroup');
|
|
245
|
-
const cols = table.querySelectorAll('col');
|
|
246
|
-
if (!colgroup && table.firstChild && cols.length > 0) {
|
|
247
|
-
const colgroup = createElement('colgroup');
|
|
248
|
-
for (const col of cols) {
|
|
249
|
-
colgroup.appendChild(col);
|
|
250
|
-
}
|
|
251
|
-
table.insertBefore(colgroup, table.firstChild);
|
|
252
|
-
}
|
|
253
244
|
const tbody = table.querySelector('tbody');
|
|
254
245
|
if (tbody) {
|
|
255
246
|
const headerRow = table.querySelector('thead > tr');
|
package/dist/cjs/schema/index.js
CHANGED
|
@@ -87,7 +87,6 @@ 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");
|
|
91
90
|
const text_1 = require("./nodes/text");
|
|
92
91
|
const title_1 = require("./nodes/title");
|
|
93
92
|
const toc_element_1 = require("./nodes/toc_element");
|
|
@@ -137,7 +136,6 @@ __exportStar(require("./nodes/section_title"), exports);
|
|
|
137
136
|
__exportStar(require("./nodes/table"), exports);
|
|
138
137
|
__exportStar(require("./nodes/table_col"), exports);
|
|
139
138
|
__exportStar(require("./nodes/table_element"), exports);
|
|
140
|
-
__exportStar(require("./nodes/table_row"), exports);
|
|
141
139
|
__exportStar(require("./nodes/text"), exports);
|
|
142
140
|
__exportStar(require("./nodes/toc_element"), exports);
|
|
143
141
|
__exportStar(require("./nodes/toc_section"), exports);
|
|
@@ -213,9 +211,9 @@ exports.schema = new prosemirror_model_1.Schema({
|
|
|
213
211
|
section_title: section_title_1.sectionTitle,
|
|
214
212
|
section_title_plain: section_title_1.sectionTitle,
|
|
215
213
|
table: table_1.table,
|
|
216
|
-
table_cell:
|
|
214
|
+
table_cell: table_1.tableCell,
|
|
217
215
|
table_element: table_element_1.tableElement,
|
|
218
|
-
table_row:
|
|
216
|
+
table_row: table_1.tableRow,
|
|
219
217
|
table_col: table_col_1.tableCol,
|
|
220
218
|
table_colgroup: table_col_1.tableColGroup,
|
|
221
219
|
text: text_1.text,
|
|
@@ -229,6 +227,6 @@ exports.schema = new prosemirror_model_1.Schema({
|
|
|
229
227
|
contributors: contributors_1.contributors,
|
|
230
228
|
supplements: supplements_1.supplements,
|
|
231
229
|
supplement: supplement_1.supplement,
|
|
232
|
-
table_header:
|
|
230
|
+
table_header: table_1.tableHeader,
|
|
233
231
|
},
|
|
234
232
|
});
|
|
@@ -15,43 +15,22 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.table = void 0;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
comments: { default: null },
|
|
31
|
-
},
|
|
32
|
-
parseDOM: [
|
|
33
|
-
{
|
|
34
|
-
tag: 'table',
|
|
35
|
-
getAttrs: (p) => {
|
|
36
|
-
const dom = p;
|
|
37
|
-
return {
|
|
38
|
-
id: dom.getAttribute('id'),
|
|
39
|
-
headerRows: dom.dataset && dom.dataset['header-rows'],
|
|
40
|
-
footerRows: dom.dataset && dom.dataset['footer-rows'],
|
|
41
|
-
};
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
],
|
|
45
|
-
toDOM: (node) => {
|
|
46
|
-
const tableNode = node;
|
|
47
|
-
return [
|
|
48
|
-
'table',
|
|
49
|
-
{
|
|
50
|
-
id: tableNode.attrs.id,
|
|
51
|
-
'data-header-rows': String(node.attrs.headerRows),
|
|
52
|
-
'data-footer-rows': String(node.attrs.footerRows),
|
|
53
|
-
},
|
|
54
|
-
0,
|
|
55
|
-
];
|
|
18
|
+
exports.tableHeader = exports.tableCell = exports.tableRow = exports.table = exports.tnodes = void 0;
|
|
19
|
+
const prosemirror_tables_1 = require("prosemirror-tables");
|
|
20
|
+
const tableOptions = {
|
|
21
|
+
tableGroup: 'block',
|
|
22
|
+
cellContent: 'inline*',
|
|
23
|
+
cellAttributes: {
|
|
24
|
+
placeholder: { default: 'Data' },
|
|
25
|
+
styles: { default: {} },
|
|
26
|
+
valign: { default: null },
|
|
27
|
+
align: { default: null },
|
|
28
|
+
scope: { default: null },
|
|
29
|
+
style: { default: null },
|
|
56
30
|
},
|
|
57
31
|
};
|
|
32
|
+
exports.tnodes = (0, prosemirror_tables_1.tableNodes)(tableOptions);
|
|
33
|
+
exports.table = Object.assign(Object.assign({}, exports.tnodes.table), { attrs: Object.assign(Object.assign({}, exports.tnodes.table.attrs), { id: { default: '' } }) });
|
|
34
|
+
exports.tableRow = exports.tnodes.table_row;
|
|
35
|
+
exports.tableCell = exports.tnodes.table_cell;
|
|
36
|
+
exports.tableHeader = exports.tnodes.table_header;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*!
|
|
3
|
-
* ©
|
|
3
|
+
* © 2024 Atypon Systems LLC
|
|
4
4
|
*
|
|
5
5
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
6
|
* you may not use this file except in compliance with the License.
|
|
@@ -14,108 +14,3 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.tableHeader = 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 | table_header)*',
|
|
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: [{ tag: 'td', getAttrs: getCellAttrs }],
|
|
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 = (0, table_cell_styles_1.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
|
-
};
|
|
121
|
-
exports.tableHeader = Object.assign(Object.assign({}, exports.tableCell), { tableRole: 'header_cell', parseDOM: [{ tag: 'th', getAttrs: getCellAttrs }] });
|
|
@@ -557,12 +557,9 @@ class Decoder {
|
|
|
557
557
|
},
|
|
558
558
|
[json_schema_1.ObjectTypes.Table]: (data) => {
|
|
559
559
|
const model = data;
|
|
560
|
-
|
|
561
|
-
comments.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
562
|
-
return this.parseContents(model.contents, undefined, this.getComments(model), {
|
|
560
|
+
return this.parseContents(model.contents, undefined, [], {
|
|
563
561
|
topNode: schema_1.schema.nodes.table.create({
|
|
564
562
|
id: model._id,
|
|
565
|
-
comments: comments.map((c) => c.attrs.id),
|
|
566
563
|
}),
|
|
567
564
|
});
|
|
568
565
|
},
|
|
@@ -238,15 +238,6 @@ export const jatsBodyTransformations = {
|
|
|
238
238
|
fixTables(body, createElement) {
|
|
239
239
|
const tables = body.querySelectorAll('table-wrap > table');
|
|
240
240
|
tables.forEach((table) => {
|
|
241
|
-
const colgroup = table.querySelector('colgroup');
|
|
242
|
-
const cols = table.querySelectorAll('col');
|
|
243
|
-
if (!colgroup && table.firstChild && cols.length > 0) {
|
|
244
|
-
const colgroup = createElement('colgroup');
|
|
245
|
-
for (const col of cols) {
|
|
246
|
-
colgroup.appendChild(col);
|
|
247
|
-
}
|
|
248
|
-
table.insertBefore(colgroup, table.firstChild);
|
|
249
|
-
}
|
|
250
241
|
const tbody = table.querySelector('tbody');
|
|
251
242
|
if (tbody) {
|
|
252
243
|
const headerRow = table.querySelector('thead > tr');
|
package/dist/es/schema/index.js
CHANGED
|
@@ -66,11 +66,10 @@ 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 } from './nodes/table';
|
|
69
|
+
import { table, tableCell, tableHeader, tableRow } 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, tableHeader, tableRow } from './nodes/table_row';
|
|
74
73
|
import { text } from './nodes/text';
|
|
75
74
|
import { title } from './nodes/title';
|
|
76
75
|
import { tocElement } from './nodes/toc_element';
|
|
@@ -120,7 +119,6 @@ export * from './nodes/section_title';
|
|
|
120
119
|
export * from './nodes/table';
|
|
121
120
|
export * from './nodes/table_col';
|
|
122
121
|
export * from './nodes/table_element';
|
|
123
|
-
export * from './nodes/table_row';
|
|
124
122
|
export * from './nodes/text';
|
|
125
123
|
export * from './nodes/toc_element';
|
|
126
124
|
export * from './nodes/toc_section';
|
|
@@ -13,42 +13,21 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
comments: { default: null },
|
|
28
|
-
},
|
|
29
|
-
parseDOM: [
|
|
30
|
-
{
|
|
31
|
-
tag: 'table',
|
|
32
|
-
getAttrs: (p) => {
|
|
33
|
-
const dom = p;
|
|
34
|
-
return {
|
|
35
|
-
id: dom.getAttribute('id'),
|
|
36
|
-
headerRows: dom.dataset && dom.dataset['header-rows'],
|
|
37
|
-
footerRows: dom.dataset && dom.dataset['footer-rows'],
|
|
38
|
-
};
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
],
|
|
42
|
-
toDOM: (node) => {
|
|
43
|
-
const tableNode = node;
|
|
44
|
-
return [
|
|
45
|
-
'table',
|
|
46
|
-
{
|
|
47
|
-
id: tableNode.attrs.id,
|
|
48
|
-
'data-header-rows': String(node.attrs.headerRows),
|
|
49
|
-
'data-footer-rows': String(node.attrs.footerRows),
|
|
50
|
-
},
|
|
51
|
-
0,
|
|
52
|
-
];
|
|
16
|
+
import { tableNodes } from 'prosemirror-tables';
|
|
17
|
+
const tableOptions = {
|
|
18
|
+
tableGroup: 'block',
|
|
19
|
+
cellContent: 'inline*',
|
|
20
|
+
cellAttributes: {
|
|
21
|
+
placeholder: { default: 'Data' },
|
|
22
|
+
styles: { default: {} },
|
|
23
|
+
valign: { default: null },
|
|
24
|
+
align: { default: null },
|
|
25
|
+
scope: { default: null },
|
|
26
|
+
style: { default: null },
|
|
53
27
|
},
|
|
54
28
|
};
|
|
29
|
+
export const tnodes = tableNodes(tableOptions);
|
|
30
|
+
export const table = Object.assign(Object.assign({}, tnodes.table), { attrs: Object.assign(Object.assign({}, tnodes.table.attrs), { id: { default: '' } }) });
|
|
31
|
+
export const tableRow = tnodes.table_row;
|
|
32
|
+
export const tableCell = tnodes.table_cell;
|
|
33
|
+
export const tableHeader = tnodes.table_header;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/*!
|
|
2
|
-
* ©
|
|
3
|
+
* © 2024 Atypon Systems LLC
|
|
3
4
|
*
|
|
4
5
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
6
|
* you may not use this file except in compliance with the License.
|
|
@@ -13,106 +14,3 @@
|
|
|
13
14
|
* See the License for the specific language governing permissions and
|
|
14
15
|
* limitations under the License.
|
|
15
16
|
*/
|
|
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 | table_header)*',
|
|
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: [{ tag: 'td', getAttrs: getCellAttrs }],
|
|
80
|
-
toDOM: (node) => {
|
|
81
|
-
const tableCellNode = node;
|
|
82
|
-
const attrs = {};
|
|
83
|
-
const tag = tableCellNode.attrs.celltype;
|
|
84
|
-
if (tableCellNode.attrs.colspan && tableCellNode.attrs.colspan !== 1) {
|
|
85
|
-
attrs.colspan = String(tableCellNode.attrs.colspan);
|
|
86
|
-
}
|
|
87
|
-
if (tableCellNode.attrs.rowspan && tableCellNode.attrs.rowspan !== 1) {
|
|
88
|
-
attrs.rowspan = String(tableCellNode.attrs.rowspan);
|
|
89
|
-
}
|
|
90
|
-
if (tableCellNode.attrs.colwidth) {
|
|
91
|
-
attrs['data-colwidth'] = tableCellNode.attrs.colwidth.join(',');
|
|
92
|
-
}
|
|
93
|
-
if (tableCellNode.attrs.placeholder) {
|
|
94
|
-
attrs['data-placeholder-text'] = tableCellNode.attrs.placeholder;
|
|
95
|
-
}
|
|
96
|
-
if (!tableCellNode.textContent) {
|
|
97
|
-
attrs.class = 'placeholder';
|
|
98
|
-
}
|
|
99
|
-
const styleString = serializeTableCellStyles(tableCellNode.attrs.styles);
|
|
100
|
-
if (styleString) {
|
|
101
|
-
attrs.style = styleString;
|
|
102
|
-
}
|
|
103
|
-
if (tableCellNode.attrs.valign) {
|
|
104
|
-
attrs.valign = tableCellNode.attrs.valign;
|
|
105
|
-
}
|
|
106
|
-
if (tableCellNode.attrs.align) {
|
|
107
|
-
attrs.align = tableCellNode.attrs.align;
|
|
108
|
-
}
|
|
109
|
-
if (tableCellNode.attrs.scope) {
|
|
110
|
-
attrs.scope = tableCellNode.attrs.scope;
|
|
111
|
-
}
|
|
112
|
-
if (tableCellNode.attrs.style) {
|
|
113
|
-
attrs.style = tableCellNode.attrs.style;
|
|
114
|
-
}
|
|
115
|
-
return [tag, attrs, 0];
|
|
116
|
-
},
|
|
117
|
-
};
|
|
118
|
-
export const tableHeader = Object.assign(Object.assign({}, tableCell), { tableRole: 'header_cell', parseDOM: [{ tag: 'th', getAttrs: getCellAttrs }] });
|
|
@@ -548,12 +548,9 @@ export class Decoder {
|
|
|
548
548
|
},
|
|
549
549
|
[ObjectTypes.Table]: (data) => {
|
|
550
550
|
const model = data;
|
|
551
|
-
|
|
552
|
-
comments.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
553
|
-
return this.parseContents(model.contents, undefined, this.getComments(model), {
|
|
551
|
+
return this.parseContents(model.contents, undefined, [], {
|
|
554
552
|
topNode: schema.nodes.table.create({
|
|
555
553
|
id: model._id,
|
|
556
|
-
comments: comments.map((c) => c.attrs.id),
|
|
557
554
|
}),
|
|
558
555
|
});
|
|
559
556
|
},
|
|
@@ -60,7 +60,6 @@ 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';
|
|
64
63
|
export * from './nodes/text';
|
|
65
64
|
export * from './nodes/toc_element';
|
|
66
65
|
export * from './nodes/toc_section';
|
|
@@ -13,14 +13,32 @@
|
|
|
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 { TableNodes } from 'prosemirror-tables';
|
|
17
|
+
export declare const tnodes: TableNodes;
|
|
18
|
+
export declare const table: {
|
|
19
19
|
attrs: {
|
|
20
|
-
id:
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
comments?: CommentNode[];
|
|
20
|
+
id: {
|
|
21
|
+
default: string;
|
|
22
|
+
};
|
|
24
23
|
};
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
content?: string | undefined;
|
|
25
|
+
marks?: string | undefined;
|
|
26
|
+
group?: string | undefined;
|
|
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 tableRow: import("prosemirror-model").NodeSpec;
|
|
43
|
+
export declare const tableCell: import("prosemirror-model").NodeSpec;
|
|
44
|
+
export declare const tableHeader: import("prosemirror-model").NodeSpec;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* ©
|
|
2
|
+
* © 2024 Atypon Systems LLC
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
* you may not use this file except in compliance with the License.
|
|
@@ -13,30 +13,3 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
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;
|
|
42
|
-
export declare const tableHeader: TableNodeSpec;
|
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-3336-
|
|
4
|
+
"version": "2.1.1-LEAN-3336-6",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-transform",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|
|
@@ -35,7 +35,8 @@
|
|
|
35
35
|
"jszip": "^3.10.1",
|
|
36
36
|
"mathjax-full": "^3.2.2",
|
|
37
37
|
"mime": "^3.0.0",
|
|
38
|
-
"prosemirror-model": "^1.
|
|
38
|
+
"prosemirror-model": "^1.8.1",
|
|
39
|
+
"prosemirror-tables": "^1.3.5",
|
|
39
40
|
"uuid": "^9.0.0",
|
|
40
41
|
"w3c-xmlserializer": "^4.0.0"
|
|
41
42
|
},
|
|
@@ -64,9 +65,9 @@
|
|
|
64
65
|
"eslint-plugin-mdx": "^2.0.5",
|
|
65
66
|
"eslint-plugin-prettier": "^4.2.1",
|
|
66
67
|
"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",
|
|
70
71
|
"husky": "^8.0.2",
|
|
71
72
|
"jest": "^29.3.1",
|
|
72
73
|
"jest-environment-jsdom": "^29.3.1",
|