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