@atlaskit/editor-plugin-table 5.3.26 → 5.3.27
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 +7 -0
- package/dist/cjs/plugins/table/commands/hover.js +9 -3
- package/dist/cjs/plugins/table/types.js +3 -0
- package/dist/cjs/plugins/table/ui/DragHandle/index.js +16 -4
- package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +2 -1
- package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +2 -1
- package/dist/cjs/plugins/table/ui/common-styles.js +1 -1
- package/dist/cjs/plugins/table/ui/consts.js +2 -1
- package/dist/cjs/plugins/table/ui/icons/DragHandleDisabledIcon.js +45 -0
- package/dist/cjs/plugins/table/ui/icons/index.js +7 -0
- package/dist/cjs/plugins/table/ui/ui-styles.js +12 -9
- package/dist/cjs/plugins/table/utils/decoration.js +7 -1
- package/dist/es2019/plugins/table/commands/hover.js +13 -4
- package/dist/es2019/plugins/table/types.js +3 -0
- package/dist/es2019/plugins/table/ui/DragHandle/index.js +19 -6
- package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +2 -1
- package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +2 -1
- package/dist/es2019/plugins/table/ui/common-styles.js +30 -38
- package/dist/es2019/plugins/table/ui/consts.js +1 -0
- package/dist/es2019/plugins/table/ui/icons/DragHandleDisabledIcon.js +37 -0
- package/dist/es2019/plugins/table/ui/icons/index.js +1 -0
- package/dist/es2019/plugins/table/ui/ui-styles.js +13 -1
- package/dist/es2019/plugins/table/utils/decoration.js +7 -1
- package/dist/esm/plugins/table/commands/hover.js +10 -4
- package/dist/esm/plugins/table/types.js +3 -0
- package/dist/esm/plugins/table/ui/DragHandle/index.js +18 -6
- package/dist/esm/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +2 -1
- package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +2 -1
- package/dist/esm/plugins/table/ui/common-styles.js +2 -2
- package/dist/esm/plugins/table/ui/consts.js +1 -0
- package/dist/esm/plugins/table/ui/icons/DragHandleDisabledIcon.js +38 -0
- package/dist/esm/plugins/table/ui/icons/index.js +1 -0
- package/dist/esm/plugins/table/ui/ui-styles.js +12 -9
- package/dist/esm/plugins/table/utils/decoration.js +7 -1
- package/dist/types/plugins/table/types.d.ts +3 -0
- package/dist/types/plugins/table/ui/DragHandle/index.d.ts +3 -1
- package/dist/types/plugins/table/ui/consts.d.ts +1 -0
- package/dist/types/plugins/table/ui/icons/DragHandleDisabledIcon.d.ts +6 -0
- package/dist/types/plugins/table/ui/icons/index.d.ts +1 -0
- package/dist/types/plugins/table/ui/ui-styles.d.ts +1 -0
- package/dist/types/plugins/table/utils/decoration.d.ts +1 -1
- package/dist/types/plugins/table/utils/selection.d.ts +2 -2
- package/dist/types-ts4.5/plugins/table/types.d.ts +3 -0
- package/dist/types-ts4.5/plugins/table/ui/DragHandle/index.d.ts +3 -1
- package/dist/types-ts4.5/plugins/table/ui/consts.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/ui/icons/DragHandleDisabledIcon.d.ts +6 -0
- package/dist/types-ts4.5/plugins/table/ui/icons/index.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/ui/ui-styles.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/utils/decoration.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/utils/selection.d.ts +2 -2
- package/package.json +2 -2
- package/src/plugins/table/commands/hover.ts +12 -1
- package/src/plugins/table/types.ts +4 -0
- package/src/plugins/table/ui/DragHandle/index.tsx +36 -5
- package/src/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.tsx +1 -0
- package/src/plugins/table/ui/TableFloatingControls/RowControls/DragControls.tsx +1 -0
- package/src/plugins/table/ui/common-styles.ts +33 -40
- package/src/plugins/table/ui/consts.ts +6 -0
- package/src/plugins/table/ui/icons/DragHandleDisabledIcon.tsx +53 -0
- package/src/plugins/table/ui/icons/index.ts +1 -0
- package/src/plugins/table/ui/ui-styles.ts +13 -0
- package/src/plugins/table/utils/decoration.ts +14 -0
- package/src/plugins/table/utils/selection.ts +6 -2
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export var DragHandleDisabledIcon = function DragHandleDisabledIcon(_ref) {
|
|
3
|
+
var style = _ref.style;
|
|
4
|
+
return /*#__PURE__*/React.createElement("svg", {
|
|
5
|
+
width: "24",
|
|
6
|
+
height: "16",
|
|
7
|
+
viewBox: "0 0 24 16",
|
|
8
|
+
fill: "none",
|
|
9
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
10
|
+
style: style
|
|
11
|
+
}, /*#__PURE__*/React.createElement("rect", {
|
|
12
|
+
width: "24",
|
|
13
|
+
height: "16",
|
|
14
|
+
rx: "4",
|
|
15
|
+
fill: "var(--ds-background-accent-gray-subtlest, Neutral200)"
|
|
16
|
+
}), /*#__PURE__*/React.createElement("g", null, /*#__PURE__*/React.createElement("rect", {
|
|
17
|
+
x: "7",
|
|
18
|
+
y: "4",
|
|
19
|
+
width: "2",
|
|
20
|
+
height: "8",
|
|
21
|
+
rx: "1",
|
|
22
|
+
fill: "var(--ds-icon-disabled, #091E424F)"
|
|
23
|
+
}), /*#__PURE__*/React.createElement("rect", {
|
|
24
|
+
x: "11",
|
|
25
|
+
y: "4",
|
|
26
|
+
width: "2",
|
|
27
|
+
height: "8",
|
|
28
|
+
rx: "1",
|
|
29
|
+
fill: "var(--ds-icon-disabled, #091E424F)"
|
|
30
|
+
}), /*#__PURE__*/React.createElement("rect", {
|
|
31
|
+
x: "15",
|
|
32
|
+
y: "4",
|
|
33
|
+
width: "2",
|
|
34
|
+
height: "8",
|
|
35
|
+
rx: "1",
|
|
36
|
+
fill: "var(--ds-icon-disabled, #091E424F)"
|
|
37
|
+
})));
|
|
38
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { DragHandleIcon } from './DragHandleIcon';
|
|
2
2
|
export { DragInMotionIcon } from './DragInMotionIcon';
|
|
3
|
+
export { DragHandleDisabledIcon } from './DragHandleDisabledIcon';
|
|
3
4
|
export { AddRowAboveIcon } from './AddRowAboveIcon';
|
|
4
5
|
export { AddRowBelowIcon } from './AddRowBelowIcon';
|
|
5
6
|
export { AddColLeftIcon } from './AddColLeftIcon';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18, _templateObject19, _templateObject20, _templateObject21, _templateObject22, _templateObject23, _templateObject24, _templateObject25, _templateObject26, _templateObject27, _templateObject28, _templateObject29, _templateObject30, _templateObject31, _templateObject32, _templateObject33;
|
|
2
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18, _templateObject19, _templateObject20, _templateObject21, _templateObject22, _templateObject23, _templateObject24, _templateObject25, _templateObject26, _templateObject27, _templateObject28, _templateObject29, _templateObject30, _templateObject31, _templateObject32, _templateObject33, _templateObject34;
|
|
3
3
|
import { css } from '@emotion/react';
|
|
4
4
|
import { tableCellBorderWidth, tableMarginTop, tableMarginTopWithControl } from '@atlaskit/editor-common/styles';
|
|
5
5
|
import { akEditorShadowZIndex, akEditorTableNumberColumnWidth, akEditorUnitZIndex } from '@atlaskit/editor-shared-styles';
|
|
@@ -7,7 +7,7 @@ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
|
7
7
|
import { B300, N0, N300, N40A, N60A, Y200, Y50 } from '@atlaskit/theme/colors';
|
|
8
8
|
import { borderRadius } from '@atlaskit/theme/constants';
|
|
9
9
|
import { TableCssClassName as ClassName } from '../types';
|
|
10
|
-
import { columnControlsDecorationHeight, columnControlsSelectedZIndex, columnControlsZIndex, insertLineWidth, lineMarkerSize, resizeHandlerAreaWidth, resizeHandlerZIndex, resizeLineWidth, tableBorderColor, tableBorderDeleteColor, tableBorderSelectedColor, tableCellDeleteColor, tableCellHoverDeleteIconBackground, tableCellHoverDeleteIconColor, tableCellSelectedDeleteIconBackground, tableCellSelectedDeleteIconColor, tableDeleteButtonSize, tableHeaderCellBackgroundColor, tableInsertColumnButtonSize, tableOverflowShadowWidth, tableOverflowShadowWidthWide, tableToolbarDeleteColor, tableToolbarSelectedColor, tableToolbarSize } from './consts';
|
|
10
|
+
import { columnControlsDecorationHeight, columnControlsSelectedZIndex, columnControlsZIndex, insertLineWidth, lineMarkerSize, resizeHandlerAreaWidth, resizeHandlerZIndex, resizeLineWidth, tableBorderColor, tableBorderDeleteColor, tableBorderSelectedColor, tableCellDeleteColor, tableCellDisabledColor, tableCellHoverDeleteIconBackground, tableCellHoverDeleteIconColor, tableCellSelectedDeleteIconBackground, tableCellSelectedDeleteIconColor, tableDeleteButtonSize, tableHeaderCellBackgroundColor, tableInsertColumnButtonSize, tableOverflowShadowWidth, tableOverflowShadowWidthWide, tableToolbarDeleteColor, tableToolbarSelectedColor, tableToolbarSize } from './consts';
|
|
11
11
|
var InsertLine = function InsertLine(props, cssString) {
|
|
12
12
|
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .", " {\n background: ", ";\n display: none;\n position: absolute;\n z-index: ", ";\n ", "\n }\n"])), ClassName.CONTROLS_INSERT_LINE, tableBorderSelectedColor(props), akEditorUnitZIndex, cssString);
|
|
13
13
|
};
|
|
@@ -89,24 +89,27 @@ export var columnControlsDecoration = function columnControlsDecoration(props) {
|
|
|
89
89
|
export var hoveredDeleteButton = function hoveredDeleteButton(props) {
|
|
90
90
|
return css(_templateObject26 || (_templateObject26 = _taggedTemplateLiteral(["\n .", ".", " {\n .", ",\n .", ",\n .", " {\n border: 1px solid ", ";\n }\n .", "::after {\n background: ", ";\n }\n }\n"])), ClassName.TABLE_CONTAINER, ClassName.HOVERED_DELETE_BUTTON, ClassName.SELECTED_CELL, ClassName.COLUMN_SELECTED, ClassName.HOVERED_CELL, tableBorderDeleteColor(props), ClassName.SELECTED_CELL, tableCellDeleteColor(props));
|
|
91
91
|
};
|
|
92
|
+
export var disabledCell = function disabledCell(props) {
|
|
93
|
+
return css(_templateObject27 || (_templateObject27 = _taggedTemplateLiteral(["\n :not(.", ")\n .", ":not(.", ") {\n .", ".", " {\n position: relative;\n border: 1px solid ", ";\n }\n .", ".", "::after {\n border: 1px solid ", ";\n }\n }\n"])), ClassName.IS_RESIZING, ClassName.TABLE_CONTAINER, ClassName.HOVERED_DELETE_BUTTON, ClassName.HOVERED_CELL, ClassName.HOVERED_DISABLED_CELL, tableCellDisabledColor, ClassName.HOVERED_CELL, ClassName.HOVERED_DISABLED_CELL, tableCellDisabledColor);
|
|
94
|
+
};
|
|
92
95
|
export var hoveredCell = function hoveredCell(props) {
|
|
93
|
-
return css(
|
|
96
|
+
return css(_templateObject28 || (_templateObject28 = _taggedTemplateLiteral(["\n :not(.", ")\n .", ":not(.", ") {\n .", " {\n position: relative;\n border: 1px solid ", ";\n }\n }\n"])), ClassName.IS_RESIZING, ClassName.TABLE_CONTAINER, ClassName.HOVERED_DELETE_BUTTON, ClassName.HOVERED_CELL, tableBorderSelectedColor(props));
|
|
94
97
|
};
|
|
95
|
-
export var hoveredWarningCell = css(
|
|
98
|
+
export var hoveredWarningCell = css(_templateObject29 || (_templateObject29 = _taggedTemplateLiteral(["\n :not(.", ")\n .", ":not(.", ") {\n td.", " {\n background-color: ", " !important; // We need to override the background-color added to the cell\n border: 1px solid ", ";\n }\n }\n"])), ClassName.IS_RESIZING, ClassName.TABLE_CONTAINER, ClassName.HOVERED_DELETE_BUTTON, ClassName.HOVERED_CELL_WARNING, "var(--ds-background-warning, ".concat(Y50, ")"), "var(--ds-border-warning, ".concat(Y200, ")"));
|
|
96
99
|
|
|
97
100
|
// move the resize handle zone completely inside the table cell to avoid overflow
|
|
98
101
|
var getLastColumnResizerOverrides = function getLastColumnResizerOverrides() {
|
|
99
|
-
return getBooleanFF('platform.editor.custom-table-width') ? css(
|
|
102
|
+
return getBooleanFF('platform.editor.custom-table-width') ? css(_templateObject30 || (_templateObject30 = _taggedTemplateLiteral(["\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 "])), ClassName.RESIZE_HANDLE_DECORATION, ClassName.RESIZE_HANDLE_DECORATION, resizeHandlerAreaWidth / 2, resizeHandlerZIndex) : '';
|
|
100
103
|
};
|
|
101
104
|
var resizeHandleOverrides = function resizeHandleOverrides(props) {
|
|
102
105
|
if (getBooleanFF('platform.editor.table.drag-and-drop')) {
|
|
103
|
-
return css(
|
|
106
|
+
return css(_templateObject31 || (_templateObject31 = _taggedTemplateLiteral(["\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 "])), ClassName.WITH_RESIZE_LINE, ClassName.WITH_RESIZE_LINE, "var(--ds-space-negative-025, -2px)", resizeLineWidth, tableBorderSelectedColor(props), columnControlsZIndex * 2, ClassName.WITH_RESIZE_LINE_LAST_COLUMN, ClassName.WITH_RESIZE_LINE_LAST_COLUMN, resizeLineWidth, tableBorderSelectedColor(props), columnControlsZIndex * 2);
|
|
104
107
|
}
|
|
105
|
-
return css(
|
|
108
|
+
return css(_templateObject32 || (_templateObject32 = _taggedTemplateLiteral(["\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 "])), ClassName.WITH_RESIZE_LINE, "var(--ds-space-negative-025, -2px)", resizeLineWidth, tableBorderSelectedColor(props), columnControlsZIndex * 2, ClassName.WITH_RESIZE_LINE, "var(--ds-space-negative-025, -2px)", resizeLineWidth, tableToolbarSize + tableCellBorderWidth, tableBorderSelectedColor(props), columnControlsZIndex * 2, tableToolbarSize + tableCellBorderWidth, ClassName.WITH_RESIZE_LINE_LAST_COLUMN, resizeLineWidth, tableBorderSelectedColor(props), columnControlsZIndex * 2, ClassName.WITH_RESIZE_LINE_LAST_COLUMN, resizeLineWidth, tableToolbarSize + tableCellBorderWidth, tableBorderSelectedColor(props), columnControlsZIndex * 2, tableToolbarSize + tableCellBorderWidth);
|
|
106
109
|
};
|
|
107
110
|
export var resizeHandle = function resizeHandle(props) {
|
|
108
|
-
return css(
|
|
111
|
+
return css(_templateObject33 || (_templateObject33 = _taggedTemplateLiteral(["\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"])), ClassName.TABLE_CONTAINER, ClassName.RESIZE_HANDLE_DECORATION, resizeHandlerAreaWidth, resizeHandlerAreaWidth / 2, resizeHandlerZIndex, getLastColumnResizerOverrides(), resizeHandleOverrides(props), ClassName.WITH_RESIZE_LINE, ClassName.RESIZE_HANDLE_DECORATION, ClassName.WITH_RESIZE_LINE, ClassName.RESIZE_HANDLE_DECORATION, tableToolbarSize + tableCellBorderWidth, tableToolbarSize + tableCellBorderWidth);
|
|
109
112
|
};
|
|
110
113
|
export var insertLine = function insertLine(props) {
|
|
111
|
-
return css(
|
|
114
|
+
return css(_templateObject34 || (_templateObject34 = _taggedTemplateLiteral(["\n .", " {\n td.", "::before {\n content: ' ';\n position: absolute;\n left: -1px;\n top: -1px;\n width: ", "px;\n height: calc(100% + ", "px);\n background-color: ", ";\n z-index: ", ";\n }\n\n th.", "::before {\n content: ' ';\n left: -1px;\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 left: ", ";\n top: -1px;\n width: ", "px;\n height: calc(100% + ", "px);\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% + ", "px);\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\n td.", "::before {\n content: ' ';\n position: absolute;\n left: ", ";\n top: -1px;\n height: ", "px;\n width: calc(100% + ", "px);\n background-color: ", ";\n z-index: ", ";\n }\n\n th.", "::before {\n content: ' ';\n left: ", ";\n position: absolute;\n height: ", "px;\n width: calc(100% + ", "px);\n background-color: ", ";\n z-index: ", ";\n top: -1px;\n }\n\n td.", "::before {\n content: ' ';\n position: absolute;\n left: ", ";\n bottom: 0;\n height: ", "px;\n width: calc(100% + 2px);\n background-color: ", ";\n z-index: ", ";\n }\n\n th.", "::before {\n content: ' ';\n left: ", ";\n bottom: 0;\n position: absolute;\n height: ", "px;\n width: calc(100% + ", "px);\n background-color: ", ";\n z-index: ", ";\n }\n }\n"])), ClassName.TABLE_CONTAINER, ClassName.WITH_FIRST_COLUMN_INSERT_LINE, insertLineWidth, tableCellBorderWidth * 2, tableBorderSelectedColor(props), columnControlsZIndex * 2, ClassName.WITH_FIRST_COLUMN_INSERT_LINE, insertLineWidth, tableCellBorderWidth * 2, tableBorderSelectedColor(props), columnControlsZIndex * 2, tableCellBorderWidth, ClassName.WITH_COLUMN_INSERT_LINE, "var(--ds-space-negative-025, -2px)", insertLineWidth, tableCellBorderWidth * 2, tableBorderSelectedColor(props), columnControlsZIndex * 2, ClassName.WITH_COLUMN_INSERT_LINE, "var(--ds-space-negative-025, -2px)", insertLineWidth, tableCellBorderWidth * 2, tableBorderSelectedColor(props), columnControlsZIndex * 2, tableCellBorderWidth, ClassName.WITH_LAST_COLUMN_INSERT_LINE, insertLineWidth, tableCellBorderWidth * 2, tableBorderSelectedColor(props), columnControlsZIndex * 2, ClassName.WITH_LAST_COLUMN_INSERT_LINE, insertLineWidth, tableCellBorderWidth * 2, tableBorderSelectedColor(props), columnControlsZIndex * 2, tableCellBorderWidth, ClassName.WITH_ROW_INSERT_LINE, "var(--ds-space-negative-025, -2px)", insertLineWidth, tableCellBorderWidth * 2, tableBorderSelectedColor(props), columnControlsZIndex * 2, ClassName.WITH_ROW_INSERT_LINE, "var(--ds-space-negative-025, -2px)", insertLineWidth, tableCellBorderWidth * 2, tableBorderSelectedColor(props), columnControlsZIndex * 2, ClassName.WITH_LAST_ROW_INSERT_LINE, "var(--ds-space-negative-025, -2px)", insertLineWidth, tableBorderSelectedColor(props), columnControlsZIndex * 2, ClassName.WITH_LAST_ROW_INSERT_LINE, "var(--ds-space-negative-025, -2px)", insertLineWidth, tableCellBorderWidth * 2, tableBorderSelectedColor(props), columnControlsZIndex * 2);
|
|
112
115
|
};
|
|
@@ -12,6 +12,7 @@ import { findTable, getCellsInRow, getSelectionRect } from '@atlaskit/editor-tab
|
|
|
12
12
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
13
13
|
import { TableCssClassName as ClassName, TableDecorations } from '../types';
|
|
14
14
|
import { ColumnResizeWidget } from '../ui/ColumnResizeWidget';
|
|
15
|
+
import { hasMergedCellsInColumn, hasMergedCellsInRow } from './merged-cells';
|
|
15
16
|
var filterDecorationByKey = function filterDecorationByKey(key, decorationSet) {
|
|
16
17
|
return decorationSet.find(undefined, undefined, function (spec) {
|
|
17
18
|
return spec.key.indexOf(key) > -1;
|
|
@@ -32,7 +33,7 @@ export var createCellHoverDecoration = function createCellHoverDecoration(cells)
|
|
|
32
33
|
});
|
|
33
34
|
});
|
|
34
35
|
};
|
|
35
|
-
export var createControlsHoverDecoration = function createControlsHoverDecoration(cells, type, tr, danger, selected) {
|
|
36
|
+
export var createControlsHoverDecoration = function createControlsHoverDecoration(cells, type, tr, isDragAndDropEnable, hoveredIndexes, danger, selected) {
|
|
36
37
|
var table = findTable(tr.selection);
|
|
37
38
|
if (!table) {
|
|
38
39
|
return [];
|
|
@@ -59,6 +60,8 @@ export var createControlsHoverDecoration = function createControlsHoverDecoratio
|
|
|
59
60
|
var updatedCells = cells.map(function (x) {
|
|
60
61
|
return x.pos;
|
|
61
62
|
});
|
|
63
|
+
var hasMergedCells = type === 'row' ? hasMergedCellsInRow(hoveredIndexes[0])(tr.selection) : hasMergedCellsInColumn(hoveredIndexes[0])(tr.selection);
|
|
64
|
+
var disabled = hasMergedCells;
|
|
62
65
|
|
|
63
66
|
// ED-15246 fixed trello card table overflow issue
|
|
64
67
|
// If columns / rows have been merged the hovered selection is different to the actual selection
|
|
@@ -109,6 +112,9 @@ export var createControlsHoverDecoration = function createControlsHoverDecoratio
|
|
|
109
112
|
if (selected) {
|
|
110
113
|
classes.push(ClassName.SELECTED_CELL);
|
|
111
114
|
}
|
|
115
|
+
if (isDragAndDropEnable && disabled) {
|
|
116
|
+
classes.push(ClassName.HOVERED_DISABLED_CELL);
|
|
117
|
+
}
|
|
112
118
|
classes.push(type === 'column' ? ClassName.HOVERED_COLUMN : type === 'row' ? ClassName.HOVERED_ROW : ClassName.HOVERED_TABLE);
|
|
113
119
|
var key;
|
|
114
120
|
switch (type) {
|
|
@@ -293,6 +293,8 @@ export declare const TableCssClassName: {
|
|
|
293
293
|
DRAG_HANDLE_BUTTON_CONTAINER: string;
|
|
294
294
|
DRAG_CORNER_BUTTON: string;
|
|
295
295
|
DRAG_CORNER_BUTTON_INNER: string;
|
|
296
|
+
/** disabled classes */
|
|
297
|
+
DRAG_HANDLE_DISABLED: string;
|
|
296
298
|
/** Other classes */
|
|
297
299
|
NUMBERED_COLUMN: string;
|
|
298
300
|
NUMBERED_COLUMN_BUTTON: string;
|
|
@@ -301,6 +303,7 @@ export declare const TableCssClassName: {
|
|
|
301
303
|
HOVERED_ROW: string;
|
|
302
304
|
HOVERED_TABLE: string;
|
|
303
305
|
HOVERED_CELL: string;
|
|
306
|
+
HOVERED_DISABLED_CELL: string;
|
|
304
307
|
HOVERED_CELL_IN_DANGER: string;
|
|
305
308
|
HOVERED_CELL_ACTIVE: string;
|
|
306
309
|
HOVERED_CELL_WARNING: string;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { MouseEventHandler } from 'react';
|
|
2
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
2
3
|
import type { TableDirection } from '../../types';
|
|
3
4
|
type DragHandleAppearance = 'default' | 'selected' | 'disabled' | 'danger';
|
|
4
5
|
type DragHandleProps = {
|
|
@@ -12,6 +13,7 @@ type DragHandleProps = {
|
|
|
12
13
|
onMouseOver?: MouseEventHandler;
|
|
13
14
|
onMouseOut?: MouseEventHandler;
|
|
14
15
|
onMouseUp?: MouseEventHandler;
|
|
16
|
+
editorView: EditorView;
|
|
15
17
|
};
|
|
16
|
-
export declare const DragHandle: ({ tableLocalId, direction, appearance, indexes, previewWidth, previewHeight, onMouseOver, onMouseOut, onMouseUp, onClick, }: DragHandleProps) => JSX.Element;
|
|
18
|
+
export declare const DragHandle: ({ tableLocalId, direction, appearance, indexes, previewWidth, previewHeight, onMouseOver, onMouseOut, onMouseUp, onClick, editorView, }: DragHandleProps) => JSX.Element;
|
|
17
19
|
export {};
|
|
@@ -13,6 +13,7 @@ export declare const tableBorderSelectedColor: import("@atlaskit/theme").ThemedV
|
|
|
13
13
|
export declare const tableCellSelectedDeleteIconColor: import("@atlaskit/theme").ThemedValue<"var(--ds-icon-subtle)">;
|
|
14
14
|
export declare const tableCellSelectedDeleteIconBackground: import("@atlaskit/theme").ThemedValue<"var(--ds-background-accent-gray-subtlest)">;
|
|
15
15
|
export declare const tableCellDeleteColor: import("@atlaskit/theme").ThemedValue<"var(--ds-blanket-danger)">;
|
|
16
|
+
export declare const tableCellDisabledColor: "var(--ds-background-accent-gray-subtler-hovered)";
|
|
16
17
|
export declare const tableBorderDeleteColor: import("@atlaskit/theme").ThemedValue<"var(--ds-border-danger)">;
|
|
17
18
|
export declare const tableToolbarDeleteColor: import("@atlaskit/theme").ThemedValue<"var(--ds-background-danger-pressed)">;
|
|
18
19
|
export declare const tableCellHoverDeleteIconColor: import("@atlaskit/theme").ThemedValue<"var(--ds-icon-inverse)">;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { DragHandleIcon } from './DragHandleIcon';
|
|
2
2
|
export { DragInMotionIcon } from './DragInMotionIcon';
|
|
3
|
+
export { DragHandleDisabledIcon } from './DragHandleDisabledIcon';
|
|
3
4
|
export { AddRowAboveIcon } from './AddRowAboveIcon';
|
|
4
5
|
export { AddRowBelowIcon } from './AddRowBelowIcon';
|
|
5
6
|
export { AddColLeftIcon } from './AddColLeftIcon';
|
|
@@ -14,6 +14,7 @@ export declare const floatingColumnControls: (props: ThemeProps) => import("@emo
|
|
|
14
14
|
export declare const rowControlsWrapperDotStyle: (props: ThemeProps) => import("@emotion/react").SerializedStyles;
|
|
15
15
|
export declare const columnControlsDecoration: (props: ThemeProps) => import("@emotion/react").SerializedStyles;
|
|
16
16
|
export declare const hoveredDeleteButton: (props: ThemeProps) => import("@emotion/react").SerializedStyles;
|
|
17
|
+
export declare const disabledCell: (props: ThemeProps) => import("@emotion/react").SerializedStyles;
|
|
17
18
|
export declare const hoveredCell: (props: ThemeProps) => import("@emotion/react").SerializedStyles;
|
|
18
19
|
export declare const hoveredWarningCell: import("@emotion/react").SerializedStyles;
|
|
19
20
|
export declare const resizeHandle: (props: ThemeProps) => import("@emotion/react").SerializedStyles;
|
|
@@ -8,7 +8,7 @@ import { TableDecorations } from '../types';
|
|
|
8
8
|
export declare const findColumnControlSelectedDecoration: (decorationSet: DecorationSet) => Decoration[];
|
|
9
9
|
export declare const findControlsHoverDecoration: (decorationSet: DecorationSet) => Decoration[];
|
|
10
10
|
export declare const createCellHoverDecoration: (cells: Cell[]) => Decoration[];
|
|
11
|
-
export declare const createControlsHoverDecoration: (cells: Cell[], type: 'row' | 'column' | 'table', tr: Transaction | ReadonlyTransaction, danger?: boolean, selected?: boolean) => Decoration[];
|
|
11
|
+
export declare const createControlsHoverDecoration: (cells: Cell[], type: 'row' | 'column' | 'table', tr: Transaction | ReadonlyTransaction, isDragAndDropEnable: boolean | undefined, hoveredIndexes: number[], danger?: boolean, selected?: boolean) => Decoration[];
|
|
12
12
|
export declare const createColumnSelectedDecoration: (tr: Transaction | ReadonlyTransaction) => Decoration[];
|
|
13
13
|
export declare const createColumnControlsDecoration: (selection: Selection) => Decoration[];
|
|
14
14
|
export declare const updateDecorations: (node: PmNode, decorationSet: DecorationSet, decorations: Decoration[], key: TableDecorations) => DecorationSet;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Selection, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
-
import { Rect } from '@atlaskit/editor-tables/table-map';
|
|
1
|
+
import type { Selection, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
import type { Rect } from '@atlaskit/editor-tables/table-map';
|
|
3
3
|
export declare const isSelectionUpdated: (oldSelection: Selection, newSelection?: Selection) => boolean;
|
|
4
4
|
export declare const normalizeSelection: (tr: Transaction) => Transaction;
|
|
5
5
|
export declare const getSelectedColumnIndexes: (selectionRect: Rect) => number[];
|
|
@@ -293,6 +293,8 @@ export declare const TableCssClassName: {
|
|
|
293
293
|
DRAG_HANDLE_BUTTON_CONTAINER: string;
|
|
294
294
|
DRAG_CORNER_BUTTON: string;
|
|
295
295
|
DRAG_CORNER_BUTTON_INNER: string;
|
|
296
|
+
/** disabled classes */
|
|
297
|
+
DRAG_HANDLE_DISABLED: string;
|
|
296
298
|
/** Other classes */
|
|
297
299
|
NUMBERED_COLUMN: string;
|
|
298
300
|
NUMBERED_COLUMN_BUTTON: string;
|
|
@@ -301,6 +303,7 @@ export declare const TableCssClassName: {
|
|
|
301
303
|
HOVERED_ROW: string;
|
|
302
304
|
HOVERED_TABLE: string;
|
|
303
305
|
HOVERED_CELL: string;
|
|
306
|
+
HOVERED_DISABLED_CELL: string;
|
|
304
307
|
HOVERED_CELL_IN_DANGER: string;
|
|
305
308
|
HOVERED_CELL_ACTIVE: string;
|
|
306
309
|
HOVERED_CELL_WARNING: string;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { MouseEventHandler } from 'react';
|
|
2
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
2
3
|
import type { TableDirection } from '../../types';
|
|
3
4
|
type DragHandleAppearance = 'default' | 'selected' | 'disabled' | 'danger';
|
|
4
5
|
type DragHandleProps = {
|
|
@@ -12,6 +13,7 @@ type DragHandleProps = {
|
|
|
12
13
|
onMouseOver?: MouseEventHandler;
|
|
13
14
|
onMouseOut?: MouseEventHandler;
|
|
14
15
|
onMouseUp?: MouseEventHandler;
|
|
16
|
+
editorView: EditorView;
|
|
15
17
|
};
|
|
16
|
-
export declare const DragHandle: ({ tableLocalId, direction, appearance, indexes, previewWidth, previewHeight, onMouseOver, onMouseOut, onMouseUp, onClick, }: DragHandleProps) => JSX.Element;
|
|
18
|
+
export declare const DragHandle: ({ tableLocalId, direction, appearance, indexes, previewWidth, previewHeight, onMouseOver, onMouseOut, onMouseUp, onClick, editorView, }: DragHandleProps) => JSX.Element;
|
|
17
19
|
export {};
|
|
@@ -13,6 +13,7 @@ export declare const tableBorderSelectedColor: import("@atlaskit/theme").ThemedV
|
|
|
13
13
|
export declare const tableCellSelectedDeleteIconColor: import("@atlaskit/theme").ThemedValue<"var(--ds-icon-subtle)">;
|
|
14
14
|
export declare const tableCellSelectedDeleteIconBackground: import("@atlaskit/theme").ThemedValue<"var(--ds-background-accent-gray-subtlest)">;
|
|
15
15
|
export declare const tableCellDeleteColor: import("@atlaskit/theme").ThemedValue<"var(--ds-blanket-danger)">;
|
|
16
|
+
export declare const tableCellDisabledColor: "var(--ds-background-accent-gray-subtler-hovered)";
|
|
16
17
|
export declare const tableBorderDeleteColor: import("@atlaskit/theme").ThemedValue<"var(--ds-border-danger)">;
|
|
17
18
|
export declare const tableToolbarDeleteColor: import("@atlaskit/theme").ThemedValue<"var(--ds-background-danger-pressed)">;
|
|
18
19
|
export declare const tableCellHoverDeleteIconColor: import("@atlaskit/theme").ThemedValue<"var(--ds-icon-inverse)">;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { DragHandleIcon } from './DragHandleIcon';
|
|
2
2
|
export { DragInMotionIcon } from './DragInMotionIcon';
|
|
3
|
+
export { DragHandleDisabledIcon } from './DragHandleDisabledIcon';
|
|
3
4
|
export { AddRowAboveIcon } from './AddRowAboveIcon';
|
|
4
5
|
export { AddRowBelowIcon } from './AddRowBelowIcon';
|
|
5
6
|
export { AddColLeftIcon } from './AddColLeftIcon';
|
|
@@ -14,6 +14,7 @@ export declare const floatingColumnControls: (props: ThemeProps) => import("@emo
|
|
|
14
14
|
export declare const rowControlsWrapperDotStyle: (props: ThemeProps) => import("@emotion/react").SerializedStyles;
|
|
15
15
|
export declare const columnControlsDecoration: (props: ThemeProps) => import("@emotion/react").SerializedStyles;
|
|
16
16
|
export declare const hoveredDeleteButton: (props: ThemeProps) => import("@emotion/react").SerializedStyles;
|
|
17
|
+
export declare const disabledCell: (props: ThemeProps) => import("@emotion/react").SerializedStyles;
|
|
17
18
|
export declare const hoveredCell: (props: ThemeProps) => import("@emotion/react").SerializedStyles;
|
|
18
19
|
export declare const hoveredWarningCell: import("@emotion/react").SerializedStyles;
|
|
19
20
|
export declare const resizeHandle: (props: ThemeProps) => import("@emotion/react").SerializedStyles;
|
|
@@ -8,7 +8,7 @@ import { TableDecorations } from '../types';
|
|
|
8
8
|
export declare const findColumnControlSelectedDecoration: (decorationSet: DecorationSet) => Decoration[];
|
|
9
9
|
export declare const findControlsHoverDecoration: (decorationSet: DecorationSet) => Decoration[];
|
|
10
10
|
export declare const createCellHoverDecoration: (cells: Cell[]) => Decoration[];
|
|
11
|
-
export declare const createControlsHoverDecoration: (cells: Cell[], type: 'row' | 'column' | 'table', tr: Transaction | ReadonlyTransaction, danger?: boolean, selected?: boolean) => Decoration[];
|
|
11
|
+
export declare const createControlsHoverDecoration: (cells: Cell[], type: 'row' | 'column' | 'table', tr: Transaction | ReadonlyTransaction, isDragAndDropEnable: boolean | undefined, hoveredIndexes: number[], danger?: boolean, selected?: boolean) => Decoration[];
|
|
12
12
|
export declare const createColumnSelectedDecoration: (tr: Transaction | ReadonlyTransaction) => Decoration[];
|
|
13
13
|
export declare const createColumnControlsDecoration: (selection: Selection) => Decoration[];
|
|
14
14
|
export declare const updateDecorations: (node: PmNode, decorationSet: DecorationSet, decorations: Decoration[], key: TableDecorations) => DecorationSet;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Selection, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
-
import { Rect } from '@atlaskit/editor-tables/table-map';
|
|
1
|
+
import type { Selection, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
import type { Rect } from '@atlaskit/editor-tables/table-map';
|
|
3
3
|
export declare const isSelectionUpdated: (oldSelection: Selection, newSelection?: Selection) => boolean;
|
|
4
4
|
export declare const normalizeSelection: (tr: Transaction) => Transaction;
|
|
5
5
|
export declare const getSelectedColumnIndexes: (selectionRect: Rect) => number[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "5.3.
|
|
3
|
+
"version": "5.3.27",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@atlaskit/adf-schema": "^32.0.0",
|
|
31
31
|
"@atlaskit/custom-steps": "^0.0.2",
|
|
32
|
-
"@atlaskit/editor-common": "^76.
|
|
32
|
+
"@atlaskit/editor-common": "^76.20.0",
|
|
33
33
|
"@atlaskit/editor-palette": "1.5.2",
|
|
34
34
|
"@atlaskit/editor-plugin-analytics": "^0.3.0",
|
|
35
35
|
"@atlaskit/editor-plugin-content-insertion": "^0.1.0",
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
getCellsInRow,
|
|
7
7
|
} from '@atlaskit/editor-tables/utils';
|
|
8
8
|
|
|
9
|
-
import { createCommand } from '../pm-plugins/plugin-factory';
|
|
9
|
+
import { createCommand, getPluginState } from '../pm-plugins/plugin-factory';
|
|
10
10
|
import type { Cell, CellColumnPositioning } from '../types';
|
|
11
11
|
import { TableDecorations } from '../types';
|
|
12
12
|
import {
|
|
@@ -57,13 +57,18 @@ export const hoverColumns = (hoveredColumns: number[], isInDanger?: boolean) =>
|
|
|
57
57
|
createCommand(
|
|
58
58
|
(state) => {
|
|
59
59
|
const cells = getCellsInColumn(hoveredColumns)(state.tr.selection);
|
|
60
|
+
|
|
61
|
+
const { isDragAndDropEnabled } = getPluginState(state);
|
|
60
62
|
if (!cells) {
|
|
61
63
|
return false;
|
|
62
64
|
}
|
|
65
|
+
|
|
63
66
|
const decorations = createControlsHoverDecoration(
|
|
64
67
|
cells,
|
|
65
68
|
'column',
|
|
66
69
|
state.tr,
|
|
70
|
+
isDragAndDropEnabled,
|
|
71
|
+
hoveredColumns,
|
|
67
72
|
isInDanger,
|
|
68
73
|
);
|
|
69
74
|
|
|
@@ -90,10 +95,13 @@ export const hoverRows = (hoveredRows: number[], isInDanger?: boolean) =>
|
|
|
90
95
|
if (!cells) {
|
|
91
96
|
return false;
|
|
92
97
|
}
|
|
98
|
+
const { isDragAndDropEnabled } = getPluginState(state);
|
|
93
99
|
const decorations = createControlsHoverDecoration(
|
|
94
100
|
cells,
|
|
95
101
|
'row',
|
|
96
102
|
state.tr,
|
|
103
|
+
isDragAndDropEnabled,
|
|
104
|
+
hoveredRows,
|
|
97
105
|
isInDanger,
|
|
98
106
|
);
|
|
99
107
|
|
|
@@ -127,10 +135,13 @@ export const hoverTable = (isInDanger?: boolean, isSelected?: boolean) =>
|
|
|
127
135
|
if (!cells) {
|
|
128
136
|
return false;
|
|
129
137
|
}
|
|
138
|
+
const { isDragAndDropEnabled } = getPluginState(state);
|
|
130
139
|
const decorations = createControlsHoverDecoration(
|
|
131
140
|
cells,
|
|
132
141
|
'table',
|
|
133
142
|
state.tr,
|
|
143
|
+
isDragAndDropEnabled,
|
|
144
|
+
[],
|
|
134
145
|
isInDanger,
|
|
135
146
|
isSelected,
|
|
136
147
|
);
|
|
@@ -325,6 +325,9 @@ export const TableCssClassName = {
|
|
|
325
325
|
DRAG_CORNER_BUTTON: `${tablePrefixSelector}-drag-corner-button`,
|
|
326
326
|
DRAG_CORNER_BUTTON_INNER: `${tablePrefixSelector}-drag-corner-button-inner`,
|
|
327
327
|
|
|
328
|
+
/** disabled classes */
|
|
329
|
+
DRAG_HANDLE_DISABLED: `${tablePrefixSelector}-drag-handle-disabled`,
|
|
330
|
+
|
|
328
331
|
/** Other classes */
|
|
329
332
|
NUMBERED_COLUMN: `${tablePrefixSelector}-numbered-column`,
|
|
330
333
|
NUMBERED_COLUMN_BUTTON: `${tablePrefixSelector}-numbered-column__button`,
|
|
@@ -334,6 +337,7 @@ export const TableCssClassName = {
|
|
|
334
337
|
HOVERED_ROW: `${tablePrefixSelector}-hovered-row`,
|
|
335
338
|
HOVERED_TABLE: `${tablePrefixSelector}-hovered-table`,
|
|
336
339
|
HOVERED_CELL: `${tablePrefixSelector}-hovered-cell`,
|
|
340
|
+
HOVERED_DISABLED_CELL: `${tablePrefixSelector}-hovered-disabled`,
|
|
337
341
|
HOVERED_CELL_IN_DANGER: 'danger',
|
|
338
342
|
HOVERED_CELL_ACTIVE: 'active',
|
|
339
343
|
HOVERED_CELL_WARNING: `${tablePrefixSelector}-hovered-cell__warning`,
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import type { MouseEventHandler } from 'react';
|
|
2
|
-
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
|
3
3
|
|
|
4
4
|
import classnames from 'classnames';
|
|
5
5
|
import ReactDOM from 'react-dom';
|
|
6
6
|
|
|
7
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
7
8
|
import { draggable } from '@atlaskit/pragmatic-drag-and-drop/adapter/element';
|
|
8
9
|
import { setCustomNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/util/set-custom-native-drag-preview';
|
|
9
10
|
|
|
11
|
+
import { getPluginState } from '../../pm-plugins/plugin-factory';
|
|
10
12
|
import type { TableDirection } from '../../types';
|
|
11
13
|
import { TableCssClassName as ClassName } from '../../types';
|
|
14
|
+
import { hasMergedCellsInColumn, hasMergedCellsInRow } from '../../utils';
|
|
12
15
|
import { DragPreview } from '../DragPreview';
|
|
13
|
-
import { DragHandleIcon } from '../icons';
|
|
16
|
+
import { DragHandleDisabledIcon, DragHandleIcon } from '../icons';
|
|
14
17
|
|
|
15
18
|
type DragHandleAppearance = 'default' | 'selected' | 'disabled' | 'danger';
|
|
16
19
|
|
|
@@ -25,6 +28,7 @@ type DragHandleProps = {
|
|
|
25
28
|
onMouseOver?: MouseEventHandler;
|
|
26
29
|
onMouseOut?: MouseEventHandler;
|
|
27
30
|
onMouseUp?: MouseEventHandler;
|
|
31
|
+
editorView: EditorView;
|
|
28
32
|
};
|
|
29
33
|
|
|
30
34
|
export const DragHandle = ({
|
|
@@ -38,17 +42,32 @@ export const DragHandle = ({
|
|
|
38
42
|
onMouseOut,
|
|
39
43
|
onMouseUp,
|
|
40
44
|
onClick,
|
|
45
|
+
editorView,
|
|
41
46
|
}: DragHandleProps) => {
|
|
42
47
|
const dragHandleDivRef = useRef<HTMLButtonElement>(null);
|
|
43
48
|
const [previewContainer, setPreviewContainer] = useState<HTMLElement | null>(
|
|
44
49
|
null,
|
|
45
50
|
);
|
|
51
|
+
const { isDragAndDropEnabled } = getPluginState(editorView.state);
|
|
52
|
+
const { selection } = editorView.state;
|
|
53
|
+
|
|
54
|
+
const hasMergedCells = useMemo(
|
|
55
|
+
() =>
|
|
56
|
+
direction === 'row'
|
|
57
|
+
? hasMergedCellsInRow(indexes[0])(selection)
|
|
58
|
+
: hasMergedCellsInColumn(indexes[0])(selection),
|
|
59
|
+
[indexes, direction, selection],
|
|
60
|
+
);
|
|
46
61
|
|
|
47
62
|
useEffect(() => {
|
|
48
63
|
const dragHandleDivRefCurrent = dragHandleDivRef.current;
|
|
64
|
+
|
|
49
65
|
if (dragHandleDivRefCurrent) {
|
|
50
66
|
return draggable({
|
|
51
67
|
element: dragHandleDivRefCurrent,
|
|
68
|
+
canDrag: () => {
|
|
69
|
+
return !hasMergedCells;
|
|
70
|
+
},
|
|
52
71
|
getInitialData() {
|
|
53
72
|
return {
|
|
54
73
|
localId: tableLocalId,
|
|
@@ -75,11 +94,23 @@ export const DragHandle = ({
|
|
|
75
94
|
},
|
|
76
95
|
});
|
|
77
96
|
}
|
|
78
|
-
}, [
|
|
97
|
+
}, [
|
|
98
|
+
tableLocalId,
|
|
99
|
+
direction,
|
|
100
|
+
indexes,
|
|
101
|
+
editorView.state.selection,
|
|
102
|
+
hasMergedCells,
|
|
103
|
+
]);
|
|
79
104
|
|
|
80
105
|
return (
|
|
81
106
|
<button
|
|
82
|
-
className={classnames(
|
|
107
|
+
className={classnames(
|
|
108
|
+
ClassName.DRAG_HANDLE_BUTTON_CONTAINER,
|
|
109
|
+
appearance,
|
|
110
|
+
isDragAndDropEnabled &&
|
|
111
|
+
hasMergedCells &&
|
|
112
|
+
ClassName.DRAG_HANDLE_DISABLED,
|
|
113
|
+
)}
|
|
83
114
|
ref={dragHandleDivRef}
|
|
84
115
|
style={{
|
|
85
116
|
transform: direction === 'column' ? 'none' : 'rotate(90deg)',
|
|
@@ -91,7 +122,7 @@ export const DragHandle = ({
|
|
|
91
122
|
onMouseUp={onMouseUp}
|
|
92
123
|
onClick={onClick}
|
|
93
124
|
>
|
|
94
|
-
<DragHandleIcon />
|
|
125
|
+
{hasMergedCells ? <DragHandleDisabledIcon /> : <DragHandleIcon />}
|
|
95
126
|
{previewContainer &&
|
|
96
127
|
previewWidth !== undefined &&
|
|
97
128
|
previewHeight !== undefined &&
|