@atlaskit/editor-plugin-table 5.3.13 → 5.3.14
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 +10 -0
- package/dist/cjs/plugins/table/event-handlers.js +6 -3
- package/dist/cjs/plugins/table/index.js +4 -3
- package/dist/cjs/plugins/table/pm-plugins/decorations/plugin.js +3 -7
- package/dist/cjs/plugins/table/pm-plugins/decorations/utils/column-controls.js +1 -3
- package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/plugin.js +11 -0
- package/dist/cjs/plugins/table/types.js +9 -2
- package/dist/cjs/plugins/table/ui/FloatingDragMenu/index.js +5 -3
- package/dist/cjs/plugins/table/ui/FloatingInsertButton/InsertButton.js +57 -9
- package/dist/cjs/plugins/table/ui/FloatingInsertButton/getPopupOptions.js +9 -7
- package/dist/cjs/plugins/table/ui/FloatingInsertButton/index.js +13 -4
- package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +44 -5
- package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/index.js +6 -4
- package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +35 -13
- package/dist/cjs/plugins/table/ui/TableFloatingControls/index.js +2 -0
- package/dist/cjs/plugins/table/ui/common-styles.js +1 -1
- package/dist/cjs/plugins/table/ui/ui-styles.js +27 -24
- package/dist/cjs/plugins/table/utils/dom.js +12 -4
- package/dist/cjs/plugins/table/utils/index.js +12 -0
- package/dist/es2019/plugins/table/event-handlers.js +5 -4
- package/dist/es2019/plugins/table/index.js +4 -3
- package/dist/es2019/plugins/table/pm-plugins/decorations/plugin.js +3 -7
- package/dist/es2019/plugins/table/pm-plugins/decorations/utils/column-controls.js +1 -3
- package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/plugin.js +12 -0
- package/dist/es2019/plugins/table/types.js +9 -2
- package/dist/es2019/plugins/table/ui/FloatingDragMenu/index.js +5 -3
- package/dist/es2019/plugins/table/ui/FloatingInsertButton/InsertButton.js +58 -7
- package/dist/es2019/plugins/table/ui/FloatingInsertButton/getPopupOptions.js +9 -7
- package/dist/es2019/plugins/table/ui/FloatingInsertButton/index.js +10 -4
- package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +46 -6
- package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/index.js +7 -5
- package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +35 -14
- package/dist/es2019/plugins/table/ui/TableFloatingControls/index.js +2 -0
- package/dist/es2019/plugins/table/ui/common-styles.js +51 -3
- package/dist/es2019/plugins/table/ui/ui-styles.js +23 -1
- package/dist/es2019/plugins/table/utils/dom.js +5 -1
- package/dist/es2019/plugins/table/utils/index.js +1 -1
- package/dist/esm/plugins/table/event-handlers.js +7 -4
- package/dist/esm/plugins/table/index.js +4 -3
- package/dist/esm/plugins/table/pm-plugins/decorations/plugin.js +3 -7
- package/dist/esm/plugins/table/pm-plugins/decorations/utils/column-controls.js +1 -3
- package/dist/esm/plugins/table/pm-plugins/drag-and-drop/plugin.js +11 -0
- package/dist/esm/plugins/table/types.js +9 -2
- package/dist/esm/plugins/table/ui/FloatingDragMenu/index.js +5 -3
- package/dist/esm/plugins/table/ui/FloatingInsertButton/InsertButton.js +56 -8
- package/dist/esm/plugins/table/ui/FloatingInsertButton/getPopupOptions.js +9 -7
- package/dist/esm/plugins/table/ui/FloatingInsertButton/index.js +10 -4
- package/dist/esm/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +45 -6
- package/dist/esm/plugins/table/ui/TableFloatingColumnControls/index.js +7 -5
- package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +36 -14
- package/dist/esm/plugins/table/ui/TableFloatingControls/index.js +2 -0
- package/dist/esm/plugins/table/ui/common-styles.js +2 -2
- package/dist/esm/plugins/table/ui/ui-styles.js +26 -23
- package/dist/esm/plugins/table/utils/dom.js +11 -3
- package/dist/esm/plugins/table/utils/index.js +1 -1
- package/dist/types/plugins/table/types.d.ts +9 -2
- package/dist/types/plugins/table/ui/FloatingInsertButton/InsertButton.d.ts +5 -1
- package/dist/types/plugins/table/ui/FloatingInsertButton/getPopupOptions.d.ts +1 -1
- package/dist/types/plugins/table/ui/FloatingInsertButton/index.d.ts +1 -0
- package/dist/types/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +2 -1
- package/dist/types/plugins/table/ui/TableFloatingControls/RowControls/DragControls.d.ts +2 -0
- package/dist/types/plugins/table/ui/ui-styles.d.ts +1 -0
- package/dist/types/plugins/table/utils/dom.d.ts +4 -1
- package/dist/types/plugins/table/utils/index.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/types.d.ts +9 -2
- package/dist/types-ts4.5/plugins/table/ui/FloatingInsertButton/InsertButton.d.ts +5 -1
- package/dist/types-ts4.5/plugins/table/ui/FloatingInsertButton/getPopupOptions.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/ui/FloatingInsertButton/index.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/RowControls/DragControls.d.ts +2 -0
- package/dist/types-ts4.5/plugins/table/ui/ui-styles.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/utils/dom.d.ts +4 -1
- package/dist/types-ts4.5/plugins/table/utils/index.d.ts +1 -1
- package/package.json +2 -1
- package/src/__tests__/unit/pm-plugins/decorations/plugin.ts +40 -194
- package/src/__tests__/unit/ui/RowDragControls.tsx +9 -11
- package/src/plugins/table/event-handlers.ts +15 -3
- package/src/plugins/table/index.tsx +3 -2
- package/src/plugins/table/pm-plugins/decorations/plugin.ts +2 -9
- package/src/plugins/table/pm-plugins/decorations/utils/column-controls.ts +1 -3
- package/src/plugins/table/pm-plugins/drag-and-drop/plugin.ts +9 -0
- package/src/plugins/table/types.ts +12 -2
- package/src/plugins/table/ui/FloatingDragMenu/index.tsx +10 -3
- package/src/plugins/table/ui/FloatingInsertButton/InsertButton.tsx +82 -8
- package/src/plugins/table/ui/FloatingInsertButton/getPopupOptions.ts +28 -5
- package/src/plugins/table/ui/FloatingInsertButton/index.tsx +19 -7
- package/src/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.tsx +47 -3
- package/src/plugins/table/ui/TableFloatingColumnControls/index.tsx +11 -4
- package/src/plugins/table/ui/TableFloatingControls/RowControls/DragControls.tsx +49 -18
- package/src/plugins/table/ui/TableFloatingControls/index.tsx +2 -0
- package/src/plugins/table/ui/common-styles.ts +57 -2
- package/src/plugins/table/ui/ui-styles.ts +27 -1
- package/src/plugins/table/utils/dom.ts +11 -4
- package/src/plugins/table/utils/index.ts +2 -0
- package/tsconfig.app.json +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 5.3.14
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#42038](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/42038) [`071533736a8`](https://bitbucket.org/atlassian/atlassian-frontend/commits/071533736a8) - Fixed an bug in the tables where the onBlur was causing the editor has focus flag to be reset to false. This would result in the drag handle disappearing due to the table not being active anymore.
|
|
8
|
+
- [#42188](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/42188) [`5b8b565940b`](https://bitbucket.org/atlassian/atlassian-frontend/commits/5b8b565940b) - Killed the outline for the drag handle button which appears only in firfox when the button has focus
|
|
9
|
+
- [#42186](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/42186) [`20b5f464a2b`](https://bitbucket.org/atlassian/atlassian-frontend/commits/20b5f464a2b) - [ux] Integrate drag menu with column control
|
|
10
|
+
- [#42148](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/42148) [`fb0c3a2c035`](https://bitbucket.org/atlassian/atlassian-frontend/commits/fb0c3a2c035) - Add row and column select functionality for table drag controls
|
|
11
|
+
- [#42182](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/42182) [`1053f5745d3`](https://bitbucket.org/atlassian/atlassian-frontend/commits/1053f5745d3) - Added autoscroller functionality to the table DnD plugin. When dragging rows/cols the table will auto scroll into view when the drag approaches the borders of the table
|
|
12
|
+
|
|
3
13
|
## 5.3.13
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
|
@@ -30,12 +30,15 @@ var isFocusingModal = function isFocusingModal(event) {
|
|
|
30
30
|
var isFocusingFloatingToolbar = function isFocusingFloatingToolbar(event) {
|
|
31
31
|
return event instanceof FocusEvent && event.relatedTarget instanceof HTMLElement && event.relatedTarget.closest('[role="toolbar"]');
|
|
32
32
|
};
|
|
33
|
+
var isFocusingDragHandles = function isFocusingDragHandles(event) {
|
|
34
|
+
return event instanceof FocusEvent && event.relatedTarget instanceof HTMLElement && event.relatedTarget.closest('button') && event.relatedTarget.getAttribute('draggable') === 'true';
|
|
35
|
+
};
|
|
33
36
|
var handleBlur = exports.handleBlur = function handleBlur(view, event) {
|
|
34
37
|
var state = view.state,
|
|
35
38
|
dispatch = view.dispatch;
|
|
36
39
|
// IE version check for ED-4665
|
|
37
40
|
// Calendar focus check for ED-10466
|
|
38
|
-
if (_utils.browser.ie_version !== 11 && !isFocusingCalendar(event) && !isFocusingModal(event) && !isFocusingFloatingToolbar(event)) {
|
|
41
|
+
if (_utils.browser.ie_version !== 11 && !isFocusingCalendar(event) && !isFocusingModal(event) && !isFocusingFloatingToolbar(event) && !isFocusingDragHandles(event)) {
|
|
39
42
|
(0, _commands.setEditorFocus)(false)(state, dispatch);
|
|
40
43
|
}
|
|
41
44
|
event.preventDefault();
|
|
@@ -192,7 +195,7 @@ var handleMouseMove = exports.handleMouseMove = function handleMouseMove(view, e
|
|
|
192
195
|
return false;
|
|
193
196
|
}
|
|
194
197
|
var element = event.target;
|
|
195
|
-
if ((0, _utils3.isColumnControlsDecorations)(element)) {
|
|
198
|
+
if ((0, _utils3.isColumnControlsDecorations)(element) || (0, _utils3.isDragColumnFloatingInsertDot)(element)) {
|
|
196
199
|
var state = view.state,
|
|
197
200
|
dispatch = view.dispatch;
|
|
198
201
|
var _getPluginState3 = (0, _pluginFactory.getPluginState)(state),
|
|
@@ -206,7 +209,7 @@ var handleMouseMove = exports.handleMouseMove = function handleMouseMove(view, e
|
|
|
206
209
|
return (0, _commands.showInsertColumnButton)(positionColumn)(state, dispatch);
|
|
207
210
|
}
|
|
208
211
|
}
|
|
209
|
-
if ((0, _utils3.isRowControlsButton)(element)) {
|
|
212
|
+
if ((0, _utils3.isRowControlsButton)(element) || (0, _utils3.isDragRowFloatingInsertDot)(element)) {
|
|
210
213
|
var _state3 = view.state,
|
|
211
214
|
_dispatch4 = view.dispatch;
|
|
212
215
|
var _getPluginState4 = (0, _pluginFactory.getPluginState)(_state3),
|
|
@@ -275,8 +275,8 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
275
275
|
insertRowButtonIndex = _ref14.insertRowButtonIndex,
|
|
276
276
|
isHeaderColumnEnabled = _ref14.isHeaderColumnEnabled,
|
|
277
277
|
isHeaderRowEnabled = _ref14.isHeaderRowEnabled,
|
|
278
|
-
|
|
279
|
-
|
|
278
|
+
isDragAndDropEnabled = _ref14.isDragAndDropEnabled,
|
|
279
|
+
tableWrapperTarget = _ref14.tableWrapperTarget;
|
|
280
280
|
var allowControls = pluginConfig.allowControls;
|
|
281
281
|
var stickyHeader = stickyHeadersState ? (0, _stickyHeaders.findStickyHeaderForTable)(stickyHeadersState, tablePos) : undefined;
|
|
282
282
|
var LayoutContent = options && !options.tableResizingEnabled && (0, _utils3.isLayoutSupported)(state) && options.breakoutEnabled ? /*#__PURE__*/_react.default.createElement(_LayoutButton.default, {
|
|
@@ -309,6 +309,7 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
309
309
|
insertRowButtonIndex: insertRowButtonIndex,
|
|
310
310
|
isHeaderColumnEnabled: isHeaderColumnEnabled,
|
|
311
311
|
isHeaderRowEnabled: isHeaderRowEnabled,
|
|
312
|
+
isDragAndDropEnabled: isDragAndDropEnabled,
|
|
312
313
|
editorView: editorView,
|
|
313
314
|
mountPoint: popupsMountPoint,
|
|
314
315
|
boundariesElement: popupsBoundariesElement,
|
|
@@ -337,7 +338,7 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
337
338
|
direction: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.dragMenuDirection,
|
|
338
339
|
index: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.dragMenuIndex,
|
|
339
340
|
isOpen: !!(dragAndDropState !== null && dragAndDropState !== void 0 && dragAndDropState.isDragMenuOpen) && !isResizing
|
|
340
|
-
}), allowControls && !isResizing && /*#__PURE__*/_react.default.createElement(_FloatingDeleteButton.default, {
|
|
341
|
+
}), allowControls && !isDragAndDropEnabled && !isResizing && /*#__PURE__*/_react.default.createElement(_FloatingDeleteButton.default, {
|
|
341
342
|
editorView: editorView,
|
|
342
343
|
selection: editorView.state.selection,
|
|
343
344
|
tableRef: tableRef,
|
|
@@ -17,7 +17,7 @@ var getDecorations = exports.getDecorations = function getDecorations(state) {
|
|
|
17
17
|
return pluginKey.getState(state);
|
|
18
18
|
};
|
|
19
19
|
var handleDocOrSelectionChanged = exports.handleDocOrSelectionChanged = function handleDocOrSelectionChanged(tr, decorationSet, oldState, newState) {
|
|
20
|
-
var _tableWidthPluginKey$, _tableWidthPluginKey$2
|
|
20
|
+
var _tableWidthPluginKey$, _tableWidthPluginKey$2;
|
|
21
21
|
var isResizing = (_tableWidthPluginKey$ = _tableWidth.pluginKey.getState(newState)) === null || _tableWidthPluginKey$ === void 0 ? void 0 : _tableWidthPluginKey$.resizing;
|
|
22
22
|
var wasResizing = (_tableWidthPluginKey$2 = _tableWidth.pluginKey.getState(oldState)) === null || _tableWidthPluginKey$2 === void 0 ? void 0 : _tableWidthPluginKey$2.resizing;
|
|
23
23
|
var changedResizing = isResizing !== wasResizing;
|
|
@@ -25,7 +25,7 @@ var handleDocOrSelectionChanged = exports.handleDocOrSelectionChanged = function
|
|
|
25
25
|
// Remove column controls when resizing and don't add column decoration controls when DnD enabled
|
|
26
26
|
if (isResizing || (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.drag-and-drop')) {
|
|
27
27
|
return _view.DecorationSet.empty;
|
|
28
|
-
} else if (tr.docChanged || tr.selection instanceof _cellSelection.CellSelection || changedResizing
|
|
28
|
+
} else if (tr.docChanged || tr.selection instanceof _cellSelection.CellSelection || changedResizing) {
|
|
29
29
|
return (0, _utils.buildColumnControlsDecorations)({
|
|
30
30
|
decorationSet: decorationSet,
|
|
31
31
|
tr: tr
|
|
@@ -48,16 +48,12 @@ var createPlugin = exports.createPlugin = function createPlugin() {
|
|
|
48
48
|
return _view.DecorationSet.empty;
|
|
49
49
|
},
|
|
50
50
|
apply: function apply(tr, decorationSet, oldState, newState) {
|
|
51
|
-
var _tablePluginKey$getSt, _tablePluginKey$getSt2;
|
|
52
51
|
var pluginState = decorationSet;
|
|
53
52
|
var meta = tr.getMeta(_pluginKey.pluginKey);
|
|
54
|
-
var previousHover = (_tablePluginKey$getSt = _pluginKey.pluginKey.getState(oldState)) === null || _tablePluginKey$getSt === void 0 ? void 0 : _tablePluginKey$getSt.hoveredCell;
|
|
55
|
-
var newHover = (_tablePluginKey$getSt2 = _pluginKey.pluginKey.getState(newState)) === null || _tablePluginKey$getSt2 === void 0 ? void 0 : _tablePluginKey$getSt2.hoveredCell;
|
|
56
|
-
var changedCellHover = (previousHover === null || previousHover === void 0 ? void 0 : previousHover.colIndex) !== (newHover === null || newHover === void 0 ? void 0 : newHover.colIndex) || (previousHover === null || previousHover === void 0 ? void 0 : previousHover.rowIndex) !== (newHover === null || newHover === void 0 ? void 0 : newHover.rowIndex);
|
|
57
53
|
if (meta && meta.data && meta.data.decorationSet) {
|
|
58
54
|
pluginState = meta.data.decorationSet;
|
|
59
55
|
}
|
|
60
|
-
if (tr.docChanged || tr.selectionSet || tr.getMeta(_tableWidth.pluginKey)
|
|
56
|
+
if (tr.docChanged || tr.selectionSet || tr.getMeta(_tableWidth.pluginKey)) {
|
|
61
57
|
pluginState = pluginState.map(tr.mapping, tr.doc);
|
|
62
58
|
return handleDocOrSelectionChanged(tr, pluginState, oldState, newState);
|
|
63
59
|
}
|
|
@@ -8,7 +8,6 @@ var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
|
|
|
8
8
|
var _utils = require("@atlaskit/editor-tables/utils");
|
|
9
9
|
var _types = require("../../../types");
|
|
10
10
|
var _decoration = require("../../../utils/decoration");
|
|
11
|
-
var _pluginKey = require("../../plugin-key");
|
|
12
11
|
var _composeDecorations = require("./compose-decorations");
|
|
13
12
|
// @ts-ignore -- ReadonlyTransaction is a local declaration and will cause a TS2305 error in CCFE typecheck
|
|
14
13
|
|
|
@@ -33,10 +32,9 @@ var maybeUpdateColumnControlsDecoration = function maybeUpdateColumnControlsDeco
|
|
|
33
32
|
var decorationSet = _ref3.decorationSet,
|
|
34
33
|
tr = _ref3.tr;
|
|
35
34
|
var table = (0, _utils.findTable)(tr.selection);
|
|
36
|
-
var meta = tr.getMeta(_pluginKey.pluginKey);
|
|
37
35
|
|
|
38
36
|
// avoid re-drawing state if dnd decorations don't need to be updated
|
|
39
|
-
if (!table
|
|
37
|
+
if (!table) {
|
|
40
38
|
return decorationSet;
|
|
41
39
|
}
|
|
42
40
|
return (0, _decoration.updateDecorations)(tr.doc, decorationSet, (0, _decoration.createColumnControlsDecoration)(tr.selection), _types.TableDecorations.COLUMN_CONTROLS_DECORATIONS);
|
|
@@ -9,6 +9,7 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
|
|
|
9
9
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
10
10
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
11
11
|
var _utils = require("@atlaskit/editor-tables/utils");
|
|
12
|
+
var _pragmaticDragAndDropReactBeautifulDndAutoscroll = require("@atlaskit/pragmatic-drag-and-drop-react-beautiful-dnd-autoscroll");
|
|
12
13
|
var _element = require("@atlaskit/pragmatic-drag-and-drop/adapter/element");
|
|
13
14
|
var _mergedCells = require("../../utils/merged-cells");
|
|
14
15
|
var _pluginFactory = require("../plugin-factory");
|
|
@@ -87,7 +88,16 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, eventD
|
|
|
87
88
|
// watch for changes
|
|
88
89
|
return localId === (tableNode === null || tableNode === void 0 ? void 0 : tableNode.attrs.localId);
|
|
89
90
|
},
|
|
91
|
+
onDragStart: function onDragStart(_ref3) {
|
|
92
|
+
var location = _ref3.location;
|
|
93
|
+
_pragmaticDragAndDropReactBeautifulDndAutoscroll.autoScroller.start({
|
|
94
|
+
input: location.current.input
|
|
95
|
+
});
|
|
96
|
+
},
|
|
90
97
|
onDrag: function onDrag(event) {
|
|
98
|
+
_pragmaticDragAndDropReactBeautifulDndAutoscroll.autoScroller.updateInput({
|
|
99
|
+
input: event.location.current.input
|
|
100
|
+
});
|
|
91
101
|
var data = (0, _monitor.getDraggableDataFromEvent)(event);
|
|
92
102
|
// If no data can be found then it's most like we do not want to perform any drag actions
|
|
93
103
|
if (!data) {
|
|
@@ -103,6 +113,7 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, eventD
|
|
|
103
113
|
(0, _commands.setDropTarget)(dropTargetType, targetAdjustedIndex)(editorView.state, editorView.dispatch);
|
|
104
114
|
},
|
|
105
115
|
onDrop: function onDrop(event) {
|
|
116
|
+
_pragmaticDragAndDropReactBeautifulDndAutoscroll.autoScroller.stop();
|
|
106
117
|
var data = (0, _monitor.getDraggableDataFromEvent)(event);
|
|
107
118
|
|
|
108
119
|
// If no data can be found then it's most like we do not want to perform any drop action
|
|
@@ -74,6 +74,9 @@ var TableCssClassName = exports.TableCssClassName = _objectSpread(_objectSpread(
|
|
|
74
74
|
CONTROLS_INSERT_LINE: "".concat(_adfSchema.tablePrefixSelector, "-controls__insert-line"),
|
|
75
75
|
CONTROLS_BUTTON_OVERLAY: "".concat(_adfSchema.tablePrefixSelector, "-controls__button-overlay"),
|
|
76
76
|
LAYOUT_BUTTON: "".concat(_adfSchema.tablePrefixSelector, "-layout-button"),
|
|
77
|
+
DRAG_CONTROLS_INSERT_BUTTON: "".concat(_adfSchema.tablePrefixSelector, "-controls__drag-insert-button"),
|
|
78
|
+
DRAG_CONTROLS_INSERT_BUTTON_INNER: "".concat(_adfSchema.tablePrefixSelector, "-controls__drag-insert-button-inner"),
|
|
79
|
+
DRAG_CONTROLS_INSERT_BUTTON_WRAP: "".concat(_adfSchema.tablePrefixSelector, "-controls__drag-insert-button-wrap"),
|
|
77
80
|
CONTROLS_INSERT_MARKER: "".concat(_adfSchema.tablePrefixSelector, "-controls__insert-marker"),
|
|
78
81
|
CONTROLS_INSERT_COLUMN: "".concat(_adfSchema.tablePrefixSelector, "-controls__insert-column"),
|
|
79
82
|
CONTROLS_INSERT_ROW: "".concat(_adfSchema.tablePrefixSelector, "-controls__insert-row"),
|
|
@@ -86,8 +89,12 @@ var TableCssClassName = exports.TableCssClassName = _objectSpread(_objectSpread(
|
|
|
86
89
|
CORNER_CONTROLS_INSERT_COLUMN_MARKER: "".concat(_adfSchema.tablePrefixSelector, "-corner-controls__insert-column-marker"),
|
|
87
90
|
CONTROLS_CORNER_BUTTON: "".concat(_adfSchema.tablePrefixSelector, "-corner-button"),
|
|
88
91
|
/** Controls with drag handle */
|
|
89
|
-
|
|
90
|
-
|
|
92
|
+
DRAG_ROW_CONTROLS: "".concat(_adfSchema.tablePrefixSelector, "-drag-row-controls"),
|
|
93
|
+
DRAG_ROW_FLOATING_INSERT_DOT_WRAPPER: "".concat(_adfSchema.tablePrefixSelector, "-drag-row-floating-insert-dot-wrapper"),
|
|
94
|
+
DRAG_ROW_FLOATING_INSERT_DOT: "".concat(_adfSchema.tablePrefixSelector, "-drag-row-floating-insert-dot"),
|
|
95
|
+
DRAG_COLUMN_CONTROLS: "".concat(_adfSchema.tablePrefixSelector, "-drag-column-controls"),
|
|
96
|
+
DRAG_COLUMN_FLOATING_INSERT_DOT_WRAPPER: "".concat(_adfSchema.tablePrefixSelector, "-drag-columns-floating-insert-dot-wrapper"),
|
|
97
|
+
DRAG_COLUMN_FLOATING_INSERT_DOT: "".concat(_adfSchema.tablePrefixSelector, "-drag-columns-floating-insert-dot"),
|
|
91
98
|
DRAG_HANDLE_BUTTON_CONTAINER: "".concat(_adfSchema.tablePrefixSelector, "-drag-handle-button-container"),
|
|
92
99
|
/** Other classes */
|
|
93
100
|
NUMBERED_COLUMN: "".concat(_adfSchema.tablePrefixSelector, "-numbered-column"),
|
|
@@ -9,6 +9,7 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
9
9
|
var _ui = require("@atlaskit/editor-common/ui");
|
|
10
10
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
11
11
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
12
|
+
var _tableMap = require("@atlaskit/editor-tables/table-map");
|
|
12
13
|
var _consts = require("../consts");
|
|
13
14
|
var _DragMenu = require("./DragMenu");
|
|
14
15
|
var FloatingDragMenu = function FloatingDragMenu(_ref) {
|
|
@@ -30,10 +31,11 @@ var FloatingDragMenu = function FloatingDragMenu(_ref) {
|
|
|
30
31
|
if (!targetCellRef) {
|
|
31
32
|
return null;
|
|
32
33
|
}
|
|
33
|
-
|
|
34
|
+
var tableMap = tableNode ? _tableMap.TableMap.get(tableNode) : undefined;
|
|
35
|
+
var offset = direction === 'row' ? [7, 0] : index === ((tableMap === null || tableMap === void 0 ? void 0 : tableMap.width) || 1) - 1 ? [14, 0] : [-14, 0];
|
|
34
36
|
// TODO: we will need to adjust the alignment and offset values depending on whether this is a row or column menu.
|
|
35
37
|
return /*#__PURE__*/_react.default.createElement(_ui.Popup, {
|
|
36
|
-
alignX:
|
|
38
|
+
alignX: direction === 'row' ? 'left' : 'center',
|
|
37
39
|
alignY: "top",
|
|
38
40
|
target: targetCellRef,
|
|
39
41
|
mountTo: mountPoint,
|
|
@@ -45,7 +47,7 @@ var FloatingDragMenu = function FloatingDragMenu(_ref) {
|
|
|
45
47
|
,
|
|
46
48
|
zIndex: _editorSharedStyles.akEditorFloatingOverlapPanelZIndex,
|
|
47
49
|
forcePlacement: true,
|
|
48
|
-
offset:
|
|
50
|
+
offset: offset,
|
|
49
51
|
stick: true
|
|
50
52
|
}, /*#__PURE__*/_react.default.createElement(_DragMenu.DragMenu, {
|
|
51
53
|
editorView: editorView,
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.default = void 0;
|
|
7
|
+
exports.default = exports.InsertButtonForDragAndDrop = exports.DragAndDropInsertButton = void 0;
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _reactIntlNext = require("react-intl-next");
|
|
10
10
|
var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
@@ -15,6 +15,8 @@ var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
|
|
|
15
15
|
var _types = require("../../types");
|
|
16
16
|
var _consts = require("../consts");
|
|
17
17
|
var _messages = _interopRequireDefault(require("../messages"));
|
|
18
|
+
/* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
|
|
19
|
+
|
|
18
20
|
var getInsertLineHeight = function getInsertLineHeight(tableRef, hasStickyHeaders) {
|
|
19
21
|
// The line gets height 100% from the table,
|
|
20
22
|
// but since we have an overflow on the left,
|
|
@@ -30,7 +32,7 @@ var getToolbarSize = function getToolbarSize(tableRef) {
|
|
|
30
32
|
}
|
|
31
33
|
return _consts.tableToolbarSize;
|
|
32
34
|
};
|
|
33
|
-
var getInsertLineWidth = function getInsertLineWidth(tableRef) {
|
|
35
|
+
var getInsertLineWidth = function getInsertLineWidth(tableRef, isDragAndDropEnabled) {
|
|
34
36
|
// The line gets width 100% from the table,
|
|
35
37
|
// but since we have an overflow on the left,
|
|
36
38
|
// we should add an offset to make up for it.
|
|
@@ -41,22 +43,68 @@ var getInsertLineWidth = function getInsertLineWidth(tableRef) {
|
|
|
41
43
|
var _ref = parentElement,
|
|
42
44
|
scrollLeft = _ref.scrollLeft;
|
|
43
45
|
var diff = offsetWidth - parentOffsetWidth;
|
|
44
|
-
var toolbarSize = getToolbarSize(tableRef);
|
|
46
|
+
var toolbarSize = isDragAndDropEnabled ? 0 : getToolbarSize(tableRef);
|
|
45
47
|
return Math.min(offsetWidth + toolbarSize, parentOffsetWidth + toolbarSize - Math.max(scrollLeft - diff, 0)) + LINE_OFFSET;
|
|
46
48
|
};
|
|
47
49
|
var tooltipMessageByType = function tooltipMessageByType(type) {
|
|
48
50
|
return type === 'row' ? _messages.default.insertRow : _messages.default.insertColumn;
|
|
49
51
|
};
|
|
50
|
-
var
|
|
52
|
+
var InsertButtonForDragAndDrop = exports.InsertButtonForDragAndDrop = function InsertButtonForDragAndDrop(_ref2) {
|
|
51
53
|
var onMouseDown = _ref2.onMouseDown,
|
|
52
54
|
tableRef = _ref2.tableRef,
|
|
53
|
-
|
|
55
|
+
type = _ref2.type,
|
|
54
56
|
formatMessage = _ref2.intl.formatMessage,
|
|
55
57
|
hasStickyHeaders = _ref2.hasStickyHeaders;
|
|
56
58
|
var content = /*#__PURE__*/_react.default.createElement(_tooltip.default, {
|
|
57
59
|
content: /*#__PURE__*/_react.default.createElement(_keymaps.ToolTipContent, {
|
|
58
|
-
description: formatMessage(tooltipMessageByType(
|
|
59
|
-
keymap:
|
|
60
|
+
description: formatMessage(tooltipMessageByType(type)),
|
|
61
|
+
keymap: type === 'row' ? _keymaps.addRowAfter : _keymaps.addColumnAfter
|
|
62
|
+
}),
|
|
63
|
+
position: "top"
|
|
64
|
+
}, /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
65
|
+
className: _types.TableCssClassName.DRAG_CONTROLS_INSERT_BUTTON_INNER
|
|
66
|
+
}, /*#__PURE__*/_react.default.createElement("button", {
|
|
67
|
+
type: "button",
|
|
68
|
+
className: _types.TableCssClassName.DRAG_CONTROLS_INSERT_BUTTON,
|
|
69
|
+
onMouseDown: onMouseDown
|
|
70
|
+
}, /*#__PURE__*/_react.default.createElement("svg", {
|
|
71
|
+
width: "10",
|
|
72
|
+
height: "10",
|
|
73
|
+
viewBox: "0 0 10 10",
|
|
74
|
+
fill: "none",
|
|
75
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
76
|
+
}, /*#__PURE__*/_react.default.createElement("path", {
|
|
77
|
+
fillRule: "evenodd",
|
|
78
|
+
clipRule: "evenodd",
|
|
79
|
+
d: "M5.41667 4.58333V2.91667C5.41667 2.80616 5.37277 2.70018 5.29463 2.62204C5.21649 2.5439 5.11051 2.5 5 2.5C4.88949 2.5 4.78351 2.5439 4.70537 2.62204C4.62723 2.70018 4.58333 2.80616 4.58333 2.91667V4.58333H2.91667C2.80616 4.58333 2.70018 4.62723 2.62204 4.70537C2.5439 4.78351 2.5 4.88949 2.5 5C2.5 5.11051 2.5439 5.21649 2.62204 5.29463C2.70018 5.37277 2.80616 5.41667 2.91667 5.41667H4.58333V7.08333C4.58333 7.19384 4.62723 7.29982 4.70537 7.37796C4.78351 7.4561 4.88949 7.5 5 7.5C5.11051 7.5 5.21649 7.4561 5.29463 7.37796C5.37277 7.29982 5.41667 7.19384 5.41667 7.08333V5.41667H7.08333C7.19384 5.41667 7.29982 5.37277 7.37796 5.29463C7.4561 5.21649 7.5 5.11051 7.5 5C7.5 4.88949 7.4561 4.78351 7.37796 4.70537C7.29982 4.62723 7.19384 4.58333 7.08333 4.58333H5.41667Z",
|
|
80
|
+
fill: "currentColor"
|
|
81
|
+
})))), /*#__PURE__*/_react.default.createElement("div", {
|
|
82
|
+
className: _types.TableCssClassName.CONTROLS_INSERT_LINE,
|
|
83
|
+
style: type === 'row' ? {
|
|
84
|
+
width: getInsertLineWidth(tableRef, true),
|
|
85
|
+
left: '14px'
|
|
86
|
+
} : {
|
|
87
|
+
height: getInsertLineHeight(tableRef, hasStickyHeaders) - 11
|
|
88
|
+
}
|
|
89
|
+
})));
|
|
90
|
+
var floatingButtonClassName = type === 'column' ? _types.TableCssClassName.CONTROLS_FLOATING_BUTTON_COLUMN : _types.TableCssClassName.CONTROLS_FLOATING_BUTTON_ROW;
|
|
91
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
92
|
+
className: floatingButtonClassName
|
|
93
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
94
|
+
className: "".concat(_types.TableCssClassName.CONTROLS_INSERT_BUTTON_WRAP, " ").concat(_types.TableCssClassName.CONTROLS_INSERT_ROW)
|
|
95
|
+
}, content));
|
|
96
|
+
};
|
|
97
|
+
var DragAndDropInsertButton = exports.DragAndDropInsertButton = (0, _reactIntlNext.injectIntl)(InsertButtonForDragAndDrop);
|
|
98
|
+
var InsertButton = function InsertButton(_ref3) {
|
|
99
|
+
var onMouseDown = _ref3.onMouseDown,
|
|
100
|
+
tableRef = _ref3.tableRef,
|
|
101
|
+
type = _ref3.type,
|
|
102
|
+
formatMessage = _ref3.intl.formatMessage,
|
|
103
|
+
hasStickyHeaders = _ref3.hasStickyHeaders;
|
|
104
|
+
var content = /*#__PURE__*/_react.default.createElement(_tooltip.default, {
|
|
105
|
+
content: /*#__PURE__*/_react.default.createElement(_keymaps.ToolTipContent, {
|
|
106
|
+
description: formatMessage(tooltipMessageByType(type)),
|
|
107
|
+
keymap: type === 'row' ? _keymaps.addRowAfter : _keymaps.addColumnAfter
|
|
60
108
|
}),
|
|
61
109
|
position: "top"
|
|
62
110
|
}, /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -73,13 +121,13 @@ var InsertButton = function InsertButton(_ref2) {
|
|
|
73
121
|
fillRule: "evenodd"
|
|
74
122
|
})))), /*#__PURE__*/_react.default.createElement("div", {
|
|
75
123
|
className: _types.TableCssClassName.CONTROLS_INSERT_LINE,
|
|
76
|
-
style:
|
|
124
|
+
style: type === 'row' ? {
|
|
77
125
|
width: getInsertLineWidth(tableRef)
|
|
78
126
|
} : {
|
|
79
127
|
height: getInsertLineHeight(tableRef, hasStickyHeaders)
|
|
80
128
|
}
|
|
81
129
|
})));
|
|
82
|
-
var floatingButtonClassName =
|
|
130
|
+
var floatingButtonClassName = type === 'column' ? _types.TableCssClassName.CONTROLS_FLOATING_BUTTON_COLUMN : _types.TableCssClassName.CONTROLS_FLOATING_BUTTON_ROW;
|
|
83
131
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
84
132
|
className: floatingButtonClassName
|
|
85
133
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -13,9 +13,11 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
13
13
|
var HORIZONTAL_ALIGN_COLUMN_BUTTON = -(_consts.tableInsertColumnButtonSize / 2);
|
|
14
14
|
var HORIZONTAL_ALIGN_NUMBERED_COLUMN_BUTTON = HORIZONTAL_ALIGN_COLUMN_BUTTON + _editorSharedStyles.akEditorTableNumberColumnWidth;
|
|
15
15
|
var VERTICAL_ALIGN_COLUMN_BUTTON = _consts.tableToolbarSize + _consts.tableInsertColumnButtonOffset;
|
|
16
|
+
var VERTICAL_ALIGN_COLUMN_BUTTON_DRAG = _consts.tableInsertColumnButtonOffset;
|
|
16
17
|
var HORIZONTAL_ALIGN_ROW_BUTTON = -(_consts.tableToolbarSize + _consts.tableInsertColumnButtonOffset + _consts.tableInsertColumnButtonSize);
|
|
18
|
+
var HORIZONTAL_ALIGN_ROW_BUTTON_DRAG = -18;
|
|
17
19
|
var VERTICAL_ALIGN_ROW_BUTTON = _consts.tableInsertColumnButtonSize / 2;
|
|
18
|
-
function getRowOptions(index) {
|
|
20
|
+
function getRowOptions(index, isDragAndDropEnabled) {
|
|
19
21
|
var defaultOptions = {
|
|
20
22
|
alignX: 'left',
|
|
21
23
|
alignY: 'bottom',
|
|
@@ -32,16 +34,16 @@ function getRowOptions(index) {
|
|
|
32
34
|
onPositionCalculated: function onPositionCalculated(position) {
|
|
33
35
|
return _objectSpread(_objectSpread({}, position), {}, {
|
|
34
36
|
// Left position should be always the offset (To place in the correct position even if the table has overflow).
|
|
35
|
-
left: HORIZONTAL_ALIGN_ROW_BUTTON
|
|
37
|
+
left: isDragAndDropEnabled ? HORIZONTAL_ALIGN_ROW_BUTTON_DRAG : HORIZONTAL_ALIGN_ROW_BUTTON
|
|
36
38
|
});
|
|
37
39
|
}
|
|
38
40
|
});
|
|
39
41
|
}
|
|
40
|
-
function getColumnOptions(index, tableContainer, hasNumberedColumns) {
|
|
42
|
+
function getColumnOptions(index, tableContainer, hasNumberedColumns, isDragAndDropEnabled) {
|
|
41
43
|
var options = {
|
|
42
44
|
alignX: 'end',
|
|
43
45
|
alignY: 'top',
|
|
44
|
-
offset: [HORIZONTAL_ALIGN_COLUMN_BUTTON, VERTICAL_ALIGN_COLUMN_BUTTON],
|
|
46
|
+
offset: [HORIZONTAL_ALIGN_COLUMN_BUTTON, isDragAndDropEnabled ? VERTICAL_ALIGN_COLUMN_BUTTON_DRAG : VERTICAL_ALIGN_COLUMN_BUTTON],
|
|
45
47
|
// :: (position: PopupPosition) -> PopupPosition
|
|
46
48
|
// Limit the InsertButton position to the table container
|
|
47
49
|
// if the left position starts before it
|
|
@@ -77,12 +79,12 @@ function getColumnOptions(index, tableContainer, hasNumberedColumns) {
|
|
|
77
79
|
}
|
|
78
80
|
return options;
|
|
79
81
|
}
|
|
80
|
-
function getPopupOptions(direction, index, hasNumberedColumns, tableContainer) {
|
|
82
|
+
function getPopupOptions(direction, index, hasNumberedColumns, isDragAndDropEnabled, tableContainer) {
|
|
81
83
|
switch (direction) {
|
|
82
84
|
case 'column':
|
|
83
|
-
return getColumnOptions(index, tableContainer, hasNumberedColumns);
|
|
85
|
+
return getColumnOptions(index, tableContainer, hasNumberedColumns, isDragAndDropEnabled);
|
|
84
86
|
case 'row':
|
|
85
|
-
return getRowOptions(index);
|
|
87
|
+
return getRowOptions(index, isDragAndDropEnabled);
|
|
86
88
|
default:
|
|
87
89
|
return {};
|
|
88
90
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
@@ -27,7 +28,9 @@ var _commandsWithAnalytics = require("../../commands-with-analytics");
|
|
|
27
28
|
var _types = require("../../types");
|
|
28
29
|
var _utils4 = require("../../utils");
|
|
29
30
|
var _getPopupOptions = _interopRequireDefault(require("./getPopupOptions"));
|
|
30
|
-
var _InsertButton =
|
|
31
|
+
var _InsertButton = _interopRequireWildcard(require("./InsertButton"));
|
|
32
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
33
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
31
34
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
32
35
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
33
36
|
var FloatingInsertButton = exports.FloatingInsertButton = /*#__PURE__*/function (_React$Component) {
|
|
@@ -54,6 +57,7 @@ var FloatingInsertButton = exports.FloatingInsertButton = /*#__PURE__*/function
|
|
|
54
57
|
boundariesElement = _this$props.boundariesElement,
|
|
55
58
|
isHeaderColumnEnabled = _this$props.isHeaderColumnEnabled,
|
|
56
59
|
isHeaderRowEnabled = _this$props.isHeaderRowEnabled,
|
|
60
|
+
isDragAndDropEnabled = _this$props.isDragAndDropEnabled,
|
|
57
61
|
dispatchAnalyticsEvent = _this$props.dispatchAnalyticsEvent;
|
|
58
62
|
var type = typeof insertColumnButtonIndex !== 'undefined' ? 'column' : typeof insertRowButtonIndex !== 'undefined' ? 'row' : null;
|
|
59
63
|
if (!tableNode || !tableRef || !type) {
|
|
@@ -128,10 +132,15 @@ var FloatingInsertButton = exports.FloatingInsertButton = /*#__PURE__*/function
|
|
|
128
132
|
scrollableElement: tableWrapper,
|
|
129
133
|
forcePlacement: true,
|
|
130
134
|
allowOutOfBounds: true
|
|
131
|
-
}, (0, _getPopupOptions.default)(type, index, hasNumberedColumns, tableContainerWrapper), {
|
|
135
|
+
}, (0, _getPopupOptions.default)(type, index, hasNumberedColumns, !!isDragAndDropEnabled, tableContainerWrapper), {
|
|
132
136
|
zIndex: zIndex
|
|
133
|
-
}), /*#__PURE__*/_react.default.createElement(_InsertButton.
|
|
134
|
-
|
|
137
|
+
}), isDragAndDropEnabled ? /*#__PURE__*/_react.default.createElement(_InsertButton.DragAndDropInsertButton, {
|
|
138
|
+
type: type,
|
|
139
|
+
tableRef: tableRef,
|
|
140
|
+
onMouseDown: type === 'column' ? this.insertColumn : this.insertRow,
|
|
141
|
+
hasStickyHeaders: this.props.hasStickyHeaders || false
|
|
142
|
+
}) : /*#__PURE__*/_react.default.createElement(_InsertButton.default, {
|
|
143
|
+
type: type,
|
|
135
144
|
tableRef: tableRef,
|
|
136
145
|
onMouseDown: type === 'column' ? this.insertColumn : this.insertRow,
|
|
137
146
|
hasStickyHeaders: this.props.hasStickyHeaders || false
|
|
@@ -9,6 +9,7 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
9
9
|
var _editorTables = require("@atlaskit/editor-tables");
|
|
10
10
|
var _utils = require("@atlaskit/editor-tables/utils");
|
|
11
11
|
var _commands = require("../../../commands");
|
|
12
|
+
var _commands2 = require("../../../pm-plugins/drag-and-drop/commands");
|
|
12
13
|
var _types = require("../../../types");
|
|
13
14
|
var _utils2 = require("../../../utils");
|
|
14
15
|
var _DragHandle = require("../../DragHandle");
|
|
@@ -35,10 +36,13 @@ var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
|
|
|
35
36
|
localId = _ref.localId,
|
|
36
37
|
isInDanger = _ref.isInDanger,
|
|
37
38
|
rowHeights = _ref.rowHeights,
|
|
38
|
-
colWidths = _ref.colWidths
|
|
39
|
+
colWidths = _ref.colWidths,
|
|
40
|
+
hasHeaderColumn = _ref.hasHeaderColumn;
|
|
39
41
|
var widths = (_colWidths$map$join = colWidths === null || colWidths === void 0 ? void 0 : colWidths.map(function (width) {
|
|
40
42
|
return width ? "".concat(width - 1, "px") : '0px';
|
|
41
43
|
}).join(' ')) !== null && _colWidths$map$join !== void 0 ? _colWidths$map$join : '0px';
|
|
44
|
+
// TODO: reusing getRowsParams here because it's generic enough to work for columns -> rename
|
|
45
|
+
var columnParams = (0, _utils2.getRowsParams)(colWidths !== null && colWidths !== void 0 ? colWidths : []);
|
|
42
46
|
var colIndex = hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.colIndex;
|
|
43
47
|
var selectedColIndexes = getSelectedColumns(editorView.state.selection);
|
|
44
48
|
var gridColumnPosition = (0, _react.useMemo)(function () {
|
|
@@ -68,8 +72,13 @@ var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
|
|
|
68
72
|
(0, _commands.clearHoverSelection)()(state, dispatch);
|
|
69
73
|
}
|
|
70
74
|
}, [editorView, tableActive]);
|
|
75
|
+
var handleMouseUp = (0, _react.useCallback)(function () {
|
|
76
|
+
var state = editorView.state,
|
|
77
|
+
dispatch = editorView.dispatch;
|
|
78
|
+
(0, _commands2.toggleDragMenu)(undefined, 'column', colIndex)(state, dispatch);
|
|
79
|
+
}, [editorView, colIndex]);
|
|
71
80
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
72
|
-
className: _types.TableCssClassName.
|
|
81
|
+
className: _types.TableCssClassName.DRAG_COLUMN_CONTROLS
|
|
73
82
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
74
83
|
className: _types.TableCssClassName.COLUMN_CONTROLS_INNER,
|
|
75
84
|
"data-testid": "table-floating-column-controls",
|
|
@@ -77,10 +86,39 @@ var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
|
|
|
77
86
|
gridTemplateColumns: widths,
|
|
78
87
|
marginTop: marginTop
|
|
79
88
|
}
|
|
80
|
-
},
|
|
89
|
+
}, !isResizing && columnParams.map(function (_ref2, index) {
|
|
90
|
+
var startIndex = _ref2.startIndex,
|
|
91
|
+
endIndex = _ref2.endIndex;
|
|
92
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
93
|
+
style: {
|
|
94
|
+
gridColumn: "".concat(index + 1, " / span 1")
|
|
95
|
+
},
|
|
96
|
+
"data-start-index": startIndex,
|
|
97
|
+
"data-end-index": endIndex,
|
|
98
|
+
className: _types.TableCssClassName.DRAG_COLUMN_FLOATING_INSERT_DOT_WRAPPER,
|
|
99
|
+
contentEditable: false,
|
|
100
|
+
key: index
|
|
101
|
+
}, !hasHeaderColumn && index === 0 && /*#__PURE__*/_react.default.createElement("div", {
|
|
102
|
+
style: {
|
|
103
|
+
left: '0px',
|
|
104
|
+
right: 'unset'
|
|
105
|
+
},
|
|
106
|
+
className: _types.TableCssClassName.DRAG_COLUMN_FLOATING_INSERT_DOT
|
|
107
|
+
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
108
|
+
className: _types.TableCssClassName.DRAG_COLUMN_FLOATING_INSERT_DOT,
|
|
109
|
+
style: columnParams.length - 1 === index ? {
|
|
110
|
+
right: '0'
|
|
111
|
+
} : {}
|
|
112
|
+
}));
|
|
113
|
+
}), tableActive && !isResizing && !!hoveredCell && Number.isFinite(hoveredCell.colIndex) && /*#__PURE__*/_react.default.createElement("div", {
|
|
81
114
|
style: {
|
|
82
115
|
gridColumn: gridColumnPosition,
|
|
83
|
-
|
|
116
|
+
zIndex: 99,
|
|
117
|
+
display: 'flex',
|
|
118
|
+
width: '100%',
|
|
119
|
+
justifyContent: 'center',
|
|
120
|
+
alignItems: 'center',
|
|
121
|
+
marginTop: "var(--ds-space-negative-025, -2px)"
|
|
84
122
|
},
|
|
85
123
|
"data-column-control-index": hoveredCell.colIndex,
|
|
86
124
|
"data-testid": "table-floating-column-control"
|
|
@@ -93,7 +131,8 @@ var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
|
|
|
93
131
|
appearance: selectedColIndexes.includes(hoveredCell.colIndex) ? isInDanger ? 'danger' : 'selected' : 'default',
|
|
94
132
|
onClick: handleClick,
|
|
95
133
|
onMouseOver: handleMouseOver,
|
|
96
|
-
onMouseOut: handleMouseOut
|
|
134
|
+
onMouseOut: handleMouseOut,
|
|
135
|
+
onMouseUp: handleMouseUp
|
|
97
136
|
}))));
|
|
98
137
|
};
|
|
99
138
|
var _default = exports.default = ColumnControls;
|
|
@@ -43,6 +43,7 @@ var TableFloatingColumnControls = exports.TableFloatingColumnControls = function
|
|
|
43
43
|
setHasDropTargets = _useState4[1];
|
|
44
44
|
var node = getNode();
|
|
45
45
|
var currentNodeLocalId = node === null || node === void 0 ? void 0 : node.attrs.localId;
|
|
46
|
+
var hasHeaderColumn = (0, _utils.containsHeaderColumn)(node);
|
|
46
47
|
(0, _react.useEffect)(function () {
|
|
47
48
|
var _window;
|
|
48
49
|
if (tableRef && (_window = window) !== null && _window !== void 0 && _window.ResizeObserver) {
|
|
@@ -105,11 +106,11 @@ var TableFloatingColumnControls = exports.TableFloatingColumnControls = function
|
|
|
105
106
|
var colWidths = (0, _utils.getColumnsWidths)(editorView);
|
|
106
107
|
var stickyTop = stickyHeader && stickyHeader.sticky && hasHeaderRow ? stickyHeader.top : undefined;
|
|
107
108
|
var mountTo = tableRef && (tableRef === null || tableRef === void 0 ? void 0 : tableRef.parentElement) || document.body;
|
|
109
|
+
if (!tableActive) {
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
108
112
|
return /*#__PURE__*/_reactDom.default.createPortal( /*#__PURE__*/_react.default.createElement("div", {
|
|
109
113
|
className: _types.TableCssClassName.COLUMN_CONTROLS_WRAPPER,
|
|
110
|
-
style: {
|
|
111
|
-
pointerEvents: 'none'
|
|
112
|
-
},
|
|
113
114
|
"data-testid": "table-floating-column-controls-wrapper"
|
|
114
115
|
}, /*#__PURE__*/_react.default.createElement(_ColumnControls.ColumnControls, {
|
|
115
116
|
editorView: editorView,
|
|
@@ -121,7 +122,8 @@ var TableFloatingColumnControls = exports.TableFloatingColumnControls = function
|
|
|
121
122
|
localId: currentNodeLocalId,
|
|
122
123
|
isInDanger: isInDanger,
|
|
123
124
|
rowHeights: rowHeights,
|
|
124
|
-
colWidths: colWidths
|
|
125
|
+
colWidths: colWidths,
|
|
126
|
+
hasHeaderColumn: hasHeaderColumn
|
|
125
127
|
}), hasDropTargets && /*#__PURE__*/_react.default.createElement(_ColumnDropTargets.ColumnDropTargets, {
|
|
126
128
|
tableRef: tableRef,
|
|
127
129
|
stickyTop: tableActive ? stickyTop : undefined,
|