@ckeditor/ckeditor5-table 32.0.0 → 33.0.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 +2 -2
- package/build/table.js.map +1 -0
- package/build/translations/el.js +1 -0
- package/build/translations/es.js +1 -1
- package/lang/translations/el.po +261 -0
- package/lang/translations/es.po +32 -32
- package/package.json +23 -21
- package/src/commands/insertcolumncommand.js +4 -4
- package/src/commands/insertrowcommand.js +4 -4
- package/src/commands/mergecellcommand.js +4 -5
- package/src/commands/mergecellscommand.js +5 -4
- package/src/commands/removecolumncommand.js +8 -7
- package/src/commands/removerowcommand.js +5 -6
- package/src/commands/selectcolumncommand.js +4 -4
- package/src/commands/selectrowcommand.js +5 -5
- package/src/commands/setheadercolumncommand.js +5 -4
- package/src/commands/setheaderrowcommand.js +7 -4
- package/src/commands/splitcellcommand.js +4 -4
- package/src/converters/downcast.js +76 -407
- package/src/converters/{table-cell-refresh-post-fixer.js → table-cell-refresh-handler.js} +8 -19
- package/src/converters/table-headings-refresh-handler.js +68 -0
- package/src/plaintableoutput.js +151 -0
- package/src/tablecellproperties/commands/tablecellpropertycommand.js +4 -3
- package/src/tableclipboard.js +18 -15
- package/src/tableediting.js +48 -27
- package/src/tablekeyboard.js +6 -5
- package/src/tablemouse.js +6 -4
- package/src/tableselection.js +9 -8
- package/src/tableutils.js +310 -0
- package/theme/table.css +1 -1
- package/src/converters/table-heading-rows-refresh-post-fixer.js +0 -72
- package/src/utils/selection.js +0 -276
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
import { Command } from 'ckeditor5/src/core';
|
|
11
11
|
|
|
12
12
|
import TableWalker from '../tablewalker';
|
|
13
|
-
import { getColumnIndexes, getSelectionAffectedTableCells } from '../utils/selection';
|
|
14
13
|
|
|
15
14
|
/**
|
|
16
15
|
* The remove column command.
|
|
@@ -28,14 +27,15 @@ export default class RemoveColumnCommand extends Command {
|
|
|
28
27
|
* @inheritDoc
|
|
29
28
|
*/
|
|
30
29
|
refresh() {
|
|
31
|
-
const
|
|
30
|
+
const tableUtils = this.editor.plugins.get( 'TableUtils' );
|
|
31
|
+
const selectedCells = tableUtils.getSelectionAffectedTableCells( this.editor.model.document.selection );
|
|
32
32
|
const firstCell = selectedCells[ 0 ];
|
|
33
33
|
|
|
34
34
|
if ( firstCell ) {
|
|
35
35
|
const table = firstCell.findAncestor( 'table' );
|
|
36
|
-
const tableColumnCount =
|
|
36
|
+
const tableColumnCount = tableUtils.getColumns( table );
|
|
37
37
|
|
|
38
|
-
const { first, last } = getColumnIndexes( selectedCells );
|
|
38
|
+
const { first, last } = tableUtils.getColumnIndexes( selectedCells );
|
|
39
39
|
|
|
40
40
|
this.isEnabled = last - first < ( tableColumnCount - 1 );
|
|
41
41
|
} else {
|
|
@@ -47,7 +47,8 @@ export default class RemoveColumnCommand extends Command {
|
|
|
47
47
|
* @inheritDoc
|
|
48
48
|
*/
|
|
49
49
|
execute() {
|
|
50
|
-
const
|
|
50
|
+
const tableUtils = this.editor.plugins.get( 'TableUtils' );
|
|
51
|
+
const [ firstCell, lastCell ] = getBoundaryCells( this.editor.model.document.selection, tableUtils );
|
|
51
52
|
const table = firstCell.parent.parent;
|
|
52
53
|
|
|
53
54
|
// Cache the table before removing or updating colspans.
|
|
@@ -111,8 +112,8 @@ function getCellToFocus( tableMap, firstCell, lastCell, removedColumnIndexes ) {
|
|
|
111
112
|
}
|
|
112
113
|
|
|
113
114
|
// Returns helper object returning the first and the last cell contained in given selection, based on DOM order.
|
|
114
|
-
function getBoundaryCells( selection ) {
|
|
115
|
-
const referenceCells = getSelectionAffectedTableCells( selection );
|
|
115
|
+
function getBoundaryCells( selection, tableUtils ) {
|
|
116
|
+
const referenceCells = tableUtils.getSelectionAffectedTableCells( selection );
|
|
116
117
|
const firstCell = referenceCells[ 0 ];
|
|
117
118
|
const lastCell = referenceCells.pop();
|
|
118
119
|
|
|
@@ -9,8 +9,6 @@
|
|
|
9
9
|
|
|
10
10
|
import { Command } from 'ckeditor5/src/core';
|
|
11
11
|
|
|
12
|
-
import { getRowIndexes, getSelectionAffectedTableCells } from '../utils/selection';
|
|
13
|
-
|
|
14
12
|
/**
|
|
15
13
|
* The remove row command.
|
|
16
14
|
*
|
|
@@ -27,7 +25,8 @@ export default class RemoveRowCommand extends Command {
|
|
|
27
25
|
* @inheritDoc
|
|
28
26
|
*/
|
|
29
27
|
refresh() {
|
|
30
|
-
const
|
|
28
|
+
const tableUtils = this.editor.plugins.get( 'TableUtils' );
|
|
29
|
+
const selectedCells = tableUtils.getSelectionAffectedTableCells( this.editor.model.document.selection );
|
|
31
30
|
const firstCell = selectedCells[ 0 ];
|
|
32
31
|
|
|
33
32
|
if ( firstCell ) {
|
|
@@ -35,7 +34,7 @@ export default class RemoveRowCommand extends Command {
|
|
|
35
34
|
const tableRowCount = this.editor.plugins.get( 'TableUtils' ).getRows( table );
|
|
36
35
|
const lastRowIndex = tableRowCount - 1;
|
|
37
36
|
|
|
38
|
-
const selectedRowIndexes = getRowIndexes( selectedCells );
|
|
37
|
+
const selectedRowIndexes = tableUtils.getRowIndexes( selectedCells );
|
|
39
38
|
|
|
40
39
|
const areAllRowsSelected = selectedRowIndexes.first === 0 && selectedRowIndexes.last === lastRowIndex;
|
|
41
40
|
|
|
@@ -53,8 +52,8 @@ export default class RemoveRowCommand extends Command {
|
|
|
53
52
|
const model = this.editor.model;
|
|
54
53
|
const tableUtils = this.editor.plugins.get( 'TableUtils' );
|
|
55
54
|
|
|
56
|
-
const referenceCells = getSelectionAffectedTableCells( model.document.selection );
|
|
57
|
-
const removedRowIndexes = getRowIndexes( referenceCells );
|
|
55
|
+
const referenceCells = tableUtils.getSelectionAffectedTableCells( model.document.selection );
|
|
56
|
+
const removedRowIndexes = tableUtils.getRowIndexes( referenceCells );
|
|
58
57
|
|
|
59
58
|
const firstCell = referenceCells[ 0 ];
|
|
60
59
|
const table = firstCell.findAncestor( 'table' );
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
import { Command } from 'ckeditor5/src/core';
|
|
11
11
|
|
|
12
12
|
import TableWalker from '../tablewalker';
|
|
13
|
-
import { getSelectionAffectedTableCells } from '../utils/selection';
|
|
14
13
|
|
|
15
14
|
/**
|
|
16
15
|
* The select column command.
|
|
@@ -38,7 +37,8 @@ export default class SelectColumnCommand extends Command {
|
|
|
38
37
|
* @inheritDoc
|
|
39
38
|
*/
|
|
40
39
|
refresh() {
|
|
41
|
-
const
|
|
40
|
+
const tableUtils = this.editor.plugins.get( 'TableUtils' );
|
|
41
|
+
const selectedCells = tableUtils.getSelectionAffectedTableCells( this.editor.model.document.selection );
|
|
42
42
|
|
|
43
43
|
this.isEnabled = selectedCells.length > 0;
|
|
44
44
|
}
|
|
@@ -47,13 +47,13 @@ export default class SelectColumnCommand extends Command {
|
|
|
47
47
|
* @inheritDoc
|
|
48
48
|
*/
|
|
49
49
|
execute() {
|
|
50
|
+
const tableUtils = this.editor.plugins.get( 'TableUtils' );
|
|
50
51
|
const model = this.editor.model;
|
|
51
|
-
const referenceCells = getSelectionAffectedTableCells( model.document.selection );
|
|
52
|
+
const referenceCells = tableUtils.getSelectionAffectedTableCells( model.document.selection );
|
|
52
53
|
const firstCell = referenceCells[ 0 ];
|
|
53
54
|
const lastCell = referenceCells.pop();
|
|
54
55
|
const table = firstCell.findAncestor( 'table' );
|
|
55
56
|
|
|
56
|
-
const tableUtils = this.editor.plugins.get( 'TableUtils' );
|
|
57
57
|
const startLocation = tableUtils.getCellLocation( firstCell );
|
|
58
58
|
const endLocation = tableUtils.getCellLocation( lastCell );
|
|
59
59
|
|
|
@@ -9,8 +9,6 @@
|
|
|
9
9
|
|
|
10
10
|
import { Command } from 'ckeditor5/src/core';
|
|
11
11
|
|
|
12
|
-
import { getRowIndexes, getSelectionAffectedTableCells } from '../utils/selection';
|
|
13
|
-
|
|
14
12
|
/**
|
|
15
13
|
* The select row command.
|
|
16
14
|
*
|
|
@@ -37,7 +35,8 @@ export default class SelectRowCommand extends Command {
|
|
|
37
35
|
* @inheritDoc
|
|
38
36
|
*/
|
|
39
37
|
refresh() {
|
|
40
|
-
const
|
|
38
|
+
const tableUtils = this.editor.plugins.get( 'TableUtils' );
|
|
39
|
+
const selectedCells = tableUtils.getSelectionAffectedTableCells( this.editor.model.document.selection );
|
|
41
40
|
|
|
42
41
|
this.isEnabled = selectedCells.length > 0;
|
|
43
42
|
}
|
|
@@ -47,8 +46,9 @@ export default class SelectRowCommand extends Command {
|
|
|
47
46
|
*/
|
|
48
47
|
execute() {
|
|
49
48
|
const model = this.editor.model;
|
|
50
|
-
const
|
|
51
|
-
const
|
|
49
|
+
const tableUtils = this.editor.plugins.get( 'TableUtils' );
|
|
50
|
+
const referenceCells = tableUtils.getSelectionAffectedTableCells( model.document.selection );
|
|
51
|
+
const rowIndexes = tableUtils.getRowIndexes( referenceCells );
|
|
52
52
|
|
|
53
53
|
const table = referenceCells[ 0 ].findAncestor( 'table' );
|
|
54
54
|
const rangesToSelect = [];
|
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
isHeadingColumnCell,
|
|
14
14
|
updateNumericAttribute
|
|
15
15
|
} from '../utils/common';
|
|
16
|
-
import { getColumnIndexes, getSelectionAffectedTableCells } from '../utils/selection';
|
|
17
16
|
import { getHorizontallyOverlappingCells, splitVertically } from '../utils/structure';
|
|
18
17
|
|
|
19
18
|
/**
|
|
@@ -37,8 +36,9 @@ export default class SetHeaderColumnCommand extends Command {
|
|
|
37
36
|
*/
|
|
38
37
|
refresh() {
|
|
39
38
|
const model = this.editor.model;
|
|
40
|
-
const selectedCells = getSelectionAffectedTableCells( model.document.selection );
|
|
41
39
|
const tableUtils = this.editor.plugins.get( 'TableUtils' );
|
|
40
|
+
|
|
41
|
+
const selectedCells = tableUtils.getSelectionAffectedTableCells( model.document.selection );
|
|
42
42
|
const isInTable = selectedCells.length > 0;
|
|
43
43
|
|
|
44
44
|
this.isEnabled = isInTable;
|
|
@@ -71,11 +71,12 @@ export default class SetHeaderColumnCommand extends Command {
|
|
|
71
71
|
return;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
+
const tableUtils = this.editor.plugins.get( 'TableUtils' );
|
|
74
75
|
const model = this.editor.model;
|
|
75
|
-
const selectedCells = getSelectionAffectedTableCells( model.document.selection );
|
|
76
|
+
const selectedCells = tableUtils.getSelectionAffectedTableCells( model.document.selection );
|
|
76
77
|
const table = selectedCells[ 0 ].findAncestor( 'table' );
|
|
77
78
|
|
|
78
|
-
const { first, last } = getColumnIndexes( selectedCells );
|
|
79
|
+
const { first, last } = tableUtils.getColumnIndexes( selectedCells );
|
|
79
80
|
const headingColumnsToSet = this.value ? first : last + 1;
|
|
80
81
|
|
|
81
82
|
model.change( writer => {
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
import { Command } from 'ckeditor5/src/core';
|
|
11
11
|
|
|
12
12
|
import { updateNumericAttribute } from '../utils/common';
|
|
13
|
-
import { getRowIndexes, getSelectionAffectedTableCells } from '../utils/selection';
|
|
14
13
|
import { getVerticallyOverlappingCells, splitHorizontally } from '../utils/structure';
|
|
15
14
|
|
|
16
15
|
/**
|
|
@@ -32,8 +31,9 @@ export default class SetHeaderRowCommand extends Command {
|
|
|
32
31
|
* @inheritDoc
|
|
33
32
|
*/
|
|
34
33
|
refresh() {
|
|
34
|
+
const tableUtils = this.editor.plugins.get( 'TableUtils' );
|
|
35
35
|
const model = this.editor.model;
|
|
36
|
-
const selectedCells = getSelectionAffectedTableCells( model.document.selection );
|
|
36
|
+
const selectedCells = tableUtils.getSelectionAffectedTableCells( model.document.selection );
|
|
37
37
|
const isInTable = selectedCells.length > 0;
|
|
38
38
|
|
|
39
39
|
this.isEnabled = isInTable;
|
|
@@ -65,11 +65,14 @@ export default class SetHeaderRowCommand extends Command {
|
|
|
65
65
|
if ( options.forceValue === this.value ) {
|
|
66
66
|
return;
|
|
67
67
|
}
|
|
68
|
+
|
|
69
|
+
const tableUtils = this.editor.plugins.get( 'TableUtils' );
|
|
68
70
|
const model = this.editor.model;
|
|
69
|
-
|
|
71
|
+
|
|
72
|
+
const selectedCells = tableUtils.getSelectionAffectedTableCells( model.document.selection );
|
|
70
73
|
const table = selectedCells[ 0 ].findAncestor( 'table' );
|
|
71
74
|
|
|
72
|
-
const { first, last } = getRowIndexes( selectedCells );
|
|
75
|
+
const { first, last } = tableUtils.getRowIndexes( selectedCells );
|
|
73
76
|
const headingRowsToSet = this.value ? first : last + 1;
|
|
74
77
|
const currentHeadingRows = table.getAttribute( 'headingRows' ) || 0;
|
|
75
78
|
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import { Command } from 'ckeditor5/src/core';
|
|
11
|
-
import { getSelectionAffectedTableCells } from '../utils/selection';
|
|
12
11
|
|
|
13
12
|
/**
|
|
14
13
|
* The split cell command.
|
|
@@ -46,7 +45,8 @@ export default class SplitCellCommand extends Command {
|
|
|
46
45
|
* @inheritDoc
|
|
47
46
|
*/
|
|
48
47
|
refresh() {
|
|
49
|
-
const
|
|
48
|
+
const tableUtils = this.editor.plugins.get( 'TableUtils' );
|
|
49
|
+
const selectedCells = tableUtils.getSelectionAffectedTableCells( this.editor.model.document.selection );
|
|
50
50
|
|
|
51
51
|
this.isEnabled = selectedCells.length === 1;
|
|
52
52
|
}
|
|
@@ -55,9 +55,9 @@ export default class SplitCellCommand extends Command {
|
|
|
55
55
|
* @inheritDoc
|
|
56
56
|
*/
|
|
57
57
|
execute() {
|
|
58
|
-
const tableCell = getSelectionAffectedTableCells( this.editor.model.document.selection )[ 0 ];
|
|
59
|
-
const isHorizontal = this.direction === 'horizontally';
|
|
60
58
|
const tableUtils = this.editor.plugins.get( 'TableUtils' );
|
|
59
|
+
const tableCell = tableUtils.getSelectionAffectedTableCells( this.editor.model.document.selection )[ 0 ];
|
|
60
|
+
const isHorizontal = this.direction === 'horizontally';
|
|
61
61
|
|
|
62
62
|
if ( isHorizontal ) {
|
|
63
63
|
tableUtils.splitCellHorizontally( tableCell, 2 );
|