@ckeditor/ckeditor5-table 35.3.2 → 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 (97) 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 +7 -2
  23. package/src/converters/upcasttable.js +21 -6
  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 +9 -4
  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 +8 -2
  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 +2 -2
  76. package/src/ui/colorinputview.js +1 -1
  77. package/src/ui/formrowview.js +1 -1
  78. package/src/ui/inserttableview.js +3 -2
  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
  97. package/build/table.js.map +0 -1
@@ -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
 
@@ -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
 
@@ -68,9 +68,11 @@ export function downcastTableColumnWidthsAttribute() {
68
68
  return dispatcher => dispatcher.on( 'attribute:columnWidths:table', ( evt, data, conversionApi ) => {
69
69
  const viewWriter = conversionApi.writer;
70
70
  const modelTable = data.item;
71
+ const viewElement = conversionApi.mapper.toViewElement( modelTable );
71
72
 
72
- const viewTable = [ ...conversionApi.mapper.toViewElement( modelTable ).getChildren() ]
73
- .find( viewChild => viewChild.is( 'element', 'table' ) );
73
+ const viewTable = viewElement.is( 'element', 'table' ) ?
74
+ viewElement :
75
+ Array.from( viewElement.getChildren() ).find( viewChild => viewChild.is( 'element', 'table' ) );
74
76
 
75
77
  if ( data.attributeNewValue ) {
76
78
  // If new value is the same as the old, the operation is not applied (see the `writer.setAttributeOnItem()`).
@@ -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
 
@@ -35,7 +35,6 @@ import {
35
35
  getTableWidthInPixels,
36
36
  normalizeColumnWidths,
37
37
  toPrecision,
38
- ensureColumnResizerElement,
39
38
  getDomCellOuterWidth
40
39
  } from './utils';
41
40
 
@@ -715,18 +714,17 @@ export default class TableColumnResizeEditing extends Plugin {
715
714
  * @private
716
715
  */
717
716
  _registerResizerInserter() {
718
- const view = this.editor.editing.view;
719
-
720
- view.on( 'render', () => {
721
- for ( const item of view.createRangeIn( view.document.getRoot() ) ) {
722
- if ( ![ 'td', 'th' ].includes( item.item.name ) ) {
723
- continue;
724
- }
725
-
726
- view.change( viewWriter => {
727
- ensureColumnResizerElement( viewWriter, item.item );
728
- } );
729
- }
730
- }, { priority: 'lowest' } );
717
+ this.editor.conversion.for( 'editingDowncast' ).add( dispatcher => {
718
+ dispatcher.on( 'insert:tableCell', ( evt, data, conversionApi ) => {
719
+ const modelElement = data.item;
720
+ const viewElement = conversionApi.mapper.toViewElement( modelElement );
721
+ const viewWriter = conversionApi.writer;
722
+
723
+ viewWriter.insert(
724
+ viewWriter.createPositionAt( viewElement, 'end' ),
725
+ viewWriter.createUIElement( 'div', { class: 'ck-table-column-resizer' } )
726
+ );
727
+ }, { priority: 'lowest' } );
728
+ } );
731
729
  }
732
730
  }
@@ -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
 
@@ -39,8 +39,8 @@ export default class TableWidthResizeCommand extends TablePropertyCommand {
39
39
  * Changes the `tableWidth` and `columnWidths` attribute values for the given or currently selected table.
40
40
  *
41
41
  * @param {Object} options
42
- * @param {String} [options.tableWidth] The new table width.
43
- * @param {String} [options.columnWidths] The new table column widths.
42
+ * @param {String} [options.tableWidth] The new table width. If skipped, the model attribute will be removed.
43
+ * @param {String} [options.columnWidths] The new table column widths. If skipped, the model attribute will be removed.
44
44
  * @param {module:engine/model/element~Element} [options.table] The table that is affected by the resize.
45
45
  */
46
46
  execute( options = {} ) {
@@ -51,10 +51,15 @@ export default class TableWidthResizeCommand extends TablePropertyCommand {
51
51
  model.change( writer => {
52
52
  if ( tableWidth ) {
53
53
  writer.setAttribute( this.attributeName, tableWidth, table );
54
- writer.setAttribute( 'columnWidths', columnWidths, table );
55
54
  } else {
56
55
  writer.removeAttribute( this.attributeName, table );
57
56
  }
57
+
58
+ if ( columnWidths ) {
59
+ writer.setAttribute( 'columnWidths', columnWidths, table );
60
+ } else {
61
+ writer.removeAttribute( 'columnWidths', table );
62
+ }
58
63
  } );
59
64
  }
60
65
  }
@@ -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
 
@@ -282,30 +282,6 @@ function calculateMissingColumnWidths( columnWidths ) {
282
282
  .map( columnWidth => toPrecision( columnWidth ) );
283
283
  }
284
284
 
285
- /**
286
- * Inserts column resizer element into a view cell if it is missing.
287
- *
288
- * @param {module:engine/view/downcastwriter~DowncastWriter} viewWriter View writer instance.
289
- * @param {module:engine/view/element~Element} viewCell View cell where resizer should be put.
290
- */
291
- export function ensureColumnResizerElement( viewWriter, viewCell ) {
292
- let viewTableColumnResizerElement = [ ...viewCell.getChildren() ]
293
- .find( viewElement => viewElement.hasClass( 'ck-table-column-resizer' ) );
294
-
295
- if ( viewTableColumnResizerElement ) {
296
- return;
297
- }
298
-
299
- viewTableColumnResizerElement = viewWriter.createUIElement( 'div', {
300
- class: 'ck-table-column-resizer'
301
- } );
302
-
303
- viewWriter.insert(
304
- viewWriter.createPositionAt( viewCell, 'end' ),
305
- viewTableColumnResizerElement
306
- );
307
- }
308
-
309
285
  /**
310
286
  * Calculates the total horizontal space taken by the cell. That includes:
311
287
  * * width,
@@ -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
 
@@ -152,11 +152,6 @@ export default class TableEditing extends Plugin {
152
152
  view: 'rowspan'
153
153
  } );
154
154
 
155
- // Manually adjust model position mappings in a special case, when a table cell contains a paragraph, which is bound
156
- // to its parent (to the table cell). This custom model-to-view position mapping is necessary in data pipeline only,
157
- // because only during this conversion a paragraph can be bound to its parent.
158
- editor.data.mapper.on( 'modelToViewPosition', mapTableCellModelPositionToView() );
159
-
160
155
  // Define the config.
161
156
  editor.config.define( 'table.defaultHeadings.rows', 0 );
162
157
  editor.config.define( 'table.defaultHeadings.columns', 0 );
@@ -197,40 +192,6 @@ export default class TableEditing extends Plugin {
197
192
  }
198
193
  }
199
194
 
200
- // Creates a mapper callback to adjust model position mappings in a table cell containing a paragraph, which is bound to its parent
201
- // (to the table cell). Only positions after this paragraph have to be adjusted, because after binding this paragraph to the table cell,
202
- // elements located after this paragraph would point either to a non-existent offset inside `tableCell` (if paragraph is empty), or after
203
- // the first character of the paragraph's text. See https://github.com/ckeditor/ckeditor5/issues/10116.
204
- //
205
- // <tableCell><paragraph></paragraph>^</tableCell> -> <td>^&nbsp;</td>
206
- //
207
- // <tableCell><paragraph>foobar</paragraph>^</tableCell> -> <td>foobar^</td>
208
- //
209
- // @returns {Function}
210
- function mapTableCellModelPositionToView() {
211
- return ( evt, data ) => {
212
- const modelParent = data.modelPosition.parent;
213
- const modelNodeBefore = data.modelPosition.nodeBefore;
214
-
215
- if ( !modelParent.is( 'element', 'tableCell' ) ) {
216
- return;
217
- }
218
-
219
- if ( !modelNodeBefore || !modelNodeBefore.is( 'element', 'paragraph' ) ) {
220
- return;
221
- }
222
-
223
- const viewNodeBefore = data.mapper.toViewElement( modelNodeBefore );
224
- const viewParent = data.mapper.toViewElement( modelParent );
225
-
226
- if ( viewNodeBefore === viewParent ) {
227
- // Since the paragraph has already been bound to its parent, update the current position in the model with paragraph's
228
- // max offset, so it points to the place which should normally (in all other cases) be the end position of this paragraph.
229
- data.viewPosition = data.mapper.findPositionIn( viewParent, modelNodeBefore.maxOffset );
230
- }
231
- };
232
- }
233
-
234
195
  // Returns fixed colspan and rowspan attrbutes values.
235
196
  //
236
197
  // @private
@@ -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/tablemouse.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
 
@@ -242,6 +242,12 @@ function enableTableToFigureProperty( schema, conversion, options ) {
242
242
  schema.extend( 'table', {
243
243
  allowAttributes: [ modelAttribute ]
244
244
  } );
245
- upcastStyleToAttribute( conversion, { viewElement: /^(table|figure)$/, ...options } );
245
+
246
+ upcastStyleToAttribute( conversion, {
247
+ viewElement: /^(table|figure)$/,
248
+ shouldUpcast: element => !( element.name == 'table' && element.parent.name == 'figure' ),
249
+ ...options
250
+ } );
251
+
246
252
  downcastAttributeToStyle( conversion, { modelElement: 'table', ...options } );
247
253
  }