@atlaskit/editor-plugin-table 5.4.18 → 5.4.20
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 +12 -0
- package/dist/cjs/plugins/table/index.js +1 -0
- package/dist/cjs/plugins/table/nodeviews/TableComponent.js +5 -2
- package/dist/cjs/plugins/table/nodeviews/table.js +7 -2
- package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/actions.js +2 -1
- package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/consts.js +3 -2
- package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/plugin.js +38 -14
- package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/reducer.js +2 -0
- package/dist/cjs/plugins/table/ui/DragHandle/HandleIconComponent.js +4 -2
- package/dist/cjs/plugins/table/ui/DragHandle/index.js +16 -4
- package/dist/cjs/plugins/table/ui/FloatingDragMenu/DragMenu.js +3 -2
- package/dist/cjs/plugins/table/ui/FloatingDragMenu/index.js +4 -2
- package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +6 -3
- package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/index.js +4 -2
- package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +5 -3
- package/dist/cjs/plugins/table/ui/TableFloatingControls/index.js +7 -4
- package/dist/cjs/plugins/table/utils/drag-menu.js +10 -6
- package/dist/es2019/plugins/table/index.js +1 -0
- package/dist/es2019/plugins/table/nodeviews/TableComponent.js +5 -2
- package/dist/es2019/plugins/table/nodeviews/table.js +7 -2
- package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/actions.js +2 -1
- package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/consts.js +2 -1
- package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/plugin.js +39 -15
- package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/reducer.js +5 -0
- package/dist/es2019/plugins/table/ui/DragHandle/HandleIconComponent.js +3 -1
- package/dist/es2019/plugins/table/ui/DragHandle/index.js +15 -4
- package/dist/es2019/plugins/table/ui/FloatingDragMenu/DragMenu.js +3 -2
- package/dist/es2019/plugins/table/ui/FloatingDragMenu/index.js +4 -2
- package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +6 -3
- package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/index.js +4 -2
- package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +5 -3
- package/dist/es2019/plugins/table/ui/TableFloatingControls/index.js +7 -4
- package/dist/es2019/plugins/table/utils/drag-menu.js +6 -6
- package/dist/esm/plugins/table/index.js +1 -0
- package/dist/esm/plugins/table/nodeviews/TableComponent.js +5 -2
- package/dist/esm/plugins/table/nodeviews/table.js +7 -2
- package/dist/esm/plugins/table/pm-plugins/drag-and-drop/actions.js +2 -1
- package/dist/esm/plugins/table/pm-plugins/drag-and-drop/consts.js +2 -1
- package/dist/esm/plugins/table/pm-plugins/drag-and-drop/plugin.js +39 -15
- package/dist/esm/plugins/table/pm-plugins/drag-and-drop/reducer.js +2 -0
- package/dist/esm/plugins/table/ui/DragHandle/HandleIconComponent.js +4 -2
- package/dist/esm/plugins/table/ui/DragHandle/index.js +16 -4
- package/dist/esm/plugins/table/ui/FloatingDragMenu/DragMenu.js +3 -2
- package/dist/esm/plugins/table/ui/FloatingDragMenu/index.js +4 -2
- package/dist/esm/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +6 -3
- package/dist/esm/plugins/table/ui/TableFloatingColumnControls/index.js +4 -2
- package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +5 -3
- package/dist/esm/plugins/table/ui/TableFloatingControls/index.js +7 -4
- package/dist/esm/plugins/table/utils/drag-menu.js +10 -6
- package/dist/types/plugins/table/nodeviews/TableComponent.d.ts +1 -0
- package/dist/types/plugins/table/pm-plugins/drag-and-drop/actions.d.ts +4 -1
- package/dist/types/plugins/table/pm-plugins/drag-and-drop/consts.d.ts +1 -0
- package/dist/types/plugins/table/pm-plugins/drag-and-drop/plugin.d.ts +2 -1
- package/dist/types/plugins/table/pm-plugins/drag-and-drop/types.d.ts +1 -0
- package/dist/types/plugins/table/ui/DragHandle/HandleIconComponent.d.ts +1 -0
- package/dist/types/plugins/table/ui/DragHandle/index.d.ts +2 -1
- package/dist/types/plugins/table/ui/FloatingDragMenu/DragMenu.d.ts +2 -1
- package/dist/types/plugins/table/ui/FloatingDragMenu/index.d.ts +2 -1
- package/dist/types/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +2 -1
- package/dist/types/plugins/table/ui/TableFloatingColumnControls/index.d.ts +1 -0
- package/dist/types/plugins/table/ui/TableFloatingControls/RowControls/DragControls.d.ts +1 -0
- package/dist/types/plugins/table/ui/TableFloatingControls/index.d.ts +1 -0
- package/dist/types/plugins/table/utils/drag-menu.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/nodeviews/TableComponent.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/actions.d.ts +4 -1
- package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/consts.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/plugin.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/types.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/ui/DragHandle/HandleIconComponent.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/ui/DragHandle/index.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/ui/FloatingDragMenu/DragMenu.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/ui/FloatingDragMenu/index.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingColumnControls/index.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/RowControls/DragControls.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/index.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/utils/drag-menu.d.ts +1 -1
- package/package.json +1 -1
- package/src/__tests__/unit/pm-plugins/drag-and-drop/plugin.ts +112 -0
- package/src/plugins/table/index.tsx +1 -0
- package/src/plugins/table/nodeviews/TableComponent.tsx +4 -0
- package/src/plugins/table/nodeviews/table.tsx +4 -0
- package/src/plugins/table/pm-plugins/drag-and-drop/actions.ts +9 -1
- package/src/plugins/table/pm-plugins/drag-and-drop/consts.ts +2 -0
- package/src/plugins/table/pm-plugins/drag-and-drop/plugin.ts +49 -17
- package/src/plugins/table/pm-plugins/drag-and-drop/reducer.ts +5 -0
- package/src/plugins/table/pm-plugins/drag-and-drop/types.ts +1 -0
- package/src/plugins/table/ui/DragHandle/HandleIconComponent.tsx +5 -1
- package/src/plugins/table/ui/DragHandle/index.tsx +15 -2
- package/src/plugins/table/ui/FloatingDragMenu/DragMenu.tsx +3 -1
- package/src/plugins/table/ui/FloatingDragMenu/index.tsx +3 -0
- package/src/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.tsx +5 -1
- package/src/plugins/table/ui/TableFloatingColumnControls/index.tsx +3 -0
- package/src/plugins/table/ui/TableFloatingControls/RowControls/DragControls.tsx +5 -2
- package/src/plugins/table/ui/TableFloatingControls/index.tsx +6 -1
- package/src/plugins/table/utils/drag-menu.ts +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 5.4.20
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#59135](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/59135) [`0f0de3fcf207`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/0f0de3fcf207) - Drag and drop inside tables will now be disabled if the table nodeSize exceeds 20000
|
|
8
|
+
|
|
9
|
+
## 5.4.19
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#59403](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/59403) [`4edf50cbdc01`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/4edf50cbdc01) - Fixed DnD preview bug which was impacting safari when the preview snapshot was taken, other html elements below the preview zone would be included.
|
|
14
|
+
|
|
3
15
|
## 5.4.18
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -352,6 +352,7 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
352
352
|
direction: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.dragMenuDirection,
|
|
353
353
|
index: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.dragMenuIndex,
|
|
354
354
|
isOpen: !!(dragAndDropState !== null && dragAndDropState !== void 0 && dragAndDropState.isDragMenuOpen) && !isResizing,
|
|
355
|
+
canDrag: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.canDrag,
|
|
355
356
|
getEditorContainerWidth: defaultGetEditorContainerWidth
|
|
356
357
|
}), allowControls && !isDragAndDropEnabled && !isResizing && /*#__PURE__*/_react.default.createElement(_FloatingDeleteButton.default, {
|
|
357
358
|
editorView: editorView,
|
|
@@ -518,7 +518,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
518
518
|
options = _this$props10.options,
|
|
519
519
|
getPos = _this$props10.getPos,
|
|
520
520
|
pluginInjectionApi = _this$props10.pluginInjectionApi,
|
|
521
|
-
isDragAndDropEnabled = _this$props10.isDragAndDropEnabled
|
|
521
|
+
isDragAndDropEnabled = _this$props10.isDragAndDropEnabled,
|
|
522
|
+
canDrag = _this$props10.canDrag;
|
|
522
523
|
var _this$state3 = this.state,
|
|
523
524
|
showBeforeShadow = _this$state3.showBeforeShadow,
|
|
524
525
|
showAfterShadow = _this$state3.showAfterShadow;
|
|
@@ -545,6 +546,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
545
546
|
isNumberColumnEnabled: node.attrs.isNumberColumnEnabled,
|
|
546
547
|
isHeaderRowEnabled: isHeaderRowEnabled,
|
|
547
548
|
isDragAndDropEnabled: isDragAndDropEnabled,
|
|
549
|
+
canDrag: canDrag,
|
|
548
550
|
ordering: ordering,
|
|
549
551
|
isHeaderColumnEnabled: isHeaderColumnEnabled,
|
|
550
552
|
hasHeaderRow: hasHeaderRow
|
|
@@ -571,7 +573,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
571
573
|
selection: view.state.selection,
|
|
572
574
|
headerRowHeight: headerRow ? headerRow.offsetHeight : undefined,
|
|
573
575
|
stickyHeader: this.state.stickyHeader,
|
|
574
|
-
getEditorFeatureFlags: this.props.getEditorFeatureFlags
|
|
576
|
+
getEditorFeatureFlags: this.props.getEditorFeatureFlags,
|
|
577
|
+
canDrag: canDrag
|
|
575
578
|
}) : null;
|
|
576
579
|
var shadowPadding = allowControls && tableActive ? -_editorSharedStyles.akEditorTableToolbarSize : _styles.tableMarginSides;
|
|
577
580
|
var shadowStyle = (0, _memoizeOne.default)(function (visible) {
|
|
@@ -23,6 +23,7 @@ var _model = require("@atlaskit/editor-prosemirror/model");
|
|
|
23
23
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
24
24
|
var _tableMap = require("@atlaskit/editor-tables/table-map");
|
|
25
25
|
var _createPluginConfig = require("../create-plugin-config");
|
|
26
|
+
var _dragAndDrop = require("../pm-plugins/drag-and-drop");
|
|
26
27
|
var _pluginFactory = require("../pm-plugins/plugin-factory");
|
|
27
28
|
var _pluginKey = require("../pm-plugins/plugin-key");
|
|
28
29
|
var _tableResizing = require("../pm-plugins/table-resizing");
|
|
@@ -142,14 +143,17 @@ var TableView = exports.default = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
142
143
|
tableResizingPluginState: _tableResizing.pluginKey,
|
|
143
144
|
tableWidthPluginState: _tableWidth.pluginKey,
|
|
144
145
|
widthPlugin: fakePluginKey,
|
|
145
|
-
mediaState: fakeMediaPluginKey
|
|
146
|
+
mediaState: fakeMediaPluginKey,
|
|
147
|
+
tableDragAndDropState: _dragAndDrop.pluginKey
|
|
146
148
|
},
|
|
147
149
|
editorView: props.view,
|
|
148
150
|
render: function render(pluginStates) {
|
|
151
|
+
var _tableDragAndDropStat;
|
|
149
152
|
var tableResizingPluginState = pluginStates.tableResizingPluginState,
|
|
150
153
|
tableWidthPluginState = pluginStates.tableWidthPluginState,
|
|
151
154
|
pluginState = pluginStates.pluginState,
|
|
152
|
-
mediaState = pluginStates.mediaState
|
|
155
|
+
mediaState = pluginStates.mediaState,
|
|
156
|
+
tableDragAndDropState = pluginStates.tableDragAndDropState;
|
|
153
157
|
var containerWidth = props.getEditorContainerWidth();
|
|
154
158
|
var isTableResizing = tableWidthPluginState === null || tableWidthPluginState === void 0 ? void 0 : tableWidthPluginState.resizing;
|
|
155
159
|
var isResizing = Boolean((tableResizingPluginState === null || tableResizingPluginState === void 0 ? void 0 : tableResizingPluginState.dragging) || isTableResizing);
|
|
@@ -177,6 +181,7 @@ var TableView = exports.default = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
177
181
|
isHeaderRowEnabled: pluginState.isHeaderRowEnabled,
|
|
178
182
|
isHeaderColumnEnabled: pluginState.isHeaderColumnEnabled,
|
|
179
183
|
isDragAndDropEnabled: pluginState.isDragAndDropEnabled,
|
|
184
|
+
canDrag: (_tableDragAndDropStat = tableDragAndDropState === null || tableDragAndDropState === void 0 ? void 0 : tableDragAndDropState.canDrag) !== null && _tableDragAndDropStat !== void 0 ? _tableDragAndDropStat : false,
|
|
180
185
|
tableActive: tableActive,
|
|
181
186
|
ordering: pluginState.ordering,
|
|
182
187
|
isResizing: isResizing,
|
|
@@ -7,7 +7,8 @@ exports.DragAndDropActionType = void 0;
|
|
|
7
7
|
var DragAndDropActionType = exports.DragAndDropActionType = {
|
|
8
8
|
SET_DROP_TARGET: 'SET_DROP_TARGET',
|
|
9
9
|
CLEAR_DROP_TARGET: 'CLEAR_DROP_TARGET',
|
|
10
|
-
TOGGLE_DRAG_MENU: 'TOGGLE_DRAG_MENU'
|
|
10
|
+
TOGGLE_DRAG_MENU: 'TOGGLE_DRAG_MENU',
|
|
11
|
+
UPDATE: 'UPDATE'
|
|
11
12
|
};
|
|
12
13
|
|
|
13
14
|
// NOTE: This should be a Union of all possible actions
|
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.DropTargetType = void 0;
|
|
6
|
+
exports.DropTargetType = exports.DRAGGABLE_TABLE_NODE_SIZE_LIMIT = void 0;
|
|
7
7
|
var DropTargetType = exports.DropTargetType = {
|
|
8
8
|
NONE: 'none',
|
|
9
9
|
ROW: 'row',
|
|
10
10
|
COLUMN: 'column'
|
|
11
|
-
};
|
|
11
|
+
};
|
|
12
|
+
var DRAGGABLE_TABLE_NODE_SIZE_LIMIT = exports.DRAGGABLE_TABLE_NODE_SIZE_LIMIT = 20000;
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.createPlugin = void 0;
|
|
8
8
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
10
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
10
11
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
11
12
|
var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
|
|
@@ -21,6 +22,8 @@ var _consts = require("./consts");
|
|
|
21
22
|
var _pluginFactory2 = require("./plugin-factory");
|
|
22
23
|
var _pluginKey2 = require("./plugin-key");
|
|
23
24
|
var _monitor = require("./utils/monitor");
|
|
25
|
+
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; }
|
|
26
|
+
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
27
|
var createPlugin = exports.createPlugin = function createPlugin(dispatch, eventDispatcher) {
|
|
25
28
|
return new _safePlugin.SafePlugin({
|
|
26
29
|
state: (0, _pluginFactory2.createPluginState)(dispatch, function (state) {
|
|
@@ -30,18 +33,24 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, eventD
|
|
|
30
33
|
dropTargetIndex: 0,
|
|
31
34
|
isDragMenuOpen: false,
|
|
32
35
|
dragMenuIndex: 0,
|
|
33
|
-
isDragging: false
|
|
36
|
+
isDragging: false,
|
|
37
|
+
canDrag: false
|
|
34
38
|
};
|
|
35
39
|
}),
|
|
36
40
|
key: _pluginKey2.pluginKey,
|
|
37
41
|
appendTransaction: function appendTransaction(transactions, oldState, newState) {
|
|
38
42
|
var _getTablePluginState = (0, _pluginFactory.getPluginState)(oldState),
|
|
39
|
-
oldTargetCellPosition = _getTablePluginState.targetCellPosition
|
|
43
|
+
oldTargetCellPosition = _getTablePluginState.targetCellPosition,
|
|
44
|
+
oldTableNode = _getTablePluginState.tableNode;
|
|
40
45
|
var _getTablePluginState2 = (0, _pluginFactory.getPluginState)(newState),
|
|
41
|
-
newTargetCellPosition = _getTablePluginState2.targetCellPosition
|
|
46
|
+
newTargetCellPosition = _getTablePluginState2.targetCellPosition,
|
|
47
|
+
newTableNode = _getTablePluginState2.tableNode;
|
|
42
48
|
var _getPluginState = (0, _pluginFactory2.getPluginState)(newState),
|
|
43
49
|
isDragMenuOpen = _getPluginState.isDragMenuOpen,
|
|
44
|
-
dragMenuIndex = _getPluginState.dragMenuIndex
|
|
50
|
+
dragMenuIndex = _getPluginState.dragMenuIndex,
|
|
51
|
+
canDrag = _getPluginState.canDrag;
|
|
52
|
+
var stateChanges = [];
|
|
53
|
+
var tr = newState.tr;
|
|
45
54
|
|
|
46
55
|
// What's happening here? you asked... In a nutshell;
|
|
47
56
|
// If the target cell position changes while the drag menu is open then we want to close the drag menu if it has been opened.
|
|
@@ -49,14 +58,6 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, eventD
|
|
|
49
58
|
// to check if the new target cell position is pointed at a different cell than what the drag menu was opened on.
|
|
50
59
|
if (oldTargetCellPosition !== newTargetCellPosition) {
|
|
51
60
|
if (isDragMenuOpen) {
|
|
52
|
-
var tr = newState.tr;
|
|
53
|
-
var action = {
|
|
54
|
-
type: _actions.DragAndDropActionType.TOGGLE_DRAG_MENU,
|
|
55
|
-
data: {
|
|
56
|
-
isDragMenuOpen: false,
|
|
57
|
-
direction: undefined
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
61
|
if (newTargetCellPosition !== undefined) {
|
|
61
62
|
var cells = (0, _utils.getCellsInRow)(dragMenuIndex)(tr.selection);
|
|
62
63
|
// ED-20673 check if it is a cell selection,
|
|
@@ -64,13 +65,36 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, eventD
|
|
|
64
65
|
// should not close the drag menu.
|
|
65
66
|
var isCellSelection = tr.selection instanceof _cellSelection.CellSelection;
|
|
66
67
|
if (cells && cells.length && cells[0].node !== tr.doc.nodeAt(newTargetCellPosition) && !isCellSelection) {
|
|
67
|
-
|
|
68
|
+
stateChanges.push({
|
|
69
|
+
isDragMenuOpen: false,
|
|
70
|
+
dragMenuDirection: undefined
|
|
71
|
+
});
|
|
68
72
|
} // else NOP
|
|
69
73
|
} else {
|
|
70
|
-
|
|
74
|
+
stateChanges.push({
|
|
75
|
+
isDragMenuOpen: false,
|
|
76
|
+
dragMenuDirection: undefined
|
|
77
|
+
});
|
|
71
78
|
}
|
|
72
79
|
}
|
|
73
80
|
}
|
|
81
|
+
if ((oldTableNode === null || oldTableNode === void 0 ? void 0 : oldTableNode.nodeSize) !== (newTableNode === null || newTableNode === void 0 ? void 0 : newTableNode.nodeSize)) {
|
|
82
|
+
var _newTableNode$nodeSiz;
|
|
83
|
+
var nextCanDrag = ((_newTableNode$nodeSiz = newTableNode === null || newTableNode === void 0 ? void 0 : newTableNode.nodeSize) !== null && _newTableNode$nodeSiz !== void 0 ? _newTableNode$nodeSiz : 0) < _consts.DRAGGABLE_TABLE_NODE_SIZE_LIMIT;
|
|
84
|
+
if (canDrag !== nextCanDrag) {
|
|
85
|
+
stateChanges.push({
|
|
86
|
+
canDrag: nextCanDrag
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (stateChanges.length) {
|
|
91
|
+
return tr.setMeta(_pluginKey2.pluginKey, {
|
|
92
|
+
type: _actions.DragAndDropActionType.UPDATE,
|
|
93
|
+
data: _objectSpread({}, stateChanges.reduce(function (state, cur) {
|
|
94
|
+
return _objectSpread(_objectSpread({}, state), cur);
|
|
95
|
+
}, {}))
|
|
96
|
+
}).setMeta('addToHistory', false);
|
|
97
|
+
}
|
|
74
98
|
},
|
|
75
99
|
view: function view(editorView) {
|
|
76
100
|
return {
|
|
@@ -32,6 +32,8 @@ var _default = exports.default = function _default(pluginState, action) {
|
|
|
32
32
|
dragMenuDirection: action.data.direction,
|
|
33
33
|
dragMenuIndex: action.data.index
|
|
34
34
|
});
|
|
35
|
+
case _actions.DragAndDropActionType.UPDATE:
|
|
36
|
+
return _objectSpread(_objectSpread({}, pluginState), action.data);
|
|
35
37
|
default:
|
|
36
38
|
return pluginState;
|
|
37
39
|
}
|
|
@@ -8,7 +8,8 @@ exports.HandleIconComponent = void 0;
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _icons = require("../icons");
|
|
10
10
|
var HandleIconComponent = exports.HandleIconComponent = function HandleIconComponent(props) {
|
|
11
|
-
var
|
|
11
|
+
var canDrag = props.canDrag,
|
|
12
|
+
direction = props.direction,
|
|
12
13
|
isDragMenuOpen = props.isDragMenuOpen,
|
|
13
14
|
isRowHandleHovered = props.isRowHandleHovered,
|
|
14
15
|
isColumnHandleHovered = props.isColumnHandleHovered,
|
|
@@ -19,7 +20,8 @@ var HandleIconComponent = exports.HandleIconComponent = function HandleIconCompo
|
|
|
19
20
|
var isHandleHovered = isRowHandleHovered || isColumnHandleHovered;
|
|
20
21
|
var isCurrentRowOrColumnSelected = isCurrentRowSelected || isCurrentColumnSelected;
|
|
21
22
|
var isDragMenuOpenOnCurrentRowOrColumn = isDragMenuOpen && dragMenuDirection === direction && isCurrentRowOrColumnSelected;
|
|
22
|
-
var
|
|
23
|
+
var isDragPossible = canDrag && !hasMergedCells;
|
|
24
|
+
var showNormalHandle = !isDragPossible ? /*#__PURE__*/_react.default.createElement(_icons.DragHandleDisabledIcon, null) : /*#__PURE__*/_react.default.createElement(_icons.DragHandleIcon, null);
|
|
23
25
|
|
|
24
26
|
// hoverred handle or open drag menu
|
|
25
27
|
if (isHandleHovered || isDragMenuOpenOnCurrentRowOrColumn) {
|
|
@@ -35,7 +35,9 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
35
35
|
onMouseOut = _ref.onMouseOut,
|
|
36
36
|
_onMouseUp = _ref.onMouseUp,
|
|
37
37
|
onClick = _ref.onClick,
|
|
38
|
-
editorView = _ref.editorView
|
|
38
|
+
editorView = _ref.editorView,
|
|
39
|
+
_ref$canDrag = _ref.canDrag,
|
|
40
|
+
_canDrag = _ref$canDrag === void 0 ? false : _ref$canDrag;
|
|
39
41
|
var dragHandleDivRef = (0, _react.useRef)(null);
|
|
40
42
|
var _useState = (0, _react.useState)(null),
|
|
41
43
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
@@ -58,6 +60,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
58
60
|
return direction === 'row' ? (0, _utils2.hasMergedCellsInRow)(indexes[0])(selection) : (0, _utils2.hasMergedCellsInColumn)(indexes[0])(selection);
|
|
59
61
|
}, [indexes, direction, selection]);
|
|
60
62
|
var handleIconProps = {
|
|
63
|
+
canDrag: _canDrag,
|
|
61
64
|
hasMergedCells: hasMergedCells,
|
|
62
65
|
direction: direction,
|
|
63
66
|
isDragMenuOpen: isDragMenuOpen,
|
|
@@ -73,7 +76,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
73
76
|
return (0, _element.draggable)({
|
|
74
77
|
element: dragHandleDivRefCurrent,
|
|
75
78
|
canDrag: function canDrag() {
|
|
76
|
-
return !hasMergedCells;
|
|
79
|
+
return _canDrag && !hasMergedCells;
|
|
77
80
|
},
|
|
78
81
|
getInitialData: function getInitialData() {
|
|
79
82
|
return {
|
|
@@ -88,6 +91,15 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
88
91
|
getOffset: function getOffset(_ref3) {
|
|
89
92
|
var container = _ref3.container;
|
|
90
93
|
var rect = container.getBoundingClientRect();
|
|
94
|
+
if (_utils.browser.safari) {
|
|
95
|
+
// See: https://product-fabric.atlassian.net/browse/ED-21442
|
|
96
|
+
// We need to ensure that the preview is not overlaying screen content when the snapshot is taken, otherwise
|
|
97
|
+
// safari will composite the screen text elements into the bitmap snapshot. The container is a wrapper which is already
|
|
98
|
+
// positioned fixed at top/left 0.
|
|
99
|
+
// IMPORTANT: we must not exceed more then the width of the container off-screen otherwise not preview will
|
|
100
|
+
// be generated.
|
|
101
|
+
container.style.left = "-".concat(rect.width - 0.0001, "px");
|
|
102
|
+
}
|
|
91
103
|
if (direction === 'row') {
|
|
92
104
|
return {
|
|
93
105
|
x: 16,
|
|
@@ -112,9 +124,9 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
112
124
|
}
|
|
113
125
|
});
|
|
114
126
|
}
|
|
115
|
-
}, [tableLocalId, direction, indexes, editorView.state.selection, hasMergedCells]);
|
|
127
|
+
}, [tableLocalId, direction, indexes, editorView.state.selection, hasMergedCells, _canDrag]);
|
|
116
128
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("button", {
|
|
117
|
-
className: (0, _classnames2.default)(_types.TableCssClassName.DRAG_HANDLE_BUTTON_CONTAINER, appearance, (0, _defineProperty2.default)({}, _types.TableCssClassName.DRAG_HANDLE_DISABLED, hasMergedCells)),
|
|
129
|
+
className: (0, _classnames2.default)(_types.TableCssClassName.DRAG_HANDLE_BUTTON_CONTAINER, appearance, (0, _defineProperty2.default)({}, _types.TableCssClassName.DRAG_HANDLE_DISABLED, !_canDrag || hasMergedCells)),
|
|
118
130
|
ref: dragHandleDivRef,
|
|
119
131
|
style: {
|
|
120
132
|
transform: direction === 'column' ? 'none' : 'rotate(90deg)'
|
|
@@ -75,7 +75,8 @@ var DragMenu = exports.DragMenu = function DragMenu(_ref) {
|
|
|
75
75
|
boundariesElement = _ref.boundariesElement,
|
|
76
76
|
scrollableElement = _ref.scrollableElement,
|
|
77
77
|
targetCellPosition = _ref.targetCellPosition,
|
|
78
|
-
getEditorContainerWidth = _ref.getEditorContainerWidth
|
|
78
|
+
getEditorContainerWidth = _ref.getEditorContainerWidth,
|
|
79
|
+
canDrag = _ref.canDrag;
|
|
79
80
|
var tableMap = tableNode ? _tableMap.TableMap.get(tableNode) : undefined;
|
|
80
81
|
var state = editorView.state,
|
|
81
82
|
dispatch = editorView.dispatch;
|
|
@@ -83,7 +84,7 @@ var DragMenu = exports.DragMenu = function DragMenu(_ref) {
|
|
|
83
84
|
var selectionRect = (0, _utils.isSelectionType)(selection, 'cell') ? (0, _utils.getSelectionRect)(selection) : (0, _utils.findCellRectClosestToPos)(selection.$from);
|
|
84
85
|
var hasMergedCells = direction === 'row' ? _utils2.hasMergedCellsInRow : _utils2.hasMergedCellsInColumn;
|
|
85
86
|
var shouldMoveDisabled = index !== undefined && hasMergedCells(index)(selection);
|
|
86
|
-
var dragMenuConfig = (0, _dragMenu.getDragMenuConfig)(direction, getEditorContainerWidth, shouldMoveDisabled, tableMap, index, targetCellPosition, selectionRect);
|
|
87
|
+
var dragMenuConfig = (0, _dragMenu.getDragMenuConfig)(direction, getEditorContainerWidth, !!canDrag && !shouldMoveDisabled, tableMap, index, targetCellPosition, selectionRect);
|
|
87
88
|
var _convertToDropdownIte = convertToDropdownItems(dragMenuConfig),
|
|
88
89
|
menuItems = _convertToDropdownIte.menuItems,
|
|
89
90
|
menuCallback = _convertToDropdownIte.menuCallback;
|
|
@@ -23,7 +23,8 @@ var FloatingDragMenu = function FloatingDragMenu(_ref) {
|
|
|
23
23
|
direction = _ref.direction,
|
|
24
24
|
index = _ref.index,
|
|
25
25
|
targetCellPosition = _ref.targetCellPosition,
|
|
26
|
-
getEditorContainerWidth = _ref.getEditorContainerWidth
|
|
26
|
+
getEditorContainerWidth = _ref.getEditorContainerWidth,
|
|
27
|
+
canDrag = _ref.canDrag;
|
|
27
28
|
if (!isOpen || !targetCellPosition || editorView.state.doc.nodeSize <= targetCellPosition) {
|
|
28
29
|
return null;
|
|
29
30
|
}
|
|
@@ -58,7 +59,8 @@ var FloatingDragMenu = function FloatingDragMenu(_ref) {
|
|
|
58
59
|
direction: direction,
|
|
59
60
|
index: index,
|
|
60
61
|
targetCellPosition: targetCellPosition,
|
|
61
|
-
getEditorContainerWidth: getEditorContainerWidth
|
|
62
|
+
getEditorContainerWidth: getEditorContainerWidth,
|
|
63
|
+
canDrag: canDrag
|
|
62
64
|
}));
|
|
63
65
|
};
|
|
64
66
|
FloatingDragMenu.displayName = 'FloatingDragMenu';
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.default = exports.ColumnControls = void 0;
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _styles = require("@atlaskit/editor-common/styles");
|
|
9
10
|
var _editorTables = require("@atlaskit/editor-tables");
|
|
10
11
|
var _utils = require("@atlaskit/editor-tables/utils");
|
|
11
12
|
var _commands = require("../../../commands");
|
|
@@ -38,7 +39,8 @@ var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
|
|
|
38
39
|
rowHeights = _ref.rowHeights,
|
|
39
40
|
colWidths = _ref.colWidths,
|
|
40
41
|
hasHeaderColumn = _ref.hasHeaderColumn,
|
|
41
|
-
isTableHovered = _ref.isTableHovered
|
|
42
|
+
isTableHovered = _ref.isTableHovered,
|
|
43
|
+
canDrag = _ref.canDrag;
|
|
42
44
|
var widths = (_colWidths$map$join = colWidths === null || colWidths === void 0 ? void 0 : colWidths.map(function (width) {
|
|
43
45
|
return width ? "".concat(width - 1, "px") : '0px';
|
|
44
46
|
}).join(' ')) !== null && _colWidths$map$join !== void 0 ? _colWidths$map$join : '0px';
|
|
@@ -148,14 +150,15 @@ var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
|
|
|
148
150
|
direction: "column",
|
|
149
151
|
tableLocalId: localId || '',
|
|
150
152
|
indexes: colIndexes,
|
|
151
|
-
previewWidth: (_colWidths = colWidths === null || colWidths === void 0 ? void 0 : colWidths[colIndex]) !== null && _colWidths !== void 0 ? _colWidths :
|
|
153
|
+
previewWidth: (_colWidths = colWidths === null || colWidths === void 0 ? void 0 : colWidths[colIndex]) !== null && _colWidths !== void 0 ? _colWidths : _styles.tableCellMinWidth,
|
|
152
154
|
previewHeight: previewHeight,
|
|
153
155
|
appearance: selectedColIndexes.includes(hoveredCell.colIndex) ? isInDanger ? 'danger' : 'selected' : 'default',
|
|
154
156
|
onClick: handleClick,
|
|
155
157
|
onMouseOver: handleMouseOver,
|
|
156
158
|
onMouseOut: handleMouseOut,
|
|
157
159
|
onMouseUp: handleMouseUp,
|
|
158
|
-
editorView: editorView
|
|
160
|
+
editorView: editorView,
|
|
161
|
+
canDrag: canDrag
|
|
159
162
|
}))));
|
|
160
163
|
};
|
|
161
164
|
var _default = exports.default = ColumnControls;
|
|
@@ -29,7 +29,8 @@ var TableFloatingColumnControls = exports.TableFloatingColumnControls = function
|
|
|
29
29
|
stickyHeader = _ref.stickyHeader,
|
|
30
30
|
selection = _ref.selection,
|
|
31
31
|
isInDanger = _ref.isInDanger,
|
|
32
|
-
isTableHovered = _ref.isTableHovered
|
|
32
|
+
isTableHovered = _ref.isTableHovered,
|
|
33
|
+
canDrag = _ref.canDrag;
|
|
33
34
|
var _useState = (0, _react.useState)({
|
|
34
35
|
width: 0,
|
|
35
36
|
height: 0
|
|
@@ -120,7 +121,8 @@ var TableFloatingColumnControls = exports.TableFloatingColumnControls = function
|
|
|
120
121
|
isInDanger: isInDanger,
|
|
121
122
|
rowHeights: rowHeights,
|
|
122
123
|
colWidths: colWidths,
|
|
123
|
-
hasHeaderColumn: hasHeaderColumn
|
|
124
|
+
hasHeaderColumn: hasHeaderColumn,
|
|
125
|
+
canDrag: canDrag
|
|
124
126
|
}), hasDropTargets && /*#__PURE__*/_react.default.createElement(_ColumnDropTargets.ColumnDropTargets, {
|
|
125
127
|
tableRef: tableRef,
|
|
126
128
|
stickyTop: tableActive ? stickyTop : undefined,
|
|
@@ -43,6 +43,7 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
|
|
|
43
43
|
isInDanger = _ref.isInDanger,
|
|
44
44
|
isResizing = _ref.isResizing,
|
|
45
45
|
isTableHovered = _ref.isTableHovered,
|
|
46
|
+
canDrag = _ref.canDrag,
|
|
46
47
|
hoverRows = _ref.hoverRows,
|
|
47
48
|
selectRow = _ref.selectRow,
|
|
48
49
|
updateCellHoverLocation = _ref.updateCellHoverLocation;
|
|
@@ -142,11 +143,11 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
|
|
|
142
143
|
"data-end-index": endIndex,
|
|
143
144
|
className: _types.TableCssClassName.DRAG_ROW_FLOATING_INSERT_DOT_WRAPPER,
|
|
144
145
|
contentEditable: false,
|
|
145
|
-
key: index
|
|
146
|
+
key: "insert-dot-".concat(index)
|
|
146
147
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
147
148
|
className: _types.TableCssClassName.DRAG_ROW_FLOATING_INSERT_DOT
|
|
148
149
|
})), isDragging && /*#__PURE__*/_react.default.createElement(_RowDropTarget.default, {
|
|
149
|
-
key: index,
|
|
150
|
+
key: "drop-target-".concat(index),
|
|
150
151
|
index: index,
|
|
151
152
|
localId: currentNodeLocalId,
|
|
152
153
|
style: {
|
|
@@ -178,7 +179,8 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
|
|
|
178
179
|
onMouseOver: handleMouseOver,
|
|
179
180
|
onMouseOut: handleMouseOut,
|
|
180
181
|
onMouseUp: onMouseUp,
|
|
181
|
-
editorView: editorView
|
|
182
|
+
editorView: editorView,
|
|
183
|
+
canDrag: canDrag
|
|
182
184
|
})));
|
|
183
185
|
};
|
|
184
186
|
var DragControls = exports.DragControls = (0, _reactIntlNext.injectIntl)(DragControlsComponent);
|
|
@@ -136,8 +136,9 @@ var TableFloatingControls = exports.default = /*#__PURE__*/function (_Component)
|
|
|
136
136
|
headerRowHeight = _this$props2.headerRowHeight,
|
|
137
137
|
stickyHeader = _this$props2.stickyHeader,
|
|
138
138
|
hoveredCell = _this$props2.hoveredCell,
|
|
139
|
-
isTableHovered = _this$props2.isTableHovered
|
|
140
|
-
|
|
139
|
+
isTableHovered = _this$props2.isTableHovered,
|
|
140
|
+
canDrag = _this$props2.canDrag;
|
|
141
|
+
return this.state.tableWrapperWidth !== nextState.tableWrapperWidth || this.state.tableWrapperHeight !== nextState.tableWrapperHeight || ordering !== nextProps.ordering || tableRef !== nextProps.tableRef || tableActive !== nextProps.tableActive || isInDanger !== nextProps.isInDanger || isResizing !== nextProps.isResizing || hoveredRows !== nextProps.hoveredRows || isHeaderRowEnabled !== nextProps.isHeaderRowEnabled || isHeaderColumnEnabled !== nextProps.isHeaderColumnEnabled || isNumberColumnEnabled !== nextProps.isNumberColumnEnabled || (0, _utils2.isSelectionUpdated)(selection, nextProps.selection) || headerRowHeight !== nextProps.headerRowHeight || stickyHeader !== nextProps.stickyHeader || hoveredCell !== nextProps.hoveredCell || isTableHovered !== nextProps.isTableHovered || canDrag !== nextProps.canDrag;
|
|
141
142
|
}
|
|
142
143
|
}, {
|
|
143
144
|
key: "componentWillUnmount",
|
|
@@ -164,7 +165,8 @@ var TableFloatingControls = exports.default = /*#__PURE__*/function (_Component)
|
|
|
164
165
|
stickyHeader = _this$props3.stickyHeader,
|
|
165
166
|
isDragAndDropEnabled = _this$props3.isDragAndDropEnabled,
|
|
166
167
|
hoveredCell = _this$props3.hoveredCell,
|
|
167
|
-
isTableHovered = _this$props3.isTableHovered
|
|
168
|
+
isTableHovered = _this$props3.isTableHovered,
|
|
169
|
+
canDrag = _this$props3.canDrag;
|
|
168
170
|
if (!tableRef) {
|
|
169
171
|
return null;
|
|
170
172
|
}
|
|
@@ -206,7 +208,8 @@ var TableFloatingControls = exports.default = /*#__PURE__*/function (_Component)
|
|
|
206
208
|
tableWidth: this.state.tableWrapperWidth,
|
|
207
209
|
hoverRows: this.hoverRows,
|
|
208
210
|
selectRow: this.selectRow,
|
|
209
|
-
updateCellHoverLocation: this.updateCellHoverLocation
|
|
211
|
+
updateCellHoverLocation: this.updateCellHoverLocation,
|
|
212
|
+
canDrag: canDrag
|
|
210
213
|
})) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_CornerControls.CornerControls, {
|
|
211
214
|
editorView: editorView,
|
|
212
215
|
tableRef: tableRef,
|
|
@@ -30,7 +30,7 @@ var canIncrease = function canIncrease(index) {
|
|
|
30
30
|
var max = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
31
31
|
return index !== undefined && index < max;
|
|
32
32
|
};
|
|
33
|
-
var getDragMenuConfig = exports.getDragMenuConfig = function getDragMenuConfig(direction, getEditorContainerWidth,
|
|
33
|
+
var getDragMenuConfig = exports.getDragMenuConfig = function getDragMenuConfig(direction, getEditorContainerWidth, canDrag, tableMap, index, targetCellPosition, selectionRect) {
|
|
34
34
|
var addOptions = direction === 'row' ? [{
|
|
35
35
|
label: 'above',
|
|
36
36
|
offset: 0,
|
|
@@ -55,27 +55,31 @@ var getDragMenuConfig = exports.getDragMenuConfig = function getDragMenuConfig(d
|
|
|
55
55
|
var moveOptions = direction === 'row' ? [{
|
|
56
56
|
label: 'up',
|
|
57
57
|
offset: -1,
|
|
58
|
-
canMove:
|
|
58
|
+
canMove: function canMove(index) {
|
|
59
|
+
return canDrag && canDecrease(index);
|
|
60
|
+
},
|
|
59
61
|
icon: _arrowUp.default
|
|
60
62
|
}, {
|
|
61
63
|
label: 'down',
|
|
62
64
|
offset: 1,
|
|
63
65
|
canMove: function canMove(index) {
|
|
64
66
|
var _tableMap$height;
|
|
65
|
-
return canIncrease(index, ((_tableMap$height = tableMap === null || tableMap === void 0 ? void 0 : tableMap.height) !== null && _tableMap$height !== void 0 ? _tableMap$height : 0) - 1);
|
|
67
|
+
return canDrag && canIncrease(index, ((_tableMap$height = tableMap === null || tableMap === void 0 ? void 0 : tableMap.height) !== null && _tableMap$height !== void 0 ? _tableMap$height : 0) - 1);
|
|
66
68
|
},
|
|
67
69
|
icon: _arrowDown.default
|
|
68
70
|
}] : [{
|
|
69
71
|
label: 'left',
|
|
70
72
|
offset: -1,
|
|
71
|
-
canMove:
|
|
73
|
+
canMove: function canMove(index) {
|
|
74
|
+
return canDrag && canDecrease(index);
|
|
75
|
+
},
|
|
72
76
|
icon: _arrowLeft.default
|
|
73
77
|
}, {
|
|
74
78
|
label: 'right',
|
|
75
79
|
offset: 1,
|
|
76
80
|
canMove: function canMove(index) {
|
|
77
81
|
var _tableMap$width;
|
|
78
|
-
return canIncrease(index, ((_tableMap$width = tableMap === null || tableMap === void 0 ? void 0 : tableMap.width) !== null && _tableMap$width !== void 0 ? _tableMap$width : 0) - 1);
|
|
82
|
+
return canDrag && canIncrease(index, ((_tableMap$width = tableMap === null || tableMap === void 0 ? void 0 : tableMap.width) !== null && _tableMap$width !== void 0 ? _tableMap$width : 0) - 1);
|
|
79
83
|
},
|
|
80
84
|
icon: _arrowRight.default
|
|
81
85
|
}];
|
|
@@ -144,7 +148,7 @@ var getDragMenuConfig = exports.getDragMenuConfig = function getDragMenuConfig(d
|
|
|
144
148
|
return {
|
|
145
149
|
id: "move_".concat(direction, "_").concat(label),
|
|
146
150
|
title: "Move ".concat(direction, " ").concat(label),
|
|
147
|
-
disabled:
|
|
151
|
+
disabled: !canMove(index),
|
|
148
152
|
icon: icon,
|
|
149
153
|
onClick: function onClick(state, dispatch) {
|
|
150
154
|
if (canMove(index)) {
|
|
@@ -346,6 +346,7 @@ const tablesPlugin = ({
|
|
|
346
346
|
direction: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.dragMenuDirection,
|
|
347
347
|
index: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.dragMenuIndex,
|
|
348
348
|
isOpen: !!(dragAndDropState !== null && dragAndDropState !== void 0 && dragAndDropState.isDragMenuOpen) && !isResizing,
|
|
349
|
+
canDrag: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.canDrag,
|
|
349
350
|
getEditorContainerWidth: defaultGetEditorContainerWidth
|
|
350
351
|
}), allowControls && !isDragAndDropEnabled && !isResizing && /*#__PURE__*/React.createElement(FloatingDeleteButton, {
|
|
351
352
|
editorView: editorView,
|
|
@@ -517,7 +517,8 @@ class TableComponent extends React.Component {
|
|
|
517
517
|
options,
|
|
518
518
|
getPos,
|
|
519
519
|
pluginInjectionApi,
|
|
520
|
-
isDragAndDropEnabled
|
|
520
|
+
isDragAndDropEnabled,
|
|
521
|
+
canDrag
|
|
521
522
|
} = this.props;
|
|
522
523
|
const {
|
|
523
524
|
showBeforeShadow,
|
|
@@ -547,6 +548,7 @@ class TableComponent extends React.Component {
|
|
|
547
548
|
isNumberColumnEnabled: node.attrs.isNumberColumnEnabled,
|
|
548
549
|
isHeaderRowEnabled: isHeaderRowEnabled,
|
|
549
550
|
isDragAndDropEnabled: isDragAndDropEnabled,
|
|
551
|
+
canDrag: canDrag,
|
|
550
552
|
ordering: ordering,
|
|
551
553
|
isHeaderColumnEnabled: isHeaderColumnEnabled,
|
|
552
554
|
hasHeaderRow: hasHeaderRow
|
|
@@ -573,7 +575,8 @@ class TableComponent extends React.Component {
|
|
|
573
575
|
selection: view.state.selection,
|
|
574
576
|
headerRowHeight: headerRow ? headerRow.offsetHeight : undefined,
|
|
575
577
|
stickyHeader: this.state.stickyHeader,
|
|
576
|
-
getEditorFeatureFlags: this.props.getEditorFeatureFlags
|
|
578
|
+
getEditorFeatureFlags: this.props.getEditorFeatureFlags,
|
|
579
|
+
canDrag: canDrag
|
|
577
580
|
}) : null;
|
|
578
581
|
const shadowPadding = allowControls && tableActive ? -tableToolbarSize : tableMarginSides;
|
|
579
582
|
const shadowStyle = memoizeOne(visible => ({
|
|
@@ -7,6 +7,7 @@ import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
|
|
|
7
7
|
import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
|
|
8
8
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
9
9
|
import { pluginConfig as getPluginConfig } from '../create-plugin-config';
|
|
10
|
+
import { pluginKey as tableDragAndDropPluginKey } from '../pm-plugins/drag-and-drop';
|
|
10
11
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
11
12
|
import { pluginKey } from '../pm-plugins/plugin-key';
|
|
12
13
|
import { pluginKey as tableResizingPluginKey } from '../pm-plugins/table-resizing';
|
|
@@ -111,16 +112,19 @@ export default class TableView extends ReactNodeView {
|
|
|
111
112
|
tableResizingPluginState: tableResizingPluginKey,
|
|
112
113
|
tableWidthPluginState: tableWidthPluginKey,
|
|
113
114
|
widthPlugin: fakePluginKey,
|
|
114
|
-
mediaState: fakeMediaPluginKey
|
|
115
|
+
mediaState: fakeMediaPluginKey,
|
|
116
|
+
tableDragAndDropState: tableDragAndDropPluginKey
|
|
115
117
|
},
|
|
116
118
|
editorView: props.view,
|
|
117
119
|
render: pluginStates => {
|
|
120
|
+
var _tableDragAndDropStat;
|
|
118
121
|
const {
|
|
119
122
|
tableResizingPluginState,
|
|
120
123
|
tableWidthPluginState,
|
|
121
124
|
pluginState,
|
|
122
125
|
// containerWidth,
|
|
123
|
-
mediaState
|
|
126
|
+
mediaState,
|
|
127
|
+
tableDragAndDropState
|
|
124
128
|
} = pluginStates;
|
|
125
129
|
const containerWidth = props.getEditorContainerWidth();
|
|
126
130
|
const isTableResizing = tableWidthPluginState === null || tableWidthPluginState === void 0 ? void 0 : tableWidthPluginState.resizing;
|
|
@@ -149,6 +153,7 @@ export default class TableView extends ReactNodeView {
|
|
|
149
153
|
isHeaderRowEnabled: pluginState.isHeaderRowEnabled,
|
|
150
154
|
isHeaderColumnEnabled: pluginState.isHeaderColumnEnabled,
|
|
151
155
|
isDragAndDropEnabled: pluginState.isDragAndDropEnabled,
|
|
156
|
+
canDrag: (_tableDragAndDropStat = tableDragAndDropState === null || tableDragAndDropState === void 0 ? void 0 : tableDragAndDropState.canDrag) !== null && _tableDragAndDropStat !== void 0 ? _tableDragAndDropStat : false,
|
|
152
157
|
tableActive: tableActive,
|
|
153
158
|
ordering: pluginState.ordering,
|
|
154
159
|
isResizing: isResizing,
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export const DragAndDropActionType = {
|
|
2
2
|
SET_DROP_TARGET: 'SET_DROP_TARGET',
|
|
3
3
|
CLEAR_DROP_TARGET: 'CLEAR_DROP_TARGET',
|
|
4
|
-
TOGGLE_DRAG_MENU: 'TOGGLE_DRAG_MENU'
|
|
4
|
+
TOGGLE_DRAG_MENU: 'TOGGLE_DRAG_MENU',
|
|
5
|
+
UPDATE: 'UPDATE'
|
|
5
6
|
};
|
|
6
7
|
|
|
7
8
|
// NOTE: This should be a Union of all possible actions
|