@atlaskit/editor-tables 2.8.2 → 2.8.4
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 +15 -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 +15 -8
- 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 +4 -0
- package/dist/cjs/utils/copy-paste.js +15 -1
- package/dist/cjs/utils/find.js +5 -1
- package/dist/cjs/utils/fix-tables.js +4 -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 +6 -1
- package/dist/cjs/utils/normalize-selection.js +2 -0
- package/dist/cjs/utils/reorder-utils.js +4 -0
- 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 +49 -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 +4 -0
- package/dist/es2019/utils/clone-row.js +1 -1
- package/dist/es2019/utils/copy-paste.js +15 -1
- package/dist/es2019/utils/find.js +4 -1
- package/dist/es2019/utils/fix-tables.js +4 -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 +6 -1
- package/dist/es2019/utils/move-row.js +1 -1
- 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 +5 -1
- 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 +15 -8
- 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 +4 -0
- package/dist/esm/utils/copy-paste.js +15 -1
- package/dist/esm/utils/find.js +5 -1
- package/dist/esm/utils/fix-tables.js +4 -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 +6 -1
- package/dist/esm/utils/normalize-selection.js +2 -0
- package/dist/esm/utils/reorder-utils.js +4 -0
- 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,20 @@
|
|
|
1
1
|
# @atlaskit/editor-tables
|
|
2
2
|
|
|
3
|
+
## 2.8.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 2.8.3
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#101371](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/101371)
|
|
14
|
+
[`3cce4a292ef1e`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/3cce4a292ef1e) -
|
|
15
|
+
Add fix for move column logic when moving a column before a column with merged rows behind FG
|
|
16
|
+
platform_editor_table_fix_move_column
|
|
17
|
+
|
|
3
18
|
## 2.8.2
|
|
4
19
|
|
|
5
20
|
### 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;
|
|
@@ -95,7 +100,7 @@ var TableMap = exports.TableMap = /*#__PURE__*/function () {
|
|
|
95
100
|
|
|
96
101
|
// :: (number) → Rect
|
|
97
102
|
// Find the dimensions of the cell at the given position.
|
|
98
|
-
(0, _createClass2.default)(TableMap, [{
|
|
103
|
+
return (0, _createClass2.default)(TableMap, [{
|
|
99
104
|
key: "findCell",
|
|
100
105
|
value: function findCell(pos) {
|
|
101
106
|
for (var i = 0; i < this.map.length; i++) {
|
|
@@ -286,7 +291,6 @@ var TableMap = exports.TableMap = /*#__PURE__*/function () {
|
|
|
286
291
|
return readFromCache(table) || addToCache(table, computeMap(table));
|
|
287
292
|
}
|
|
288
293
|
}]);
|
|
289
|
-
return TableMap;
|
|
290
294
|
}(); // Compute a table map.
|
|
291
295
|
function computeMap(table) {
|
|
292
296
|
if (table.type.spec.tableRole !== 'table') {
|
|
@@ -294,10 +298,10 @@ function computeMap(table) {
|
|
|
294
298
|
}
|
|
295
299
|
var width = findWidth(table);
|
|
296
300
|
var height = table.childCount;
|
|
297
|
-
var map = []
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
+
var map = [];
|
|
302
|
+
var colWidths = [];
|
|
303
|
+
var mapPos = 0,
|
|
304
|
+
problems = null;
|
|
301
305
|
for (var i = 0, e = width * height; i < e; i++) {
|
|
302
306
|
map[i] = 0;
|
|
303
307
|
}
|
|
@@ -451,8 +455,8 @@ function findBadColWidths(map, colWidths, table) {
|
|
|
451
455
|
continue;
|
|
452
456
|
}
|
|
453
457
|
seen[pos] = true;
|
|
454
|
-
var node = table.nodeAt(pos)
|
|
455
|
-
|
|
458
|
+
var node = table.nodeAt(pos);
|
|
459
|
+
var updated = null;
|
|
456
460
|
for (var j = 0; j < node.attrs.colspan; j++) {
|
|
457
461
|
var col = (i + j) % map.width,
|
|
458
462
|
colWidth = colWidths[col * 2];
|
|
@@ -469,6 +473,9 @@ function findBadColWidths(map, colWidths, table) {
|
|
|
469
473
|
}
|
|
470
474
|
}
|
|
471
475
|
}
|
|
476
|
+
|
|
477
|
+
// Ignored via go/ees005
|
|
478
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
472
479
|
function freshColWidth(attrs) {
|
|
473
480
|
if (attrs.colwidth) {
|
|
474
481
|
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);
|
|
@@ -112,6 +114,8 @@ function normalizeCellNode(cellNode, rowHeaderEnabled, columnHeaderEnabled, type
|
|
|
112
114
|
}
|
|
113
115
|
function createContentNodeFactory(table) {
|
|
114
116
|
return function (nodePos) {
|
|
117
|
+
// Ignored via go/ees005
|
|
118
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
115
119
|
var node = table.node.nodeAt(nodePos);
|
|
116
120
|
var pos = nodePos + table.start;
|
|
117
121
|
return {
|
|
@@ -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++) {
|
|
@@ -218,8 +220,12 @@ function growTable(tr, map, table, start, width, height, mapFrom) {
|
|
|
218
220
|
var cells = [];
|
|
219
221
|
var add = void 0;
|
|
220
222
|
if (rowNode.lastChild == null || rowNode.lastChild.type === types.cell) {
|
|
223
|
+
// Ignored via go/ees005
|
|
224
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
221
225
|
add = empty || (empty = types.cell.createAndFill());
|
|
222
226
|
} else {
|
|
227
|
+
// Ignored via go/ees005
|
|
228
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
223
229
|
add = emptyHead || (emptyHead = types.header_cell.createAndFill());
|
|
224
230
|
}
|
|
225
231
|
for (var i = map.width; i < width; i++) {
|
|
@@ -242,7 +248,13 @@ function growTable(tr, map, table, start, width, height, mapFrom) {
|
|
|
242
248
|
}
|
|
243
249
|
header = node.type === types.header_cell;
|
|
244
250
|
}
|
|
245
|
-
_cells2.push(header ?
|
|
251
|
+
_cells2.push(header ?
|
|
252
|
+
// Ignored via go/ees005
|
|
253
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
254
|
+
emptyHead || (emptyHead = types.header_cell.createAndFill()) :
|
|
255
|
+
// Ignored via go/ees005
|
|
256
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
257
|
+
empty || (empty = types.cell.createAndFill()));
|
|
246
258
|
}
|
|
247
259
|
var emptyRow = types.row.create(null, _model.Fragment.from(_cells2));
|
|
248
260
|
var rows = [];
|
|
@@ -370,6 +382,8 @@ function insertCells(state, dispatch, tableStart, rect, cells) {
|
|
|
370
382
|
var tr = state.tr;
|
|
371
383
|
var mapFrom = 0;
|
|
372
384
|
function recomp() {
|
|
385
|
+
// Ignored via go/ees005
|
|
386
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
373
387
|
table = tableStart ? tr.doc.nodeAt(tableStart - 1) : tr.doc;
|
|
374
388
|
map = _tableMap.TableMap.get(table);
|
|
375
389
|
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
|
};
|
|
@@ -20,13 +20,14 @@ function changedDescendants(old, cur, offsetStart, f) {
|
|
|
20
20
|
var offset = offsetStart;
|
|
21
21
|
var oldSize = old.childCount;
|
|
22
22
|
var curSize = cur.childCount;
|
|
23
|
+
// eslint-disable-next-line no-labels
|
|
23
24
|
outer: for (var i = 0, j = 0; i < curSize; i++) {
|
|
24
25
|
var child = cur.child(i);
|
|
25
26
|
for (var scan = j, e = Math.min(oldSize, i + 3); scan < e; scan++) {
|
|
26
27
|
if (old.child(scan) === child) {
|
|
27
28
|
j = scan + 1;
|
|
28
29
|
offset += child.nodeSize;
|
|
29
|
-
// eslint-disable-next-line no-continue
|
|
30
|
+
// eslint-disable-next-line no-continue, no-labels
|
|
30
31
|
continue outer;
|
|
31
32
|
}
|
|
32
33
|
}
|
|
@@ -146,6 +147,8 @@ function fixTable(state, table, tablePos, transaction, reportFixedTable) {
|
|
|
146
147
|
}
|
|
147
148
|
var nodes = [];
|
|
148
149
|
for (var _j = 0; _j < add; _j++) {
|
|
150
|
+
// Ignored via go/ees005
|
|
151
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
149
152
|
nodes.push((0, _tableNodeTypes.tableNodeTypes)(state.schema)[tableNodeType].createAndFill());
|
|
150
153
|
}
|
|
151
154
|
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);
|
|
@@ -245,6 +248,8 @@ function normalizeCellNode(cellNode, rowHeaderEnabled, columnHeaderEnabled, type
|
|
|
245
248
|
}
|
|
246
249
|
function createContentNodeFactory(table) {
|
|
247
250
|
return function (nodePos) {
|
|
251
|
+
// Ignored via go/ees005
|
|
252
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
248
253
|
var node = table.node.nodeAt(nodePos);
|
|
249
254
|
var pos = nodePos + table.start;
|
|
250
255
|
return {
|
|
@@ -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) {
|
|
@@ -33,7 +33,11 @@ var _tableMap = require("../table-map");
|
|
|
33
33
|
// ['a3', 'b3', 'c3', 'd3'],
|
|
34
34
|
// ]
|
|
35
35
|
// ```
|
|
36
|
+
// Ignored via go/ees005
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
36
38
|
var transpose = exports.transpose = function transpose(array) {
|
|
39
|
+
// Ignored via go/ees005
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
37
41
|
return array[0].map(function (_, i) {
|
|
38
42
|
return array.map(function (column) {
|
|
39
43
|
return column[i];
|
|
@@ -47,9 +47,9 @@ function splitCellWithType(getCellType) {
|
|
|
47
47
|
return false;
|
|
48
48
|
}
|
|
49
49
|
if (cellNode && dispatch) {
|
|
50
|
-
var cellAttrs = cellNode.attrs
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
var cellAttrs = cellNode.attrs;
|
|
51
|
+
var attrs = [];
|
|
52
|
+
var colwidth = cellAttrs.colwidth;
|
|
53
53
|
if (cellAttrs.rowspan && cellAttrs.rowspan > 1) {
|
|
54
54
|
cellAttrs = _objectSpread(_objectSpread({}, cellAttrs), {}, {
|
|
55
55
|
rowspan: 1
|
package/dist/cjs/utils/uuid.js
CHANGED
|
@@ -11,10 +11,14 @@ exports.uuid = exports.generateUuid = void 0;
|
|
|
11
11
|
|
|
12
12
|
/* eslint-disable no-bitwise */
|
|
13
13
|
var generateUuid = exports.generateUuid = function generateUuid() {
|
|
14
|
-
return
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
return (
|
|
15
|
+
// Ignored via go/ees005
|
|
16
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
17
|
+
'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
18
|
+
var r = Math.random() * 16 | 0;
|
|
19
|
+
return (c === 'x' ? r : r & 0x3 | 0x8).toString(16);
|
|
20
|
+
})
|
|
21
|
+
);
|
|
18
22
|
};
|
|
19
23
|
/* eslint-enable no-bitwise */
|
|
20
24
|
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/* eslint-disable @atlaskit/editor/no-re-export */
|
|
2
|
+
// Entry file in package.json
|
|
3
|
+
|
|
1
4
|
// Was copied from https://github.com/ProseMirror/prosemirror-tables/blob/master/src/cellselection.js
|
|
2
5
|
|
|
3
6
|
// This file defines a ProseMirror selection subclass that models
|
|
@@ -89,6 +92,8 @@ export class CellSelection extends Selection {
|
|
|
89
92
|
attrs = removeColSpan(attrs, 0, extraLeft);
|
|
90
93
|
}
|
|
91
94
|
if (extraRight > 0) {
|
|
95
|
+
// Ignored via go/ees005
|
|
96
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
92
97
|
attrs = removeColSpan(attrs, attrs.colspan - extraRight, extraRight);
|
|
93
98
|
}
|
|
94
99
|
if (cellRect.left < rect.left) {
|
|
@@ -169,7 +174,11 @@ export class CellSelection extends Selection {
|
|
|
169
174
|
if (Math.min(anchorTop, headTop) > 0) {
|
|
170
175
|
return false;
|
|
171
176
|
}
|
|
177
|
+
// Ignored via go/ees005
|
|
178
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
172
179
|
const anchorBot = anchorTop + this.$anchorCell.nodeAfter.attrs.rowspan;
|
|
180
|
+
// Ignored via go/ees005
|
|
181
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
173
182
|
const headBot = headTop + this.$headCell.nodeAfter.attrs.rowspan;
|
|
174
183
|
return Math.max(anchorBot, headBot) === this.$headCell.node(-1).childCount;
|
|
175
184
|
}
|
|
@@ -218,7 +227,7 @@ export class CellSelection extends Selection {
|
|
|
218
227
|
|
|
219
228
|
// if anchor and head in the same line, counting how many cells
|
|
220
229
|
// should be in the row except merged cell
|
|
221
|
-
|
|
230
|
+
const maxColumnInSelectedRow = map.getMaxColInRow(this.$anchorCell);
|
|
222
231
|
|
|
223
232
|
// if selected cells less than table max column amount, and
|
|
224
233
|
// the anchor/head not in a merged cell
|
|
@@ -234,7 +243,11 @@ export class CellSelection extends Selection {
|
|
|
234
243
|
if (Math.min(anchorLeft, headLeft) > 0) {
|
|
235
244
|
return false;
|
|
236
245
|
}
|
|
246
|
+
// Ignored via go/ees005
|
|
247
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
237
248
|
const anchorRight = anchorLeft + this.$anchorCell.nodeAfter.attrs.colspan;
|
|
249
|
+
// Ignored via go/ees005
|
|
250
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
238
251
|
const headRight = headLeft + this.$headCell.nodeAfter.attrs.colspan;
|
|
239
252
|
return Math.max(anchorRight, headRight) === map.width;
|
|
240
253
|
}
|