@progress/kendo-react-editor 5.16.0-dev.202307211637 → 5.16.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.
@@ -40,336 +40,10 @@ var kendo_react_dialogs_1 = require("@progress/kendo-react-dialogs");
40
40
  var kendo_react_layout_1 = require("@progress/kendo-react-layout");
41
41
  var kendo_svg_icons_1 = require("@progress/kendo-svg-icons");
42
42
  var utils_1 = require("./../utils");
43
- var utils_2 = require("./utils");
44
43
  var tableCellProperties_1 = require("./tableCellProperties");
45
- var kendo_editor_common_1 = require("@progress/kendo-editor-common");
46
- var tableEdit_1 = require("../tableEdit");
47
44
  var kendo_react_intl_1 = require("@progress/kendo-react-intl");
48
45
  var messages_1 = require("./../../messages");
49
- var lastCell = function (table) {
50
- var lastRow = table.lastChild;
51
- var cell = lastRow.lastChild;
52
- return { node: cell, pos: table.content.size - cell.nodeSize };
53
- };
54
- var addTableNodes = function (state, tablePos, table, toAdd, command) {
55
- var last = lastCell(table);
56
- var cellPos = tablePos + last.pos;
57
- var cell = state.doc.nodeAt(cellPos);
58
- if (!cell) {
59
- return state;
60
- }
61
- var res = state.doc.resolve(cellPos);
62
- var sel = new kendo_editor_common_1.CellSelection(res, res);
63
- var selTr = state.tr.setSelection(sel);
64
- var resultState = state.apply(selTr);
65
- for (var i = 0; i < toAdd; i++) {
66
- command(resultState, function (tr) {
67
- resultState = resultState.apply(tr);
68
- });
69
- }
70
- return resultState;
71
- };
72
- var removeTableNodes = function (state, tablePos, toDelete, command) {
73
- var resultState = state;
74
- for (var i = 0; i < toDelete; i++) {
75
- var table = resultState.doc.nodeAt(tablePos);
76
- if (table) {
77
- var last = lastCell(table);
78
- var cellPos = tablePos + last.pos;
79
- var res = resultState.doc.resolve(cellPos);
80
- var selection = new kendo_editor_common_1.CellSelection(res, res);
81
- var selTr = resultState.tr.setSelection(selection);
82
- resultState = resultState.apply(selTr);
83
- command(resultState, function (tr) {
84
- resultState = resultState.apply(tr);
85
- });
86
- }
87
- }
88
- return resultState;
89
- };
90
- var resizeTable = function (state, tablePos, rows, columns) {
91
- var nextState = state;
92
- var table = nextState.doc.nodeAt(tablePos);
93
- if (!table) {
94
- return nextState;
95
- }
96
- var map = kendo_editor_common_1.TableMap.get(table);
97
- if (map.width === columns && map.height === rows) {
98
- return nextState;
99
- }
100
- if (columns > map.width) {
101
- nextState = addTableNodes(nextState, tablePos, table, columns - map.width, kendo_editor_common_1.addColumnAfter);
102
- }
103
- else if (columns < map.width) {
104
- nextState = removeTableNodes(nextState, tablePos, map.width - columns, tableEdit_1.deleteColumnCmd);
105
- }
106
- table = nextState.doc.nodeAt(tablePos);
107
- if (!table) {
108
- return nextState;
109
- }
110
- map = kendo_editor_common_1.TableMap.get(table);
111
- if (rows > map.height) {
112
- nextState = addTableNodes(nextState, tablePos, table, rows - map.height, kendo_editor_common_1.addRowAfter);
113
- }
114
- else if (rows < map.height) {
115
- nextState = removeTableNodes(nextState, tablePos, map.height - rows, tableEdit_1.deleteRowCmd);
116
- }
117
- return nextState;
118
- };
119
- var setTableStyles = function (state, data, tablePos) {
120
- var _a;
121
- var table = state.doc.nodeAt(tablePos);
122
- if (!table) {
123
- return state;
124
- }
125
- var attrs = __assign({}, table.attrs);
126
- attrs = (0, utils_2.setNodeStyle)(attrs, 'width', data.width !== null ? data.width + data.widthUnit : '');
127
- attrs = (0, utils_2.setNodeStyle)(attrs, 'height', data.height !== null ? data.height + data.heightUnit : '');
128
- attrs = (0, utils_2.setNodeStyle)(attrs, 'text-align', data.textAlign || '');
129
- attrs = (0, utils_2.setNodeStyle)(attrs, 'background-color', data.backgroundColor || '');
130
- attrs = (0, utils_2.setNodeStyle)(attrs, 'border-width', data.borderWidth ? data.borderWidth + 'px' : '');
131
- attrs = (0, utils_2.setNodeStyle)(attrs, 'border-style', data.borderStyle || '');
132
- attrs = (0, utils_2.setNodeStyle)(attrs, 'border-color', data.borderColor || '');
133
- attrs = (0, utils_2.setNodeStyle)(attrs, 'border-spacing', data.cellSpacing !== null ? data.cellSpacing + 'px' : '');
134
- if (data.cellSpacing !== null) {
135
- attrs = (0, utils_2.setNodeStyle)(attrs, 'border-collapse', 'unset');
136
- }
137
- else {
138
- attrs = (0, utils_2.setNodeStyle)(attrs, 'border-collapse', data.collapseBorders ? 'collapse' : '');
139
- }
140
- var posStyles = ((_a = data.position) === null || _a === void 0 ? void 0 : _a.style) || {};
141
- Object.keys(posStyles).forEach(function (style) {
142
- attrs = (0, utils_2.setNodeStyle)(attrs, style, posStyles[style]);
143
- });
144
- attrs.id = data.id || null;
145
- attrs.class = data.className || null;
146
- var tr = state.tr.setNodeMarkup(tablePos, null, attrs);
147
- state = state.apply(tr);
148
- return state;
149
- };
150
- var toCellsMap = function (map) {
151
- var cells = [];
152
- for (var h = 0; h < map.height; h++) {
153
- var start = h * map.width;
154
- var end = start + map.width;
155
- cells.push(map.map.slice(start, end));
156
- }
157
- return cells;
158
- };
159
- var headerCellsCount = function (table, map) {
160
- var headerRows = 0;
161
- var headerColumns = 0;
162
- var cells = toCellsMap(map);
163
- cells.forEach(function (row) {
164
- var headerCells = true;
165
- row.forEach(function (cellPos) {
166
- var cell = table.nodeAt(cellPos);
167
- if (cell && cell.type.name !== 'table_header') {
168
- headerCells = false;
169
- }
170
- });
171
- if (headerCells) {
172
- headerRows++;
173
- }
174
- });
175
- for (var col = 0; col < map.width; col++) {
176
- var headerCells = true;
177
- for (var row = 0; row < map.height; row++) {
178
- var cellPos = cells[row] && cells[row][col];
179
- var cell = typeof cellPos === 'number' && table.nodeAt(cellPos);
180
- if (cell && cell.type.name !== 'table_header') {
181
- headerCells = false;
182
- }
183
- }
184
- if (headerCells) {
185
- headerColumns++;
186
- }
187
- }
188
- return { rows: headerRows, columns: headerColumns };
189
- };
190
- var setCellType = function (state, cell, pos, type, attrs) {
191
- if (cell.type.name !== type.name || Object.keys(attrs).length > 0) {
192
- var tr = state.tr.setNodeMarkup(pos, type, __assign(__assign({}, cell.attrs), attrs));
193
- return state.apply(tr);
194
- }
195
- return state;
196
- };
197
- var resetId = function (cell, attrs) {
198
- if (/^cell-[0-9]+-[0-9]+$/.test(cell.attrs.id || '')) {
199
- attrs.id = null;
200
- }
201
- };
202
- var setTableHeaderCells = function (state, data, tablePos) {
203
- var table = state.doc.nodeAt(tablePos);
204
- var map = table && kendo_editor_common_1.TableMap.get(table);
205
- if (!table || !map) {
206
- return state;
207
- }
208
- // const headerCells = headerCellsCount(table, map);
209
- // if (data.headerRows === headerCells.rows && data.headerColumns === headerCells.columns) {
210
- // return state;
211
- // }
212
- var cells = toCellsMap(map);
213
- var newState = state;
214
- var _a = state.schema.nodes, table_header = _a.table_header, table_cell = _a.table_cell;
215
- var id = String(new Date().getTime());
216
- var ids = [];
217
- var cellId = function (row, col) {
218
- var result = "cell-".concat(row).concat(col, "-").concat(id);
219
- if (!ids[row]) {
220
- ids.push([]);
221
- }
222
- if (!ids[row][col]) {
223
- ids[row].push([]);
224
- }
225
- ids[row][col] = result;
226
- return result;
227
- };
228
- var headers = function (row, col, colHeader, rowHeader) {
229
- var result = [];
230
- if (rowHeader) {
231
- for (var r = 0; r < row; r++) {
232
- if (ids[r] && ids[r][col]) {
233
- result.push(ids[r][col]);
234
- }
235
- }
236
- }
237
- if (colHeader) {
238
- for (var c = 0; c < col; c++) {
239
- if (ids[row] && ids[row][c]) {
240
- result.push(ids[row][c]);
241
- }
242
- }
243
- }
244
- return result.join(' ');
245
- };
246
- cells.forEach(function (row, rowIndex) {
247
- row.forEach(function (cellPos, cellIndex) {
248
- var cell = table.nodeAt(cellPos);
249
- if (cell) {
250
- var colHeader = cellIndex < data.headerColumns;
251
- var rowHeader = rowIndex < data.headerRows;
252
- var attrs = __assign({}, cell.attrs);
253
- resetId(cell, attrs);
254
- attrs.headers = null;
255
- attrs.scope = null;
256
- if (rowHeader || colHeader) {
257
- if (data.associateHeaders === 'scope') {
258
- attrs.scope = rowHeader ? 'col' : 'row';
259
- }
260
- if (data.associateHeaders === 'id') {
261
- attrs.id = cellId(rowIndex, cellIndex);
262
- if (cellIndex > 0 || rowIndex > 0) {
263
- attrs.headers = headers(rowIndex, cellIndex, colHeader, rowHeader) || null;
264
- }
265
- }
266
- newState = setCellType(newState, cell, tablePos + cellPos + 1, table_header, attrs);
267
- }
268
- else {
269
- if (data.associateHeaders === 'id') {
270
- attrs.headers = headers(rowIndex, cellIndex, data.headerColumns > 0, data.headerRows > 0) || null;
271
- }
272
- newState = setCellType(newState, cell, tablePos + cellPos + 1, table_cell, attrs);
273
- }
274
- }
275
- });
276
- });
277
- return newState;
278
- };
279
- var setTablePosition = function (state, wrapperNode, wrapperPos, styles) {
280
- var attrs = __assign({}, wrapperNode.attrs);
281
- attrs = (0, utils_2.setNodeStyle)(attrs, 'margin-left', '');
282
- attrs = (0, utils_2.setNodeStyle)(attrs, 'margin-right', '');
283
- Object.keys(styles || {}).forEach(function (s) {
284
- attrs = (0, utils_2.setNodeStyle)(attrs, s, (styles || {})[s] || '');
285
- });
286
- return state.apply(state.tr.setNodeMarkup(wrapperPos, null, attrs));
287
- };
288
- var parseCaptionContent = function (content, schema) {
289
- var doc = (0, kendo_editor_common_1.parseContent)('<p>' + content + '</p>', schema);
290
- return doc.content.firstChild.content;
291
- };
292
- var createCaption = function (data, schema) {
293
- if (!data.caption) {
294
- return;
295
- }
296
- var captAttrs = { caption: '', style: 'display: table-caption' };
297
- if (data.captionAlignment) {
298
- captAttrs = (0, utils_2.setNodeStyle)(captAttrs, 'text-align', data.captionAlignment);
299
- }
300
- if (data.captionPosition) {
301
- captAttrs = (0, utils_2.setNodeStyle)(captAttrs, 'caption-side', data.captionPosition);
302
- }
303
- var captionContent = parseCaptionContent(data.caption, schema);
304
- var captionNode = (captionContent && schema.nodes.table_caption_external.createAndFill(captAttrs, captionContent)) || undefined;
305
- return captionNode;
306
- };
307
- var hasCaption = function (wrapperNode) {
308
- return wrapperNode.firstChild && wrapperNode.firstChild.type.name === 'table_caption_external';
309
- };
310
- var setTableCaption = function (state, wrapperNode, wrapperPos, data) {
311
- var nextState = state;
312
- var captionNode;
313
- var captContentPos = wrapperPos + 2;
314
- var captPos = wrapperPos + 1;
315
- var schema = nextState.schema;
316
- if (hasCaption(wrapperNode)) {
317
- captionNode = wrapperNode.firstChild;
318
- if (data.caption) {
319
- var captionContent = parseCaptionContent(data.caption, schema);
320
- nextState = nextState.apply(nextState.tr.replaceWith(captContentPos, captContentPos + captionNode.content.size, captionContent));
321
- captionNode = nextState.doc.nodeAt(captPos);
322
- if (captionNode) {
323
- var captAttrs = __assign({}, captionNode.attrs);
324
- captAttrs = (0, utils_2.setNodeStyle)(captAttrs, 'text-align', data.captionAlignment || '');
325
- captAttrs = (0, utils_2.setNodeStyle)(captAttrs, 'caption-side', data.captionPosition || '');
326
- nextState = nextState.apply(nextState.tr.setNodeAttribute(captPos, 'style', captAttrs.style));
327
- }
328
- }
329
- else {
330
- nextState = nextState.apply(nextState.tr.deleteRange(captContentPos, captContentPos + captionNode.content.size));
331
- }
332
- }
333
- else {
334
- captionNode = createCaption(data, schema);
335
- if (captionNode) {
336
- nextState = nextState.apply(nextState.tr.replaceWith(captPos, captPos, captionNode));
337
- }
338
- }
339
- return nextState;
340
- };
341
- var updateWrapper = function (state, data, tablePos, tableWrapper, tableWrapperPos) {
342
- if (!tableWrapper && (data.position || data.caption)) {
343
- var wrapperAttrs_1 = { table: '', style: 'display: table' };
344
- var children = [];
345
- if (data.position) {
346
- Object.keys(data.position.style).forEach(function (s) {
347
- wrapperAttrs_1 = (0, utils_2.setNodeStyle)(wrapperAttrs_1, s, data.position.style[s] || '');
348
- });
349
- }
350
- var captionNode = createCaption(data, state.schema);
351
- if (captionNode) {
352
- children.push(captionNode);
353
- }
354
- var table = state.doc.nodeAt(tablePos);
355
- children.push(table);
356
- var createdWrapper = state.schema.nodes.table_wrapper.createAndFill(wrapperAttrs_1, children);
357
- if (createdWrapper) {
358
- var tr = state.tr.replaceWith(tablePos, tablePos + table.content.size, createdWrapper);
359
- state = state.apply(tr);
360
- return { state: state, pos: tablePos };
361
- }
362
- }
363
- else if (tableWrapper && (data.position || data.caption || (!data.caption && hasCaption(tableWrapper.node)))) {
364
- state = setTablePosition(state, tableWrapper.node, tableWrapperPos, data.position && data.position.style);
365
- state = setTableCaption(state, tableWrapper.node, tableWrapperPos, data);
366
- return { state: state, pos: tableWrapperPos };
367
- }
368
- else if (tableWrapper && !(data.position || data.caption)) {
369
- return { state: state, node: tableWrapper.node, pos: state.selection.$from.start(tableWrapper.depth) - 1 };
370
- }
371
- return { state: state, pos: tablePos };
372
- };
46
+ var tablePropsUtils_1 = require("./tablePropsUtils");
373
47
  /**
374
48
  * @hidden
375
49
  */
@@ -386,40 +60,10 @@ var TableProperties = function (props) {
386
60
  }, []);
387
61
  var onSave = React.useCallback(function (data) {
388
62
  if (view && data) {
389
- var $from = view.state.selection.$from;
390
- var table = (0, utils_1.parentNode)($from, function (n) { return n.type.spec.tableRole === 'table'; });
391
- if (!table) {
392
- return;
393
- }
394
- var tablePos = $from.start(table.depth) - 1;
395
- var state = resizeTable(view.state, tablePos, data.rows, data.columns);
396
- if (!state) {
397
- return;
398
- }
399
- var transaction_1 = state.tr;
400
- (0, tableCellProperties_1.tableCells)(state).forEach(function (cell) {
401
- var attrs = __assign({}, cell.node.attrs);
402
- attrs = (0, utils_2.setNodeStyle)(attrs, 'padding', typeof data.cellPadding === 'number' ? data.cellPadding + 'px' : '');
403
- transaction_1.setNodeMarkup(cell.pos, null, attrs);
404
- });
405
- state = state.apply(transaction_1);
406
- state = setTableStyles(state, data, tablePos);
407
- state = setTableHeaderCells(state, data, tablePos);
408
- var tableParent = (0, utils_1.parentNode)($from, function (n) { return n.type.name === 'table_wrapper'; });
409
- var tableParentPos = $from.start((tableParent === null || tableParent === void 0 ? void 0 : tableParent.depth) || 0) - 1;
410
- var result = updateWrapper(state, data, tablePos, tableParent, tableParentPos);
411
- state = result.state;
412
- var from = result.pos;
413
- var node = state.doc.nodeAt(result.pos);
414
- if (!node) {
415
- return;
63
+ var tr = (0, tablePropsUtils_1.applyTableData)(view.state, data);
64
+ if (tr) {
65
+ view.dispatch(tr);
416
66
  }
417
- var to = from + (tableParent || table).node.content.size;
418
- var tr = view.state.tr.replaceWith(from, to, node);
419
- var atEnd = kendo_editor_common_1.Selection.atEnd(node);
420
- var selection = kendo_editor_common_1.TextSelection.create(tr.doc, from + atEnd.to);
421
- tr.setSelection(selection);
422
- view.dispatch(tr);
423
67
  }
424
68
  setShowDialog(false);
425
69
  }, [view]);
@@ -442,24 +86,24 @@ var tablePosition = [{
442
86
  textKey: messages_1.keys.tablePropertiesLeft,
443
87
  text: messages_1.messages[messages_1.keys.tablePropertiesLeft],
444
88
  value: 'left',
445
- style: { 'margin-left': '', 'margin-right': 'auto' },
89
+ style: {},
446
90
  icon: 'table-position-left',
447
91
  svgIcon: kendo_svg_icons_1.tablePositionStartIcon
448
92
  }, {
449
93
  textKey: messages_1.keys.tablePropertiesCenter,
450
94
  text: messages_1.messages[messages_1.keys.tablePropertiesCenter],
451
95
  value: 'center',
452
- style: { 'margin-left': 'auto', 'margin-right': 'auto' },
96
+ style: {},
453
97
  icon: 'table-position-center',
454
98
  svgIcon: kendo_svg_icons_1.tablePositionCenterIcon
455
99
  }, {
456
100
  textKey: messages_1.keys.tablePropertiesRight,
457
101
  text: messages_1.messages[messages_1.keys.tablePropertiesRight],
458
102
  value: 'right',
459
- style: { 'margin-left': 'auto', 'margin-right': '' },
103
+ style: {},
460
104
  icon: 'table-position-right',
461
105
  svgIcon: kendo_svg_icons_1.tablePositionEndIcon
462
- }];
106
+ }].map(function (p) { return (__assign(__assign({}, p), { style: tablePropsUtils_1.tablePositionStyles[p.value] })); });
463
107
  var captionPositionData = [{
464
108
  textKey: messages_1.keys.tablePropertiesTop,
465
109
  text: messages_1.messages[messages_1.keys.tablePropertiesTop],
@@ -478,63 +122,11 @@ var associateHeadersData = [
478
122
  { textKey: messages_1.keys.tablePropertiesUsingScopeAttribute, text: messages_1.messages[messages_1.keys.tablePropertiesUsingScopeAttribute], value: 'scope' },
479
123
  { textKey: messages_1.keys.tablePropertiesUsingIdAttributes, text: messages_1.messages[messages_1.keys.tablePropertiesUsingIdAttributes], value: 'id' }
480
124
  ];
481
- var initialData = {
482
- rows: 0,
483
- columns: 0,
484
- width: null,
485
- widthUnit: '',
486
- height: null,
487
- heightUnit: '',
488
- position: null,
489
- textAlign: '',
490
- cellPadding: null,
491
- cellSpacing: null,
492
- backgroundColor: undefined,
493
- borderWidth: null,
494
- borderColor: undefined,
495
- borderStyle: null,
496
- collapseBorders: false,
497
- id: '',
498
- className: '',
499
- caption: '',
500
- captionAlignment: null,
501
- captionPosition: null,
502
- headerRows: 0,
503
- headerColumns: 0,
504
- associateHeaders: 'none'
505
- };
506
125
  var TablePropertiesDialog = function (props) {
507
126
  var defaults = React.useMemo(function () {
508
- var _a, _b, _c;
509
- var cells = (0, tableCellProperties_1.selectedCells)(props.view.state);
510
- var $pos = props.view.state.selection.$from;
511
- var table = cells.length ? (0, utils_1.parentNode)($pos, function (n) { return n.type.spec.tableRole === 'table'; }) : null;
512
- if (!table) {
513
- return initialData;
514
- }
515
- var tableParent = (0, utils_1.parentNode)($pos, function (n) { return n.type.name === 'table_wrapper'; });
516
- var captionStr = '';
517
- var captionStyles = {};
518
- var parentStyles = {};
519
- if (tableParent) {
520
- parentStyles = (0, utils_2.parseStyle)(tableParent.node.attrs.style);
521
- tableParent.node.content.forEach(function (node) {
522
- if (node.type.name === 'table_caption_external') {
523
- var fr = (0, kendo_editor_common_1.pmDocToFragment)(node);
524
- captionStr = (0, kendo_editor_common_1.fragmentToHtml)(fr);
525
- captionStyles = (0, utils_2.parseStyle)(node.attrs.style);
526
- }
527
- });
528
- }
529
- var styles = (0, utils_2.parseStyle)(((_a = table.node.attrs) === null || _a === void 0 ? void 0 : _a.style) || '');
530
- var map = kendo_editor_common_1.TableMap.get(table.node);
531
- var pos = (parentStyles['margin-left'] === 'auto' && parentStyles['margin-right'] === 'auto') ? tablePosition.find(function (p) { return p.value === 'center'; }) :
532
- parentStyles['margin-right'] === 'auto' ? tablePosition.find(function (p) { return p.value === 'left'; }) :
533
- parentStyles['margin-left'] === 'auto' ? tablePosition.find(function (p) { return p.value === 'right'; }) : null;
534
- var headerCells = headerCellsCount(table.node, map);
535
- return __assign(__assign(__assign(__assign(__assign({}, initialData), { columns: map.width, rows: map.height }), (0, utils_2.nodeSize)(table.node, 'width')), (0, utils_2.nodeSize)(table.node, 'height')), { textAlign: styles['text-align'] || '', position: pos || null, cellPadding: styles.padding ? parseFloat(styles.padding) : null, cellSpacing: styles['border-spacing'] ? parseFloat(styles['border-spacing']) : null, backgroundColor: styles['background-color'], borderWidth: styles['border-width'] ? parseFloat(styles['border-width']) : null, borderColor: styles['border-color'], borderStyle: styles['border-style'], collapseBorders: styles['border-collapse'] === 'collapse', caption: captionStr, captionAlignment: captionStyles['text-align'], captionPosition: captionStyles['caption-side'], headerRows: headerCells.rows, headerColumns: headerCells.columns,
536
- // associateHeaders
537
- id: (_b = table.node.attrs) === null || _b === void 0 ? void 0 : _b.id, className: (_c = table.node.attrs) === null || _c === void 0 ? void 0 : _c.class });
127
+ var state = props.view && props.view.state;
128
+ var data = state ? (0, tablePropsUtils_1.tableDefaultData)(state) : tablePropsUtils_1.initialTableData;
129
+ return data;
538
130
  }, [props.view]);
539
131
  var loc = (0, kendo_react_intl_1.useLocalization)();
540
132
  var _a = React.useState(0), selected = _a[0], setSelected = _a[1];
@@ -567,7 +159,7 @@ var TablePropertiesDialog = function (props) {
567
159
  var captionPosition = React.useRef(null);
568
160
  var associateHeaders = React.useRef(null);
569
161
  var onSave = React.useCallback(function () {
570
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
162
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
571
163
  var data = {
572
164
  rows: ((_a = rows.current) === null || _a === void 0 ? void 0 : _a.value) || 0,
573
165
  columns: ((_b = columns.current) === null || _b === void 0 ? void 0 : _b.value) || 0,
@@ -578,20 +170,20 @@ var TablePropertiesDialog = function (props) {
578
170
  borderWidth: borderWidth.current ? borderWidth.current.value : null,
579
171
  widthUnit: ((_c = widthUnit.current) === null || _c === void 0 ? void 0 : _c.value) || '',
580
172
  heightUnit: ((_d = heightUnit.current) === null || _d === void 0 ? void 0 : _d.value) || '',
581
- position: ((_e = position.current) === null || _e === void 0 ? void 0 : _e.value) || null,
582
- textAlign: ((_f = alignment.current) === null || _f === void 0 ? void 0 : _f.value) ? alignment.current.value.value : null,
583
- borderStyle: ((_g = borderStyle.current) === null || _g === void 0 ? void 0 : _g.value) ? borderStyle.current.value.value : null,
584
- backgroundColor: (_h = backgroundColor.current) === null || _h === void 0 ? void 0 : _h.value,
585
- borderColor: (_j = borderColor.current) === null || _j === void 0 ? void 0 : _j.value,
586
- collapseBorders: Boolean((_l = (_k = collapseBorders.current) === null || _k === void 0 ? void 0 : _k.element) === null || _l === void 0 ? void 0 : _l.checked),
587
- id: String(((_m = id.current) === null || _m === void 0 ? void 0 : _m.value) || ''),
588
- className: String(((_o = className.current) === null || _o === void 0 ? void 0 : _o.value) || ''),
589
- caption: String(((_p = caption.current) === null || _p === void 0 ? void 0 : _p.value) || ''),
590
- headerRows: ((_q = headerRows.current) === null || _q === void 0 ? void 0 : _q.value) || 0,
591
- headerColumns: ((_r = headerColumns.current) === null || _r === void 0 ? void 0 : _r.value) || 0,
592
- captionAlignment: ((_s = captionAlignment.current) === null || _s === void 0 ? void 0 : _s.value) ? captionAlignment.current.value.value : null,
593
- captionPosition: ((_t = captionPosition.current) === null || _t === void 0 ? void 0 : _t.value) ? captionPosition.current.value.value : null,
594
- associateHeaders: ((_u = associateHeaders.current) === null || _u === void 0 ? void 0 : _u.value) ? associateHeaders.current.value.value : 'none'
173
+ position: ((_f = (_e = position.current) === null || _e === void 0 ? void 0 : _e.value) === null || _f === void 0 ? void 0 : _f.value) || null,
174
+ textAlign: ((_g = alignment.current) === null || _g === void 0 ? void 0 : _g.value) ? alignment.current.value.value : null,
175
+ borderStyle: ((_h = borderStyle.current) === null || _h === void 0 ? void 0 : _h.value) ? borderStyle.current.value.value : null,
176
+ backgroundColor: (_j = backgroundColor.current) === null || _j === void 0 ? void 0 : _j.value,
177
+ borderColor: (_k = borderColor.current) === null || _k === void 0 ? void 0 : _k.value,
178
+ collapseBorders: Boolean((_m = (_l = collapseBorders.current) === null || _l === void 0 ? void 0 : _l.element) === null || _m === void 0 ? void 0 : _m.checked),
179
+ id: String(((_o = id.current) === null || _o === void 0 ? void 0 : _o.value) || ''),
180
+ className: String(((_p = className.current) === null || _p === void 0 ? void 0 : _p.value) || ''),
181
+ caption: String(((_q = caption.current) === null || _q === void 0 ? void 0 : _q.value) || ''),
182
+ headerRows: ((_r = headerRows.current) === null || _r === void 0 ? void 0 : _r.value) || 0,
183
+ headerColumns: ((_s = headerColumns.current) === null || _s === void 0 ? void 0 : _s.value) || 0,
184
+ captionAlignment: ((_t = captionAlignment.current) === null || _t === void 0 ? void 0 : _t.value) ? captionAlignment.current.value.value : null,
185
+ captionPosition: ((_u = captionPosition.current) === null || _u === void 0 ? void 0 : _u.value) ? captionPosition.current.value.value : null,
186
+ associateHeaders: ((_v = associateHeaders.current) === null || _v === void 0 ? void 0 : _v.value) ? associateHeaders.current.value.value : 'none'
595
187
  };
596
188
  props.onSave.call(undefined, data);
597
189
  }, [props.onSave]);
@@ -625,7 +217,7 @@ var TablePropertiesDialog = function (props) {
625
217
  React.createElement("div", { className: "k-form-field k-col-span-2" },
626
218
  React.createElement("label", { className: "k-label k-form-label" }, loc.toLanguageString(messages_1.keys.tablePropertiesPosition, messages_1.messages[messages_1.keys.tablePropertiesPosition])),
627
219
  React.createElement("div", { className: "k-form-field-wrap" },
628
- React.createElement(kendo_react_dropdowns_1.DropDownList, { ref: position, defaultValue: defaults.position, popupSettings: utils_1.popupSettings, data: tablePosition.map(function (i) { return (__assign(__assign({}, i), { text: loc.toLanguageString(i.textKey, i.text) })); }), textField: 'text', dataItemKey: 'value', valueRender: tableCellProperties_1.valueRenderWithIcon, itemRender: tableCellProperties_1.itemRenderWithIcon }))),
220
+ React.createElement(kendo_react_dropdowns_1.DropDownList, { ref: position, defaultValue: tablePosition.find(function (p) { return p.value === defaults.position; }), popupSettings: utils_1.popupSettings, data: tablePosition.map(function (i) { return (__assign(__assign({}, i), { text: loc.toLanguageString(i.textKey, i.text) })); }), textField: 'text', dataItemKey: 'value', valueRender: tableCellProperties_1.valueRenderWithIcon, itemRender: tableCellProperties_1.itemRenderWithIcon }))),
629
221
  React.createElement("div", { className: "k-form-field k-col-span-2" },
630
222
  React.createElement("label", { className: "k-label k-form-label" }, loc.toLanguageString(messages_1.keys.tablePropertiesAlignment, messages_1.messages[messages_1.keys.tablePropertiesAlignment])),
631
223
  React.createElement("div", { className: "k-form-field-wrap" },
@@ -694,7 +286,7 @@ var TablePropertiesDialog = function (props) {
694
286
  React.createElement("div", { className: "k-form-field k-col-span-2" },
695
287
  React.createElement("label", { className: "k-label k-form-label" }, loc.toLanguageString(messages_1.keys.tablePropertiesAssociateHeaders, messages_1.messages[messages_1.keys.tablePropertiesAssociateHeaders])),
696
288
  React.createElement("div", { className: "k-form-field-wrap" },
697
- React.createElement(kendo_react_dropdowns_1.DropDownList, { ref: associateHeaders, defaultValue: associateHeadersData[0], data: associateHeadersData.map(function (i) { return (__assign(__assign({}, i), { text: loc.toLanguageString(i.textKey, i.text) })); }), popupSettings: utils_1.popupSettings, textField: 'text', dataItemKey: 'value' })))))))));
289
+ React.createElement(kendo_react_dropdowns_1.DropDownList, { ref: associateHeaders, defaultValue: associateHeadersData.find(function (i) { return i.value === defaults.associateHeaders; }), data: associateHeadersData.map(function (i) { return (__assign(__assign({}, i), { text: loc.toLanguageString(i.textKey, i.text) })); }), popupSettings: utils_1.popupSettings, textField: 'text', dataItemKey: 'value' })))))))));
698
290
  var content = (React.createElement(kendo_react_layout_1.TabStrip, { selected: selected, onSelect: onSelect, animation: false, keepTabsMounted: true },
699
291
  React.createElement(kendo_react_layout_1.TabStripTab, { title: loc.toLanguageString(messages_1.keys.tablePropertiesGeneral, messages_1.messages[messages_1.keys.tablePropertiesGeneral]) }, general),
700
292
  React.createElement(kendo_react_layout_1.TabStripTab, { title: loc.toLanguageString(messages_1.keys.tablePropertiesAdvanced, messages_1.messages[messages_1.keys.tablePropertiesAdvanced]) }, advanced)));
@@ -0,0 +1,52 @@
1
+ import { EditorState, Transaction } from '@progress/kendo-editor-common';
2
+ /**
3
+ * @hidden
4
+ */
5
+ declare type TablePosition = 'left' | 'right' | 'center' | '';
6
+ /**
7
+ * @hidden
8
+ */
9
+ interface TableData {
10
+ rows: number;
11
+ columns: number;
12
+ width: number | null;
13
+ widthUnit: string;
14
+ height: number | null;
15
+ heightUnit: string;
16
+ position: TablePosition | null;
17
+ textAlign: string;
18
+ cellPadding: number | null;
19
+ cellSpacing: number | null;
20
+ backgroundColor: string | undefined;
21
+ borderWidth: number | null;
22
+ borderColor: string | undefined;
23
+ borderStyle: string | null;
24
+ collapseBorders: boolean;
25
+ id: string;
26
+ className: string;
27
+ caption?: string;
28
+ captionPosition: string | null;
29
+ captionAlignment: string | null;
30
+ headerRows: number;
31
+ headerColumns: number;
32
+ associateHeaders: 'none' | 'scope' | 'id';
33
+ }
34
+ /**
35
+ * @hidden
36
+ */
37
+ declare const initialTableData: TableData;
38
+ /**
39
+ * @hidden
40
+ */
41
+ declare const tablePositionStyles: Record<TablePosition, {
42
+ [styleName: string]: string;
43
+ }>;
44
+ /**
45
+ * @hidden
46
+ */
47
+ declare const tableDefaultData: (state: EditorState) => TableData;
48
+ /**
49
+ * @hidden
50
+ */
51
+ declare const applyTableData: (state: EditorState, data: TableData) => Transaction | undefined;
52
+ export { TableData, initialTableData, tablePositionStyles, TablePosition, tableDefaultData, applyTableData };