@progress/kendo-angular-editor 2.5.0 → 3.0.0-dev.202201191455
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/LICENSE.md +1 -1
- package/NOTICE.txt +119 -79
- package/README.md +1 -1
- package/dist/cdn/js/kendo-angular-editor.js +2 -2
- package/dist/cdn/main.js +1 -1
- package/dist/es/common/error-messages.js +4 -3
- package/dist/es/config/command-icons.js +1 -0
- package/dist/es/config/commands.js +18 -17
- package/dist/es/config/schema.js +2 -4
- package/dist/es/config/table-commands.js +1 -363
- package/dist/es/dialogs/colorpicker-dialog.component.js +1 -1
- package/dist/es/dialogs/file-link-dialog.component.js +1 -1
- package/dist/es/dialogs/image-dialog.component.js +1 -1
- package/dist/es/editor-toolbar-state.js +12 -2
- package/dist/es/editor.component.js +103 -75
- package/dist/es/editor.module.js +6 -3
- package/dist/es/index.js +2 -0
- package/dist/es/localization/messages.js +4 -0
- 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/es/tools/blockquote/editor-blockquote-button.directive.js +48 -0
- package/dist/es/tools/colorpicker/editor-colorpicker.component.js +24 -7
- package/dist/es/tools/format/editor-format-dropdownlist.component.js +1 -1
- package/dist/es/tools/format/editor-format.component.js +0 -1
- package/dist/es/tools/tables/popup-table-grid.component.js +1 -1
- package/dist/es2015/common/commands.d.ts +1 -1
- package/dist/es2015/common/error-messages.js +4 -3
- package/dist/es2015/common/format-item.interface.d.ts +1 -1
- package/dist/es2015/common/paste-cleanup-settings.d.ts +14 -0
- package/dist/es2015/config/command-icons.js +1 -0
- package/dist/es2015/config/commands.js +18 -17
- package/dist/es2015/config/schema.d.ts +1 -1
- package/dist/es2015/config/schema.js +2 -3
- package/dist/es2015/config/table-commands.d.ts +0 -36
- package/dist/es2015/config/table-commands.js +1 -357
- package/dist/es2015/dialogs/colorpicker-dialog.component.js +1 -1
- package/dist/es2015/dialogs/file-link-dialog.component.js +4 -4
- package/dist/es2015/dialogs/image-dialog.component.js +4 -4
- package/dist/es2015/editor-toolbar-state.js +12 -2
- package/dist/es2015/editor.component.d.ts +16 -11
- package/dist/es2015/editor.component.js +105 -75
- package/dist/es2015/editor.module.js +6 -3
- package/dist/es2015/index.d.ts +2 -0
- package/dist/es2015/index.js +2 -0
- package/dist/es2015/index.metadata.json +1 -1
- package/dist/es2015/localization/messages.d.ts +4 -0
- package/dist/es2015/localization/messages.js +4 -0
- 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/es2015/tools/blockquote/editor-blockquote-button.directive.d.ts +30 -0
- package/dist/es2015/tools/blockquote/editor-blockquote-button.directive.js +45 -0
- package/dist/es2015/tools/colorpicker/editor-colorpicker.component.d.ts +8 -2
- package/dist/es2015/tools/colorpicker/editor-colorpicker.component.js +20 -7
- package/dist/es2015/tools/format/editor-format-dropdownlist.component.js +0 -4
- package/dist/es2015/tools/format/editor-format.component.js +0 -1
- package/dist/es2015/tools/tables/popup-table-grid.component.js +2 -2
- package/dist/fesm2015/index.js +354 -1624
- package/dist/fesm5/index.js +365 -1649
- package/dist/npm/common/error-messages.js +4 -2
- package/dist/npm/config/command-icons.js +1 -0
- package/dist/npm/config/commands.js +16 -14
- package/dist/npm/config/schema.js +2 -4
- package/dist/npm/config/table-commands.js +1 -368
- package/dist/npm/dialogs/colorpicker-dialog.component.js +1 -1
- package/dist/npm/dialogs/file-link-dialog.component.js +1 -1
- package/dist/npm/dialogs/image-dialog.component.js +1 -1
- package/dist/npm/editor-toolbar-state.js +11 -1
- package/dist/npm/editor.component.js +99 -71
- package/dist/npm/editor.module.js +7 -4
- package/dist/npm/index.js +5 -0
- package/dist/npm/localization/messages.js +4 -0
- 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/npm/tools/blockquote/editor-blockquote-button.directive.js +50 -0
- package/dist/npm/tools/colorpicker/editor-colorpicker.component.js +24 -7
- package/dist/npm/tools/format/editor-format-dropdownlist.component.js +1 -1
- package/dist/npm/tools/format/editor-format.component.js +0 -1
- package/dist/npm/tools/tables/popup-table-grid.component.js +1 -1
- package/dist/systemjs/kendo-angular-editor.js +1 -1
- package/package.json +18 -18
- 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
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
/**-----------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright © 2021 Progress Software Corporation. All rights reserved.
|
|
3
|
-
* Licensed under commercial license. See LICENSE.md in the project root for more information
|
|
4
|
-
*-------------------------------------------------------------------------------------------*/
|
|
5
|
-
"use strict";
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
var tslib_1 = require("tslib");
|
|
8
|
-
var util_1 = require("../util");
|
|
9
|
-
var utils_1 = require("./utils");
|
|
10
|
-
var setCellAttrs = function (nodeAttributes) {
|
|
11
|
-
var attrs = tslib_1.__assign({}, nodeAttributes);
|
|
12
|
-
if (nodeAttributes.colspan !== 1) {
|
|
13
|
-
attrs.colspan = nodeAttributes.colspan;
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
attrs.colspan = null;
|
|
17
|
-
}
|
|
18
|
-
if (nodeAttributes.rowspan !== 1) {
|
|
19
|
-
attrs.rowspan = nodeAttributes.rowspan;
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
attrs.rowspan = null;
|
|
23
|
-
}
|
|
24
|
-
return util_1.removeEmptyEntries(attrs);
|
|
25
|
-
};
|
|
26
|
-
var ɵ0 = setCellAttrs;
|
|
27
|
-
exports.ɵ0 = ɵ0;
|
|
28
|
-
var ɵ1 = function (node) { return ['table', util_1.removeEmptyEntries(node.attrs), 0]; }, ɵ2 = function (node) { return ['tr', util_1.removeEmptyEntries(node.attrs), 0]; }, ɵ3 = function (node) { return ['td', setCellAttrs(node.attrs), 0]; }, ɵ4 = function (node) { return ['th', setCellAttrs(node.attrs), 0]; }, ɵ5 = function (node) { return ['tbody', util_1.removeEmptyEntries(node.attrs), 0]; }, ɵ6 = function (node) { return ['tfoot', util_1.removeEmptyEntries(node.attrs), 0]; }, ɵ7 = function (node) { return ['thead', util_1.removeEmptyEntries(node.attrs), 0]; }, ɵ8 = function (node) { return ['col', util_1.removeEmptyEntries(node.attrs)]; }, ɵ9 = function (node) { return ['colgroup', util_1.removeEmptyEntries(node.attrs), 0]; };
|
|
29
|
-
exports.ɵ1 = ɵ1;
|
|
30
|
-
exports.ɵ2 = ɵ2;
|
|
31
|
-
exports.ɵ3 = ɵ3;
|
|
32
|
-
exports.ɵ4 = ɵ4;
|
|
33
|
-
exports.ɵ5 = ɵ5;
|
|
34
|
-
exports.ɵ6 = ɵ6;
|
|
35
|
-
exports.ɵ7 = ɵ7;
|
|
36
|
-
exports.ɵ8 = ɵ8;
|
|
37
|
-
exports.ɵ9 = ɵ9;
|
|
38
|
-
/**
|
|
39
|
-
* @hidden
|
|
40
|
-
*/
|
|
41
|
-
exports.tableNodes = {
|
|
42
|
-
// all table node names must start with table - this is needed for the commands to work properly
|
|
43
|
-
table: {
|
|
44
|
-
attrs: tslib_1.__assign({}, utils_1.commonAttributes(), utils_1.createDefaultAttributes(['cellspacing', 'cellpadding'])),
|
|
45
|
-
content: '(table_body | table_head | table_foot | table_colgroup)+',
|
|
46
|
-
tableRole: 'table',
|
|
47
|
-
isolating: true,
|
|
48
|
-
group: 'block',
|
|
49
|
-
parseDOM: [
|
|
50
|
-
{
|
|
51
|
-
getAttrs: utils_1.serializeDOMAttrs,
|
|
52
|
-
tag: 'table'
|
|
53
|
-
}
|
|
54
|
-
],
|
|
55
|
-
toDOM: ɵ1
|
|
56
|
-
},
|
|
57
|
-
table_row: {
|
|
58
|
-
content: '(table_cell | table_header)*',
|
|
59
|
-
attrs: tslib_1.__assign({}, utils_1.commonAttributes()),
|
|
60
|
-
tableRole: 'row',
|
|
61
|
-
parseDOM: [
|
|
62
|
-
{
|
|
63
|
-
getAttrs: utils_1.serializeDOMAttrs,
|
|
64
|
-
tag: 'tr'
|
|
65
|
-
}
|
|
66
|
-
],
|
|
67
|
-
toDOM: ɵ2
|
|
68
|
-
},
|
|
69
|
-
table_cell: {
|
|
70
|
-
content: 'block+',
|
|
71
|
-
attrs: tslib_1.__assign({}, utils_1.commonAttributes(), utils_1.createDefaultAttributes(['headers']), {
|
|
72
|
-
// this is needed for the commands
|
|
73
|
-
colspan: { default: 1 }, rowspan: { default: 1 } }),
|
|
74
|
-
tableRole: 'cell',
|
|
75
|
-
isolating: true,
|
|
76
|
-
parseDOM: [
|
|
77
|
-
{
|
|
78
|
-
getAttrs: utils_1.serializeDOMAttrs,
|
|
79
|
-
tag: 'td'
|
|
80
|
-
}
|
|
81
|
-
],
|
|
82
|
-
toDOM: ɵ3
|
|
83
|
-
},
|
|
84
|
-
table_header: {
|
|
85
|
-
content: 'block+',
|
|
86
|
-
attrs: tslib_1.__assign({}, utils_1.commonAttributes(), utils_1.createDefaultAttributes(['headers', 'abbr', 'scope']), { colspan: { default: 1 }, rowspan: { default: 1 } }),
|
|
87
|
-
tableRole: 'header_cell',
|
|
88
|
-
isolating: true,
|
|
89
|
-
parseDOM: [
|
|
90
|
-
{
|
|
91
|
-
getAttrs: utils_1.serializeDOMAttrs,
|
|
92
|
-
tag: 'th'
|
|
93
|
-
}
|
|
94
|
-
],
|
|
95
|
-
toDOM: ɵ4
|
|
96
|
-
},
|
|
97
|
-
table_body: {
|
|
98
|
-
attrs: tslib_1.__assign({}, utils_1.commonAttributes()),
|
|
99
|
-
content: 'table_row+',
|
|
100
|
-
isolating: true,
|
|
101
|
-
parseDOM: [
|
|
102
|
-
{
|
|
103
|
-
getAttrs: utils_1.serializeDOMAttrs,
|
|
104
|
-
tag: 'tbody'
|
|
105
|
-
}
|
|
106
|
-
],
|
|
107
|
-
toDOM: ɵ5
|
|
108
|
-
},
|
|
109
|
-
table_foot: {
|
|
110
|
-
attrs: tslib_1.__assign({}, utils_1.commonAttributes()),
|
|
111
|
-
content: 'table_row+',
|
|
112
|
-
isolating: true,
|
|
113
|
-
parseDOM: [
|
|
114
|
-
{
|
|
115
|
-
getAttrs: utils_1.serializeDOMAttrs,
|
|
116
|
-
tag: 'tfoot'
|
|
117
|
-
}
|
|
118
|
-
],
|
|
119
|
-
toDOM: ɵ6
|
|
120
|
-
},
|
|
121
|
-
table_head: {
|
|
122
|
-
attrs: tslib_1.__assign({}, utils_1.commonAttributes()),
|
|
123
|
-
content: 'table_row+',
|
|
124
|
-
isolating: true,
|
|
125
|
-
parseDOM: [
|
|
126
|
-
{
|
|
127
|
-
getAttrs: utils_1.serializeDOMAttrs,
|
|
128
|
-
tag: 'thead'
|
|
129
|
-
}
|
|
130
|
-
],
|
|
131
|
-
toDOM: ɵ7
|
|
132
|
-
},
|
|
133
|
-
table_col: {
|
|
134
|
-
attrs: tslib_1.__assign({}, utils_1.commonAttributes(), utils_1.createDefaultAttributes(['span'])),
|
|
135
|
-
selectable: false,
|
|
136
|
-
atom: true,
|
|
137
|
-
parseDOM: [
|
|
138
|
-
{
|
|
139
|
-
getAttrs: utils_1.serializeDOMAttrs,
|
|
140
|
-
tag: 'col'
|
|
141
|
-
}
|
|
142
|
-
],
|
|
143
|
-
toDOM: ɵ8
|
|
144
|
-
},
|
|
145
|
-
table_colgroup: {
|
|
146
|
-
attrs: tslib_1.__assign({}, utils_1.commonAttributes(), utils_1.createDefaultAttributes(['span'])),
|
|
147
|
-
content: 'table_col*',
|
|
148
|
-
selectable: false,
|
|
149
|
-
parseDOM: [
|
|
150
|
-
{
|
|
151
|
-
getAttrs: utils_1.serializeDOMAttrs,
|
|
152
|
-
tag: 'colgroup'
|
|
153
|
-
}
|
|
154
|
-
],
|
|
155
|
-
toDOM: ɵ9
|
|
156
|
-
}
|
|
157
|
-
};
|
|
@@ -1,270 +0,0 @@
|
|
|
1
|
-
/**-----------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright © 2021 Progress Software Corporation. All rights reserved.
|
|
3
|
-
* Licensed under commercial license. See LICENSE.md in the project root for more information
|
|
4
|
-
*-------------------------------------------------------------------------------------------*/
|
|
5
|
-
"use strict";
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
var tslib_1 = require("tslib");
|
|
8
|
-
var kendo_editor_common_1 = require("@progress/kendo-editor-common");
|
|
9
|
-
var TableMap_1 = require("./TableMap");
|
|
10
|
-
var table_utils_1 = require("./table-utils");
|
|
11
|
-
/**
|
|
12
|
-
* @hidden
|
|
13
|
-
*/
|
|
14
|
-
// ::- A [`Selection`](http://prosemirror.net/docs/ref/#state.Selection)
|
|
15
|
-
// subclass that represents a cell selection spanning part of a table.
|
|
16
|
-
// With the plugin enabled, these will be created when the user
|
|
17
|
-
// selects across cells, and will be drawn by giving selected cells a
|
|
18
|
-
// `selectedCell` CSS class.
|
|
19
|
-
var CellSelection = /** @class */ (function (_super) {
|
|
20
|
-
tslib_1.__extends(CellSelection, _super);
|
|
21
|
-
// :: (ResolvedPos, ?ResolvedPos)
|
|
22
|
-
// A table selection is identified by its anchor and head cells. The
|
|
23
|
-
// positions given to this constructor should point _before_ two
|
|
24
|
-
// cells in the same table. They may be the same, to select a single
|
|
25
|
-
// cell.
|
|
26
|
-
function CellSelection($anchorCell, $headCell) {
|
|
27
|
-
if ($headCell === void 0) { $headCell = $anchorCell; }
|
|
28
|
-
var _this = this;
|
|
29
|
-
var table = $anchorCell.node(-1), map = TableMap_1.TableMap.get(table), start = $anchorCell.start(-1);
|
|
30
|
-
var rect = map.rectBetween($anchorCell.pos - start, $headCell.pos - start);
|
|
31
|
-
var doc = $anchorCell.node(0);
|
|
32
|
-
var cells = map.cellsInRect(rect).filter(function (p) { return p !== $headCell.pos - start; });
|
|
33
|
-
// Make the head cell the first range, so that it counts as the
|
|
34
|
-
// primary part of the selection
|
|
35
|
-
cells.unshift($headCell.pos - start);
|
|
36
|
-
var ranges = cells.map(function (pos) {
|
|
37
|
-
var cell = table.nodeAt(pos), from = pos + start + 1;
|
|
38
|
-
return new kendo_editor_common_1.SelectionRange(doc.resolve(from), doc.resolve(from + cell.content.size));
|
|
39
|
-
});
|
|
40
|
-
_this = _super.call(this, ranges[0].$from, ranges[0].$to, ranges) || this;
|
|
41
|
-
// :: ResolvedPos
|
|
42
|
-
// A resolved position pointing _in front of_ the anchor cell (the one
|
|
43
|
-
// that doesn't move when extending the selection).
|
|
44
|
-
_this.$anchorCell = $anchorCell;
|
|
45
|
-
// :: ResolvedPos
|
|
46
|
-
// A resolved position pointing in front of the head cell (the one
|
|
47
|
-
// moves when extending the selection).
|
|
48
|
-
_this.$headCell = $headCell;
|
|
49
|
-
return _this;
|
|
50
|
-
}
|
|
51
|
-
// :: (ResolvedPos, ?ResolvedPos) → CellSelection
|
|
52
|
-
// Returns the smallest column selection that covers the given anchor
|
|
53
|
-
// and head cell.
|
|
54
|
-
CellSelection.colSelection = function ($anchorCell, $headCell) {
|
|
55
|
-
if ($headCell === void 0) { $headCell = $anchorCell; }
|
|
56
|
-
var map = TableMap_1.TableMap.get($anchorCell.node(-1));
|
|
57
|
-
var start = $anchorCell.start(-1);
|
|
58
|
-
var anchorRect = map.findCell($anchorCell.pos - start);
|
|
59
|
-
var headRect = map.findCell($headCell.pos - start);
|
|
60
|
-
var doc = $anchorCell.node(0);
|
|
61
|
-
if (anchorRect.top <= headRect.top) {
|
|
62
|
-
if (anchorRect.top > 0) {
|
|
63
|
-
$anchorCell = doc.resolve(start + map.map[anchorRect.left]);
|
|
64
|
-
}
|
|
65
|
-
if (headRect.bottom < map.height) {
|
|
66
|
-
$headCell = doc.resolve(start + map.map[map.width * (map.height - 1) + headRect.right - 1]);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
if (headRect.top > 0) {
|
|
71
|
-
$headCell = doc.resolve(start + map.map[headRect.left]);
|
|
72
|
-
}
|
|
73
|
-
if (anchorRect.bottom < map.height) {
|
|
74
|
-
$anchorCell = doc.resolve(start + map.map[map.width * (map.height - 1) + anchorRect.right - 1]);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
return new CellSelection($anchorCell, $headCell);
|
|
78
|
-
};
|
|
79
|
-
// :: (ResolvedPos, ?ResolvedPos) → CellSelection
|
|
80
|
-
// Returns the smallest row selection that covers the given anchor
|
|
81
|
-
// and head cell.
|
|
82
|
-
CellSelection.rowSelection = function ($anchorCell, $headCell) {
|
|
83
|
-
if ($headCell === void 0) { $headCell = $anchorCell; }
|
|
84
|
-
var map = TableMap_1.TableMap.get($anchorCell.node(-1));
|
|
85
|
-
var start = $anchorCell.start(-1);
|
|
86
|
-
var anchorRect = map.findCell($anchorCell.pos - start);
|
|
87
|
-
var headRect = map.findCell($headCell.pos - start);
|
|
88
|
-
var doc = $anchorCell.node(0);
|
|
89
|
-
if (anchorRect.left <= headRect.left) {
|
|
90
|
-
if (anchorRect.left > 0) {
|
|
91
|
-
$anchorCell = doc.resolve(start + map.map[anchorRect.top * map.width]);
|
|
92
|
-
}
|
|
93
|
-
if (headRect.right < map.width) {
|
|
94
|
-
$headCell = doc.resolve(start + map.map[map.width * (headRect.top + 1) - 1]);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
if (headRect.left > 0) {
|
|
99
|
-
$headCell = doc.resolve(start + map.map[headRect.top * map.width]);
|
|
100
|
-
}
|
|
101
|
-
if (anchorRect.right < map.width) {
|
|
102
|
-
$anchorCell = doc.resolve(start + map.map[map.width * (anchorRect.top + 1) - 1]);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
return new CellSelection($anchorCell, $headCell);
|
|
106
|
-
};
|
|
107
|
-
CellSelection.fromJSON = function (doc, json) {
|
|
108
|
-
return new CellSelection(doc.resolve(json.anchor), doc.resolve(json.head));
|
|
109
|
-
};
|
|
110
|
-
// :: (Node, number, ?number) → CellSelection
|
|
111
|
-
CellSelection.create = function (doc, anchorCell, headCell) {
|
|
112
|
-
if (headCell === void 0) { headCell = anchorCell; }
|
|
113
|
-
return new CellSelection(doc.resolve(anchorCell), doc.resolve(headCell));
|
|
114
|
-
};
|
|
115
|
-
CellSelection.prototype.map = function (doc, mapping) {
|
|
116
|
-
var $anchorCell = doc.resolve(mapping.map(this.$anchorCell.pos));
|
|
117
|
-
var $headCell = doc.resolve(mapping.map(this.$headCell.pos));
|
|
118
|
-
if (table_utils_1.pointsAtCell($anchorCell) && table_utils_1.pointsAtCell($headCell) && table_utils_1.inSameTable($anchorCell, $headCell)) {
|
|
119
|
-
var tableChanged = this.$anchorCell.node(-1) !== $anchorCell.node(-1);
|
|
120
|
-
if (tableChanged && this.isRowSelection()) {
|
|
121
|
-
return CellSelection.rowSelection($anchorCell, $headCell);
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
124
|
-
if (tableChanged && this.isColSelection()) {
|
|
125
|
-
return CellSelection.colSelection($anchorCell, $headCell);
|
|
126
|
-
}
|
|
127
|
-
else {
|
|
128
|
-
return new CellSelection($anchorCell, $headCell);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
return kendo_editor_common_1.TextSelection.between($anchorCell, $headCell);
|
|
133
|
-
};
|
|
134
|
-
// :: () → Slice
|
|
135
|
-
// Returns a rectangular slice of table rows containing the selected
|
|
136
|
-
// cells.
|
|
137
|
-
CellSelection.prototype.content = function () {
|
|
138
|
-
var table = this.$anchorCell.node(-1), map = TableMap_1.TableMap.get(table), start = this.$anchorCell.start(-1);
|
|
139
|
-
var rect = map.rectBetween(this.$anchorCell.pos - start, this.$headCell.pos - start);
|
|
140
|
-
var seen = {}, rows = [];
|
|
141
|
-
for (var row = rect.top; row < rect.bottom; row++) {
|
|
142
|
-
var rowContent = [];
|
|
143
|
-
for (var index = row * map.width + rect.left, col = rect.left; col < rect.right; col++, index++) {
|
|
144
|
-
var pos = map.map[index];
|
|
145
|
-
if (!seen[pos]) {
|
|
146
|
-
seen[pos] = true;
|
|
147
|
-
var cellRect = map.findCell(pos), cell = table.nodeAt(pos);
|
|
148
|
-
var extraLeft = rect.left - cellRect.left, extraRight = cellRect.right - rect.right;
|
|
149
|
-
if (extraLeft > 0 || extraRight > 0) {
|
|
150
|
-
var attrs = cell.attrs;
|
|
151
|
-
if (extraLeft > 0) {
|
|
152
|
-
attrs = table_utils_1.removeColSpan(attrs, 0, extraLeft);
|
|
153
|
-
}
|
|
154
|
-
if (extraRight > 0) {
|
|
155
|
-
attrs = table_utils_1.removeColSpan(attrs, attrs.colspan - extraRight, extraRight);
|
|
156
|
-
}
|
|
157
|
-
if (cellRect.left < rect.left) {
|
|
158
|
-
cell = cell.type.createAndFill(attrs);
|
|
159
|
-
}
|
|
160
|
-
else {
|
|
161
|
-
cell = cell.type.create(attrs, cell.content);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
if (cellRect.top < rect.top || cellRect.bottom > rect.bottom) {
|
|
165
|
-
var attrs = table_utils_1.setAttr(cell.attrs, 'rowspan', Math.min(cellRect.bottom, rect.bottom) - Math.max(cellRect.top, rect.top));
|
|
166
|
-
if (cellRect.top < rect.top) {
|
|
167
|
-
cell = cell.type.createAndFill(attrs);
|
|
168
|
-
}
|
|
169
|
-
else {
|
|
170
|
-
cell = cell.type.create(attrs, cell.content);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
rowContent.push(cell);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
rows.push(table.child(row).copy(kendo_editor_common_1.Fragment.from(rowContent)));
|
|
177
|
-
}
|
|
178
|
-
var fragment = this.isColSelection() && this.isRowSelection() ? table : rows;
|
|
179
|
-
return new kendo_editor_common_1.Slice(kendo_editor_common_1.Fragment.from(fragment), 1, 1);
|
|
180
|
-
};
|
|
181
|
-
CellSelection.prototype.replace = function (tr, content) {
|
|
182
|
-
if (content === void 0) { content = kendo_editor_common_1.Slice.empty; }
|
|
183
|
-
var mapFrom = tr.steps.length;
|
|
184
|
-
var ranges = this.ranges;
|
|
185
|
-
for (var i = 0; i < ranges.length; i++) {
|
|
186
|
-
var _a = ranges[i], $from = _a.$from, $to = _a.$to;
|
|
187
|
-
var mapping = tr.mapping.slice(mapFrom);
|
|
188
|
-
tr.replace(mapping.map($from.pos), mapping.map($to.pos), i ? kendo_editor_common_1.Slice.empty : content);
|
|
189
|
-
}
|
|
190
|
-
var sel = kendo_editor_common_1.Selection.findFrom(tr.doc.resolve(tr.mapping.slice(mapFrom).map(this.to)), -1);
|
|
191
|
-
if (sel) {
|
|
192
|
-
tr.setSelection(sel);
|
|
193
|
-
}
|
|
194
|
-
};
|
|
195
|
-
CellSelection.prototype.replaceWith = function (tr, node) {
|
|
196
|
-
this.replace(tr, new kendo_editor_common_1.Slice(kendo_editor_common_1.Fragment.from(node), 0, 0));
|
|
197
|
-
};
|
|
198
|
-
CellSelection.prototype.forEachCell = function (f) {
|
|
199
|
-
var table = this.$anchorCell.node(-1);
|
|
200
|
-
var map = TableMap_1.TableMap.get(table);
|
|
201
|
-
var start = this.$anchorCell.start(-1);
|
|
202
|
-
var cells = map.cellsInRect(map.rectBetween(this.$anchorCell.pos - start, this.$headCell.pos - start));
|
|
203
|
-
for (var i = 0; i < cells.length; i++) {
|
|
204
|
-
f(table.nodeAt(cells[i]), start + cells[i]);
|
|
205
|
-
}
|
|
206
|
-
};
|
|
207
|
-
// :: () → bool
|
|
208
|
-
// True if this selection goes all the way from the top to the
|
|
209
|
-
// bottom of the table.
|
|
210
|
-
CellSelection.prototype.isColSelection = function () {
|
|
211
|
-
var anchorTop = this.$anchorCell.index(-1), headTop = this.$headCell.index(-1);
|
|
212
|
-
if (Math.min(anchorTop, headTop) > 0) {
|
|
213
|
-
return false;
|
|
214
|
-
}
|
|
215
|
-
var anchorBot = anchorTop + this.$anchorCell.nodeAfter.attrs.rowspan;
|
|
216
|
-
var headBot = headTop + this.$headCell.nodeAfter.attrs.rowspan;
|
|
217
|
-
return Math.max(anchorBot, headBot) === this.$headCell.node(-1).childCount;
|
|
218
|
-
};
|
|
219
|
-
// :: () → bool
|
|
220
|
-
// True if this selection goes all the way from the left to the
|
|
221
|
-
// right of the table.
|
|
222
|
-
CellSelection.prototype.isRowSelection = function () {
|
|
223
|
-
var map = TableMap_1.TableMap.get(this.$anchorCell.node(-1));
|
|
224
|
-
var start = this.$anchorCell.start(-1);
|
|
225
|
-
var anchorLeft = map.colCount(this.$anchorCell.pos - start);
|
|
226
|
-
var headLeft = map.colCount(this.$headCell.pos - start);
|
|
227
|
-
if (Math.min(anchorLeft, headLeft) > 0) {
|
|
228
|
-
return false;
|
|
229
|
-
}
|
|
230
|
-
var anchorRight = anchorLeft + this.$anchorCell.nodeAfter.attrs.colspan;
|
|
231
|
-
var headRight = headLeft + this.$headCell.nodeAfter.attrs.colspan;
|
|
232
|
-
return Math.max(anchorRight, headRight) === map.width;
|
|
233
|
-
};
|
|
234
|
-
CellSelection.prototype.eq = function (other) {
|
|
235
|
-
return (other instanceof CellSelection && other.$anchorCell.pos === this.$anchorCell.pos && other.$headCell.pos === this.$headCell.pos);
|
|
236
|
-
};
|
|
237
|
-
CellSelection.prototype.toJSON = function () {
|
|
238
|
-
return { type: 'cell', anchor: this.$anchorCell.pos, head: this.$headCell.pos };
|
|
239
|
-
};
|
|
240
|
-
CellSelection.prototype.getBookmark = function () {
|
|
241
|
-
return new CellBookmark(this.$anchorCell.pos, this.$headCell.pos);
|
|
242
|
-
};
|
|
243
|
-
return CellSelection;
|
|
244
|
-
}(kendo_editor_common_1.Selection));
|
|
245
|
-
exports.CellSelection = CellSelection;
|
|
246
|
-
CellSelection.prototype.visible = false;
|
|
247
|
-
kendo_editor_common_1.Selection.jsonID('table_cell', CellSelection);
|
|
248
|
-
var CellBookmark = /** @class */ (function () {
|
|
249
|
-
function CellBookmark(anchor, head) {
|
|
250
|
-
this.anchor = anchor;
|
|
251
|
-
this.head = head;
|
|
252
|
-
}
|
|
253
|
-
CellBookmark.prototype.map = function (mapping) {
|
|
254
|
-
return new CellBookmark(mapping.map(this.anchor), mapping.map(this.head));
|
|
255
|
-
};
|
|
256
|
-
CellBookmark.prototype.resolve = function (doc) {
|
|
257
|
-
var $anchorCell = doc.resolve(this.anchor), $headCell = doc.resolve(this.head);
|
|
258
|
-
if ($anchorCell.parent.type.spec.tableRole === 'row' &&
|
|
259
|
-
$headCell.parent.type.spec.tableRole === 'row' &&
|
|
260
|
-
$anchorCell.index() < $anchorCell.parent.childCount &&
|
|
261
|
-
$headCell.index() < $headCell.parent.childCount &&
|
|
262
|
-
table_utils_1.inSameTable($anchorCell, $headCell)) {
|
|
263
|
-
return new CellSelection($anchorCell, $headCell);
|
|
264
|
-
}
|
|
265
|
-
else {
|
|
266
|
-
return kendo_editor_common_1.Selection.near($headCell, 1);
|
|
267
|
-
}
|
|
268
|
-
};
|
|
269
|
-
return CellBookmark;
|
|
270
|
-
}());
|