@atlaskit/editor-plugin-table 5.3.11 → 5.3.13
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 +14 -0
- package/dist/cjs/plugins/table/index.js +15 -2
- package/dist/cjs/plugins/table/nodeviews/TableComponent.js +2 -1
- package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/actions.js +2 -1
- package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/commands.js +27 -3
- package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/plugin.js +43 -7
- package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/reducer.js +6 -0
- package/dist/cjs/plugins/table/ui/DragHandle/index.js +2 -0
- package/dist/cjs/plugins/table/ui/FloatingDragMenu/DragMenu.js +80 -0
- package/dist/cjs/plugins/table/ui/FloatingDragMenu/index.js +60 -0
- package/dist/cjs/plugins/table/ui/FloatingInsertButton/InsertButton.js +5 -5
- package/dist/cjs/plugins/table/ui/FloatingInsertButton/getPopupOptions.js +2 -2
- package/dist/cjs/plugins/table/ui/FloatingInsertButton/index.js +1 -1
- package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +9 -7
- package/dist/cjs/plugins/table/ui/TableFloatingControls/index.js +2 -0
- package/dist/cjs/plugins/table/ui/consts.js +3 -2
- package/dist/cjs/plugins/table/utils/drag-menu.js +59 -0
- package/dist/es2019/plugins/table/index.js +15 -2
- package/dist/es2019/plugins/table/nodeviews/TableComponent.js +2 -1
- package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/actions.js +2 -1
- package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/commands.js +26 -3
- package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/plugin.js +42 -3
- package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/reducer.js +7 -0
- package/dist/es2019/plugins/table/ui/DragHandle/index.js +2 -0
- package/dist/es2019/plugins/table/ui/FloatingDragMenu/DragMenu.js +77 -0
- package/dist/es2019/plugins/table/ui/FloatingDragMenu/index.js +54 -0
- package/dist/es2019/plugins/table/ui/FloatingInsertButton/InsertButton.js +5 -5
- package/dist/es2019/plugins/table/ui/FloatingInsertButton/getPopupOptions.js +2 -2
- package/dist/es2019/plugins/table/ui/FloatingInsertButton/index.js +1 -1
- package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +10 -8
- package/dist/es2019/plugins/table/ui/TableFloatingControls/index.js +2 -0
- package/dist/es2019/plugins/table/ui/consts.js +2 -1
- package/dist/es2019/plugins/table/utils/drag-menu.js +44 -0
- package/dist/esm/plugins/table/index.js +15 -2
- package/dist/esm/plugins/table/nodeviews/TableComponent.js +2 -1
- package/dist/esm/plugins/table/pm-plugins/drag-and-drop/actions.js +2 -1
- package/dist/esm/plugins/table/pm-plugins/drag-and-drop/commands.js +27 -3
- package/dist/esm/plugins/table/pm-plugins/drag-and-drop/plugin.js +43 -7
- package/dist/esm/plugins/table/pm-plugins/drag-and-drop/reducer.js +6 -0
- package/dist/esm/plugins/table/ui/DragHandle/index.js +2 -0
- package/dist/esm/plugins/table/ui/FloatingDragMenu/DragMenu.js +73 -0
- package/dist/esm/plugins/table/ui/FloatingDragMenu/index.js +53 -0
- package/dist/esm/plugins/table/ui/FloatingInsertButton/InsertButton.js +5 -5
- package/dist/esm/plugins/table/ui/FloatingInsertButton/getPopupOptions.js +2 -2
- package/dist/esm/plugins/table/ui/FloatingInsertButton/index.js +1 -1
- package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +10 -8
- package/dist/esm/plugins/table/ui/TableFloatingControls/index.js +2 -0
- package/dist/esm/plugins/table/ui/consts.js +2 -1
- package/dist/esm/plugins/table/utils/drag-menu.js +52 -0
- package/dist/types/plugins/table/pm-plugins/drag-and-drop/actions.d.ts +8 -1
- package/dist/types/plugins/table/pm-plugins/drag-and-drop/commands.d.ts +2 -1
- package/dist/types/plugins/table/pm-plugins/drag-and-drop/types.d.ts +4 -0
- package/dist/types/plugins/table/types.d.ts +1 -0
- package/dist/types/plugins/table/ui/DragHandle/index.d.ts +4 -2
- package/dist/types/plugins/table/ui/DragPreview/index.d.ts +2 -1
- package/dist/types/plugins/table/ui/FloatingDeleteButton/index.d.ts +2 -1
- package/dist/types/plugins/table/ui/FloatingDeleteButton/types.d.ts +2 -1
- package/dist/types/plugins/table/ui/FloatingDragMenu/DragMenu.d.ts +19 -0
- package/dist/types/plugins/table/ui/FloatingDragMenu/index.d.ts +21 -0
- package/dist/types/plugins/table/ui/FloatingInsertButton/InsertButton.d.ts +2 -1
- package/dist/types/plugins/table/ui/FloatingInsertButton/getPopupOptions.d.ts +2 -1
- package/dist/types/plugins/table/ui/FloatingInsertButton/index.d.ts +4 -5
- package/dist/types/plugins/table/ui/TableFloatingControls/RowControls/DragControls.d.ts +2 -0
- package/dist/types/plugins/table/ui/TableFloatingControls/index.d.ts +3 -0
- package/dist/types/plugins/table/ui/consts.d.ts +1 -0
- package/dist/types/plugins/table/utils/drag-menu.d.ts +7 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/actions.d.ts +8 -1
- package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/commands.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/types.d.ts +4 -0
- package/dist/types-ts4.5/plugins/table/types.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/ui/DragHandle/index.d.ts +4 -2
- package/dist/types-ts4.5/plugins/table/ui/DragPreview/index.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/ui/FloatingDeleteButton/index.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/ui/FloatingDeleteButton/types.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/ui/FloatingDragMenu/DragMenu.d.ts +19 -0
- package/dist/types-ts4.5/plugins/table/ui/FloatingDragMenu/index.d.ts +21 -0
- package/dist/types-ts4.5/plugins/table/ui/FloatingInsertButton/InsertButton.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/ui/FloatingInsertButton/getPopupOptions.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/ui/FloatingInsertButton/index.d.ts +4 -5
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/RowControls/DragControls.d.ts +2 -0
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/index.d.ts +3 -0
- package/dist/types-ts4.5/plugins/table/ui/consts.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/utils/drag-menu.d.ts +7 -0
- package/package.json +3 -3
- package/src/plugins/table/index.tsx +16 -0
- package/src/plugins/table/nodeviews/TableComponent.tsx +2 -1
- package/src/plugins/table/pm-plugins/drag-and-drop/actions.ts +14 -1
- package/src/plugins/table/pm-plugins/drag-and-drop/commands.ts +43 -4
- package/src/plugins/table/pm-plugins/drag-and-drop/plugin.ts +41 -2
- package/src/plugins/table/pm-plugins/drag-and-drop/reducer.ts +7 -0
- package/src/plugins/table/pm-plugins/drag-and-drop/types.ts +5 -0
- package/src/plugins/table/types.ts +2 -0
- package/src/plugins/table/ui/DragHandle/index.tsx +5 -1
- package/src/plugins/table/ui/DragPreview/index.tsx +2 -1
- package/src/plugins/table/ui/FloatingDeleteButton/index.tsx +2 -1
- package/src/plugins/table/ui/FloatingDeleteButton/types.ts +3 -1
- package/src/plugins/table/ui/FloatingDragMenu/DragMenu.tsx +99 -0
- package/src/plugins/table/ui/FloatingDragMenu/index.tsx +84 -0
- package/src/plugins/table/ui/FloatingInsertButton/InsertButton.tsx +8 -7
- package/src/plugins/table/ui/FloatingInsertButton/getPopupOptions.ts +3 -2
- package/src/plugins/table/ui/FloatingInsertButton/index.tsx +10 -7
- package/src/plugins/table/ui/TableFloatingControls/RowControls/DragControls.tsx +16 -7
- package/src/plugins/table/ui/TableFloatingControls/index.tsx +5 -0
- package/src/plugins/table/ui/consts.ts +2 -0
- package/src/plugins/table/utils/drag-menu.ts +65 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 5.3.13
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#41846](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/41846) [`7fe6ab0832b`](https://bitbucket.org/atlassian/atlassian-frontend/commits/7fe6ab0832b) - [ux] Add utility function to create drag menu content and integrate with row control behind platform.editor.table.drag-and-drop FF
|
|
8
|
+
- [#42137](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/42137) [`88058fc0fcb`](https://bitbucket.org/atlassian/atlassian-frontend/commits/88058fc0fcb) - ED-20197 moved editor preset and other prod code out of labs
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 5.3.12
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [#42109](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/42109) [`d25ae495fed`](https://bitbucket.org/atlassian/atlassian-frontend/commits/d25ae495fed) - [ux] Adds a fix to keep selection on a dropped row or column.
|
|
16
|
+
|
|
3
17
|
## 5.3.11
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -35,6 +35,7 @@ var _toolbar = require("./toolbar");
|
|
|
35
35
|
var _FloatingContextualButton = _interopRequireDefault(require("./ui/FloatingContextualButton"));
|
|
36
36
|
var _FloatingContextualMenu = _interopRequireDefault(require("./ui/FloatingContextualMenu"));
|
|
37
37
|
var _FloatingDeleteButton = _interopRequireDefault(require("./ui/FloatingDeleteButton"));
|
|
38
|
+
var _FloatingDragMenu = _interopRequireDefault(require("./ui/FloatingDragMenu"));
|
|
38
39
|
var _FloatingInsertButton = _interopRequireDefault(require("./ui/FloatingInsertButton"));
|
|
39
40
|
var _LayoutButton = _interopRequireDefault(require("./ui/LayoutButton"));
|
|
40
41
|
var _utils3 = require("./utils");
|
|
@@ -256,7 +257,8 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
256
257
|
var resizingPluginState = _ref13.tableResizingPluginState,
|
|
257
258
|
stickyHeadersState = _ref13.stickyHeadersState,
|
|
258
259
|
tablePluginState = _ref13.tablePluginState,
|
|
259
|
-
tableWidthPluginState = _ref13.tableWidthPluginState
|
|
260
|
+
tableWidthPluginState = _ref13.tableWidthPluginState,
|
|
261
|
+
dragAndDropState = _ref13.dragAndDropState;
|
|
260
262
|
var state = editorView.state;
|
|
261
263
|
var isColumnResizing = resizingPluginState === null || resizingPluginState === void 0 ? void 0 : resizingPluginState.dragging;
|
|
262
264
|
var isTableResizing = tableWidthPluginState === null || tableWidthPluginState === void 0 ? void 0 : tableWidthPluginState.resizing;
|
|
@@ -273,7 +275,8 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
273
275
|
insertRowButtonIndex = _ref14.insertRowButtonIndex,
|
|
274
276
|
isHeaderColumnEnabled = _ref14.isHeaderColumnEnabled,
|
|
275
277
|
isHeaderRowEnabled = _ref14.isHeaderRowEnabled,
|
|
276
|
-
tableWrapperTarget = _ref14.tableWrapperTarget
|
|
278
|
+
tableWrapperTarget = _ref14.tableWrapperTarget,
|
|
279
|
+
isDragAndDropEnabled = _ref14.isDragAndDropEnabled;
|
|
277
280
|
var allowControls = pluginConfig.allowControls;
|
|
278
281
|
var stickyHeader = stickyHeadersState ? (0, _stickyHeaders.findStickyHeaderForTable)(stickyHeadersState, tablePos) : undefined;
|
|
279
282
|
var LayoutContent = options && !options.tableResizingEnabled && (0, _utils3.isLayoutSupported)(state) && options.breakoutEnabled ? /*#__PURE__*/_react.default.createElement(_LayoutButton.default, {
|
|
@@ -324,6 +327,16 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
324
327
|
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
325
328
|
getEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
326
329
|
getEditorFeatureFlags: (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags
|
|
330
|
+
}), isDragAndDropEnabled && /*#__PURE__*/_react.default.createElement(_FloatingDragMenu.default, {
|
|
331
|
+
editorView: editorView,
|
|
332
|
+
mountPoint: popupsMountPoint,
|
|
333
|
+
boundariesElement: popupsBoundariesElement,
|
|
334
|
+
tableRef: tableRef,
|
|
335
|
+
tableNode: tableNode,
|
|
336
|
+
targetCellPosition: targetCellPosition,
|
|
337
|
+
direction: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.dragMenuDirection,
|
|
338
|
+
index: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.dragMenuIndex,
|
|
339
|
+
isOpen: !!(dragAndDropState !== null && dragAndDropState !== void 0 && dragAndDropState.isDragMenuOpen) && !isResizing
|
|
327
340
|
}), allowControls && !isResizing && /*#__PURE__*/_react.default.createElement(_FloatingDeleteButton.default, {
|
|
328
341
|
editorView: editorView,
|
|
329
342
|
selection: editorView.state.selection,
|
|
@@ -479,6 +479,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
479
479
|
}, /*#__PURE__*/_react.default.createElement(_TableFloatingControls.default, {
|
|
480
480
|
editorView: view,
|
|
481
481
|
tableRef: tableRef,
|
|
482
|
+
tableNode: node,
|
|
482
483
|
tableActive: tableActive,
|
|
483
484
|
hoveredRows: hoveredRows,
|
|
484
485
|
hoveredCell: hoveredCell,
|
|
@@ -486,7 +487,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
486
487
|
isResizing: isResizing,
|
|
487
488
|
isNumberColumnEnabled: node.attrs.isNumberColumnEnabled,
|
|
488
489
|
isHeaderRowEnabled: isHeaderRowEnabled,
|
|
489
|
-
isDragAndDropEnabled:
|
|
490
|
+
isDragAndDropEnabled: isDragAndDropEnabled,
|
|
490
491
|
ordering: ordering,
|
|
491
492
|
isHeaderColumnEnabled: isHeaderColumnEnabled,
|
|
492
493
|
hasHeaderRow: hasHeaderRow
|
|
@@ -6,7 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.DragAndDropActionType = void 0;
|
|
7
7
|
var DragAndDropActionType = exports.DragAndDropActionType = {
|
|
8
8
|
SET_DROP_TARGET: 'SET_DROP_TARGET',
|
|
9
|
-
CLEAR_DROP_TARGET: 'CLEAR_DROP_TARGET'
|
|
9
|
+
CLEAR_DROP_TARGET: 'CLEAR_DROP_TARGET',
|
|
10
|
+
TOGGLE_DRAG_MENU: 'TOGGLE_DRAG_MENU'
|
|
10
11
|
};
|
|
11
12
|
|
|
12
13
|
// NOTE: This should be a Union of all possible actions
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.updatePluginStateDecorations = exports.setDropTarget = exports.moveSource = exports.getDecorations = exports.clearDropTarget = void 0;
|
|
6
|
+
exports.updatePluginStateDecorations = exports.toggleDragMenu = exports.setDropTarget = exports.moveSource = exports.getDecorations = exports.clearDropTarget = void 0;
|
|
7
7
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
8
8
|
var _utils = require("@atlaskit/editor-tables/utils");
|
|
9
9
|
var _types = require("../../types");
|
|
@@ -76,7 +76,31 @@ var moveSource = exports.moveSource = function moveSource(sourceType, sourceInde
|
|
|
76
76
|
if (sourceIndex === targetIndex) {
|
|
77
77
|
return tr.setMeta('addToHistory', false);
|
|
78
78
|
}
|
|
79
|
-
var
|
|
80
|
-
|
|
79
|
+
var isTableRow = sourceType === 'table-row';
|
|
80
|
+
var move = isTableRow ? _utils.moveRow : _utils.moveColumn;
|
|
81
|
+
var newTr = move(sourceIndex, targetIndex)(tr);
|
|
82
|
+
var select = isTableRow ? _utils.selectRow : _utils.selectColumn;
|
|
83
|
+
return select(targetIndex)(newTr);
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
var toggleDragMenu = exports.toggleDragMenu = function toggleDragMenu(isDragMenuOpen, direction, index) {
|
|
87
|
+
return (0, _pluginFactory.createCommand)(function (state) {
|
|
88
|
+
var _getPluginState3 = (0, _pluginFactory.getPluginState)(state),
|
|
89
|
+
previousOpenState = _getPluginState3.isDragMenuOpen,
|
|
90
|
+
dragMenuDirection = _getPluginState3.dragMenuDirection,
|
|
91
|
+
dragMenuIndex = _getPluginState3.dragMenuIndex;
|
|
92
|
+
if (previousOpenState === isDragMenuOpen) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
type: _actions.DragAndDropActionType.TOGGLE_DRAG_MENU,
|
|
97
|
+
data: {
|
|
98
|
+
isDragMenuOpen: isDragMenuOpen === undefined ? !previousOpenState : isDragMenuOpen,
|
|
99
|
+
direction: direction !== null && direction !== void 0 ? direction : dragMenuDirection,
|
|
100
|
+
index: index !== null && index !== void 0 ? index : dragMenuIndex
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
}, function (tr) {
|
|
104
|
+
return tr.setMeta('addToHistory', false);
|
|
81
105
|
});
|
|
82
106
|
};
|
|
@@ -8,9 +8,11 @@ exports.createPlugin = void 0;
|
|
|
8
8
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
9
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
10
10
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
11
|
+
var _utils = require("@atlaskit/editor-tables/utils");
|
|
11
12
|
var _element = require("@atlaskit/pragmatic-drag-and-drop/adapter/element");
|
|
12
13
|
var _mergedCells = require("../../utils/merged-cells");
|
|
13
14
|
var _pluginFactory = require("../plugin-factory");
|
|
15
|
+
var _actions = require("./actions");
|
|
14
16
|
var _commands = require("./commands");
|
|
15
17
|
var _consts = require("./consts");
|
|
16
18
|
var _pluginFactory2 = require("./plugin-factory");
|
|
@@ -21,13 +23,47 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, eventD
|
|
|
21
23
|
state: (0, _pluginFactory2.createPluginState)(dispatch, function (state) {
|
|
22
24
|
return {
|
|
23
25
|
decorationSet: _view.DecorationSet.empty,
|
|
24
|
-
// TODO: This is example placeholder state. We could use this to track which row/col is currently set as the drop target
|
|
25
|
-
// This would result in a blue highlight being displayed on the corrisponding row/column to single the drop target location.
|
|
26
26
|
dropTargetType: _consts.DropTargetType.NONE,
|
|
27
|
-
dropTargetIndex: 0
|
|
27
|
+
dropTargetIndex: 0,
|
|
28
|
+
isDragMenuOpen: false,
|
|
29
|
+
dragMenuIndex: 0
|
|
28
30
|
};
|
|
29
31
|
}),
|
|
30
32
|
key: _pluginKey.pluginKey,
|
|
33
|
+
appendTransaction: function appendTransaction(transactions, oldState, newState) {
|
|
34
|
+
var _getTablePluginState = (0, _pluginFactory.getPluginState)(oldState),
|
|
35
|
+
oldTargetCellPosition = _getTablePluginState.targetCellPosition;
|
|
36
|
+
var _getTablePluginState2 = (0, _pluginFactory.getPluginState)(newState),
|
|
37
|
+
newTargetCellPosition = _getTablePluginState2.targetCellPosition;
|
|
38
|
+
var _getPluginState = (0, _pluginFactory2.getPluginState)(newState),
|
|
39
|
+
isDragMenuOpen = _getPluginState.isDragMenuOpen,
|
|
40
|
+
dragMenuIndex = _getPluginState.dragMenuIndex;
|
|
41
|
+
|
|
42
|
+
// What's happening here? you asked... In a nutshell;
|
|
43
|
+
// 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.
|
|
44
|
+
// This will stop the drag menu from moving around the screen to different row/cols. Too achieve this we need
|
|
45
|
+
// to check if the new target cell position is pointed at a different cell than what the drag menu was opened on.
|
|
46
|
+
if (oldTargetCellPosition !== newTargetCellPosition) {
|
|
47
|
+
if (isDragMenuOpen) {
|
|
48
|
+
var tr = newState.tr;
|
|
49
|
+
var action = {
|
|
50
|
+
type: _actions.DragAndDropActionType.TOGGLE_DRAG_MENU,
|
|
51
|
+
data: {
|
|
52
|
+
isDragMenuOpen: false,
|
|
53
|
+
direction: undefined
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
if (newTargetCellPosition !== undefined) {
|
|
57
|
+
var cells = (0, _utils.getCellsInRow)(dragMenuIndex)(tr.selection);
|
|
58
|
+
if (cells && cells.length && cells[0].node !== tr.doc.nodeAt(newTargetCellPosition)) {
|
|
59
|
+
return tr.setMeta(_pluginKey.pluginKey, action);
|
|
60
|
+
} // else NOP
|
|
61
|
+
} else {
|
|
62
|
+
return tr.setMeta(_pluginKey.pluginKey, action);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
},
|
|
31
67
|
view: function view(editorView) {
|
|
32
68
|
return {
|
|
33
69
|
destroy: (0, _element.monitorForElements)({
|
|
@@ -45,8 +81,8 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, eventD
|
|
|
45
81
|
indexes.length !== 1 || !(type === 'table-row' || type === 'table-column')) {
|
|
46
82
|
return false;
|
|
47
83
|
}
|
|
48
|
-
var
|
|
49
|
-
tableNode =
|
|
84
|
+
var _getTablePluginState3 = (0, _pluginFactory.getPluginState)(editorView.state),
|
|
85
|
+
tableNode = _getTablePluginState3.tableNode;
|
|
50
86
|
// If the draggable localId is the same as the current selected table localId then we will allow the monitor
|
|
51
87
|
// watch for changes
|
|
52
88
|
return localId === (tableNode === null || tableNode === void 0 ? void 0 : tableNode.attrs.localId);
|
|
@@ -94,8 +130,8 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, eventD
|
|
|
94
130
|
},
|
|
95
131
|
props: {
|
|
96
132
|
decorations: function decorations(state) {
|
|
97
|
-
var
|
|
98
|
-
decorationSet =
|
|
133
|
+
var _getPluginState2 = (0, _pluginFactory2.getPluginState)(state),
|
|
134
|
+
decorationSet = _getPluginState2.decorationSet;
|
|
99
135
|
return decorationSet;
|
|
100
136
|
}
|
|
101
137
|
}
|
|
@@ -24,6 +24,12 @@ var _default = exports.default = function _default(pluginState, action) {
|
|
|
24
24
|
dropTargetType: _consts.DropTargetType.NONE,
|
|
25
25
|
dropTargetIndex: 0
|
|
26
26
|
});
|
|
27
|
+
case _actions.DragAndDropActionType.TOGGLE_DRAG_MENU:
|
|
28
|
+
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
29
|
+
isDragMenuOpen: action.data.isDragMenuOpen,
|
|
30
|
+
dragMenuDirection: action.data.direction,
|
|
31
|
+
dragMenuIndex: action.data.index
|
|
32
|
+
});
|
|
27
33
|
default:
|
|
28
34
|
return pluginState;
|
|
29
35
|
}
|
|
@@ -28,6 +28,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
28
28
|
previewHeight = _ref.previewHeight,
|
|
29
29
|
onMouseOver = _ref.onMouseOver,
|
|
30
30
|
onMouseOut = _ref.onMouseOut,
|
|
31
|
+
onMouseUp = _ref.onMouseUp,
|
|
31
32
|
onClick = _ref.onClick;
|
|
32
33
|
var dragHandleDivRef = (0, _react.useRef)(null);
|
|
33
34
|
var _useState = (0, _react.useState)(null),
|
|
@@ -87,6 +88,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
87
88
|
"data-testid": "table-floating-column-controls-drag-handle",
|
|
88
89
|
onMouseOver: onMouseOver,
|
|
89
90
|
onMouseOut: onMouseOut,
|
|
91
|
+
onMouseUp: onMouseUp,
|
|
90
92
|
onClick: onClick
|
|
91
93
|
}, /*#__PURE__*/_react.default.createElement(_icons.DragHandleIcon, null), previewContainer && previewWidth !== undefined && previewHeight !== undefined && /*#__PURE__*/_reactDom.default.createPortal( /*#__PURE__*/_react.default.createElement(_DragPreview.DragPreview, {
|
|
92
94
|
direction: direction,
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.DragMenu = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _uiMenu = require("@atlaskit/editor-common/ui-menu");
|
|
10
|
+
var _tableMap = require("@atlaskit/editor-tables/table-map");
|
|
11
|
+
var _commands = require("../../pm-plugins/drag-and-drop/commands");
|
|
12
|
+
var _dragMenu = require("../../utils/drag-menu");
|
|
13
|
+
var _consts = require("../consts");
|
|
14
|
+
var convertToDropdownItems = function convertToDropdownItems(dragMenuConfig) {
|
|
15
|
+
var menuItems = [];
|
|
16
|
+
var menuCallback = {};
|
|
17
|
+
dragMenuConfig.forEach(function (item) {
|
|
18
|
+
menuItems.push({
|
|
19
|
+
key: item.id,
|
|
20
|
+
content: item.title,
|
|
21
|
+
value: {
|
|
22
|
+
name: item.id
|
|
23
|
+
},
|
|
24
|
+
isDisabled: item.disabled
|
|
25
|
+
});
|
|
26
|
+
item.onClick && (menuCallback[item.id] = item.onClick);
|
|
27
|
+
});
|
|
28
|
+
return {
|
|
29
|
+
menuItems: menuItems,
|
|
30
|
+
menuCallback: menuCallback
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
var DragMenu = exports.DragMenu = function DragMenu(_ref) {
|
|
34
|
+
var _ref$direction = _ref.direction,
|
|
35
|
+
direction = _ref$direction === void 0 ? 'row' : _ref$direction,
|
|
36
|
+
index = _ref.index,
|
|
37
|
+
isOpen = _ref.isOpen,
|
|
38
|
+
editorView = _ref.editorView,
|
|
39
|
+
tableNode = _ref.tableNode,
|
|
40
|
+
mountPoint = _ref.mountPoint,
|
|
41
|
+
boundariesElement = _ref.boundariesElement,
|
|
42
|
+
scrollableElement = _ref.scrollableElement;
|
|
43
|
+
var tableMap = tableNode ? _tableMap.TableMap.get(tableNode) : undefined;
|
|
44
|
+
var dragMenuConfig = (0, _dragMenu.getDragMenuConfig)(direction, tableMap, index);
|
|
45
|
+
var _convertToDropdownIte = convertToDropdownItems(dragMenuConfig),
|
|
46
|
+
menuItems = _convertToDropdownIte.menuItems,
|
|
47
|
+
menuCallback = _convertToDropdownIte.menuCallback;
|
|
48
|
+
var closeMenu = function closeMenu() {
|
|
49
|
+
var state = editorView.state,
|
|
50
|
+
dispatch = editorView.dispatch;
|
|
51
|
+
(0, _commands.toggleDragMenu)(false)(state, dispatch);
|
|
52
|
+
};
|
|
53
|
+
var onMenuItemActivated = function onMenuItemActivated(_ref2) {
|
|
54
|
+
var _menuCallback$item$va;
|
|
55
|
+
var item = _ref2.item;
|
|
56
|
+
(_menuCallback$item$va = menuCallback[item.value.name]) === null || _menuCallback$item$va === void 0 || _menuCallback$item$va.call(menuCallback, editorView.state, editorView.dispatch);
|
|
57
|
+
closeMenu();
|
|
58
|
+
};
|
|
59
|
+
if (!menuItems) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
return /*#__PURE__*/_react.default.createElement(_uiMenu.DropdownMenu, {
|
|
63
|
+
mountTo: mountPoint
|
|
64
|
+
//This needs be removed when the a11y is completely handled
|
|
65
|
+
//Disabling key navigation now as it works only partially
|
|
66
|
+
,
|
|
67
|
+
arrowKeyNavigationProviderOptions: {
|
|
68
|
+
type: _uiMenu.ArrowKeyNavigationType.MENU,
|
|
69
|
+
disableArrowKeyNavigation: true
|
|
70
|
+
},
|
|
71
|
+
items: [{
|
|
72
|
+
items: menuItems
|
|
73
|
+
}],
|
|
74
|
+
isOpen: isOpen,
|
|
75
|
+
onOpenChange: closeMenu,
|
|
76
|
+
onItemActivated: onMenuItemActivated,
|
|
77
|
+
fitWidth: _consts.dragMenuDropdownWidth,
|
|
78
|
+
boundariesElement: boundariesElement
|
|
79
|
+
});
|
|
80
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _ui = require("@atlaskit/editor-common/ui");
|
|
10
|
+
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
11
|
+
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
12
|
+
var _consts = require("../consts");
|
|
13
|
+
var _DragMenu = require("./DragMenu");
|
|
14
|
+
var FloatingDragMenu = function FloatingDragMenu(_ref) {
|
|
15
|
+
var mountPoint = _ref.mountPoint,
|
|
16
|
+
boundariesElement = _ref.boundariesElement,
|
|
17
|
+
scrollableElement = _ref.scrollableElement,
|
|
18
|
+
editorView = _ref.editorView,
|
|
19
|
+
isOpen = _ref.isOpen,
|
|
20
|
+
tableRef = _ref.tableRef,
|
|
21
|
+
tableNode = _ref.tableNode,
|
|
22
|
+
direction = _ref.direction,
|
|
23
|
+
index = _ref.index,
|
|
24
|
+
targetCellPosition = _ref.targetCellPosition;
|
|
25
|
+
if (!isOpen || !targetCellPosition || editorView.state.doc.nodeSize <= targetCellPosition) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
var domAtPos = editorView.domAtPos.bind(editorView);
|
|
29
|
+
var targetCellRef = (0, _utils.findDomRefAtPos)(targetCellPosition, domAtPos);
|
|
30
|
+
if (!targetCellRef) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// TODO: we will need to adjust the alignment and offset values depending on whether this is a row or column menu.
|
|
35
|
+
return /*#__PURE__*/_react.default.createElement(_ui.Popup, {
|
|
36
|
+
alignX: "left",
|
|
37
|
+
alignY: "top",
|
|
38
|
+
target: targetCellRef,
|
|
39
|
+
mountTo: mountPoint,
|
|
40
|
+
boundariesElement: boundariesElement,
|
|
41
|
+
scrollableElement: scrollableElement,
|
|
42
|
+
fitWidth: _consts.dragMenuDropdownWidth
|
|
43
|
+
// z-index value below is to ensure that this menu is above other floating menu
|
|
44
|
+
// in table, but below floating dialogs like typeaheads, pickers, etc.
|
|
45
|
+
,
|
|
46
|
+
zIndex: _editorSharedStyles.akEditorFloatingOverlapPanelZIndex,
|
|
47
|
+
forcePlacement: true,
|
|
48
|
+
offset: [7, 0],
|
|
49
|
+
stick: true
|
|
50
|
+
}, /*#__PURE__*/_react.default.createElement(_DragMenu.DragMenu, {
|
|
51
|
+
editorView: editorView,
|
|
52
|
+
isOpen: isOpen,
|
|
53
|
+
boundariesElement: boundariesElement,
|
|
54
|
+
tableNode: tableNode,
|
|
55
|
+
direction: direction,
|
|
56
|
+
index: index
|
|
57
|
+
}));
|
|
58
|
+
};
|
|
59
|
+
FloatingDragMenu.displayName = 'FloatingDragMenu';
|
|
60
|
+
var _default = exports.default = FloatingDragMenu;
|
|
@@ -50,13 +50,13 @@ var tooltipMessageByType = function tooltipMessageByType(type) {
|
|
|
50
50
|
var InsertButton = function InsertButton(_ref2) {
|
|
51
51
|
var onMouseDown = _ref2.onMouseDown,
|
|
52
52
|
tableRef = _ref2.tableRef,
|
|
53
|
-
|
|
53
|
+
direction = _ref2.direction,
|
|
54
54
|
formatMessage = _ref2.intl.formatMessage,
|
|
55
55
|
hasStickyHeaders = _ref2.hasStickyHeaders;
|
|
56
56
|
var content = /*#__PURE__*/_react.default.createElement(_tooltip.default, {
|
|
57
57
|
content: /*#__PURE__*/_react.default.createElement(_keymaps.ToolTipContent, {
|
|
58
|
-
description: formatMessage(tooltipMessageByType(
|
|
59
|
-
keymap:
|
|
58
|
+
description: formatMessage(tooltipMessageByType(direction)),
|
|
59
|
+
keymap: direction === 'row' ? _keymaps.addRowAfter : _keymaps.addColumnAfter
|
|
60
60
|
}),
|
|
61
61
|
position: "top"
|
|
62
62
|
}, /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -73,13 +73,13 @@ var InsertButton = function InsertButton(_ref2) {
|
|
|
73
73
|
fillRule: "evenodd"
|
|
74
74
|
})))), /*#__PURE__*/_react.default.createElement("div", {
|
|
75
75
|
className: _types.TableCssClassName.CONTROLS_INSERT_LINE,
|
|
76
|
-
style:
|
|
76
|
+
style: direction === 'row' ? {
|
|
77
77
|
width: getInsertLineWidth(tableRef)
|
|
78
78
|
} : {
|
|
79
79
|
height: getInsertLineHeight(tableRef, hasStickyHeaders)
|
|
80
80
|
}
|
|
81
81
|
})));
|
|
82
|
-
var floatingButtonClassName =
|
|
82
|
+
var floatingButtonClassName = direction === 'column' ? _types.TableCssClassName.CONTROLS_FLOATING_BUTTON_COLUMN : _types.TableCssClassName.CONTROLS_FLOATING_BUTTON_ROW;
|
|
83
83
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
84
84
|
className: floatingButtonClassName
|
|
85
85
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -77,8 +77,8 @@ function getColumnOptions(index, tableContainer, hasNumberedColumns) {
|
|
|
77
77
|
}
|
|
78
78
|
return options;
|
|
79
79
|
}
|
|
80
|
-
function getPopupOptions(
|
|
81
|
-
switch (
|
|
80
|
+
function getPopupOptions(direction, index, hasNumberedColumns, tableContainer) {
|
|
81
|
+
switch (direction) {
|
|
82
82
|
case 'column':
|
|
83
83
|
return getColumnOptions(index, tableContainer, hasNumberedColumns);
|
|
84
84
|
case 'row':
|
|
@@ -131,7 +131,7 @@ var FloatingInsertButton = exports.FloatingInsertButton = /*#__PURE__*/function
|
|
|
131
131
|
}, (0, _getPopupOptions.default)(type, index, hasNumberedColumns, tableContainerWrapper), {
|
|
132
132
|
zIndex: zIndex
|
|
133
133
|
}), /*#__PURE__*/_react.default.createElement(_InsertButton.default, {
|
|
134
|
-
|
|
134
|
+
direction: type,
|
|
135
135
|
tableRef: tableRef,
|
|
136
136
|
onMouseDown: type === 'column' ? this.insertColumn : this.insertRow,
|
|
137
137
|
hasStickyHeaders: this.props.hasStickyHeaders || false
|
|
@@ -10,6 +10,7 @@ var _reactIntlNext = require("react-intl-next");
|
|
|
10
10
|
var _editorTables = require("@atlaskit/editor-tables");
|
|
11
11
|
var _utils = require("@atlaskit/editor-tables/utils");
|
|
12
12
|
var _commands = require("../../../commands");
|
|
13
|
+
var _commands2 = require("../../../pm-plugins/drag-and-drop/commands");
|
|
13
14
|
var _types = require("../../../types");
|
|
14
15
|
var _utils2 = require("../../../utils");
|
|
15
16
|
var _DragHandle = require("../../DragHandle");
|
|
@@ -26,7 +27,9 @@ var getSelectedRows = function getSelectedRows(selection) {
|
|
|
26
27
|
return [];
|
|
27
28
|
};
|
|
28
29
|
var DragControlsComponent = function DragControlsComponent(_ref) {
|
|
30
|
+
var _tableNode$attrs$loca, _tableNode$attrs;
|
|
29
31
|
var tableRef = _ref.tableRef,
|
|
32
|
+
tableNode = _ref.tableNode,
|
|
30
33
|
hoveredCell = _ref.hoveredCell,
|
|
31
34
|
tableActive = _ref.tableActive,
|
|
32
35
|
editorView = _ref.editorView,
|
|
@@ -40,6 +43,9 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
|
|
|
40
43
|
}).join(' ');
|
|
41
44
|
var selectedRowIndexes = getSelectedRows(editorView.state.selection);
|
|
42
45
|
var rowWidth = tableRef.offsetWidth;
|
|
46
|
+
var onMouseUp = (0, _react.useCallback)(function () {
|
|
47
|
+
(0, _commands2.toggleDragMenu)(undefined, 'row', hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.rowIndex)(editorView.state, editorView.dispatch);
|
|
48
|
+
}, [editorView, hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.rowIndex]);
|
|
43
49
|
var rowIndex = hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.rowIndex;
|
|
44
50
|
var gridRowPosition = (0, _react.useMemo)(function () {
|
|
45
51
|
// if more than one row is selected, ensure the handle spans over the selected range
|
|
@@ -48,11 +54,6 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
|
|
|
48
54
|
}
|
|
49
55
|
return "".concat(rowIndex + 1, " / span 1");
|
|
50
56
|
}, [rowIndex, selectedRowIndexes]);
|
|
51
|
-
var getLocalId = function getLocalId() {
|
|
52
|
-
var _tableNode$node;
|
|
53
|
-
var tableNode = (0, _utils.findTable)(editorView.state.selection);
|
|
54
|
-
return (tableNode === null || tableNode === void 0 || (_tableNode$node = tableNode.node) === null || _tableNode$node === void 0 || (_tableNode$node = _tableNode$node.attrs) === null || _tableNode$node === void 0 ? void 0 : _tableNode$node.localId) || '';
|
|
55
|
-
};
|
|
56
57
|
var handleMouseOut = (0, _react.useCallback)(function () {
|
|
57
58
|
if (tableActive) {
|
|
58
59
|
var state = editorView.state,
|
|
@@ -94,14 +95,15 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
|
|
|
94
95
|
justifyContent: 'center'
|
|
95
96
|
}
|
|
96
97
|
}, /*#__PURE__*/_react.default.createElement(_DragHandle.DragHandle, {
|
|
97
|
-
tableLocalId:
|
|
98
|
+
tableLocalId: (_tableNode$attrs$loca = tableNode === null || tableNode === void 0 || (_tableNode$attrs = tableNode.attrs) === null || _tableNode$attrs === void 0 ? void 0 : _tableNode$attrs.localId) !== null && _tableNode$attrs$loca !== void 0 ? _tableNode$attrs$loca : '',
|
|
98
99
|
indexes: [rowIndex],
|
|
99
100
|
previewWidth: rowWidth,
|
|
100
101
|
previewHeight: rowHeights[rowIndex],
|
|
101
102
|
appearance: selectedRowIndexes.includes(rowIndex) ? isInDanger ? 'danger' : 'selected' : 'default',
|
|
102
103
|
onClick: handleClick,
|
|
103
104
|
onMouseOver: handleMouseOver,
|
|
104
|
-
onMouseOut: handleMouseOut
|
|
105
|
+
onMouseOut: handleMouseOut,
|
|
106
|
+
onMouseUp: onMouseUp
|
|
105
107
|
})));
|
|
106
108
|
};
|
|
107
109
|
var DragControls = exports.DragControls = (0, _reactIntlNext.injectIntl)(DragControlsComponent);
|
|
@@ -144,6 +144,7 @@ var TableFloatingControls = exports.default = /*#__PURE__*/function (_Component)
|
|
|
144
144
|
var _this$props3 = this.props,
|
|
145
145
|
editorView = _this$props3.editorView,
|
|
146
146
|
tableRef = _this$props3.tableRef,
|
|
147
|
+
tableNode = _this$props3.tableNode,
|
|
147
148
|
isInDanger = _this$props3.isInDanger,
|
|
148
149
|
isResizing = _this$props3.isResizing,
|
|
149
150
|
isNumberColumnEnabled = _this$props3.isNumberColumnEnabled,
|
|
@@ -178,6 +179,7 @@ var TableFloatingControls = exports.default = /*#__PURE__*/function (_Component)
|
|
|
178
179
|
isDragAndDropEnabled: isDragAndDropEnabled
|
|
179
180
|
}) : null, tableActive && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, isDragAndDropEnabled ? /*#__PURE__*/_react.default.createElement(_RowControls.DragControls, {
|
|
180
181
|
tableRef: tableRef,
|
|
182
|
+
tableNode: tableNode,
|
|
181
183
|
hoveredCell: hoveredCell,
|
|
182
184
|
editorView: editorView,
|
|
183
185
|
tableActive: tableActive,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.tableToolbarSize = exports.tableToolbarSelectedColor = exports.tableToolbarDeleteColor = exports.tableToolbarColor = exports.tableTextColor = exports.tableScrollbarOffset = exports.tablePadding = exports.tableOverflowShadowWidthWide = exports.tableOverflowShadowWidth = exports.tableMarginFullWidthMode = exports.tableInsertColumnButtonSize = exports.tableInsertColumnButtonOffset = exports.tableHeaderCellBackgroundColor = exports.tableFloatingControlsColor = exports.tableDeleteButtonSize = exports.tableDeleteButtonOffset = exports.tableControlsSpacing = exports.tableCellSelectedDeleteIconColor = exports.tableCellSelectedDeleteIconBackground = exports.tableCellSelectedColor = exports.tableCellHoverDeleteIconColor = exports.tableCellHoverDeleteIconBackground = exports.tableCellDeleteColor = exports.tableCellBackgroundColor = exports.tableBorderSelectedColor = exports.tableBorderRadiusSize = exports.tableBorderDeleteColor = exports.tableBorderColor = exports.stickyRowZIndex = exports.stickyRowOffsetTop = exports.stickyHeaderBorderBottomWidth = exports.rowControlsZIndex = exports.resizeLineWidth = exports.resizeHandlerZIndex = exports.resizeHandlerAreaWidth = exports.lineMarkerSize = exports.lineMarkerOffsetFromColumnControls = exports.layoutButtonSize = exports.insertLineWidth = exports.contextualMenuTriggerSize = exports.contextualMenuDropdownWidth = exports.columnResizeHandleZIndex = exports.columnControlsZIndex = exports.columnControlsSelectedZIndex = exports.columnControlsDecorationHeight = exports.TABLE_SNAP_GAP = exports.TABLE_HIGHLIGHT_TOLERANCE = exports.TABLE_HIGHLIGHT_GAP = exports.STICKY_HEADER_TOGGLE_TOLERANCE_MS = void 0;
|
|
6
|
+
exports.tableToolbarSize = exports.tableToolbarSelectedColor = exports.tableToolbarDeleteColor = exports.tableToolbarColor = exports.tableTextColor = exports.tableScrollbarOffset = exports.tablePadding = exports.tableOverflowShadowWidthWide = exports.tableOverflowShadowWidth = exports.tableMarginFullWidthMode = exports.tableInsertColumnButtonSize = exports.tableInsertColumnButtonOffset = exports.tableHeaderCellBackgroundColor = exports.tableFloatingControlsColor = exports.tableDeleteButtonSize = exports.tableDeleteButtonOffset = exports.tableControlsSpacing = exports.tableCellSelectedDeleteIconColor = exports.tableCellSelectedDeleteIconBackground = exports.tableCellSelectedColor = exports.tableCellHoverDeleteIconColor = exports.tableCellHoverDeleteIconBackground = exports.tableCellDeleteColor = exports.tableCellBackgroundColor = exports.tableBorderSelectedColor = exports.tableBorderRadiusSize = exports.tableBorderDeleteColor = exports.tableBorderColor = exports.stickyRowZIndex = exports.stickyRowOffsetTop = exports.stickyHeaderBorderBottomWidth = exports.rowControlsZIndex = exports.resizeLineWidth = exports.resizeHandlerZIndex = exports.resizeHandlerAreaWidth = exports.lineMarkerSize = exports.lineMarkerOffsetFromColumnControls = exports.layoutButtonSize = exports.insertLineWidth = exports.dragMenuDropdownWidth = exports.contextualMenuTriggerSize = exports.contextualMenuDropdownWidth = exports.columnResizeHandleZIndex = exports.columnControlsZIndex = exports.columnControlsSelectedZIndex = exports.columnControlsDecorationHeight = exports.TABLE_SNAP_GAP = exports.TABLE_HIGHLIGHT_TOLERANCE = exports.TABLE_HIGHLIGHT_GAP = exports.STICKY_HEADER_TOGGLE_TOLERANCE_MS = void 0;
|
|
7
7
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
8
8
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
9
9
|
var _colors = require("@atlaskit/theme/colors");
|
|
@@ -109,4 +109,5 @@ var tableOverflowShadowWidthWide = exports.tableOverflowShadowWidthWide = 32;
|
|
|
109
109
|
var TABLE_SNAP_GAP = exports.TABLE_SNAP_GAP = 9;
|
|
110
110
|
var TABLE_HIGHLIGHT_GAP = exports.TABLE_HIGHLIGHT_GAP = 10;
|
|
111
111
|
var TABLE_HIGHLIGHT_TOLERANCE = exports.TABLE_HIGHLIGHT_TOLERANCE = 2;
|
|
112
|
-
var STICKY_HEADER_TOGGLE_TOLERANCE_MS = exports.STICKY_HEADER_TOGGLE_TOLERANCE_MS = 5;
|
|
112
|
+
var STICKY_HEADER_TOGGLE_TOLERANCE_MS = exports.STICKY_HEADER_TOGGLE_TOLERANCE_MS = 5;
|
|
113
|
+
var dragMenuDropdownWidth = exports.dragMenuDropdownWidth = 240;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.getDragMenuConfig = void 0;
|
|
8
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
|
+
var _commands = require("../pm-plugins/drag-and-drop/commands");
|
|
10
|
+
var canDecrease = function canDecrease(index) {
|
|
11
|
+
var min = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
12
|
+
return index !== undefined && index > min;
|
|
13
|
+
};
|
|
14
|
+
var canIncrease = function canIncrease(index) {
|
|
15
|
+
var max = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
16
|
+
return index !== undefined && index < max;
|
|
17
|
+
};
|
|
18
|
+
var getDragMenuConfig = exports.getDragMenuConfig = function getDragMenuConfig(direction, tableMap, index) {
|
|
19
|
+
var moveOptions = direction === 'row' ? [{
|
|
20
|
+
label: 'up',
|
|
21
|
+
offset: -1,
|
|
22
|
+
canMove: canDecrease
|
|
23
|
+
}, {
|
|
24
|
+
label: 'down',
|
|
25
|
+
offset: 1,
|
|
26
|
+
canMove: function canMove(index) {
|
|
27
|
+
var _tableMap$height;
|
|
28
|
+
return canIncrease(index, ((_tableMap$height = tableMap === null || tableMap === void 0 ? void 0 : tableMap.height) !== null && _tableMap$height !== void 0 ? _tableMap$height : 0) - 1);
|
|
29
|
+
}
|
|
30
|
+
}] : [{
|
|
31
|
+
label: 'left',
|
|
32
|
+
offset: -1,
|
|
33
|
+
canMove: canDecrease
|
|
34
|
+
}, {
|
|
35
|
+
label: 'right',
|
|
36
|
+
offset: 1,
|
|
37
|
+
canMove: function canMove(index) {
|
|
38
|
+
var _tableMap$width;
|
|
39
|
+
return canIncrease(index, ((_tableMap$width = tableMap === null || tableMap === void 0 ? void 0 : tableMap.width) !== null && _tableMap$width !== void 0 ? _tableMap$width : 0) - 1);
|
|
40
|
+
}
|
|
41
|
+
}];
|
|
42
|
+
return (0, _toConsumableArray2.default)(moveOptions.map(function (_ref) {
|
|
43
|
+
var label = _ref.label,
|
|
44
|
+
offset = _ref.offset,
|
|
45
|
+
canMove = _ref.canMove;
|
|
46
|
+
return {
|
|
47
|
+
id: "move_".concat(direction, "_").concat(label),
|
|
48
|
+
title: "Move ".concat(direction, " ").concat(label),
|
|
49
|
+
disabled: !canMove(index),
|
|
50
|
+
onClick: function onClick(state, dispatch) {
|
|
51
|
+
if (canMove(index)) {
|
|
52
|
+
(0, _commands.moveSource)("table-".concat(direction), index, index + offset)(state, dispatch);
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
}));
|
|
59
|
+
};
|
|
@@ -28,6 +28,7 @@ import { getToolbarConfig } from './toolbar';
|
|
|
28
28
|
import FloatingContextualButton from './ui/FloatingContextualButton';
|
|
29
29
|
import FloatingContextualMenu from './ui/FloatingContextualMenu';
|
|
30
30
|
import FloatingDeleteButton from './ui/FloatingDeleteButton';
|
|
31
|
+
import FloatingDragMenu from './ui/FloatingDragMenu';
|
|
31
32
|
import FloatingInsertButton from './ui/FloatingInsertButton';
|
|
32
33
|
import LayoutButton from './ui/LayoutButton';
|
|
33
34
|
import { isLayoutSupported } from './utils';
|
|
@@ -242,7 +243,8 @@ const tablesPlugin = ({
|
|
|
242
243
|
tableResizingPluginState: resizingPluginState,
|
|
243
244
|
stickyHeadersState,
|
|
244
245
|
tablePluginState,
|
|
245
|
-
tableWidthPluginState
|
|
246
|
+
tableWidthPluginState,
|
|
247
|
+
dragAndDropState
|
|
246
248
|
}) => {
|
|
247
249
|
const {
|
|
248
250
|
state
|
|
@@ -262,7 +264,8 @@ const tablesPlugin = ({
|
|
|
262
264
|
insertRowButtonIndex,
|
|
263
265
|
isHeaderColumnEnabled,
|
|
264
266
|
isHeaderRowEnabled,
|
|
265
|
-
tableWrapperTarget
|
|
267
|
+
tableWrapperTarget,
|
|
268
|
+
isDragAndDropEnabled
|
|
266
269
|
} = tablePluginState;
|
|
267
270
|
const {
|
|
268
271
|
allowControls
|
|
@@ -316,6 +319,16 @@ const tablesPlugin = ({
|
|
|
316
319
|
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
317
320
|
getEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
318
321
|
getEditorFeatureFlags: (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags
|
|
322
|
+
}), isDragAndDropEnabled && /*#__PURE__*/React.createElement(FloatingDragMenu, {
|
|
323
|
+
editorView: editorView,
|
|
324
|
+
mountPoint: popupsMountPoint,
|
|
325
|
+
boundariesElement: popupsBoundariesElement,
|
|
326
|
+
tableRef: tableRef,
|
|
327
|
+
tableNode: tableNode,
|
|
328
|
+
targetCellPosition: targetCellPosition,
|
|
329
|
+
direction: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.dragMenuDirection,
|
|
330
|
+
index: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.dragMenuIndex,
|
|
331
|
+
isOpen: !!(dragAndDropState !== null && dragAndDropState !== void 0 && dragAndDropState.isDragMenuOpen) && !isResizing
|
|
319
332
|
}), allowControls && !isResizing && /*#__PURE__*/React.createElement(FloatingDeleteButton, {
|
|
320
333
|
editorView: editorView,
|
|
321
334
|
selection: editorView.state.selection,
|