@ckeditor/ckeditor5-table 35.4.0 → 36.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 (96) hide show
  1. package/LICENSE.md +1 -1
  2. package/build/table.js +2 -2
  3. package/package.json +26 -26
  4. package/src/commands/insertcolumncommand.js +1 -1
  5. package/src/commands/insertrowcommand.js +1 -1
  6. package/src/commands/inserttablecommand.js +1 -1
  7. package/src/commands/mergecellcommand.js +1 -1
  8. package/src/commands/mergecellscommand.js +1 -1
  9. package/src/commands/removecolumncommand.js +1 -1
  10. package/src/commands/removerowcommand.js +1 -1
  11. package/src/commands/selectcolumncommand.js +1 -1
  12. package/src/commands/selectrowcommand.js +1 -1
  13. package/src/commands/setheadercolumncommand.js +1 -1
  14. package/src/commands/setheaderrowcommand.js +1 -1
  15. package/src/commands/splitcellcommand.js +1 -1
  16. package/src/converters/downcast.js +8 -5
  17. package/src/converters/table-caption-post-fixer.js +1 -1
  18. package/src/converters/table-cell-paragraph-post-fixer.js +1 -1
  19. package/src/converters/table-cell-refresh-handler.js +1 -1
  20. package/src/converters/table-headings-refresh-handler.js +1 -1
  21. package/src/converters/table-layout-post-fixer.js +1 -1
  22. package/src/converters/tableproperties.js +1 -1
  23. package/src/converters/upcasttable.js +20 -5
  24. package/src/index.js +1 -1
  25. package/src/plaintableoutput.js +1 -1
  26. package/src/table.js +1 -1
  27. package/src/tablecaption/tablecaptionediting.js +1 -1
  28. package/src/tablecaption/tablecaptionui.js +1 -1
  29. package/src/tablecaption/toggletablecaptioncommand.js +1 -1
  30. package/src/tablecaption/utils.js +1 -1
  31. package/src/tablecaption.js +1 -1
  32. package/src/tablecellproperties/commands/tablecellbackgroundcolorcommand.js +1 -1
  33. package/src/tablecellproperties/commands/tablecellbordercolorcommand.js +1 -1
  34. package/src/tablecellproperties/commands/tablecellborderstylecommand.js +1 -1
  35. package/src/tablecellproperties/commands/tablecellborderwidthcommand.js +1 -1
  36. package/src/tablecellproperties/commands/tablecellheightcommand.js +1 -1
  37. package/src/tablecellproperties/commands/tablecellhorizontalalignmentcommand.js +1 -1
  38. package/src/tablecellproperties/commands/tablecellpaddingcommand.js +1 -1
  39. package/src/tablecellproperties/commands/tablecellpropertycommand.js +1 -1
  40. package/src/tablecellproperties/commands/tablecellverticalalignmentcommand.js +1 -1
  41. package/src/tablecellproperties/tablecellpropertiesediting.js +1 -1
  42. package/src/tablecellproperties/tablecellpropertiesui.js +53 -32
  43. package/src/tablecellproperties/ui/tablecellpropertiesview.js +1 -1
  44. package/src/tablecellproperties.js +1 -1
  45. package/src/tablecellwidth/commands/tablecellwidthcommand.js +1 -1
  46. package/src/tablecellwidth/tablecellwidthediting.js +1 -1
  47. package/src/tableclipboard.js +1 -1
  48. package/src/tablecolumnresize/constants.js +1 -1
  49. package/src/tablecolumnresize/converters.js +5 -3
  50. package/src/tablecolumnresize/tablecolumnresizeediting.js +13 -15
  51. package/src/tablecolumnresize/tablecolumnwidthscommand.js +1 -1
  52. package/src/tablecolumnresize/tablewidthresizecommand.js +1 -1
  53. package/src/tablecolumnresize/utils.js +1 -25
  54. package/src/tablecolumnresize.js +1 -1
  55. package/src/tableediting.js +1 -40
  56. package/src/tablekeyboard.js +1 -1
  57. package/src/tablemouse/mouseeventsobserver.js +1 -1
  58. package/src/tablemouse.js +1 -1
  59. package/src/tableproperties/commands/tablealignmentcommand.js +1 -1
  60. package/src/tableproperties/commands/tablebackgroundcolorcommand.js +1 -1
  61. package/src/tableproperties/commands/tablebordercolorcommand.js +1 -1
  62. package/src/tableproperties/commands/tableborderstylecommand.js +1 -1
  63. package/src/tableproperties/commands/tableborderwidthcommand.js +1 -1
  64. package/src/tableproperties/commands/tableheightcommand.js +1 -1
  65. package/src/tableproperties/commands/tablepropertycommand.js +1 -1
  66. package/src/tableproperties/commands/tablewidthcommand.js +1 -1
  67. package/src/tableproperties/tablepropertiesediting.js +1 -1
  68. package/src/tableproperties/tablepropertiesui.js +32 -17
  69. package/src/tableproperties/ui/tablepropertiesview.js +1 -1
  70. package/src/tableproperties.js +1 -1
  71. package/src/tableselection.js +1 -1
  72. package/src/tabletoolbar.js +1 -1
  73. package/src/tableui.js +2 -2
  74. package/src/tableutils.js +1 -1
  75. package/src/tablewalker.js +1 -1
  76. package/src/ui/colorinputview.js +1 -1
  77. package/src/ui/formrowview.js +1 -1
  78. package/src/ui/inserttableview.js +1 -1
  79. package/src/utils/common.js +1 -1
  80. package/src/utils/structure.js +1 -1
  81. package/src/utils/table-properties.js +1 -1
  82. package/src/utils/ui/contextualballoon.js +1 -1
  83. package/src/utils/ui/table-properties.js +1 -1
  84. package/src/utils/ui/widget.js +1 -1
  85. package/theme/colorinput.css +1 -1
  86. package/theme/form.css +1 -1
  87. package/theme/formrow.css +1 -1
  88. package/theme/inserttable.css +1 -1
  89. package/theme/table.css +1 -1
  90. package/theme/tablecaption.css +1 -1
  91. package/theme/tablecellproperties.css +1 -1
  92. package/theme/tablecolumnresize.css +1 -1
  93. package/theme/tableediting.css +1 -1
  94. package/theme/tableform.css +1 -1
  95. package/theme/tableproperties.css +1 -1
  96. package/theme/tableselection.css +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-table",
3
- "version": "35.4.0",
3
+ "version": "36.0.0",
4
4
  "description": "Table feature for CKEditor 5.",
5
5
  "keywords": [
6
6
  "ckeditor",
@@ -12,34 +12,34 @@
12
12
  ],
13
13
  "main": "src/index.js",
14
14
  "dependencies": {
15
- "ckeditor5": "^35.4.0",
15
+ "ckeditor5": "^36.0.0",
16
16
  "lodash-es": "^4.17.15"
17
17
  },
18
18
  "devDependencies": {
19
- "@ckeditor/ckeditor5-alignment": "^35.4.0",
20
- "@ckeditor/ckeditor5-basic-styles": "^35.4.0",
21
- "@ckeditor/ckeditor5-block-quote": "^35.4.0",
22
- "@ckeditor/ckeditor5-clipboard": "^35.4.0",
23
- "@ckeditor/ckeditor5-core": "^35.4.0",
24
- "@ckeditor/ckeditor5-dev-utils": "^31.0.0",
25
- "@ckeditor/ckeditor5-editor-classic": "^35.4.0",
26
- "@ckeditor/ckeditor5-engine": "^35.4.0",
27
- "@ckeditor/ckeditor5-highlight": "^35.4.0",
28
- "@ckeditor/ckeditor5-horizontal-line": "^35.4.0",
29
- "@ckeditor/ckeditor5-html-support": "^35.4.0",
30
- "@ckeditor/ckeditor5-image": "^35.4.0",
31
- "@ckeditor/ckeditor5-indent": "^35.4.0",
32
- "@ckeditor/ckeditor5-link": "^35.4.0",
33
- "@ckeditor/ckeditor5-list": "^35.4.0",
34
- "@ckeditor/ckeditor5-media-embed": "^35.4.0",
35
- "@ckeditor/ckeditor5-paragraph": "^35.4.0",
36
- "@ckeditor/ckeditor5-theme-lark": "^35.4.0",
37
- "@ckeditor/ckeditor5-typing": "^35.4.0",
38
- "@ckeditor/ckeditor5-ui": "^35.4.0",
39
- "@ckeditor/ckeditor5-undo": "^35.4.0",
40
- "@ckeditor/ckeditor5-utils": "^35.4.0",
41
- "@ckeditor/ckeditor5-widget": "^35.4.0",
42
- "@ckeditor/ckeditor5-source-editing": "^35.4.0",
19
+ "@ckeditor/ckeditor5-alignment": "^36.0.0",
20
+ "@ckeditor/ckeditor5-basic-styles": "^36.0.0",
21
+ "@ckeditor/ckeditor5-block-quote": "^36.0.0",
22
+ "@ckeditor/ckeditor5-clipboard": "^36.0.0",
23
+ "@ckeditor/ckeditor5-core": "^36.0.0",
24
+ "@ckeditor/ckeditor5-dev-utils": "^32.0.0",
25
+ "@ckeditor/ckeditor5-editor-classic": "^36.0.0",
26
+ "@ckeditor/ckeditor5-engine": "^36.0.0",
27
+ "@ckeditor/ckeditor5-highlight": "^36.0.0",
28
+ "@ckeditor/ckeditor5-horizontal-line": "^36.0.0",
29
+ "@ckeditor/ckeditor5-html-support": "^36.0.0",
30
+ "@ckeditor/ckeditor5-image": "^36.0.0",
31
+ "@ckeditor/ckeditor5-indent": "^36.0.0",
32
+ "@ckeditor/ckeditor5-link": "^36.0.0",
33
+ "@ckeditor/ckeditor5-list": "^36.0.0",
34
+ "@ckeditor/ckeditor5-media-embed": "^36.0.0",
35
+ "@ckeditor/ckeditor5-paragraph": "^36.0.0",
36
+ "@ckeditor/ckeditor5-theme-lark": "^36.0.0",
37
+ "@ckeditor/ckeditor5-typing": "^36.0.0",
38
+ "@ckeditor/ckeditor5-ui": "^36.0.0",
39
+ "@ckeditor/ckeditor5-undo": "^36.0.0",
40
+ "@ckeditor/ckeditor5-utils": "^36.0.0",
41
+ "@ckeditor/ckeditor5-widget": "^36.0.0",
42
+ "@ckeditor/ckeditor5-source-editing": "^36.0.0",
43
43
  "json-diff": "^0.5.4",
44
44
  "webpack": "^5.58.1",
45
45
  "webpack-cli": "^4.9.0"
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
 
@@ -114,7 +114,7 @@ export function downcastCell( options = {} ) {
114
114
  * @returns {Function} Element creator.
115
115
  */
116
116
  export function convertParagraphInTableCell( options = {} ) {
117
- return ( modelElement, { writer, consumable, mapper } ) => {
117
+ return ( modelElement, { writer } ) => {
118
118
  if ( !modelElement.parent.is( 'element', 'tableCell' ) ) {
119
119
  return;
120
120
  }
@@ -126,9 +126,12 @@ export function convertParagraphInTableCell( options = {} ) {
126
126
  if ( options.asWidget ) {
127
127
  return writer.createContainerElement( 'span', { class: 'ck-table-bogus-paragraph' } );
128
128
  } else {
129
- // Additional requirement for data pipeline to have backward compatible data tables.
130
- consumable.consume( modelElement, 'insert' );
131
- mapper.bindElements( modelElement, mapper.toViewElement( modelElement.parent ) );
129
+ // Using `<p>` in case there are some markers on it and transparentRendering will render it anyway.
130
+ const viewElement = writer.createContainerElement( 'p' );
131
+
132
+ writer.setCustomProperty( 'dataPipeline:transparentRendering', true, viewElement );
133
+
134
+ return viewElement;
132
135
  }
133
136
  };
134
137
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
 
@@ -146,18 +146,33 @@ export function skipEmptyTableRow() {
146
146
  */
147
147
  export function ensureParagraphInTableCell( elementName ) {
148
148
  return dispatcher => {
149
- dispatcher.on( `element:${ elementName }`, ( evt, data, conversionApi ) => {
149
+ dispatcher.on( `element:${ elementName }`, ( evt, data, { writer } ) => {
150
150
  // The default converter will create a model range on converted table cell.
151
151
  if ( !data.modelRange ) {
152
152
  return;
153
153
  }
154
154
 
155
+ const tableCell = data.modelRange.start.nodeAfter;
156
+ const modelCursor = writer.createPositionAt( tableCell, 0 );
157
+
155
158
  // Ensure a paragraph in the model for empty table cells for converted table cells.
156
159
  if ( data.viewItem.isEmpty ) {
157
- const tableCell = data.modelRange.start.nodeAfter;
158
- const modelCursor = conversionApi.writer.createPositionAt( tableCell, 0 );
160
+ writer.insertElement( 'paragraph', modelCursor );
161
+
162
+ return;
163
+ }
159
164
 
160
- conversionApi.writer.insertElement( 'paragraph', modelCursor );
165
+ const childNodes = Array.from( tableCell.getChildren() );
166
+
167
+ // In case there are only markers inside the table cell then move them to the paragraph.
168
+ if ( childNodes.every( node => node.is( 'element', '$marker' ) ) ) {
169
+ const paragraph = writer.createElement( 'paragraph' );
170
+
171
+ writer.insert( paragraph, writer.createPositionAt( tableCell, 0 ) );
172
+
173
+ for ( const node of childNodes ) {
174
+ writer.move( writer.createRangeOn( node ), writer.createPositionAt( paragraph, 'end' ) );
175
+ }
161
176
  }
162
177
  }, { priority: 'low' } );
163
178
  };
package/src/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
 
package/src/table.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
 
@@ -113,7 +113,7 @@ export default class TableCellPropertiesUI extends Plugin {
113
113
  *
114
114
  * @member {module:table/tablecellproperties/ui/tablecellpropertiesview~TableCellPropertiesView}
115
115
  */
116
- this.view = this._createPropertiesView();
116
+ this.view = null;
117
117
 
118
118
  /**
119
119
  * The batch used to undo all changes made by the form (which are live, as the user types)
@@ -124,6 +124,15 @@ export default class TableCellPropertiesUI extends Plugin {
124
124
  */
125
125
  this._undoStepBatch = null;
126
126
 
127
+ /**
128
+ * Flag used to indicate whether view is ready to execute update commands
129
+ * (it finished loading initial data).
130
+ *
131
+ * @private
132
+ * @member {Boolean}
133
+ */
134
+ this._isReady = false;
135
+
127
136
  editor.ui.componentFactory.add( 'tableCellProperties', locale => {
128
137
  const view = new ButtonView( locale );
129
138
 
@@ -154,7 +163,9 @@ export default class TableCellPropertiesUI extends Plugin {
154
163
 
155
164
  // Destroy created UI components as they are not automatically destroyed.
156
165
  // See https://github.com/ckeditor/ckeditor5/issues/1341.
157
- this.view.destroy();
166
+ if ( this.view ) {
167
+ this.view.destroy();
168
+ }
158
169
  }
159
170
 
160
171
  /**
@@ -166,12 +177,12 @@ export default class TableCellPropertiesUI extends Plugin {
166
177
  */
167
178
  _createPropertiesView() {
168
179
  const editor = this.editor;
169
- const viewDocument = editor.editing.view.document;
170
180
  const config = editor.config.get( 'table.tableCellProperties' );
171
181
  const borderColorsConfig = normalizeColorOptions( config.borderColors );
172
182
  const localizedBorderColors = getLocalizedColorOptions( editor.locale, borderColorsConfig );
173
183
  const backgroundColorsConfig = normalizeColorOptions( config.backgroundColors );
174
184
  const localizedBackgroundColors = getLocalizedColorOptions( editor.locale, backgroundColorsConfig );
185
+
175
186
  const view = new TableCellPropertiesView( editor.locale, {
176
187
  borderColors: localizedBorderColors,
177
188
  backgroundColors: localizedBackgroundColors,
@@ -201,15 +212,6 @@ export default class TableCellPropertiesUI extends Plugin {
201
212
  cancel();
202
213
  } );
203
214
 
204
- // Reposition the balloon or hide the form if a table cell is no longer selected.
205
- this.listenTo( editor.ui, 'update', () => {
206
- if ( !getTableWidgetAncestor( viewDocument.selection ) ) {
207
- this._hideView();
208
- } else if ( this._isViewVisible ) {
209
- repositionContextualBalloon( editor, 'cell' );
210
- }
211
- } );
212
-
213
215
  // Close on click outside of balloon panel element.
214
216
  clickOutsideHandler( {
215
217
  emitter: view,
@@ -319,6 +321,8 @@ export default class TableCellPropertiesUI extends Plugin {
319
321
 
320
322
  this.view.set( property, value );
321
323
  } );
324
+
325
+ this._isReady = true;
322
326
  }
323
327
 
324
328
  /**
@@ -333,6 +337,14 @@ export default class TableCellPropertiesUI extends Plugin {
333
337
  _showView() {
334
338
  const editor = this.editor;
335
339
 
340
+ if ( !this.view ) {
341
+ this.view = this._createPropertiesView();
342
+ }
343
+
344
+ this.listenTo( editor.ui, 'update', () => {
345
+ this._updateView();
346
+ } );
347
+
336
348
  // Update the view with the model values.
337
349
  this._fillViewFormFromCommandValues();
338
350
 
@@ -354,14 +366,12 @@ export default class TableCellPropertiesUI extends Plugin {
354
366
  * @protected
355
367
  */
356
368
  _hideView() {
357
- if ( !this._isViewInBalloon ) {
358
- return;
359
- }
360
-
361
369
  const editor = this.editor;
362
370
 
363
371
  this.stopListening( editor.ui, 'update' );
364
372
 
373
+ this._isReady = false;
374
+
365
375
  // Blur any input element before removing it from DOM to prevent issues in some browsers.
366
376
  // See https://github.com/ckeditor/ckeditor5/issues/1501.
367
377
  this.view.saveButtonView.focus();
@@ -373,6 +383,22 @@ export default class TableCellPropertiesUI extends Plugin {
373
383
  this.editor.editing.view.focus();
374
384
  }
375
385
 
386
+ /**
387
+ * Repositions the {@link #_balloon} or hides the {@link #view} if a table cell is no longer selected.
388
+ *
389
+ * @protected
390
+ */
391
+ _updateView() {
392
+ const editor = this.editor;
393
+ const viewDocument = editor.editing.view.document;
394
+
395
+ if ( !getTableWidgetAncestor( viewDocument.selection ) ) {
396
+ this._hideView();
397
+ } else if ( this._isViewVisible ) {
398
+ repositionContextualBalloon( editor, 'cell' );
399
+ }
400
+ }
401
+
376
402
  /**
377
403
  * Returns `true` when the {@link #view} is visible in the {@link #_balloon}.
378
404
  *
@@ -380,7 +406,7 @@ export default class TableCellPropertiesUI extends Plugin {
380
406
  * @type {Boolean}
381
407
  */
382
408
  get _isViewVisible() {
383
- return this._balloon.visibleView === this.view;
409
+ return !!this.view && this._balloon.visibleView === this.view;
384
410
  }
385
411
 
386
412
  /**
@@ -390,7 +416,7 @@ export default class TableCellPropertiesUI extends Plugin {
390
416
  * @type {Boolean}
391
417
  */
392
418
  get _isViewInBalloon() {
393
- return this._balloon.hasView( this.view );
419
+ return !!this.view && this._balloon.hasView( this.view );
394
420
  }
395
421
 
396
422
  /**
@@ -399,14 +425,12 @@ export default class TableCellPropertiesUI extends Plugin {
399
425
  *
400
426
  * @private
401
427
  * @param {String} commandName
402
- * @param {String} defaultValue The default value of the command.
403
428
  * @returns {Function}
404
429
  */
405
- _getPropertyChangeCallback( commandName, defaultValue ) {
406
- return ( evt, propertyName, newValue, oldValue ) => {
407
- // If the "oldValue" is missing and "newValue" is set to the default value, do not execute the command.
408
- // It is an initial call (when opening the table properties view).
409
- if ( !oldValue && defaultValue === newValue ) {
430
+ _getPropertyChangeCallback( commandName ) {
431
+ return ( evt, propertyName, newValue ) => {
432
+ // Do not execute the command on initial call (opening the table properties view).
433
+ if ( !this._isReady ) {
410
434
  return;
411
435
  }
412
436
 
@@ -428,21 +452,18 @@ export default class TableCellPropertiesUI extends Plugin {
428
452
  * @param {module:ui/view~View} options.viewField
429
453
  * @param {Function} options.validator
430
454
  * @param {String} options.errorText
431
- * @param {String} options.defaultValue
432
455
  * @returns {Function}
433
456
  */
434
457
  _getValidatedPropertyChangeCallback( options ) {
435
- const { commandName, viewField, validator, errorText, defaultValue } = options;
458
+ const { commandName, viewField, validator, errorText } = options;
436
459
  const setErrorTextDebounced = debounce( () => {
437
460
  viewField.errorText = errorText;
438
461
  }, ERROR_TEXT_TIMEOUT );
439
462
 
440
- return ( evt, propertyName, newValue, oldValue ) => {
463
+ return ( evt, propertyName, newValue ) => {
441
464
  setErrorTextDebounced.cancel();
442
-
443
- // If the "oldValue" is missing and "newValue" is set to the default value, do not execute the command.
444
- // It is an initial call (when opening the table properties view).
445
- if ( !oldValue && defaultValue === newValue ) {
465
+ // Do not execute the command on initial call (opening the table properties view).
466
+ if ( !this._isReady ) {
446
467
  return;
447
468
  }
448
469