@progress/kendo-editor-common 1.8.2-dev.202204060750 → 1.9.0-dev.202204180753

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 (47) hide show
  1. package/dist/cdn/js/kendo-editor-common.js +2 -2
  2. package/dist/cdn/main.js +1 -1
  3. package/dist/es/config/constants.js +5 -0
  4. package/dist/es/config/schema.js +9 -5
  5. package/dist/es/main.js +1 -0
  6. package/dist/es/plugins/image-resize.js +5 -14
  7. package/dist/es/plugins/resize-utils.js +11 -0
  8. package/dist/es/plugins/table-resize/column-resize.js +273 -0
  9. package/dist/es/plugins/table-resize/index.js +8 -0
  10. package/dist/es/plugins/table-resize/row-resize.js +230 -0
  11. package/dist/es/plugins/table-resize/table-resize.js +255 -0
  12. package/dist/es/plugins/table-resize/table-view.js +87 -0
  13. package/dist/es/plugins/table-resize/utils.js +77 -0
  14. package/dist/es2015/config/constants.js +5 -0
  15. package/dist/es2015/config/schema.js +11 -8
  16. package/dist/es2015/main.js +1 -0
  17. package/dist/es2015/plugins/image-resize.js +5 -14
  18. package/dist/es2015/plugins/resize-utils.js +11 -0
  19. package/dist/es2015/plugins/table-resize/column-resize.js +269 -0
  20. package/dist/es2015/plugins/table-resize/index.js +8 -0
  21. package/dist/es2015/plugins/table-resize/row-resize.js +226 -0
  22. package/dist/es2015/plugins/table-resize/table-resize.js +251 -0
  23. package/dist/es2015/plugins/table-resize/table-view.js +84 -0
  24. package/dist/es2015/plugins/table-resize/utils.js +75 -0
  25. package/dist/npm/config/constants.d.ts +5 -0
  26. package/dist/npm/config/constants.js +5 -0
  27. package/dist/npm/config/schema.d.ts +1 -0
  28. package/dist/npm/config/schema.js +8 -4
  29. package/dist/npm/main.d.ts +1 -0
  30. package/dist/npm/main.js +2 -0
  31. package/dist/npm/plugins/image-resize.js +7 -16
  32. package/dist/npm/plugins/resize-utils.d.ts +35 -0
  33. package/dist/npm/plugins/resize-utils.js +13 -0
  34. package/dist/npm/plugins/table-resize/column-resize.d.ts +2 -0
  35. package/dist/npm/plugins/table-resize/column-resize.js +276 -0
  36. package/dist/npm/plugins/table-resize/index.d.ts +1 -0
  37. package/dist/npm/plugins/table-resize/index.js +10 -0
  38. package/dist/npm/plugins/table-resize/row-resize.d.ts +2 -0
  39. package/dist/npm/plugins/table-resize/row-resize.js +233 -0
  40. package/dist/npm/plugins/table-resize/table-resize.d.ts +4 -0
  41. package/dist/npm/plugins/table-resize/table-resize.js +257 -0
  42. package/dist/npm/plugins/table-resize/table-view.d.ts +17 -0
  43. package/dist/npm/plugins/table-resize/table-view.js +89 -0
  44. package/dist/npm/plugins/table-resize/utils.d.ts +22 -0
  45. package/dist/npm/plugins/table-resize/utils.js +86 -0
  46. package/dist/systemjs/kendo-editor-common.js +1 -1
  47. package/package.json +2 -2
@@ -0,0 +1,269 @@
1
+ import { Plugin } from 'prosemirror-state';
2
+ import { tableNodeTypes, TableMap } from 'prosemirror-tables';
3
+ import { Decoration, DecorationSet } from 'prosemirror-view';
4
+ import { colgroupAttr } from '../../config/constants';
5
+ import { TableView } from './table-view';
6
+ import { cellIndexes, domCellAround, otherResizeHandle, otherResizing, parentNode, parseStyle, setNodeStyle, tableColumnResizing as key } from './utils';
7
+ export function columnResizing() {
8
+ // tslint:disable-next-line:variable-name
9
+ const View = TableView, handleWidth = 5, cellMinWidth = 25;
10
+ let plugin = new Plugin({
11
+ key,
12
+ state: {
13
+ init(_, state) {
14
+ this.spec.props.nodeViews[tableNodeTypes(state.schema).table.name] = (node, view) => new View(node, view);
15
+ return new ResizeState(-1, null);
16
+ },
17
+ apply(tr, prev) {
18
+ return prev.apply(tr);
19
+ }
20
+ },
21
+ props: {
22
+ attributes(state) {
23
+ if (otherResizeHandle(key, state)) {
24
+ return null;
25
+ }
26
+ let pluginState = key.getState(state);
27
+ return pluginState.activeHandle > -1 ? { class: 'resize-cursor' } : null;
28
+ },
29
+ handleDOMEvents: {
30
+ mousemove(view, event) {
31
+ if (!otherResizing(key, view.state)) {
32
+ handleMouseMove(view, event, handleWidth);
33
+ }
34
+ return false;
35
+ },
36
+ mouseleave(view) {
37
+ handleMouseLeave(view);
38
+ return false;
39
+ },
40
+ mousedown(view, event) {
41
+ return handleMouseDown(view, event, cellMinWidth);
42
+ }
43
+ },
44
+ decorations(state) {
45
+ if (!otherResizing(key, state)) {
46
+ let pluginState = key.getState(state);
47
+ if (pluginState.activeHandle > -1) {
48
+ return handleDecorations(state, pluginState.activeHandle);
49
+ }
50
+ }
51
+ return DecorationSet.empty;
52
+ },
53
+ nodeViews: {}
54
+ }
55
+ });
56
+ return plugin;
57
+ }
58
+ function pointsAtCell($pos) {
59
+ return Boolean($pos.parent.type.spec.tableRole === 'row' && $pos.nodeAfter);
60
+ }
61
+ class ResizeState {
62
+ constructor(activeHandle, dragging) {
63
+ this.activeHandle = activeHandle;
64
+ this.dragging = dragging;
65
+ }
66
+ apply(tr) {
67
+ let state = this, action = tr.getMeta(key);
68
+ if (action && action.setHandle != null) {
69
+ return new ResizeState(action.setHandle, null);
70
+ }
71
+ if (action && action.setDragging !== undefined) {
72
+ return new ResizeState(state.activeHandle, action.setDragging);
73
+ }
74
+ if (state.activeHandle > -1 && tr.docChanged) {
75
+ let handle = tr.mapping.map(state.activeHandle, -1);
76
+ if (!pointsAtCell(tr.doc.resolve(handle))) {
77
+ handle = -1;
78
+ }
79
+ state = new ResizeState(handle, state.dragging);
80
+ }
81
+ return state;
82
+ }
83
+ }
84
+ function handleMouseMove(view, event, handleWidth) {
85
+ let pluginState = key.getState(view.state);
86
+ if (!pluginState.dragging) {
87
+ let target = domCellAround(event.target), cell = -1;
88
+ if (target) {
89
+ const indexes = cellIndexes(target);
90
+ let { left, right } = target.getBoundingClientRect();
91
+ if (Math.abs(event.clientX - left) <= handleWidth && indexes.cellIndex > 0) {
92
+ indexes.cellIndex--;
93
+ cell = edgeCell(view, event, indexes);
94
+ }
95
+ else if (right - event.clientX > 0 && right - event.clientX <= handleWidth) {
96
+ cell = edgeCell(view, event, indexes);
97
+ }
98
+ }
99
+ if (cell !== pluginState.activeHandle) {
100
+ updateHandle(view, cell);
101
+ }
102
+ }
103
+ }
104
+ function handleMouseLeave(view) {
105
+ let pluginState = key.getState(view.state);
106
+ if (pluginState.activeHandle > -1 && !pluginState.dragging) {
107
+ updateHandle(view, -1);
108
+ }
109
+ }
110
+ function handleMouseDown(view, event, cellMinWidth) {
111
+ let pluginState = key.getState(view.state);
112
+ if (pluginState.activeHandle === -1 || pluginState.dragging) {
113
+ return false;
114
+ }
115
+ let $cell = view.state.doc.resolve(pluginState.activeHandle);
116
+ const row = $cell.parent;
117
+ const cellIndex = $cell.index();
118
+ let colSpan = 0;
119
+ for (let i = 0; i <= cellIndex; i++) {
120
+ colSpan += row.child(i).attrs.colspan;
121
+ }
122
+ const tableNode = $cell.node($cell.depth - 1);
123
+ let dom = view.domAtPos(pluginState.activeHandle);
124
+ let domCell = dom.node.childNodes[dom.offset];
125
+ let tableDom = domCell.closest('table');
126
+ let col, tableAttrs;
127
+ if (tableNode.attrs[colgroupAttr]) {
128
+ const colgroup = tableDom.firstChild;
129
+ col = colgroup.children[colSpan - 1];
130
+ if (!col.style.width) {
131
+ col.style.width = col.offsetWidth + 'px';
132
+ }
133
+ }
134
+ else {
135
+ let total = 0;
136
+ for (let i = 0; i < row.childCount; i++) {
137
+ total += row.child(i).attrs.colspan;
138
+ }
139
+ const colgroup = document.createElement('colgroup');
140
+ const cols = new Array(total);
141
+ for (let i = 0; i < total; i++) {
142
+ cols[i] = document.createElement('col');
143
+ colgroup.appendChild(cols[i]);
144
+ }
145
+ tableDom.insertBefore(colgroup, tableDom.firstChild);
146
+ col = cols[cellIndex];
147
+ col.style.width = col.offsetWidth + 'px';
148
+ tableAttrs = Object.assign({}, tableNode.attrs, { [colgroupAttr]: '<colgroup>' + cols.reduce((acc, cur) => acc + cur.outerHTML, '') + '</colgroup>' });
149
+ }
150
+ let width = parseFloat(col.style.width);
151
+ const tr = view.state.tr.setMeta(key, { setDragging: { startX: event.clientX, startWidth: width } });
152
+ if (!tableDom.style.width) {
153
+ const widths = Array.from(col.parentNode.children).map((c) => c.style.width);
154
+ if (widths.every(Boolean)) {
155
+ const sum = widths.reduce((acc, cur) => acc + parseFloat(cur), 0);
156
+ tableAttrs = setNodeStyle(tableAttrs || tableNode.attrs, 'width', sum + 'px');
157
+ }
158
+ }
159
+ if (tableAttrs) {
160
+ const tablePos = $cell.posAtIndex(0, $cell.depth - 1) - 1;
161
+ tr.setNodeMarkup(tablePos, null, tableAttrs);
162
+ }
163
+ view.dispatch(tr);
164
+ function finish(ev) {
165
+ ev.view.removeEventListener('mouseup', finish);
166
+ ev.view.removeEventListener('mousemove', move);
167
+ let curPluginState = key.getState(view.state);
168
+ if (curPluginState.dragging) {
169
+ updateColumnWidth(view, curPluginState.activeHandle, draggedWidth(curPluginState.dragging, ev, cellMinWidth));
170
+ view.dispatch(view.state.tr.setMeta(key, { setDragging: null }));
171
+ }
172
+ }
173
+ function move(ev) {
174
+ if (!ev.which) {
175
+ return finish(ev);
176
+ }
177
+ let curPluginState = key.getState(view.state);
178
+ let dragged = draggedWidth(curPluginState.dragging, ev, cellMinWidth);
179
+ displayColumnWidth(view, curPluginState.activeHandle, dragged, cellMinWidth);
180
+ }
181
+ event.view.addEventListener('mouseup', finish);
182
+ event.view.addEventListener('mousemove', move);
183
+ event.preventDefault();
184
+ return true;
185
+ }
186
+ function edgeCell(view, event, indexes) {
187
+ let found = view.posAtCoords({ left: event.clientX, top: event.clientY });
188
+ if (!found) {
189
+ return -1;
190
+ }
191
+ let $pos = view.state.doc.resolve(found.pos);
192
+ let parentTable = parentNode($pos, n => n.type.spec.tableRole === 'table');
193
+ if (parentTable === null) {
194
+ return -1;
195
+ }
196
+ let tablePos = $pos.start(parentTable.depth);
197
+ const tableNode = parentTable.node;
198
+ const map = TableMap.get(tableNode);
199
+ const cell = tablePos + map.map[(map.width * indexes.rowIndex) + indexes.cellIndex];
200
+ return cell;
201
+ }
202
+ function draggedWidth(dragging, event, cellMinWidth) {
203
+ let offset = event.clientX - dragging.startX;
204
+ return Math.max(cellMinWidth, dragging.startWidth + offset);
205
+ }
206
+ function updateHandle(view, value) {
207
+ view.dispatch(view.state.tr.setMeta(key, { setHandle: value }));
208
+ }
209
+ function updateColumnWidth(view, cell, _width) {
210
+ let $cell = view.state.doc.resolve(cell);
211
+ let tableNode = $cell.node(-1), start = $cell.start(-1);
212
+ let tr = view.state.tr;
213
+ const tablePos = $cell.posAtIndex(0, $cell.depth - 1) - 1;
214
+ const tableDom = view.nodeDOM(start).closest('table');
215
+ let attrs = tableNode.attrs;
216
+ if (tableNode && attrs[colgroupAttr]) {
217
+ const colgroup = tableDom.firstChild;
218
+ attrs = Object.assign({}, attrs, { [colgroupAttr]: colgroup.outerHTML });
219
+ }
220
+ const tableDomWidth = tableDom.style.width;
221
+ if (tableDom && tableDomWidth && parseStyle(attrs.style).width !== tableDomWidth) {
222
+ attrs = setNodeStyle(attrs, 'width', tableDomWidth);
223
+ tr.setNodeMarkup(tablePos, null, attrs);
224
+ }
225
+ if (tr.docChanged) {
226
+ view.dispatch(tr);
227
+ }
228
+ }
229
+ function displayColumnWidth(view, cell, width, _cellMinWidth) {
230
+ let $cell = view.state.doc.resolve(cell);
231
+ let table = $cell.node(-1), start = $cell.start(-1);
232
+ let col = TableMap.get(table).colCount($cell.pos - start) + $cell.nodeAfter.attrs.colspan - 1;
233
+ let dom = view.domAtPos($cell.start(-1)).node;
234
+ if (dom.nodeName !== 'TABLE') {
235
+ dom = dom.closest('table');
236
+ }
237
+ const tableDom = dom;
238
+ const colgroup = tableDom.firstChild;
239
+ const cols = Array.from(colgroup.children);
240
+ cols[col].style.width = width + 'px';
241
+ if (tableDom.style.width) {
242
+ const widths = cols.map(c => c.style.width);
243
+ if (widths.every(Boolean)) {
244
+ const sum = widths.reduce((acc, cur) => acc + parseFloat(cur), 0);
245
+ tableDom.style.width = sum + 'px';
246
+ }
247
+ }
248
+ }
249
+ function handleDecorations(state, cell) {
250
+ let decorations = [];
251
+ let $cell = state.doc.resolve(cell);
252
+ let table = $cell.node(-1), map = TableMap.get(table), start = $cell.start(-1);
253
+ let col = map.colCount($cell.pos - start) + $cell.nodeAfter.attrs.colspan;
254
+ for (let row = 0; row < map.height; row++) {
255
+ let index = col + row * map.width - 1;
256
+ // For positions that are have either a different cell or the end
257
+ // of the table to their right, and either the top of the table or
258
+ // a different cell above them, add a decoration
259
+ if ((col === map.width || map.map[index] !== map.map[index + 1]) &&
260
+ (row === 0 || map.map[index - 1] !== map.map[index - 1 - map.width])) {
261
+ let cellPos = map.map[index];
262
+ let pos = start + cellPos + table.nodeAt(cellPos).nodeSize - 1;
263
+ let dom = document.createElement('div');
264
+ dom.className = 'column-resize-handle';
265
+ decorations.push(Decoration.widget(pos, dom));
266
+ }
267
+ }
268
+ return DecorationSet.create(state.doc, decorations);
269
+ }
@@ -0,0 +1,8 @@
1
+ import { columnResizing } from './column-resize';
2
+ import { tableResizing as tableResize } from './table-resize';
3
+ import { rowResizing } from './row-resize';
4
+ export const tableResizing = () => [
5
+ tableResize(),
6
+ columnResizing(),
7
+ rowResizing()
8
+ ];
@@ -0,0 +1,226 @@
1
+ import { Plugin } from 'prosemirror-state';
2
+ import { TableMap, tableNodeTypes } from 'prosemirror-tables';
3
+ import { Decoration, DecorationSet } from 'prosemirror-view';
4
+ import { domCellAround, otherResizeHandle, otherResizing, parentNode, parseStyle, setNodeStyle, tableRowResizing as key } from './utils';
5
+ class TableRowView {
6
+ ignoreMutation(record) {
7
+ return record.type === 'attributes' && record.attributeName === 'style' && record.target.nodeName === 'TR';
8
+ }
9
+ }
10
+ export function rowResizing() {
11
+ const handleWidth = 5;
12
+ let plugin = new Plugin({
13
+ key,
14
+ state: {
15
+ init(_, state) {
16
+ this.spec.props.nodeViews[tableNodeTypes(state.schema).row.name] = (_node, _view) => new TableRowView();
17
+ return new ResizeState(-1, null);
18
+ },
19
+ apply(tr, prev) {
20
+ return prev.apply(tr);
21
+ }
22
+ },
23
+ props: {
24
+ attributes(state) {
25
+ if (otherResizeHandle(key, state)) {
26
+ return null;
27
+ }
28
+ let pluginState = key.getState(state);
29
+ return pluginState.activeHandle > -1 ? { class: 'resize-cursor-vertical' } : null;
30
+ },
31
+ handleDOMEvents: {
32
+ mousemove(view, event) {
33
+ if (!otherResizing(key, view.state)) {
34
+ handleMouseMove(view, event, handleWidth);
35
+ }
36
+ return false;
37
+ },
38
+ mouseleave(view) {
39
+ handleMouseLeave(view);
40
+ return false;
41
+ },
42
+ mousedown(view, event) {
43
+ return handleMouseDown(view, event);
44
+ }
45
+ },
46
+ decorations(state) {
47
+ if (otherResizing(key, state)) {
48
+ return DecorationSet.empty;
49
+ }
50
+ let pluginState = key.getState(state);
51
+ if (pluginState.activeHandle > -1) {
52
+ return handleDecorations(state, pluginState.activeHandle);
53
+ }
54
+ },
55
+ nodeViews: {}
56
+ }
57
+ });
58
+ return plugin;
59
+ }
60
+ function pointsAtCell($pos) {
61
+ return $pos.parent.type.spec.tableRole === 'row' && $pos.nodeAfter;
62
+ }
63
+ class ResizeState {
64
+ constructor(activeHandle, dragging) {
65
+ this.activeHandle = activeHandle;
66
+ this.dragging = dragging;
67
+ }
68
+ apply(tr) {
69
+ let state = this, action = tr.getMeta(key);
70
+ if (action && action.setHandle != null) {
71
+ return new ResizeState(action.setHandle, null);
72
+ }
73
+ if (action && action.setDragging !== undefined) {
74
+ return new ResizeState(state.activeHandle, action.setDragging);
75
+ }
76
+ if (state.activeHandle > -1) {
77
+ let handle = tr.mapping.map(state.activeHandle, -1);
78
+ if (!pointsAtCell(tr.doc.resolve(handle))) {
79
+ handle = null;
80
+ }
81
+ state = new ResizeState(handle, state.dragging);
82
+ }
83
+ return state;
84
+ }
85
+ }
86
+ function handleMouseMove(view, event, handleWidth) {
87
+ let pluginState = key.getState(view.state);
88
+ if (!pluginState.dragging) {
89
+ let target = domCellAround(event.target), row = -1;
90
+ if (target) {
91
+ const rowDom = target.parentNode;
92
+ let domRect = rowDom.getBoundingClientRect();
93
+ if (Math.abs(event.clientY - domRect.top) <= handleWidth && rowDom.rowIndex > 0) {
94
+ row = edgeRow(view, event, rowDom.rowIndex - 1);
95
+ }
96
+ else if (domRect.bottom - event.clientY > 0 && domRect.bottom - event.clientY <= handleWidth) {
97
+ row = edgeRow(view, event, rowDom.rowIndex);
98
+ }
99
+ }
100
+ if (row !== pluginState.activeHandle) {
101
+ updateHandle(view, row);
102
+ }
103
+ }
104
+ }
105
+ function handleMouseLeave(view) {
106
+ let pluginState = key.getState(view.state);
107
+ if (pluginState.activeHandle > -1 && !pluginState.dragging) {
108
+ updateHandle(view, -1);
109
+ }
110
+ }
111
+ function handleMouseDown(view, event) {
112
+ let pluginState = key.getState(view.state);
113
+ if (pluginState.activeHandle === -1 || pluginState.dragging) {
114
+ return false;
115
+ }
116
+ const doc = view.state.doc;
117
+ let $pos = doc.resolve(pluginState.activeHandle);
118
+ let row = doc.nodeAt(pluginState.activeHandle);
119
+ let table = $pos.parent;
120
+ let rowHeightStr = parseStyle(row.attrs.style).height;
121
+ let tableHeight = parseStyle(table.attrs.style).height;
122
+ let rowHeight = rowHeightStr ? parseFloat(rowHeightStr) : 0;
123
+ if (!rowHeightStr) {
124
+ const tr = view.nodeDOM(pluginState.activeHandle);
125
+ rowHeight = tr.offsetHeight;
126
+ }
127
+ view.dispatch(view.state.tr.setMeta(key, {
128
+ setDragging: {
129
+ startY: event.clientY,
130
+ startHeight: { rowHeight, tableHeight }
131
+ }
132
+ }));
133
+ function finish(ev) {
134
+ ev.view.removeEventListener('mouseup', finish);
135
+ ev.view.removeEventListener('mousemove', move);
136
+ let curPluginState = key.getState(view.state);
137
+ if (curPluginState.dragging) {
138
+ const tr = view.state.tr.setMeta(key, { setDragging: null });
139
+ updateRowHeight(view, tr, curPluginState.activeHandle);
140
+ view.dispatch(tr);
141
+ }
142
+ }
143
+ function move(ev) {
144
+ if (!ev.which) {
145
+ return finish(ev);
146
+ }
147
+ let curPluginState = key.getState(view.state);
148
+ let dragged = draggedHeight(curPluginState.dragging, ev);
149
+ let offset = ev.clientY - curPluginState.dragging.startY;
150
+ displayRowHeight(view, curPluginState.activeHandle, dragged, offset, tableHeight);
151
+ }
152
+ event.view.addEventListener('mouseup', finish);
153
+ event.view.addEventListener('mousemove', move);
154
+ event.preventDefault();
155
+ return true;
156
+ }
157
+ function edgeRow(view, event, rowIndex) {
158
+ let found = view.posAtCoords({ left: event.clientX, top: event.clientY });
159
+ if (!found) {
160
+ return -1;
161
+ }
162
+ let $pos = view.state.doc.resolve(found.pos);
163
+ let parentTable = parentNode($pos, n => n.type.spec.tableRole === 'table');
164
+ if (parentTable === null) {
165
+ return -1;
166
+ }
167
+ let tablePos = $pos.start(parentTable.depth);
168
+ const tableNode = parentTable.node;
169
+ const map = TableMap.get(tableNode);
170
+ const row = tablePos + map.map[(map.width * rowIndex)] - 1;
171
+ return row;
172
+ }
173
+ function draggedHeight(dragging, event) {
174
+ let offset = event.clientY - dragging.startY;
175
+ return dragging.startHeight.rowHeight + offset;
176
+ }
177
+ function updateHandle(view, value) {
178
+ view.dispatch(view.state.tr.setMeta(key, { setHandle: value }));
179
+ }
180
+ function updateRowHeight(view, tr, rowPos) {
181
+ const doc = view.state.doc;
182
+ let row = doc.nodeAt(rowPos);
183
+ const dom = view.nodeDOM(rowPos);
184
+ const win = (dom.ownerDocument && dom.ownerDocument.defaultView) || window;
185
+ dom.style.height = win.getComputedStyle(dom).height;
186
+ tr.setNodeMarkup(rowPos, null, setNodeStyle(row.attrs, 'height', dom.style.height));
187
+ const table = dom && dom.closest('table');
188
+ const tableHeight = table && table.style.height;
189
+ if (tableHeight) {
190
+ let $pos = doc.resolve(rowPos);
191
+ let tablePos = $pos.start($pos.depth) - 1;
192
+ tr.setNodeMarkup(tablePos, null, setNodeStyle($pos.parent.attrs, 'height', tableHeight));
193
+ }
194
+ }
195
+ function displayRowHeight(view, rowPos, height, offset, tableHeight) {
196
+ const dom = view.nodeDOM(rowPos);
197
+ if (dom) {
198
+ dom.style.height = height + 'px';
199
+ const win = (dom.ownerDocument && dom.ownerDocument.defaultView) || window;
200
+ dom.style.height = win.getComputedStyle(dom).height;
201
+ const table = dom.closest('table');
202
+ const newHeight = (parseFloat(tableHeight) + offset) + 'px';
203
+ const current = table && table.style.height;
204
+ if (current && current !== newHeight) {
205
+ table.style.height = (parseFloat(tableHeight) + offset) + 'px';
206
+ table.style.height = win.getComputedStyle(table).height;
207
+ }
208
+ }
209
+ }
210
+ function handleDecorations(state, pos) {
211
+ let decorations = [];
212
+ if (typeof pos !== 'number') {
213
+ return DecorationSet.empty;
214
+ }
215
+ let $row = state.doc.resolve(pos), table = $row.parent, map = TableMap.get(table), rowIndex = $row.index($row.depth), start = $row.start($row.depth);
216
+ for (let col = 0; col < map.width; col++) {
217
+ let index = col + rowIndex * map.width;
218
+ let cellPos = map.map[index];
219
+ const cell = table.nodeAt(cellPos);
220
+ let widgetPos = start + cellPos + (cell ? cell.nodeSize : 0) - 1;
221
+ let dom = document.createElement('div');
222
+ dom.className = 'row-resize-handle';
223
+ decorations.push(Decoration.widget(widgetPos, dom));
224
+ }
225
+ return DecorationSet.create(state.doc, decorations);
226
+ }