@atlaskit/editor-plugin-table 5.3.26 → 5.3.28
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 +13 -0
- package/dist/cjs/plugins/table/commands/hover.js +9 -3
- package/dist/cjs/plugins/table/event-handlers.js +17 -13
- 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/event-handlers.js +6 -1
- 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/event-handlers.js +5 -1
- 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/event-handlers.ts +4 -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
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.28",
|
|
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
|
);
|
|
@@ -41,6 +41,7 @@ import {
|
|
|
41
41
|
showInsertRowButton,
|
|
42
42
|
showResizeHandleLine,
|
|
43
43
|
} from './commands';
|
|
44
|
+
import { getPluginState as getDragDropPluginState } from './pm-plugins/drag-and-drop/plugin-factory';
|
|
44
45
|
import { getPluginState } from './pm-plugins/plugin-factory';
|
|
45
46
|
import { getPluginState as getResizePluginState } from './pm-plugins/table-resizing/plugin-factory';
|
|
46
47
|
import { deleteColumns, deleteRows } from './transforms';
|
|
@@ -299,7 +300,9 @@ export const handleMouseLeave = (view: EditorView, event: Event): boolean => {
|
|
|
299
300
|
}
|
|
300
301
|
|
|
301
302
|
if (isDragAndDropEnabled) {
|
|
302
|
-
|
|
303
|
+
const { isDragMenuOpen } = getDragDropPluginState(state);
|
|
304
|
+
// Only set hoveredCell colIndex and rowIndex to undefined if the drag menu is not open
|
|
305
|
+
!isDragMenuOpen && hoverCell()(state, dispatch);
|
|
303
306
|
}
|
|
304
307
|
|
|
305
308
|
if (
|
|
@@ -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 &&
|
|
@@ -56,6 +56,7 @@ import {
|
|
|
56
56
|
columnControlsDecoration,
|
|
57
57
|
columnControlsLineMarker,
|
|
58
58
|
DeleteButton,
|
|
59
|
+
disabledCell,
|
|
59
60
|
dragCornerControlButton,
|
|
60
61
|
dragInsertButtonWrapper,
|
|
61
62
|
floatingColumnControls,
|
|
@@ -315,6 +316,7 @@ export const tableStyles = (
|
|
|
315
316
|
${columnControlsLineMarker()};
|
|
316
317
|
${hoveredDeleteButton(props)};
|
|
317
318
|
${hoveredCell(props)};
|
|
319
|
+
${disabledCell(props)};
|
|
318
320
|
${hoveredWarningCell};
|
|
319
321
|
${getBooleanFF('platform.editor.table.drag-and-drop') && insertLine(props)};
|
|
320
322
|
${resizeHandle(props)};
|
|
@@ -779,58 +781,49 @@ export const tableStyles = (
|
|
|
779
781
|
align-items: center;
|
|
780
782
|
outline: none !important;
|
|
781
783
|
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
fill: ${token('color.background.accent.gray.subtlest', '#F1F2F4')};
|
|
785
|
-
}
|
|
786
|
-
g {
|
|
787
|
-
fill: ${token('color.icon.subtle', '#626F86')};
|
|
788
|
-
}
|
|
789
|
-
}
|
|
790
|
-
|
|
791
|
-
&:hover {
|
|
792
|
-
svg {
|
|
784
|
+
&:not(.${ClassName.DRAG_HANDLE_DISABLED}) {
|
|
785
|
+
& > svg {
|
|
793
786
|
rect {
|
|
794
|
-
fill: ${token('color.background.accent.
|
|
787
|
+
fill: ${token('color.background.accent.gray.subtlest', '#F1F2F4')};
|
|
795
788
|
}
|
|
796
789
|
g {
|
|
797
|
-
fill: ${token('color.icon.
|
|
790
|
+
fill: ${token('color.icon.subtle', '#626F86')};
|
|
798
791
|
}
|
|
799
792
|
}
|
|
800
|
-
}
|
|
801
793
|
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
794
|
+
&:hover {
|
|
795
|
+
svg {
|
|
796
|
+
rect {
|
|
797
|
+
fill: ${token('color.background.accent.blue.subtle', '#579DFF')};
|
|
798
|
+
}
|
|
799
|
+
g {
|
|
800
|
+
fill: ${token('color.icon.inverse', '#FFF')};
|
|
801
|
+
}
|
|
809
802
|
}
|
|
810
803
|
}
|
|
811
|
-
}
|
|
812
804
|
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
g {
|
|
822
|
-
fill: ${token('color.border.inverse', '#FFF')};
|
|
805
|
+
&.selected {
|
|
806
|
+
svg {
|
|
807
|
+
rect {
|
|
808
|
+
fill: ${token('color.background.accent.blue.subtle', '#579dff')};
|
|
809
|
+
}
|
|
810
|
+
g {
|
|
811
|
+
fill: ${token('color.icon.inverse', '#fff')};
|
|
812
|
+
}
|
|
823
813
|
}
|
|
824
814
|
}
|
|
825
|
-
}
|
|
826
815
|
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
816
|
+
&.danger {
|
|
817
|
+
svg {
|
|
818
|
+
rect {
|
|
819
|
+
fill: ${token(
|
|
820
|
+
'color.background.accent.red.subtler.pressed',
|
|
821
|
+
'#F87462',
|
|
822
|
+
)};
|
|
823
|
+
}
|
|
824
|
+
g {
|
|
825
|
+
fill: ${token('color.border.inverse', '#FFF')};
|
|
826
|
+
}
|
|
834
827
|
}
|
|
835
828
|
}
|
|
836
829
|
}
|
|
@@ -97,6 +97,12 @@ export const tableCellDeleteColor = themed({
|
|
|
97
97
|
light: token('color.blanket.danger', akEditorTableCellBlanketDeleted),
|
|
98
98
|
dark: token('color.blanket.danger', akEditorTableCellBlanketDeleted),
|
|
99
99
|
});
|
|
100
|
+
|
|
101
|
+
export const tableCellDisabledColor = token(
|
|
102
|
+
'color.background.accent.gray.subtler.hovered',
|
|
103
|
+
'#C1C7D0',
|
|
104
|
+
);
|
|
105
|
+
|
|
100
106
|
export const tableBorderDeleteColor = themed({
|
|
101
107
|
light: token('color.border.danger', R400),
|
|
102
108
|
dark: token('color.border.danger', R400),
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { token } from '@atlaskit/tokens';
|
|
4
|
+
|
|
5
|
+
interface DragHandleDisabledIconProps {
|
|
6
|
+
style?: React.CSSProperties;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const DragHandleDisabledIcon = ({
|
|
10
|
+
style,
|
|
11
|
+
}: DragHandleDisabledIconProps) => (
|
|
12
|
+
<svg
|
|
13
|
+
width="24"
|
|
14
|
+
height="16"
|
|
15
|
+
viewBox="0 0 24 16"
|
|
16
|
+
fill="none"
|
|
17
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
18
|
+
style={style}
|
|
19
|
+
>
|
|
20
|
+
<rect
|
|
21
|
+
width="24"
|
|
22
|
+
height="16"
|
|
23
|
+
rx="4"
|
|
24
|
+
fill={token('color.background.accent.gray.subtlest', 'Neutral200')}
|
|
25
|
+
/>
|
|
26
|
+
<g>
|
|
27
|
+
<rect
|
|
28
|
+
x="7"
|
|
29
|
+
y="4"
|
|
30
|
+
width="2"
|
|
31
|
+
height="8"
|
|
32
|
+
rx="1"
|
|
33
|
+
fill={token('color.icon.disabled', '#091E424F')}
|
|
34
|
+
/>
|
|
35
|
+
<rect
|
|
36
|
+
x="11"
|
|
37
|
+
y="4"
|
|
38
|
+
width="2"
|
|
39
|
+
height="8"
|
|
40
|
+
rx="1"
|
|
41
|
+
fill={token('color.icon.disabled', '#091E424F')}
|
|
42
|
+
/>
|
|
43
|
+
<rect
|
|
44
|
+
x="15"
|
|
45
|
+
y="4"
|
|
46
|
+
width="2"
|
|
47
|
+
height="8"
|
|
48
|
+
rx="1"
|
|
49
|
+
fill={token('color.icon.disabled', '#091E424F')}
|
|
50
|
+
/>
|
|
51
|
+
</g>
|
|
52
|
+
</svg>
|
|
53
|
+
);
|
|
@@ -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';
|
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
tableBorderDeleteColor,
|
|
32
32
|
tableBorderSelectedColor,
|
|
33
33
|
tableCellDeleteColor,
|
|
34
|
+
tableCellDisabledColor,
|
|
34
35
|
tableCellHoverDeleteIconBackground,
|
|
35
36
|
tableCellHoverDeleteIconColor,
|
|
36
37
|
tableCellSelectedDeleteIconBackground,
|
|
@@ -707,6 +708,18 @@ export const hoveredDeleteButton = (props: ThemeProps) => css`
|
|
|
707
708
|
}
|
|
708
709
|
`;
|
|
709
710
|
|
|
711
|
+
export const disabledCell = (props: ThemeProps) => css`
|
|
712
|
+
:not(.${ClassName.IS_RESIZING})
|
|
713
|
+
.${ClassName.TABLE_CONTAINER}:not(.${ClassName.HOVERED_DELETE_BUTTON}) {
|
|
714
|
+
.${ClassName.HOVERED_CELL}.${ClassName.HOVERED_DISABLED_CELL} {
|
|
715
|
+
position: relative;
|
|
716
|
+
border: 1px solid ${tableCellDisabledColor};
|
|
717
|
+
}
|
|
718
|
+
.${ClassName.HOVERED_CELL}.${ClassName.HOVERED_DISABLED_CELL}::after {
|
|
719
|
+
border: 1px solid ${tableCellDisabledColor};
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
`;
|
|
710
723
|
export const hoveredCell = (props: ThemeProps) => css`
|
|
711
724
|
:not(.${ClassName.IS_RESIZING})
|
|
712
725
|
.${ClassName.TABLE_CONTAINER}:not(.${ClassName.HOVERED_DELETE_BUTTON}) {
|
|
@@ -28,6 +28,8 @@ import type { Cell, CellColumnPositioning } from '../types';
|
|
|
28
28
|
import { TableCssClassName as ClassName, TableDecorations } from '../types';
|
|
29
29
|
import { ColumnResizeWidget } from '../ui/ColumnResizeWidget';
|
|
30
30
|
|
|
31
|
+
import { hasMergedCellsInColumn, hasMergedCellsInRow } from './merged-cells';
|
|
32
|
+
|
|
31
33
|
const filterDecorationByKey = (
|
|
32
34
|
key: TableDecorations,
|
|
33
35
|
decorationSet: DecorationSet,
|
|
@@ -66,6 +68,8 @@ export const createControlsHoverDecoration = (
|
|
|
66
68
|
cells: Cell[],
|
|
67
69
|
type: 'row' | 'column' | 'table',
|
|
68
70
|
tr: Transaction | ReadonlyTransaction,
|
|
71
|
+
isDragAndDropEnable: boolean | undefined,
|
|
72
|
+
hoveredIndexes: number[],
|
|
69
73
|
danger?: boolean,
|
|
70
74
|
selected?: boolean,
|
|
71
75
|
): Decoration[] => {
|
|
@@ -95,6 +99,13 @@ export const createControlsHoverDecoration = (
|
|
|
95
99
|
|
|
96
100
|
let updatedCells: number[] = cells.map((x) => x.pos);
|
|
97
101
|
|
|
102
|
+
const hasMergedCells =
|
|
103
|
+
type === 'row'
|
|
104
|
+
? hasMergedCellsInRow(hoveredIndexes[0])(tr.selection)
|
|
105
|
+
: hasMergedCellsInColumn(hoveredIndexes[0])(tr.selection);
|
|
106
|
+
|
|
107
|
+
let disabled: boolean = hasMergedCells;
|
|
108
|
+
|
|
98
109
|
// ED-15246 fixed trello card table overflow issue
|
|
99
110
|
// If columns / rows have been merged the hovered selection is different to the actual selection
|
|
100
111
|
// So If the table cells are in danger we want to create a "rectangle" selection
|
|
@@ -140,6 +151,9 @@ export const createControlsHoverDecoration = (
|
|
|
140
151
|
if (selected) {
|
|
141
152
|
classes.push(ClassName.SELECTED_CELL);
|
|
142
153
|
}
|
|
154
|
+
if (isDragAndDropEnable && disabled) {
|
|
155
|
+
classes.push(ClassName.HOVERED_DISABLED_CELL);
|
|
156
|
+
}
|
|
143
157
|
|
|
144
158
|
classes.push(
|
|
145
159
|
type === 'column'
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type {
|
|
2
|
+
Selection,
|
|
3
|
+
Transaction,
|
|
4
|
+
} from '@atlaskit/editor-prosemirror/state';
|
|
2
5
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
3
|
-
import { Rect
|
|
6
|
+
import type { Rect } from '@atlaskit/editor-tables/table-map';
|
|
7
|
+
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
4
8
|
import {
|
|
5
9
|
findTable,
|
|
6
10
|
getSelectionRangeInColumn,
|