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