@progress/kendo-angular-editor 2.5.0-dev.202111261548 → 3.0.0-dev.202201121058
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/cdn/js/kendo-angular-editor.js +2 -2
- package/dist/cdn/main.js +1 -1
- package/dist/es/common/error-messages.js +3 -2
- package/dist/es/config/commands.js +2 -2
- package/dist/es/config/schema.js +1 -2
- package/dist/es/config/table-commands.js +1 -363
- package/dist/es/editor.component.js +99 -71
- package/dist/es/main.js +1 -0
- package/dist/es/package-metadata.js +1 -1
- package/dist/{es2015/config/table-nodes.d.ts → es/preventable-events/paste-event-data.js} +0 -5
- package/dist/es/preventable-events/paste-event.js +25 -0
- package/dist/es2015/common/error-messages.js +3 -2
- package/dist/es2015/common/paste-cleanup-settings.d.ts +14 -0
- package/dist/es2015/config/commands.js +2 -2
- package/dist/es2015/config/schema.js +1 -2
- package/dist/es2015/config/table-commands.d.ts +0 -36
- package/dist/es2015/config/table-commands.js +1 -357
- package/dist/es2015/editor.component.d.ts +15 -10
- package/dist/es2015/editor.component.js +99 -71
- package/dist/es2015/index.metadata.json +1 -1
- package/dist/es2015/main.d.ts +2 -0
- package/dist/es2015/main.js +1 -0
- package/dist/es2015/package-metadata.js +1 -1
- package/dist/es2015/preventable-events/paste-event-data.d.ts +21 -0
- package/dist/es2015/preventable-events/paste-event-data.js +4 -0
- package/dist/es2015/preventable-events/paste-event.d.ts +27 -0
- package/dist/es2015/preventable-events/paste-event.js +20 -0
- package/dist/fesm2015/index.js +263 -1596
- package/dist/fesm5/index.js +285 -1641
- package/dist/npm/common/error-messages.js +3 -1
- package/dist/npm/config/commands.js +1 -1
- package/dist/npm/config/schema.js +1 -2
- package/dist/npm/config/table-commands.js +1 -368
- package/dist/npm/editor.component.js +95 -67
- package/dist/npm/main.js +2 -0
- package/dist/npm/package-metadata.js +1 -1
- package/dist/npm/preventable-events/paste-event-data.js +6 -0
- package/dist/npm/preventable-events/paste-event.js +27 -0
- package/dist/systemjs/kendo-angular-editor.js +1 -1
- package/package.json +5 -5
- package/dist/es/config/table-nodes.js +0 -146
- package/dist/es/config/tables/CellSelection.js +0 -268
- package/dist/es/config/tables/TableMap.js +0 -333
- package/dist/es/config/tables/table-utils.js +0 -302
- package/dist/es2015/config/table-nodes.js +0 -145
- package/dist/es2015/config/tables/CellSelection.d.ts +0 -35
- package/dist/es2015/config/tables/CellSelection.js +0 -256
- package/dist/es2015/config/tables/TableMap.d.ts +0 -35
- package/dist/es2015/config/tables/TableMap.js +0 -329
- package/dist/es2015/config/tables/table-utils.d.ts +0 -77
- package/dist/es2015/config/tables/table-utils.js +0 -299
- package/dist/npm/config/table-nodes.js +0 -157
- package/dist/npm/config/tables/CellSelection.js +0 -270
- package/dist/npm/config/tables/TableMap.js +0 -338
- package/dist/npm/config/tables/table-utils.js +0 -307
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
*-------------------------------------------------------------------------------------------*/
|
|
5
5
|
"use strict";
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
var ɵ0 = function (arg) { return "plugins must be a function, but received " + JSON.stringify(arg) + "."; };
|
|
7
|
+
var ɵ0 = function (arg) { return "plugins must be a function, but received " + JSON.stringify(arg) + "."; }, ɵ1 = function (arg) { return "pastedContent must be a function, but received " + JSON.stringify(arg) + "."; };
|
|
8
8
|
exports.ɵ0 = ɵ0;
|
|
9
|
+
exports.ɵ1 = ɵ1;
|
|
9
10
|
/* tslint:disable:variable-name */
|
|
10
11
|
/**
|
|
11
12
|
* @hidden
|
|
@@ -14,6 +15,7 @@ exports.EditorErrorMessages = {
|
|
|
14
15
|
schemaType: 'Expected value of type Schema. See http://www.telerik.com/kendo-angular-ui/components/editor/schema/',
|
|
15
16
|
setSchemaOnce: 'The Schema cannot be changed dynamically. See http://www.telerik.com/kendo-angular-ui/components/editor/schema/',
|
|
16
17
|
pluginsCallbackType: ɵ0,
|
|
18
|
+
pastedContentCallbackType: ɵ1,
|
|
17
19
|
setPluginsOnce: 'The plugins cannot be changed dynamically. See http://www.telerik.com/kendo-angular-ui/components/editor/plugins/',
|
|
18
20
|
setPlaceHolderOnce: 'The placeholder cannot be changed dynamically. See http://www.telerik.com/kendo-angular-ui/components/editor/placeholder/',
|
|
19
21
|
printTool: 'The Print tool and functionality are supported only in iframe mode. See https://www.telerik.com/kendo-angular-ui-develop/components/editor/api/EditorPrintButtonDirective/'
|
|
@@ -81,7 +81,7 @@ var blockCommand = {
|
|
|
81
81
|
setHTML: ɵ29,
|
|
82
82
|
undo: ɵ30
|
|
83
83
|
};
|
|
84
|
-
var ɵ31 = function (attr) { return table_commands_1.insertTable(attr); }, ɵ32 = function () { return
|
|
84
|
+
var ɵ31 = function (attr) { return table_commands_1.insertTable(attr); }, ɵ32 = function () { return kendo_editor_common_1.addColumnBefore; }, ɵ33 = function () { return kendo_editor_common_1.addColumnAfter; }, ɵ34 = function () { return kendo_editor_common_1.addRowBefore; }, ɵ35 = function () { return kendo_editor_common_1.addRowAfter; }, ɵ36 = function () { return kendo_editor_common_1.deleteRow; }, ɵ37 = function () { return kendo_editor_common_1.deleteColumn; }, ɵ38 = function () { return kendo_editor_common_1.mergeCells; }, ɵ39 = function () { return kendo_editor_common_1.splitCell; }, ɵ40 = function () { return kendo_editor_common_1.deleteTable; };
|
|
85
85
|
exports.ɵ31 = ɵ31;
|
|
86
86
|
exports.ɵ32 = ɵ32;
|
|
87
87
|
exports.ɵ33 = ɵ33;
|
|
@@ -8,12 +8,11 @@ var tslib_1 = require("tslib");
|
|
|
8
8
|
var semantic_nodes_1 = require("./semantic-nodes");
|
|
9
9
|
var kendo_editor_common_1 = require("@progress/kendo-editor-common");
|
|
10
10
|
exports.Schema = kendo_editor_common_1.Schema;
|
|
11
|
-
var table_nodes_1 = require("./table-nodes");
|
|
12
11
|
/**
|
|
13
12
|
* @hidden
|
|
14
13
|
*/
|
|
15
14
|
var marks = kendo_editor_common_1.marks;
|
|
16
|
-
var nodes = Object.assign(kendo_editor_common_1.nodes,
|
|
15
|
+
var nodes = Object.assign(kendo_editor_common_1.nodes, semantic_nodes_1.semanticNodes);
|
|
17
16
|
/**
|
|
18
17
|
* @hidden
|
|
19
18
|
*/
|
|
@@ -5,379 +5,12 @@
|
|
|
5
5
|
"use strict";
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
var kendo_editor_common_1 = require("@progress/kendo-editor-common");
|
|
8
|
-
var table_utils_1 = require("./tables/table-utils");
|
|
9
|
-
var utils_1 = require("./utils");
|
|
10
|
-
var TableMap_1 = require("./tables/TableMap");
|
|
11
|
-
var CellSelection_1 = require("./tables/CellSelection");
|
|
12
8
|
/**
|
|
13
9
|
* @hidden
|
|
14
10
|
*/
|
|
15
11
|
exports.insertTable = function (attrs) { return function (state, dispatch) {
|
|
16
|
-
var newTable =
|
|
12
|
+
var newTable = kendo_editor_common_1.createTable(state.schema.nodes, attrs.rows, attrs.cols);
|
|
17
13
|
if (newTable) {
|
|
18
14
|
kendo_editor_common_1.insertNode(newTable, true)(state, dispatch);
|
|
19
15
|
}
|
|
20
16
|
}; };
|
|
21
|
-
var addTableGroupColumn = function (tr, _a, col, mainTable, requiredGroup, doc) {
|
|
22
|
-
var left = _a.left, right = _a.right;
|
|
23
|
-
var refColumn = col > 0 ? -1 : 0;
|
|
24
|
-
// not sure if this should be deleted
|
|
25
|
-
// if (columnIsHeader(map, table, col + refColumn)) {
|
|
26
|
-
// refColumn = col === 0 || col === map.width ? null : 0;
|
|
27
|
-
// }
|
|
28
|
-
var rect;
|
|
29
|
-
mainTable.node.descendants(function (tableChildNode, offset) {
|
|
30
|
-
if (requiredGroup(tableChildNode)) {
|
|
31
|
-
var i_1 = -1;
|
|
32
|
-
tableChildNode.firstChild.descendants(function (childNode, pos) {
|
|
33
|
-
if (utils_1.isTableCell(childNode) || utils_1.isTableHeaderCell(childNode)) {
|
|
34
|
-
i_1 = i_1 + 1;
|
|
35
|
-
if (i_1 === right || i_1 === left) {
|
|
36
|
-
var selection = new kendo_editor_common_1.Selection(doc.resolve(pos + offset + mainTable.start), doc.resolve(pos + offset + mainTable.start));
|
|
37
|
-
rect = table_utils_1.selectedRect(selection);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
// Do nothing if thead, tfoot or tbody is missing
|
|
44
|
-
if (!rect) {
|
|
45
|
-
return tr;
|
|
46
|
-
}
|
|
47
|
-
for (var row = 0; row < rect.map.height; row++) {
|
|
48
|
-
var index = row * rect.map.width + col;
|
|
49
|
-
// If this position falls inside a col-spanning cell
|
|
50
|
-
if (col > 0 && col < rect.map.width && rect.map.map[index - 1] === rect.map.map[index]) {
|
|
51
|
-
var pos = rect.map.map[index];
|
|
52
|
-
var cell = rect.table.nodeAt(pos);
|
|
53
|
-
tr.setNodeMarkup(tr.mapping.map(rect.tableStart + pos), null, table_utils_1.addColSpan(cell.attrs, col - rect.map.colCount(pos)));
|
|
54
|
-
// Skip ahead if rowspan > 1
|
|
55
|
-
row += cell.attrs.rowspan - 1;
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
var type = rect.table.nodeAt(rect.map.map[index + refColumn]).type;
|
|
59
|
-
var pos = rect.map.positionAt(row, col, rect.table);
|
|
60
|
-
tr.insert(tr.mapping.map(rect.tableStart + pos), type.createAndFill());
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
return tr;
|
|
64
|
-
};
|
|
65
|
-
var ɵ0 = addTableGroupColumn;
|
|
66
|
-
exports.ɵ0 = ɵ0;
|
|
67
|
-
var removeTableGroupColumn = function (tr, _a, mainTable, requiredGroup, doc) {
|
|
68
|
-
var right = _a.right, left = _a.left;
|
|
69
|
-
var rect;
|
|
70
|
-
mainTable.node.descendants(function (tableChildNode, offset) {
|
|
71
|
-
if (requiredGroup(tableChildNode)) {
|
|
72
|
-
var i_2 = -1;
|
|
73
|
-
tableChildNode.firstChild.descendants(function (childNode, pos) {
|
|
74
|
-
if (utils_1.isTableCell(childNode) || utils_1.isTableHeaderCell(childNode)) {
|
|
75
|
-
i_2 = i_2 + 1;
|
|
76
|
-
if (i_2 >= left && i_2 < right) {
|
|
77
|
-
var resolvedPos = doc.resolve(pos + offset + mainTable.start + childNode.nodeSize);
|
|
78
|
-
var selection = new kendo_editor_common_1.Selection(resolvedPos, resolvedPos);
|
|
79
|
-
rect = table_utils_1.selectedRect(selection);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
// Do nothing if thead, tfoot or tbody is missing
|
|
86
|
-
if (!rect) {
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
for (var i = rect.right - 1;; i--) {
|
|
90
|
-
removeColumn(tr, rect, i);
|
|
91
|
-
if (i === rect.left) {
|
|
92
|
-
break;
|
|
93
|
-
}
|
|
94
|
-
rect.table = rect.tableStart ? tr.doc.nodeAt(rect.tableStart - 1) : tr.doc;
|
|
95
|
-
rect.map = TableMap_1.TableMap.get(rect.table);
|
|
96
|
-
}
|
|
97
|
-
return;
|
|
98
|
-
};
|
|
99
|
-
var ɵ1 = removeTableGroupColumn;
|
|
100
|
-
exports.ɵ1 = ɵ1;
|
|
101
|
-
var removeColumn = function (tr, _a, col) {
|
|
102
|
-
var map = _a.map, table = _a.table, tableStart = _a.tableStart;
|
|
103
|
-
for (var row = 0; row < map.height;) {
|
|
104
|
-
var index = row * map.width + col;
|
|
105
|
-
var pos = map.map[index];
|
|
106
|
-
var cell = table.nodeAt(pos);
|
|
107
|
-
// If this is part of a col-spanning cell
|
|
108
|
-
if ((col > 0 && map.map[index - 1] === pos) || (col < map.width - 1 && map.map[index + 1] === pos)) {
|
|
109
|
-
tr.setNodeMarkup(tr.mapping.map(tableStart + pos), null, table_utils_1.removeColSpan(cell.attrs, col - map.colCount(pos)));
|
|
110
|
-
}
|
|
111
|
-
else {
|
|
112
|
-
var start = tr.mapping.map(tableStart + pos);
|
|
113
|
-
tr.delete(start, start + cell.nodeSize);
|
|
114
|
-
}
|
|
115
|
-
row += cell.attrs.rowspan;
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
var ɵ2 = removeColumn;
|
|
119
|
-
exports.ɵ2 = ɵ2;
|
|
120
|
-
/**
|
|
121
|
-
* @hidden
|
|
122
|
-
*/
|
|
123
|
-
// Command to add a column before the column with the selection.
|
|
124
|
-
exports.addColumnBefore = function (state, dispatch) {
|
|
125
|
-
if (!table_utils_1.isInTable(state)) {
|
|
126
|
-
return false;
|
|
127
|
-
}
|
|
128
|
-
if (dispatch) {
|
|
129
|
-
var rect = table_utils_1.selectedRect(state.selection);
|
|
130
|
-
var mainTable = table_utils_1.findParentNodeClosestToPos(state.selection.$anchor, utils_1.isTable);
|
|
131
|
-
var tHeadTr = addTableGroupColumn(state.tr, rect, rect.left, mainTable, utils_1.isTableHead, state.doc);
|
|
132
|
-
var tBodyTr = addTableGroupColumn(tHeadTr, rect, rect.left, mainTable, utils_1.isTableBody, state.doc);
|
|
133
|
-
var tFootTr = addTableGroupColumn(tBodyTr, rect, rect.left, mainTable, utils_1.isTableFoot, state.doc);
|
|
134
|
-
dispatch(tFootTr);
|
|
135
|
-
}
|
|
136
|
-
return true;
|
|
137
|
-
};
|
|
138
|
-
/**
|
|
139
|
-
* @hidden
|
|
140
|
-
*/
|
|
141
|
-
// Command to add a column after the column with the selection.
|
|
142
|
-
exports.addColumnAfter = function (state, dispatch) {
|
|
143
|
-
if (!table_utils_1.isInTable(state)) {
|
|
144
|
-
return false;
|
|
145
|
-
}
|
|
146
|
-
if (dispatch) {
|
|
147
|
-
var rect = table_utils_1.selectedRect(state.selection);
|
|
148
|
-
var mainTable = table_utils_1.findParentNodeClosestToPos(state.selection.$anchor, utils_1.isTable);
|
|
149
|
-
var theadTr = addTableGroupColumn(state.tr, rect, rect.right, mainTable, utils_1.isTableHead, state.doc);
|
|
150
|
-
var tBodyTr = addTableGroupColumn(theadTr, rect, rect.right, mainTable, utils_1.isTableBody, state.doc);
|
|
151
|
-
var tFootTr = addTableGroupColumn(tBodyTr, rect, rect.right, mainTable, utils_1.isTableFoot, state.doc);
|
|
152
|
-
dispatch(tFootTr);
|
|
153
|
-
}
|
|
154
|
-
return true;
|
|
155
|
-
};
|
|
156
|
-
var addRow = function (tr, _a, row) {
|
|
157
|
-
var map = _a.map, tableStart = _a.tableStart, table = _a.table;
|
|
158
|
-
var rowPos = tableStart;
|
|
159
|
-
for (var i = 0; i < row; i++) {
|
|
160
|
-
rowPos += table.child(i).nodeSize;
|
|
161
|
-
}
|
|
162
|
-
var cells = [];
|
|
163
|
-
var refRow = row > 0 ? -1 : 0;
|
|
164
|
-
if (table_utils_1.rowIsHeader(map, table, row + refRow)) {
|
|
165
|
-
refRow = row === 0 || row === map.height ? null : 0;
|
|
166
|
-
}
|
|
167
|
-
for (var col = 0, index = map.width * row; col < map.width; col++, index++) {
|
|
168
|
-
// Covered by a rowspan cell
|
|
169
|
-
if (row > 0 && row < map.height && map.map[index] === map.map[index - map.width]) {
|
|
170
|
-
var pos = map.map[index];
|
|
171
|
-
var attrs = table.nodeAt(pos).attrs;
|
|
172
|
-
tr.setNodeMarkup(tableStart + pos, null, table_utils_1.setAttr(attrs, 'rowspan', attrs.rowspan + 1));
|
|
173
|
-
col += attrs.colspan - 1;
|
|
174
|
-
}
|
|
175
|
-
else {
|
|
176
|
-
var type = refRow == null ? table_utils_1.tableNodeTypes(table.type.schema).cell : table.nodeAt(map.map[index + refRow * map.width]).type;
|
|
177
|
-
cells.push(type.createAndFill());
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
tr.insert(rowPos, table_utils_1.tableNodeTypes(table.type.schema).row.create(null, cells));
|
|
181
|
-
return tr;
|
|
182
|
-
};
|
|
183
|
-
var ɵ3 = addRow;
|
|
184
|
-
exports.ɵ3 = ɵ3;
|
|
185
|
-
/**
|
|
186
|
-
* @hidden
|
|
187
|
-
*/
|
|
188
|
-
// Add a table row before the selection.
|
|
189
|
-
exports.addRowBefore = function (state, dispatch) {
|
|
190
|
-
if (!table_utils_1.isInTable(state)) {
|
|
191
|
-
return false;
|
|
192
|
-
}
|
|
193
|
-
if (dispatch) {
|
|
194
|
-
var rect = table_utils_1.selectedRect(state.selection);
|
|
195
|
-
dispatch(addRow(state.tr, rect, rect.top));
|
|
196
|
-
}
|
|
197
|
-
return true;
|
|
198
|
-
};
|
|
199
|
-
/**
|
|
200
|
-
* @hidden
|
|
201
|
-
*/
|
|
202
|
-
// Add a table row after the selection.
|
|
203
|
-
exports.addRowAfter = function (state, dispatch) {
|
|
204
|
-
if (!table_utils_1.isInTable(state)) {
|
|
205
|
-
return false;
|
|
206
|
-
}
|
|
207
|
-
if (dispatch) {
|
|
208
|
-
var rect = table_utils_1.selectedRect(state.selection);
|
|
209
|
-
dispatch(addRow(state.tr, rect, rect.bottom));
|
|
210
|
-
}
|
|
211
|
-
return true;
|
|
212
|
-
};
|
|
213
|
-
/**
|
|
214
|
-
* @hidden
|
|
215
|
-
*/
|
|
216
|
-
// Command function that removes the selected columns from a table.
|
|
217
|
-
exports.deleteColumn = function (state, dispatch) {
|
|
218
|
-
if (!table_utils_1.isInTable(state)) {
|
|
219
|
-
return false;
|
|
220
|
-
}
|
|
221
|
-
if (dispatch) {
|
|
222
|
-
var rect = table_utils_1.selectedRect(state.selection);
|
|
223
|
-
// if only one column left - delete the whole table
|
|
224
|
-
if (rect.left === 0 && rect.right === rect.map.width) {
|
|
225
|
-
return exports.deleteTable(state, dispatch);
|
|
226
|
-
}
|
|
227
|
-
var mainTable = table_utils_1.findParentNodeClosestToPos(state.selection.$anchor, utils_1.isTable);
|
|
228
|
-
var tr = state.tr;
|
|
229
|
-
removeTableGroupColumn(tr, rect, mainTable, utils_1.isTableFoot, tr.doc);
|
|
230
|
-
removeTableGroupColumn(tr, rect, mainTable, utils_1.isTableBody, tr.doc);
|
|
231
|
-
removeTableGroupColumn(tr, rect, mainTable, utils_1.isTableHead, tr.doc);
|
|
232
|
-
dispatch(tr);
|
|
233
|
-
}
|
|
234
|
-
return true;
|
|
235
|
-
};
|
|
236
|
-
var removeRow = function (tr, _a, row) {
|
|
237
|
-
var map = _a.map, table = _a.table, tableStart = _a.tableStart;
|
|
238
|
-
var rowPos = 0;
|
|
239
|
-
for (var i = 0; i < row; i++) {
|
|
240
|
-
rowPos += table.child(i).nodeSize;
|
|
241
|
-
}
|
|
242
|
-
var nextRow = rowPos + table.child(row).nodeSize;
|
|
243
|
-
var mapFrom = tr.mapping.maps.length;
|
|
244
|
-
tr.delete(rowPos + tableStart, nextRow + tableStart);
|
|
245
|
-
for (var col = 0, index = row * map.width; col < map.width; col++, index++) {
|
|
246
|
-
var pos = map.map[index];
|
|
247
|
-
if (row > 0 && pos === map.map[index - map.width]) {
|
|
248
|
-
// If this cell starts in the row above, simply reduce its rowspan
|
|
249
|
-
var attrs = table.nodeAt(pos).attrs;
|
|
250
|
-
tr.setNodeMarkup(tr.mapping.slice(mapFrom).map(pos + tableStart), null, table_utils_1.setAttr(attrs, 'rowspan', attrs.rowspan - 1));
|
|
251
|
-
col += attrs.colspan - 1;
|
|
252
|
-
}
|
|
253
|
-
else if (row < map.width && pos === map.map[index + map.width]) {
|
|
254
|
-
// Else, if it continues in the row below, it has to be moved down
|
|
255
|
-
var cell = table.nodeAt(pos);
|
|
256
|
-
var copy = cell.type.create(table_utils_1.setAttr(cell.attrs, 'rowspan', cell.attrs.rowspan - 1), cell.content);
|
|
257
|
-
var newPos = map.positionAt(row + 1, col, table);
|
|
258
|
-
tr.insert(tr.mapping.slice(mapFrom).map(tableStart + newPos), copy);
|
|
259
|
-
col += cell.attrs.colspan - 1;
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
};
|
|
263
|
-
var ɵ4 = removeRow;
|
|
264
|
-
exports.ɵ4 = ɵ4;
|
|
265
|
-
/**
|
|
266
|
-
* @hidden
|
|
267
|
-
*/
|
|
268
|
-
// Remove the selected rows from a table.
|
|
269
|
-
exports.deleteRow = function (state, dispatch) {
|
|
270
|
-
if (!table_utils_1.isInTable(state)) {
|
|
271
|
-
return false;
|
|
272
|
-
}
|
|
273
|
-
if (dispatch) {
|
|
274
|
-
var rect_1 = table_utils_1.selectedRect(state.selection);
|
|
275
|
-
var tr = state.tr;
|
|
276
|
-
if (rect_1.top === 0 && rect_1.bottom === rect_1.map.height) {
|
|
277
|
-
var mainTable = table_utils_1.findParentNodeClosestToPos(state.selection.$anchor, utils_1.isTable);
|
|
278
|
-
if (mainTable.node.childCount === 1) {
|
|
279
|
-
exports.deleteTable(state, dispatch);
|
|
280
|
-
}
|
|
281
|
-
else {
|
|
282
|
-
deleteTableElement(function (n) { return n.type.name === rect_1.table.type.name; })(state, dispatch);
|
|
283
|
-
}
|
|
284
|
-
return true;
|
|
285
|
-
}
|
|
286
|
-
for (var i = rect_1.bottom - 1;; i--) {
|
|
287
|
-
removeRow(tr, rect_1, i);
|
|
288
|
-
if (i === rect_1.top) {
|
|
289
|
-
break;
|
|
290
|
-
}
|
|
291
|
-
rect_1.table = rect_1.tableStart ? tr.doc.nodeAt(rect_1.tableStart - 1) : tr.doc;
|
|
292
|
-
rect_1.map = TableMap_1.TableMap.get(rect_1.table);
|
|
293
|
-
}
|
|
294
|
-
dispatch(tr);
|
|
295
|
-
}
|
|
296
|
-
return true;
|
|
297
|
-
};
|
|
298
|
-
/**
|
|
299
|
-
* @hidden
|
|
300
|
-
*/
|
|
301
|
-
// Merge the selected cells into a single cell. Only available when
|
|
302
|
-
// the selected cells' outline forms a rectangle.
|
|
303
|
-
exports.mergeCells = function (state, dispatch) {
|
|
304
|
-
var sel = state.selection;
|
|
305
|
-
if (!(sel instanceof CellSelection_1.CellSelection) || sel.$anchorCell.pos === sel.$headCell.pos) {
|
|
306
|
-
return false;
|
|
307
|
-
}
|
|
308
|
-
var rect = table_utils_1.selectedRect(state.selection);
|
|
309
|
-
var map = rect.map;
|
|
310
|
-
if (table_utils_1.cellsOverlapRectangle(map, rect)) {
|
|
311
|
-
return false;
|
|
312
|
-
}
|
|
313
|
-
if (dispatch) {
|
|
314
|
-
var tr = state.tr;
|
|
315
|
-
var seen = {};
|
|
316
|
-
var content = kendo_editor_common_1.Fragment.empty;
|
|
317
|
-
var mergedPos = void 0;
|
|
318
|
-
var mergedCell = void 0;
|
|
319
|
-
for (var row = rect.top; row < rect.bottom; row++) {
|
|
320
|
-
for (var col = rect.left; col < rect.right; col++) {
|
|
321
|
-
var cellPos = map.map[row * map.width + col], cell = rect.table.nodeAt(cellPos);
|
|
322
|
-
if (seen[cellPos]) {
|
|
323
|
-
continue;
|
|
324
|
-
}
|
|
325
|
-
seen[cellPos] = true;
|
|
326
|
-
if (mergedPos === null) {
|
|
327
|
-
mergedPos = cellPos;
|
|
328
|
-
mergedCell = cell;
|
|
329
|
-
}
|
|
330
|
-
else {
|
|
331
|
-
if (!table_utils_1.isCellEmpty(cell)) {
|
|
332
|
-
content = content.append(cell.content);
|
|
333
|
-
}
|
|
334
|
-
var mapped = tr.mapping.map(cellPos + rect.tableStart);
|
|
335
|
-
tr.delete(mapped, mapped + cell.nodeSize);
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
tr.setNodeMarkup(mergedPos + rect.tableStart, null, table_utils_1.setAttr(table_utils_1.addColSpan(mergedCell.attrs, mergedCell.attrs.colspan, rect.right - rect.left - mergedCell.attrs.colspan), 'rowspan', rect.bottom - rect.top));
|
|
340
|
-
if (content.size) {
|
|
341
|
-
var end = mergedPos + 1 + mergedCell.content.size;
|
|
342
|
-
var start = table_utils_1.isCellEmpty(mergedCell) ? mergedPos + 1 : end;
|
|
343
|
-
tr.replaceWith(start + rect.tableStart, end + rect.tableStart, content);
|
|
344
|
-
}
|
|
345
|
-
tr.setSelection(new CellSelection_1.CellSelection(tr.doc.resolve(mergedPos + rect.tableStart)));
|
|
346
|
-
dispatch(tr);
|
|
347
|
-
}
|
|
348
|
-
return true;
|
|
349
|
-
};
|
|
350
|
-
/**
|
|
351
|
-
* @hidden
|
|
352
|
-
*/
|
|
353
|
-
// Split a selected cell, whose rowpan or colspan is greater than one,
|
|
354
|
-
// into smaller cells. Use the first cell type for the new cells.
|
|
355
|
-
exports.splitCell = function (state, dispatch) {
|
|
356
|
-
var nodeTypes = table_utils_1.tableNodeTypes(state.schema);
|
|
357
|
-
return table_utils_1.splitCellWithType(function (_a) {
|
|
358
|
-
var node = _a.node;
|
|
359
|
-
return nodeTypes[node.type.spec.tableRole];
|
|
360
|
-
})(state, dispatch);
|
|
361
|
-
};
|
|
362
|
-
var deleteTableElement = function (selector) { return function (state, dispatch) {
|
|
363
|
-
var $pos = state.selection.$anchor;
|
|
364
|
-
for (var d = $pos.depth; d > 0; d--) {
|
|
365
|
-
var node = $pos.node(d);
|
|
366
|
-
if (selector(node)) {
|
|
367
|
-
if (dispatch) {
|
|
368
|
-
var tr = state.tr;
|
|
369
|
-
tr.delete($pos.before(d), $pos.after(d)).scrollIntoView();
|
|
370
|
-
dispatch(tr);
|
|
371
|
-
}
|
|
372
|
-
return true;
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
return false;
|
|
376
|
-
}; };
|
|
377
|
-
var ɵ5 = deleteTableElement;
|
|
378
|
-
exports.ɵ5 = ɵ5;
|
|
379
|
-
/**
|
|
380
|
-
* @hidden
|
|
381
|
-
*/
|
|
382
|
-
// Deletes the table around the selection, if any.
|
|
383
|
-
exports.deleteTable = deleteTableElement(utils_1.isTable);
|