@progress/kendo-editor-common 1.9.0-dev.202204060830 → 1.9.0-dev.202204181342

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 (36) 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 +2 -1
  4. package/dist/es/config/schema.js +10 -6
  5. package/dist/es/plugins/image-resize.js +4 -14
  6. package/dist/es/plugins/resize-utils.js +11 -0
  7. package/dist/es/plugins/table-resize/column-resize.js +28 -49
  8. package/dist/es/plugins/table-resize/row-resize.js +40 -54
  9. package/dist/es/plugins/table-resize/table-resize.js +46 -67
  10. package/dist/es/plugins/table-resize/table-view.js +9 -9
  11. package/dist/es/plugins/table-resize/utils.js +26 -2
  12. package/dist/es2015/config/constants.js +2 -1
  13. package/dist/es2015/config/schema.js +6 -6
  14. package/dist/es2015/plugins/image-resize.js +4 -14
  15. package/dist/es2015/plugins/resize-utils.js +11 -0
  16. package/dist/es2015/plugins/table-resize/column-resize.js +28 -49
  17. package/dist/es2015/plugins/table-resize/row-resize.js +40 -54
  18. package/dist/es2015/plugins/table-resize/table-resize.js +45 -66
  19. package/dist/es2015/plugins/table-resize/table-view.js +9 -9
  20. package/dist/es2015/plugins/table-resize/utils.js +26 -2
  21. package/dist/npm/config/constants.d.ts +2 -1
  22. package/dist/npm/config/constants.js +2 -1
  23. package/dist/npm/config/schema.js +10 -6
  24. package/dist/npm/plugins/image-resize.js +6 -16
  25. package/dist/npm/plugins/resize-utils.d.ts +35 -0
  26. package/dist/npm/plugins/resize-utils.js +13 -0
  27. package/dist/npm/plugins/table-resize/column-resize.js +28 -49
  28. package/dist/npm/plugins/table-resize/row-resize.js +39 -53
  29. package/dist/npm/plugins/table-resize/table-resize.d.ts +2 -4
  30. package/dist/npm/plugins/table-resize/table-resize.js +45 -66
  31. package/dist/npm/plugins/table-resize/table-view.d.ts +7 -7
  32. package/dist/npm/plugins/table-resize/table-view.js +8 -8
  33. package/dist/npm/plugins/table-resize/utils.d.ts +10 -0
  34. package/dist/npm/plugins/table-resize/utils.js +29 -2
  35. package/dist/systemjs/kendo-editor-common.js +1 -1
  36. package/package.json +2 -2
@@ -3,4 +3,5 @@ export var colgroupAttr = 'k-colgroup-data';
3
3
  export var resizableAttr = 'resizable-node';
4
4
  export var resizableWrap = 'k-editor-resize-wrap-element';
5
5
  export var resizeHandle = 'k-editor-resize-handle';
6
- export var dataDirection = 'data-direction';
6
+ export var dataResizeDirTable = 'data-direction';
7
+ export var dataResizeDirImage = 'data-direction-image';
@@ -32,11 +32,15 @@ var hasAttrs = function (attrs, exclude) {
32
32
  return false;
33
33
  };
34
34
  var pmAttributes = function (attrs, exclude) {
35
+ if (exclude === void 0) { exclude = []; }
35
36
  var result = {};
36
- for (var attr in attrs) {
37
- if (attr && attrs[attr] !== null && attr !== exclude) {
37
+ var _loop_1 = function (attr) {
38
+ if (attr && attrs[attr] !== null && !exclude.find(function (e) { return e === attr; })) {
38
39
  result[attr] = attrs[attr];
39
40
  }
41
+ };
42
+ for (var attr in attrs) {
43
+ _loop_1(attr);
40
44
  }
41
45
  return result;
42
46
  };
@@ -121,7 +125,7 @@ tNodes.table_row.toDOM = function (node) { return ['tr', pmAttributes(node.attrs
121
125
  tNodes.table_row.parseDOM = [{ tag: 'tr', getAttrs: domAttributes }];
122
126
  tNodes.table.attrs = tslib_1.__assign({}, tNodes.table.attrs, defaultAttrs(['style', 'class', 'id', colgroupAttr, resizableAttr]));
123
127
  tNodes.table.toDOM = function (node) {
124
- var tableAttrs = hasAttrs(node.attrs) ? pmAttributes(node.attrs, colgroupAttr) : {};
128
+ var tableAttrs = hasAttrs(node.attrs) ? pmAttributes(node.attrs, [colgroupAttr, resizableAttr]) : {};
125
129
  var colgroup = null;
126
130
  if (node.attrs[colgroupAttr] && !shouldSkipColgroup(node)) {
127
131
  var colgroupEl = parseStrColgroup(node.attrs[colgroupAttr]);
@@ -210,7 +214,7 @@ var nodes = tslib_1.__assign({
210
214
  { tag: 'h6', getAttrs: function (node) { return (tslib_1.__assign({}, domAttributes(node), { level: 6 })); } }
211
215
  ],
212
216
  toDOM: function (node) { return hasAttrs(node.attrs, 'level') ?
213
- ['h' + node.attrs.level, pmAttributes(node.attrs, 'level'), hole] :
217
+ ['h' + node.attrs.level, pmAttributes(node.attrs, ['level']), hole] :
214
218
  ['h' + node.attrs.level, hole]; }
215
219
  },
216
220
  // :: NodeSpec A code listing. Disallows marks or non-text inline
@@ -267,8 +271,8 @@ var nodes = tslib_1.__assign({
267
271
  } }],
268
272
  toDOM: function (node) {
269
273
  return node.attrs.order === 1 ?
270
- (hasAttrs(node.attrs, 'order') ? ['ol', pmAttributes(node.attrs, 'order'), hole] : olDOM) :
271
- ['ol', tslib_1.__assign({}, pmAttributes(node.attrs, 'order'), { start: node.attrs.order }), hole];
274
+ (hasAttrs(node.attrs, 'order') ? ['ol', pmAttributes(node.attrs, ['order']), hole] : olDOM) :
275
+ ['ol', tslib_1.__assign({}, pmAttributes(node.attrs, ['order']), { start: node.attrs.order }), hole];
272
276
  }
273
277
  },
274
278
  // :: NodeSpec
@@ -1,20 +1,10 @@
1
1
  import * as tslib_1 from "tslib";
2
2
  import { NodeSelection, Plugin, PluginKey } from "prosemirror-state";
3
3
  import { Decoration, DecorationSet } from "prosemirror-view";
4
- import { dataDirection, resizeHandle } from "../config/constants";
4
+ import { dataResizeDirImage, resizeHandle } from "../config/constants";
5
5
  import { changeStylesString } from "../utils";
6
+ import { directions, handles } from './resize-utils';
6
7
  export var imageResizeKey = new PluginKey('image-resize');
7
- var directions = {
8
- 'southeast': { x: 1, y: 1 },
9
- 'east': { x: 1, y: 0 },
10
- 'south': { x: 0, y: 1 },
11
- 'north': { x: 0, y: -1 },
12
- 'west': { x: -1, y: 0 },
13
- 'southwest': { x: -1, y: 1 },
14
- 'northwest': { x: -1, y: -1 },
15
- 'northeast': { x: 1, y: -1 } // top right
16
- };
17
- var handles = Object.keys(directions);
18
8
  var setSize = function (domNode, sizeType, value) {
19
9
  domNode.style[sizeType] = value + 'px';
20
10
  };
@@ -110,7 +100,7 @@ var handleMouseUp = function (view) {
110
100
  };
111
101
  var handleMouseDown = function (view, event, options) {
112
102
  var target = event.target;
113
- var activeHandle = target.getAttribute(dataDirection);
103
+ var activeHandle = target.getAttribute(dataResizeDirImage);
114
104
  if (!activeHandle) {
115
105
  return false;
116
106
  }
@@ -223,7 +213,7 @@ export var imageResizing = function (options) {
223
213
  for (var i = 0; i < handles.length; i++) {
224
214
  var dom = document.createElement('div');
225
215
  dom.className = resizeHandle + ' ' + handles[i];
226
- dom.setAttribute(dataDirection, handles[i]);
216
+ dom.setAttribute(dataResizeDirImage, handles[i]);
227
217
  wrapper.appendChild(dom);
228
218
  }
229
219
  return DecorationSet.create(state.doc, [Decoration.widget(state.selection.from + 1, wrapper)]);
@@ -0,0 +1,11 @@
1
+ export var directions = {
2
+ 'southeast': { x: 1, y: 1 },
3
+ 'east': { x: 1, y: 0 },
4
+ 'south': { x: 0, y: 1 },
5
+ 'north': { x: 0, y: -1 },
6
+ 'west': { x: -1, y: 0 },
7
+ 'southwest': { x: -1, y: 1 },
8
+ 'northwest': { x: -1, y: -1 },
9
+ 'northeast': { x: 1, y: -1 } // top right
10
+ };
11
+ export var handles = Object.keys(directions);
@@ -4,10 +4,10 @@ import { tableNodeTypes, TableMap } from 'prosemirror-tables';
4
4
  import { Decoration, DecorationSet } from 'prosemirror-view';
5
5
  import { colgroupAttr } from '../../config/constants';
6
6
  import { TableView } from './table-view';
7
- import { otherResizeHandle, otherResizing, parseStyle, setNodeStyle, tableColumnResizing as key } from './utils';
7
+ import { cellIndexes, domCellAround, otherResizeHandle, otherResizing, parentNode, parseStyle, setNodeStyle, tableColumnResizing as key } from './utils';
8
8
  export function columnResizing() {
9
9
  // tslint:disable-next-line:variable-name
10
- var View = TableView, lastColumnResizable = true, handleWidth = 5, cellMinWidth = 25;
10
+ var View = TableView, handleWidth = 5, cellMinWidth = 25;
11
11
  var plugin = new Plugin({
12
12
  key: key,
13
13
  state: {
@@ -30,7 +30,7 @@ export function columnResizing() {
30
30
  handleDOMEvents: {
31
31
  mousemove: function (view, event) {
32
32
  if (!otherResizing(key, view.state)) {
33
- handleMouseMove(view, event, handleWidth, cellMinWidth, lastColumnResizable);
33
+ handleMouseMove(view, event, handleWidth);
34
34
  }
35
35
  return false;
36
36
  },
@@ -43,29 +43,21 @@ export function columnResizing() {
43
43
  }
44
44
  },
45
45
  decorations: function (state) {
46
- if (otherResizing(key, state)) {
47
- return DecorationSet.empty;
48
- }
49
- var pluginState = key.getState(state);
50
- if (pluginState.activeHandle > -1) {
51
- return handleDecorations(state, pluginState.activeHandle);
46
+ if (!otherResizing(key, state)) {
47
+ var pluginState = key.getState(state);
48
+ if (pluginState.activeHandle > -1) {
49
+ return handleDecorations(state, pluginState.activeHandle);
50
+ }
52
51
  }
52
+ return DecorationSet.empty;
53
53
  },
54
54
  nodeViews: {}
55
55
  }
56
56
  });
57
57
  return plugin;
58
58
  }
59
- function cellAround($pos) {
60
- for (var d = $pos.depth - 1; d > 0; d--) {
61
- if ($pos.node(d).type.spec.tableRole === 'row') {
62
- return $pos.node(0).resolve($pos.before(d + 1));
63
- }
64
- }
65
- return null;
66
- }
67
59
  function pointsAtCell($pos) {
68
- return $pos.parent.type.spec.tableRole === 'row' && $pos.nodeAfter;
60
+ return Boolean($pos.parent.type.spec.tableRole === 'row' && $pos.nodeAfter);
69
61
  }
70
62
  var ResizeState = /** @class */ (function () {
71
63
  function ResizeState(activeHandle, dragging) {
@@ -83,7 +75,7 @@ var ResizeState = /** @class */ (function () {
83
75
  if (state.activeHandle > -1 && tr.docChanged) {
84
76
  var handle = tr.mapping.map(state.activeHandle, -1);
85
77
  if (!pointsAtCell(tr.doc.resolve(handle))) {
86
- handle = null;
78
+ handle = -1;
87
79
  }
88
80
  state = new ResizeState(handle, state.dragging);
89
81
  }
@@ -91,28 +83,22 @@ var ResizeState = /** @class */ (function () {
91
83
  };
92
84
  return ResizeState;
93
85
  }());
94
- function handleMouseMove(view, event, handleWidth, _cellMinWidth, lastColumnResizable) {
86
+ function handleMouseMove(view, event, handleWidth) {
95
87
  var pluginState = key.getState(view.state);
96
88
  if (!pluginState.dragging) {
97
89
  var target = domCellAround(event.target), cell = -1;
98
90
  if (target) {
91
+ var indexes = cellIndexes(target);
99
92
  var _a = target.getBoundingClientRect(), left = _a.left, right = _a.right;
100
- if (event.clientX - left <= handleWidth) {
101
- cell = edgeCell(view, event, 'left');
93
+ if (Math.abs(event.clientX - left) <= handleWidth && indexes.cellIndex > 0) {
94
+ indexes.cellIndex--;
95
+ cell = edgeCell(view, event, indexes);
102
96
  }
103
- else if (right - event.clientX <= handleWidth) {
104
- cell = edgeCell(view, event, 'right');
97
+ else if (right - event.clientX > 0 && right - event.clientX <= handleWidth) {
98
+ cell = edgeCell(view, event, indexes);
105
99
  }
106
100
  }
107
101
  if (cell !== pluginState.activeHandle) {
108
- if (!lastColumnResizable && cell !== -1) {
109
- var $cell = view.state.doc.resolve(cell);
110
- var table = $cell.node(-1), map = TableMap.get(table), start = $cell.start(-1);
111
- var col = map.colCount($cell.pos - start) + $cell.nodeAfter.attrs.colspan - 1;
112
- if (col === map.width - 1) {
113
- return;
114
- }
115
- }
116
102
  updateHandle(view, cell);
117
103
  }
118
104
  }
@@ -170,7 +156,7 @@ function handleMouseDown(view, event, cellMinWidth) {
170
156
  var widths = Array.from(col.parentNode.children).map(function (c) { return c.style.width; });
171
157
  if (widths.every(Boolean)) {
172
158
  var sum = widths.reduce(function (acc, cur) { return acc + parseFloat(cur); }, 0);
173
- tableAttrs = setNodeStyle(tableNode.attrs, 'width', sum + 'px');
159
+ tableAttrs = setNodeStyle(tableAttrs || tableNode.attrs, 'width', sum + 'px');
174
160
  }
175
161
  }
176
162
  if (tableAttrs) {
@@ -200,28 +186,21 @@ function handleMouseDown(view, event, cellMinWidth) {
200
186
  event.preventDefault();
201
187
  return true;
202
188
  }
203
- function domCellAround(target) {
204
- while (target && target.nodeName !== 'TD' && target.nodeName !== 'TH') {
205
- target = target.classList.contains('ProseMirror') ? null : target.parentNode;
206
- }
207
- return target;
208
- }
209
- function edgeCell(view, event, side) {
189
+ function edgeCell(view, event, indexes) {
210
190
  var found = view.posAtCoords({ left: event.clientX, top: event.clientY });
211
191
  if (!found) {
212
192
  return -1;
213
193
  }
214
- var pos = found.pos;
215
- var $cell = cellAround(view.state.doc.resolve(pos));
216
- if (!$cell) {
194
+ var $pos = view.state.doc.resolve(found.pos);
195
+ var parentTable = parentNode($pos, function (n) { return n.type.spec.tableRole === 'table'; });
196
+ if (parentTable === null) {
217
197
  return -1;
218
198
  }
219
- if (side === 'right') {
220
- return $cell.pos;
221
- }
222
- var map = TableMap.get($cell.node(-1)), start = $cell.start(-1);
223
- var index = map.map.indexOf($cell.pos - start);
224
- return index % map.width === 0 ? -1 : start + map.map[index - 1];
199
+ var tablePos = $pos.start(parentTable.depth);
200
+ var tableNode = parentTable.node;
201
+ var map = TableMap.get(tableNode);
202
+ var cell = tablePos + map.map[(map.width * indexes.rowIndex) + indexes.cellIndex];
203
+ return cell;
225
204
  }
226
205
  function draggedWidth(dragging, event, cellMinWidth) {
227
206
  var offset = event.clientX - dragging.startX;
@@ -1,7 +1,7 @@
1
1
  import { Plugin } from 'prosemirror-state';
2
2
  import { TableMap, tableNodeTypes } from 'prosemirror-tables';
3
3
  import { Decoration, DecorationSet } from 'prosemirror-view';
4
- import { otherResizeHandle, otherResizing, parseStyle, setNodeStyle, tableRowResizing as key } from './utils';
4
+ import { domCellAround, otherResizeHandle, otherResizing, parentNode, parseStyle, setNodeStyle, tableRowResizing as key } from './utils';
5
5
  var TableRowView = /** @class */ (function () {
6
6
  function TableRowView() {
7
7
  }
@@ -11,7 +11,7 @@ var TableRowView = /** @class */ (function () {
11
11
  return TableRowView;
12
12
  }());
13
13
  export function rowResizing() {
14
- var handleWidth = 5, rowMinHeight = 25, lastRowResizable = true;
14
+ var handleWidth = 5;
15
15
  var plugin = new Plugin({
16
16
  key: key,
17
17
  state: {
@@ -34,7 +34,7 @@ export function rowResizing() {
34
34
  handleDOMEvents: {
35
35
  mousemove: function (view, event) {
36
36
  if (!otherResizing(key, view.state)) {
37
- handleMouseMove(view, event, handleWidth, rowMinHeight, lastRowResizable);
37
+ handleMouseMove(view, event, handleWidth);
38
38
  }
39
39
  return false;
40
40
  },
@@ -43,7 +43,7 @@ export function rowResizing() {
43
43
  return false;
44
44
  },
45
45
  mousedown: function (view, event) {
46
- return handleMouseDown(view, event, rowMinHeight);
46
+ return handleMouseDown(view, event);
47
47
  }
48
48
  },
49
49
  decorations: function (state) {
@@ -76,7 +76,7 @@ var ResizeState = /** @class */ (function () {
76
76
  if (action && action.setDragging !== undefined) {
77
77
  return new ResizeState(state.activeHandle, action.setDragging);
78
78
  }
79
- if (state.activeHandle > -1) { // && tr.docChanged
79
+ if (state.activeHandle > -1) {
80
80
  var handle = tr.mapping.map(state.activeHandle, -1);
81
81
  if (!pointsAtCell(tr.doc.resolve(handle))) {
82
82
  handle = null;
@@ -87,30 +87,22 @@ var ResizeState = /** @class */ (function () {
87
87
  };
88
88
  return ResizeState;
89
89
  }());
90
- function handleMouseMove(view, event, handleWidth, _rowMinHeight, lastRowResizable) {
90
+ function handleMouseMove(view, event, handleWidth) {
91
91
  var pluginState = key.getState(view.state);
92
92
  if (!pluginState.dragging) {
93
- var target = domCellAround(event.target), cell = -1;
93
+ var target = domCellAround(event.target), row = -1;
94
94
  if (target) {
95
95
  var rowDom = target.parentNode;
96
96
  var domRect = rowDom.getBoundingClientRect();
97
- if (event.clientY - domRect.top <= handleWidth) {
98
- cell = edgeCell(view, event, 'up');
97
+ if (Math.abs(event.clientY - domRect.top) <= handleWidth && rowDom.rowIndex > 0) {
98
+ row = edgeRow(view, event, rowDom.rowIndex - 1);
99
99
  }
100
- else if (domRect.bottom - event.clientY <= handleWidth) {
101
- cell = edgeCell(view, event, 'down');
100
+ else if (domRect.bottom - event.clientY > 0 && domRect.bottom - event.clientY <= handleWidth) {
101
+ row = edgeRow(view, event, rowDom.rowIndex);
102
102
  }
103
103
  }
104
- if (cell !== pluginState.activeHandle) {
105
- if (!lastRowResizable && cell !== -1) {
106
- // let $cell = view.state.doc.resolve(cell);
107
- // let table = $cell.node(-1), map = TableMap.get(table), start = $cell.start(-1);
108
- // let col = map.colCount($cell.pos - start) + $cell.nodeAfter.attrs.colspan - 1;
109
- // if (col === map.width - 1) {
110
- // return;
111
- // }
112
- }
113
- updateHandle(view, cell);
104
+ if (row !== pluginState.activeHandle) {
105
+ updateHandle(view, row);
114
106
  }
115
107
  }
116
108
  }
@@ -120,7 +112,7 @@ function handleMouseLeave(view) {
120
112
  updateHandle(view, -1);
121
113
  }
122
114
  }
123
- function handleMouseDown(view, event, rowMinHeight) {
115
+ function handleMouseDown(view, event) {
124
116
  var pluginState = key.getState(view.state);
125
117
  if (pluginState.activeHandle === -1 || pluginState.dragging) {
126
118
  return false;
@@ -148,7 +140,7 @@ function handleMouseDown(view, event, rowMinHeight) {
148
140
  var curPluginState = key.getState(view.state);
149
141
  if (curPluginState.dragging) {
150
142
  var tr = view.state.tr.setMeta(key, { setDragging: null });
151
- updateRowHeight(view, tr, curPluginState.activeHandle, draggedHeight(curPluginState.dragging, ev, rowMinHeight));
143
+ updateRowHeight(view, tr, curPluginState.activeHandle);
152
144
  view.dispatch(tr);
153
145
  }
154
146
  }
@@ -157,54 +149,45 @@ function handleMouseDown(view, event, rowMinHeight) {
157
149
  return finish(ev);
158
150
  }
159
151
  var curPluginState = key.getState(view.state);
160
- var dragged = draggedHeight(curPluginState.dragging, ev, rowMinHeight);
152
+ var dragged = draggedHeight(curPluginState.dragging, ev);
161
153
  var offset = ev.clientY - curPluginState.dragging.startY;
162
- displayRowHeight(view, curPluginState.activeHandle, dragged, rowMinHeight, offset, tableHeight);
154
+ displayRowHeight(view, curPluginState.activeHandle, dragged, offset, tableHeight);
163
155
  }
164
156
  event.view.addEventListener('mouseup', finish);
165
157
  event.view.addEventListener('mousemove', move);
166
158
  event.preventDefault();
167
159
  return true;
168
160
  }
169
- function domCellAround(target) {
170
- while (target && target.nodeName !== 'TD' && target.nodeName !== 'TH') {
171
- target = target.classList.contains('ProseMirror') ? null : target.parentNode;
172
- }
173
- return target;
174
- }
175
- function edgeCell(view, event, side) {
161
+ function edgeRow(view, event, rowIndex) {
176
162
  var found = view.posAtCoords({ left: event.clientX, top: event.clientY });
177
163
  if (!found) {
178
164
  return -1;
179
165
  }
180
- var pos = found.pos;
181
- var doc = view.state.doc;
182
- var $pos = doc.resolve(pos);
183
- var rowDepth = new Array($pos.depth + 1).fill(0).findIndex(function (_, i) { return $pos.node(i).type.spec.tableRole === 'row'; });
184
- if (rowDepth === -1) {
185
- return -1;
186
- }
187
- var tableDepth = rowDepth - 1;
188
- var rowIndex = $pos.index(tableDepth);
189
- rowIndex += side === 'up' ? -1 : 0;
190
- if (rowIndex < 0) {
166
+ var $pos = view.state.doc.resolve(found.pos);
167
+ var parentTable = parentNode($pos, function (n) { return n.type.spec.tableRole === 'table'; });
168
+ if (parentTable === null) {
191
169
  return -1;
192
170
  }
193
- var rowPos = $pos.posAtIndex(rowIndex, tableDepth);
194
- return rowPos;
171
+ var tablePos = $pos.start(parentTable.depth);
172
+ var tableNode = parentTable.node;
173
+ var map = TableMap.get(tableNode);
174
+ var row = tablePos + map.map[(map.width * rowIndex)] - 1;
175
+ return row;
195
176
  }
196
- function draggedHeight(dragging, event, rowMinHeight) {
177
+ function draggedHeight(dragging, event) {
197
178
  var offset = event.clientY - dragging.startY;
198
- return Math.max(rowMinHeight, dragging.startHeight.rowHeight + offset);
179
+ return dragging.startHeight.rowHeight + offset;
199
180
  }
200
181
  function updateHandle(view, value) {
201
182
  view.dispatch(view.state.tr.setMeta(key, { setHandle: value }));
202
183
  }
203
- function updateRowHeight(view, tr, rowPos, height) {
184
+ function updateRowHeight(view, tr, rowPos) {
204
185
  var doc = view.state.doc;
205
186
  var row = doc.nodeAt(rowPos);
206
- tr.setNodeMarkup(rowPos, null, setNodeStyle(row.attrs, 'height', height + 'px'));
207
187
  var dom = view.nodeDOM(rowPos);
188
+ var win = (dom.ownerDocument && dom.ownerDocument.defaultView) || window;
189
+ dom.style.height = win.getComputedStyle(dom).height;
190
+ tr.setNodeMarkup(rowPos, null, setNodeStyle(row.attrs, 'height', dom.style.height));
208
191
  var table = dom && dom.closest('table');
209
192
  var tableHeight = table && table.style.height;
210
193
  if (tableHeight) {
@@ -213,29 +196,32 @@ function updateRowHeight(view, tr, rowPos, height) {
213
196
  tr.setNodeMarkup(tablePos, null, setNodeStyle($pos.parent.attrs, 'height', tableHeight));
214
197
  }
215
198
  }
216
- // tslint:disable-next-line:max-line-length
217
- function displayRowHeight(view, rowPos, height, rowMinHeight, offset, tableHeight) {
199
+ function displayRowHeight(view, rowPos, height, offset, tableHeight) {
218
200
  var dom = view.nodeDOM(rowPos);
219
201
  if (dom) {
220
- dom.style.height = Math.max(height, rowMinHeight) + 'px';
202
+ dom.style.height = height + 'px';
203
+ var win = (dom.ownerDocument && dom.ownerDocument.defaultView) || window;
204
+ dom.style.height = win.getComputedStyle(dom).height;
221
205
  var table = dom.closest('table');
222
206
  var newHeight = (parseFloat(tableHeight) + offset) + 'px';
223
207
  var current = table && table.style.height;
224
208
  if (current && current !== newHeight) {
225
209
  table.style.height = (parseFloat(tableHeight) + offset) + 'px';
210
+ table.style.height = win.getComputedStyle(table).height;
226
211
  }
227
212
  }
228
213
  }
229
214
  function handleDecorations(state, pos) {
230
215
  var decorations = [];
231
216
  if (typeof pos !== 'number') {
232
- return;
217
+ return DecorationSet.empty;
233
218
  }
234
219
  var $row = state.doc.resolve(pos), table = $row.parent, map = TableMap.get(table), rowIndex = $row.index($row.depth), start = $row.start($row.depth);
235
220
  for (var col = 0; col < map.width; col++) {
236
221
  var index = col + rowIndex * map.width;
237
222
  var cellPos = map.map[index];
238
- var widgetPos = start + cellPos + table.nodeAt(cellPos).nodeSize - 1;
223
+ var cell = table.nodeAt(cellPos);
224
+ var widgetPos = start + cellPos + (cell ? cell.nodeSize : 0) - 1;
239
225
  var dom = document.createElement('div');
240
226
  dom.className = 'row-resize-handle';
241
227
  decorations.push(Decoration.widget(widgetPos, dom));