@atlaskit/editor-plugin-table 7.1.0 → 7.1.1
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/event-handlers.js +4 -1
- package/dist/cjs/pm-plugins/drag-and-drop/commands-with-analytics.js +9 -9
- package/dist/cjs/pm-plugins/drag-and-drop/commands.js +4 -11
- package/dist/cjs/pm-plugins/drag-and-drop/plugin.js +1 -4
- package/dist/cjs/pm-plugins/drag-and-drop/utils/monitor.js +0 -5
- package/dist/cjs/types.js +1 -0
- package/dist/cjs/ui/DragHandle/index.js +27 -9
- package/dist/cjs/ui/FloatingContextualMenu/ContextualMenu.js +1 -1
- package/dist/cjs/ui/FloatingContextualMenu/index.js +4 -3
- package/dist/cjs/ui/FloatingContextualMenu/styles.js +3 -1
- package/dist/cjs/ui/TableFloatingColumnControls/ColumnControls/index.js +7 -2
- package/dist/cjs/ui/TableFloatingColumnControls/ColumnDropTargets/index.js +1 -7
- package/dist/cjs/ui/TableFloatingColumnControls/index.js +0 -2
- package/dist/cjs/ui/TableFloatingControls/RowControls/DragControls.js +6 -1
- package/dist/cjs/ui/common-styles.js +2 -1
- package/dist/cjs/ui/consts.js +3 -3
- package/dist/cjs/ui/ui-styles.js +8 -8
- package/dist/cjs/utils/drag-menu.js +42 -29
- package/dist/es2019/event-handlers.js +3 -2
- package/dist/es2019/pm-plugins/drag-and-drop/commands-with-analytics.js +8 -8
- package/dist/es2019/pm-plugins/drag-and-drop/commands.js +5 -10
- package/dist/es2019/pm-plugins/drag-and-drop/plugin.js +1 -4
- package/dist/es2019/pm-plugins/drag-and-drop/utils/monitor.js +0 -5
- package/dist/es2019/types.js +1 -0
- package/dist/es2019/ui/DragHandle/index.js +26 -8
- package/dist/es2019/ui/FloatingContextualMenu/ContextualMenu.js +2 -2
- package/dist/es2019/ui/FloatingContextualMenu/index.js +5 -4
- package/dist/es2019/ui/FloatingContextualMenu/styles.js +3 -3
- package/dist/es2019/ui/TableFloatingColumnControls/ColumnControls/index.js +7 -2
- package/dist/es2019/ui/TableFloatingColumnControls/ColumnDropTargets/index.js +1 -7
- package/dist/es2019/ui/TableFloatingColumnControls/index.js +0 -2
- package/dist/es2019/ui/TableFloatingControls/RowControls/DragControls.js +6 -1
- package/dist/es2019/ui/common-styles.js +24 -5
- package/dist/es2019/ui/consts.js +2 -2
- package/dist/es2019/ui/ui-styles.js +8 -8
- package/dist/es2019/utils/drag-menu.js +29 -24
- package/dist/esm/event-handlers.js +5 -2
- package/dist/esm/pm-plugins/drag-and-drop/commands-with-analytics.js +9 -9
- package/dist/esm/pm-plugins/drag-and-drop/commands.js +5 -12
- package/dist/esm/pm-plugins/drag-and-drop/plugin.js +1 -4
- package/dist/esm/pm-plugins/drag-and-drop/utils/monitor.js +0 -5
- package/dist/esm/types.js +1 -0
- package/dist/esm/ui/DragHandle/index.js +27 -9
- package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +2 -2
- package/dist/esm/ui/FloatingContextualMenu/index.js +5 -4
- package/dist/esm/ui/FloatingContextualMenu/styles.js +4 -2
- package/dist/esm/ui/TableFloatingColumnControls/ColumnControls/index.js +7 -2
- package/dist/esm/ui/TableFloatingColumnControls/ColumnDropTargets/index.js +1 -7
- package/dist/esm/ui/TableFloatingColumnControls/index.js +0 -2
- package/dist/esm/ui/TableFloatingControls/RowControls/DragControls.js +6 -1
- package/dist/esm/ui/common-styles.js +2 -1
- package/dist/esm/ui/consts.js +2 -2
- package/dist/esm/ui/ui-styles.js +8 -8
- package/dist/esm/utils/drag-menu.js +41 -28
- package/dist/types/types.d.ts +1 -0
- package/dist/types/ui/FloatingContextualMenu/styles.d.ts +1 -1
- package/dist/types/ui/TableFloatingColumnControls/ColumnDropTargets/index.d.ts +0 -2
- package/dist/types/ui/consts.d.ts +2 -1
- package/dist/types/ui/ui-styles.d.ts +2 -2
- package/dist/types-ts4.5/types.d.ts +1 -0
- package/dist/types-ts4.5/ui/FloatingContextualMenu/styles.d.ts +1 -1
- package/dist/types-ts4.5/ui/TableFloatingColumnControls/ColumnDropTargets/index.d.ts +0 -2
- package/dist/types-ts4.5/ui/consts.d.ts +2 -1
- package/dist/types-ts4.5/ui/ui-styles.d.ts +2 -2
- package/package.json +3 -5
- package/src/__tests__/unit/event-handlers.ts +3 -17
- package/src/__tests__/unit/pm-plugins/decorations/column-controls.ts +46 -17
- package/src/event-handlers.ts +14 -2
- package/src/pm-plugins/drag-and-drop/commands-with-analytics.ts +11 -8
- package/src/pm-plugins/drag-and-drop/commands.ts +5 -33
- package/src/pm-plugins/drag-and-drop/plugin.ts +0 -3
- package/src/pm-plugins/drag-and-drop/utils/monitor.ts +0 -5
- package/src/types.ts +1 -0
- package/src/ui/DragHandle/index.tsx +33 -14
- package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +9 -2
- package/src/ui/FloatingContextualMenu/index.tsx +10 -3
- package/src/ui/FloatingContextualMenu/styles.ts +10 -3
- package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +13 -4
- package/src/ui/TableFloatingColumnControls/ColumnDropTargets/index.tsx +1 -13
- package/src/ui/TableFloatingColumnControls/index.tsx +0 -2
- package/src/ui/TableFloatingControls/RowControls/DragControls.tsx +16 -7
- package/src/ui/common-styles.ts +20 -4
- package/src/ui/consts.ts +2 -6
- package/src/ui/ui-styles.ts +12 -8
- package/src/utils/drag-menu.ts +48 -32
- package/tsconfig.json +273 -0
package/dist/cjs/ui/ui-styles.js
CHANGED
|
@@ -62,11 +62,11 @@ var columnControlsLineMarker = exports.columnControlsLineMarker = function colum
|
|
|
62
62
|
var DeleteButton = exports.DeleteButton = function DeleteButton() {
|
|
63
63
|
return (0, _react.css)(_templateObject15 || (_templateObject15 = (0, _taggedTemplateLiteral2.default)(["\n .", ",\n .", " {\n height: ", "px;\n width: ", "px;\n }\n .", " {\n .", " {\n ", "\n }\n }\n\n .", ":hover {\n background: ", ";\n color: ", ";\n cursor: pointer;\n }\n"])), _types.TableCssClassName.CONTROLS_DELETE_BUTTON_WRAP, _types.TableCssClassName.CONTROLS_DELETE_BUTTON, _consts.tableDeleteButtonSize, _consts.tableDeleteButtonSize, _types.TableCssClassName.CONTROLS_DELETE_BUTTON_WRAP, _types.TableCssClassName.CONTROLS_DELETE_BUTTON, Button("\n background: ".concat(_consts.tableCellSelectedDeleteIconBackground, ";\n color: ").concat(_consts.tableCellSelectedDeleteIconColor, ";\n ")), _types.TableCssClassName.CONTROLS_DELETE_BUTTON, _consts.tableCellHoverDeleteIconBackground, _consts.tableCellHoverDeleteIconColor);
|
|
64
64
|
};
|
|
65
|
-
var OverflowShadow = exports.OverflowShadow = function OverflowShadow() {
|
|
66
|
-
return (0, _react.css)(_templateObject16 || (_templateObject16 = (0, _taggedTemplateLiteral2.default)(["\n .", ", .", " {\n display: block;\n height: calc(100% - ", "px);\n position: absolute;\n pointer-events: none;\n top: ", "px;\n z-index: ", ";\n width: ", "px;\n }\n .", " {\n background: linear-gradient(\n to left,\n transparent 0,\n ", "\n ", "%\n ),\n linear-gradient(\n to right,\n ", " 0px,\n transparent 1px\n );\n left: 0px;\n }\n .", "[data-number-column='true'] > :not(.", ").", " {\n left: ", "px;\n }\n .", " {\n background: linear-gradient(\n to right,\n transparent 0,\n ", "\n ", "%\n ),\n linear-gradient(\n to left,\n ", " 0px,\n transparent 1px\n );\n left: ", ";\n }\n .", " {\n ", "\n .", " {\n border-left: 1px solid ", ";\n }\n }\n"])), _types.TableCssClassName.TABLE_RIGHT_SHADOW, _types.TableCssClassName.TABLE_LEFT_SHADOW, _styles.tableMarginTop, _styles.tableMarginTop, _editorSharedStyles.akEditorShadowZIndex, (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.increase-shadow-visibility_lh89r') ? _consts.tableOverflowShadowWidthWide : _consts.tableOverflowShadowWidth, _types.TableCssClassName.TABLE_LEFT_SHADOW, "var(--ds-shadow-overflow-spread, ".concat(_colors.N40A, ")"), (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.increase-shadow-visibility_lh89r') ? 140 : 100, "var(--ds-shadow-overflow-perimeter, transparent)", _types.TableCssClassName.TABLE_CONTAINER, _types.TableCssClassName.TABLE_STICKY_SHADOW, _types.TableCssClassName.TABLE_LEFT_SHADOW, _editorSharedStyles.akEditorTableNumberColumnWidth - 1, _types.TableCssClassName.TABLE_RIGHT_SHADOW, "var(--ds-shadow-overflow-spread, ".concat(_colors.N40A, ")"), (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.increase-shadow-visibility_lh89r') ? 140 : 100, "var(--ds-shadow-overflow-perimeter, transparent)", (0, _platformFeatureFlags.getBooleanFF)('platform.editor.custom-table-width') ? "calc(100% - ".concat((0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.increase-shadow-visibility_lh89r') ? _consts.tableOverflowShadowWidthWide : _consts.tableOverflowShadowWidth, "px)") : "calc(100% - ".concat((0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.increase-shadow-visibility_lh89r') ? _consts.tableOverflowShadowWidthWide - 10 : -2, "px)"), _types.TableCssClassName.WITH_CONTROLS, overflowShadowWidhoutDnD(), _types.TableCssClassName.TABLE_LEFT_SHADOW, _consts.tableBorderColor);
|
|
65
|
+
var OverflowShadow = exports.OverflowShadow = function OverflowShadow(isDragAndDropEnabled) {
|
|
66
|
+
return (0, _react.css)(_templateObject16 || (_templateObject16 = (0, _taggedTemplateLiteral2.default)(["\n .", ", .", " {\n display: block;\n height: calc(100% - ", "px);\n position: absolute;\n pointer-events: none;\n top: ", "px;\n z-index: ", ";\n width: ", "px;\n }\n .", " {\n background: linear-gradient(\n to left,\n transparent 0,\n ", "\n ", "%\n ),\n linear-gradient(\n to right,\n ", " 0px,\n transparent 1px\n );\n left: 0px;\n }\n .", "[data-number-column='true'] > :not(.", ").", " {\n left: ", "px;\n }\n .", " {\n background: linear-gradient(\n to right,\n transparent 0,\n ", "\n ", "%\n ),\n linear-gradient(\n to left,\n ", " 0px,\n transparent 1px\n );\n left: ", ";\n }\n .", " {\n ", "\n .", " {\n border-left: 1px solid ", ";\n }\n }\n"])), _types.TableCssClassName.TABLE_RIGHT_SHADOW, _types.TableCssClassName.TABLE_LEFT_SHADOW, _styles.tableMarginTop, _styles.tableMarginTop, _editorSharedStyles.akEditorShadowZIndex, (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.increase-shadow-visibility_lh89r') ? _consts.tableOverflowShadowWidthWide : _consts.tableOverflowShadowWidth, _types.TableCssClassName.TABLE_LEFT_SHADOW, "var(--ds-shadow-overflow-spread, ".concat(_colors.N40A, ")"), (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.increase-shadow-visibility_lh89r') ? 140 : 100, "var(--ds-shadow-overflow-perimeter, transparent)", _types.TableCssClassName.TABLE_CONTAINER, _types.TableCssClassName.TABLE_STICKY_SHADOW, _types.TableCssClassName.TABLE_LEFT_SHADOW, _editorSharedStyles.akEditorTableNumberColumnWidth - 1, _types.TableCssClassName.TABLE_RIGHT_SHADOW, "var(--ds-shadow-overflow-spread, ".concat(_colors.N40A, ")"), (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.increase-shadow-visibility_lh89r') ? 140 : 100, "var(--ds-shadow-overflow-perimeter, transparent)", (0, _platformFeatureFlags.getBooleanFF)('platform.editor.custom-table-width') ? "calc(100% - ".concat((0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.increase-shadow-visibility_lh89r') ? _consts.tableOverflowShadowWidthWide : _consts.tableOverflowShadowWidth, "px)") : "calc(100% - ".concat((0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.increase-shadow-visibility_lh89r') ? _consts.tableOverflowShadowWidthWide - 10 : -2, "px)"), _types.TableCssClassName.WITH_CONTROLS, overflowShadowWidhoutDnD(isDragAndDropEnabled), _types.TableCssClassName.TABLE_LEFT_SHADOW, _consts.tableBorderColor);
|
|
67
67
|
};
|
|
68
|
-
var overflowShadowWidhoutDnD = function overflowShadowWidhoutDnD() {
|
|
69
|
-
if (!
|
|
68
|
+
var overflowShadowWidhoutDnD = function overflowShadowWidhoutDnD(isDragAndDropEnabled) {
|
|
69
|
+
if (!isDragAndDropEnabled) {
|
|
70
70
|
return (0, _react.css)(_templateObject17 || (_templateObject17 = (0, _taggedTemplateLiteral2.default)(["\n .", ", .", " {\n height: calc(100% - ", "px);\n top: ", "px;\n }\n "])), _types.TableCssClassName.TABLE_RIGHT_SHADOW, _types.TableCssClassName.TABLE_LEFT_SHADOW, _styles.tableMarginTopWithControl, _styles.tableMarginTopWithControl);
|
|
71
71
|
}
|
|
72
72
|
};
|
|
@@ -108,14 +108,14 @@ var hoveredWarningCell = exports.hoveredWarningCell = (0, _react.css)(_templateO
|
|
|
108
108
|
var getLastColumnResizerOverrides = function getLastColumnResizerOverrides() {
|
|
109
109
|
return (0, _platformFeatureFlags.getBooleanFF)('platform.editor.custom-table-width') ? (0, _react.css)(_templateObject29 || (_templateObject29 = (0, _taggedTemplateLiteral2.default)(["\n tr\n th:last-child\n .", ",\n tr\n td:last-child\n .", " {\n background-color: transparent;\n position: absolute;\n width: ", "px;\n height: 100%;\n top: 0;\n right: 0;\n cursor: col-resize;\n z-index: ", ";\n }\n "])), _types.TableCssClassName.RESIZE_HANDLE_DECORATION, _types.TableCssClassName.RESIZE_HANDLE_DECORATION, _consts.resizeHandlerAreaWidth / 2, _consts.resizeHandlerZIndex) : '';
|
|
110
110
|
};
|
|
111
|
-
var resizeHandleOverrides = function resizeHandleOverrides() {
|
|
112
|
-
if (
|
|
111
|
+
var resizeHandleOverrides = function resizeHandleOverrides(isDragAndDropEnabled) {
|
|
112
|
+
if (isDragAndDropEnabled) {
|
|
113
113
|
return (0, _react.css)(_templateObject30 || (_templateObject30 = (0, _taggedTemplateLiteral2.default)(["\n th.", "::before,\n td.", "::before {\n content: ' ';\n position: absolute;\n left: ", ";\n top: -1px;\n width: ", "px;\n height: calc(100% + 2px);\n background-color: ", ";\n z-index: ", ";\n }\n\n th.", "::before,\n td.", "::before {\n content: ' ';\n position: absolute;\n right: -1px;\n top: -1px;\n width: ", "px;\n height: calc(100% + 2px);\n background-color: ", ";\n z-index: ", ";\n }\n "])), _types.TableCssClassName.WITH_RESIZE_LINE, _types.TableCssClassName.WITH_RESIZE_LINE, "var(--ds-space-negative-025, -2px)", _consts.resizeLineWidth, _consts.tableBorderSelectedColor, _consts.columnControlsZIndex * 2, _types.TableCssClassName.WITH_RESIZE_LINE_LAST_COLUMN, _types.TableCssClassName.WITH_RESIZE_LINE_LAST_COLUMN, _consts.resizeLineWidth, _consts.tableBorderSelectedColor, _consts.columnControlsZIndex * 2);
|
|
114
114
|
}
|
|
115
115
|
return (0, _react.css)(_templateObject31 || (_templateObject31 = (0, _taggedTemplateLiteral2.default)(["\n td.", "::before {\n content: ' ';\n position: absolute;\n left: ", ";\n top: -1px;\n width: ", "px;\n height: calc(100% + 2px);\n background-color: ", ";\n z-index: ", ";\n }\n\n th.", "::before {\n content: ' ';\n left: ", ";\n position: absolute;\n width: ", "px;\n height: calc(100% + ", "px);\n background-color: ", ";\n z-index: ", ";\n top: -", "px;\n }\n\n td.", "::before {\n content: ' ';\n position: absolute;\n right: -1px;\n top: -1px;\n width: ", "px;\n height: calc(100% + 2px);\n background-color: ", ";\n z-index: ", ";\n }\n\n th.", "::before {\n content: ' ';\n right: -1px;\n position: absolute;\n width: ", "px;\n height: calc(100% + ", "px);\n background-color: ", ";\n z-index: ", ";\n top: -", "px;\n }\n "])), _types.TableCssClassName.WITH_RESIZE_LINE, "var(--ds-space-negative-025, -2px)", _consts.resizeLineWidth, _consts.tableBorderSelectedColor, _consts.columnControlsZIndex * 2, _types.TableCssClassName.WITH_RESIZE_LINE, "var(--ds-space-negative-025, -2px)", _consts.resizeLineWidth, _consts.tableToolbarSize + _styles.tableCellBorderWidth, _consts.tableBorderSelectedColor, _consts.columnControlsZIndex * 2, _consts.tableToolbarSize + _styles.tableCellBorderWidth, _types.TableCssClassName.WITH_RESIZE_LINE_LAST_COLUMN, _consts.resizeLineWidth, _consts.tableBorderSelectedColor, _consts.columnControlsZIndex * 2, _types.TableCssClassName.WITH_RESIZE_LINE_LAST_COLUMN, _consts.resizeLineWidth, _consts.tableToolbarSize + _styles.tableCellBorderWidth, _consts.tableBorderSelectedColor, _consts.columnControlsZIndex * 2, _consts.tableToolbarSize + _styles.tableCellBorderWidth);
|
|
116
116
|
};
|
|
117
|
-
var resizeHandle = exports.resizeHandle = function resizeHandle() {
|
|
118
|
-
return (0, _react.css)(_templateObject32 || (_templateObject32 = (0, _taggedTemplateLiteral2.default)(["\n .", " {\n .", " {\n background-color: transparent;\n position: absolute;\n width: ", "px;\n height: 100%;\n top: 0;\n right: -", "px;\n cursor: col-resize;\n z-index: ", ";\n }\n\n ", "\n\n ", "\n\n table\n tr:first-of-type\n th.", "\n .", "::after,\n table\n tr:first-of-type\n td.", "\n .", "::after {\n top: -", "px;\n height: calc(100% + ", "px);\n }\n }\n"])), _types.TableCssClassName.TABLE_CONTAINER, _types.TableCssClassName.RESIZE_HANDLE_DECORATION, _consts.resizeHandlerAreaWidth, _consts.resizeHandlerAreaWidth / 2, _consts.resizeHandlerZIndex, getLastColumnResizerOverrides(), resizeHandleOverrides(), _types.TableCssClassName.WITH_RESIZE_LINE, _types.TableCssClassName.RESIZE_HANDLE_DECORATION, _types.TableCssClassName.WITH_RESIZE_LINE, _types.TableCssClassName.RESIZE_HANDLE_DECORATION, _consts.tableToolbarSize + _styles.tableCellBorderWidth, _consts.tableToolbarSize + _styles.tableCellBorderWidth);
|
|
117
|
+
var resizeHandle = exports.resizeHandle = function resizeHandle(isDragAndDropEnabled) {
|
|
118
|
+
return (0, _react.css)(_templateObject32 || (_templateObject32 = (0, _taggedTemplateLiteral2.default)(["\n .", " {\n .", " {\n background-color: transparent;\n position: absolute;\n width: ", "px;\n height: 100%;\n top: 0;\n right: -", "px;\n cursor: col-resize;\n z-index: ", ";\n }\n\n ", "\n\n ", "\n\n table\n tr:first-of-type\n th.", "\n .", "::after,\n table\n tr:first-of-type\n td.", "\n .", "::after {\n top: -", "px;\n height: calc(100% + ", "px);\n }\n }\n"])), _types.TableCssClassName.TABLE_CONTAINER, _types.TableCssClassName.RESIZE_HANDLE_DECORATION, _consts.resizeHandlerAreaWidth, _consts.resizeHandlerAreaWidth / 2, _consts.resizeHandlerZIndex, getLastColumnResizerOverrides(), resizeHandleOverrides(isDragAndDropEnabled), _types.TableCssClassName.WITH_RESIZE_LINE, _types.TableCssClassName.RESIZE_HANDLE_DECORATION, _types.TableCssClassName.WITH_RESIZE_LINE, _types.TableCssClassName.RESIZE_HANDLE_DECORATION, _consts.tableToolbarSize + _styles.tableCellBorderWidth, _consts.tableToolbarSize + _styles.tableCellBorderWidth);
|
|
119
119
|
};
|
|
120
120
|
|
|
121
121
|
// Drag and Drop: drop target insert line
|
|
@@ -26,7 +26,7 @@ var _resizeState = require("../pm-plugins/table-resizing/utils/resize-state");
|
|
|
26
26
|
var _toolbar = require("../toolbar");
|
|
27
27
|
var _transforms = require("../transforms");
|
|
28
28
|
var _icons = require("../ui/icons");
|
|
29
|
-
var
|
|
29
|
+
var _selection = require("./selection");
|
|
30
30
|
var canDecrease = function canDecrease(index) {
|
|
31
31
|
var min = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
32
32
|
return index !== undefined && index > min;
|
|
@@ -38,7 +38,7 @@ var canIncrease = function canIncrease(index) {
|
|
|
38
38
|
var isDistributeColumnsEnabled = function isDistributeColumnsEnabled(state) {
|
|
39
39
|
var rect = (0, _toolbar.getClosestSelectionRect)(state);
|
|
40
40
|
if (rect) {
|
|
41
|
-
var selectedColIndexes = (0,
|
|
41
|
+
var selectedColIndexes = (0, _selection.getSelectedColumnIndexes)(rect);
|
|
42
42
|
return selectedColIndexes.length > 1;
|
|
43
43
|
}
|
|
44
44
|
return false;
|
|
@@ -67,38 +67,50 @@ var getDragMenuConfig = exports.getDragMenuConfig = function getDragMenuConfig(d
|
|
|
67
67
|
}];
|
|
68
68
|
var moveOptions = direction === 'row' ? [{
|
|
69
69
|
label: 'up',
|
|
70
|
-
offset: -1,
|
|
71
|
-
canMove: function canMove(index) {
|
|
72
|
-
return canDrag && canDecrease(index);
|
|
73
|
-
},
|
|
74
70
|
icon: _arrowUp.default,
|
|
75
|
-
keymap: _keymaps.moveRowUp
|
|
71
|
+
keymap: _keymaps.moveRowUp,
|
|
72
|
+
canMove: function canMove(selectionRect) {
|
|
73
|
+
return canDrag && canDecrease(selectionRect === null || selectionRect === void 0 ? void 0 : selectionRect.top);
|
|
74
|
+
},
|
|
75
|
+
getOriginIndexes: _selection.getSelectedRowIndexes,
|
|
76
|
+
getTargetIndex: function getTargetIndex(selectionRect) {
|
|
77
|
+
return selectionRect.top - 1;
|
|
78
|
+
}
|
|
76
79
|
}, {
|
|
77
80
|
label: 'down',
|
|
78
|
-
offset: 1,
|
|
79
|
-
canMove: function canMove(index) {
|
|
80
|
-
var _tableMap$height;
|
|
81
|
-
return canDrag && canIncrease(index, ((_tableMap$height = tableMap === null || tableMap === void 0 ? void 0 : tableMap.height) !== null && _tableMap$height !== void 0 ? _tableMap$height : 0) - 1);
|
|
82
|
-
},
|
|
83
81
|
icon: _arrowDown.default,
|
|
84
|
-
keymap: _keymaps.moveRowDown
|
|
82
|
+
keymap: _keymaps.moveRowDown,
|
|
83
|
+
canMove: function canMove(selectionRect) {
|
|
84
|
+
var _selectionRect$bottom, _tableMap$height;
|
|
85
|
+
return canDrag && canIncrease(((_selectionRect$bottom = selectionRect === null || selectionRect === void 0 ? void 0 : selectionRect.bottom) !== null && _selectionRect$bottom !== void 0 ? _selectionRect$bottom : 0) - 1, ((_tableMap$height = tableMap === null || tableMap === void 0 ? void 0 : tableMap.height) !== null && _tableMap$height !== void 0 ? _tableMap$height : 0) - 1);
|
|
86
|
+
},
|
|
87
|
+
getOriginIndexes: _selection.getSelectedRowIndexes,
|
|
88
|
+
getTargetIndex: function getTargetIndex(selectionRect) {
|
|
89
|
+
return selectionRect.bottom;
|
|
90
|
+
}
|
|
85
91
|
}] : [{
|
|
86
92
|
label: 'left',
|
|
87
|
-
offset: -1,
|
|
88
|
-
canMove: function canMove(index) {
|
|
89
|
-
return canDrag && canDecrease(index);
|
|
90
|
-
},
|
|
91
93
|
icon: _arrowLeft.default,
|
|
92
|
-
keymap: _keymaps.moveColumnLeft
|
|
94
|
+
keymap: _keymaps.moveColumnLeft,
|
|
95
|
+
canMove: function canMove(selectionRect) {
|
|
96
|
+
return canDrag && canDecrease(selectionRect === null || selectionRect === void 0 ? void 0 : selectionRect.left);
|
|
97
|
+
},
|
|
98
|
+
getOriginIndexes: _selection.getSelectedColumnIndexes,
|
|
99
|
+
getTargetIndex: function getTargetIndex(selectionRect) {
|
|
100
|
+
return selectionRect.left - 1;
|
|
101
|
+
}
|
|
93
102
|
}, {
|
|
94
103
|
label: 'right',
|
|
95
|
-
offset: 1,
|
|
96
|
-
canMove: function canMove(index) {
|
|
97
|
-
var _tableMap$width;
|
|
98
|
-
return canDrag && canIncrease(index, ((_tableMap$width = tableMap === null || tableMap === void 0 ? void 0 : tableMap.width) !== null && _tableMap$width !== void 0 ? _tableMap$width : 0) - 1);
|
|
99
|
-
},
|
|
100
104
|
icon: _arrowRight.default,
|
|
101
|
-
keymap: _keymaps.moveColumnRight
|
|
105
|
+
keymap: _keymaps.moveColumnRight,
|
|
106
|
+
canMove: function canMove(selectionRect) {
|
|
107
|
+
var _selectionRect$right, _tableMap$width;
|
|
108
|
+
return canDrag && canIncrease(((_selectionRect$right = selectionRect === null || selectionRect === void 0 ? void 0 : selectionRect.right) !== null && _selectionRect$right !== void 0 ? _selectionRect$right : 0) - 1, ((_tableMap$width = tableMap === null || tableMap === void 0 ? void 0 : tableMap.width) !== null && _tableMap$width !== void 0 ? _tableMap$width : 0) - 1);
|
|
109
|
+
},
|
|
110
|
+
getOriginIndexes: _selection.getSelectedColumnIndexes,
|
|
111
|
+
getTargetIndex: function getTargetIndex(selectionRect) {
|
|
112
|
+
return selectionRect.right;
|
|
113
|
+
}
|
|
102
114
|
}];
|
|
103
115
|
var sortOptions = direction === 'column' ? [{
|
|
104
116
|
label: 'increasing',
|
|
@@ -171,19 +183,20 @@ var getDragMenuConfig = exports.getDragMenuConfig = function getDragMenuConfig(d
|
|
|
171
183
|
keymap: direction === 'row' ? (0, _keymaps.tooltip)(_keymaps.deleteRow) : (0, _keymaps.tooltip)(_keymaps.deleteColumn)
|
|
172
184
|
}], (0, _toConsumableArray2.default)(moveOptions.map(function (_ref2) {
|
|
173
185
|
var label = _ref2.label,
|
|
174
|
-
offset = _ref2.offset,
|
|
175
186
|
canMove = _ref2.canMove,
|
|
176
187
|
icon = _ref2.icon,
|
|
177
|
-
keymap = _ref2.keymap
|
|
188
|
+
keymap = _ref2.keymap,
|
|
189
|
+
getOriginIndexes = _ref2.getOriginIndexes,
|
|
190
|
+
getTargetIndex = _ref2.getTargetIndex;
|
|
178
191
|
return {
|
|
179
192
|
id: "move_".concat(direction, "_").concat(label),
|
|
180
193
|
title: "Move ".concat(direction, " ").concat(label),
|
|
181
|
-
disabled: !canMove(
|
|
194
|
+
disabled: !canMove(selectionRect),
|
|
182
195
|
icon: icon,
|
|
183
196
|
onClick: function onClick(state, dispatch) {
|
|
184
|
-
if (canMove(
|
|
197
|
+
if (canMove(selectionRect)) {
|
|
185
198
|
requestAnimationFrame(function () {
|
|
186
|
-
(0, _commandsWithAnalytics.moveSourceWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.TABLE_CONTEXT_MENU, "table-".concat(direction),
|
|
199
|
+
(0, _commandsWithAnalytics.moveSourceWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.TABLE_CONTEXT_MENU, "table-".concat(direction), getOriginIndexes(selectionRect), getTargetIndex(selectionRect))(editorView.state, editorView.dispatch);
|
|
187
200
|
});
|
|
188
201
|
return true;
|
|
189
202
|
}
|
|
@@ -9,13 +9,14 @@ import { getPluginState as getDragDropPluginState } from './pm-plugins/drag-and-
|
|
|
9
9
|
import { getPluginState } from './pm-plugins/plugin-factory';
|
|
10
10
|
import { getPluginState as getResizePluginState } from './pm-plugins/table-resizing/plugin-factory';
|
|
11
11
|
import { deleteColumns, deleteRows } from './transforms';
|
|
12
|
-
import { RESIZE_HANDLE_AREA_DECORATION_GAP } from './types';
|
|
12
|
+
import { TableCssClassName as ClassName, RESIZE_HANDLE_AREA_DECORATION_GAP } from './types';
|
|
13
13
|
import { convertHTMLCellIndexToColumnIndex, getColumnIndexMappedToColumnIndexInFirstRow, getColumnOrRowIndex, getMousePositionHorizontalRelativeByElement, getMousePositionVerticalRelativeByElement, getSelectedCellInfo, hasResizeHandler, isCell, isColumnControlsDecorations, isCornerButton, isDragColumnFloatingInsertDot, isDragCornerButton, isDragRowFloatingInsertDot, isInsertRowButton, isResizeHandleDecoration, isRowControlsButton, isTableContainerOrWrapper, isTableControlsButton } from './utils';
|
|
14
14
|
import { getAllowAddColumnCustomStep } from './utils/get-allow-add-column-custom-step';
|
|
15
15
|
const isFocusingCalendar = event => event instanceof FocusEvent && event.relatedTarget instanceof HTMLElement && event.relatedTarget.getAttribute('aria-label') === 'calendar';
|
|
16
16
|
const isFocusingModal = event => event instanceof FocusEvent && event.relatedTarget instanceof HTMLElement && event.relatedTarget.closest('[role="dialog"]');
|
|
17
17
|
const isFocusingFloatingToolbar = event => event instanceof FocusEvent && event.relatedTarget instanceof HTMLElement && event.relatedTarget.closest('[role="toolbar"]');
|
|
18
18
|
const isFocusingDragHandles = event => event instanceof FocusEvent && event.relatedTarget instanceof HTMLElement && event.relatedTarget.closest('button') && event.relatedTarget.getAttribute('draggable') === 'true';
|
|
19
|
+
const isFocusingDragHandlesClickableZone = event => event instanceof FocusEvent && event.relatedTarget instanceof HTMLElement && event.relatedTarget.closest('button') && event.relatedTarget.classList.contains(ClassName.DRAG_HANDLE_BUTTON_CLICKABLE_ZONE);
|
|
19
20
|
export const handleBlur = (view, event) => {
|
|
20
21
|
const {
|
|
21
22
|
state,
|
|
@@ -23,7 +24,7 @@ export const handleBlur = (view, event) => {
|
|
|
23
24
|
} = view;
|
|
24
25
|
// IE version check for ED-4665
|
|
25
26
|
// Calendar focus check for ED-10466
|
|
26
|
-
if (browser.ie_version !== 11 && !isFocusingCalendar(event) && !isFocusingModal(event) && !isFocusingFloatingToolbar(event) && !isFocusingDragHandles(event)) {
|
|
27
|
+
if (browser.ie_version !== 11 && !isFocusingCalendar(event) && !isFocusingModal(event) && !isFocusingFloatingToolbar(event) && !isFocusingDragHandles(event) && !isFocusingDragHandlesClickableZone(event)) {
|
|
27
28
|
setEditorFocus(false)(state, dispatch);
|
|
28
29
|
}
|
|
29
30
|
event.preventDefault();
|
|
@@ -38,6 +38,7 @@ export const moveSourceWithAnalytics = editorAnalyticsAPI => (inputMethod, sourc
|
|
|
38
38
|
return withEditorAnalyticsAPI(({
|
|
39
39
|
selection
|
|
40
40
|
}) => {
|
|
41
|
+
const direction = sourceIndexes[0] > targetIndex ? -1 : 1;
|
|
41
42
|
const {
|
|
42
43
|
totalRowCount,
|
|
43
44
|
totalColumnCount
|
|
@@ -51,7 +52,7 @@ export const moveSourceWithAnalytics = editorAnalyticsAPI => (inputMethod, sourc
|
|
|
51
52
|
count: sourceIndexes.length,
|
|
52
53
|
// This identifies the total amount of row/cols the move operation covered. The distance covered should be a representaion
|
|
53
54
|
// of the minimum distance. This will account for large selection being moved causing a large distance travelled value.
|
|
54
|
-
distance: Math.min(...sourceIndexes.map(v => targetIndex - v)),
|
|
55
|
+
distance: Math.min(...sourceIndexes.map(v => Math.abs(targetIndex - v))) * direction,
|
|
55
56
|
// If a drop doesn't actually change anything then we're going to mark the event as cancelled.
|
|
56
57
|
status: sourceIndexes.includes(targetIndex) ? TABLE_STATUS.CANCELLED : TABLE_STATUS.SUCCESS,
|
|
57
58
|
totalRowCount,
|
|
@@ -77,15 +78,14 @@ export const moveSourceWithAnalyticsViaShortcut = editorAnalyticsAPI => (sourceT
|
|
|
77
78
|
}
|
|
78
79
|
const isRow = sourceType === 'table-row';
|
|
79
80
|
const selectedIndexes = isRow ? getSelectedRowIndexes(selectionRect) : getSelectedColumnIndexes(selectionRect);
|
|
80
|
-
|
|
81
|
-
// FIXME: We can move if only one row/column selected
|
|
82
|
-
if (selectedIndexes.length === 0 || selectedIndexes.length > 1) {
|
|
81
|
+
if (selectedIndexes.length === 0) {
|
|
83
82
|
return false;
|
|
84
83
|
}
|
|
85
|
-
|
|
84
|
+
|
|
85
|
+
// const sourceIndex = selectedIndexes[0];
|
|
86
86
|
// we can move only by one row/column
|
|
87
87
|
// 'direction' can only be 1 (for right or down) or -1 (for left or up)
|
|
88
|
-
const targetIndex =
|
|
88
|
+
const targetIndex = Math[direction < 0 ? 'min' : 'max'](...selectedIndexes) + direction;
|
|
89
89
|
|
|
90
90
|
// We can move only if targetIndex is a positive number and is not higher than the total number of rows/columns.
|
|
91
91
|
const {
|
|
@@ -98,7 +98,7 @@ export const moveSourceWithAnalyticsViaShortcut = editorAnalyticsAPI => (sourceT
|
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
// We can move only if there are no merged cells in the source or target row/column
|
|
101
|
-
const hasMergedCellsInSource = isRow ? hasMergedCellsInRow(
|
|
101
|
+
const hasMergedCellsInSource = isRow ? hasMergedCellsInRow(selectedIndexes)(selection) : hasMergedCellsInColumn(selectedIndexes)(selection);
|
|
102
102
|
if (hasMergedCellsInSource) {
|
|
103
103
|
return false;
|
|
104
104
|
}
|
|
@@ -106,5 +106,5 @@ export const moveSourceWithAnalyticsViaShortcut = editorAnalyticsAPI => (sourceT
|
|
|
106
106
|
if (hasMergedCellsInTarget) {
|
|
107
107
|
return false;
|
|
108
108
|
}
|
|
109
|
-
return moveSourceWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.SHORTCUT, sourceType,
|
|
109
|
+
return moveSourceWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.SHORTCUT, sourceType, selectedIndexes, targetIndex)(state, dispatch);
|
|
110
110
|
};
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
2
1
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
-
import { moveColumn, moveRow
|
|
2
|
+
import { moveColumn, moveRow } from '@atlaskit/editor-tables/utils';
|
|
4
3
|
import { TableDecorations } from '../../types';
|
|
5
4
|
import { createColumnInsertLine, createRowInsertLine, updateDecorations } from '../../utils';
|
|
6
|
-
import { combineTransforms } from '../../utils/transforms';
|
|
7
5
|
import { DragAndDropActionType } from './actions';
|
|
8
6
|
import { DropTargetType } from './consts';
|
|
9
7
|
import { createCommand, getPluginState } from './plugin-factory';
|
|
@@ -65,13 +63,10 @@ export const moveSource = (sourceType, sourceIndexes, targetIndex, tr) => create
|
|
|
65
63
|
if (sourceIndexes.includes(targetIndex)) {
|
|
66
64
|
return nextTr.setMeta('addToHistory', false);
|
|
67
65
|
}
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
return combineTransforms([moveRow(state, sourceIndexes, targetIndex), selectStartOfTable, selectRow(targetIndex)], nextTr);
|
|
73
|
-
}
|
|
74
|
-
return combineTransforms([moveColumn(state, sourceIndexes, targetIndex), selectStartOfTable, selectColumn(targetIndex)], nextTr);
|
|
66
|
+
const move = sourceType === 'table-row' ? moveRow : moveColumn;
|
|
67
|
+
return move(state, sourceIndexes, targetIndex, {
|
|
68
|
+
selectAfterMove: true
|
|
69
|
+
})(nextTr);
|
|
75
70
|
});
|
|
76
71
|
export const toggleDragMenu = (isDragMenuOpen, direction, index) => createCommand(state => {
|
|
77
72
|
let {
|
|
@@ -58,10 +58,7 @@ const destroyFn = (editorView, editorAnalyticsAPI) => {
|
|
|
58
58
|
} = source.data;
|
|
59
59
|
|
|
60
60
|
// First; Perform any quick checks so we can abort early.
|
|
61
|
-
if (!indexes || !localId ||
|
|
62
|
-
// FIXME: We currently don't support DragNDrop of multiple elements. For now we will not bother to monitor drags
|
|
63
|
-
// of more then 1 item.
|
|
64
|
-
indexes.length !== 1 || !(type === 'table-row' || type === 'table-column')) {
|
|
61
|
+
if (!indexes || !localId || !(type === 'table-row' || type === 'table-column')) {
|
|
65
62
|
return false;
|
|
66
63
|
}
|
|
67
64
|
const {
|
|
@@ -33,11 +33,6 @@ export const getDraggableDataFromEvent = ({
|
|
|
33
33
|
sourceLocalId !== targetLocalId) {
|
|
34
34
|
return undefined;
|
|
35
35
|
}
|
|
36
|
-
|
|
37
|
-
// FIXME: currently we only support a single row/col index being moved, remove this clause when this is no longer the case.
|
|
38
|
-
if (sourceIndexes.length > 1) {
|
|
39
|
-
return undefined;
|
|
40
|
-
}
|
|
41
36
|
const targetClosestEdge = (_extractClosestEdge = extractClosestEdge(destination.data)) !== null && _extractClosestEdge !== void 0 ? _extractClosestEdge : targetType === 'table-row' ? 'top' : 'left';
|
|
42
37
|
// NOTE: By default we always insert row/cols at the target index to the top/left (retrospectively of row/cols).
|
|
43
38
|
// This introduces an offset in the event the drop occured closer to the bottom/right of the target. We want
|
package/dist/es2019/types.js
CHANGED
|
@@ -91,6 +91,7 @@ export const TableCssClassName = {
|
|
|
91
91
|
DRAG_COLUMN_DROP_TARGET_CONTROLS: `${tablePrefixSelector}-col-drop-target-controls`,
|
|
92
92
|
DRAG_COLUMN_CONTROLS_INNER: `${tablePrefixSelector}-col-controls__inner`,
|
|
93
93
|
DRAG_HANDLE_BUTTON_CONTAINER: `${tablePrefixSelector}-drag-handle-button-container`,
|
|
94
|
+
DRAG_HANDLE_BUTTON_CLICKABLE_ZONE: `${tablePrefixSelector}-drag-handle-button-clickable-zone`,
|
|
94
95
|
DRAG_CORNER_BUTTON: `${tablePrefixSelector}-drag-corner-button`,
|
|
95
96
|
DRAG_CORNER_BUTTON_INNER: `${tablePrefixSelector}-drag-corner-button-inner`,
|
|
96
97
|
/** disabled classes */
|
|
@@ -9,6 +9,7 @@ import { setCustomNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/ut
|
|
|
9
9
|
import { getPluginState } from '../../pm-plugins/plugin-factory';
|
|
10
10
|
import { TableCssClassName as ClassName } from '../../types';
|
|
11
11
|
import { hasMergedCellsInColumn, hasMergedCellsInRow } from '../../utils';
|
|
12
|
+
import { dragTableInsertColumnButtonSize } from '../consts';
|
|
12
13
|
import { DragPreview } from '../DragPreview';
|
|
13
14
|
import { HandleIconComponent } from './HandleIconComponent';
|
|
14
15
|
const DragHandleComponent = ({
|
|
@@ -39,9 +40,11 @@ const DragHandleComponent = ({
|
|
|
39
40
|
const {
|
|
40
41
|
selection
|
|
41
42
|
} = editorView.state;
|
|
42
|
-
const
|
|
43
|
-
const
|
|
44
|
-
const
|
|
43
|
+
const isRow = direction === 'row';
|
|
44
|
+
const isColumn = direction === 'column';
|
|
45
|
+
const isRowHandleHovered = isRow && hoveredRows.length > 0;
|
|
46
|
+
const isColumnHandleHovered = isColumn && hoveredColumns.length > 0;
|
|
47
|
+
const hasMergedCells = useMemo(() => isRow ? hasMergedCellsInRow(indexes[0])(selection) : hasMergedCellsInColumn(indexes[0])(selection), [indexes, isRow, selection]);
|
|
45
48
|
const handleIconProps = {
|
|
46
49
|
forceDefaultHandle,
|
|
47
50
|
isColumnHandleHovered,
|
|
@@ -80,7 +83,7 @@ const DragHandleComponent = ({
|
|
|
80
83
|
// be generated.
|
|
81
84
|
container.style.left = `-${rect.width - 0.0001}px`;
|
|
82
85
|
}
|
|
83
|
-
if (
|
|
86
|
+
if (isRow) {
|
|
84
87
|
return {
|
|
85
88
|
x: 12,
|
|
86
89
|
y: rect.height / 2
|
|
@@ -103,19 +106,34 @@ const DragHandleComponent = ({
|
|
|
103
106
|
}
|
|
104
107
|
});
|
|
105
108
|
}
|
|
106
|
-
}, [tableLocalId, direction, indexes, editorView.state.selection, hasMergedCells, canDrag]);
|
|
107
|
-
const showDragMenuAnchorId =
|
|
109
|
+
}, [tableLocalId, direction, indexes, isRow, editorView.state.selection, hasMergedCells, canDrag]);
|
|
110
|
+
const showDragMenuAnchorId = isRow ? 'drag-handle-button-row' : 'drag-handle-button-column';
|
|
108
111
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("button", {
|
|
112
|
+
className: ClassName.DRAG_HANDLE_BUTTON_CLICKABLE_ZONE,
|
|
113
|
+
"data-testid": "table-drag-handle-clickable-zone-button",
|
|
114
|
+
style: {
|
|
115
|
+
height: isRow ? `calc(100% - ${dragTableInsertColumnButtonSize}px)` : `${"var(--ds-space-200, 16px)"}`,
|
|
116
|
+
// 16px here because it's the size of drag handle button's large side
|
|
117
|
+
width: isRow ? `${"var(--ds-space-200, 16px)"}` // 16px here because it's the size of drag handle button's large side
|
|
118
|
+
: `calc(100% - ${dragTableInsertColumnButtonSize}px)`,
|
|
119
|
+
left: isRow ? '3px' : undefined,
|
|
120
|
+
bottom: isColumn ? '0' : undefined,
|
|
121
|
+
alignSelf: isColumn ? 'none' : 'center',
|
|
122
|
+
zIndex: isColumn ? '-1' : 'auto'
|
|
123
|
+
},
|
|
124
|
+
onClick: onClick
|
|
125
|
+
}), /*#__PURE__*/React.createElement("button", {
|
|
109
126
|
id: isDragMenuTarget ? showDragMenuAnchorId : undefined,
|
|
110
127
|
className: classnames(ClassName.DRAG_HANDLE_BUTTON_CONTAINER, appearance, {
|
|
111
128
|
[ClassName.DRAG_HANDLE_DISABLED]: !canDrag || hasMergedCells
|
|
112
129
|
}),
|
|
113
130
|
ref: dragHandleDivRef,
|
|
114
131
|
style: {
|
|
115
|
-
transform:
|
|
132
|
+
transform: isColumn ? 'none' : 'rotate(90deg)',
|
|
133
|
+
alignSelf: isColumn ? 'none' : 'center'
|
|
116
134
|
},
|
|
117
135
|
"data-testid": "table-drag-handle-button",
|
|
118
|
-
"aria-label": formatMessage(
|
|
136
|
+
"aria-label": formatMessage(isRow ? messages.rowDragHandle : messages.columnDragHandle),
|
|
119
137
|
onMouseOver: onMouseOver,
|
|
120
138
|
onMouseOut: onMouseOut,
|
|
121
139
|
onMouseUp: e => {
|
|
@@ -26,7 +26,7 @@ import { getNewResizeStateFromSelectedColumns } from '../../pm-plugins/table-res
|
|
|
26
26
|
import { canMergeCells } from '../../transforms';
|
|
27
27
|
import { TableCssClassName as ClassName } from '../../types';
|
|
28
28
|
import { getMergedCellsPositions, getSelectedColumnIndexes, getSelectedRowIndexes } from '../../utils';
|
|
29
|
-
import { contextualMenuDropdownWidth } from '../consts';
|
|
29
|
+
import { contextualMenuDropdownWidth, contextualMenuDropdownWidthDnD } from '../consts';
|
|
30
30
|
import { AddColRightIcon, AddRowBelowIcon, MergeCellsIcon, SplitCellIcon } from '../icons';
|
|
31
31
|
import { cellColourPreviewStyles, elementBeforeIconStyles } from './styles';
|
|
32
32
|
export class ContextualMenu extends Component {
|
|
@@ -584,7 +584,7 @@ export class ContextualMenu extends Component {
|
|
|
584
584
|
onMouseEnter: this.handleItemMouseEnter,
|
|
585
585
|
onMouseLeave: this.handleItemMouseLeave,
|
|
586
586
|
fitHeight: 188,
|
|
587
|
-
fitWidth: contextualMenuDropdownWidth,
|
|
587
|
+
fitWidth: isDragAndDropEnabled ? contextualMenuDropdownWidthDnD : contextualMenuDropdownWidth,
|
|
588
588
|
boundariesElement: boundariesElement,
|
|
589
589
|
offset: offset,
|
|
590
590
|
section: isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') && getBooleanFF('platform.editor.menu.group-items') ? {
|
|
@@ -5,7 +5,7 @@ import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
|
5
5
|
import { akEditorFloatingDialogZIndex, akEditorFloatingOverlapPanelZIndex } from '@atlaskit/editor-shared-styles';
|
|
6
6
|
import { findCellRectClosestToPos, getSelectionRect, isSelectionType } from '@atlaskit/editor-tables/utils';
|
|
7
7
|
import { getPluginState } from '../../pm-plugins/plugin-factory';
|
|
8
|
-
import { contextualMenuDropdownWidth, contextualMenuTriggerSize } from '../consts';
|
|
8
|
+
import { contextualMenuDropdownWidth, contextualMenuDropdownWidthDnD, contextualMenuTriggerSize } from '../consts';
|
|
9
9
|
import ContextualMenu from './ContextualMenu';
|
|
10
10
|
import { tablePopupStyles } from './styles';
|
|
11
11
|
const FloatingContextualMenu = ({
|
|
@@ -20,7 +20,8 @@ const FloatingContextualMenu = ({
|
|
|
20
20
|
}) => {
|
|
21
21
|
// TargetCellPosition could be outdated: https://product-fabric.atlassian.net/browse/ED-8129
|
|
22
22
|
const {
|
|
23
|
-
targetCellPosition
|
|
23
|
+
targetCellPosition,
|
|
24
|
+
isDragAndDropEnabled
|
|
24
25
|
} = getPluginState(editorView.state);
|
|
25
26
|
if (!isOpen || !targetCellPosition || editorView.state.doc.nodeSize <= targetCellPosition) {
|
|
26
27
|
return null;
|
|
@@ -46,7 +47,7 @@ const FloatingContextualMenu = ({
|
|
|
46
47
|
boundariesElement: boundariesElement,
|
|
47
48
|
scrollableElement: scrollableElement,
|
|
48
49
|
fitHeight: 188,
|
|
49
|
-
fitWidth: contextualMenuDropdownWidth
|
|
50
|
+
fitWidth: isDragAndDropEnabled ? contextualMenuDropdownWidthDnD : contextualMenuDropdownWidth
|
|
50
51
|
// z-index value below is to ensure that this menu is above other floating menu
|
|
51
52
|
// in table, but below floating dialogs like typeaheads, pickers, etc.
|
|
52
53
|
,
|
|
@@ -55,7 +56,7 @@ const FloatingContextualMenu = ({
|
|
|
55
56
|
offset: [-7, 0],
|
|
56
57
|
stick: true
|
|
57
58
|
}, jsx("div", {
|
|
58
|
-
css: tablePopupStyles
|
|
59
|
+
css: tablePopupStyles(isDragAndDropEnabled)
|
|
59
60
|
}, jsx(ContextualMenu, {
|
|
60
61
|
editorView: editorView,
|
|
61
62
|
offset: [contextualMenuTriggerSize / 2, -contextualMenuTriggerSize],
|
|
@@ -2,7 +2,7 @@ import { css } from '@emotion/react';
|
|
|
2
2
|
import { tableBackgroundBorderColor } from '@atlaskit/adf-schema';
|
|
3
3
|
import { N60A, N90 } from '@atlaskit/theme/colors';
|
|
4
4
|
import { TableCssClassName as ClassName } from '../../types';
|
|
5
|
-
import { contextualMenuDropdownWidth } from '../consts';
|
|
5
|
+
import { contextualMenuDropdownWidth, contextualMenuDropdownWidthDnD } from '../consts';
|
|
6
6
|
export const cellColourPreviewStyles = selectedColor => css`
|
|
7
7
|
&::before {
|
|
8
8
|
background: ${selectedColor};
|
|
@@ -15,7 +15,7 @@ export const elementBeforeIconStyles = css`
|
|
|
15
15
|
|
|
16
16
|
// TODO Delete this comment after verifying space token -> previous value `padding: 8px`
|
|
17
17
|
// TODO Delete this comment after verifying space token -> previous value `margin-left: 4px`
|
|
18
|
-
export const tablePopupStyles = css`
|
|
18
|
+
export const tablePopupStyles = isDragAndDropEnabled => css`
|
|
19
19
|
.${ClassName.CONTEXTUAL_SUBMENU} {
|
|
20
20
|
border-radius: ${"var(--ds-border-radius, 3px)"};
|
|
21
21
|
background: ${"var(--ds-surface-overlay, white)"};
|
|
@@ -23,7 +23,7 @@ export const tablePopupStyles = css`
|
|
|
23
23
|
display: block;
|
|
24
24
|
position: absolute;
|
|
25
25
|
top: 0;
|
|
26
|
-
left: ${contextualMenuDropdownWidth}px;
|
|
26
|
+
left: ${isDragAndDropEnabled ? contextualMenuDropdownWidthDnD : contextualMenuDropdownWidth}px;
|
|
27
27
|
padding: ${"var(--ds-space-100, 8px)"};
|
|
28
28
|
|
|
29
29
|
> div {
|
|
@@ -103,11 +103,14 @@ export const ColumnControls = ({
|
|
|
103
103
|
clearHoverSelection()(state, dispatch);
|
|
104
104
|
}
|
|
105
105
|
}, [editorView, tableActive]);
|
|
106
|
-
const handleMouseUp = useCallback(
|
|
106
|
+
const handleMouseUp = useCallback(event => {
|
|
107
107
|
const {
|
|
108
108
|
state,
|
|
109
109
|
dispatch
|
|
110
110
|
} = editorView;
|
|
111
|
+
if (event.shiftKey) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
111
114
|
toggleDragMenu(undefined, 'column', colIndex)(state, dispatch);
|
|
112
115
|
}, [editorView, colIndex]);
|
|
113
116
|
const colIndexes = useMemo(() => {
|
|
@@ -160,7 +163,9 @@ export const ColumnControls = ({
|
|
|
160
163
|
alignItems: 'center',
|
|
161
164
|
height: 'fit-content',
|
|
162
165
|
placeSelf: 'center',
|
|
163
|
-
zIndex: 99
|
|
166
|
+
zIndex: 99,
|
|
167
|
+
width: '100%',
|
|
168
|
+
position: 'relative'
|
|
164
169
|
},
|
|
165
170
|
"data-column-control-index": hoveredCell.colIndex,
|
|
166
171
|
"data-testid": `table-floating-column-${isSelecting ? selectedColIndexes[0] : colIndex}-drag-handle`
|
|
@@ -4,18 +4,12 @@ import { ColumnDropTarget } from './ColumnDropTarget';
|
|
|
4
4
|
export const ColumnDropTargets = ({
|
|
5
5
|
tableRef,
|
|
6
6
|
tableHeight,
|
|
7
|
-
stickyTop,
|
|
8
7
|
localId,
|
|
9
|
-
rowHeights,
|
|
10
8
|
colWidths
|
|
11
9
|
}) => {
|
|
12
|
-
var _rowHeights$;
|
|
13
10
|
if (!tableRef) {
|
|
14
11
|
return null;
|
|
15
12
|
}
|
|
16
|
-
const firstRow = tableRef.querySelector('tr');
|
|
17
|
-
const hasHeaderRow = firstRow ? firstRow.getAttribute('data-header-row') : false;
|
|
18
|
-
const marginTop = hasHeaderRow && stickyTop !== undefined ? (_rowHeights$ = rowHeights === null || rowHeights === void 0 ? void 0 : rowHeights[0]) !== null && _rowHeights$ !== void 0 ? _rowHeights$ : 0 : 0;
|
|
19
13
|
return /*#__PURE__*/React.createElement("div", {
|
|
20
14
|
className: ClassName.DRAG_COLUMN_DROP_TARGET_CONTROLS,
|
|
21
15
|
contentEditable: false
|
|
@@ -29,7 +23,7 @@ export const ColumnDropTargets = ({
|
|
|
29
23
|
localId: localId,
|
|
30
24
|
width: width,
|
|
31
25
|
height: tableHeight,
|
|
32
|
-
marginTop:
|
|
26
|
+
marginTop: 0
|
|
33
27
|
});
|
|
34
28
|
})));
|
|
35
29
|
};
|
|
@@ -112,10 +112,8 @@ export const TableFloatingColumnControls = ({
|
|
|
112
112
|
isDragging: isDragging
|
|
113
113
|
}), isDragging && /*#__PURE__*/React.createElement(ColumnDropTargets, {
|
|
114
114
|
tableRef: tableRef,
|
|
115
|
-
stickyTop: tableActive ? stickyTop : undefined,
|
|
116
115
|
tableHeight: tableRect.height,
|
|
117
116
|
localId: currentNodeLocalId,
|
|
118
|
-
rowHeights: rowHeights,
|
|
119
117
|
colWidths: colWidths
|
|
120
118
|
}));
|
|
121
119
|
};
|
|
@@ -74,7 +74,10 @@ const DragControlsComponent = ({
|
|
|
74
74
|
}
|
|
75
75
|
});
|
|
76
76
|
}, [editorView]);
|
|
77
|
-
const onMouseUp = useCallback(
|
|
77
|
+
const onMouseUp = useCallback(event => {
|
|
78
|
+
if (event.shiftKey) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
78
81
|
toggleDragMenu(undefined, 'row', hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.rowIndex)(editorView.state, editorView.dispatch);
|
|
79
82
|
}, [editorView, hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.rowIndex]);
|
|
80
83
|
const rowIndex = hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.rowIndex;
|
|
@@ -136,7 +139,9 @@ const DragControlsComponent = ({
|
|
|
136
139
|
gridRow: isSelecting ? selectedRowPosition : gridRowPosition,
|
|
137
140
|
gridColumn: '2',
|
|
138
141
|
// DragHandle uses `transform: rotate(90)`, which doesn't affect its parent (this div) causing the width of this element to be the true height of the drag handle
|
|
142
|
+
display: 'flex',
|
|
139
143
|
width: '9px',
|
|
144
|
+
height: '100%',
|
|
140
145
|
position: 'relative',
|
|
141
146
|
right: '-0.5px'
|
|
142
147
|
},
|
|
@@ -204,7 +204,9 @@ const tableWrapperStyles = () => {
|
|
|
204
204
|
};
|
|
205
205
|
|
|
206
206
|
// TODO: https://product-fabric.atlassian.net/browse/DSP-4139
|
|
207
|
-
export const tableStyles = props =>
|
|
207
|
+
export const tableStyles = props => {
|
|
208
|
+
var _props$featureFlags, _props$featureFlags2, _props$featureFlags3, _props$featureFlags4;
|
|
209
|
+
return css`
|
|
208
210
|
.${ClassName.LAYOUT_BUTTON} button {
|
|
209
211
|
background: ${`var(--ds-background-neutral, ${N20A})`};
|
|
210
212
|
color: ${`var(--ds-icon, ${N300})`};
|
|
@@ -223,8 +225,8 @@ export const tableStyles = props => css`
|
|
|
223
225
|
${hoveredDeleteButton()};
|
|
224
226
|
${hoveredCell()};
|
|
225
227
|
${hoveredWarningCell};
|
|
226
|
-
${
|
|
227
|
-
${resizeHandle()};
|
|
228
|
+
${((_props$featureFlags = props.featureFlags) === null || _props$featureFlags === void 0 ? void 0 : _props$featureFlags.tableDragAndDrop) && insertLine()};
|
|
229
|
+
${resizeHandle((_props$featureFlags2 = props.featureFlags) === null || _props$featureFlags2 === void 0 ? void 0 : _props$featureFlags2.tableDragAndDrop)};
|
|
228
230
|
${rangeSelectionStyles};
|
|
229
231
|
|
|
230
232
|
.${ClassName.LAST_ITEM_IN_CELL} {
|
|
@@ -434,7 +436,7 @@ export const tableStyles = props => css`
|
|
|
434
436
|
}
|
|
435
437
|
|
|
436
438
|
${sentinelStyles}
|
|
437
|
-
${OverflowShadow()}
|
|
439
|
+
${OverflowShadow((_props$featureFlags3 = props.featureFlags) === null || _props$featureFlags3 === void 0 ? void 0 : _props$featureFlags3.tableDragAndDrop)}
|
|
438
440
|
${stickyScrollbarStyles(props.featureFlags)}
|
|
439
441
|
|
|
440
442
|
.${ClassName.TABLE_STICKY} .${ClassName.TABLE_STICKY_SHADOW} {
|
|
@@ -653,6 +655,22 @@ export const tableStyles = props => css`
|
|
|
653
655
|
}
|
|
654
656
|
}
|
|
655
657
|
|
|
658
|
+
.${ClassName.DRAG_HANDLE_BUTTON_CLICKABLE_ZONE} {
|
|
659
|
+
background: none;
|
|
660
|
+
border: none;
|
|
661
|
+
outline: none;
|
|
662
|
+
position: absolute;
|
|
663
|
+
margin: 0;
|
|
664
|
+
padding: 0;
|
|
665
|
+
display: flex;
|
|
666
|
+
align-items: center;
|
|
667
|
+
cursor: pointer;
|
|
668
|
+
|
|
669
|
+
:focus {
|
|
670
|
+
outline: none;
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
|
|
656
674
|
.${ClassName.DRAG_HANDLE_BUTTON_CONTAINER} {
|
|
657
675
|
cursor: grab;
|
|
658
676
|
pointer-events: auto;
|
|
@@ -739,7 +757,7 @@ export const tableStyles = props => css`
|
|
|
739
757
|
position: relative;
|
|
740
758
|
float: right;
|
|
741
759
|
margin-left: ${getBooleanFF('platform.editor.custom-table-width') ? akEditorTableToolbarSize : akEditorTableToolbarSize - 1}px;
|
|
742
|
-
top: ${
|
|
760
|
+
top: ${(_props$featureFlags4 = props.featureFlags) !== null && _props$featureFlags4 !== void 0 && _props$featureFlags4.tableDragAndDrop ? 0 : akEditorTableToolbarSize}px;
|
|
743
761
|
width: ${akEditorTableNumberColumnWidth + 1}px;
|
|
744
762
|
box-sizing: border-box;
|
|
745
763
|
}
|
|
@@ -969,6 +987,7 @@ export const tableStyles = props => css`
|
|
|
969
987
|
|
|
970
988
|
${shadowSentinelStyles}
|
|
971
989
|
`;
|
|
990
|
+
};
|
|
972
991
|
export const tableFullPageEditorStyles = css`
|
|
973
992
|
.ProseMirror .${ClassName.TABLE_NODE_WRAPPER} > table {
|
|
974
993
|
margin-left: 0;
|