@atlaskit/editor-tables 2.8.2 → 2.8.3
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/CHANGELOG.md +9 -0
- package/afm-cc/tsconfig.json +5 -1
- package/afm-jira/tsconfig.json +5 -1
- package/afm-post-office/tsconfig.json +5 -1
- package/dist/cjs/cell-bookmark.js +3 -2
- package/dist/cjs/cell-selection.js +17 -8
- package/dist/cjs/pm-plugins/input.js +23 -4
- package/dist/cjs/table-map.js +21 -9
- package/dist/cjs/utils/add-column.js +2 -0
- package/dist/cjs/utils/add-row.js +2 -0
- package/dist/cjs/utils/clone-column.js +7 -0
- package/dist/cjs/utils/clone-row.js +2 -0
- package/dist/cjs/utils/copy-paste.js +29 -1
- package/dist/cjs/utils/find.js +5 -1
- package/dist/cjs/utils/fix-tables.js +8 -1
- package/dist/cjs/utils/get-cells-in-column.js +2 -0
- package/dist/cjs/utils/get-cells-in-row.js +2 -0
- package/dist/cjs/utils/move-column.js +9 -1
- package/dist/cjs/utils/move-row.js +2 -0
- package/dist/cjs/utils/normalize-selection.js +2 -0
- package/dist/cjs/utils/reorder-utils.js +20 -4
- package/dist/cjs/utils/split-cell-with-type.js +3 -3
- package/dist/cjs/utils/uuid.js +8 -4
- package/dist/es2019/cell-bookmark.js +3 -0
- package/dist/es2019/cell-selection.js +14 -1
- package/dist/es2019/index.js +3 -0
- package/dist/es2019/pm-plugins/input.js +23 -4
- package/dist/es2019/pm-plugins.js +3 -0
- package/dist/es2019/table-map.js +53 -41
- package/dist/es2019/utils/add-column.js +2 -0
- package/dist/es2019/utils/add-row-at.js +4 -4
- package/dist/es2019/utils/add-row.js +2 -0
- package/dist/es2019/utils/clone-column.js +11 -1
- package/dist/es2019/utils/clone-row.js +7 -2
- package/dist/es2019/utils/copy-paste.js +29 -1
- package/dist/es2019/utils/find.js +4 -1
- package/dist/es2019/utils/fix-tables.js +8 -1
- package/dist/es2019/utils/get-cells-in-column.js +2 -0
- package/dist/es2019/utils/get-cells-in-row.js +2 -0
- package/dist/es2019/utils/get-selection-range-in-column.js +2 -2
- package/dist/es2019/utils/get-selection-range-in-row.js +2 -2
- package/dist/es2019/utils/move-column.js +13 -2
- package/dist/es2019/utils/move-row.js +7 -2
- package/dist/es2019/utils/normalize-selection.js +2 -0
- package/dist/es2019/utils/remove-row.js +3 -3
- package/dist/es2019/utils/remove-table.js +1 -1
- package/dist/es2019/utils/reorder-utils.js +21 -5
- package/dist/es2019/utils/replace-table.js +1 -1
- package/dist/es2019/utils/split-cell-with-type.js +6 -6
- package/dist/es2019/utils/toggle-header.js +6 -6
- package/dist/es2019/utils/uuid.js +4 -1
- package/dist/es2019/utils.js +3 -0
- package/dist/esm/cell-bookmark.js +4 -2
- package/dist/esm/cell-selection.js +18 -7
- package/dist/esm/index.js +3 -0
- package/dist/esm/pm-plugins/input.js +23 -4
- package/dist/esm/pm-plugins.js +3 -0
- package/dist/esm/table-map.js +21 -9
- package/dist/esm/utils/add-column.js +2 -0
- package/dist/esm/utils/add-row.js +2 -0
- package/dist/esm/utils/clone-column.js +7 -0
- package/dist/esm/utils/clone-row.js +2 -0
- package/dist/esm/utils/copy-paste.js +29 -1
- package/dist/esm/utils/find.js +5 -1
- package/dist/esm/utils/fix-tables.js +8 -1
- package/dist/esm/utils/get-cells-in-column.js +2 -0
- package/dist/esm/utils/get-cells-in-row.js +2 -0
- package/dist/esm/utils/move-column.js +9 -1
- package/dist/esm/utils/move-row.js +2 -0
- package/dist/esm/utils/normalize-selection.js +2 -0
- package/dist/esm/utils/reorder-utils.js +20 -4
- package/dist/esm/utils/split-cell-with-type.js +3 -3
- package/dist/esm/utils/uuid.js +8 -4
- package/dist/esm/utils.js +3 -0
- package/package.json +8 -2
- package/tsconfig.json +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @atlaskit/editor-tables
|
|
2
2
|
|
|
3
|
+
## 2.8.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#101371](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/101371)
|
|
8
|
+
[`3cce4a292ef1e`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/3cce4a292ef1e) -
|
|
9
|
+
Add fix for move column logic when moving a column before a column with merged rows behind FG
|
|
10
|
+
platform_editor_table_fix_move_column
|
|
11
|
+
|
|
3
12
|
## 2.8.2
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/afm-cc/tsconfig.json
CHANGED
package/afm-jira/tsconfig.json
CHANGED
|
@@ -9,13 +9,15 @@ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/cl
|
|
|
9
9
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
10
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
11
11
|
var _tables = require("./utils/tables");
|
|
12
|
+
/* eslint-disable @atlaskit/editor/no-re-export */
|
|
13
|
+
// Entry file in package.json
|
|
12
14
|
var CellBookmark = exports.CellBookmark = /*#__PURE__*/function () {
|
|
13
15
|
function CellBookmark(anchor, head) {
|
|
14
16
|
(0, _classCallCheck2.default)(this, CellBookmark);
|
|
15
17
|
this.anchor = anchor;
|
|
16
18
|
this.head = head;
|
|
17
19
|
}
|
|
18
|
-
(0, _createClass2.default)(CellBookmark, [{
|
|
20
|
+
return (0, _createClass2.default)(CellBookmark, [{
|
|
19
21
|
key: "map",
|
|
20
22
|
value: function map(mapping) {
|
|
21
23
|
return new CellBookmark(mapping.map(this.anchor), mapping.map(this.head));
|
|
@@ -36,5 +38,4 @@ var CellBookmark = exports.CellBookmark = /*#__PURE__*/function () {
|
|
|
36
38
|
return _state.Selection.near($headCell, 1);
|
|
37
39
|
}
|
|
38
40
|
}]);
|
|
39
|
-
return CellBookmark;
|
|
40
41
|
}();
|
|
@@ -8,9 +8,9 @@ exports.CellSelection = void 0;
|
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
10
10
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
11
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
12
11
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
13
12
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
13
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
14
14
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
15
15
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
16
16
|
var _cellBookmark = require("./cell-bookmark");
|
|
@@ -21,8 +21,9 @@ var _getCellSelectionRanges = require("./utils/get-cell-selection-ranges");
|
|
|
21
21
|
var _tables = require("./utils/tables");
|
|
22
22
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
23
23
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
24
|
-
function
|
|
25
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } //
|
|
24
|
+
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
|
|
25
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } /* eslint-disable @atlaskit/editor/no-re-export */ // Entry file in package.json
|
|
26
|
+
// Was copied from https://github.com/ProseMirror/prosemirror-tables/blob/master/src/cellselection.js
|
|
26
27
|
// This file defines a ProseMirror selection subclass that models
|
|
27
28
|
// table cell selections. The table plugin needs to be active to wire
|
|
28
29
|
// in the user interaction part of table selections (so that you
|
|
@@ -33,8 +34,6 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
|
|
|
33
34
|
// selects across cells, and will be drawn by giving selected cells a
|
|
34
35
|
// `selectedCell` CSS class.
|
|
35
36
|
var CellSelection = exports.CellSelection = /*#__PURE__*/function (_Selection) {
|
|
36
|
-
(0, _inherits2.default)(CellSelection, _Selection);
|
|
37
|
-
var _super = _createSuper(CellSelection);
|
|
38
37
|
// :: (ResolvedPos, ?ResolvedPos)
|
|
39
38
|
// A table selection is identified by its anchor and head cells. The
|
|
40
39
|
// positions given to this constructor should point _before_ two
|
|
@@ -46,7 +45,7 @@ var CellSelection = exports.CellSelection = /*#__PURE__*/function (_Selection) {
|
|
|
46
45
|
var $headCell = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : $anchorCell;
|
|
47
46
|
(0, _classCallCheck2.default)(this, CellSelection);
|
|
48
47
|
var ranges = (0, _getCellSelectionRanges.getCellSelectionRanges)($anchorCell, $headCell);
|
|
49
|
-
_this =
|
|
48
|
+
_this = _callSuper(this, CellSelection, [ranges[0].$from, ranges[0].$to, ranges]);
|
|
50
49
|
// :: ResolvedPos
|
|
51
50
|
// A resolved position pointing _in front of_ the anchor cell (the one
|
|
52
51
|
// that doesn't move when extending the selection).
|
|
@@ -58,7 +57,8 @@ var CellSelection = exports.CellSelection = /*#__PURE__*/function (_Selection) {
|
|
|
58
57
|
_this.visible = false;
|
|
59
58
|
return _this;
|
|
60
59
|
}
|
|
61
|
-
(0,
|
|
60
|
+
(0, _inherits2.default)(CellSelection, _Selection);
|
|
61
|
+
return (0, _createClass2.default)(CellSelection, [{
|
|
62
62
|
key: "map",
|
|
63
63
|
value: function map(doc, mapping) {
|
|
64
64
|
var $anchorCell = doc.resolve(mapping.map(this.$anchorCell.pos));
|
|
@@ -111,6 +111,8 @@ var CellSelection = exports.CellSelection = /*#__PURE__*/function (_Selection) {
|
|
|
111
111
|
attrs = (0, _colspan.removeColSpan)(attrs, 0, extraLeft);
|
|
112
112
|
}
|
|
113
113
|
if (extraRight > 0) {
|
|
114
|
+
// Ignored via go/ees005
|
|
115
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
114
116
|
attrs = (0, _colspan.removeColSpan)(attrs, attrs.colspan - extraRight, extraRight);
|
|
115
117
|
}
|
|
116
118
|
if (cellRect.left < rect.left) {
|
|
@@ -196,7 +198,11 @@ var CellSelection = exports.CellSelection = /*#__PURE__*/function (_Selection) {
|
|
|
196
198
|
if (Math.min(anchorTop, headTop) > 0) {
|
|
197
199
|
return false;
|
|
198
200
|
}
|
|
201
|
+
// Ignored via go/ees005
|
|
202
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
199
203
|
var anchorBot = anchorTop + this.$anchorCell.nodeAfter.attrs.rowspan;
|
|
204
|
+
// Ignored via go/ees005
|
|
205
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
200
206
|
var headBot = headTop + this.$headCell.nodeAfter.attrs.rowspan;
|
|
201
207
|
return Math.max(anchorBot, headBot) === this.$headCell.node(-1).childCount;
|
|
202
208
|
}
|
|
@@ -238,7 +244,11 @@ var CellSelection = exports.CellSelection = /*#__PURE__*/function (_Selection) {
|
|
|
238
244
|
if (Math.min(anchorLeft, headLeft) > 0) {
|
|
239
245
|
return false;
|
|
240
246
|
}
|
|
247
|
+
// Ignored via go/ees005
|
|
248
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
241
249
|
var anchorRight = anchorLeft + this.$anchorCell.nodeAfter.attrs.colspan;
|
|
250
|
+
// Ignored via go/ees005
|
|
251
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
242
252
|
var headRight = headLeft + this.$headCell.nodeAfter.attrs.colspan;
|
|
243
253
|
return Math.max(anchorRight, headRight) === map.width;
|
|
244
254
|
}
|
|
@@ -335,6 +345,5 @@ var CellSelection = exports.CellSelection = /*#__PURE__*/function (_Selection) {
|
|
|
335
345
|
return new CellSelection(doc.resolve(anchorCell), doc.resolve(headCell));
|
|
336
346
|
}
|
|
337
347
|
}]);
|
|
338
|
-
return CellSelection;
|
|
339
348
|
}(_state.Selection);
|
|
340
349
|
_state.Selection.jsonID('cell', CellSelection);
|
|
@@ -110,6 +110,8 @@ function deleteCellSelection(state, dispatch) {
|
|
|
110
110
|
}
|
|
111
111
|
if (dispatch) {
|
|
112
112
|
var tr = state.tr;
|
|
113
|
+
// Ignored via go/ees005
|
|
114
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
113
115
|
var baseContent = (0, _utils.tableNodeTypes)(state.schema).cell.createAndFill().content;
|
|
114
116
|
sel.forEachCell(function (cell, pos) {
|
|
115
117
|
if (!cell.content.eq(baseContent)) {
|
|
@@ -138,18 +140,23 @@ function handleMouseDown(view, event, dragAndDropEnabled) {
|
|
|
138
140
|
) {
|
|
139
141
|
return false;
|
|
140
142
|
}
|
|
143
|
+
|
|
144
|
+
// Ignored via go/ees005
|
|
145
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
141
146
|
var startDOMCell = domInCell(view, startEvent.target);
|
|
142
147
|
var $anchor = (0, _cells.cellAround)(view.state.selection.$anchor);
|
|
143
148
|
if (startEvent.shiftKey && view.state.selection instanceof _cellSelection.CellSelection) {
|
|
144
|
-
var isDragHandleElement;
|
|
145
149
|
var targetElement = event.target instanceof HTMLElement || event.target instanceof SVGElement ? event.target : null;
|
|
146
|
-
isDragHandleElement = !!targetElement && !!targetElement.closest('button.pm-table-drag-handle-button-container, button.pm-table-drag-handle-button-clickable-zone');
|
|
150
|
+
var isDragHandleElement = !!targetElement && !!targetElement.closest('button.pm-table-drag-handle-button-container, button.pm-table-drag-handle-button-clickable-zone');
|
|
147
151
|
if (dragAndDropEnabled && isDragHandleElement) {
|
|
148
152
|
return false;
|
|
149
153
|
}
|
|
150
154
|
setCellSelection(view.state.selection.$anchorCell, startEvent);
|
|
151
155
|
startEvent.preventDefault();
|
|
152
|
-
} else if (startEvent.shiftKey && startDOMCell && $anchor !== null &&
|
|
156
|
+
} else if (startEvent.shiftKey && startDOMCell && $anchor !== null &&
|
|
157
|
+
// Ignored via go/ees005
|
|
158
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
159
|
+
cellUnderMouse(view, startEvent).pos !== $anchor.pos) {
|
|
153
160
|
// Adding to a selection that starts in another cell (causing a
|
|
154
161
|
// cell selection to be created).
|
|
155
162
|
setCellSelection($anchor, startEvent);
|
|
@@ -183,8 +190,14 @@ function handleMouseDown(view, event, dragAndDropEnabled) {
|
|
|
183
190
|
|
|
184
191
|
// Stop listening to mouse motion events.
|
|
185
192
|
function stop() {
|
|
193
|
+
// Ignored via go/ees005
|
|
194
|
+
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
186
195
|
view.root.removeEventListener('mouseup', stop);
|
|
196
|
+
// Ignored via go/ees005
|
|
197
|
+
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
187
198
|
view.root.removeEventListener('dragstart', stop);
|
|
199
|
+
// Ignored via go/ees005
|
|
200
|
+
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
188
201
|
view.root.removeEventListener('mousemove', move);
|
|
189
202
|
if (_pluginKey.tableEditingKey.getState(view.state) != null) {
|
|
190
203
|
view.dispatch(view.state.tr.setMeta(_pluginKey.tableEditingKey, -1));
|
|
@@ -196,6 +209,8 @@ function handleMouseDown(view, event, dragAndDropEnabled) {
|
|
|
196
209
|
if (anchor != null) {
|
|
197
210
|
// Continuing an existing cross-cell selection
|
|
198
211
|
$moveAnchor = view.state.doc.resolve(anchor);
|
|
212
|
+
// Ignored via go/ees005
|
|
213
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
199
214
|
} else if (domInCell(view, event.target) !== startDOMCell) {
|
|
200
215
|
// Moving out of the initial cell -- start a new cell selection
|
|
201
216
|
$moveAnchor = cellUnderMouse(view, startEvent);
|
|
@@ -208,9 +223,13 @@ function handleMouseDown(view, event, dragAndDropEnabled) {
|
|
|
208
223
|
setCellSelection($moveAnchor, event);
|
|
209
224
|
}
|
|
210
225
|
}
|
|
226
|
+
// Ignored via go/ees005
|
|
227
|
+
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
211
228
|
view.root.addEventListener('mouseup', stop);
|
|
212
|
-
// eslint-disable-next-line @atlaskit/design-system/no-direct-use-of-web-platform-drag-and-drop
|
|
229
|
+
// eslint-disable-next-line @atlaskit/design-system/no-direct-use-of-web-platform-drag-and-drop, @repo/internal/dom-events/no-unsafe-event-listeners
|
|
213
230
|
view.root.addEventListener('dragstart', stop);
|
|
231
|
+
// Ignored via go/ees005
|
|
232
|
+
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
214
233
|
view.root.addEventListener('mousemove', move);
|
|
215
234
|
return false;
|
|
216
235
|
}
|
package/dist/cjs/table-map.js
CHANGED
|
@@ -8,6 +8,9 @@ exports.tableNewColumnMinWidth = exports.TableProblemTypes = exports.TableMap =
|
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
10
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
+
/* eslint-disable @atlaskit/editor/no-re-export */
|
|
12
|
+
// Entry file in package.json
|
|
13
|
+
|
|
11
14
|
// Because working with row and column-spanning cells is not quite
|
|
12
15
|
// trivial, this code builds up a descriptive structure for a given
|
|
13
16
|
// table node. The structures are cached with the (persistent) table
|
|
@@ -32,6 +35,8 @@ if (typeof WeakMap !== 'undefined') {
|
|
|
32
35
|
return value;
|
|
33
36
|
};
|
|
34
37
|
} else {
|
|
38
|
+
// Ignored via go/ees005
|
|
39
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
35
40
|
var _cache = [];
|
|
36
41
|
var cacheSize = 10;
|
|
37
42
|
var cachePos = 0;
|
|
@@ -50,7 +55,10 @@ if (typeof WeakMap !== 'undefined') {
|
|
|
50
55
|
return _cache[cachePos++] = value;
|
|
51
56
|
};
|
|
52
57
|
}
|
|
53
|
-
var Rect = exports.Rect = /*#__PURE__*/(0, _createClass2.default)(
|
|
58
|
+
var Rect = exports.Rect = /*#__PURE__*/(0, _createClass2.default)(
|
|
59
|
+
// Ignored via go/ees005
|
|
60
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
61
|
+
function Rect(left, top, right, bottom) {
|
|
54
62
|
(0, _classCallCheck2.default)(this, Rect);
|
|
55
63
|
this.left = left;
|
|
56
64
|
this.top = top;
|
|
@@ -75,6 +83,8 @@ var tableNewColumnMinWidth = exports.tableNewColumnMinWidth = 140;
|
|
|
75
83
|
// be able to do that, positions saved in the map are relative to the
|
|
76
84
|
// start of the table, rather than the start of the document.
|
|
77
85
|
var TableMap = exports.TableMap = /*#__PURE__*/function () {
|
|
86
|
+
// Ignored via go/ees005
|
|
87
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
78
88
|
function TableMap(width, height, map, problems, mapByColumn, mapByRow) {
|
|
79
89
|
(0, _classCallCheck2.default)(this, TableMap);
|
|
80
90
|
// The width of the table
|
|
@@ -95,7 +105,7 @@ var TableMap = exports.TableMap = /*#__PURE__*/function () {
|
|
|
95
105
|
|
|
96
106
|
// :: (number) → Rect
|
|
97
107
|
// Find the dimensions of the cell at the given position.
|
|
98
|
-
(0, _createClass2.default)(TableMap, [{
|
|
108
|
+
return (0, _createClass2.default)(TableMap, [{
|
|
99
109
|
key: "findCell",
|
|
100
110
|
value: function findCell(pos) {
|
|
101
111
|
for (var i = 0; i < this.map.length; i++) {
|
|
@@ -286,7 +296,6 @@ var TableMap = exports.TableMap = /*#__PURE__*/function () {
|
|
|
286
296
|
return readFromCache(table) || addToCache(table, computeMap(table));
|
|
287
297
|
}
|
|
288
298
|
}]);
|
|
289
|
-
return TableMap;
|
|
290
299
|
}(); // Compute a table map.
|
|
291
300
|
function computeMap(table) {
|
|
292
301
|
if (table.type.spec.tableRole !== 'table') {
|
|
@@ -294,10 +303,10 @@ function computeMap(table) {
|
|
|
294
303
|
}
|
|
295
304
|
var width = findWidth(table);
|
|
296
305
|
var height = table.childCount;
|
|
297
|
-
var map = []
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
306
|
+
var map = [];
|
|
307
|
+
var colWidths = [];
|
|
308
|
+
var mapPos = 0,
|
|
309
|
+
problems = null;
|
|
301
310
|
for (var i = 0, e = width * height; i < e; i++) {
|
|
302
311
|
map[i] = 0;
|
|
303
312
|
}
|
|
@@ -451,8 +460,8 @@ function findBadColWidths(map, colWidths, table) {
|
|
|
451
460
|
continue;
|
|
452
461
|
}
|
|
453
462
|
seen[pos] = true;
|
|
454
|
-
var node = table.nodeAt(pos)
|
|
455
|
-
|
|
463
|
+
var node = table.nodeAt(pos);
|
|
464
|
+
var updated = null;
|
|
456
465
|
for (var j = 0; j < node.attrs.colspan; j++) {
|
|
457
466
|
var col = (i + j) % map.width,
|
|
458
467
|
colWidth = colWidths[col * 2];
|
|
@@ -469,6 +478,9 @@ function findBadColWidths(map, colWidths, table) {
|
|
|
469
478
|
}
|
|
470
479
|
}
|
|
471
480
|
}
|
|
481
|
+
|
|
482
|
+
// Ignored via go/ees005
|
|
483
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
472
484
|
function freshColWidth(attrs) {
|
|
473
485
|
if (attrs.colwidth) {
|
|
474
486
|
return attrs.colwidth.slice();
|
|
@@ -61,6 +61,8 @@ function addColumn(tr, _ref, col) {
|
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
var _pos = map.positionAt(row, col, table);
|
|
64
|
+
// Ignored via go/ees005
|
|
65
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
64
66
|
tr.insert(tr.mapping.map(tableStart + _pos), type.createAndFill(attrs));
|
|
65
67
|
}
|
|
66
68
|
}
|
|
@@ -88,6 +88,8 @@ var cloneColumn = exports.cloneColumn = function cloneColumn(state, originColumn
|
|
|
88
88
|
// The actual target index needs to be translated per row, this is because row/col spans can affect the amount of
|
|
89
89
|
// cells each row contains.
|
|
90
90
|
var rowTargetPosition = translateTargetPosition(y, actualTargetIndex, tableMap);
|
|
91
|
+
// Ignored via go/ees005
|
|
92
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
91
93
|
var node = table.node.nodeAt(rowTargetPosition);
|
|
92
94
|
var pos = table.start + rowTargetPosition;
|
|
93
95
|
var insertPos = direction === 'end' ? newTr.mapping.map(pos + node.nodeSize, 1) : newTr.mapping.map(pos, -1);
|
|
@@ -106,12 +108,17 @@ var cloneColumn = exports.cloneColumn = function cloneColumn(state, originColumn
|
|
|
106
108
|
return newTr;
|
|
107
109
|
};
|
|
108
110
|
};
|
|
111
|
+
|
|
112
|
+
// Ignored via go/ees005
|
|
113
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
109
114
|
function normalizeCellNode(cellNode, rowHeaderEnabled, columnHeaderEnabled, types) {
|
|
110
115
|
var newTargetType = rowHeaderEnabled || columnHeaderEnabled ? types.header_cell : types.cell;
|
|
111
116
|
return cellNode.type !== newTargetType ? newTargetType.create(cellNode.attrs, cellNode.content, cellNode.marks) : cellNode;
|
|
112
117
|
}
|
|
113
118
|
function createContentNodeFactory(table) {
|
|
114
119
|
return function (nodePos) {
|
|
120
|
+
// Ignored via go/ees005
|
|
121
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
115
122
|
var node = table.node.nodeAt(nodePos);
|
|
116
123
|
var pos = nodePos + table.start;
|
|
117
124
|
return {
|
|
@@ -116,6 +116,8 @@ var cloneRow = exports.cloneRow = function cloneRow(state, originRowIndex, targe
|
|
|
116
116
|
* This ensures the row node cell type correctly reflect what they should be.
|
|
117
117
|
* @returns A copy of the rowNode
|
|
118
118
|
*/
|
|
119
|
+
// Ignored via go/ees005
|
|
120
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
119
121
|
function normalizeRowNode(rowNode, rowHeaderEnabled, columnHeaderEnabled, types) {
|
|
120
122
|
var content = [];
|
|
121
123
|
rowNode.forEach(function (node, offset, index) {
|
|
@@ -122,6 +122,8 @@ function ensureRectangular(schema, rowsFragment) {
|
|
|
122
122
|
rows.push(_model.Fragment.empty);
|
|
123
123
|
}
|
|
124
124
|
if (widths[_r2] < width) {
|
|
125
|
+
// Ignored via go/ees005
|
|
126
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
125
127
|
var empty = (0, _tableNodeTypes.tableNodeTypes)(schema).cell.createAndFill();
|
|
126
128
|
var cells = [];
|
|
127
129
|
for (var _i = widths[_r2]; _i < width; _i++) {
|
|
@@ -206,6 +208,8 @@ function clipCells(_ref, newWidth, newHeight) {
|
|
|
206
208
|
|
|
207
209
|
// Make sure a table has at least the given width and height. Return
|
|
208
210
|
// true if something was changed.
|
|
211
|
+
// Ignored via go/ees005
|
|
212
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
209
213
|
function growTable(tr, map, table, start, width, height, mapFrom) {
|
|
210
214
|
var schema = tr.doc.type.schema;
|
|
211
215
|
var types = (0, _tableNodeTypes.tableNodeTypes)(schema);
|
|
@@ -218,8 +222,12 @@ function growTable(tr, map, table, start, width, height, mapFrom) {
|
|
|
218
222
|
var cells = [];
|
|
219
223
|
var add = void 0;
|
|
220
224
|
if (rowNode.lastChild == null || rowNode.lastChild.type === types.cell) {
|
|
225
|
+
// Ignored via go/ees005
|
|
226
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
221
227
|
add = empty || (empty = types.cell.createAndFill());
|
|
222
228
|
} else {
|
|
229
|
+
// Ignored via go/ees005
|
|
230
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
223
231
|
add = emptyHead || (emptyHead = types.header_cell.createAndFill());
|
|
224
232
|
}
|
|
225
233
|
for (var i = map.width; i < width; i++) {
|
|
@@ -242,7 +250,13 @@ function growTable(tr, map, table, start, width, height, mapFrom) {
|
|
|
242
250
|
}
|
|
243
251
|
header = node.type === types.header_cell;
|
|
244
252
|
}
|
|
245
|
-
_cells2.push(header ?
|
|
253
|
+
_cells2.push(header ?
|
|
254
|
+
// Ignored via go/ees005
|
|
255
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
256
|
+
emptyHead || (emptyHead = types.header_cell.createAndFill()) :
|
|
257
|
+
// Ignored via go/ees005
|
|
258
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
259
|
+
empty || (empty = types.cell.createAndFill()));
|
|
246
260
|
}
|
|
247
261
|
var emptyRow = types.row.create(null, _model.Fragment.from(_cells2));
|
|
248
262
|
var rows = [];
|
|
@@ -257,6 +271,8 @@ function growTable(tr, map, table, start, width, height, mapFrom) {
|
|
|
257
271
|
// Make sure the given line (left, top) to (right, top) doesn't cross
|
|
258
272
|
// any rowspan cells by splitting cells that cross it. Return true if
|
|
259
273
|
// something changed.
|
|
274
|
+
// Ignored via go/ees005
|
|
275
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
260
276
|
function isolateHorizontal(tr, map, table, start, left, right, top, mapFrom) {
|
|
261
277
|
if (top === 0 || top === map.height) {
|
|
262
278
|
return false;
|
|
@@ -293,6 +309,8 @@ function isolateHorizontal(tr, map, table, start, left, right, top, mapFrom) {
|
|
|
293
309
|
// Make sure the given line (left, top) to (left, bottom) doesn't
|
|
294
310
|
// cross any colspan cells by splitting cells that cross it. Return
|
|
295
311
|
// true if something changed.
|
|
312
|
+
// Ignored via go/ees005
|
|
313
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
296
314
|
function isolateVertical(tr, map, table, start, top, bottom, left, mapFrom) {
|
|
297
315
|
if (left === 0 || left === map.width) {
|
|
298
316
|
return false;
|
|
@@ -320,8 +338,14 @@ function isolateVertical(tr, map, table, start, top, bottom, left, mapFrom) {
|
|
|
320
338
|
}
|
|
321
339
|
return found;
|
|
322
340
|
}
|
|
341
|
+
|
|
342
|
+
// Ignored via go/ees005
|
|
343
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
323
344
|
function applyHeaderCells(tr, tableMap, state, tableStart, table, headerRowEnabled, headerColumnEnabled) {
|
|
324
345
|
var schema = state.schema;
|
|
346
|
+
|
|
347
|
+
// Ignored via go/ees005
|
|
348
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
325
349
|
var setMarkup = function setMarkup(tr, row, col, headerEnabled) {
|
|
326
350
|
var cellPos = tableStart + tableMap.positionAt(row, col, table);
|
|
327
351
|
var cell = tr.doc.nodeAt(cellPos);
|
|
@@ -348,6 +372,8 @@ function applyHeaderCells(tr, tableMap, state, tableStart, table, headerRowEnabl
|
|
|
348
372
|
|
|
349
373
|
// Insert the given set of cells (as returned by `pastedCells`) into a
|
|
350
374
|
// table, at the position pointed at by rect.
|
|
375
|
+
// Ignored via go/ees005
|
|
376
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
351
377
|
function insertCells(state, dispatch, tableStart, rect, cells) {
|
|
352
378
|
var table = state.doc;
|
|
353
379
|
var newRect = (0, _selectionRect.selectedRect)(state);
|
|
@@ -370,6 +396,8 @@ function insertCells(state, dispatch, tableStart, rect, cells) {
|
|
|
370
396
|
var tr = state.tr;
|
|
371
397
|
var mapFrom = 0;
|
|
372
398
|
function recomp() {
|
|
399
|
+
// Ignored via go/ees005
|
|
400
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
373
401
|
table = tableStart ? tr.doc.nodeAt(tableStart - 1) : tr.doc;
|
|
374
402
|
map = _tableMap.TableMap.get(table);
|
|
375
403
|
mapFrom = tr.mapping.maps.length;
|
package/dist/cjs/utils/find.js
CHANGED
|
@@ -24,7 +24,11 @@ var findTableClosestToPos = exports.findTableClosestToPos = function findTableCl
|
|
|
24
24
|
// Iterates over parent nodes, returning a table cell or a table header node closest to a given `$pos`.
|
|
25
25
|
var findCellClosestToPos = exports.findCellClosestToPos = function findCellClosestToPos($pos) {
|
|
26
26
|
var predicate = function predicate(node) {
|
|
27
|
-
return
|
|
27
|
+
return (
|
|
28
|
+
// Ignored via go/ees005
|
|
29
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
30
|
+
node.type.spec.tableRole && /cell/i.test(node.type.spec.tableRole)
|
|
31
|
+
);
|
|
28
32
|
};
|
|
29
33
|
return (0, _utils.findParentNodeClosestToPos)($pos, predicate);
|
|
30
34
|
};
|
|
@@ -16,17 +16,20 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
16
16
|
// Helper for iterating through the nodes in a document that changed
|
|
17
17
|
// compared to the given previous document. Useful for avoiding
|
|
18
18
|
// duplicate work on each transaction.
|
|
19
|
+
// Ignored via go/ees005
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
19
21
|
function changedDescendants(old, cur, offsetStart, f) {
|
|
20
22
|
var offset = offsetStart;
|
|
21
23
|
var oldSize = old.childCount;
|
|
22
24
|
var curSize = cur.childCount;
|
|
25
|
+
// eslint-disable-next-line no-labels
|
|
23
26
|
outer: for (var i = 0, j = 0; i < curSize; i++) {
|
|
24
27
|
var child = cur.child(i);
|
|
25
28
|
for (var scan = j, e = Math.min(oldSize, i + 3); scan < e; scan++) {
|
|
26
29
|
if (old.child(scan) === child) {
|
|
27
30
|
j = scan + 1;
|
|
28
31
|
offset += child.nodeSize;
|
|
29
|
-
// eslint-disable-next-line no-continue
|
|
32
|
+
// eslint-disable-next-line no-continue, no-labels
|
|
30
33
|
continue outer;
|
|
31
34
|
}
|
|
32
35
|
}
|
|
@@ -64,6 +67,8 @@ function fixTables(state, oldState, reportFixedTable) {
|
|
|
64
67
|
// : (EditorState, Node, number, ?Transaction) → ?Transaction
|
|
65
68
|
// Fix the given table, if necessary. Will append to the transaction
|
|
66
69
|
// it was given, if non-null, or create a new one if necessary.
|
|
70
|
+
// Ignored via go/ees005
|
|
71
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
67
72
|
function fixTable(state, table, tablePos, transaction, reportFixedTable) {
|
|
68
73
|
var tr = transaction;
|
|
69
74
|
var map = _tableMap.TableMap.get(table);
|
|
@@ -146,6 +151,8 @@ function fixTable(state, table, tablePos, transaction, reportFixedTable) {
|
|
|
146
151
|
}
|
|
147
152
|
var nodes = [];
|
|
148
153
|
for (var _j = 0; _j < add; _j++) {
|
|
154
|
+
// Ignored via go/ees005
|
|
155
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
149
156
|
nodes.push((0, _tableNodeTypes.tableNodeTypes)(state.schema)[tableNodeType].createAndFill());
|
|
150
157
|
}
|
|
151
158
|
var side = (_i3 === 0 || first === _i3 - 1) && last === _i3 ? pos + 1 : end - 1;
|
|
@@ -25,6 +25,8 @@ var getCellsInColumn = exports.getCellsInColumn = function getCellsInColumn(colu
|
|
|
25
25
|
bottom: map.height
|
|
26
26
|
});
|
|
27
27
|
return acc.concat(cells.map(function (nodePos) {
|
|
28
|
+
// Ignored via go/ees005
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
28
30
|
var node = table.node.nodeAt(nodePos);
|
|
29
31
|
var pos = nodePos + table.start;
|
|
30
32
|
return {
|
|
@@ -25,6 +25,8 @@ var getCellsInRow = exports.getCellsInRow = function getCellsInRow(rowIndex) {
|
|
|
25
25
|
bottom: index + 1
|
|
26
26
|
});
|
|
27
27
|
return acc.concat(cells.map(function (nodePos) {
|
|
28
|
+
// Ignored via go/ees005
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
28
30
|
var node = table.node.nodeAt(nodePos);
|
|
29
31
|
var pos = nodePos + table.start;
|
|
30
32
|
return {
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.moveColumn = void 0;
|
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
9
10
|
var _cellSelection = require("../cell-selection");
|
|
10
11
|
var _tableMap = require("../table-map");
|
|
11
12
|
var _analyseTable = require("./analyse-table");
|
|
@@ -215,9 +216,11 @@ var moveColumn = exports.moveColumn = function moveColumn(state, originColumnInd
|
|
|
215
216
|
// The actual target index needs to be translated per row, this is because row/col spans can affect the amount of
|
|
216
217
|
// cells each row contains.
|
|
217
218
|
var rowTargetPosition = translateTargetPosition(y, actualTargetIndex, tableMap);
|
|
219
|
+
// Ignored via go/ees005
|
|
220
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
218
221
|
var node = table.node.nodeAt(rowTargetPosition);
|
|
219
222
|
var pos = table.start + rowTargetPosition;
|
|
220
|
-
var insertPos = direction === 'end' ? newTr.mapping.map(pos + node.nodeSize, 1) : newTr.mapping.map(pos, -1);
|
|
223
|
+
var insertPos = direction === 'end' || tableMap.isCellMergedTopLeft(y, actualTargetIndex) && (0, _platformFeatureFlags.fg)('platform_editor_table_fix_move_column') ? newTr.mapping.map(pos + node.nodeSize, 1) : newTr.mapping.map(pos, -1);
|
|
221
224
|
newTr.insert(insertPos, row.map(function (_ref, x) {
|
|
222
225
|
var node = _ref.node;
|
|
223
226
|
return normalizeCellNode(node, rowHeaderEnabled && y === 0, columnHeaderEnabled && actualTargetIndex === 0 && x === 0, types);
|
|
@@ -239,12 +242,17 @@ var moveColumn = exports.moveColumn = function moveColumn(state, originColumnInd
|
|
|
239
242
|
return newTr;
|
|
240
243
|
};
|
|
241
244
|
};
|
|
245
|
+
|
|
246
|
+
// Ignored via go/ees005
|
|
247
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
242
248
|
function normalizeCellNode(cellNode, rowHeaderEnabled, columnHeaderEnabled, types) {
|
|
243
249
|
var newTargetType = rowHeaderEnabled || columnHeaderEnabled ? types.header_cell : types.cell;
|
|
244
250
|
return cellNode.type !== newTargetType ? newTargetType.create(cellNode.attrs, cellNode.content, cellNode.marks) : cellNode;
|
|
245
251
|
}
|
|
246
252
|
function createContentNodeFactory(table) {
|
|
247
253
|
return function (nodePos) {
|
|
254
|
+
// Ignored via go/ees005
|
|
255
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
248
256
|
var node = table.node.nodeAt(nodePos);
|
|
249
257
|
var pos = nodePos + table.start;
|
|
250
258
|
return {
|
|
@@ -268,6 +268,8 @@ var moveRow = exports.moveRow = function moveRow(state, originRowIndex, targetRo
|
|
|
268
268
|
* This ensures the row node cell type correctly reflect what they should be.
|
|
269
269
|
* @returns A copy of the rowNode
|
|
270
270
|
*/
|
|
271
|
+
// Ignored via go/ees005
|
|
272
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
271
273
|
function normalizeRowNode(rowNode, rowHeaderEnabled, columnHeaderEnabled, types) {
|
|
272
274
|
var content = [];
|
|
273
275
|
rowNode.forEach(function (node, offset, index) {
|
|
@@ -58,6 +58,8 @@ function isCellBoundarySelection(_ref2) {
|
|
|
58
58
|
break;
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
+
// Ignored via go/ees005
|
|
62
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
61
63
|
return afterFrom === beforeTo && /row|table/.test($from.node(depth).type.spec.tableRole);
|
|
62
64
|
}
|
|
63
65
|
function isTextSelectionAcrossCells(_ref3) {
|