@ckeditor/ckeditor5-table 45.2.1 → 46.0.0-alpha.1
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/dist/index-content.css +6 -5
- package/dist/index-editor.css +46 -46
- package/dist/index.css +63 -62
- package/dist/index.css.map +1 -1
- package/dist/index.js +306 -49
- package/dist/index.js.map +1 -1
- package/package.json +10 -10
- package/src/commands/insertcolumncommand.d.ts +1 -1
- package/src/commands/insertcolumncommand.js +1 -1
- package/src/commands/insertrowcommand.d.ts +1 -1
- package/src/commands/insertrowcommand.js +1 -1
- package/src/commands/inserttablecommand.d.ts +1 -1
- package/src/commands/inserttablecommand.js +1 -1
- package/src/commands/inserttablelayoutcommand.d.ts +1 -1
- package/src/commands/inserttablelayoutcommand.js +1 -1
- package/src/commands/mergecellcommand.d.ts +3 -3
- package/src/commands/mergecellcommand.js +2 -2
- package/src/commands/mergecellscommand.d.ts +1 -1
- package/src/commands/mergecellscommand.js +2 -2
- package/src/commands/removecolumncommand.d.ts +1 -1
- package/src/commands/removecolumncommand.js +2 -2
- package/src/commands/removerowcommand.d.ts +1 -1
- package/src/commands/removerowcommand.js +1 -1
- package/src/commands/selectcolumncommand.d.ts +1 -1
- package/src/commands/selectcolumncommand.js +2 -2
- package/src/commands/selectrowcommand.d.ts +1 -1
- package/src/commands/selectrowcommand.js +1 -1
- package/src/commands/setheadercolumncommand.d.ts +2 -2
- package/src/commands/setheadercolumncommand.js +1 -1
- package/src/commands/setheaderrowcommand.d.ts +2 -2
- package/src/commands/setheaderrowcommand.js +1 -1
- package/src/commands/splitcellcommand.d.ts +1 -1
- package/src/commands/splitcellcommand.js +1 -1
- package/src/converters/downcast.d.ts +21 -9
- package/src/converters/downcast.js +11 -3
- package/src/converters/table-caption-post-fixer.d.ts +3 -1
- package/src/converters/table-caption-post-fixer.js +3 -1
- package/src/converters/table-cell-paragraph-post-fixer.d.ts +3 -1
- package/src/converters/table-cell-paragraph-post-fixer.js +3 -1
- package/src/converters/table-cell-refresh-handler.d.ts +3 -1
- package/src/converters/table-cell-refresh-handler.js +3 -1
- package/src/converters/table-headings-refresh-handler.d.ts +3 -1
- package/src/converters/table-headings-refresh-handler.js +4 -2
- package/src/converters/table-layout-post-fixer.d.ts +3 -1
- package/src/converters/table-layout-post-fixer.js +4 -2
- package/src/converters/tableproperties.d.ts +17 -1
- package/src/converters/tableproperties.js +49 -2
- package/src/converters/upcasttable.d.ts +6 -1
- package/src/converters/upcasttable.js +6 -1
- package/src/index.d.ts +89 -56
- package/src/index.js +84 -24
- package/src/plaintableoutput.d.ts +2 -2
- package/src/plaintableoutput.js +2 -2
- package/src/table.d.ts +7 -7
- package/src/table.js +7 -7
- package/src/tablecaption/tablecaptionediting.d.ts +6 -6
- package/src/tablecaption/tablecaptionediting.js +8 -8
- package/src/tablecaption/tablecaptionui.d.ts +1 -1
- package/src/tablecaption/tablecaptionui.js +1 -1
- package/src/tablecaption/toggletablecaptioncommand.d.ts +1 -1
- package/src/tablecaption/toggletablecaptioncommand.js +1 -1
- package/src/tablecaption/utils.d.ts +8 -4
- package/src/tablecaption/utils.js +4 -0
- package/src/tablecaption.d.ts +3 -3
- package/src/tablecaption.js +3 -3
- package/src/tablecellproperties/commands/tablecellbackgroundcolorcommand.d.ts +2 -2
- package/src/tablecellproperties/commands/tablecellbackgroundcolorcommand.js +2 -2
- package/src/tablecellproperties/commands/tablecellbordercolorcommand.d.ts +4 -4
- package/src/tablecellproperties/commands/tablecellbordercolorcommand.js +2 -2
- package/src/tablecellproperties/commands/tablecellborderstylecommand.d.ts +4 -4
- package/src/tablecellproperties/commands/tablecellborderstylecommand.js +2 -2
- package/src/tablecellproperties/commands/tablecellborderwidthcommand.d.ts +4 -4
- package/src/tablecellproperties/commands/tablecellborderwidthcommand.js +2 -2
- package/src/tablecellproperties/commands/tablecellheightcommand.d.ts +2 -2
- package/src/tablecellproperties/commands/tablecellheightcommand.js +2 -2
- package/src/tablecellproperties/commands/tablecellhorizontalalignmentcommand.d.ts +2 -2
- package/src/tablecellproperties/commands/tablecellhorizontalalignmentcommand.js +2 -2
- package/src/tablecellproperties/commands/tablecellpaddingcommand.d.ts +4 -4
- package/src/tablecellproperties/commands/tablecellpaddingcommand.js +2 -2
- package/src/tablecellproperties/commands/tablecellpropertycommand.d.ts +3 -3
- package/src/tablecellproperties/commands/tablecellpropertycommand.js +1 -1
- package/src/tablecellproperties/commands/tablecellverticalalignmentcommand.d.ts +2 -2
- package/src/tablecellproperties/commands/tablecellverticalalignmentcommand.js +2 -2
- package/src/tablecellproperties/tablecellpropertiesediting.d.ts +3 -3
- package/src/tablecellproperties/tablecellpropertiesediting.js +44 -19
- package/src/tablecellproperties/tablecellpropertiesui.d.ts +2 -2
- package/src/tablecellproperties/tablecellpropertiesui.js +2 -2
- package/src/tablecellproperties/ui/tablecellpropertiesview.d.ts +2 -2
- package/src/tablecellproperties/ui/tablecellpropertiesview.js +1 -1
- package/src/tablecellproperties.d.ts +3 -3
- package/src/tablecellproperties.js +3 -3
- package/src/tablecellwidth/commands/tablecellwidthcommand.d.ts +2 -2
- package/src/tablecellwidth/commands/tablecellwidthcommand.js +2 -2
- package/src/tablecellwidth/tablecellwidthediting.d.ts +2 -2
- package/src/tablecellwidth/tablecellwidthediting.js +5 -3
- package/src/tableclipboard.d.ts +6 -6
- package/src/tableclipboard.js +4 -4
- package/src/tablecolumnresize/constants.d.ts +9 -0
- package/src/tablecolumnresize/constants.js +9 -0
- package/src/tablecolumnresize/converters.d.ts +11 -1
- package/src/tablecolumnresize/converters.js +16 -0
- package/src/tablecolumnresize/tablecolumnresizeediting.d.ts +7 -7
- package/src/tablecolumnresize/tablecolumnresizeediting.js +13 -11
- package/src/tablecolumnresize/tablewidthscommand.d.ts +3 -3
- package/src/tablecolumnresize/tablewidthscommand.js +1 -1
- package/src/tablecolumnresize/utils.d.ts +23 -11
- package/src/tablecolumnresize/utils.js +14 -2
- package/src/tablecolumnresize.d.ts +3 -3
- package/src/tablecolumnresize.js +3 -3
- package/src/tableconfig.d.ts +3 -1
- package/src/tableediting.d.ts +7 -7
- package/src/tableediting.js +19 -19
- package/src/tablekeyboard.d.ts +8 -8
- package/src/tablekeyboard.js +7 -7
- package/src/tablelayout/commands/tabletypecommand.d.ts +1 -1
- package/src/tablelayout/commands/tabletypecommand.js +1 -1
- package/src/tablelayout/tablelayoutediting.d.ts +2 -2
- package/src/tablelayout/tablelayoutediting.js +4 -4
- package/src/tablelayout/tablelayoutui.d.ts +1 -1
- package/src/tablelayout/tablelayoutui.js +4 -4
- package/src/tablelayout.d.ts +5 -5
- package/src/tablelayout.js +5 -5
- package/src/tablemouse/mouseeventsobserver.d.ts +13 -11
- package/src/tablemouse/mouseeventsobserver.js +4 -2
- package/src/tablemouse.d.ts +3 -3
- package/src/tablemouse.js +4 -4
- package/src/tableproperties/commands/tablealignmentcommand.d.ts +2 -2
- package/src/tableproperties/commands/tablealignmentcommand.js +2 -2
- package/src/tableproperties/commands/tablebackgroundcolorcommand.d.ts +2 -2
- package/src/tableproperties/commands/tablebackgroundcolorcommand.js +2 -2
- package/src/tableproperties/commands/tablebordercolorcommand.d.ts +4 -4
- package/src/tableproperties/commands/tablebordercolorcommand.js +2 -2
- package/src/tableproperties/commands/tableborderstylecommand.d.ts +4 -4
- package/src/tableproperties/commands/tableborderstylecommand.js +2 -2
- package/src/tableproperties/commands/tableborderwidthcommand.d.ts +4 -4
- package/src/tableproperties/commands/tableborderwidthcommand.js +2 -2
- package/src/tableproperties/commands/tableheightcommand.d.ts +2 -2
- package/src/tableproperties/commands/tableheightcommand.js +2 -2
- package/src/tableproperties/commands/tablepropertycommand.d.ts +4 -4
- package/src/tableproperties/commands/tablepropertycommand.js +1 -1
- package/src/tableproperties/commands/tablewidthcommand.d.ts +2 -2
- package/src/tableproperties/commands/tablewidthcommand.js +2 -2
- package/src/tableproperties/tablepropertiesediting.d.ts +2 -2
- package/src/tableproperties/tablepropertiesediting.js +49 -21
- package/src/tableproperties/tablepropertiesui.d.ts +2 -2
- package/src/tableproperties/tablepropertiesui.js +2 -2
- package/src/tableproperties/ui/tablepropertiesview.d.ts +2 -2
- package/src/tableproperties/ui/tablepropertiesview.js +1 -1
- package/src/tableproperties.d.ts +3 -3
- package/src/tableproperties.js +3 -3
- package/src/tableselection.d.ts +9 -9
- package/src/tableselection.js +4 -4
- package/src/tabletoolbar.d.ts +1 -1
- package/src/tabletoolbar.js +1 -1
- package/src/tableui.d.ts +1 -1
- package/src/tableui.js +4 -4
- package/src/tableutils.d.ts +25 -26
- package/src/tableutils.js +4 -4
- package/src/tablewalker.d.ts +8 -8
- package/src/tablewalker.js +2 -2
- package/src/ui/colorinputview.d.ts +6 -1
- package/src/ui/colorinputview.js +1 -1
- package/src/ui/inserttableview.d.ts +3 -1
- package/src/ui/inserttableview.js +3 -1
- package/src/utils/common.d.ts +16 -7
- package/src/utils/common.js +9 -1
- package/src/utils/structure.d.ts +24 -14
- package/src/utils/structure.js +11 -1
- package/src/utils/table-properties.d.ts +15 -2
- package/src/utils/table-properties.js +6 -0
- package/src/utils/ui/contextualballoon.d.ts +5 -3
- package/src/utils/ui/contextualballoon.js +2 -0
- package/src/utils/ui/table-properties.d.ts +20 -7
- package/src/utils/ui/table-properties.js +24 -11
- package/src/utils/ui/widget.d.ts +6 -0
- package/src/utils/ui/widget.js +6 -0
- package/theme/tablecaption.css +9 -8
- package/theme/tablecolumnresize.css +2 -2
package/src/tablewalker.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module table/tablewalker
|
|
7
7
|
*/
|
|
8
|
-
import type {
|
|
8
|
+
import type { ModelElement, ModelPosition } from 'ckeditor5/src/engine.js';
|
|
9
9
|
/**
|
|
10
10
|
* An object with configuration for `TableWalker`.
|
|
11
11
|
*/
|
|
@@ -43,13 +43,13 @@ export interface TableWalkerOptions {
|
|
|
43
43
|
* The table iterator class. It allows to iterate over table cells. For each cell the iterator yields
|
|
44
44
|
* {@link module:table/tablewalker~TableSlot} with proper table cell attributes.
|
|
45
45
|
*/
|
|
46
|
-
export
|
|
46
|
+
export declare class TableWalker implements IterableIterator<TableSlot> {
|
|
47
47
|
/**
|
|
48
48
|
* The walker's table element.
|
|
49
49
|
*
|
|
50
50
|
* @internal
|
|
51
51
|
*/
|
|
52
|
-
readonly _table:
|
|
52
|
+
readonly _table: ModelElement;
|
|
53
53
|
/**
|
|
54
54
|
* A row index from which this iterator will start.
|
|
55
55
|
*/
|
|
@@ -187,7 +187,7 @@ export default class TableWalker implements IterableIterator<TableSlot> {
|
|
|
187
187
|
* @param options.endColumn A column index at which this iterator should end. Can't be used together with `column`.
|
|
188
188
|
* @param options.includeAllSlots Also return values for spanned cells. Default value is "false".
|
|
189
189
|
*/
|
|
190
|
-
constructor(table:
|
|
190
|
+
constructor(table: ModelElement, options?: TableWalkerOptions);
|
|
191
191
|
/**
|
|
192
192
|
* Iterable interface.
|
|
193
193
|
*/
|
|
@@ -292,7 +292,7 @@ declare class TableSlot {
|
|
|
292
292
|
/**
|
|
293
293
|
* The current table cell.
|
|
294
294
|
*/
|
|
295
|
-
readonly cell:
|
|
295
|
+
readonly cell: ModelElement;
|
|
296
296
|
/**
|
|
297
297
|
* The row index of a table slot.
|
|
298
298
|
*/
|
|
@@ -329,7 +329,7 @@ declare class TableSlot {
|
|
|
329
329
|
* @param anchorRow The row index of a cell anchor slot.
|
|
330
330
|
* @param anchorColumn The column index of a cell anchor slot.
|
|
331
331
|
*/
|
|
332
|
-
constructor(tableWalker: TableWalker, cell:
|
|
332
|
+
constructor(tableWalker: TableWalker, cell: ModelElement, anchorRow: number, anchorColumn: number);
|
|
333
333
|
/**
|
|
334
334
|
* Whether the cell is anchored in the current slot.
|
|
335
335
|
*/
|
|
@@ -347,9 +347,9 @@ declare class TableSlot {
|
|
|
347
347
|
*/
|
|
348
348
|
get rowIndex(): number;
|
|
349
349
|
/**
|
|
350
|
-
* Returns the {@link module:engine/model/position~
|
|
350
|
+
* Returns the {@link module:engine/model/position~ModelPosition} before the table slot.
|
|
351
351
|
*/
|
|
352
|
-
getPositionBefore():
|
|
352
|
+
getPositionBefore(): ModelPosition;
|
|
353
353
|
}
|
|
354
354
|
export type { TableSlot };
|
|
355
355
|
/**
|
package/src/tablewalker.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* The table iterator class. It allows to iterate over table cells. For each cell the iterator yields
|
|
7
7
|
* {@link module:table/tablewalker~TableSlot} with proper table cell attributes.
|
|
8
8
|
*/
|
|
9
|
-
export
|
|
9
|
+
export class TableWalker {
|
|
10
10
|
/**
|
|
11
11
|
* The walker's table element.
|
|
12
12
|
*
|
|
@@ -466,7 +466,7 @@ class TableSlot {
|
|
|
466
466
|
return this._rowIndex;
|
|
467
467
|
}
|
|
468
468
|
/**
|
|
469
|
-
* Returns the {@link module:engine/model/position~
|
|
469
|
+
* Returns the {@link module:engine/model/position~ModelPosition} before the table slot.
|
|
470
470
|
*/
|
|
471
471
|
getPositionBefore() {
|
|
472
472
|
const model = this._table.root.document.model;
|
|
@@ -8,6 +8,11 @@
|
|
|
8
8
|
import { View, InputTextView, FocusCycler, ViewCollection, type ColorDefinition, type DropdownView, type ColorPickerConfig, type FocusableView } from 'ckeditor5/src/ui.js';
|
|
9
9
|
import { FocusTracker, KeystrokeHandler, type Locale } from 'ckeditor5/src/utils.js';
|
|
10
10
|
import '../../theme/colorinput.css';
|
|
11
|
+
/**
|
|
12
|
+
* The options for the color input view.
|
|
13
|
+
*
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
11
16
|
export type ColorInputViewOptions = {
|
|
12
17
|
colorDefinitions: Array<ColorDefinition>;
|
|
13
18
|
columns: number;
|
|
@@ -20,7 +25,7 @@ export type ColorInputViewOptions = {
|
|
|
20
25
|
*
|
|
21
26
|
* @internal
|
|
22
27
|
*/
|
|
23
|
-
export
|
|
28
|
+
export declare class ColorInputView extends View implements FocusableView {
|
|
24
29
|
/**
|
|
25
30
|
* The value of the input.
|
|
26
31
|
*
|
package/src/ui/colorinputview.js
CHANGED
|
@@ -12,8 +12,10 @@ import './../../theme/inserttable.css';
|
|
|
12
12
|
* The table size view.
|
|
13
13
|
*
|
|
14
14
|
* It renders a 10x10 grid to choose the inserted table size.
|
|
15
|
+
*
|
|
16
|
+
* @internal
|
|
15
17
|
*/
|
|
16
|
-
export
|
|
18
|
+
export declare class InsertTableView extends View {
|
|
17
19
|
/**
|
|
18
20
|
* A collection of table size box items.
|
|
19
21
|
*/
|
|
@@ -12,8 +12,10 @@ import './../../theme/inserttable.css';
|
|
|
12
12
|
* The table size view.
|
|
13
13
|
*
|
|
14
14
|
* It renders a 10x10 grid to choose the inserted table size.
|
|
15
|
+
*
|
|
16
|
+
* @internal
|
|
15
17
|
*/
|
|
16
|
-
export
|
|
18
|
+
export class InsertTableView extends View {
|
|
17
19
|
/**
|
|
18
20
|
* A collection of table size box items.
|
|
19
21
|
*/
|
package/src/utils/common.d.ts
CHANGED
|
@@ -5,42 +5,51 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module table/utils/common
|
|
7
7
|
*/
|
|
8
|
-
import type { Conversion,
|
|
9
|
-
import type TableUtils from '../tableutils.js';
|
|
8
|
+
import type { Conversion, ModelElement, ModelItem, ModelPosition, ModelSchema, ModelWriter, ModelDocumentSelection } from 'ckeditor5/src/engine.js';
|
|
9
|
+
import { type TableUtils } from '../tableutils.js';
|
|
10
10
|
/**
|
|
11
11
|
* A common method to update the numeric value. If a value is the default one, it will be unset.
|
|
12
12
|
*
|
|
13
|
+
* @internal
|
|
13
14
|
* @param key An attribute key.
|
|
14
15
|
* @param value The new attribute value.
|
|
15
16
|
* @param item A model item on which the attribute will be set.
|
|
16
17
|
* @param defaultValue The default attribute value. If a value is lower or equal, it will be unset.
|
|
17
18
|
*/
|
|
18
|
-
export declare function updateNumericAttribute(key: string, value: unknown, item:
|
|
19
|
+
export declare function updateNumericAttribute(key: string, value: unknown, item: ModelItem, writer: ModelWriter, defaultValue?: unknown): void;
|
|
19
20
|
/**
|
|
20
21
|
* A common method to create an empty table cell. It creates a proper model structure as a table cell must have at least one block inside.
|
|
21
22
|
*
|
|
23
|
+
* @internal
|
|
22
24
|
* @param writer The model writer.
|
|
23
25
|
* @param insertPosition The position at which the table cell should be inserted.
|
|
24
26
|
* @param attributes The element attributes.
|
|
25
27
|
* @returns Created table cell.
|
|
26
28
|
*/
|
|
27
|
-
export declare function createEmptyTableCell(writer:
|
|
29
|
+
export declare function createEmptyTableCell(writer: ModelWriter, insertPosition: ModelPosition, attributes?: Record<string, unknown>): ModelElement;
|
|
28
30
|
/**
|
|
29
31
|
* Checks if a table cell belongs to the heading column section.
|
|
32
|
+
*
|
|
33
|
+
* @internal
|
|
30
34
|
*/
|
|
31
|
-
export declare function isHeadingColumnCell(tableUtils: TableUtils, tableCell:
|
|
35
|
+
export declare function isHeadingColumnCell(tableUtils: TableUtils, tableCell: ModelElement): boolean;
|
|
32
36
|
/**
|
|
33
37
|
* Enables conversion for an attribute for simple view-model mappings.
|
|
34
38
|
*
|
|
39
|
+
* @internal
|
|
35
40
|
* @param options.defaultValue The default value for the specified `modelAttribute`.
|
|
36
41
|
*/
|
|
37
|
-
export declare function enableProperty(schema:
|
|
42
|
+
export declare function enableProperty(schema: ModelSchema, conversion: Conversion, options: {
|
|
38
43
|
modelAttribute: string;
|
|
39
44
|
styleName: string;
|
|
45
|
+
attributeName?: string;
|
|
46
|
+
attributeType?: 'length' | 'color';
|
|
40
47
|
defaultValue: string;
|
|
41
48
|
reduceBoxSides?: boolean;
|
|
42
49
|
}): void;
|
|
43
50
|
/**
|
|
44
51
|
* Depending on the position of the selection we either return the table under cursor or look for the table higher in the hierarchy.
|
|
52
|
+
*
|
|
53
|
+
* @internal
|
|
45
54
|
*/
|
|
46
|
-
export declare function getSelectionAffectedTable(selection:
|
|
55
|
+
export declare function getSelectionAffectedTable(selection: ModelDocumentSelection): ModelElement;
|
package/src/utils/common.js
CHANGED
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
4
|
*/
|
|
5
|
-
import { downcastAttributeToStyle, upcastStyleToAttribute } from '
|
|
5
|
+
import { downcastAttributeToStyle, upcastStyleToAttribute } from '../converters/tableproperties.js';
|
|
6
6
|
/**
|
|
7
7
|
* A common method to update the numeric value. If a value is the default one, it will be unset.
|
|
8
8
|
*
|
|
9
|
+
* @internal
|
|
9
10
|
* @param key An attribute key.
|
|
10
11
|
* @param value The new attribute value.
|
|
11
12
|
* @param item A model item on which the attribute will be set.
|
|
@@ -22,6 +23,7 @@ export function updateNumericAttribute(key, value, item, writer, defaultValue =
|
|
|
22
23
|
/**
|
|
23
24
|
* A common method to create an empty table cell. It creates a proper model structure as a table cell must have at least one block inside.
|
|
24
25
|
*
|
|
26
|
+
* @internal
|
|
25
27
|
* @param writer The model writer.
|
|
26
28
|
* @param insertPosition The position at which the table cell should be inserted.
|
|
27
29
|
* @param attributes The element attributes.
|
|
@@ -35,6 +37,8 @@ export function createEmptyTableCell(writer, insertPosition, attributes = {}) {
|
|
|
35
37
|
}
|
|
36
38
|
/**
|
|
37
39
|
* Checks if a table cell belongs to the heading column section.
|
|
40
|
+
*
|
|
41
|
+
* @internal
|
|
38
42
|
*/
|
|
39
43
|
export function isHeadingColumnCell(tableUtils, tableCell) {
|
|
40
44
|
const table = tableCell.parent.parent;
|
|
@@ -45,6 +49,7 @@ export function isHeadingColumnCell(tableUtils, tableCell) {
|
|
|
45
49
|
/**
|
|
46
50
|
* Enables conversion for an attribute for simple view-model mappings.
|
|
47
51
|
*
|
|
52
|
+
* @internal
|
|
48
53
|
* @param options.defaultValue The default value for the specified `modelAttribute`.
|
|
49
54
|
*/
|
|
50
55
|
export function enableProperty(schema, conversion, options) {
|
|
@@ -52,11 +57,14 @@ export function enableProperty(schema, conversion, options) {
|
|
|
52
57
|
schema.extend('tableCell', {
|
|
53
58
|
allowAttributes: [modelAttribute]
|
|
54
59
|
});
|
|
60
|
+
schema.setAttributeProperties(modelAttribute, { isFormatting: true });
|
|
55
61
|
upcastStyleToAttribute(conversion, { viewElement: /^(td|th)$/, ...options });
|
|
56
62
|
downcastAttributeToStyle(conversion, { modelElement: 'tableCell', ...options });
|
|
57
63
|
}
|
|
58
64
|
/**
|
|
59
65
|
* Depending on the position of the selection we either return the table under cursor or look for the table higher in the hierarchy.
|
|
66
|
+
*
|
|
67
|
+
* @internal
|
|
60
68
|
*/
|
|
61
69
|
export function getSelectionAffectedTable(selection) {
|
|
62
70
|
const selectedElement = selection.getSelectedElement();
|
package/src/utils/structure.d.ts
CHANGED
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module table/utils/structure
|
|
7
7
|
*/
|
|
8
|
-
import type {
|
|
8
|
+
import type { ModelElement, ModelWriter } from 'ckeditor5/src/engine.js';
|
|
9
9
|
import { type TableSlot } from '../tablewalker.js';
|
|
10
|
-
import type TableUtils from '../tableutils.js';
|
|
10
|
+
import { type TableUtils } from '../tableutils.js';
|
|
11
11
|
/**
|
|
12
12
|
* Returns a cropped table according to given dimensions.
|
|
13
13
|
|
|
@@ -36,13 +36,15 @@ import type TableUtils from '../tableutils.js';
|
|
|
36
36
|
* ├───┼───┬───┤ ├───┤ └───────┴───┘
|
|
37
37
|
* 4 │ n │ o │ p │ │ q │
|
|
38
38
|
* └───┴───┴───┴───┴───┘
|
|
39
|
+
*
|
|
40
|
+
* @internal
|
|
39
41
|
*/
|
|
40
|
-
export declare function cropTableToDimensions(sourceTable:
|
|
42
|
+
export declare function cropTableToDimensions(sourceTable: ModelElement, cropDimensions: {
|
|
41
43
|
startRow: number;
|
|
42
44
|
startColumn: number;
|
|
43
45
|
endRow: number;
|
|
44
46
|
endColumn: number;
|
|
45
|
-
}, writer:
|
|
47
|
+
}, writer: ModelWriter): ModelElement;
|
|
46
48
|
/**
|
|
47
49
|
* Returns slot info of cells that starts above and overlaps a given row.
|
|
48
50
|
*
|
|
@@ -62,17 +64,19 @@ export declare function cropTableToDimensions(sourceTable: Element, cropDimensio
|
|
|
62
64
|
*
|
|
63
65
|
* will return slot info for cells: "j", "f", "k".
|
|
64
66
|
*
|
|
67
|
+
* @internal
|
|
65
68
|
* @param table The table to check.
|
|
66
69
|
* @param overlapRow The index of the row to check.
|
|
67
70
|
* @param startRow row to start analysis. Use it when it is known that the cells above that row will not overlap. Default value is 0.
|
|
68
71
|
*/
|
|
69
|
-
export declare function getVerticallyOverlappingCells(table:
|
|
72
|
+
export declare function getVerticallyOverlappingCells(table: ModelElement, overlapRow: number, startRow?: number): Array<TableSlot>;
|
|
70
73
|
/**
|
|
71
74
|
* Splits the table cell horizontally.
|
|
72
75
|
*
|
|
76
|
+
* @internal
|
|
73
77
|
* @returns Created table cell, if any were created.
|
|
74
78
|
*/
|
|
75
|
-
export declare function splitHorizontally(tableCell:
|
|
79
|
+
export declare function splitHorizontally(tableCell: ModelElement, splitRow: number, writer: ModelWriter): ModelElement | null;
|
|
76
80
|
/**
|
|
77
81
|
* Returns slot info of cells that starts before and overlaps a given column.
|
|
78
82
|
*
|
|
@@ -95,25 +99,29 @@ export declare function splitHorizontally(tableCell: Element, splitRow: number,
|
|
|
95
99
|
*
|
|
96
100
|
* will return slot info for cells: "b", "e", "i".
|
|
97
101
|
*
|
|
102
|
+
* @internal
|
|
98
103
|
* @param table The table to check.
|
|
99
104
|
* @param overlapColumn The index of the column to check.
|
|
100
105
|
*/
|
|
101
|
-
export declare function getHorizontallyOverlappingCells(table:
|
|
106
|
+
export declare function getHorizontallyOverlappingCells(table: ModelElement, overlapColumn: number): Array<TableSlot>;
|
|
102
107
|
/**
|
|
103
108
|
* Splits the table cell vertically.
|
|
104
109
|
*
|
|
110
|
+
* @internal
|
|
105
111
|
* @param columnIndex The table cell column index.
|
|
106
112
|
* @param splitColumn The index of column to split cell on.
|
|
107
113
|
* @returns Created table cell.
|
|
108
114
|
*/
|
|
109
|
-
export declare function splitVertically(tableCell:
|
|
115
|
+
export declare function splitVertically(tableCell: ModelElement, columnIndex: number, splitColumn: number, writer: ModelWriter): ModelElement;
|
|
110
116
|
/**
|
|
111
117
|
* Adjusts table cell dimensions to not exceed limit row and column.
|
|
112
118
|
*
|
|
113
119
|
* If table cell width (or height) covers a column (or row) that is after a limit column (or row)
|
|
114
120
|
* this method will trim "colspan" (or "rowspan") attribute so the table cell will fit in a defined limits.
|
|
121
|
+
*
|
|
122
|
+
* @internal
|
|
115
123
|
*/
|
|
116
|
-
export declare function trimTableCellIfNeeded(tableCell:
|
|
124
|
+
export declare function trimTableCellIfNeeded(tableCell: ModelElement, cellRow: number, cellColumn: number, limitRow: number, limitColumn: number, writer: ModelWriter): void;
|
|
117
125
|
/**
|
|
118
126
|
* Removes columns that have no cells anchored.
|
|
119
127
|
*
|
|
@@ -136,7 +144,7 @@ export declare function trimTableCellIfNeeded(tableCell: Element, cellRow: numbe
|
|
|
136
144
|
* @internal
|
|
137
145
|
* @returns True if removed some columns.
|
|
138
146
|
*/
|
|
139
|
-
export declare function removeEmptyColumns(table:
|
|
147
|
+
export declare function removeEmptyColumns(table: ModelElement, tableUtils: TableUtils): boolean;
|
|
140
148
|
/**
|
|
141
149
|
* Removes rows that have no cells anchored.
|
|
142
150
|
*
|
|
@@ -166,7 +174,7 @@ export declare function removeEmptyColumns(table: Element, tableUtils: TableUtil
|
|
|
166
174
|
* @internal
|
|
167
175
|
* @returns True if removed some rows.
|
|
168
176
|
*/
|
|
169
|
-
export declare function removeEmptyRows(table:
|
|
177
|
+
export declare function removeEmptyRows(table: ModelElement, tableUtils: TableUtils): boolean;
|
|
170
178
|
/**
|
|
171
179
|
* Removes rows and columns that have no cells anchored.
|
|
172
180
|
*
|
|
@@ -191,7 +199,7 @@ export declare function removeEmptyRows(table: Element, tableUtils: TableUtils):
|
|
|
191
199
|
*
|
|
192
200
|
* @internal
|
|
193
201
|
*/
|
|
194
|
-
export declare function removeEmptyRowsColumns(table:
|
|
202
|
+
export declare function removeEmptyRowsColumns(table: ModelElement, tableUtils: TableUtils): void;
|
|
195
203
|
/**
|
|
196
204
|
* Returns adjusted last row index if selection covers part of a row with empty slots (spanned by other cells).
|
|
197
205
|
* The `dimensions.lastRow` is equal to last row index but selection might be bigger.
|
|
@@ -208,9 +216,10 @@ export declare function removeEmptyRowsColumns(table: Element, tableUtils: Table
|
|
|
208
216
|
* 3 | | | | |
|
|
209
217
|
* +---+---+---+---+
|
|
210
218
|
*
|
|
219
|
+
* @internal
|
|
211
220
|
* @returns Adjusted last row index.
|
|
212
221
|
*/
|
|
213
|
-
export declare function adjustLastRowIndex(table:
|
|
222
|
+
export declare function adjustLastRowIndex(table: ModelElement, dimensions: {
|
|
214
223
|
firstRow: number;
|
|
215
224
|
firstColumn: number;
|
|
216
225
|
lastRow: number;
|
|
@@ -235,9 +244,10 @@ export declare function adjustLastRowIndex(table: Element, dimensions: {
|
|
|
235
244
|
* ^
|
|
236
245
|
* last column, each cell has colspan = 2, so we need to return 3, not 2
|
|
237
246
|
*
|
|
247
|
+
* @internal
|
|
238
248
|
* @returns Adjusted last column index.
|
|
239
249
|
*/
|
|
240
|
-
export declare function adjustLastColumnIndex(table:
|
|
250
|
+
export declare function adjustLastColumnIndex(table: ModelElement, dimensions: {
|
|
241
251
|
firstRow: number;
|
|
242
252
|
firstColumn: number;
|
|
243
253
|
lastRow: number;
|
package/src/utils/structure.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
5
|
+
import { TableWalker } from '../tablewalker.js';
|
|
6
6
|
import { createEmptyTableCell, updateNumericAttribute } from './common.js';
|
|
7
7
|
/**
|
|
8
8
|
* Returns a cropped table according to given dimensions.
|
|
@@ -32,6 +32,8 @@ import { createEmptyTableCell, updateNumericAttribute } from './common.js';
|
|
|
32
32
|
* ├───┼───┬───┤ ├───┤ └───────┴───┘
|
|
33
33
|
* 4 │ n │ o │ p │ │ q │
|
|
34
34
|
* └───┴───┴───┴───┴───┘
|
|
35
|
+
*
|
|
36
|
+
* @internal
|
|
35
37
|
*/
|
|
36
38
|
export function cropTableToDimensions(sourceTable, cropDimensions, writer) {
|
|
37
39
|
const { startRow, startColumn, endRow, endColumn } = cropDimensions;
|
|
@@ -93,6 +95,7 @@ export function cropTableToDimensions(sourceTable, cropDimensions, writer) {
|
|
|
93
95
|
*
|
|
94
96
|
* will return slot info for cells: "j", "f", "k".
|
|
95
97
|
*
|
|
98
|
+
* @internal
|
|
96
99
|
* @param table The table to check.
|
|
97
100
|
* @param overlapRow The index of the row to check.
|
|
98
101
|
* @param startRow row to start analysis. Use it when it is known that the cells above that row will not overlap. Default value is 0.
|
|
@@ -112,6 +115,7 @@ export function getVerticallyOverlappingCells(table, overlapRow, startRow = 0) {
|
|
|
112
115
|
/**
|
|
113
116
|
* Splits the table cell horizontally.
|
|
114
117
|
*
|
|
118
|
+
* @internal
|
|
115
119
|
* @returns Created table cell, if any were created.
|
|
116
120
|
*/
|
|
117
121
|
export function splitHorizontally(tableCell, splitRow, writer) {
|
|
@@ -169,6 +173,7 @@ export function splitHorizontally(tableCell, splitRow, writer) {
|
|
|
169
173
|
*
|
|
170
174
|
* will return slot info for cells: "b", "e", "i".
|
|
171
175
|
*
|
|
176
|
+
* @internal
|
|
172
177
|
* @param table The table to check.
|
|
173
178
|
* @param overlapColumn The index of the column to check.
|
|
174
179
|
*/
|
|
@@ -187,6 +192,7 @@ export function getHorizontallyOverlappingCells(table, overlapColumn) {
|
|
|
187
192
|
/**
|
|
188
193
|
* Splits the table cell vertically.
|
|
189
194
|
*
|
|
195
|
+
* @internal
|
|
190
196
|
* @param columnIndex The table cell column index.
|
|
191
197
|
* @param splitColumn The index of column to split cell on.
|
|
192
198
|
* @returns Created table cell.
|
|
@@ -213,6 +219,8 @@ export function splitVertically(tableCell, columnIndex, splitColumn, writer) {
|
|
|
213
219
|
*
|
|
214
220
|
* If table cell width (or height) covers a column (or row) that is after a limit column (or row)
|
|
215
221
|
* this method will trim "colspan" (or "rowspan") attribute so the table cell will fit in a defined limits.
|
|
222
|
+
*
|
|
223
|
+
* @internal
|
|
216
224
|
*/
|
|
217
225
|
export function trimTableCellIfNeeded(tableCell, cellRow, cellColumn, limitRow, limitColumn, writer) {
|
|
218
226
|
const colspan = parseInt(tableCell.getAttribute('colspan') || '1');
|
|
@@ -377,6 +385,7 @@ export function removeEmptyRowsColumns(table, tableUtils) {
|
|
|
377
385
|
* 3 | | | | |
|
|
378
386
|
* +---+---+---+---+
|
|
379
387
|
*
|
|
388
|
+
* @internal
|
|
380
389
|
* @returns Adjusted last row index.
|
|
381
390
|
*/
|
|
382
391
|
export function adjustLastRowIndex(table, dimensions) {
|
|
@@ -413,6 +422,7 @@ export function adjustLastRowIndex(table, dimensions) {
|
|
|
413
422
|
* ^
|
|
414
423
|
* last column, each cell has colspan = 2, so we need to return 3, not 2
|
|
415
424
|
*
|
|
425
|
+
* @internal
|
|
416
426
|
* @returns Adjusted last column index.
|
|
417
427
|
*/
|
|
418
428
|
export function adjustLastColumnIndex(table, dimensions) {
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module table/utils/table-properties
|
|
7
7
|
*/
|
|
8
|
-
import type {
|
|
8
|
+
import type { BoxStyleSides } from 'ckeditor5/src/engine.js';
|
|
9
9
|
/**
|
|
10
10
|
* Returns a string if all four values of box sides are equal.
|
|
11
11
|
*
|
|
@@ -20,8 +20,10 @@ import type { BoxSides } from 'ckeditor5/src/engine.js';
|
|
|
20
20
|
* getSingleValue( { top: 'foo', right: 'foo', bottom: 'bar', left: 'foo' } );
|
|
21
21
|
* getSingleValue( { top: 'foo', right: 'foo' } );
|
|
22
22
|
* ```
|
|
23
|
+
*
|
|
24
|
+
* @internal
|
|
23
25
|
*/
|
|
24
|
-
export declare function getSingleValue(objectOrString:
|
|
26
|
+
export declare function getSingleValue(objectOrString: BoxStyleSides | string | undefined): string | undefined;
|
|
25
27
|
/**
|
|
26
28
|
* Adds a unit to a value if the value is a number or a string representing a number.
|
|
27
29
|
*
|
|
@@ -34,9 +36,15 @@ export declare function getSingleValue(objectOrString: BoxSides | string | undef
|
|
|
34
36
|
* getSingleValue( 'foo', 'px' ); // 'foo'
|
|
35
37
|
* ```
|
|
36
38
|
*
|
|
39
|
+
* @internal
|
|
37
40
|
* @param defaultUnit A default unit added to a numeric value.
|
|
38
41
|
*/
|
|
39
42
|
export declare function addDefaultUnitToNumericValue(value: string | number | undefined, defaultUnit: string): string | number | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Interface representing the normalized default properties for table and cell elements.
|
|
45
|
+
*
|
|
46
|
+
* @internal
|
|
47
|
+
*/
|
|
40
48
|
export interface NormalizedDefaultProperties {
|
|
41
49
|
borderStyle: string;
|
|
42
50
|
borderWidth: string;
|
|
@@ -51,6 +59,8 @@ export interface NormalizedDefaultProperties {
|
|
|
51
59
|
}
|
|
52
60
|
/**
|
|
53
61
|
* Options used to determine which properties should be added to the normalized configuration.
|
|
62
|
+
*
|
|
63
|
+
* @internal
|
|
54
64
|
*/
|
|
55
65
|
export type NormalizeTableDefaultPropertiesOptions = {
|
|
56
66
|
/**
|
|
@@ -77,6 +87,7 @@ export type NormalizeTableDefaultPropertiesOptions = {
|
|
|
77
87
|
/**
|
|
78
88
|
* Returns the normalized configuration.
|
|
79
89
|
*
|
|
90
|
+
* @internal
|
|
80
91
|
* @param config The configuration to normalize.
|
|
81
92
|
* @param options Options used to determine which properties should be added.
|
|
82
93
|
*/
|
|
@@ -84,6 +95,7 @@ export declare function getNormalizedDefaultProperties(config?: Partial<Normaliz
|
|
|
84
95
|
/**
|
|
85
96
|
* Returns the normalized default table properties.
|
|
86
97
|
*
|
|
98
|
+
* @internal
|
|
87
99
|
* @param config The configuration to normalize.
|
|
88
100
|
* @param options Options used to determine which properties should be added.
|
|
89
101
|
*/
|
|
@@ -91,6 +103,7 @@ export declare function getNormalizedDefaultTableProperties(config?: Partial<Nor
|
|
|
91
103
|
/**
|
|
92
104
|
* Returns the normalized default cell properties.
|
|
93
105
|
*
|
|
106
|
+
* @internal
|
|
94
107
|
* @param config The configuration to normalize.
|
|
95
108
|
* @param options Options used to determine which properties should be added.
|
|
96
109
|
*/
|
|
@@ -17,6 +17,8 @@ import { isObject } from 'es-toolkit/compat';
|
|
|
17
17
|
* getSingleValue( { top: 'foo', right: 'foo', bottom: 'bar', left: 'foo' } );
|
|
18
18
|
* getSingleValue( { top: 'foo', right: 'foo' } );
|
|
19
19
|
* ```
|
|
20
|
+
*
|
|
21
|
+
* @internal
|
|
20
22
|
*/
|
|
21
23
|
export function getSingleValue(objectOrString) {
|
|
22
24
|
if (!objectOrString || !isObject(objectOrString)) {
|
|
@@ -39,6 +41,7 @@ export function getSingleValue(objectOrString) {
|
|
|
39
41
|
* getSingleValue( 'foo', 'px' ); // 'foo'
|
|
40
42
|
* ```
|
|
41
43
|
*
|
|
44
|
+
* @internal
|
|
42
45
|
* @param defaultUnit A default unit added to a numeric value.
|
|
43
46
|
*/
|
|
44
47
|
export function addDefaultUnitToNumericValue(value, defaultUnit) {
|
|
@@ -54,6 +57,7 @@ export function addDefaultUnitToNumericValue(value, defaultUnit) {
|
|
|
54
57
|
/**
|
|
55
58
|
* Returns the normalized configuration.
|
|
56
59
|
*
|
|
60
|
+
* @internal
|
|
57
61
|
* @param config The configuration to normalize.
|
|
58
62
|
* @param options Options used to determine which properties should be added.
|
|
59
63
|
*/
|
|
@@ -84,6 +88,7 @@ export function getNormalizedDefaultProperties(config, options = {}) {
|
|
|
84
88
|
/**
|
|
85
89
|
* Returns the normalized default table properties.
|
|
86
90
|
*
|
|
91
|
+
* @internal
|
|
87
92
|
* @param config The configuration to normalize.
|
|
88
93
|
* @param options Options used to determine which properties should be added.
|
|
89
94
|
*/
|
|
@@ -100,6 +105,7 @@ export function getNormalizedDefaultTableProperties(config, options) {
|
|
|
100
105
|
/**
|
|
101
106
|
* Returns the normalized default cell properties.
|
|
102
107
|
*
|
|
108
|
+
* @internal
|
|
103
109
|
* @param config The configuration to normalize.
|
|
104
110
|
* @param options Options used to determine which properties should be added.
|
|
105
111
|
*/
|
|
@@ -5,13 +5,14 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module table/utils/ui/contextualballoon
|
|
7
7
|
*/
|
|
8
|
-
import { type
|
|
8
|
+
import { type DomOptimalPositionOptions } from 'ckeditor5/src/utils.js';
|
|
9
9
|
import type { Editor } from 'ckeditor5/src/core.js';
|
|
10
10
|
/**
|
|
11
11
|
* A helper utility that positions the
|
|
12
12
|
* {@link module:ui/panel/balloon/contextualballoon~ContextualBalloon contextual balloon} instance
|
|
13
13
|
* with respect to the table in the editor content, if one is selected.
|
|
14
14
|
*
|
|
15
|
+
* @internal
|
|
15
16
|
* @param editor The editor instance.
|
|
16
17
|
* @param target Either "cell" or "table". Determines the target the balloon will be attached to.
|
|
17
18
|
*/
|
|
@@ -23,12 +24,13 @@ export declare function repositionContextualBalloon(editor: Editor, target: stri
|
|
|
23
24
|
*
|
|
24
25
|
* @param editor The editor instance.
|
|
25
26
|
*/
|
|
26
|
-
export declare function getBalloonTablePositionData(editor: Editor): Partial<
|
|
27
|
+
export declare function getBalloonTablePositionData(editor: Editor): Partial<DomOptimalPositionOptions>;
|
|
27
28
|
/**
|
|
28
29
|
* Returns the positioning options that control the geometry of the
|
|
29
30
|
* {@link module:ui/panel/balloon/contextualballoon~ContextualBalloon contextual balloon} with respect
|
|
30
31
|
* to the selected table cell in the editor content.
|
|
31
32
|
*
|
|
32
33
|
* @param editor The editor instance.
|
|
34
|
+
* @internal
|
|
33
35
|
*/
|
|
34
|
-
export declare function getBalloonCellPositionData(editor: Editor): Partial<
|
|
36
|
+
export declare function getBalloonCellPositionData(editor: Editor): Partial<DomOptimalPositionOptions>;
|
|
@@ -23,6 +23,7 @@ const BALLOON_POSITIONS = /* #__PURE__ */ (() => [
|
|
|
23
23
|
* {@link module:ui/panel/balloon/contextualballoon~ContextualBalloon contextual balloon} instance
|
|
24
24
|
* with respect to the table in the editor content, if one is selected.
|
|
25
25
|
*
|
|
26
|
+
* @internal
|
|
26
27
|
* @param editor The editor instance.
|
|
27
28
|
* @param target Either "cell" or "table". Determines the target the balloon will be attached to.
|
|
28
29
|
*/
|
|
@@ -64,6 +65,7 @@ export function getBalloonTablePositionData(editor) {
|
|
|
64
65
|
* to the selected table cell in the editor content.
|
|
65
66
|
*
|
|
66
67
|
* @param editor The editor instance.
|
|
68
|
+
* @internal
|
|
67
69
|
*/
|
|
68
70
|
export function getBalloonCellPositionData(editor) {
|
|
69
71
|
const mapper = editor.editing.mapper;
|