@atlaskit/editor-plugin-table 5.8.2 → 5.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 +13 -0
- package/dist/cjs/nodeviews/TableComponent.js +17 -62
- package/dist/cjs/pm-plugins/drag-and-drop/plugin.js +153 -123
- package/dist/cjs/pm-plugins/drag-and-drop/utils/autoscrollers.js +53 -0
- package/dist/cjs/pm-plugins/drag-and-drop/utils/index.js +8 -1
- package/dist/cjs/ui/DragHandle/index.js +8 -3
- package/dist/cjs/ui/FloatingContextualMenu/ContextualMenu.js +2 -2
- package/dist/cjs/ui/FloatingDragMenu/DragMenu.js +103 -12
- package/dist/cjs/ui/FloatingDragMenu/index.js +2 -2
- package/dist/es2019/nodeviews/TableComponent.js +5 -55
- package/dist/es2019/pm-plugins/drag-and-drop/plugin.js +158 -124
- package/dist/es2019/pm-plugins/drag-and-drop/utils/autoscrollers.js +50 -0
- package/dist/es2019/pm-plugins/drag-and-drop/utils/index.js +2 -1
- package/dist/es2019/ui/DragHandle/index.js +10 -3
- package/dist/es2019/ui/FloatingContextualMenu/ContextualMenu.js +2 -2
- package/dist/es2019/ui/FloatingDragMenu/DragMenu.js +106 -11
- package/dist/es2019/ui/FloatingDragMenu/index.js +1 -1
- package/dist/esm/nodeviews/TableComponent.js +7 -52
- package/dist/esm/pm-plugins/drag-and-drop/plugin.js +152 -122
- package/dist/esm/pm-plugins/drag-and-drop/utils/autoscrollers.js +47 -0
- package/dist/esm/pm-plugins/drag-and-drop/utils/index.js +2 -1
- package/dist/esm/ui/DragHandle/index.js +8 -3
- package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +2 -2
- package/dist/esm/ui/FloatingDragMenu/DragMenu.js +102 -11
- package/dist/esm/ui/FloatingDragMenu/index.js +1 -1
- package/dist/types/pm-plugins/drag-and-drop/utils/autoscrollers.d.ts +7 -0
- package/dist/types/pm-plugins/drag-and-drop/utils/index.d.ts +1 -0
- package/dist/types/ui/DragHandle/index.d.ts +5 -1
- package/dist/types/ui/FloatingDragMenu/DragMenu.d.ts +7 -2
- package/dist/types/utils/drag-menu.d.ts +2 -1
- package/dist/types-ts4.5/pm-plugins/drag-and-drop/utils/autoscrollers.d.ts +7 -0
- package/dist/types-ts4.5/pm-plugins/drag-and-drop/utils/index.d.ts +1 -0
- package/dist/types-ts4.5/ui/DragHandle/index.d.ts +5 -1
- package/dist/types-ts4.5/ui/FloatingDragMenu/DragMenu.d.ts +7 -2
- package/dist/types-ts4.5/utils/drag-menu.d.ts +2 -1
- package/package.json +2 -2
- package/src/__tests__/unit/ui/FloatingDragMenu.tsx +129 -105
- package/src/nodeviews/TableComponent.tsx +5 -49
- package/src/pm-plugins/drag-and-drop/plugin.ts +202 -157
- package/src/pm-plugins/drag-and-drop/utils/autoscrollers.ts +52 -0
- package/src/pm-plugins/drag-and-drop/utils/index.ts +2 -0
- package/src/ui/DragHandle/index.tsx +13 -2
- package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +2 -2
- package/src/ui/FloatingDragMenu/DragMenu.tsx +137 -12
- package/src/ui/FloatingDragMenu/index.tsx +1 -1
- package/src/utils/drag-menu.ts +17 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 5.8.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#67113](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/67113) [`7160ae19d9e5`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/7160ae19d9e5) - [ux] Adds localisation for table drag handle menu options
|
|
8
|
+
- [#66456](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/66456) [`f67ea3106bb9`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/f67ea3106bb9) - Add support for i18n for drag handles
|
|
9
|
+
|
|
10
|
+
## 5.8.3
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- [#66462](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/66462) [`241abc835673`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/241abc835673) - Add autoscroll to editor page to fix table drag and drop
|
|
15
|
+
|
|
3
16
|
## 5.8.2
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
8
9
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
10
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
11
|
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
@@ -23,21 +24,20 @@ var _utils = require("@atlaskit/editor-common/utils");
|
|
|
23
24
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
24
25
|
var _utils2 = require("@atlaskit/editor-tables/utils");
|
|
25
26
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
26
|
-
var _element = require("@atlaskit/pragmatic-drag-and-drop-auto-scroll/element");
|
|
27
|
-
var _element2 = require("@atlaskit/pragmatic-drag-and-drop-auto-scroll/unsafe-overflow/element");
|
|
28
27
|
var _combine = require("@atlaskit/pragmatic-drag-and-drop/util/combine");
|
|
29
28
|
var _commands = require("../commands");
|
|
29
|
+
var _utils3 = require("../pm-plugins/drag-and-drop/utils");
|
|
30
30
|
var _pluginFactory = require("../pm-plugins/plugin-factory");
|
|
31
31
|
var _stickyHeaders = require("../pm-plugins/sticky-headers");
|
|
32
32
|
var _tableAnalytics = require("../pm-plugins/table-analytics");
|
|
33
|
-
var
|
|
33
|
+
var _utils4 = require("../pm-plugins/table-resizing/utils");
|
|
34
34
|
var _colgroup = require("../pm-plugins/table-resizing/utils/colgroup");
|
|
35
35
|
var _dom = require("../pm-plugins/table-resizing/utils/dom");
|
|
36
36
|
var _types = require("../types");
|
|
37
37
|
var _consts = require("../ui/consts");
|
|
38
38
|
var _TableFloatingColumnControls = _interopRequireDefault(require("../ui/TableFloatingColumnControls"));
|
|
39
39
|
var _TableFloatingControls = _interopRequireDefault(require("../ui/TableFloatingControls"));
|
|
40
|
-
var
|
|
40
|
+
var _utils5 = require("../utils");
|
|
41
41
|
var _ExternalDropTargets = require("./ExternalDropTargets");
|
|
42
42
|
var _OverflowShadowsObserver = require("./OverflowShadowsObserver");
|
|
43
43
|
var _TableContainer = require("./TableContainer");
|
|
@@ -125,14 +125,14 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
125
125
|
var prevNode = _this.node;
|
|
126
126
|
var node = getNode();
|
|
127
127
|
var prevAttrs = prevNode.attrs;
|
|
128
|
-
var isNested = (0,
|
|
128
|
+
var isNested = (0, _utils5.isTableNested)(_this.props.view.state, _this.props.getPos());
|
|
129
129
|
// We only consider a layout change valid if it's done outside of an autoSize.
|
|
130
130
|
var layoutChanged = prevAttrs.layout !== node.attrs.layout && prevAttrs.__autoSize === node.attrs.__autoSize;
|
|
131
131
|
var parentWidth = _this.getParentNodeWidth();
|
|
132
132
|
var parentWidthChanged = parentWidth && parentWidth !== _this.state.parentWidth;
|
|
133
133
|
var layoutSize = _this.tableNodeLayoutSize(node, containerWidth.width, options);
|
|
134
134
|
var hasNumberedColumnChanged = prevAttrs.isNumberColumnEnabled !== node.attrs.isNumberColumnEnabled;
|
|
135
|
-
var noOfColumnsChanged = (0,
|
|
135
|
+
var noOfColumnsChanged = (0, _utils5.tablesHaveDifferentNoOfColumns)(node, prevNode);
|
|
136
136
|
if (
|
|
137
137
|
// Breakout mode/layout changed
|
|
138
138
|
layoutChanged ||
|
|
@@ -186,7 +186,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
186
186
|
var domAtPos = view.domAtPos.bind(view);
|
|
187
187
|
var width = containerWidth.width;
|
|
188
188
|
_this.scaleTableDebounced.cancel();
|
|
189
|
-
var tr = (0,
|
|
189
|
+
var tr = (0, _utils4.scaleTable)(_this.table, _objectSpread(_objectSpread({}, scaleOptions), {}, {
|
|
190
190
|
node: node,
|
|
191
191
|
prevNode: _this.node || node,
|
|
192
192
|
start: pos + 1,
|
|
@@ -274,7 +274,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
274
274
|
});
|
|
275
275
|
});
|
|
276
276
|
(0, _defineProperty3.default)((0, _assertThisInitialized2.default)(_this), "tableNodeLayoutSize", function (node, containerWidth, options) {
|
|
277
|
-
return (0,
|
|
277
|
+
return (0, _utils4.getLayoutSize)(node.attrs.layout, containerWidth || _this.props.containerWidth.width, options || _this.props.options || {});
|
|
278
278
|
});
|
|
279
279
|
(0, _defineProperty3.default)((0, _assertThisInitialized2.default)(_this), "scaleTableDebounced", (0, _rafSchd.default)(_this.scaleTable));
|
|
280
280
|
(0, _defineProperty3.default)((0, _assertThisInitialized2.default)(_this), "handleTableResizingDebounced", (0, _rafSchd.default)(_this.handleTableResizing));
|
|
@@ -327,55 +327,10 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
327
327
|
}
|
|
328
328
|
}
|
|
329
329
|
if (isDragAndDropEnabled) {
|
|
330
|
-
this.dragAndDropCleanupFn = (0,
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
var _ref2 = source.data,
|
|
335
|
-
localId = _ref2.localId,
|
|
336
|
-
type = _ref2.type;
|
|
337
|
-
var node = getNode();
|
|
338
|
-
return localId === (node === null || node === void 0 ? void 0 : node.attrs.localId) && type === 'table-column';
|
|
339
|
-
}
|
|
340
|
-
}), (0, _element.autoScrollWindowForElements)({
|
|
341
|
-
canScroll: function canScroll(_ref3) {
|
|
342
|
-
var source = _ref3.source;
|
|
343
|
-
var _ref4 = source.data,
|
|
344
|
-
localId = _ref4.localId,
|
|
345
|
-
type = _ref4.type;
|
|
346
|
-
var node = getNode();
|
|
347
|
-
return localId === (node === null || node === void 0 ? void 0 : node.attrs.localId) && type === 'table-row';
|
|
348
|
-
}
|
|
349
|
-
}), (0, _element2.unsafeOverflowAutoScrollForElements)({
|
|
350
|
-
element: this.wrapper,
|
|
351
|
-
canScroll: function canScroll(_ref5) {
|
|
352
|
-
var source = _ref5.source;
|
|
353
|
-
var _ref6 = source.data,
|
|
354
|
-
localId = _ref6.localId,
|
|
355
|
-
type = _ref6.type;
|
|
356
|
-
var node = getNode();
|
|
357
|
-
return localId === (node === null || node === void 0 ? void 0 : node.attrs.localId) && type === 'table-column';
|
|
358
|
-
},
|
|
359
|
-
getOverflow: function getOverflow() {
|
|
360
|
-
return {
|
|
361
|
-
fromTopEdge: {
|
|
362
|
-
top: _consts.dropTargetExtendedWidth,
|
|
363
|
-
right: _consts.dropTargetExtendedWidth,
|
|
364
|
-
left: _consts.dropTargetExtendedWidth
|
|
365
|
-
},
|
|
366
|
-
fromRightEdge: {
|
|
367
|
-
right: _consts.dropTargetExtendedWidth,
|
|
368
|
-
top: _consts.dropTargetExtendedWidth,
|
|
369
|
-
bottom: _consts.dropTargetExtendedWidth
|
|
370
|
-
},
|
|
371
|
-
fromLeftEdge: {
|
|
372
|
-
top: _consts.dropTargetExtendedWidth,
|
|
373
|
-
left: _consts.dropTargetExtendedWidth,
|
|
374
|
-
bottom: _consts.dropTargetExtendedWidth
|
|
375
|
-
}
|
|
376
|
-
};
|
|
377
|
-
}
|
|
378
|
-
}));
|
|
330
|
+
this.dragAndDropCleanupFn = _combine.combine.apply(void 0, (0, _toConsumableArray2.default)((0, _utils3.autoScrollerFactory)({
|
|
331
|
+
tableWrapper: this.wrapper,
|
|
332
|
+
getNode: getNode
|
|
333
|
+
})));
|
|
379
334
|
}
|
|
380
335
|
}
|
|
381
336
|
if (allowColumnResizing) {
|
|
@@ -471,11 +426,11 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
471
426
|
// If col widths (e.g. via collab) or number of columns (e.g. delete a column) have changed,
|
|
472
427
|
// re-draw colgroup.
|
|
473
428
|
var previousTable = this.node;
|
|
474
|
-
if ((0,
|
|
429
|
+
if ((0, _utils5.tablesHaveDifferentColumnWidths)(currentTable, previousTable) || (0, _utils5.tablesHaveDifferentNoOfColumns)(currentTable, previousTable)) {
|
|
475
430
|
var _view = this.props.view;
|
|
476
|
-
var shouldRecreateResizeCols = !(options !== null && options !== void 0 && options.isTableResizingEnabled) || !isResizing || (0,
|
|
431
|
+
var shouldRecreateResizeCols = !(options !== null && options !== void 0 && options.isTableResizingEnabled) || !isResizing || (0, _utils5.tablesHaveDifferentNoOfColumns)(currentTable, previousTable) && isResizing;
|
|
477
432
|
if (shouldRecreateResizeCols) {
|
|
478
|
-
(0,
|
|
433
|
+
(0, _utils4.insertColgroupFromNode)(this.table, currentTable);
|
|
479
434
|
}
|
|
480
435
|
(0, _dom.updateControls)()(_view.state);
|
|
481
436
|
}
|
|
@@ -537,7 +492,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
537
492
|
isTableHovered = _getPluginState2.isTableHovered;
|
|
538
493
|
var tableRef = this.table || undefined;
|
|
539
494
|
var headerRow = tableRef ? tableRef.querySelector('tr[data-header-row]') : undefined;
|
|
540
|
-
var hasHeaderRow = (0,
|
|
495
|
+
var hasHeaderRow = (0, _utils5.containsHeaderRow)(node);
|
|
541
496
|
var rowControls = /*#__PURE__*/_react.default.createElement(_TableFloatingControls.default, {
|
|
542
497
|
editorView: view,
|
|
543
498
|
tableRef: tableRef,
|
|
@@ -602,7 +557,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
602
557
|
} catch (e) {
|
|
603
558
|
tablePos = undefined;
|
|
604
559
|
}
|
|
605
|
-
var isNested = (0,
|
|
560
|
+
var isNested = (0, _utils5.isTableNested)(view.state, tablePos);
|
|
606
561
|
var topStickyShadowPosition = isDragAndDropEnabled ? this.state.stickyHeader && this.state.stickyHeader.top + this.state.stickyHeader.padding + 2 : this.state.stickyHeader && this.state.stickyHeader.top + this.state.stickyHeader.padding + shadowPadding + 2;
|
|
607
562
|
var _getEditorFeatureFlag3 = getEditorFeatureFlags(),
|
|
608
563
|
stickyScrollbar = _getEditorFeatureFlag3.stickyScrollbar,
|
|
@@ -5,14 +5,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.createPlugin = void 0;
|
|
8
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
10
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
11
11
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
12
12
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
13
13
|
var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
|
|
14
14
|
var _utils = require("@atlaskit/editor-tables/utils");
|
|
15
|
-
var _element = require("@atlaskit/pragmatic-drag-and-drop/
|
|
15
|
+
var _element = require("@atlaskit/pragmatic-drag-and-drop-auto-scroll/element");
|
|
16
|
+
var _element2 = require("@atlaskit/pragmatic-drag-and-drop/adapter/element");
|
|
17
|
+
var _combine = require("@atlaskit/pragmatic-drag-and-drop/util/combine");
|
|
16
18
|
var _utils2 = require("../../utils");
|
|
17
19
|
var _pluginFactory = require("../plugin-factory");
|
|
18
20
|
var _pluginKey = require("../plugin-key");
|
|
@@ -26,6 +28,148 @@ var _pluginKey2 = require("./plugin-key");
|
|
|
26
28
|
var _monitor = require("./utils/monitor");
|
|
27
29
|
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; }
|
|
28
30
|
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; }
|
|
31
|
+
var destroyFn = function destroyFn(editorView, editorAnalyticsAPI) {
|
|
32
|
+
var editorPageScrollContainer = document.querySelector('.fabric-editor-popup-scroll-parent');
|
|
33
|
+
var rowAutoScrollers = editorPageScrollContainer ? [(0, _element2.monitorForElements)({
|
|
34
|
+
canMonitor: function canMonitor(_ref) {
|
|
35
|
+
var source = _ref.source;
|
|
36
|
+
var _ref2 = source.data,
|
|
37
|
+
type = _ref2.type;
|
|
38
|
+
return type === 'table-row';
|
|
39
|
+
},
|
|
40
|
+
onDragStart: function onDragStart() {
|
|
41
|
+
// auto scroller doesn't work when scroll-behavior: smooth is set, this monitor temporarily removes it via inline styles
|
|
42
|
+
editorPageScrollContainer.style.setProperty('scroll-behavior', 'unset');
|
|
43
|
+
},
|
|
44
|
+
onDrop: function onDrop() {
|
|
45
|
+
// 'null' will remove the inline style
|
|
46
|
+
editorPageScrollContainer.style.setProperty('scroll-behavior', null);
|
|
47
|
+
}
|
|
48
|
+
}), (0, _element.autoScrollForElements)({
|
|
49
|
+
element: editorPageScrollContainer,
|
|
50
|
+
canScroll: function canScroll(_ref3) {
|
|
51
|
+
var source = _ref3.source;
|
|
52
|
+
var _ref4 = source.data,
|
|
53
|
+
type = _ref4.type;
|
|
54
|
+
return type === 'table-row';
|
|
55
|
+
}
|
|
56
|
+
})] : [];
|
|
57
|
+
return _combine.combine.apply(void 0, rowAutoScrollers.concat([(0, _element2.monitorForElements)({
|
|
58
|
+
canMonitor: function canMonitor(_ref5) {
|
|
59
|
+
var source = _ref5.source;
|
|
60
|
+
var _ref6 = source.data,
|
|
61
|
+
type = _ref6.type,
|
|
62
|
+
localId = _ref6.localId,
|
|
63
|
+
indexes = _ref6.indexes;
|
|
64
|
+
|
|
65
|
+
// First; Perform any quick checks so we can abort early.
|
|
66
|
+
if (!indexes || !localId ||
|
|
67
|
+
// FIXME: We currently don't support DragNDrop of multiple elements. For now we will not bother to monitor drags
|
|
68
|
+
// of more then 1 item.
|
|
69
|
+
indexes.length !== 1 || !(type === 'table-row' || type === 'table-column')) {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
var _getTablePluginState = (0, _pluginFactory.getPluginState)(editorView.state),
|
|
73
|
+
tableNode = _getTablePluginState.tableNode;
|
|
74
|
+
// If the draggable localId is the same as the current selected table localId then we will allow the monitor
|
|
75
|
+
// watch for changes
|
|
76
|
+
return localId === (tableNode === null || tableNode === void 0 ? void 0 : tableNode.attrs.localId);
|
|
77
|
+
},
|
|
78
|
+
onDragStart: function onDragStart(_ref7) {
|
|
79
|
+
var location = _ref7.location;
|
|
80
|
+
(0, _commands.toggleDragMenu)(false)(editorView.state, editorView.dispatch);
|
|
81
|
+
},
|
|
82
|
+
onDrag: function onDrag(event) {
|
|
83
|
+
var data = (0, _monitor.getDraggableDataFromEvent)(event);
|
|
84
|
+
// If no data can be found then it's most like we do not want to perform any drag actions
|
|
85
|
+
if (!data) {
|
|
86
|
+
(0, _commands.clearDropTarget)()(editorView.state, editorView.dispatch);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// TODO: as we drag an element around we are going to want to update the state to acurately reflect the current
|
|
91
|
+
// insert location as to where the draggable will most likely be go. For example;
|
|
92
|
+
var sourceType = data.sourceType,
|
|
93
|
+
targetAdjustedIndex = data.targetAdjustedIndex;
|
|
94
|
+
var dropTargetType = sourceType === 'table-row' ? _consts.DropTargetType.ROW : _consts.DropTargetType.COLUMN;
|
|
95
|
+
var hasMergedCells = (0, _utils2.hasMergedCellsInBetween)([targetAdjustedIndex - 1, targetAdjustedIndex], dropTargetType)(editorView.state.selection);
|
|
96
|
+
(0, _commands.setDropTarget)(dropTargetType, targetAdjustedIndex, hasMergedCells)(editorView.state, editorView.dispatch);
|
|
97
|
+
},
|
|
98
|
+
onDrop: function onDrop(event) {
|
|
99
|
+
var _cell$row, _cell$col;
|
|
100
|
+
var data = (0, _monitor.getDraggableDataFromEvent)(event);
|
|
101
|
+
|
|
102
|
+
// On Drop we need to update the table main plugin hoveredCell value with the current row/col that the mouse is
|
|
103
|
+
// over. This is so the drag handles update their positions to correctly align with the users mouse. Unfortunately
|
|
104
|
+
// at this point in time and during the drag opertation, the drop targets are eating all the mouse events so
|
|
105
|
+
// it's not possible to know what row/col the mouse is over (via mouse events). This attempts to locate the nearest cell and
|
|
106
|
+
// then tries to update the main table hoveredCell value by piggy-backing the transaction onto the command
|
|
107
|
+
// triggered by this on drop event.
|
|
108
|
+
var _getTablePluginState2 = (0, _pluginFactory.getPluginState)(editorView.state),
|
|
109
|
+
hoveredCell = _getTablePluginState2.hoveredCell;
|
|
110
|
+
var cell = (0, _utils2.findNearestCellIndexToPoint)(event.location.current.input.clientX, event.location.current.input.clientY);
|
|
111
|
+
var tr = editorView.state.tr;
|
|
112
|
+
var action = {
|
|
113
|
+
type: 'HOVER_CELL',
|
|
114
|
+
data: {
|
|
115
|
+
hoveredCell: {
|
|
116
|
+
rowIndex: (_cell$row = cell === null || cell === void 0 ? void 0 : cell.row) !== null && _cell$row !== void 0 ? _cell$row : hoveredCell.rowIndex,
|
|
117
|
+
colIndex: (_cell$col = cell === null || cell === void 0 ? void 0 : cell.col) !== null && _cell$col !== void 0 ? _cell$col : hoveredCell.colIndex
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
tr.setMeta(_pluginKey.pluginKey, action);
|
|
122
|
+
|
|
123
|
+
// If no data can be found then it's most like we do not want to perform any drop action
|
|
124
|
+
if (!data) {
|
|
125
|
+
var _event$source, _event$source2;
|
|
126
|
+
// If we're able to determine the source type of the dropped element then we should report to analytics that
|
|
127
|
+
// the drop event was cancelled. Otherwise we will cancel silently.
|
|
128
|
+
if ((event === null || event === void 0 || (_event$source = event.source) === null || _event$source === void 0 || (_event$source = _event$source.data) === null || _event$source === void 0 ? void 0 : _event$source.type) === 'table-row' || (event === null || event === void 0 || (_event$source2 = event.source) === null || _event$source2 === void 0 || (_event$source2 = _event$source2.data) === null || _event$source2 === void 0 ? void 0 : _event$source2.type) === 'table-column') {
|
|
129
|
+
return (0, _commandsWithAnalytics.clearDropTargetWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.DRAG_AND_DROP, event.source.data.type, _analytics.TABLE_STATUS.CANCELLED, tr)(editorView.state, editorView.dispatch);
|
|
130
|
+
}
|
|
131
|
+
return (0, _commands.clearDropTarget)(tr)(editorView.state, editorView.dispatch);
|
|
132
|
+
}
|
|
133
|
+
var sourceType = data.sourceType,
|
|
134
|
+
sourceIndexes = data.sourceIndexes,
|
|
135
|
+
targetIndex = data.targetIndex,
|
|
136
|
+
targetAdjustedIndex = data.targetAdjustedIndex,
|
|
137
|
+
direction = data.direction;
|
|
138
|
+
|
|
139
|
+
// When we drop on a target we will know the targets row/col index for certain,
|
|
140
|
+
if (sourceType === 'table-row') {
|
|
141
|
+
action.data.hoveredCell.rowIndex = targetIndex;
|
|
142
|
+
} else {
|
|
143
|
+
action.data.hoveredCell.colIndex = targetIndex;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// If the drop target index contains merged cells then we should not allow the drop to occur.
|
|
147
|
+
if ((0, _utils2.hasMergedCellsInBetween)([targetAdjustedIndex - 1, targetAdjustedIndex], sourceType === 'table-row' ? _consts.DropTargetType.ROW : _consts.DropTargetType.COLUMN)(editorView.state.selection)) {
|
|
148
|
+
(0, _commandsWithAnalytics.clearDropTargetWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.DRAG_AND_DROP, sourceType,
|
|
149
|
+
// This event is mrked as invalid because the user is attempting to drop an element in an area which has merged cells.
|
|
150
|
+
_analytics.TABLE_STATUS.INVALID, tr)(editorView.state, editorView.dispatch);
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
var _sourceIndexes = (0, _slicedToArray2.default)(sourceIndexes, 1),
|
|
154
|
+
sourceIndex = _sourceIndexes[0];
|
|
155
|
+
requestAnimationFrame(function () {
|
|
156
|
+
(0, _commandsWithAnalytics.moveSourceWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.DRAG_AND_DROP, sourceType, sourceIndex, targetAdjustedIndex + (direction === -1 ? 0 : -1), tr)(editorView.state, editorView.dispatch);
|
|
157
|
+
|
|
158
|
+
// force a colgroup update here, otherwise dropped columns don't have
|
|
159
|
+
// the correct width immediately after the drop
|
|
160
|
+
if (sourceType === 'table-column') {
|
|
161
|
+
var _getTablePluginState3 = (0, _pluginFactory.getPluginState)(editorView.state),
|
|
162
|
+
tableRef = _getTablePluginState3.tableRef,
|
|
163
|
+
tableNode = _getTablePluginState3.tableNode;
|
|
164
|
+
if (tableRef && tableNode) {
|
|
165
|
+
(0, _utils3.insertColgroupFromNode)(tableRef, tableNode);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
editorView.focus();
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
})]));
|
|
172
|
+
};
|
|
29
173
|
var createPlugin = exports.createPlugin = function createPlugin(dispatch, eventDispatcher, editorAnalyticsAPI) {
|
|
30
174
|
return new _safePlugin.SafePlugin({
|
|
31
175
|
state: (0, _pluginFactory2.createPluginState)(dispatch, function (state) {
|
|
@@ -41,12 +185,12 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, eventD
|
|
|
41
185
|
}),
|
|
42
186
|
key: _pluginKey2.pluginKey,
|
|
43
187
|
appendTransaction: function appendTransaction(transactions, oldState, newState) {
|
|
44
|
-
var
|
|
45
|
-
oldTargetCellPosition =
|
|
46
|
-
oldTableNode =
|
|
47
|
-
var
|
|
48
|
-
newTargetCellPosition =
|
|
49
|
-
newTableNode =
|
|
188
|
+
var _getTablePluginState4 = (0, _pluginFactory.getPluginState)(oldState),
|
|
189
|
+
oldTargetCellPosition = _getTablePluginState4.targetCellPosition,
|
|
190
|
+
oldTableNode = _getTablePluginState4.tableNode;
|
|
191
|
+
var _getTablePluginState5 = (0, _pluginFactory.getPluginState)(newState),
|
|
192
|
+
newTargetCellPosition = _getTablePluginState5.targetCellPosition,
|
|
193
|
+
newTableNode = _getTablePluginState5.tableNode;
|
|
50
194
|
var _getPluginState = (0, _pluginFactory2.getPluginState)(newState),
|
|
51
195
|
isDragMenuOpen = _getPluginState.isDragMenuOpen,
|
|
52
196
|
dragMenuIndex = _getPluginState.dragMenuIndex,
|
|
@@ -100,121 +244,7 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, eventD
|
|
|
100
244
|
},
|
|
101
245
|
view: function view(editorView) {
|
|
102
246
|
return {
|
|
103
|
-
destroy: (
|
|
104
|
-
canMonitor: function canMonitor(_ref) {
|
|
105
|
-
var source = _ref.source;
|
|
106
|
-
var _ref2 = source.data,
|
|
107
|
-
type = _ref2.type,
|
|
108
|
-
localId = _ref2.localId,
|
|
109
|
-
indexes = _ref2.indexes;
|
|
110
|
-
|
|
111
|
-
// First; Perform any quick checks so we can abort early.
|
|
112
|
-
if (!indexes || !localId ||
|
|
113
|
-
// FIXME: We currently don't support DragNDrop of multiple elements. For now we will not bother to monitor drags
|
|
114
|
-
// of more then 1 item.
|
|
115
|
-
indexes.length !== 1 || !(type === 'table-row' || type === 'table-column')) {
|
|
116
|
-
return false;
|
|
117
|
-
}
|
|
118
|
-
var _getTablePluginState3 = (0, _pluginFactory.getPluginState)(editorView.state),
|
|
119
|
-
tableNode = _getTablePluginState3.tableNode;
|
|
120
|
-
// If the draggable localId is the same as the current selected table localId then we will allow the monitor
|
|
121
|
-
// watch for changes
|
|
122
|
-
return localId === (tableNode === null || tableNode === void 0 ? void 0 : tableNode.attrs.localId);
|
|
123
|
-
},
|
|
124
|
-
onDragStart: function onDragStart(_ref3) {
|
|
125
|
-
var location = _ref3.location;
|
|
126
|
-
(0, _commands.toggleDragMenu)(false)(editorView.state, editorView.dispatch);
|
|
127
|
-
},
|
|
128
|
-
onDrag: function onDrag(event) {
|
|
129
|
-
var data = (0, _monitor.getDraggableDataFromEvent)(event);
|
|
130
|
-
// If no data can be found then it's most like we do not want to perform any drag actions
|
|
131
|
-
if (!data) {
|
|
132
|
-
(0, _commands.clearDropTarget)()(editorView.state, editorView.dispatch);
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// TODO: as we drag an element around we are going to want to update the state to acurately reflect the current
|
|
137
|
-
// insert location as to where the draggable will most likely be go. For example;
|
|
138
|
-
var sourceType = data.sourceType,
|
|
139
|
-
targetAdjustedIndex = data.targetAdjustedIndex;
|
|
140
|
-
var dropTargetType = sourceType === 'table-row' ? _consts.DropTargetType.ROW : _consts.DropTargetType.COLUMN;
|
|
141
|
-
var hasMergedCells = (0, _utils2.hasMergedCellsInBetween)([targetAdjustedIndex - 1, targetAdjustedIndex], dropTargetType)(editorView.state.selection);
|
|
142
|
-
(0, _commands.setDropTarget)(dropTargetType, targetAdjustedIndex, hasMergedCells)(editorView.state, editorView.dispatch);
|
|
143
|
-
},
|
|
144
|
-
onDrop: function onDrop(event) {
|
|
145
|
-
var _cell$row, _cell$col;
|
|
146
|
-
var data = (0, _monitor.getDraggableDataFromEvent)(event);
|
|
147
|
-
|
|
148
|
-
// On Drop we need to update the table main plugin hoveredCell value with the current row/col that the mouse is
|
|
149
|
-
// over. This is so the drag handles update their positions to correctly align with the users mouse. Unfortunately
|
|
150
|
-
// at this point in time and during the drag opertation, the drop targets are eating all the mouse events so
|
|
151
|
-
// it's not possible to know what row/col the mouse is over (via mouse events). This attempts to locate the nearest cell and
|
|
152
|
-
// then tries to update the main table hoveredCell value by piggy-backing the transaction onto the command
|
|
153
|
-
// triggered by this on drop event.
|
|
154
|
-
var _getTablePluginState4 = (0, _pluginFactory.getPluginState)(editorView.state),
|
|
155
|
-
hoveredCell = _getTablePluginState4.hoveredCell;
|
|
156
|
-
var cell = (0, _utils2.findNearestCellIndexToPoint)(event.location.current.input.clientX, event.location.current.input.clientY);
|
|
157
|
-
var tr = editorView.state.tr;
|
|
158
|
-
var action = {
|
|
159
|
-
type: 'HOVER_CELL',
|
|
160
|
-
data: {
|
|
161
|
-
hoveredCell: {
|
|
162
|
-
rowIndex: (_cell$row = cell === null || cell === void 0 ? void 0 : cell.row) !== null && _cell$row !== void 0 ? _cell$row : hoveredCell.rowIndex,
|
|
163
|
-
colIndex: (_cell$col = cell === null || cell === void 0 ? void 0 : cell.col) !== null && _cell$col !== void 0 ? _cell$col : hoveredCell.colIndex
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
};
|
|
167
|
-
tr.setMeta(_pluginKey.pluginKey, action);
|
|
168
|
-
|
|
169
|
-
// If no data can be found then it's most like we do not want to perform any drop action
|
|
170
|
-
if (!data) {
|
|
171
|
-
var _event$source, _event$source2;
|
|
172
|
-
// If we're able to determine the source type of the dropped element then we should report to analytics that
|
|
173
|
-
// the drop event was cancelled. Otherwise we will cancel silently.
|
|
174
|
-
if ((event === null || event === void 0 || (_event$source = event.source) === null || _event$source === void 0 || (_event$source = _event$source.data) === null || _event$source === void 0 ? void 0 : _event$source.type) === 'table-row' || (event === null || event === void 0 || (_event$source2 = event.source) === null || _event$source2 === void 0 || (_event$source2 = _event$source2.data) === null || _event$source2 === void 0 ? void 0 : _event$source2.type) === 'table-column') {
|
|
175
|
-
return (0, _commandsWithAnalytics.clearDropTargetWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.DRAG_AND_DROP, event.source.data.type, _analytics.TABLE_STATUS.CANCELLED, tr)(editorView.state, editorView.dispatch);
|
|
176
|
-
}
|
|
177
|
-
return (0, _commands.clearDropTarget)(tr)(editorView.state, editorView.dispatch);
|
|
178
|
-
}
|
|
179
|
-
var sourceType = data.sourceType,
|
|
180
|
-
sourceIndexes = data.sourceIndexes,
|
|
181
|
-
targetIndex = data.targetIndex,
|
|
182
|
-
targetAdjustedIndex = data.targetAdjustedIndex,
|
|
183
|
-
direction = data.direction;
|
|
184
|
-
|
|
185
|
-
// When we drop on a target we will know the targets row/col index for certain,
|
|
186
|
-
if (sourceType === 'table-row') {
|
|
187
|
-
action.data.hoveredCell.rowIndex = targetIndex;
|
|
188
|
-
} else {
|
|
189
|
-
action.data.hoveredCell.colIndex = targetIndex;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
// If the drop target index contains merged cells then we should not allow the drop to occur.
|
|
193
|
-
if ((0, _utils2.hasMergedCellsInBetween)([targetAdjustedIndex - 1, targetAdjustedIndex], sourceType === 'table-row' ? _consts.DropTargetType.ROW : _consts.DropTargetType.COLUMN)(editorView.state.selection)) {
|
|
194
|
-
(0, _commandsWithAnalytics.clearDropTargetWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.DRAG_AND_DROP, sourceType,
|
|
195
|
-
// This event is mrked as invalid because the user is attempting to drop an element in an area which has merged cells.
|
|
196
|
-
_analytics.TABLE_STATUS.INVALID, tr)(editorView.state, editorView.dispatch);
|
|
197
|
-
return;
|
|
198
|
-
}
|
|
199
|
-
var _sourceIndexes = (0, _slicedToArray2.default)(sourceIndexes, 1),
|
|
200
|
-
sourceIndex = _sourceIndexes[0];
|
|
201
|
-
requestAnimationFrame(function () {
|
|
202
|
-
(0, _commandsWithAnalytics.moveSourceWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.DRAG_AND_DROP, sourceType, sourceIndex, targetAdjustedIndex + (direction === -1 ? 0 : -1), tr)(editorView.state, editorView.dispatch);
|
|
203
|
-
|
|
204
|
-
// force a colgroup update here, otherwise dropped columns don't have
|
|
205
|
-
// the correct width immediately after the drop
|
|
206
|
-
if (sourceType === 'table-column') {
|
|
207
|
-
var _getTablePluginState5 = (0, _pluginFactory.getPluginState)(editorView.state),
|
|
208
|
-
tableRef = _getTablePluginState5.tableRef,
|
|
209
|
-
tableNode = _getTablePluginState5.tableNode;
|
|
210
|
-
if (tableRef && tableNode) {
|
|
211
|
-
(0, _utils3.insertColgroupFromNode)(tableRef, tableNode);
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
editorView.focus();
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
})
|
|
247
|
+
destroy: destroyFn(editorView, editorAnalyticsAPI)
|
|
218
248
|
};
|
|
219
249
|
},
|
|
220
250
|
props: {
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.autoScrollerFactory = void 0;
|
|
7
|
+
var _element = require("@atlaskit/pragmatic-drag-and-drop-auto-scroll/element");
|
|
8
|
+
var _element2 = require("@atlaskit/pragmatic-drag-and-drop-auto-scroll/unsafe-overflow/element");
|
|
9
|
+
var _consts = require("../../../ui/consts");
|
|
10
|
+
var autoScrollerFactory = exports.autoScrollerFactory = function autoScrollerFactory(_ref) {
|
|
11
|
+
var tableWrapper = _ref.tableWrapper,
|
|
12
|
+
getNode = _ref.getNode;
|
|
13
|
+
return [(0, _element.autoScrollForElements)({
|
|
14
|
+
element: tableWrapper,
|
|
15
|
+
canScroll: function canScroll(_ref2) {
|
|
16
|
+
var source = _ref2.source;
|
|
17
|
+
var _ref3 = source.data,
|
|
18
|
+
localId = _ref3.localId,
|
|
19
|
+
type = _ref3.type;
|
|
20
|
+
var node = getNode();
|
|
21
|
+
return localId === (node === null || node === void 0 ? void 0 : node.attrs.localId) && type === 'table-column';
|
|
22
|
+
}
|
|
23
|
+
}), (0, _element2.unsafeOverflowAutoScrollForElements)({
|
|
24
|
+
element: tableWrapper,
|
|
25
|
+
canScroll: function canScroll(_ref4) {
|
|
26
|
+
var source = _ref4.source;
|
|
27
|
+
var _ref5 = source.data,
|
|
28
|
+
localId = _ref5.localId,
|
|
29
|
+
type = _ref5.type;
|
|
30
|
+
var node = getNode();
|
|
31
|
+
return localId === (node === null || node === void 0 ? void 0 : node.attrs.localId) && type === 'table-column';
|
|
32
|
+
},
|
|
33
|
+
getOverflow: function getOverflow() {
|
|
34
|
+
return {
|
|
35
|
+
fromTopEdge: {
|
|
36
|
+
top: _consts.dropTargetExtendedWidth,
|
|
37
|
+
right: _consts.dropTargetExtendedWidth,
|
|
38
|
+
left: _consts.dropTargetExtendedWidth
|
|
39
|
+
},
|
|
40
|
+
fromRightEdge: {
|
|
41
|
+
right: _consts.dropTargetExtendedWidth,
|
|
42
|
+
top: _consts.dropTargetExtendedWidth,
|
|
43
|
+
bottom: _consts.dropTargetExtendedWidth
|
|
44
|
+
},
|
|
45
|
+
fromLeftEdge: {
|
|
46
|
+
top: _consts.dropTargetExtendedWidth,
|
|
47
|
+
left: _consts.dropTargetExtendedWidth,
|
|
48
|
+
bottom: _consts.dropTargetExtendedWidth
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
})];
|
|
53
|
+
};
|
|
@@ -3,10 +3,17 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
Object.defineProperty(exports, "autoScrollerFactory", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _autoscrollers.autoScrollerFactory;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
6
12
|
Object.defineProperty(exports, "getDraggableDataFromEvent", {
|
|
7
13
|
enumerable: true,
|
|
8
14
|
get: function get() {
|
|
9
15
|
return _monitor.getDraggableDataFromEvent;
|
|
10
16
|
}
|
|
11
17
|
});
|
|
12
|
-
var _monitor = require("./monitor");
|
|
18
|
+
var _monitor = require("./monitor");
|
|
19
|
+
var _autoscrollers = require("./autoscrollers");
|
|
@@ -11,6 +11,8 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
|
|
|
11
11
|
var _react = _interopRequireWildcard(require("react"));
|
|
12
12
|
var _classnames2 = _interopRequireDefault(require("classnames"));
|
|
13
13
|
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
14
|
+
var _reactIntlNext = require("react-intl-next");
|
|
15
|
+
var _messages = require("@atlaskit/editor-common/messages");
|
|
14
16
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
15
17
|
var _element = require("@atlaskit/pragmatic-drag-and-drop/adapter/element");
|
|
16
18
|
var _setCustomNativeDragPreview = require("@atlaskit/pragmatic-drag-and-drop/util/set-custom-native-drag-preview");
|
|
@@ -21,7 +23,7 @@ var _DragPreview = require("../DragPreview");
|
|
|
21
23
|
var _HandleIconComponent = require("./HandleIconComponent");
|
|
22
24
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
23
25
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
24
|
-
var
|
|
26
|
+
var DragHandleComponent = function DragHandleComponent(_ref) {
|
|
25
27
|
var isDragMenuTarget = _ref.isDragMenuTarget,
|
|
26
28
|
tableLocalId = _ref.tableLocalId,
|
|
27
29
|
_ref$direction = _ref.direction,
|
|
@@ -39,7 +41,8 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
39
41
|
onClick = _ref.onClick,
|
|
40
42
|
editorView = _ref.editorView,
|
|
41
43
|
_ref$canDrag = _ref.canDrag,
|
|
42
|
-
_canDrag = _ref$canDrag === void 0 ? false : _ref$canDrag
|
|
44
|
+
_canDrag = _ref$canDrag === void 0 ? false : _ref$canDrag,
|
|
45
|
+
formatMessage = _ref.intl.formatMessage;
|
|
43
46
|
var dragHandleDivRef = (0, _react.useRef)(null);
|
|
44
47
|
var _useState = (0, _react.useState)(null),
|
|
45
48
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
@@ -124,6 +127,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
124
127
|
transform: direction === 'column' ? 'none' : 'rotate(90deg)'
|
|
125
128
|
},
|
|
126
129
|
"data-testid": "table-drag-handle-button",
|
|
130
|
+
"aria-label": formatMessage(direction === 'row' ? _messages.tableMessages.rowDragHandle : _messages.tableMessages.columnDragHandle),
|
|
127
131
|
onMouseOver: onMouseOver,
|
|
128
132
|
onMouseOut: onMouseOut,
|
|
129
133
|
onMouseUp: function onMouseUp(e) {
|
|
@@ -142,4 +146,5 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
142
146
|
width: previewWidth,
|
|
143
147
|
height: previewHeight
|
|
144
148
|
}), previewContainer));
|
|
145
|
-
};
|
|
149
|
+
};
|
|
150
|
+
var DragHandle = exports.DragHandle = (0, _reactIntlNext.injectIntl)(DragHandleComponent);
|
|
@@ -148,7 +148,7 @@ var ContextualMenu = exports.ContextualMenu = /*#__PURE__*/function (_Component)
|
|
|
148
148
|
var _getPluginState3 = (0, _pluginFactory.getPluginState)(editorView.state),
|
|
149
149
|
isDragAndDropEnabled = _getPluginState3.isDragAndDropEnabled;
|
|
150
150
|
return {
|
|
151
|
-
content: formatMessage(isDragAndDropEnabled && (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.new-cell-context-menu-styling') ? _messages.tableMessages.
|
|
151
|
+
content: formatMessage(isDragAndDropEnabled && (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.new-cell-context-menu-styling') ? _messages.tableMessages.addColumnRight : _messages.tableMessages.insertColumn),
|
|
152
152
|
value: {
|
|
153
153
|
name: 'insert_column'
|
|
154
154
|
},
|
|
@@ -165,7 +165,7 @@ var ContextualMenu = exports.ContextualMenu = /*#__PURE__*/function (_Component)
|
|
|
165
165
|
var _getPluginState4 = (0, _pluginFactory.getPluginState)(editorView.state),
|
|
166
166
|
isDragAndDropEnabled = _getPluginState4.isDragAndDropEnabled;
|
|
167
167
|
return {
|
|
168
|
-
content: formatMessage(isDragAndDropEnabled && (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.new-cell-context-menu-styling') ? _messages.tableMessages.
|
|
168
|
+
content: formatMessage(isDragAndDropEnabled && (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.new-cell-context-menu-styling') ? _messages.tableMessages.addRowBelow : _messages.tableMessages.insertRow),
|
|
169
169
|
value: {
|
|
170
170
|
name: 'insert_row'
|
|
171
171
|
},
|