@ckeditor/ckeditor5-table 29.2.0 → 32.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/build/table.js +3 -3
  3. package/build/translations/cs.js +1 -1
  4. package/build/translations/es.js +1 -1
  5. package/build/translations/id.js +1 -1
  6. package/build/translations/nl.js +1 -1
  7. package/build/translations/pl.js +1 -1
  8. package/build/translations/pt-br.js +1 -1
  9. package/build/translations/sr-latn.js +1 -1
  10. package/build/translations/sr.js +1 -1
  11. package/build/translations/uz.js +1 -0
  12. package/build/translations/zh.js +1 -1
  13. package/lang/translations/ar.po +1 -1
  14. package/lang/translations/az.po +1 -1
  15. package/lang/translations/bg.po +1 -1
  16. package/lang/translations/cs.po +4 -4
  17. package/lang/translations/da.po +1 -1
  18. package/lang/translations/de-ch.po +1 -1
  19. package/lang/translations/de.po +1 -1
  20. package/lang/translations/en-au.po +1 -1
  21. package/lang/translations/en-gb.po +1 -1
  22. package/lang/translations/en.po +1 -1
  23. package/lang/translations/es.po +12 -12
  24. package/lang/translations/et.po +1 -1
  25. package/lang/translations/fa.po +1 -1
  26. package/lang/translations/fi.po +1 -1
  27. package/lang/translations/fr.po +1 -1
  28. package/lang/translations/gl.po +1 -1
  29. package/lang/translations/hi.po +1 -1
  30. package/lang/translations/hr.po +1 -1
  31. package/lang/translations/hu.po +1 -1
  32. package/lang/translations/id.po +11 -11
  33. package/lang/translations/it.po +1 -1
  34. package/lang/translations/ja.po +1 -1
  35. package/lang/translations/ko.po +1 -1
  36. package/lang/translations/ku.po +1 -1
  37. package/lang/translations/lt.po +1 -1
  38. package/lang/translations/lv.po +1 -1
  39. package/lang/translations/nb.po +1 -1
  40. package/lang/translations/ne.po +1 -1
  41. package/lang/translations/nl.po +3 -3
  42. package/lang/translations/no.po +1 -1
  43. package/lang/translations/pl.po +4 -4
  44. package/lang/translations/pt-br.po +4 -4
  45. package/lang/translations/ro.po +1 -1
  46. package/lang/translations/ru.po +1 -1
  47. package/lang/translations/sk.po +1 -1
  48. package/lang/translations/sq.po +1 -1
  49. package/lang/translations/sr-latn.po +4 -4
  50. package/lang/translations/sr.po +4 -4
  51. package/lang/translations/sv.po +1 -1
  52. package/lang/translations/th.po +1 -1
  53. package/lang/translations/tk.po +1 -1
  54. package/lang/translations/tr.po +1 -1
  55. package/lang/translations/ug.po +1 -1
  56. package/lang/translations/uk.po +1 -1
  57. package/lang/translations/uz.po +261 -0
  58. package/lang/translations/vi.po +1 -1
  59. package/lang/translations/zh-cn.po +1 -1
  60. package/lang/translations/zh.po +4 -4
  61. package/package.json +24 -24
  62. package/src/commands/insertcolumncommand.js +1 -1
  63. package/src/commands/insertrowcommand.js +1 -1
  64. package/src/commands/inserttablecommand.js +1 -1
  65. package/src/commands/mergecellcommand.js +1 -1
  66. package/src/commands/mergecellscommand.js +1 -1
  67. package/src/commands/removecolumncommand.js +1 -1
  68. package/src/commands/removerowcommand.js +1 -1
  69. package/src/commands/selectcolumncommand.js +11 -1
  70. package/src/commands/selectrowcommand.js +11 -1
  71. package/src/commands/setheadercolumncommand.js +1 -1
  72. package/src/commands/setheaderrowcommand.js +1 -1
  73. package/src/commands/splitcellcommand.js +1 -1
  74. package/src/converters/downcast.js +2 -19
  75. package/src/converters/table-caption-post-fixer.js +1 -1
  76. package/src/converters/table-cell-paragraph-post-fixer.js +1 -1
  77. package/src/converters/table-cell-refresh-post-fixer.js +1 -1
  78. package/src/converters/table-heading-rows-refresh-post-fixer.js +24 -7
  79. package/src/converters/table-layout-post-fixer.js +1 -1
  80. package/src/converters/tableproperties.js +6 -5
  81. package/src/converters/upcasttable.js +7 -1
  82. package/src/index.js +1 -1
  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 +2 -2
  90. package/src/tablecellproperties/commands/tablecellbordercolorcommand.js +2 -2
  91. package/src/tablecellproperties/commands/tablecellborderstylecommand.js +2 -2
  92. package/src/tablecellproperties/commands/tablecellborderwidthcommand.js +2 -2
  93. package/src/tablecellproperties/commands/tablecellheightcommand.js +2 -2
  94. package/src/tablecellproperties/commands/tablecellhorizontalalignmentcommand.js +2 -2
  95. package/src/tablecellproperties/commands/tablecellpaddingcommand.js +2 -2
  96. package/src/tablecellproperties/commands/tablecellpropertycommand.js +2 -2
  97. package/src/tablecellproperties/commands/tablecellverticalalignmentcommand.js +2 -2
  98. package/src/tablecellproperties/commands/tablecellwidthcommand.js +2 -2
  99. package/src/tablecellproperties/tablecellpropertiesediting.js +42 -35
  100. package/src/tablecellproperties/tablecellpropertiesui.js +1 -1
  101. package/src/tablecellproperties/ui/tablecellpropertiesview.js +11 -2
  102. package/src/tablecellproperties.js +1 -1
  103. package/src/tableclipboard.js +1 -1
  104. package/src/tableediting.js +1 -1
  105. package/src/tablekeyboard.js +20 -5
  106. package/src/tablemouse/mouseeventsobserver.js +1 -1
  107. package/src/tablemouse.js +1 -1
  108. package/src/tableproperties/commands/tablealignmentcommand.js +2 -2
  109. package/src/tableproperties/commands/tablebackgroundcolorcommand.js +2 -2
  110. package/src/tableproperties/commands/tablebordercolorcommand.js +2 -2
  111. package/src/tableproperties/commands/tableborderstylecommand.js +2 -2
  112. package/src/tableproperties/commands/tableborderwidthcommand.js +2 -2
  113. package/src/tableproperties/commands/tableheightcommand.js +2 -2
  114. package/src/tableproperties/commands/tablepropertycommand.js +2 -2
  115. package/src/tableproperties/commands/tablewidthcommand.js +2 -2
  116. package/src/tableproperties/tablepropertiesediting.js +29 -21
  117. package/src/tableproperties/tablepropertiesui.js +1 -1
  118. package/src/tableproperties/ui/tablepropertiesview.js +11 -2
  119. package/src/tableproperties.js +1 -1
  120. package/src/tableselection.js +1 -1
  121. package/src/tabletoolbar.js +1 -1
  122. package/src/tableui.js +1 -1
  123. package/src/tableutils.js +1 -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/selection.js +1 -1
  130. package/src/utils/structure.js +1 -1
  131. package/src/utils/table-properties.js +1 -1
  132. package/src/utils/ui/contextualballoon.js +4 -9
  133. package/src/utils/ui/table-properties.js +1 -1
  134. package/src/utils/ui/widget.js +1 -1
  135. package/theme/colorinput.css +4 -1
  136. package/theme/form.css +1 -1
  137. package/theme/formrow.css +1 -1
  138. package/theme/inserttable.css +1 -1
  139. package/theme/table.css +1 -1
  140. package/theme/tablecaption.css +1 -1
  141. package/theme/tablecellproperties.css +1 -1
  142. package/theme/tableediting.css +1 -1
  143. package/theme/tableform.css +1 -1
  144. package/theme/tableproperties.css +1 -1
  145. package/theme/tableselection.css +1 -1
  146. package/CHANGELOG.md +0 -261
@@ -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,8 +8,7 @@
8
8
  */
9
9
 
10
10
  import TableWalker from './../tablewalker';
11
- import { setHighlightHandling, toWidget, toWidgetEditable } from 'ckeditor5/src/widget';
12
- import { toArray } from 'ckeditor5/src/utils';
11
+ import { toWidget, toWidgetEditable } from 'ckeditor5/src/widget';
13
12
 
14
13
  /**
15
14
  * Model table element to view table element conversion helper.
@@ -311,13 +310,6 @@ function renameViewTableCell( tableCell, desiredCellElementName, conversionApi )
311
310
  const editable = viewWriter.createEditableElement( desiredCellElementName, viewCell.getAttributes() );
312
311
  const renamedCell = toWidgetEditable( editable, viewWriter );
313
312
 
314
- setHighlightHandling(
315
- renamedCell,
316
- viewWriter,
317
- ( element, descriptor, writer ) => writer.addClass( toArray( descriptor.classes ), element ),
318
- ( element, descriptor, writer ) => writer.removeClass( toArray( descriptor.classes ), element )
319
- );
320
-
321
313
  viewWriter.insert( viewWriter.createPositionAfter( viewCell ), renamedCell );
322
314
  viewWriter.move( viewWriter.createRangeIn( viewCell ), viewWriter.createPositionAt( renamedCell, 0 ) );
323
315
  viewWriter.remove( viewWriter.createRangeOn( viewCell ) );
@@ -359,15 +351,6 @@ function createViewTableCellElement( tableSlot, tableAttributes, insertPosition,
359
351
  toWidgetEditable( conversionApi.writer.createEditableElement( cellElementName ), conversionApi.writer ) :
360
352
  conversionApi.writer.createContainerElement( cellElementName );
361
353
 
362
- if ( asWidget ) {
363
- setHighlightHandling(
364
- cellElement,
365
- conversionApi.writer,
366
- ( element, descriptor, writer ) => writer.addClass( toArray( descriptor.classes ), element ),
367
- ( element, descriptor, writer ) => writer.removeClass( toArray( descriptor.classes ), element )
368
- );
369
- }
370
-
371
354
  const tableCell = tableSlot.cell;
372
355
 
373
356
  const firstChild = tableCell.getChild( 0 );
@@ -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
 
@@ -29,14 +29,31 @@ function tableHeadingRowsRefreshPostFixer( model ) {
29
29
  const tablesToRefresh = new Set();
30
30
 
31
31
  for ( const change of differ.getChanges() ) {
32
- if ( change.type != 'attribute' ) {
33
- continue;
34
- }
32
+ if ( change.type === 'attribute' ) {
33
+ const element = change.range.start.nodeAfter;
34
+
35
+ if ( element && element.is( 'element', 'table' ) && change.attributeKey === 'headingRows' ) {
36
+ tablesToRefresh.add( element );
37
+ }
38
+ } else {
39
+ /* istanbul ignore else */
40
+ if ( change.type === 'insert' || change.type === 'remove' ) {
41
+ if ( change.name === 'tableRow' ) {
42
+ const table = change.position.findAncestor( 'table' );
43
+ const headingRows = table.getAttribute( 'headingRows' ) || 0;
35
44
 
36
- const element = change.range.start.nodeAfter;
45
+ if ( change.position.offset < headingRows ) {
46
+ tablesToRefresh.add( table );
47
+ }
48
+ } else if ( change.name === 'tableCell' ) {
49
+ const table = change.position.findAncestor( 'table' );
50
+ const headingColumns = table.getAttribute( 'headingColumns' ) || 0;
37
51
 
38
- if ( element && element.is( 'element', 'table' ) && change.attributeKey == 'headingRows' ) {
39
- tablesToRefresh.add( element );
52
+ if ( change.position.offset < headingColumns ) {
53
+ tablesToRefresh.add( table );
54
+ }
55
+ }
56
+ }
40
57
  }
41
58
  }
42
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
 
@@ -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
 
@@ -47,12 +47,13 @@ export function upcastStyleToAttribute( conversion, options ) {
47
47
  *
48
48
  * @param {module:engine/conversion/conversion~Conversion} conversion
49
49
  * @param {String} viewElementName
50
+ * @param {Object} modelAttributes
50
51
  * @param {Object} defaultBorder The default border values.
51
52
  * @param {String} defaultBorder.color The default `borderColor` value.
52
53
  * @param {String} defaultBorder.style The default `borderStyle` value.
53
54
  * @param {String} defaultBorder.width The default `borderWidth` value.
54
55
  */
55
- export function upcastBorderStyles( conversion, viewElementName, defaultBorder ) {
56
+ export function upcastBorderStyles( conversion, viewElementName, modelAttributes, defaultBorder ) {
56
57
  conversion.for( 'upcast' ).add( dispatcher => dispatcher.on( 'element:' + viewElementName, ( evt, data, conversionApi ) => {
57
58
  // If the element was not converted by element-to-element converter,
58
59
  // we should not try to convert the style. See #8393.
@@ -107,15 +108,15 @@ export function upcastBorderStyles( conversion, viewElementName, defaultBorder )
107
108
  };
108
109
 
109
110
  if ( reducedBorder.style !== defaultBorder.style ) {
110
- conversionApi.writer.setAttribute( 'borderStyle', reducedBorder.style, modelElement );
111
+ conversionApi.writer.setAttribute( modelAttributes.style, reducedBorder.style, modelElement );
111
112
  }
112
113
 
113
114
  if ( reducedBorder.color !== defaultBorder.color ) {
114
- conversionApi.writer.setAttribute( 'borderColor', reducedBorder.color, modelElement );
115
+ conversionApi.writer.setAttribute( modelAttributes.color, reducedBorder.color, modelElement );
115
116
  }
116
117
 
117
118
  if ( reducedBorder.width !== defaultBorder.width ) {
118
- conversionApi.writer.setAttribute( 'borderWidth', reducedBorder.width, modelElement );
119
+ conversionApi.writer.setAttribute( modelAttributes.width, reducedBorder.width, modelElement );
119
120
  }
120
121
  } ) );
121
122
  }
@@ -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
 
@@ -37,6 +37,9 @@ export function upcastTableFigure() {
37
37
  return;
38
38
  }
39
39
 
40
+ // Consume the figure to prevent other converters from processing it again.
41
+ conversionApi.consumable.consume( data.viewItem, { name: true, classes: 'table' } );
42
+
40
43
  // Convert view table to model table.
41
44
  const conversionResult = conversionApi.convertItem( viewTable, data.modelCursor );
42
45
 
@@ -45,6 +48,9 @@ export function upcastTableFigure() {
45
48
 
46
49
  // When table wasn't successfully converted then finish conversion.
47
50
  if ( !modelTable ) {
51
+ // Revert consumed figure so other features can convert it.
52
+ conversionApi.consumable.revert( data.viewItem, { name: true, classes: 'table' } );
53
+
48
54
  return;
49
55
  }
50
56
 
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
 
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
 
@@ -31,6 +31,6 @@ export default class TableCellBackgroundColorCommand extends TableCellPropertyCo
31
31
  * @param {String} defaultValue The default value of the attribute.
32
32
  */
33
33
  constructor( editor, defaultValue ) {
34
- super( editor, 'backgroundColor', defaultValue );
34
+ super( editor, 'tableCellBackgroundColor', defaultValue );
35
35
  }
36
36
  }
@@ -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
 
@@ -32,7 +32,7 @@ export default class TableCellBorderColorCommand extends TableCellPropertyComman
32
32
  * @param {String} defaultValue The default value of the attribute.
33
33
  */
34
34
  constructor( editor, defaultValue ) {
35
- super( editor, 'borderColor', defaultValue );
35
+ super( editor, 'tableCellBorderColor', defaultValue );
36
36
  }
37
37
 
38
38
  /**
@@ -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
 
@@ -32,7 +32,7 @@ export default class TableCellBorderStyleCommand extends TableCellPropertyComman
32
32
  * @param {String} defaultValue The default value of the attribute.
33
33
  */
34
34
  constructor( editor, defaultValue ) {
35
- super( editor, 'borderStyle', defaultValue );
35
+ super( editor, 'tableCellBorderStyle', defaultValue );
36
36
  }
37
37
 
38
38
  /**
@@ -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
 
@@ -40,7 +40,7 @@ export default class TableCellBorderWidthCommand extends TableCellPropertyComman
40
40
  * @param {String} defaultValue The default value of the attribute.
41
41
  */
42
42
  constructor( editor, defaultValue ) {
43
- super( editor, 'borderWidth', defaultValue );
43
+ super( editor, 'tableCellBorderWidth', defaultValue );
44
44
  }
45
45
 
46
46
  /**
@@ -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
 
@@ -40,7 +40,7 @@ export default class TableCellHeightCommand extends TableCellPropertyCommand {
40
40
  * @param {String} defaultValue The default value of the attribute.
41
41
  */
42
42
  constructor( editor, defaultValue ) {
43
- super( editor, 'height', defaultValue );
43
+ super( editor, 'tableCellHeight', defaultValue );
44
44
  }
45
45
 
46
46
  /**
@@ -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
 
@@ -31,6 +31,6 @@ export default class TableCellHorizontalAlignmentCommand extends TableCellProper
31
31
  * @param {String} defaultValue The default value for the "alignment" attribute.
32
32
  */
33
33
  constructor( editor, defaultValue ) {
34
- super( editor, 'horizontalAlignment', defaultValue );
34
+ super( editor, 'tableCellHorizontalAlignment', defaultValue );
35
35
  }
36
36
  }
@@ -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
 
@@ -40,7 +40,7 @@ export default class TableCellPaddingCommand extends TableCellPropertyCommand {
40
40
  * @param {String} defaultValue The default value of the attribute.
41
41
  */
42
42
  constructor( editor, defaultValue ) {
43
- super( editor, 'padding', defaultValue );
43
+ super( editor, 'tableCellPadding', defaultValue );
44
44
  }
45
45
 
46
46
  /**
@@ -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
 
@@ -73,7 +73,7 @@ export default class TableCellPropertyCommand extends Command {
73
73
  const tableCells = getSelectionAffectedTableCells( model.document.selection );
74
74
  const valueToSet = this._getValueToSet( value );
75
75
 
76
- model.enqueueChange( batch || 'default', writer => {
76
+ model.enqueueChange( batch, writer => {
77
77
  if ( valueToSet ) {
78
78
  tableCells.forEach( tableCell => writer.setAttribute( this.attributeName, valueToSet, tableCell ) );
79
79
  } 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
 
@@ -39,6 +39,6 @@ export default class TableCellVerticalAlignmentCommand extends TableCellProperty
39
39
  * @param {String} defaultValue The default value for the "alignment" attribute.
40
40
  */
41
41
  constructor( editor, defaultValue ) {
42
- super( editor, 'verticalAlignment', defaultValue );
42
+ super( editor, 'tableCellVerticalAlignment', defaultValue );
43
43
  }
44
44
  }
@@ -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
 
@@ -40,7 +40,7 @@ export default class TableCellWidthCommand extends TableCellPropertyCommand {
40
40
  * @param {String} defaultValue The default value of the attribute.
41
41
  */
42
42
  constructor( editor, defaultValue ) {
43
- super( editor, 'width', defaultValue );
43
+ super( editor, 'tableCellWidth', defaultValue );
44
44
  }
45
45
 
46
46
  /**
@@ -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
 
@@ -31,11 +31,11 @@ const ALIGN_VALUES_REG_EXP = /^(left|center|right|justify)$/;
31
31
  *
32
32
  * Introduces table cell model attributes and their conversion:
33
33
  *
34
- * - border: `borderStyle`, `borderColor` and `borderWidth`
35
- * - background color: `backgroundColor`
36
- * - cell padding: `padding`
37
- * - horizontal and vertical alignment: `horizontalAlignment`, `verticalAlignment`
38
- * - cell width and height: `width`, `height`
34
+ * - border: `tableCellBorderStyle`, `tableCellBorderColor` and `tableCellBorderWidth`
35
+ * - background color: `tableCellBackgroundColor`
36
+ * - cell padding: `tableCellPadding`
37
+ * - horizontal and vertical alignment: `tableCellHorizontalAlignment`, `tableCellVerticalAlignment`
38
+ * - cell width and height: `tableCellWidth`, `tableCellHeight`
39
39
  *
40
40
  * It also registers commands used to manipulate the above attributes:
41
41
  *
@@ -92,21 +92,15 @@ export default class TableCellPropertiesEditing extends Plugin {
92
92
  editor.commands.add( 'tableCellBorderColor', new TableCellBorderColorCommand( editor, defaultTableCellProperties.borderColor ) );
93
93
  editor.commands.add( 'tableCellBorderWidth', new TableCellBorderWidthCommand( editor, defaultTableCellProperties.borderWidth ) );
94
94
 
95
- enableHorizontalAlignmentProperty( schema, conversion, defaultTableCellProperties.horizontalAlignment );
96
- editor.commands.add(
97
- 'tableCellHorizontalAlignment',
98
- new TableCellHorizontalAlignmentCommand( editor, defaultTableCellProperties.horizontalAlignment )
99
- );
100
-
101
95
  enableProperty( schema, conversion, {
102
- modelAttribute: 'width',
96
+ modelAttribute: 'tableCellWidth',
103
97
  styleName: 'width',
104
98
  defaultValue: defaultTableCellProperties.width
105
99
  } );
106
100
  editor.commands.add( 'tableCellWidth', new TableCellWidthCommand( editor, defaultTableCellProperties.width ) );
107
101
 
108
102
  enableProperty( schema, conversion, {
109
- modelAttribute: 'height',
103
+ modelAttribute: 'tableCellHeight',
110
104
  styleName: 'height',
111
105
  defaultValue: defaultTableCellProperties.height
112
106
  } );
@@ -114,7 +108,7 @@ export default class TableCellPropertiesEditing extends Plugin {
114
108
 
115
109
  editor.data.addStyleProcessorRules( addPaddingRules );
116
110
  enableProperty( schema, conversion, {
117
- modelAttribute: 'padding',
111
+ modelAttribute: 'tableCellPadding',
118
112
  styleName: 'padding',
119
113
  reduceBoxSides: true,
120
114
  defaultValue: defaultTableCellProperties.padding
@@ -123,7 +117,7 @@ export default class TableCellPropertiesEditing extends Plugin {
123
117
 
124
118
  editor.data.addStyleProcessorRules( addBackgroundRules );
125
119
  enableProperty( schema, conversion, {
126
- modelAttribute: 'backgroundColor',
120
+ modelAttribute: 'tableCellBackgroundColor',
127
121
  styleName: 'background-color',
128
122
  defaultValue: defaultTableCellProperties.backgroundColor
129
123
  } );
@@ -132,6 +126,12 @@ export default class TableCellPropertiesEditing extends Plugin {
132
126
  new TableCellBackgroundColorCommand( editor, defaultTableCellProperties.backgroundColor )
133
127
  );
134
128
 
129
+ enableHorizontalAlignmentProperty( schema, conversion, defaultTableCellProperties.horizontalAlignment );
130
+ editor.commands.add(
131
+ 'tableCellHorizontalAlignment',
132
+ new TableCellHorizontalAlignmentCommand( editor, defaultTableCellProperties.horizontalAlignment )
133
+ );
134
+
135
135
  enableVerticalAlignmentProperty( schema, conversion, defaultTableCellProperties.verticalAlignment );
136
136
  editor.commands.add(
137
137
  'tableCellVerticalAlignment',
@@ -140,26 +140,33 @@ export default class TableCellPropertiesEditing extends Plugin {
140
140
  }
141
141
  }
142
142
 
143
- // Enables the `'borderStyle'`, `'borderColor'` and `'borderWidth'` attributes for table cells.
143
+ // Enables the `'tableCellBorderStyle'`, `'tableCellBorderColor'` and `'tableCellBorderWidth'` attributes for table cells.
144
144
  //
145
145
  // @param {module:engine/model/schema~Schema} schema
146
146
  // @param {module:engine/conversion/conversion~Conversion} conversion
147
147
  // @param {Object} defaultBorder The default border values.
148
- // @param {String} defaultBorder.color The default `borderColor` value.
149
- // @param {String} defaultBorder.style The default `borderStyle` value.
150
- // @param {String} defaultBorder.width The default `borderWidth` value.
148
+ // @param {String} defaultBorder.color The default `tableCellBorderColor` value.
149
+ // @param {String} defaultBorder.style The default `tableCellBorderStyle` value.
150
+ // @param {String} defaultBorder.width The default `tableCellBorderWidth` value.
151
151
  function enableBorderProperties( schema, conversion, defaultBorder ) {
152
+ const modelAttributes = {
153
+ width: 'tableCellBorderWidth',
154
+ color: 'tableCellBorderColor',
155
+ style: 'tableCellBorderStyle'
156
+ };
157
+
152
158
  schema.extend( 'tableCell', {
153
- allowAttributes: [ 'borderWidth', 'borderColor', 'borderStyle' ]
159
+ allowAttributes: Object.values( modelAttributes )
154
160
  } );
155
- upcastBorderStyles( conversion, 'td', defaultBorder );
156
- upcastBorderStyles( conversion, 'th', defaultBorder );
157
- downcastAttributeToStyle( conversion, { modelElement: 'tableCell', modelAttribute: 'borderStyle', styleName: 'border-style' } );
158
- downcastAttributeToStyle( conversion, { modelElement: 'tableCell', modelAttribute: 'borderColor', styleName: 'border-color' } );
159
- downcastAttributeToStyle( conversion, { modelElement: 'tableCell', modelAttribute: 'borderWidth', styleName: 'border-width' } );
161
+
162
+ upcastBorderStyles( conversion, 'td', modelAttributes, defaultBorder );
163
+ upcastBorderStyles( conversion, 'th', modelAttributes, defaultBorder );
164
+ downcastAttributeToStyle( conversion, { modelElement: 'tableCell', modelAttribute: modelAttributes.style, styleName: 'border-style' } );
165
+ downcastAttributeToStyle( conversion, { modelElement: 'tableCell', modelAttribute: modelAttributes.color, styleName: 'border-color' } );
166
+ downcastAttributeToStyle( conversion, { modelElement: 'tableCell', modelAttribute: modelAttributes.width, styleName: 'border-width' } );
160
167
  }
161
168
 
162
- // Enables the `'horizontalAlignment'` attribute for table cells.
169
+ // Enables the `'tableCellHorizontalAlignment'` attribute for table cells.
163
170
  //
164
171
  // @param {module:engine/model/schema~Schema} schema
165
172
  // @param {module:engine/conversion/conversion~Conversion} conversion
@@ -167,14 +174,14 @@ function enableBorderProperties( schema, conversion, defaultBorder ) {
167
174
  // @param {String} defaultValue The default horizontal alignment value.
168
175
  function enableHorizontalAlignmentProperty( schema, conversion, defaultValue ) {
169
176
  schema.extend( 'tableCell', {
170
- allowAttributes: [ 'horizontalAlignment' ]
177
+ allowAttributes: [ 'tableCellHorizontalAlignment' ]
171
178
  } );
172
179
 
173
180
  conversion.for( 'downcast' )
174
181
  .attributeToAttribute( {
175
182
  model: {
176
183
  name: 'tableCell',
177
- key: 'horizontalAlignment'
184
+ key: 'tableCellHorizontalAlignment'
178
185
  },
179
186
  view: alignment => ( {
180
187
  key: 'style',
@@ -194,7 +201,7 @@ function enableHorizontalAlignmentProperty( schema, conversion, defaultValue ) {
194
201
  }
195
202
  },
196
203
  model: {
197
- key: 'horizontalAlignment',
204
+ key: 'tableCellHorizontalAlignment',
198
205
  value: viewElement => {
199
206
  const align = viewElement.getStyle( 'text-align' );
200
207
 
@@ -211,7 +218,7 @@ function enableHorizontalAlignmentProperty( schema, conversion, defaultValue ) {
211
218
  }
212
219
  },
213
220
  model: {
214
- key: 'horizontalAlignment',
221
+ key: 'tableCellHorizontalAlignment',
215
222
  value: viewElement => {
216
223
  const align = viewElement.getAttribute( 'align' );
217
224
 
@@ -228,14 +235,14 @@ function enableHorizontalAlignmentProperty( schema, conversion, defaultValue ) {
228
235
  // @param {String} defaultValue The default vertical alignment value.
229
236
  function enableVerticalAlignmentProperty( schema, conversion, defaultValue ) {
230
237
  schema.extend( 'tableCell', {
231
- allowAttributes: [ 'verticalAlignment' ]
238
+ allowAttributes: [ 'tableCellVerticalAlignment' ]
232
239
  } );
233
240
 
234
241
  conversion.for( 'downcast' )
235
242
  .attributeToAttribute( {
236
243
  model: {
237
244
  name: 'tableCell',
238
- key: 'verticalAlignment'
245
+ key: 'tableCellVerticalAlignment'
239
246
  },
240
247
  view: alignment => ( {
241
248
  key: 'style',
@@ -255,7 +262,7 @@ function enableVerticalAlignmentProperty( schema, conversion, defaultValue ) {
255
262
  }
256
263
  },
257
264
  model: {
258
- key: 'verticalAlignment',
265
+ key: 'tableCellVerticalAlignment',
259
266
  value: viewElement => {
260
267
  const align = viewElement.getStyle( 'vertical-align' );
261
268
 
@@ -272,7 +279,7 @@ function enableVerticalAlignmentProperty( schema, conversion, defaultValue ) {
272
279
  }
273
280
  },
274
281
  model: {
275
- key: 'verticalAlignment',
282
+ key: 'tableCellVerticalAlignment',
276
283
  value: viewElement => {
277
284
  const valign = viewElement.getAttribute( 'valign' );
278
285
 
@@ -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