@atlaskit/editor-plugin-table 5.4.19 → 5.4.21
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 +7 -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 +10 -8
- package/dist/cjs/plugins/table/ui/TableFloatingControls/index.js +7 -4
- package/dist/cjs/plugins/table/ui/common-styles.js +1 -1
- 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 +6 -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 +10 -8
- package/dist/es2019/plugins/table/ui/TableFloatingControls/index.js +7 -4
- package/dist/es2019/plugins/table/ui/common-styles.js +1 -2
- 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 +7 -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 +10 -8
- package/dist/esm/plugins/table/ui/TableFloatingControls/index.js +7 -4
- package/dist/esm/plugins/table/ui/common-styles.js +1 -1
- 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 +6 -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 +11 -8
- package/src/plugins/table/ui/TableFloatingControls/index.tsx +6 -1
- package/src/plugins/table/ui/common-styles.ts +1 -2
- 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.21
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#59392](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/59392) [`d0da8be30b97`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/d0da8be30b97) - Reduce width of drag handle to ensure it doesn't overlap editable space
|
|
8
|
+
|
|
9
|
+
## 5.4.20
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#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
|
|
14
|
+
|
|
3
15
|
## 5.4.19
|
|
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 {
|
|
@@ -121,9 +124,9 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
121
124
|
}
|
|
122
125
|
});
|
|
123
126
|
}
|
|
124
|
-
}, [tableLocalId, direction, indexes, editorView.state.selection, hasMergedCells]);
|
|
127
|
+
}, [tableLocalId, direction, indexes, editorView.state.selection, hasMergedCells, _canDrag]);
|
|
125
128
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("button", {
|
|
126
|
-
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)),
|
|
127
130
|
ref: dragHandleDivRef,
|
|
128
131
|
style: {
|
|
129
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;
|
|
@@ -123,7 +124,7 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
|
|
|
123
124
|
className: _types.TableCssClassName.DRAG_ROW_CONTROLS,
|
|
124
125
|
style: {
|
|
125
126
|
gridTemplateRows: heights,
|
|
126
|
-
gridTemplateColumns: isDragging ? "".concat(_consts.dropTargetExtendedWidth, "px
|
|
127
|
+
gridTemplateColumns: isDragging ? "".concat(_consts.dropTargetExtendedWidth, "px 14px ").concat(tableWidth, "px") : '0px 14px 0px',
|
|
127
128
|
left: isDragging ? "-".concat(_consts.dropTargetExtendedWidth + 2, "px") : "-2px"
|
|
128
129
|
},
|
|
129
130
|
onMouseMove: handleMouseMove,
|
|
@@ -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: {
|
|
@@ -162,10 +163,10 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
|
|
|
162
163
|
style: {
|
|
163
164
|
gridRow: gridRowPosition,
|
|
164
165
|
gridColumn: '2',
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
166
|
+
// DragHandle uses `transform: rotate(90)`, which doesn't affect its parent (this div) causing the width of this element to be the true height of the drag handle
|
|
167
|
+
width: '9px',
|
|
168
|
+
position: 'relative',
|
|
169
|
+
right: '-0.5px'
|
|
169
170
|
},
|
|
170
171
|
"data-testid": "table-floating-row-drag-handle"
|
|
171
172
|
}, /*#__PURE__*/_react.default.createElement(_DragHandle.DragHandle, {
|
|
@@ -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,
|