@manuscripts/transform 2.1.1-LEAN-3336-13 → 2.1.1-LEAN-3336-16
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.
|
@@ -15,129 +15,90 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.tableHeader = exports.tableCell = exports.tableRow = exports.table = exports.tableNodes =
|
|
18
|
+
exports.tableHeader = exports.tableCell = exports.tableRow = exports.table = exports.tableNodes = void 0;
|
|
19
|
+
const prosemirror_tables_1 = require("prosemirror-tables");
|
|
19
20
|
const table_cell_styles_1 = require("../../lib/table-cell-styles");
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
const modifyTableCellSchema = (tableCell) => {
|
|
22
|
+
const modifiedTableCell = Object.assign({}, tableCell);
|
|
23
|
+
const originalToDOM = tableCell.toDOM;
|
|
24
|
+
if (!originalToDOM) {
|
|
25
|
+
throw new Error(`toDOM not found inside ${tableCell}, check for table schema changes in prosemirror-tables`);
|
|
23
26
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const colspan = Number(dom.getAttribute('colspan') || 1);
|
|
29
|
-
const result = {
|
|
30
|
-
colspan,
|
|
31
|
-
rowspan: Number(dom.getAttribute('rowspan') || 1),
|
|
32
|
-
colwidth: widths && widths.length == colspan ? widths : null,
|
|
33
|
-
};
|
|
34
|
-
for (const prop in extraAttrs) {
|
|
35
|
-
const getter = extraAttrs[prop].getFromDOM;
|
|
36
|
-
const value = getter && getter(dom);
|
|
37
|
-
if (value != null) {
|
|
38
|
-
result[prop] = value;
|
|
27
|
+
modifiedTableCell.toDOM = function (node) {
|
|
28
|
+
const originalArray = originalToDOM.call(this, node);
|
|
29
|
+
if (!Array.isArray(originalArray)) {
|
|
30
|
+
throw new Error(`${originalArray} is of type ${typeof originalArray}, check for table schema changes in prosemirror-tables`);
|
|
39
31
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const attrs = {};
|
|
45
|
-
if (node.attrs.colspan != 1) {
|
|
46
|
-
attrs.colspan = node.attrs.colspan;
|
|
47
|
-
}
|
|
48
|
-
if (node.attrs.rowspan != 1) {
|
|
49
|
-
attrs.rowspan = node.attrs.rowspan;
|
|
50
|
-
}
|
|
51
|
-
if (node.attrs.colwidth) {
|
|
52
|
-
attrs['data-colwidth'] = node.attrs.colwidth.join(',');
|
|
53
|
-
}
|
|
54
|
-
if (!node.textContent) {
|
|
55
|
-
attrs.class = 'placeholder';
|
|
56
|
-
}
|
|
57
|
-
for (const prop in extraAttrs) {
|
|
58
|
-
const setter = extraAttrs[prop].setDOMAttr;
|
|
59
|
-
if (setter) {
|
|
60
|
-
setter(node.attrs[prop], attrs);
|
|
32
|
+
const attrsIndex = originalArray.findIndex((item) => typeof item === 'object' && !Array.isArray(item));
|
|
33
|
+
const modifiedAttrs = Object.assign({}, originalArray[attrsIndex]);
|
|
34
|
+
if (!node.textContent) {
|
|
35
|
+
modifiedAttrs.class = 'placeholder';
|
|
61
36
|
}
|
|
37
|
+
originalArray[attrsIndex] = modifiedAttrs;
|
|
38
|
+
return originalArray;
|
|
39
|
+
};
|
|
40
|
+
return modifiedTableCell;
|
|
41
|
+
};
|
|
42
|
+
const modifyTableToDOM = (modifiedTable) => {
|
|
43
|
+
const originalToDOM = modifiedTable.toDOM;
|
|
44
|
+
if (!originalToDOM) {
|
|
45
|
+
throw new Error(`toDOM not found inside ${modifiedTable}, check for table schema changes in prosemirror-tables`);
|
|
62
46
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
47
|
+
modifiedTable.toDOM = function (node) {
|
|
48
|
+
const originalArray = originalToDOM.call(this, node);
|
|
49
|
+
if (!Array.isArray(originalArray)) {
|
|
50
|
+
throw new Error(`${originalArray} is of type ${typeof originalArray}, check for table schema changes in prosemirror-tables`);
|
|
51
|
+
}
|
|
52
|
+
const modifiedAttrs = {
|
|
53
|
+
id: node.attrs.id,
|
|
54
|
+
'data-header-rows': String(node.attrs.headerRows),
|
|
55
|
+
'data-footer-rows': String(node.attrs.footerRows),
|
|
56
|
+
};
|
|
57
|
+
if (Array.isArray(originalArray[1])) {
|
|
58
|
+
originalArray.splice(1, 0, modifiedAttrs);
|
|
59
|
+
}
|
|
60
|
+
else if (typeof originalArray[1] === 'object') {
|
|
61
|
+
originalArray[1] = Object.assign(Object.assign({}, originalArray[1]), modifiedAttrs);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
throw new Error(`toDOM[1] ${originalArray[1]} is of type ${typeof originalArray[1]}, check for table schema changes in prosemirror-tables`);
|
|
65
|
+
}
|
|
66
|
+
return originalArray;
|
|
71
67
|
};
|
|
72
|
-
|
|
73
|
-
|
|
68
|
+
};
|
|
69
|
+
const modifyTableParseDOM = (modifiedTable) => {
|
|
70
|
+
if (!modifiedTable.parseDOM || !modifiedTable.parseDOM[0]) {
|
|
71
|
+
throw new Error(`parseDOM not found inside ${modifiedTable}, check for table schema changes in prosemirror-tables`);
|
|
74
72
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
},
|
|
93
|
-
],
|
|
94
|
-
toDOM(node) {
|
|
95
|
-
return [
|
|
96
|
-
'table',
|
|
97
|
-
{
|
|
98
|
-
id: node.attrs.id,
|
|
99
|
-
'data-header-rows': String(node.attrs.headerRows),
|
|
100
|
-
'data-footer-rows': String(node.attrs.footerRows),
|
|
101
|
-
},
|
|
102
|
-
['tbody', 0],
|
|
103
|
-
];
|
|
104
|
-
},
|
|
105
|
-
},
|
|
106
|
-
table_row: {
|
|
107
|
-
content: '(table_cell | table_header)*',
|
|
108
|
-
tableRole: 'row',
|
|
109
|
-
parseDOM: [{ tag: 'tr' }],
|
|
110
|
-
toDOM() {
|
|
111
|
-
return ['tr', 0];
|
|
112
|
-
},
|
|
113
|
-
},
|
|
114
|
-
table_cell: {
|
|
115
|
-
content: options.cellContent,
|
|
116
|
-
attrs: cellAttrs,
|
|
117
|
-
tableRole: 'cell',
|
|
118
|
-
isolating: true,
|
|
119
|
-
parseDOM: [
|
|
120
|
-
{ tag: 'td', getAttrs: (dom) => getCellAttrs(dom, extraAttrs) },
|
|
121
|
-
],
|
|
122
|
-
toDOM(node) {
|
|
123
|
-
return ['td', setCellAttrs(node, extraAttrs), 0];
|
|
124
|
-
},
|
|
125
|
-
},
|
|
126
|
-
table_header: {
|
|
127
|
-
content: options.cellContent,
|
|
128
|
-
attrs: cellAttrs,
|
|
129
|
-
tableRole: 'header_cell',
|
|
130
|
-
isolating: true,
|
|
131
|
-
parseDOM: [
|
|
132
|
-
{ tag: 'th', getAttrs: (dom) => getCellAttrs(dom, extraAttrs) },
|
|
133
|
-
],
|
|
134
|
-
toDOM(node) {
|
|
135
|
-
return ['th', setCellAttrs(node, extraAttrs), 0];
|
|
136
|
-
},
|
|
137
|
-
},
|
|
73
|
+
const originalGetAttrs = modifiedTable.parseDOM[0].getAttrs;
|
|
74
|
+
let originalAttrs;
|
|
75
|
+
modifiedTable.parseDOM[0].getAttrs = function (p) {
|
|
76
|
+
const dom = p;
|
|
77
|
+
if (originalGetAttrs) {
|
|
78
|
+
originalAttrs = originalGetAttrs.call(this, p);
|
|
79
|
+
}
|
|
80
|
+
if (originalAttrs && typeof originalAttrs === 'object') {
|
|
81
|
+
return Object.assign(Object.assign({}, originalAttrs), { id: dom.getAttribute('id'), headerRows: dom.dataset && dom.dataset['header-rows'], footerRows: dom.dataset && dom.dataset['footer-rows'] });
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
return {
|
|
85
|
+
id: dom.getAttribute('id'),
|
|
86
|
+
headerRows: dom.dataset && dom.dataset['header-rows'],
|
|
87
|
+
footerRows: dom.dataset && dom.dataset['footer-rows'],
|
|
88
|
+
};
|
|
89
|
+
}
|
|
138
90
|
};
|
|
139
|
-
}
|
|
140
|
-
|
|
91
|
+
};
|
|
92
|
+
const modifyTableAttrs = (modifiedTable, table) => {
|
|
93
|
+
modifiedTable.attrs = Object.assign(Object.assign({}, table.attrs), { id: { default: '' }, dataTracked: { default: null }, comments: { default: null }, headerRows: { default: 1 }, footerRows: { default: 1 } });
|
|
94
|
+
};
|
|
95
|
+
const modifyTableSchema = (table) => {
|
|
96
|
+
const modifiedTable = Object.assign({}, table);
|
|
97
|
+
modifyTableAttrs(modifiedTable, table);
|
|
98
|
+
modifyTableToDOM(modifiedTable);
|
|
99
|
+
modifyTableParseDOM(modifiedTable);
|
|
100
|
+
return modifiedTable;
|
|
101
|
+
};
|
|
141
102
|
const tableOptions = {
|
|
142
103
|
tableGroup: 'block',
|
|
143
104
|
cellContent: 'inline*',
|
|
@@ -165,14 +126,6 @@ const tableOptions = {
|
|
|
165
126
|
}
|
|
166
127
|
},
|
|
167
128
|
},
|
|
168
|
-
class: {
|
|
169
|
-
default: null,
|
|
170
|
-
setDOMAttr(value, attrs) {
|
|
171
|
-
if (value) {
|
|
172
|
-
attrs['class'] = value;
|
|
173
|
-
}
|
|
174
|
-
},
|
|
175
|
-
},
|
|
176
129
|
valign: {
|
|
177
130
|
default: null,
|
|
178
131
|
getFromDOM(dom) {
|
|
@@ -219,8 +172,8 @@ const tableOptions = {
|
|
|
219
172
|
},
|
|
220
173
|
},
|
|
221
174
|
};
|
|
222
|
-
exports.tableNodes =
|
|
223
|
-
exports.table =
|
|
175
|
+
exports.tableNodes = (0, prosemirror_tables_1.tableNodes)(tableOptions);
|
|
176
|
+
exports.table = modifyTableSchema(exports.tableNodes.table);
|
|
224
177
|
exports.tableRow = exports.tableNodes.table_row;
|
|
225
|
-
exports.tableCell = exports.tableNodes.table_cell;
|
|
226
|
-
exports.tableHeader = exports.tableNodes.table_header;
|
|
178
|
+
exports.tableCell = modifyTableCellSchema(exports.tableNodes.table_cell);
|
|
179
|
+
exports.tableHeader = modifyTableCellSchema(exports.tableNodes.table_header);
|
|
@@ -574,12 +574,14 @@ class Decoder {
|
|
|
574
574
|
const figcaption = this.getFigcaption(model);
|
|
575
575
|
const comments = this.createCommentNodes(model);
|
|
576
576
|
comments.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
577
|
-
const content =
|
|
578
|
-
? [table, tableElementFooter, figcaption]
|
|
579
|
-
: [table, figcaption];
|
|
577
|
+
const content = [table];
|
|
580
578
|
if (tableColGroup) {
|
|
581
579
|
content.unshift(tableColGroup);
|
|
582
580
|
}
|
|
581
|
+
if (tableElementFooter) {
|
|
582
|
+
content.push(tableElementFooter);
|
|
583
|
+
}
|
|
584
|
+
content.push(figcaption);
|
|
583
585
|
if (model.listingID) {
|
|
584
586
|
const listing = this.createListing(model.listingID);
|
|
585
587
|
content.push(listing);
|
|
@@ -13,127 +13,89 @@
|
|
|
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';
|
|
16
17
|
import { getTableCellStyles, serializeTableCellStyles, } from '../../lib/table-cell-styles';
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
const modifyTableCellSchema = (tableCell) => {
|
|
19
|
+
const modifiedTableCell = Object.assign({}, tableCell);
|
|
20
|
+
const originalToDOM = tableCell.toDOM;
|
|
21
|
+
if (!originalToDOM) {
|
|
22
|
+
throw new Error(`toDOM not found inside ${tableCell}, check for table schema changes in prosemirror-tables`);
|
|
20
23
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const colspan = Number(dom.getAttribute('colspan') || 1);
|
|
26
|
-
const result = {
|
|
27
|
-
colspan,
|
|
28
|
-
rowspan: Number(dom.getAttribute('rowspan') || 1),
|
|
29
|
-
colwidth: widths && widths.length == colspan ? widths : null,
|
|
30
|
-
};
|
|
31
|
-
for (const prop in extraAttrs) {
|
|
32
|
-
const getter = extraAttrs[prop].getFromDOM;
|
|
33
|
-
const value = getter && getter(dom);
|
|
34
|
-
if (value != null) {
|
|
35
|
-
result[prop] = value;
|
|
24
|
+
modifiedTableCell.toDOM = function (node) {
|
|
25
|
+
const originalArray = originalToDOM.call(this, node);
|
|
26
|
+
if (!Array.isArray(originalArray)) {
|
|
27
|
+
throw new Error(`${originalArray} is of type ${typeof originalArray}, check for table schema changes in prosemirror-tables`);
|
|
36
28
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const attrs = {};
|
|
42
|
-
if (node.attrs.colspan != 1) {
|
|
43
|
-
attrs.colspan = node.attrs.colspan;
|
|
44
|
-
}
|
|
45
|
-
if (node.attrs.rowspan != 1) {
|
|
46
|
-
attrs.rowspan = node.attrs.rowspan;
|
|
47
|
-
}
|
|
48
|
-
if (node.attrs.colwidth) {
|
|
49
|
-
attrs['data-colwidth'] = node.attrs.colwidth.join(',');
|
|
50
|
-
}
|
|
51
|
-
if (!node.textContent) {
|
|
52
|
-
attrs.class = 'placeholder';
|
|
53
|
-
}
|
|
54
|
-
for (const prop in extraAttrs) {
|
|
55
|
-
const setter = extraAttrs[prop].setDOMAttr;
|
|
56
|
-
if (setter) {
|
|
57
|
-
setter(node.attrs[prop], attrs);
|
|
29
|
+
const attrsIndex = originalArray.findIndex((item) => typeof item === 'object' && !Array.isArray(item));
|
|
30
|
+
const modifiedAttrs = Object.assign({}, originalArray[attrsIndex]);
|
|
31
|
+
if (!node.textContent) {
|
|
32
|
+
modifiedAttrs.class = 'placeholder';
|
|
58
33
|
}
|
|
34
|
+
originalArray[attrsIndex] = modifiedAttrs;
|
|
35
|
+
return originalArray;
|
|
36
|
+
};
|
|
37
|
+
return modifiedTableCell;
|
|
38
|
+
};
|
|
39
|
+
const modifyTableToDOM = (modifiedTable) => {
|
|
40
|
+
const originalToDOM = modifiedTable.toDOM;
|
|
41
|
+
if (!originalToDOM) {
|
|
42
|
+
throw new Error(`toDOM not found inside ${modifiedTable}, check for table schema changes in prosemirror-tables`);
|
|
59
43
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
44
|
+
modifiedTable.toDOM = function (node) {
|
|
45
|
+
const originalArray = originalToDOM.call(this, node);
|
|
46
|
+
if (!Array.isArray(originalArray)) {
|
|
47
|
+
throw new Error(`${originalArray} is of type ${typeof originalArray}, check for table schema changes in prosemirror-tables`);
|
|
48
|
+
}
|
|
49
|
+
const modifiedAttrs = {
|
|
50
|
+
id: node.attrs.id,
|
|
51
|
+
'data-header-rows': String(node.attrs.headerRows),
|
|
52
|
+
'data-footer-rows': String(node.attrs.footerRows),
|
|
53
|
+
};
|
|
54
|
+
if (Array.isArray(originalArray[1])) {
|
|
55
|
+
originalArray.splice(1, 0, modifiedAttrs);
|
|
56
|
+
}
|
|
57
|
+
else if (typeof originalArray[1] === 'object') {
|
|
58
|
+
originalArray[1] = Object.assign(Object.assign({}, originalArray[1]), modifiedAttrs);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
throw new Error(`toDOM[1] ${originalArray[1]} is of type ${typeof originalArray[1]}, check for table schema changes in prosemirror-tables`);
|
|
62
|
+
}
|
|
63
|
+
return originalArray;
|
|
68
64
|
};
|
|
69
|
-
|
|
70
|
-
|
|
65
|
+
};
|
|
66
|
+
const modifyTableParseDOM = (modifiedTable) => {
|
|
67
|
+
if (!modifiedTable.parseDOM || !modifiedTable.parseDOM[0]) {
|
|
68
|
+
throw new Error(`parseDOM not found inside ${modifiedTable}, check for table schema changes in prosemirror-tables`);
|
|
71
69
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
},
|
|
90
|
-
],
|
|
91
|
-
toDOM(node) {
|
|
92
|
-
return [
|
|
93
|
-
'table',
|
|
94
|
-
{
|
|
95
|
-
id: node.attrs.id,
|
|
96
|
-
'data-header-rows': String(node.attrs.headerRows),
|
|
97
|
-
'data-footer-rows': String(node.attrs.footerRows),
|
|
98
|
-
},
|
|
99
|
-
['tbody', 0],
|
|
100
|
-
];
|
|
101
|
-
},
|
|
102
|
-
},
|
|
103
|
-
table_row: {
|
|
104
|
-
content: '(table_cell | table_header)*',
|
|
105
|
-
tableRole: 'row',
|
|
106
|
-
parseDOM: [{ tag: 'tr' }],
|
|
107
|
-
toDOM() {
|
|
108
|
-
return ['tr', 0];
|
|
109
|
-
},
|
|
110
|
-
},
|
|
111
|
-
table_cell: {
|
|
112
|
-
content: options.cellContent,
|
|
113
|
-
attrs: cellAttrs,
|
|
114
|
-
tableRole: 'cell',
|
|
115
|
-
isolating: true,
|
|
116
|
-
parseDOM: [
|
|
117
|
-
{ tag: 'td', getAttrs: (dom) => getCellAttrs(dom, extraAttrs) },
|
|
118
|
-
],
|
|
119
|
-
toDOM(node) {
|
|
120
|
-
return ['td', setCellAttrs(node, extraAttrs), 0];
|
|
121
|
-
},
|
|
122
|
-
},
|
|
123
|
-
table_header: {
|
|
124
|
-
content: options.cellContent,
|
|
125
|
-
attrs: cellAttrs,
|
|
126
|
-
tableRole: 'header_cell',
|
|
127
|
-
isolating: true,
|
|
128
|
-
parseDOM: [
|
|
129
|
-
{ tag: 'th', getAttrs: (dom) => getCellAttrs(dom, extraAttrs) },
|
|
130
|
-
],
|
|
131
|
-
toDOM(node) {
|
|
132
|
-
return ['th', setCellAttrs(node, extraAttrs), 0];
|
|
133
|
-
},
|
|
134
|
-
},
|
|
70
|
+
const originalGetAttrs = modifiedTable.parseDOM[0].getAttrs;
|
|
71
|
+
let originalAttrs;
|
|
72
|
+
modifiedTable.parseDOM[0].getAttrs = function (p) {
|
|
73
|
+
const dom = p;
|
|
74
|
+
if (originalGetAttrs) {
|
|
75
|
+
originalAttrs = originalGetAttrs.call(this, p);
|
|
76
|
+
}
|
|
77
|
+
if (originalAttrs && typeof originalAttrs === 'object') {
|
|
78
|
+
return Object.assign(Object.assign({}, originalAttrs), { id: dom.getAttribute('id'), headerRows: dom.dataset && dom.dataset['header-rows'], footerRows: dom.dataset && dom.dataset['footer-rows'] });
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
return {
|
|
82
|
+
id: dom.getAttribute('id'),
|
|
83
|
+
headerRows: dom.dataset && dom.dataset['header-rows'],
|
|
84
|
+
footerRows: dom.dataset && dom.dataset['footer-rows'],
|
|
85
|
+
};
|
|
86
|
+
}
|
|
135
87
|
};
|
|
136
|
-
}
|
|
88
|
+
};
|
|
89
|
+
const modifyTableAttrs = (modifiedTable, table) => {
|
|
90
|
+
modifiedTable.attrs = Object.assign(Object.assign({}, table.attrs), { id: { default: '' }, dataTracked: { default: null }, comments: { default: null }, headerRows: { default: 1 }, footerRows: { default: 1 } });
|
|
91
|
+
};
|
|
92
|
+
const modifyTableSchema = (table) => {
|
|
93
|
+
const modifiedTable = Object.assign({}, table);
|
|
94
|
+
modifyTableAttrs(modifiedTable, table);
|
|
95
|
+
modifyTableToDOM(modifiedTable);
|
|
96
|
+
modifyTableParseDOM(modifiedTable);
|
|
97
|
+
return modifiedTable;
|
|
98
|
+
};
|
|
137
99
|
const tableOptions = {
|
|
138
100
|
tableGroup: 'block',
|
|
139
101
|
cellContent: 'inline*',
|
|
@@ -161,14 +123,6 @@ const tableOptions = {
|
|
|
161
123
|
}
|
|
162
124
|
},
|
|
163
125
|
},
|
|
164
|
-
class: {
|
|
165
|
-
default: null,
|
|
166
|
-
setDOMAttr(value, attrs) {
|
|
167
|
-
if (value) {
|
|
168
|
-
attrs['class'] = value;
|
|
169
|
-
}
|
|
170
|
-
},
|
|
171
|
-
},
|
|
172
126
|
valign: {
|
|
173
127
|
default: null,
|
|
174
128
|
getFromDOM(dom) {
|
|
@@ -216,7 +170,7 @@ const tableOptions = {
|
|
|
216
170
|
},
|
|
217
171
|
};
|
|
218
172
|
export const tableNodes = createTableNodes(tableOptions);
|
|
219
|
-
export const table =
|
|
173
|
+
export const table = modifyTableSchema(tableNodes.table);
|
|
220
174
|
export const tableRow = tableNodes.table_row;
|
|
221
|
-
export const tableCell = tableNodes.table_cell;
|
|
222
|
-
export const tableHeader = tableNodes.table_header;
|
|
175
|
+
export const tableCell = modifyTableCellSchema(tableNodes.table_cell);
|
|
176
|
+
export const tableHeader = modifyTableCellSchema(tableNodes.table_header);
|
|
@@ -565,12 +565,14 @@ export class Decoder {
|
|
|
565
565
|
const figcaption = this.getFigcaption(model);
|
|
566
566
|
const comments = this.createCommentNodes(model);
|
|
567
567
|
comments.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
568
|
-
const content =
|
|
569
|
-
? [table, tableElementFooter, figcaption]
|
|
570
|
-
: [table, figcaption];
|
|
568
|
+
const content = [table];
|
|
571
569
|
if (tableColGroup) {
|
|
572
570
|
content.unshift(tableColGroup);
|
|
573
571
|
}
|
|
572
|
+
if (tableElementFooter) {
|
|
573
|
+
content.push(tableElementFooter);
|
|
574
|
+
}
|
|
575
|
+
content.push(figcaption);
|
|
574
576
|
if (model.listingID) {
|
|
575
577
|
const listing = this.createListing(model.listingID);
|
|
576
578
|
content.push(listing);
|
|
@@ -13,33 +13,66 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { Node } from 'prosemirror-model';
|
|
17
|
-
import { TableNodes
|
|
18
|
-
export declare function createTableNodes(options: TableNodesOptions): TableNodes;
|
|
16
|
+
import { Node, NodeSpec } from 'prosemirror-model';
|
|
17
|
+
import { TableNodes } from 'prosemirror-tables';
|
|
19
18
|
export declare const tableNodes: TableNodes;
|
|
20
19
|
export declare const table: {
|
|
21
|
-
|
|
22
|
-
id: {
|
|
23
|
-
default: string;
|
|
24
|
-
};
|
|
25
|
-
dataTracked: {
|
|
26
|
-
default: null;
|
|
27
|
-
};
|
|
28
|
-
comments: {
|
|
29
|
-
default: null;
|
|
30
|
-
};
|
|
31
|
-
headerRows: {
|
|
32
|
-
default: number;
|
|
33
|
-
};
|
|
34
|
-
footerRows: {
|
|
35
|
-
default: number;
|
|
36
|
-
};
|
|
37
|
-
};
|
|
20
|
+
[x: string]: any;
|
|
38
21
|
content?: string | undefined;
|
|
39
22
|
marks?: string | undefined;
|
|
40
23
|
group?: string | undefined;
|
|
41
24
|
inline?: boolean | undefined;
|
|
42
25
|
atom?: boolean | undefined;
|
|
26
|
+
attrs?: {
|
|
27
|
+
[name: string]: import("prosemirror-model").AttributeSpec;
|
|
28
|
+
} | 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: Node) => import("prosemirror-model").DOMOutputSpec) | undefined;
|
|
38
|
+
parseDOM?: readonly import("prosemirror-model").ParseRule[] | undefined;
|
|
39
|
+
toDebugString?: ((node: Node) => string) | undefined;
|
|
40
|
+
leafText?: ((node: Node) => string) | undefined;
|
|
41
|
+
};
|
|
42
|
+
export declare const tableRow: NodeSpec;
|
|
43
|
+
export declare const tableCell: {
|
|
44
|
+
[x: string]: any;
|
|
45
|
+
content?: string | undefined;
|
|
46
|
+
marks?: string | undefined;
|
|
47
|
+
group?: string | undefined;
|
|
48
|
+
inline?: boolean | undefined;
|
|
49
|
+
atom?: boolean | undefined;
|
|
50
|
+
attrs?: {
|
|
51
|
+
[name: string]: import("prosemirror-model").AttributeSpec;
|
|
52
|
+
} | 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: Node) => import("prosemirror-model").DOMOutputSpec) | undefined;
|
|
62
|
+
parseDOM?: readonly import("prosemirror-model").ParseRule[] | undefined;
|
|
63
|
+
toDebugString?: ((node: Node) => string) | undefined;
|
|
64
|
+
leafText?: ((node: Node) => string) | undefined;
|
|
65
|
+
};
|
|
66
|
+
export declare const tableHeader: {
|
|
67
|
+
[x: string]: any;
|
|
68
|
+
content?: string | undefined;
|
|
69
|
+
marks?: string | undefined;
|
|
70
|
+
group?: string | undefined;
|
|
71
|
+
inline?: boolean | undefined;
|
|
72
|
+
atom?: boolean | undefined;
|
|
73
|
+
attrs?: {
|
|
74
|
+
[name: string]: import("prosemirror-model").AttributeSpec;
|
|
75
|
+
} | undefined;
|
|
43
76
|
selectable?: boolean | undefined;
|
|
44
77
|
draggable?: boolean | undefined;
|
|
45
78
|
code?: boolean | undefined;
|
|
@@ -53,6 +86,3 @@ export declare const table: {
|
|
|
53
86
|
toDebugString?: ((node: Node) => string) | undefined;
|
|
54
87
|
leafText?: ((node: Node) => string) | undefined;
|
|
55
88
|
};
|
|
56
|
-
export declare const tableRow: import("prosemirror-model").NodeSpec;
|
|
57
|
-
export declare const tableCell: import("prosemirror-model").NodeSpec;
|
|
58
|
-
export declare const tableHeader: import("prosemirror-model").NodeSpec;
|
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-16",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-transform",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|