@ckeditor/ckeditor5-table 31.1.0 → 34.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.
Files changed (146) hide show
  1. package/LICENSE.md +2 -2
  2. package/README.md +2 -1
  3. package/build/table.js +3 -3
  4. package/build/table.js.map +1 -0
  5. package/build/translations/cs.js +1 -1
  6. package/build/translations/el.js +1 -0
  7. package/build/translations/en-au.js +1 -1
  8. package/build/translations/es.js +1 -1
  9. package/build/translations/hr.js +1 -1
  10. package/build/translations/sk.js +1 -1
  11. package/lang/translations/ar.po +1 -1
  12. package/lang/translations/az.po +1 -1
  13. package/lang/translations/bg.po +1 -1
  14. package/lang/translations/cs.po +4 -4
  15. package/lang/translations/da.po +1 -1
  16. package/lang/translations/de-ch.po +1 -1
  17. package/lang/translations/de.po +1 -1
  18. package/lang/translations/el.po +261 -0
  19. package/lang/translations/en-au.po +4 -4
  20. package/lang/translations/en-gb.po +1 -1
  21. package/lang/translations/en.po +1 -1
  22. package/lang/translations/es.po +33 -33
  23. package/lang/translations/et.po +1 -1
  24. package/lang/translations/fa.po +1 -1
  25. package/lang/translations/fi.po +1 -1
  26. package/lang/translations/fr.po +1 -1
  27. package/lang/translations/gl.po +1 -1
  28. package/lang/translations/hi.po +1 -1
  29. package/lang/translations/hr.po +4 -4
  30. package/lang/translations/hu.po +1 -1
  31. package/lang/translations/id.po +1 -1
  32. package/lang/translations/it.po +1 -1
  33. package/lang/translations/ja.po +1 -1
  34. package/lang/translations/ko.po +1 -1
  35. package/lang/translations/ku.po +1 -1
  36. package/lang/translations/lt.po +1 -1
  37. package/lang/translations/lv.po +1 -1
  38. package/lang/translations/nb.po +1 -1
  39. package/lang/translations/ne.po +1 -1
  40. package/lang/translations/nl.po +1 -1
  41. package/lang/translations/no.po +1 -1
  42. package/lang/translations/pl.po +1 -1
  43. package/lang/translations/pt-br.po +1 -1
  44. package/lang/translations/ro.po +1 -1
  45. package/lang/translations/ru.po +1 -1
  46. package/lang/translations/sk.po +4 -4
  47. package/lang/translations/sq.po +1 -1
  48. package/lang/translations/sr-latn.po +1 -1
  49. package/lang/translations/sr.po +1 -1
  50. package/lang/translations/sv.po +1 -1
  51. package/lang/translations/th.po +1 -1
  52. package/lang/translations/tk.po +1 -1
  53. package/lang/translations/tr.po +1 -1
  54. package/lang/translations/ug.po +1 -1
  55. package/lang/translations/uk.po +1 -1
  56. package/lang/translations/uz.po +1 -1
  57. package/lang/translations/vi.po +1 -1
  58. package/lang/translations/zh-cn.po +1 -1
  59. package/lang/translations/zh.po +1 -1
  60. package/package.json +26 -24
  61. package/src/commands/insertcolumncommand.js +5 -5
  62. package/src/commands/insertrowcommand.js +5 -5
  63. package/src/commands/inserttablecommand.js +2 -6
  64. package/src/commands/mergecellcommand.js +5 -6
  65. package/src/commands/mergecellscommand.js +6 -5
  66. package/src/commands/removecolumncommand.js +9 -8
  67. package/src/commands/removerowcommand.js +6 -7
  68. package/src/commands/selectcolumncommand.js +5 -5
  69. package/src/commands/selectrowcommand.js +6 -6
  70. package/src/commands/setheadercolumncommand.js +6 -5
  71. package/src/commands/setheaderrowcommand.js +8 -5
  72. package/src/commands/splitcellcommand.js +5 -5
  73. package/src/converters/downcast.js +77 -408
  74. package/src/converters/table-caption-post-fixer.js +1 -1
  75. package/src/converters/table-cell-paragraph-post-fixer.js +1 -1
  76. package/src/converters/{table-cell-refresh-post-fixer.js → table-cell-refresh-handler.js} +9 -20
  77. package/src/converters/table-headings-refresh-handler.js +68 -0
  78. package/src/converters/table-layout-post-fixer.js +1 -1
  79. package/src/converters/tableproperties.js +1 -1
  80. package/src/converters/upcasttable.js +1 -1
  81. package/src/index.js +2 -1
  82. package/src/plaintableoutput.js +151 -0
  83. package/src/table.js +1 -1
  84. package/src/tablecaption/tablecaptionediting.js +1 -1
  85. package/src/tablecaption/tablecaptionui.js +3 -3
  86. package/src/tablecaption/toggletablecaptioncommand.js +3 -3
  87. package/src/tablecaption/utils.js +1 -1
  88. package/src/tablecaption.js +1 -1
  89. package/src/tablecellproperties/commands/tablecellbackgroundcolorcommand.js +1 -1
  90. package/src/tablecellproperties/commands/tablecellbordercolorcommand.js +1 -1
  91. package/src/tablecellproperties/commands/tablecellborderstylecommand.js +1 -1
  92. package/src/tablecellproperties/commands/tablecellborderwidthcommand.js +1 -1
  93. package/src/tablecellproperties/commands/tablecellheightcommand.js +1 -1
  94. package/src/tablecellproperties/commands/tablecellhorizontalalignmentcommand.js +1 -1
  95. package/src/tablecellproperties/commands/tablecellpaddingcommand.js +1 -1
  96. package/src/tablecellproperties/commands/tablecellpropertycommand.js +6 -5
  97. package/src/tablecellproperties/commands/tablecellverticalalignmentcommand.js +1 -1
  98. package/src/tablecellproperties/commands/tablecellwidthcommand.js +1 -1
  99. package/src/tablecellproperties/tablecellpropertiesediting.js +1 -1
  100. package/src/tablecellproperties/tablecellpropertiesui.js +1 -1
  101. package/src/tablecellproperties/ui/tablecellpropertiesview.js +1 -1
  102. package/src/tablecellproperties.js +1 -1
  103. package/src/tableclipboard.js +19 -16
  104. package/src/tableediting.js +52 -33
  105. package/src/tablekeyboard.js +74 -71
  106. package/src/tablemouse/mouseeventsobserver.js +1 -1
  107. package/src/tablemouse.js +7 -5
  108. package/src/tableproperties/commands/tablealignmentcommand.js +1 -1
  109. package/src/tableproperties/commands/tablebackgroundcolorcommand.js +1 -1
  110. package/src/tableproperties/commands/tablebordercolorcommand.js +1 -1
  111. package/src/tableproperties/commands/tableborderstylecommand.js +1 -1
  112. package/src/tableproperties/commands/tableborderwidthcommand.js +1 -1
  113. package/src/tableproperties/commands/tableheightcommand.js +1 -1
  114. package/src/tableproperties/commands/tablepropertycommand.js +2 -2
  115. package/src/tableproperties/commands/tablewidthcommand.js +1 -1
  116. package/src/tableproperties/tablepropertiesediting.js +1 -1
  117. package/src/tableproperties/tablepropertiesui.js +1 -1
  118. package/src/tableproperties/ui/tablepropertiesview.js +1 -1
  119. package/src/tableproperties.js +1 -1
  120. package/src/tableselection.js +10 -9
  121. package/src/tabletoolbar.js +1 -1
  122. package/src/tableui.js +1 -1
  123. package/src/tableutils.js +311 -1
  124. package/src/tablewalker.js +1 -1
  125. package/src/ui/colorinputview.js +1 -1
  126. package/src/ui/formrowview.js +1 -1
  127. package/src/ui/inserttableview.js +1 -1
  128. package/src/utils/common.js +1 -1
  129. package/src/utils/structure.js +1 -1
  130. package/src/utils/table-properties.js +1 -1
  131. package/src/utils/ui/contextualballoon.js +1 -1
  132. package/src/utils/ui/table-properties.js +1 -1
  133. package/src/utils/ui/widget.js +1 -1
  134. package/theme/colorinput.css +1 -1
  135. package/theme/form.css +1 -1
  136. package/theme/formrow.css +1 -1
  137. package/theme/inserttable.css +1 -1
  138. package/theme/table.css +2 -2
  139. package/theme/tablecaption.css +1 -1
  140. package/theme/tablecellproperties.css +1 -1
  141. package/theme/tableediting.css +1 -1
  142. package/theme/tableform.css +1 -1
  143. package/theme/tableproperties.css +1 -1
  144. package/theme/tableselection.css +1 -1
  145. package/src/converters/table-heading-rows-refresh-post-fixer.js +0 -72
  146. package/src/utils/selection.js +0 -276
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
2
+ * @license Copyright (c) 2003-2022, 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
5
 
@@ -8,7 +8,6 @@
8
8
  */
9
9
 
10
10
  import { Command } from 'ckeditor5/src/core';
11
- import { findOptimalInsertionRange } from 'ckeditor5/src/widget';
12
11
 
13
12
  /**
14
13
  * The insert table command.
@@ -51,12 +50,9 @@ export default class InsertTableCommand extends Command {
51
50
  */
52
51
  execute( options = {} ) {
53
52
  const model = this.editor.model;
54
- const selection = model.document.selection;
55
53
  const tableUtils = this.editor.plugins.get( 'TableUtils' );
56
54
  const config = this.editor.config.get( 'table' );
57
55
 
58
- const insertionRange = findOptimalInsertionRange( selection, model );
59
-
60
56
  const defaultRows = config.defaultHeadings.rows;
61
57
  const defaultColumns = config.defaultHeadings.columns;
62
58
 
@@ -71,7 +67,7 @@ export default class InsertTableCommand extends Command {
71
67
  model.change( writer => {
72
68
  const table = tableUtils.createTable( writer, options );
73
69
 
74
- model.insertContent( table, insertionRange );
70
+ model.insertObject( table, null, null, { findOptimalPosition: 'auto' } );
75
71
 
76
72
  writer.setSelection( writer.createPositionAt( table.getNodeByPath( [ 0, 0, 0 ] ), 0 ) );
77
73
  } );
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
2
+ * @license Copyright (c) 2003-2022, 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
5
 
@@ -9,7 +9,6 @@
9
9
 
10
10
  import { Command } from 'ckeditor5/src/core';
11
11
  import TableWalker from '../tablewalker';
12
- import { getTableCellsContainingSelection } from '../utils/selection';
13
12
  import { isHeadingColumnCell } from '../utils/common';
14
13
  import { removeEmptyRowsColumns } from '../utils/structure';
15
14
 
@@ -80,7 +79,8 @@ export default class MergeCellCommand extends Command {
80
79
  execute() {
81
80
  const model = this.editor.model;
82
81
  const doc = model.document;
83
- const tableCell = getTableCellsContainingSelection( doc.selection )[ 0 ];
82
+ const tableUtils = this.editor.plugins.get( 'TableUtils' );
83
+ const tableCell = tableUtils.getTableCellsContainingSelection( doc.selection )[ 0 ];
84
84
 
85
85
  const cellToMerge = this.value;
86
86
  const direction = this.direction;
@@ -122,14 +122,13 @@ export default class MergeCellCommand extends Command {
122
122
  _getMergeableCell() {
123
123
  const model = this.editor.model;
124
124
  const doc = model.document;
125
- const tableCell = getTableCellsContainingSelection( doc.selection )[ 0 ];
125
+ const tableUtils = this.editor.plugins.get( 'TableUtils' );
126
+ const tableCell = tableUtils.getTableCellsContainingSelection( doc.selection )[ 0 ];
126
127
 
127
128
  if ( !tableCell ) {
128
129
  return;
129
130
  }
130
131
 
131
- const tableUtils = this.editor.plugins.get( 'TableUtils' );
132
-
133
132
  // First get the cell on proper direction.
134
133
  const cellToMerge = this.isHorizontal ?
135
134
  getHorizontalCell( tableCell, this.direction, tableUtils ) :
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
2
+ * @license Copyright (c) 2003-2022, 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
5
 
@@ -9,7 +9,6 @@
9
9
 
10
10
  import { Command } from 'ckeditor5/src/core';
11
11
  import TableUtils from '../tableutils';
12
- import { getSelectedTableCells, isSelectionRectangular } from '../utils/selection';
13
12
  import { updateNumericAttribute } from '../utils/common';
14
13
  import { removeEmptyRowsColumns } from '../utils/structure';
15
14
 
@@ -29,8 +28,10 @@ export default class MergeCellsCommand extends Command {
29
28
  * @inheritDoc
30
29
  */
31
30
  refresh() {
32
- const selectedTableCells = getSelectedTableCells( this.editor.model.document.selection );
33
- this.isEnabled = isSelectionRectangular( selectedTableCells, this.editor.plugins.get( TableUtils ) );
31
+ const tableUtils = this.editor.plugins.get( TableUtils );
32
+
33
+ const selectedTableCells = tableUtils.getSelectedTableCells( this.editor.model.document.selection );
34
+ this.isEnabled = tableUtils.isSelectionRectangular( selectedTableCells, this.editor.plugins.get( TableUtils ) );
34
35
  }
35
36
 
36
37
  /**
@@ -43,7 +44,7 @@ export default class MergeCellsCommand extends Command {
43
44
  const tableUtils = this.editor.plugins.get( TableUtils );
44
45
 
45
46
  model.change( writer => {
46
- const selectedTableCells = getSelectedTableCells( model.document.selection );
47
+ const selectedTableCells = tableUtils.getSelectedTableCells( model.document.selection );
47
48
 
48
49
  // All cells will be merged into the first one.
49
50
  const firstTableCell = selectedTableCells.shift();
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
2
+ * @license Copyright (c) 2003-2022, 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
5
 
@@ -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 selectedCells = getSelectionAffectedTableCells( this.editor.model.document.selection );
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 = this.editor.plugins.get( 'TableUtils' ).getColumns( table );
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 [ firstCell, lastCell ] = getBoundaryCells( this.editor.model.document.selection );
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
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
2
+ * @license Copyright (c) 2003-2022, 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
5
 
@@ -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 selectedCells = getSelectionAffectedTableCells( this.editor.model.document.selection );
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' );
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
2
+ * @license Copyright (c) 2003-2022, 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
5
 
@@ -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 selectedCells = getSelectionAffectedTableCells( this.editor.model.document.selection );
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
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
2
+ * @license Copyright (c) 2003-2022, 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
5
 
@@ -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 selectedCells = getSelectionAffectedTableCells( this.editor.model.document.selection );
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 referenceCells = getSelectionAffectedTableCells( model.document.selection );
51
- const rowIndexes = getRowIndexes( referenceCells );
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 = [];
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
2
+ * @license Copyright (c) 2003-2022, 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
5
 
@@ -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 => {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
2
+ * @license Copyright (c) 2003-2022, 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
5
 
@@ -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
- const selectedCells = getSelectionAffectedTableCells( model.document.selection );
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
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
2
+ * @license Copyright (c) 2003-2022, 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
5
 
@@ -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 selectedCells = getSelectionAffectedTableCells( this.editor.model.document.selection );
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 );