@ckeditor/ckeditor5-table 35.4.0 → 36.0.1
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.
- package/LICENSE.md +1 -1
- package/build/table.js +2 -2
- package/package.json +26 -26
- package/src/commands/insertcolumncommand.js +1 -1
- package/src/commands/insertrowcommand.js +1 -1
- package/src/commands/inserttablecommand.js +1 -1
- package/src/commands/mergecellcommand.js +1 -1
- package/src/commands/mergecellscommand.js +1 -1
- package/src/commands/removecolumncommand.js +1 -1
- package/src/commands/removerowcommand.js +1 -1
- package/src/commands/selectcolumncommand.js +1 -1
- package/src/commands/selectrowcommand.js +1 -1
- package/src/commands/setheadercolumncommand.js +1 -1
- package/src/commands/setheaderrowcommand.js +1 -1
- package/src/commands/splitcellcommand.js +1 -1
- package/src/converters/downcast.js +8 -5
- package/src/converters/table-caption-post-fixer.js +1 -1
- package/src/converters/table-cell-paragraph-post-fixer.js +1 -1
- package/src/converters/table-cell-refresh-handler.js +1 -1
- package/src/converters/table-headings-refresh-handler.js +1 -1
- package/src/converters/table-layout-post-fixer.js +1 -1
- package/src/converters/tableproperties.js +1 -1
- package/src/converters/upcasttable.js +20 -5
- package/src/index.js +1 -1
- package/src/plaintableoutput.js +1 -1
- package/src/table.js +1 -1
- package/src/tablecaption/tablecaptionediting.js +1 -1
- package/src/tablecaption/tablecaptionui.js +1 -1
- package/src/tablecaption/toggletablecaptioncommand.js +1 -1
- package/src/tablecaption/utils.js +1 -1
- package/src/tablecaption.js +1 -1
- package/src/tablecellproperties/commands/tablecellbackgroundcolorcommand.js +1 -1
- package/src/tablecellproperties/commands/tablecellbordercolorcommand.js +1 -1
- package/src/tablecellproperties/commands/tablecellborderstylecommand.js +1 -1
- package/src/tablecellproperties/commands/tablecellborderwidthcommand.js +1 -1
- package/src/tablecellproperties/commands/tablecellheightcommand.js +1 -1
- package/src/tablecellproperties/commands/tablecellhorizontalalignmentcommand.js +1 -1
- package/src/tablecellproperties/commands/tablecellpaddingcommand.js +1 -1
- package/src/tablecellproperties/commands/tablecellpropertycommand.js +1 -1
- package/src/tablecellproperties/commands/tablecellverticalalignmentcommand.js +1 -1
- package/src/tablecellproperties/tablecellpropertiesediting.js +1 -1
- package/src/tablecellproperties/tablecellpropertiesui.js +53 -32
- package/src/tablecellproperties/ui/tablecellpropertiesview.js +1 -1
- package/src/tablecellproperties.js +1 -1
- package/src/tablecellwidth/commands/tablecellwidthcommand.js +1 -1
- package/src/tablecellwidth/tablecellwidthediting.js +1 -1
- package/src/tableclipboard.js +1 -1
- package/src/tablecolumnresize/constants.js +1 -1
- package/src/tablecolumnresize/converters.js +5 -3
- package/src/tablecolumnresize/tablecolumnresizeediting.js +13 -15
- package/src/tablecolumnresize/tablecolumnwidthscommand.js +1 -1
- package/src/tablecolumnresize/tablewidthresizecommand.js +1 -1
- package/src/tablecolumnresize/utils.js +1 -25
- package/src/tablecolumnresize.js +1 -1
- package/src/tableediting.js +1 -40
- package/src/tablekeyboard.js +1 -1
- package/src/tablemouse/mouseeventsobserver.js +1 -1
- package/src/tablemouse.js +1 -1
- package/src/tableproperties/commands/tablealignmentcommand.js +1 -1
- package/src/tableproperties/commands/tablebackgroundcolorcommand.js +1 -1
- package/src/tableproperties/commands/tablebordercolorcommand.js +1 -1
- package/src/tableproperties/commands/tableborderstylecommand.js +1 -1
- package/src/tableproperties/commands/tableborderwidthcommand.js +1 -1
- package/src/tableproperties/commands/tableheightcommand.js +1 -1
- package/src/tableproperties/commands/tablepropertycommand.js +1 -1
- package/src/tableproperties/commands/tablewidthcommand.js +1 -1
- package/src/tableproperties/tablepropertiesediting.js +1 -1
- package/src/tableproperties/tablepropertiesui.js +32 -17
- package/src/tableproperties/ui/tablepropertiesview.js +1 -1
- package/src/tableproperties.js +1 -1
- package/src/tableselection.js +1 -1
- package/src/tabletoolbar.js +1 -1
- package/src/tableui.js +2 -2
- package/src/tableutils.js +1 -1
- package/src/tablewalker.js +1 -1
- package/src/ui/colorinputview.js +1 -1
- package/src/ui/formrowview.js +1 -1
- package/src/ui/inserttableview.js +1 -1
- package/src/utils/common.js +1 -1
- package/src/utils/structure.js +1 -1
- package/src/utils/table-properties.js +1 -1
- package/src/utils/ui/contextualballoon.js +1 -1
- package/src/utils/ui/table-properties.js +1 -1
- package/src/utils/ui/widget.js +1 -1
- package/theme/colorinput.css +1 -1
- package/theme/form.css +1 -1
- package/theme/formrow.css +1 -1
- package/theme/inserttable.css +1 -1
- package/theme/table.css +1 -1
- package/theme/tablecaption.css +1 -1
- package/theme/tablecellproperties.css +1 -1
- package/theme/tablecolumnresize.css +1 -1
- package/theme/tableediting.css +1 -1
- package/theme/tableform.css +1 -1
- package/theme/tableproperties.css +1 -1
- package/theme/tableselection.css +1 -1
package/src/tableclipboard.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
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 =
|
|
73
|
-
|
|
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-
|
|
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
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
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-
|
|
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,
|
package/src/tablecolumnresize.js
CHANGED
package/src/tableediting.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
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>^ </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
|
package/src/tablekeyboard.js
CHANGED
package/src/tablemouse.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
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
|
|
|
@@ -105,7 +105,7 @@ export default class TablePropertiesUI extends Plugin {
|
|
|
105
105
|
*
|
|
106
106
|
* @member {module:table/tableproperties/ui/tablepropertiesview~TablePropertiesView}
|
|
107
107
|
*/
|
|
108
|
-
this.view =
|
|
108
|
+
this.view = null;
|
|
109
109
|
|
|
110
110
|
/**
|
|
111
111
|
* The batch used to undo all changes made by the form (which are live, as the user types)
|
|
@@ -116,6 +116,15 @@ export default class TablePropertiesUI extends Plugin {
|
|
|
116
116
|
*/
|
|
117
117
|
this._undoStepBatch = null;
|
|
118
118
|
|
|
119
|
+
/**
|
|
120
|
+
* Flag used to indicate whether view is ready to execute update commands
|
|
121
|
+
* (it finished loading initial data).
|
|
122
|
+
*
|
|
123
|
+
* @private
|
|
124
|
+
* @member {Boolean}
|
|
125
|
+
*/
|
|
126
|
+
this._isReady = false;
|
|
127
|
+
|
|
119
128
|
editor.ui.componentFactory.add( 'tableProperties', locale => {
|
|
120
129
|
const view = new ButtonView( locale );
|
|
121
130
|
|
|
@@ -146,7 +155,9 @@ export default class TablePropertiesUI extends Plugin {
|
|
|
146
155
|
|
|
147
156
|
// Destroy created UI components as they are not automatically destroyed.
|
|
148
157
|
// See https://github.com/ckeditor/ckeditor5/issues/1341.
|
|
149
|
-
this.view
|
|
158
|
+
if ( this.view ) {
|
|
159
|
+
this.view.destroy();
|
|
160
|
+
}
|
|
150
161
|
}
|
|
151
162
|
|
|
152
163
|
/**
|
|
@@ -290,6 +301,8 @@ export default class TablePropertiesUI extends Plugin {
|
|
|
290
301
|
|
|
291
302
|
this.view.set( property, value );
|
|
292
303
|
} );
|
|
304
|
+
|
|
305
|
+
this._isReady = true;
|
|
293
306
|
}
|
|
294
307
|
|
|
295
308
|
/**
|
|
@@ -304,6 +317,10 @@ export default class TablePropertiesUI extends Plugin {
|
|
|
304
317
|
_showView() {
|
|
305
318
|
const editor = this.editor;
|
|
306
319
|
|
|
320
|
+
if ( !this.view ) {
|
|
321
|
+
this.view = this._createPropertiesView();
|
|
322
|
+
}
|
|
323
|
+
|
|
307
324
|
this.listenTo( editor.ui, 'update', () => {
|
|
308
325
|
this._updateView();
|
|
309
326
|
} );
|
|
@@ -333,6 +350,8 @@ export default class TablePropertiesUI extends Plugin {
|
|
|
333
350
|
|
|
334
351
|
this.stopListening( editor.ui, 'update' );
|
|
335
352
|
|
|
353
|
+
this._isReady = false;
|
|
354
|
+
|
|
336
355
|
// Blur any input element before removing it from DOM to prevent issues in some browsers.
|
|
337
356
|
// See https://github.com/ckeditor/ckeditor5/issues/1501.
|
|
338
357
|
this.view.saveButtonView.focus();
|
|
@@ -367,7 +386,7 @@ export default class TablePropertiesUI extends Plugin {
|
|
|
367
386
|
* @type {Boolean}
|
|
368
387
|
*/
|
|
369
388
|
get _isViewVisible() {
|
|
370
|
-
return this._balloon.visibleView === this.view;
|
|
389
|
+
return !!this.view && this._balloon.visibleView === this.view;
|
|
371
390
|
}
|
|
372
391
|
|
|
373
392
|
/**
|
|
@@ -377,7 +396,7 @@ export default class TablePropertiesUI extends Plugin {
|
|
|
377
396
|
* @type {Boolean}
|
|
378
397
|
*/
|
|
379
398
|
get _isViewInBalloon() {
|
|
380
|
-
return this._balloon.hasView( this.view );
|
|
399
|
+
return !!this.view && this._balloon.hasView( this.view );
|
|
381
400
|
}
|
|
382
401
|
|
|
383
402
|
/**
|
|
@@ -388,14 +407,12 @@ export default class TablePropertiesUI extends Plugin {
|
|
|
388
407
|
*
|
|
389
408
|
* @private
|
|
390
409
|
* @param {String} commandName The command that will be executed.
|
|
391
|
-
* @param {String} defaultValue The default value of the command.
|
|
392
410
|
* @returns {Function}
|
|
393
411
|
*/
|
|
394
|
-
_getPropertyChangeCallback( commandName
|
|
395
|
-
return ( evt, propertyName, newValue
|
|
396
|
-
//
|
|
397
|
-
|
|
398
|
-
if ( !oldValue && defaultValue === newValue ) {
|
|
412
|
+
_getPropertyChangeCallback( commandName ) {
|
|
413
|
+
return ( evt, propertyName, newValue ) => {
|
|
414
|
+
// Do not execute the command on initial call (opening the table properties view).
|
|
415
|
+
if ( !this._isReady ) {
|
|
399
416
|
return;
|
|
400
417
|
}
|
|
401
418
|
|
|
@@ -417,21 +434,19 @@ export default class TablePropertiesUI extends Plugin {
|
|
|
417
434
|
* @param {module:ui/view~View} options.viewField
|
|
418
435
|
* @param {Function} options.validator
|
|
419
436
|
* @param {String} options.errorText
|
|
420
|
-
* @param {String} options.defaultValue
|
|
421
437
|
* @returns {Function}
|
|
422
438
|
*/
|
|
423
439
|
_getValidatedPropertyChangeCallback( options ) {
|
|
424
|
-
const { commandName, viewField, validator, errorText
|
|
440
|
+
const { commandName, viewField, validator, errorText } = options;
|
|
425
441
|
const setErrorTextDebounced = debounce( () => {
|
|
426
442
|
viewField.errorText = errorText;
|
|
427
443
|
}, ERROR_TEXT_TIMEOUT );
|
|
428
444
|
|
|
429
|
-
return ( evt, propertyName, newValue
|
|
445
|
+
return ( evt, propertyName, newValue ) => {
|
|
430
446
|
setErrorTextDebounced.cancel();
|
|
431
447
|
|
|
432
|
-
//
|
|
433
|
-
|
|
434
|
-
if ( !oldValue && defaultValue === newValue ) {
|
|
448
|
+
// Do not execute the command on initial call (opening the table properties view).
|
|
449
|
+
if ( !this._isReady ) {
|
|
435
450
|
return;
|
|
436
451
|
}
|
|
437
452
|
|
package/src/tableproperties.js
CHANGED
package/src/tableselection.js
CHANGED
package/src/tabletoolbar.js
CHANGED
package/src/tableui.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
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
|
|
|
@@ -327,7 +327,7 @@ export default class TableUI extends Plugin {
|
|
|
327
327
|
addListOption( option, editor, commands, itemDefinitions );
|
|
328
328
|
}
|
|
329
329
|
|
|
330
|
-
addListToDropdown( dropdownView, itemDefinitions
|
|
330
|
+
addListToDropdown( dropdownView, itemDefinitions );
|
|
331
331
|
|
|
332
332
|
return commands;
|
|
333
333
|
}
|
package/src/tableutils.js
CHANGED
package/src/tablewalker.js
CHANGED
package/src/ui/colorinputview.js
CHANGED
package/src/ui/formrowview.js
CHANGED
package/src/utils/common.js
CHANGED
package/src/utils/structure.js
CHANGED
package/src/utils/ui/widget.js
CHANGED
package/theme/colorinput.css
CHANGED
package/theme/form.css
CHANGED
package/theme/formrow.css
CHANGED