@ckeditor/ckeditor5-table 36.0.1 → 37.0.0-alpha.0
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/build/table.js +1 -1
- package/package.json +34 -29
- package/src/commands/insertcolumncommand.d.ts +61 -0
- package/src/commands/insertcolumncommand.js +45 -60
- package/src/commands/insertrowcommand.d.ts +60 -0
- package/src/commands/insertrowcommand.js +44 -59
- package/src/commands/inserttablecommand.d.ts +50 -0
- package/src/commands/inserttablecommand.js +51 -68
- package/src/commands/mergecellcommand.d.ts +76 -0
- package/src/commands/mergecellcommand.js +169 -244
- package/src/commands/mergecellscommand.d.ts +33 -0
- package/src/commands/mergecellscommand.js +72 -101
- package/src/commands/removecolumncommand.d.ts +34 -0
- package/src/commands/removecolumncommand.js +88 -102
- package/src/commands/removerowcommand.d.ts +34 -0
- package/src/commands/removerowcommand.js +63 -80
- package/src/commands/selectcolumncommand.d.ts +38 -0
- package/src/commands/selectcolumncommand.js +41 -54
- package/src/commands/selectrowcommand.d.ts +38 -0
- package/src/commands/selectrowcommand.js +38 -48
- package/src/commands/setheadercolumncommand.d.ts +55 -0
- package/src/commands/setheadercolumncommand.js +48 -73
- package/src/commands/setheaderrowcommand.d.ts +58 -0
- package/src/commands/setheaderrowcommand.js +56 -85
- package/src/commands/splitcellcommand.d.ts +49 -0
- package/src/commands/splitcellcommand.js +35 -49
- package/src/converters/downcast.d.ts +63 -0
- package/src/converters/downcast.js +98 -130
- package/src/converters/table-caption-post-fixer.d.ts +20 -0
- package/src/converters/table-caption-post-fixer.js +36 -52
- package/src/converters/table-cell-paragraph-post-fixer.d.ts +32 -0
- package/src/converters/table-cell-paragraph-post-fixer.js +88 -119
- package/src/converters/table-cell-refresh-handler.d.ts +18 -0
- package/src/converters/table-cell-refresh-handler.js +29 -48
- package/src/converters/table-headings-refresh-handler.d.ts +17 -0
- package/src/converters/table-headings-refresh-handler.js +35 -54
- package/src/converters/table-layout-post-fixer.d.ts +226 -0
- package/src/converters/table-layout-post-fixer.js +276 -313
- package/src/converters/tableproperties.d.ts +54 -0
- package/src/converters/tableproperties.js +136 -168
- package/src/converters/upcasttable.d.ts +49 -0
- package/src/converters/upcasttable.js +196 -251
- package/src/index.d.ts +29 -0
- package/src/index.js +0 -2
- package/src/plaintableoutput.d.ts +30 -0
- package/src/plaintableoutput.js +107 -135
- package/src/table.d.ts +38 -0
- package/src/table.js +12 -88
- package/src/tablecaption/tablecaptionediting.d.ts +68 -0
- package/src/tablecaption/tablecaptionediting.js +104 -135
- package/src/tablecaption/tablecaptionui.d.ts +26 -0
- package/src/tablecaption/tablecaptionui.js +42 -58
- package/src/tablecaption/toggletablecaptioncommand.d.ts +73 -0
- package/src/tablecaption/toggletablecaptioncommand.js +77 -92
- package/src/tablecaption/utils.d.ts +42 -0
- package/src/tablecaption/utils.js +35 -61
- package/src/tablecaption.d.ts +27 -0
- package/src/tablecaption.js +12 -19
- package/src/tablecellproperties/commands/tablecellbackgroundcolorcommand.d.ts +37 -0
- package/src/tablecellproperties/commands/tablecellbackgroundcolorcommand.js +14 -20
- package/src/tablecellproperties/commands/tablecellbordercolorcommand.d.ts +42 -0
- package/src/tablecellproperties/commands/tablecellbordercolorcommand.js +27 -37
- package/src/tablecellproperties/commands/tablecellborderstylecommand.d.ts +42 -0
- package/src/tablecellproperties/commands/tablecellborderstylecommand.js +27 -37
- package/src/tablecellproperties/commands/tablecellborderwidthcommand.d.ts +56 -0
- package/src/tablecellproperties/commands/tablecellborderwidthcommand.js +42 -53
- package/src/tablecellproperties/commands/tablecellheightcommand.d.ts +51 -0
- package/src/tablecellproperties/commands/tablecellheightcommand.js +29 -36
- package/src/tablecellproperties/commands/tablecellhorizontalalignmentcommand.d.ts +37 -0
- package/src/tablecellproperties/commands/tablecellhorizontalalignmentcommand.js +14 -20
- package/src/tablecellproperties/commands/tablecellpaddingcommand.d.ts +56 -0
- package/src/tablecellproperties/commands/tablecellpaddingcommand.js +42 -53
- package/src/tablecellproperties/commands/tablecellpropertycommand.d.ts +62 -0
- package/src/tablecellproperties/commands/tablecellpropertycommand.js +77 -122
- package/src/tablecellproperties/commands/tablecellverticalalignmentcommand.d.ts +45 -0
- package/src/tablecellproperties/commands/tablecellverticalalignmentcommand.js +14 -20
- package/src/tablecellproperties/tablecellpropertiesediting.d.ts +47 -0
- package/src/tablecellproperties/tablecellpropertiesediting.js +194 -236
- package/src/tablecellproperties/tablecellpropertiesui.d.ts +117 -0
- package/src/tablecellproperties/tablecellpropertiesui.js +303 -456
- package/src/tablecellproperties/ui/tablecellpropertiesview.d.ts +227 -0
- package/src/tablecellproperties/ui/tablecellpropertiesview.js +509 -844
- package/src/tablecellproperties.d.ts +33 -0
- package/src/tablecellproperties.js +12 -98
- package/src/tablecellwidth/commands/tablecellwidthcommand.d.ts +51 -0
- package/src/tablecellwidth/commands/tablecellwidthcommand.js +29 -35
- package/src/tablecellwidth/tablecellwidthediting.d.ts +34 -0
- package/src/tablecellwidth/tablecellwidthediting.js +26 -38
- package/src/tableclipboard.d.ts +68 -0
- package/src/tableclipboard.js +429 -568
- package/src/tablecolumnresize/constants.d.ts +20 -0
- package/src/tablecolumnresize/constants.js +0 -10
- package/src/tablecolumnresize/converters.d.ts +18 -0
- package/src/tablecolumnresize/converters.js +35 -119
- package/src/tablecolumnresize/tablecolumnresizeediting.d.ts +142 -0
- package/src/tablecolumnresize/tablecolumnresizeediting.js +545 -711
- package/src/tablecolumnresize/tablewidthscommand.d.ts +38 -0
- package/src/tablecolumnresize/tablewidthscommand.js +61 -0
- package/src/tablecolumnresize/utils.d.ts +141 -0
- package/src/tablecolumnresize/utils.js +256 -233
- package/src/tablecolumnresize.d.ts +29 -0
- package/src/tablecolumnresize.js +12 -19
- package/src/tableconfig.d.ts +341 -0
- package/src/tableconfig.js +5 -0
- package/src/tableediting.d.ts +102 -0
- package/src/tableediting.js +157 -176
- package/src/tablekeyboard.d.ts +68 -0
- package/src/tablekeyboard.js +261 -344
- package/src/tablemouse/mouseeventsobserver.d.ts +62 -0
- package/src/tablemouse/mouseeventsobserver.js +12 -49
- package/src/tablemouse.d.ts +51 -0
- package/src/tablemouse.js +154 -202
- package/src/tableproperties/commands/tablealignmentcommand.d.ts +37 -0
- package/src/tableproperties/commands/tablealignmentcommand.js +14 -20
- package/src/tableproperties/commands/tablebackgroundcolorcommand.d.ts +37 -0
- package/src/tableproperties/commands/tablebackgroundcolorcommand.js +14 -20
- package/src/tableproperties/commands/tablebordercolorcommand.d.ts +42 -0
- package/src/tableproperties/commands/tablebordercolorcommand.js +27 -37
- package/src/tableproperties/commands/tableborderstylecommand.d.ts +42 -0
- package/src/tableproperties/commands/tableborderstylecommand.js +27 -37
- package/src/tableproperties/commands/tableborderwidthcommand.d.ts +56 -0
- package/src/tableproperties/commands/tableborderwidthcommand.js +42 -53
- package/src/tableproperties/commands/tableheightcommand.d.ts +51 -0
- package/src/tableproperties/commands/tableheightcommand.js +29 -33
- package/src/tableproperties/commands/tablepropertycommand.d.ts +61 -0
- package/src/tableproperties/commands/tablepropertycommand.js +68 -112
- package/src/tableproperties/commands/tablewidthcommand.d.ts +51 -0
- package/src/tableproperties/commands/tablewidthcommand.js +29 -33
- package/src/tableproperties/tablepropertiesediting.d.ts +45 -0
- package/src/tableproperties/tablepropertiesediting.js +164 -210
- package/src/tableproperties/tablepropertiesui.d.ts +119 -0
- package/src/tableproperties/tablepropertiesui.js +294 -439
- package/src/tableproperties/ui/tablepropertiesview.d.ts +203 -0
- package/src/tableproperties/ui/tablepropertiesview.js +427 -718
- package/src/tableproperties.d.ts +33 -0
- package/src/tableproperties.js +12 -95
- package/src/tableselection.d.ts +111 -0
- package/src/tableselection.js +279 -376
- package/src/tabletoolbar.d.ts +37 -0
- package/src/tabletoolbar.js +39 -92
- package/src/tableui.d.ts +58 -0
- package/src/tableui.js +281 -338
- package/src/tableutils.d.ts +453 -0
- package/src/tableutils.js +1015 -1229
- package/src/tablewalker.d.ts +323 -0
- package/src/tablewalker.js +308 -548
- package/src/ui/colorinputview.d.ts +143 -0
- package/src/ui/colorinputview.js +229 -366
- package/src/ui/formrowview.d.ts +61 -0
- package/src/ui/formrowview.js +38 -84
- package/src/ui/inserttableview.d.ts +77 -0
- package/src/ui/inserttableview.js +152 -242
- package/src/utils/common.d.ts +42 -0
- package/src/utils/common.js +33 -57
- package/src/utils/structure.d.ts +245 -0
- package/src/utils/structure.js +261 -379
- package/src/utils/table-properties.d.ts +67 -0
- package/src/utils/table-properties.js +60 -81
- package/src/utils/ui/contextualballoon.d.ts +34 -0
- package/src/utils/ui/contextualballoon.js +70 -89
- package/src/utils/ui/table-properties.d.ts +193 -0
- package/src/utils/ui/table-properties.js +259 -319
- package/src/utils/ui/widget.d.ts +16 -0
- package/src/utils/ui/widget.js +24 -46
- package/src/tablecolumnresize/tablecolumnwidthscommand.js +0 -55
- package/src/tablecolumnresize/tablewidthresizecommand.js +0 -65
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckeditor/ckeditor5-table",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "37.0.0-alpha.0",
|
|
4
4
|
"description": "Table feature for CKEditor 5.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ckeditor",
|
|
@@ -12,35 +12,36 @@
|
|
|
12
12
|
],
|
|
13
13
|
"main": "src/index.js",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"ckeditor5": "^
|
|
15
|
+
"ckeditor5": "^37.0.0-alpha.0",
|
|
16
16
|
"lodash-es": "^4.17.15"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@ckeditor/ckeditor5-alignment": "^
|
|
20
|
-
"@ckeditor/ckeditor5-basic-styles": "^
|
|
21
|
-
"@ckeditor/ckeditor5-block-quote": "^
|
|
22
|
-
"@ckeditor/ckeditor5-clipboard": "^
|
|
23
|
-
"@ckeditor/ckeditor5-core": "^
|
|
24
|
-
"@ckeditor/ckeditor5-dev-utils": "^
|
|
25
|
-
"@ckeditor/ckeditor5-editor-classic": "^
|
|
26
|
-
"@ckeditor/ckeditor5-engine": "^
|
|
27
|
-
"@ckeditor/ckeditor5-highlight": "^
|
|
28
|
-
"@ckeditor/ckeditor5-horizontal-line": "^
|
|
29
|
-
"@ckeditor/ckeditor5-html-support": "^
|
|
30
|
-
"@ckeditor/ckeditor5-image": "^
|
|
31
|
-
"@ckeditor/ckeditor5-indent": "^
|
|
32
|
-
"@ckeditor/ckeditor5-link": "^
|
|
33
|
-
"@ckeditor/ckeditor5-list": "^
|
|
34
|
-
"@ckeditor/ckeditor5-media-embed": "^
|
|
35
|
-
"@ckeditor/ckeditor5-paragraph": "^
|
|
36
|
-
"@ckeditor/ckeditor5-theme-lark": "^
|
|
37
|
-
"@ckeditor/ckeditor5-typing": "^
|
|
38
|
-
"@ckeditor/ckeditor5-ui": "^
|
|
39
|
-
"@ckeditor/ckeditor5-undo": "^
|
|
40
|
-
"@ckeditor/ckeditor5-utils": "^
|
|
41
|
-
"@ckeditor/ckeditor5-widget": "^
|
|
42
|
-
"@ckeditor/ckeditor5-source-editing": "^
|
|
19
|
+
"@ckeditor/ckeditor5-alignment": "^37.0.0-alpha.0",
|
|
20
|
+
"@ckeditor/ckeditor5-basic-styles": "^37.0.0-alpha.0",
|
|
21
|
+
"@ckeditor/ckeditor5-block-quote": "^37.0.0-alpha.0",
|
|
22
|
+
"@ckeditor/ckeditor5-clipboard": "^37.0.0-alpha.0",
|
|
23
|
+
"@ckeditor/ckeditor5-core": "^37.0.0-alpha.0",
|
|
24
|
+
"@ckeditor/ckeditor5-dev-utils": "^34.0.0",
|
|
25
|
+
"@ckeditor/ckeditor5-editor-classic": "^37.0.0-alpha.0",
|
|
26
|
+
"@ckeditor/ckeditor5-engine": "^37.0.0-alpha.0",
|
|
27
|
+
"@ckeditor/ckeditor5-highlight": "^37.0.0-alpha.0",
|
|
28
|
+
"@ckeditor/ckeditor5-horizontal-line": "^37.0.0-alpha.0",
|
|
29
|
+
"@ckeditor/ckeditor5-html-support": "^37.0.0-alpha.0",
|
|
30
|
+
"@ckeditor/ckeditor5-image": "^37.0.0-alpha.0",
|
|
31
|
+
"@ckeditor/ckeditor5-indent": "^37.0.0-alpha.0",
|
|
32
|
+
"@ckeditor/ckeditor5-link": "^37.0.0-alpha.0",
|
|
33
|
+
"@ckeditor/ckeditor5-list": "^37.0.0-alpha.0",
|
|
34
|
+
"@ckeditor/ckeditor5-media-embed": "^37.0.0-alpha.0",
|
|
35
|
+
"@ckeditor/ckeditor5-paragraph": "^37.0.0-alpha.0",
|
|
36
|
+
"@ckeditor/ckeditor5-theme-lark": "^37.0.0-alpha.0",
|
|
37
|
+
"@ckeditor/ckeditor5-typing": "^37.0.0-alpha.0",
|
|
38
|
+
"@ckeditor/ckeditor5-ui": "^37.0.0-alpha.0",
|
|
39
|
+
"@ckeditor/ckeditor5-undo": "^37.0.0-alpha.0",
|
|
40
|
+
"@ckeditor/ckeditor5-utils": "^37.0.0-alpha.0",
|
|
41
|
+
"@ckeditor/ckeditor5-widget": "^37.0.0-alpha.0",
|
|
42
|
+
"@ckeditor/ckeditor5-source-editing": "^37.0.0-alpha.0",
|
|
43
43
|
"json-diff": "^0.5.4",
|
|
44
|
+
"typescript": "^4.8.4",
|
|
44
45
|
"webpack": "^5.58.1",
|
|
45
46
|
"webpack-cli": "^4.9.0"
|
|
46
47
|
},
|
|
@@ -59,13 +60,17 @@
|
|
|
59
60
|
},
|
|
60
61
|
"files": [
|
|
61
62
|
"lang",
|
|
62
|
-
"src",
|
|
63
|
+
"src/**/*.js",
|
|
64
|
+
"src/**/*.d.ts",
|
|
63
65
|
"theme",
|
|
64
66
|
"build",
|
|
65
67
|
"ckeditor5-metadata.json",
|
|
66
68
|
"CHANGELOG.md"
|
|
67
69
|
],
|
|
68
70
|
"scripts": {
|
|
69
|
-
"dll:build": "webpack"
|
|
70
|
-
|
|
71
|
+
"dll:build": "webpack",
|
|
72
|
+
"build": "tsc -p ./tsconfig.release.json",
|
|
73
|
+
"postversion": "npm run build"
|
|
74
|
+
},
|
|
75
|
+
"types": "src/index.d.ts"
|
|
71
76
|
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module table/commands/insertcolumncommand
|
|
7
|
+
*/
|
|
8
|
+
import { Command, type Editor } from 'ckeditor5/src/core';
|
|
9
|
+
/**
|
|
10
|
+
* The insert column command.
|
|
11
|
+
*
|
|
12
|
+
* The command is registered by {@link module:table/tableediting~TableEditing} as the `'insertTableColumnLeft'` and
|
|
13
|
+
* `'insertTableColumnRight'` editor commands.
|
|
14
|
+
*
|
|
15
|
+
* To insert a column to the left of the selected cell, execute the following command:
|
|
16
|
+
*
|
|
17
|
+
* ```ts
|
|
18
|
+
* editor.execute( 'insertTableColumnLeft' );
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* To insert a column to the right of the selected cell, execute the following command:
|
|
22
|
+
*
|
|
23
|
+
* ```ts
|
|
24
|
+
* editor.execute( 'insertTableColumnRight' );
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export default class InsertColumnCommand extends Command {
|
|
28
|
+
/**
|
|
29
|
+
* The order of insertion relative to the column in which the caret is located.
|
|
30
|
+
*/
|
|
31
|
+
readonly order: 'left' | 'right';
|
|
32
|
+
/**
|
|
33
|
+
* Creates a new `InsertColumnCommand` instance.
|
|
34
|
+
*
|
|
35
|
+
* @param editor An editor on which this command will be used.
|
|
36
|
+
* @param options.order The order of insertion relative to the column in which the caret is located.
|
|
37
|
+
* Possible values: `"left"` and `"right"`. Default value is "right".
|
|
38
|
+
*/
|
|
39
|
+
constructor(editor: Editor, options?: {
|
|
40
|
+
order?: 'left' | 'right';
|
|
41
|
+
});
|
|
42
|
+
/**
|
|
43
|
+
* @inheritDoc
|
|
44
|
+
*/
|
|
45
|
+
refresh(): void;
|
|
46
|
+
/**
|
|
47
|
+
* Executes the command.
|
|
48
|
+
*
|
|
49
|
+
* Depending on the command's {@link #order} value, it inserts a column to the `'left'` or `'right'` of the column
|
|
50
|
+
* in which the selection is set.
|
|
51
|
+
*
|
|
52
|
+
* @fires execute
|
|
53
|
+
*/
|
|
54
|
+
execute(): void;
|
|
55
|
+
}
|
|
56
|
+
declare module '@ckeditor/ckeditor5-core' {
|
|
57
|
+
interface CommandsMap {
|
|
58
|
+
insertTableColumnLeft: InsertColumnCommand;
|
|
59
|
+
insertTableColumnRight: InsertColumnCommand;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -2,13 +2,10 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
5
|
/**
|
|
7
6
|
* @module table/commands/insertcolumncommand
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
import { Command } from 'ckeditor5/src/core';
|
|
11
|
-
|
|
12
9
|
/**
|
|
13
10
|
* The insert column command.
|
|
14
11
|
*
|
|
@@ -17,66 +14,54 @@ import { Command } from 'ckeditor5/src/core';
|
|
|
17
14
|
*
|
|
18
15
|
* To insert a column to the left of the selected cell, execute the following command:
|
|
19
16
|
*
|
|
20
|
-
*
|
|
17
|
+
* ```ts
|
|
18
|
+
* editor.execute( 'insertTableColumnLeft' );
|
|
19
|
+
* ```
|
|
21
20
|
*
|
|
22
21
|
* To insert a column to the right of the selected cell, execute the following command:
|
|
23
22
|
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
23
|
+
* ```ts
|
|
24
|
+
* editor.execute( 'insertTableColumnRight' );
|
|
25
|
+
* ```
|
|
27
26
|
*/
|
|
28
27
|
export default class InsertColumnCommand extends Command {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
execute() {
|
|
69
|
-
const editor = this.editor;
|
|
70
|
-
const selection = editor.model.document.selection;
|
|
71
|
-
const tableUtils = editor.plugins.get( 'TableUtils' );
|
|
72
|
-
const insertBefore = this.order === 'left';
|
|
73
|
-
|
|
74
|
-
const affectedTableCells = tableUtils.getSelectionAffectedTableCells( selection );
|
|
75
|
-
const columnIndexes = tableUtils.getColumnIndexes( affectedTableCells );
|
|
76
|
-
|
|
77
|
-
const column = insertBefore ? columnIndexes.first : columnIndexes.last;
|
|
78
|
-
const table = affectedTableCells[ 0 ].findAncestor( 'table' );
|
|
79
|
-
|
|
80
|
-
tableUtils.insertColumns( table, { columns: 1, at: insertBefore ? column : column + 1 } );
|
|
81
|
-
}
|
|
28
|
+
/**
|
|
29
|
+
* Creates a new `InsertColumnCommand` instance.
|
|
30
|
+
*
|
|
31
|
+
* @param editor An editor on which this command will be used.
|
|
32
|
+
* @param options.order The order of insertion relative to the column in which the caret is located.
|
|
33
|
+
* Possible values: `"left"` and `"right"`. Default value is "right".
|
|
34
|
+
*/
|
|
35
|
+
constructor(editor, options = {}) {
|
|
36
|
+
super(editor);
|
|
37
|
+
this.order = options.order || 'right';
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* @inheritDoc
|
|
41
|
+
*/
|
|
42
|
+
refresh() {
|
|
43
|
+
const selection = this.editor.model.document.selection;
|
|
44
|
+
const tableUtils = this.editor.plugins.get('TableUtils');
|
|
45
|
+
const isAnyCellSelected = !!tableUtils.getSelectionAffectedTableCells(selection).length;
|
|
46
|
+
this.isEnabled = isAnyCellSelected;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Executes the command.
|
|
50
|
+
*
|
|
51
|
+
* Depending on the command's {@link #order} value, it inserts a column to the `'left'` or `'right'` of the column
|
|
52
|
+
* in which the selection is set.
|
|
53
|
+
*
|
|
54
|
+
* @fires execute
|
|
55
|
+
*/
|
|
56
|
+
execute() {
|
|
57
|
+
const editor = this.editor;
|
|
58
|
+
const selection = editor.model.document.selection;
|
|
59
|
+
const tableUtils = editor.plugins.get('TableUtils');
|
|
60
|
+
const insertBefore = this.order === 'left';
|
|
61
|
+
const affectedTableCells = tableUtils.getSelectionAffectedTableCells(selection);
|
|
62
|
+
const columnIndexes = tableUtils.getColumnIndexes(affectedTableCells);
|
|
63
|
+
const column = insertBefore ? columnIndexes.first : columnIndexes.last;
|
|
64
|
+
const table = affectedTableCells[0].findAncestor('table');
|
|
65
|
+
tableUtils.insertColumns(table, { columns: 1, at: insertBefore ? column : column + 1 });
|
|
66
|
+
}
|
|
82
67
|
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module table/commands/insertrowcommand
|
|
7
|
+
*/
|
|
8
|
+
import { Command, type Editor } from 'ckeditor5/src/core';
|
|
9
|
+
/**
|
|
10
|
+
* The insert row command.
|
|
11
|
+
*
|
|
12
|
+
* The command is registered by {@link module:table/tableediting~TableEditing} as the `'insertTableRowBelow'` and
|
|
13
|
+
* `'insertTableRowAbove'` editor commands.
|
|
14
|
+
*
|
|
15
|
+
* To insert a row below the selected cell, execute the following command:
|
|
16
|
+
*
|
|
17
|
+
* ```ts
|
|
18
|
+
* editor.execute( 'insertTableRowBelow' );
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* To insert a row above the selected cell, execute the following command:
|
|
22
|
+
*
|
|
23
|
+
* ```ts
|
|
24
|
+
* editor.execute( 'insertTableRowAbove' );
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export default class InsertRowCommand extends Command {
|
|
28
|
+
/**
|
|
29
|
+
* The order of insertion relative to the row in which the caret is located.
|
|
30
|
+
*/
|
|
31
|
+
readonly order: 'above' | 'below';
|
|
32
|
+
/**
|
|
33
|
+
* Creates a new `InsertRowCommand` instance.
|
|
34
|
+
*
|
|
35
|
+
* @param editor The editor on which this command will be used.
|
|
36
|
+
* @param options.order The order of insertion relative to the row in which the caret is located.
|
|
37
|
+
* Possible values: `"above"` and `"below"`. Default value is "below"
|
|
38
|
+
*/
|
|
39
|
+
constructor(editor: Editor, options?: {
|
|
40
|
+
order?: 'above' | 'below';
|
|
41
|
+
});
|
|
42
|
+
/**
|
|
43
|
+
* @inheritDoc
|
|
44
|
+
*/
|
|
45
|
+
refresh(): void;
|
|
46
|
+
/**
|
|
47
|
+
* Executes the command.
|
|
48
|
+
*
|
|
49
|
+
* Depending on the command's {@link #order} value, it inserts a row `'below'` or `'above'` the row in which selection is set.
|
|
50
|
+
*
|
|
51
|
+
* @fires execute
|
|
52
|
+
*/
|
|
53
|
+
execute(): void;
|
|
54
|
+
}
|
|
55
|
+
declare module '@ckeditor/ckeditor5-core' {
|
|
56
|
+
interface CommandsMap {
|
|
57
|
+
insertTableRowAbove: InsertRowCommand;
|
|
58
|
+
insertTableRowBelow: InsertRowCommand;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -2,13 +2,10 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
5
|
/**
|
|
7
6
|
* @module table/commands/insertrowcommand
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
import { Command } from 'ckeditor5/src/core';
|
|
11
|
-
|
|
12
9
|
/**
|
|
13
10
|
* The insert row command.
|
|
14
11
|
*
|
|
@@ -17,65 +14,53 @@ import { Command } from 'ckeditor5/src/core';
|
|
|
17
14
|
*
|
|
18
15
|
* To insert a row below the selected cell, execute the following command:
|
|
19
16
|
*
|
|
20
|
-
*
|
|
17
|
+
* ```ts
|
|
18
|
+
* editor.execute( 'insertTableRowBelow' );
|
|
19
|
+
* ```
|
|
21
20
|
*
|
|
22
21
|
* To insert a row above the selected cell, execute the following command:
|
|
23
22
|
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
23
|
+
* ```ts
|
|
24
|
+
* editor.execute( 'insertTableRowAbove' );
|
|
25
|
+
* ```
|
|
27
26
|
*/
|
|
28
27
|
export default class InsertRowCommand extends Command {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
execute() {
|
|
68
|
-
const editor = this.editor;
|
|
69
|
-
const selection = editor.model.document.selection;
|
|
70
|
-
const tableUtils = editor.plugins.get( 'TableUtils' );
|
|
71
|
-
const insertAbove = this.order === 'above';
|
|
72
|
-
|
|
73
|
-
const affectedTableCells = tableUtils.getSelectionAffectedTableCells( selection );
|
|
74
|
-
const rowIndexes = tableUtils.getRowIndexes( affectedTableCells );
|
|
75
|
-
|
|
76
|
-
const row = insertAbove ? rowIndexes.first : rowIndexes.last;
|
|
77
|
-
const table = affectedTableCells[ 0 ].findAncestor( 'table' );
|
|
78
|
-
|
|
79
|
-
tableUtils.insertRows( table, { at: insertAbove ? row : row + 1, copyStructureFromAbove: !insertAbove } );
|
|
80
|
-
}
|
|
28
|
+
/**
|
|
29
|
+
* Creates a new `InsertRowCommand` instance.
|
|
30
|
+
*
|
|
31
|
+
* @param editor The editor on which this command will be used.
|
|
32
|
+
* @param options.order The order of insertion relative to the row in which the caret is located.
|
|
33
|
+
* Possible values: `"above"` and `"below"`. Default value is "below"
|
|
34
|
+
*/
|
|
35
|
+
constructor(editor, options = {}) {
|
|
36
|
+
super(editor);
|
|
37
|
+
this.order = options.order || 'below';
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* @inheritDoc
|
|
41
|
+
*/
|
|
42
|
+
refresh() {
|
|
43
|
+
const selection = this.editor.model.document.selection;
|
|
44
|
+
const tableUtils = this.editor.plugins.get('TableUtils');
|
|
45
|
+
const isAnyCellSelected = !!tableUtils.getSelectionAffectedTableCells(selection).length;
|
|
46
|
+
this.isEnabled = isAnyCellSelected;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Executes the command.
|
|
50
|
+
*
|
|
51
|
+
* Depending on the command's {@link #order} value, it inserts a row `'below'` or `'above'` the row in which selection is set.
|
|
52
|
+
*
|
|
53
|
+
* @fires execute
|
|
54
|
+
*/
|
|
55
|
+
execute() {
|
|
56
|
+
const editor = this.editor;
|
|
57
|
+
const selection = editor.model.document.selection;
|
|
58
|
+
const tableUtils = editor.plugins.get('TableUtils');
|
|
59
|
+
const insertAbove = this.order === 'above';
|
|
60
|
+
const affectedTableCells = tableUtils.getSelectionAffectedTableCells(selection);
|
|
61
|
+
const rowIndexes = tableUtils.getRowIndexes(affectedTableCells);
|
|
62
|
+
const row = insertAbove ? rowIndexes.first : rowIndexes.last;
|
|
63
|
+
const table = affectedTableCells[0].findAncestor('table');
|
|
64
|
+
tableUtils.insertRows(table, { at: insertAbove ? row : row + 1, copyStructureFromAbove: !insertAbove });
|
|
65
|
+
}
|
|
81
66
|
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module table/commands/inserttablecommand
|
|
7
|
+
*/
|
|
8
|
+
import { Command } from 'ckeditor5/src/core';
|
|
9
|
+
import '../tableconfig';
|
|
10
|
+
/**
|
|
11
|
+
* The insert table command.
|
|
12
|
+
*
|
|
13
|
+
* The command is registered by {@link module:table/tableediting~TableEditing} as the `'insertTable'` editor command.
|
|
14
|
+
*
|
|
15
|
+
* To insert a table at the current selection, execute the command and specify the dimensions:
|
|
16
|
+
*
|
|
17
|
+
* ```ts
|
|
18
|
+
* editor.execute( 'insertTable', { rows: 20, columns: 5 } );
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export default class InsertTableCommand extends Command {
|
|
22
|
+
/**
|
|
23
|
+
* @inheritDoc
|
|
24
|
+
*/
|
|
25
|
+
refresh(): void;
|
|
26
|
+
/**
|
|
27
|
+
* Executes the command.
|
|
28
|
+
*
|
|
29
|
+
* Inserts a table with the given number of rows and columns into the editor.
|
|
30
|
+
*
|
|
31
|
+
* @param options.rows The number of rows to create in the inserted table. Default value is 2.
|
|
32
|
+
* @param options.columns The number of columns to create in the inserted table. Default value is 2.
|
|
33
|
+
* @param options.headingRows The number of heading rows. If not provided it will default to
|
|
34
|
+
* {@link module:table/tableconfig~TableConfig#defaultHeadings `config.table.defaultHeadings.rows`} table config.
|
|
35
|
+
* @param options.headingColumns The number of heading columns. If not provided it will default to
|
|
36
|
+
* {@link module:table/tableconfig~TableConfig#defaultHeadings `config.table.defaultHeadings.columns`} table config.
|
|
37
|
+
* @fires execute
|
|
38
|
+
*/
|
|
39
|
+
execute(options?: {
|
|
40
|
+
rows?: number;
|
|
41
|
+
columns?: number;
|
|
42
|
+
headingRows?: number;
|
|
43
|
+
headingColumns?: number;
|
|
44
|
+
}): void;
|
|
45
|
+
}
|
|
46
|
+
declare module '@ckeditor/ckeditor5-core' {
|
|
47
|
+
interface CommandsMap {
|
|
48
|
+
insertTable: InsertTableCommand;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -2,13 +2,11 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
5
|
/**
|
|
7
6
|
* @module table/commands/inserttablecommand
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
import { Command } from 'ckeditor5/src/core';
|
|
11
|
-
|
|
9
|
+
import '../tableconfig';
|
|
12
10
|
/**
|
|
13
11
|
* The insert table command.
|
|
14
12
|
*
|
|
@@ -16,72 +14,57 @@ import { Command } from 'ckeditor5/src/core';
|
|
|
16
14
|
*
|
|
17
15
|
* To insert a table at the current selection, execute the command and specify the dimensions:
|
|
18
16
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
17
|
+
* ```ts
|
|
18
|
+
* editor.execute( 'insertTable', { rows: 20, columns: 5 } );
|
|
19
|
+
* ```
|
|
22
20
|
*/
|
|
23
21
|
export default class InsertTableCommand extends Command {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
options.headingColumns = defaultColumns;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
model.change( writer => {
|
|
68
|
-
const table = tableUtils.createTable( writer, options );
|
|
69
|
-
|
|
70
|
-
model.insertObject( table, null, null, { findOptimalPosition: 'auto' } );
|
|
71
|
-
|
|
72
|
-
writer.setSelection( writer.createPositionAt( table.getNodeByPath( [ 0, 0, 0 ] ), 0 ) );
|
|
73
|
-
} );
|
|
74
|
-
}
|
|
22
|
+
/**
|
|
23
|
+
* @inheritDoc
|
|
24
|
+
*/
|
|
25
|
+
refresh() {
|
|
26
|
+
const model = this.editor.model;
|
|
27
|
+
const selection = model.document.selection;
|
|
28
|
+
const schema = model.schema;
|
|
29
|
+
this.isEnabled = isAllowedInParent(selection, schema);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Executes the command.
|
|
33
|
+
*
|
|
34
|
+
* Inserts a table with the given number of rows and columns into the editor.
|
|
35
|
+
*
|
|
36
|
+
* @param options.rows The number of rows to create in the inserted table. Default value is 2.
|
|
37
|
+
* @param options.columns The number of columns to create in the inserted table. Default value is 2.
|
|
38
|
+
* @param options.headingRows The number of heading rows. If not provided it will default to
|
|
39
|
+
* {@link module:table/tableconfig~TableConfig#defaultHeadings `config.table.defaultHeadings.rows`} table config.
|
|
40
|
+
* @param options.headingColumns The number of heading columns. If not provided it will default to
|
|
41
|
+
* {@link module:table/tableconfig~TableConfig#defaultHeadings `config.table.defaultHeadings.columns`} table config.
|
|
42
|
+
* @fires execute
|
|
43
|
+
*/
|
|
44
|
+
execute(options = {}) {
|
|
45
|
+
const editor = this.editor;
|
|
46
|
+
const model = editor.model;
|
|
47
|
+
const tableUtils = editor.plugins.get('TableUtils');
|
|
48
|
+
const defaultRows = editor.config.get('table.defaultHeadings.rows');
|
|
49
|
+
const defaultColumns = editor.config.get('table.defaultHeadings.columns');
|
|
50
|
+
if (options.headingRows === undefined && defaultRows) {
|
|
51
|
+
options.headingRows = defaultRows;
|
|
52
|
+
}
|
|
53
|
+
if (options.headingColumns === undefined && defaultColumns) {
|
|
54
|
+
options.headingColumns = defaultColumns;
|
|
55
|
+
}
|
|
56
|
+
model.change(writer => {
|
|
57
|
+
const table = tableUtils.createTable(writer, options);
|
|
58
|
+
model.insertObject(table, null, null, { findOptimalPosition: 'auto' });
|
|
59
|
+
writer.setSelection(writer.createPositionAt(table.getNodeByPath([0, 0, 0]), 0));
|
|
60
|
+
});
|
|
61
|
+
}
|
|
75
62
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
const positionParent = selection.getFirstPosition().parent;
|
|
84
|
-
const validParent = positionParent === positionParent.root ? positionParent : positionParent.parent;
|
|
85
|
-
|
|
86
|
-
return schema.checkChild( validParent, 'table' );
|
|
63
|
+
/**
|
|
64
|
+
* Checks if the table is allowed in the parent.
|
|
65
|
+
*/
|
|
66
|
+
function isAllowedInParent(selection, schema) {
|
|
67
|
+
const positionParent = selection.getFirstPosition().parent;
|
|
68
|
+
const validParent = positionParent === positionParent.root ? positionParent : positionParent.parent;
|
|
69
|
+
return schema.checkChild(validParent, 'table');
|
|
87
70
|
}
|