@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
@@ -0,0 +1,68 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2022, 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
+ /**
7
+ * @module table/converters/table-heading-rows-refresh-post-fixer
8
+ */
9
+
10
+ import TableWalker from '../tablewalker';
11
+
12
+ /**
13
+ * A table headings refresh handler which marks the table cells or rows in the differ to have it re-rendered
14
+ * if the headings attribute changed.
15
+ *
16
+ * Table heading rows and heading columns are represented in the model by a `headingRows` and `headingColumns` attributes.
17
+ *
18
+ * When table headings attribute changes, all the cells/rows are marked to re-render to change between `<td>` and `<th>`.
19
+ *
20
+ * @param {module:engine/model/model~Model} model
21
+ * @param {module:engine/controller/editingcontroller~EditingController} editing
22
+ */
23
+ export default function tableHeadingsRefreshHandler( model, editing ) {
24
+ const differ = model.document.differ;
25
+
26
+ for ( const change of differ.getChanges() ) {
27
+ let table;
28
+ let isRowChange = false;
29
+
30
+ if ( change.type == 'attribute' ) {
31
+ const element = change.range.start.nodeAfter;
32
+
33
+ if ( !element || !element.is( 'element', 'table' ) ) {
34
+ continue;
35
+ }
36
+
37
+ if ( change.attributeKey != 'headingRows' && change.attributeKey != 'headingColumns' ) {
38
+ continue;
39
+ }
40
+
41
+ table = element;
42
+ isRowChange = change.attributeKey == 'headingRows';
43
+ } else if ( change.name == 'tableRow' || change.name == 'tableCell' ) {
44
+ table = change.position.findAncestor( 'table' );
45
+ isRowChange = change.name == 'tableRow';
46
+ }
47
+
48
+ if ( !table ) {
49
+ continue;
50
+ }
51
+
52
+ const headingRows = table.getAttribute( 'headingRows' ) || 0;
53
+ const headingColumns = table.getAttribute( 'headingColumns' ) || 0;
54
+
55
+ const tableWalker = new TableWalker( table );
56
+
57
+ for ( const tableSlot of tableWalker ) {
58
+ const isHeading = tableSlot.row < headingRows || tableSlot.column < headingColumns;
59
+ const expectedElementName = isHeading ? 'th' : 'td';
60
+
61
+ const viewElement = editing.mapper.toViewElement( tableSlot.cell );
62
+
63
+ if ( viewElement && viewElement.is( 'element' ) && viewElement.name != expectedElementName ) {
64
+ editing.reconvertItem( isRowChange ? tableSlot.cell.parent : tableSlot.cell );
65
+ }
66
+ }
67
+ }
68
+ }
@@ -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
 
@@ -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
 
@@ -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
 
package/src/index.js CHANGED
@@ -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
 
@@ -7,6 +7,7 @@
7
7
  * @module table
8
8
  */
9
9
 
10
+ export { default as PlainTableOutput } from './plaintableoutput';
10
11
  export { default as Table } from './table';
11
12
  export { default as TableEditing } from './tableediting';
12
13
  export { default as TableUI } from './tableui';
@@ -0,0 +1,151 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2022, 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
+ /**
7
+ * @module table/plaintableoutput
8
+ */
9
+
10
+ import { Plugin } from 'ckeditor5/src/core';
11
+ import Table from './table';
12
+
13
+ /**
14
+ * The plain table output feature.
15
+ *
16
+ * @extends module:core/plugin~Plugin
17
+ */
18
+ export default class PlainTableOutput extends Plugin {
19
+ /**
20
+ * @inheritDoc
21
+ */
22
+ static get pluginName() {
23
+ return 'PlainTableOutput';
24
+ }
25
+
26
+ /**
27
+ * @inheritDoc
28
+ */
29
+ static get requires() {
30
+ return [ Table ];
31
+ }
32
+
33
+ /**
34
+ * @inheritDoc
35
+ */
36
+ init() {
37
+ const editor = this.editor;
38
+
39
+ // Override default table data downcast converter.
40
+ editor.conversion.for( 'dataDowncast' ).elementToStructure( {
41
+ model: 'table',
42
+ view: downcastTableElement,
43
+ converterPriority: 'high'
44
+ } );
45
+
46
+ // Make sure table <caption> is downcasted into <caption> in the data pipeline when necessary.
47
+ if ( editor.plugins.has( 'TableCaption' ) ) {
48
+ editor.conversion.for( 'dataDowncast' ).elementToElement( {
49
+ model: 'caption',
50
+ view: ( modelElement, { writer } ) => {
51
+ if ( modelElement.parent.name === 'table' ) {
52
+ return writer.createContainerElement( 'caption' );
53
+ }
54
+ },
55
+ converterPriority: 'high'
56
+ } );
57
+ }
58
+
59
+ // Handle border-style, border-color, border-width and background-color table attributes.
60
+ if ( editor.plugins.has( 'TableProperties' ) ) {
61
+ downcastTableBorderAndBackgroundAttributes( editor );
62
+ }
63
+ }
64
+ }
65
+
66
+ // The plain table downcast converter callback.
67
+ //
68
+ // @private
69
+ // @param {module:engine/model/element~Element} Table model element.
70
+ // @param {module:engine/conversion/downcastdispatcher~DowncastConversionApi} conversionApi The conversion API object.
71
+ // @returns {module:engine/view/containerelement~ContainerElement} Created element.
72
+ function downcastTableElement( table, { writer } ) {
73
+ const headingRows = table.getAttribute( 'headingRows' ) || 0;
74
+
75
+ // Table head rows slot.
76
+ const headRowsSlot = writer.createSlot( element =>
77
+ element.is( 'element', 'tableRow' ) && element.index < headingRows
78
+ );
79
+
80
+ // Table body rows slot.
81
+ const bodyRowsSlot = writer.createSlot( element =>
82
+ element.is( 'element', 'tableRow' ) && element.index >= headingRows
83
+ );
84
+
85
+ // Table children slot.
86
+ const childrenSlot = writer.createSlot( element => !element.is( 'element', 'tableRow' ) );
87
+
88
+ // Table <thead> element with all the heading rows.
89
+ const theadElement = writer.createContainerElement( 'thead', null, headRowsSlot );
90
+
91
+ // Table <tbody> element with all the body rows.
92
+ const tbodyElement = writer.createContainerElement( 'tbody', null, bodyRowsSlot );
93
+
94
+ // Table contents element containing <thead> and <tbody> when necessary.
95
+ const tableContentElements = [];
96
+
97
+ if ( headingRows ) {
98
+ tableContentElements.push( theadElement );
99
+ }
100
+
101
+ if ( headingRows < table.childCount ) {
102
+ tableContentElements.push( tbodyElement );
103
+ }
104
+
105
+ // Create table structure.
106
+ //
107
+ // <table>
108
+ // {children-slot-like-caption}
109
+ // <thead>
110
+ // {table-head-rows-slot}
111
+ // </thead>
112
+ // <tbody>
113
+ // {table-body-rows-slot}
114
+ // </tbody>
115
+ // </table>
116
+ return writer.createContainerElement( 'table', null, [ childrenSlot, ...tableContentElements ] );
117
+ }
118
+
119
+ // Register table border and background attributes converters.
120
+ //
121
+ // @private
122
+ // @param {module:core/editor/editor~Editor} editor
123
+ function downcastTableBorderAndBackgroundAttributes( editor ) {
124
+ const modelAttributes = {
125
+ 'border-width': 'tableBorderWidth',
126
+ 'border-color': 'tableBorderColor',
127
+ 'border-style': 'tableBorderStyle',
128
+ 'background-color': 'tableBackgroundColor'
129
+ };
130
+
131
+ for ( const [ styleName, modelAttribute ] of Object.entries( modelAttributes ) ) {
132
+ editor.conversion.for( 'dataDowncast' ).add( dispatcher => {
133
+ return dispatcher.on( `attribute:${ modelAttribute }:table`, ( evt, data, conversionApi ) => {
134
+ const { item, attributeNewValue } = data;
135
+ const { mapper, writer } = conversionApi;
136
+
137
+ if ( !conversionApi.consumable.consume( item, evt.name ) ) {
138
+ return;
139
+ }
140
+
141
+ const table = mapper.toViewElement( item );
142
+
143
+ if ( attributeNewValue ) {
144
+ writer.setStyle( styleName, attributeNewValue, table );
145
+ } else {
146
+ writer.removeStyle( styleName, table );
147
+ }
148
+ }, { priority: 'high' } );
149
+ } );
150
+ }
151
+ }
package/src/table.js CHANGED
@@ -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
 
@@ -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
 
@@ -1,7 +1,7 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
2
+ * @license Copyright (c) 2003-2022, 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
5
 
6
6
  /**
7
7
  * @module table/tablecaption/tablecaptionui
@@ -1,7 +1,7 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
2
+ * @license Copyright (c) 2003-2022, 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
5
 
6
6
  /**
7
7
  * @module table/tablecaption/toggletablecaptioncommand
@@ -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
 
@@ -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
 
@@ -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
 
@@ -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
 
@@ -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
 
@@ -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
 
@@ -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
 
@@ -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
 
@@ -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
 
@@ -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 table cell attribute command.
@@ -51,7 +50,8 @@ export default class TableCellPropertyCommand extends Command {
51
50
  */
52
51
  refresh() {
53
52
  const editor = this.editor;
54
- const selectedTableCells = getSelectionAffectedTableCells( editor.model.document.selection );
53
+ const tableUtils = this.editor.plugins.get( 'TableUtils' );
54
+ const selectedTableCells = tableUtils.getSelectionAffectedTableCells( editor.model.document.selection );
55
55
 
56
56
  this.isEnabled = !!selectedTableCells.length;
57
57
  this.value = this._getSingleValue( selectedTableCells );
@@ -70,10 +70,11 @@ export default class TableCellPropertyCommand extends Command {
70
70
  execute( options = {} ) {
71
71
  const { value, batch } = options;
72
72
  const model = this.editor.model;
73
- const tableCells = getSelectionAffectedTableCells( model.document.selection );
73
+ const tableUtils = this.editor.plugins.get( 'TableUtils' );
74
+ const tableCells = tableUtils.getSelectionAffectedTableCells( model.document.selection );
74
75
  const valueToSet = this._getValueToSet( value );
75
76
 
76
- model.enqueueChange( batch || 'default', writer => {
77
+ model.enqueueChange( batch, writer => {
77
78
  if ( valueToSet ) {
78
79
  tableCells.forEach( tableCell => writer.setAttribute( this.attributeName, valueToSet, tableCell ) );
79
80
  } else {
@@ -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
 
@@ -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
 
@@ -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
 
@@ -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
 
@@ -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
 
@@ -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
 
@@ -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
 
@@ -12,7 +12,6 @@ import { Plugin } from 'ckeditor5/src/core';
12
12
  import TableSelection from './tableselection';
13
13
  import TableWalker from './tablewalker';
14
14
  import TableUtils from './tableutils';
15
- import { getColumnIndexes, getRowIndexes, getSelectionAffectedTableCells, isSelectionRectangular, sortRanges } from './utils/selection';
16
15
  import {
17
16
  cropTableToDimensions,
18
17
  getHorizontallyOverlappingCells,
@@ -122,7 +121,7 @@ export default class TableClipboard extends Plugin {
122
121
  return;
123
122
  }
124
123
 
125
- const selectedTableCells = getSelectionAffectedTableCells( model.document.selection );
124
+ const selectedTableCells = tableUtils.getSelectionAffectedTableCells( model.document.selection );
126
125
 
127
126
  if ( !selectedTableCells.length ) {
128
127
  removeEmptyRowsColumns( pastedTable, tableUtils );
@@ -171,7 +170,7 @@ export default class TableClipboard extends Plugin {
171
170
  if ( this.editor.plugins.get( 'TableSelection' ).isEnabled ) {
172
171
  // Selection ranges must be sorted because the first and last selection ranges are considered
173
172
  // as anchor/focus cell ranges for multi-cell selection.
174
- const selectionRanges = sortRanges( cellsToSelect.map( cell => writer.createRangeOn( cell ) ) );
173
+ const selectionRanges = tableUtils.sortRanges( cellsToSelect.map( cell => writer.createRangeOn( cell ) ) );
175
174
 
176
175
  writer.setSelection( selectionRanges );
177
176
  } else {
@@ -311,17 +310,21 @@ export default class TableClipboard extends Plugin {
311
310
 
312
311
  return cellToInsert;
313
312
  }
313
+
314
+ /**
315
+ * Extracts the table for pasting into a table.
316
+ *
317
+ * @protected
318
+ * @param {module:engine/model/documentfragment~DocumentFragment|module:engine/model/item~Item} content The content to insert.
319
+ * @param {module:engine/model/model~Model} model The editor model.
320
+ * @returns {module:engine/model/element~Element|null}
321
+ */
322
+ getTableIfOnlyTableInContent( content, model ) {
323
+ return getTableIfOnlyTableInContent( content, model );
324
+ }
314
325
  }
315
326
 
316
- /**
317
- * Extract table for pasting into table.
318
- *
319
- * @private
320
- * @param {module:engine/model/documentfragment~DocumentFragment|module:engine/model/item~Item} content The content to insert.
321
- * @param {module:engine/model/model~Model} model The editor model.
322
- * @returns {module:engine/model/element~Element|null}
323
- */
324
- export function getTableIfOnlyTableInContent( content, model ) {
327
+ function getTableIfOnlyTableInContent( content, model ) {
325
328
  if ( !content.is( 'documentFragment' ) && !content.is( 'element' ) ) {
326
329
  return null;
327
330
  }
@@ -381,8 +384,8 @@ export function getTableIfOnlyTableInContent( content, model ) {
381
384
  function prepareTableForPasting( selectedTableCells, pastedDimensions, writer, tableUtils ) {
382
385
  const selectedTable = selectedTableCells[ 0 ].findAncestor( 'table' );
383
386
 
384
- const columnIndexes = getColumnIndexes( selectedTableCells );
385
- const rowIndexes = getRowIndexes( selectedTableCells );
387
+ const columnIndexes = tableUtils.getColumnIndexes( selectedTableCells );
388
+ const rowIndexes = tableUtils.getRowIndexes( selectedTableCells );
386
389
 
387
390
  const selection = {
388
391
  firstColumn: columnIndexes.first,
@@ -403,7 +406,7 @@ function prepareTableForPasting( selectedTableCells, pastedDimensions, writer, t
403
406
 
404
407
  // In case of expanding selection we do not reset the selection so in this case we will always try to fix selection
405
408
  // like in the case of a non-rectangular area. This might be fixed by re-setting selected cells array but this shortcut is safe.
406
- if ( shouldExpandSelection || !isSelectionRectangular( selectedTableCells, tableUtils ) ) {
409
+ if ( shouldExpandSelection || !tableUtils.isSelectionRectangular( selectedTableCells ) ) {
407
410
  // For a non-rectangular selection (ie in which some cells sticks out from a virtual selection rectangle) we need to create
408
411
  // a table layout that has a rectangular selection. This will split cells so the selection become rectangular.
409
412
  // Beyond this point we will operate on fixed content table.