@atlaskit/editor-plugin-table 5.4.1 → 5.4.3

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.
Files changed (41) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/plugins/table/types.js +2 -0
  3. package/dist/cjs/plugins/table/ui/DragHandle/index.js +25 -4
  4. package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +22 -2
  5. package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +8 -3
  6. package/dist/cjs/plugins/table/ui/common-styles.js +1 -1
  7. package/dist/cjs/plugins/table/ui/icons/DragHandleDisabledIcon.js +4 -8
  8. package/dist/cjs/plugins/table/ui/icons/MinimisedHandle.js +22 -0
  9. package/dist/cjs/plugins/table/ui/icons/index.js +7 -0
  10. package/dist/es2019/plugins/table/types.js +2 -0
  11. package/dist/es2019/plugins/table/ui/DragHandle/index.js +25 -3
  12. package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +25 -3
  13. package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +8 -3
  14. package/dist/es2019/plugins/table/ui/common-styles.js +18 -5
  15. package/dist/es2019/plugins/table/ui/icons/DragHandleDisabledIcon.js +4 -8
  16. package/dist/es2019/plugins/table/ui/icons/MinimisedHandle.js +13 -0
  17. package/dist/es2019/plugins/table/ui/icons/index.js +1 -0
  18. package/dist/esm/plugins/table/types.js +2 -0
  19. package/dist/esm/plugins/table/ui/DragHandle/index.js +24 -3
  20. package/dist/esm/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +23 -3
  21. package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +8 -3
  22. package/dist/esm/plugins/table/ui/common-styles.js +2 -2
  23. package/dist/esm/plugins/table/ui/icons/DragHandleDisabledIcon.js +4 -8
  24. package/dist/esm/plugins/table/ui/icons/MinimisedHandle.js +15 -0
  25. package/dist/esm/plugins/table/ui/icons/index.js +1 -0
  26. package/dist/types/plugins/table/types.d.ts +2 -0
  27. package/dist/types/plugins/table/ui/icons/MinimisedHandle.d.ts +2 -0
  28. package/dist/types/plugins/table/ui/icons/index.d.ts +1 -0
  29. package/dist/types-ts4.5/plugins/table/types.d.ts +2 -0
  30. package/dist/types-ts4.5/plugins/table/ui/icons/MinimisedHandle.d.ts +2 -0
  31. package/dist/types-ts4.5/plugins/table/ui/icons/index.d.ts +1 -0
  32. package/package.json +1 -1
  33. package/src/__tests__/unit/ui/RowDragControls.tsx +2 -2
  34. package/src/plugins/table/types.ts +3 -0
  35. package/src/plugins/table/ui/DragHandle/index.tsx +37 -3
  36. package/src/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.tsx +33 -2
  37. package/src/plugins/table/ui/TableFloatingControls/RowControls/DragControls.tsx +9 -3
  38. package/src/plugins/table/ui/common-styles.ts +17 -5
  39. package/src/plugins/table/ui/icons/DragHandleDisabledIcon.tsx +4 -32
  40. package/src/plugins/table/ui/icons/MinimisedHandle.tsx +14 -0
  41. package/src/plugins/table/ui/icons/index.ts +1 -0
@@ -8,6 +8,7 @@ import { getSelectionRect } from '@atlaskit/editor-tables/utils';
8
8
 
9
9
  import {
10
10
  clearHoverSelection,
11
+ hoverCell,
11
12
  hoverColumns,
12
13
  selectColumn,
13
14
  } from '../../../commands';
@@ -92,6 +93,29 @@ export const ColumnControls = ({
92
93
  hoverColumns([colIndex!])(state, dispatch);
93
94
  }, [colIndex, editorView]);
94
95
 
96
+ const handleMouseMove = useCallback(
97
+ (e: MouseEvent) => {
98
+ const isParentDragControls = (e.nativeEvent.target as Element).closest(
99
+ `.${ClassName.DRAG_COLUMN_CONTROLS}`,
100
+ );
101
+ const colIndex = (e.nativeEvent.target as Element).getAttribute(
102
+ 'data-start-index',
103
+ );
104
+
105
+ // avoid updating if event target is not related
106
+ if (!isParentDragControls || !colIndex) {
107
+ return;
108
+ }
109
+
110
+ // update hovered cell location
111
+ const { state, dispatch } = editorView;
112
+ if (tableActive && hoveredCell?.colIndex !== Number(colIndex)) {
113
+ hoverCell(hoveredCell?.rowIndex, Number(colIndex))(state, dispatch);
114
+ }
115
+ },
116
+ [editorView, hoveredCell?.colIndex, hoveredCell?.rowIndex, tableActive],
117
+ );
118
+
95
119
  const handleMouseOut = useCallback(() => {
96
120
  if (tableActive) {
97
121
  const { state, dispatch } = editorView;
@@ -104,8 +128,15 @@ export const ColumnControls = ({
104
128
  toggleDragMenu(undefined, 'column', colIndex)(state, dispatch);
105
129
  }, [editorView, colIndex]);
106
130
 
131
+ const colIndexes = useMemo(() => {
132
+ return [colIndex!];
133
+ }, [colIndex]);
134
+
107
135
  return (
108
- <div className={ClassName.DRAG_COLUMN_CONTROLS}>
136
+ <div
137
+ className={ClassName.DRAG_COLUMN_CONTROLS}
138
+ onMouseMove={handleMouseMove}
139
+ >
109
140
  <div
110
141
  className={ClassName.DRAG_COLUMN_CONTROLS_INNER}
111
142
  data-testid="table-floating-column-controls"
@@ -160,7 +191,7 @@ export const ColumnControls = ({
160
191
  <DragHandle
161
192
  direction="column"
162
193
  tableLocalId={localId || ''}
163
- indexes={[hoveredCell.colIndex!]}
194
+ indexes={colIndexes}
164
195
  previewWidth={hoveredCell.colWidth}
165
196
  previewHeight={hoveredCell.colHeight}
166
197
  appearance={
@@ -146,6 +146,10 @@ const DragControlsComponent = ({
146
146
  [updateCellHoverLocation],
147
147
  );
148
148
 
149
+ const rowIndexes = useMemo(() => {
150
+ return [rowIndex!];
151
+ }, [rowIndex]);
152
+
149
153
  const handleMouseOver = useCallback(() => {
150
154
  hoverRows([rowIndex!]);
151
155
  }, [hoverRows, rowIndex]);
@@ -163,10 +167,12 @@ const DragControlsComponent = ({
163
167
  style={{
164
168
  gridTemplateRows: heights,
165
169
  gridTemplateColumns: isDragging
166
- ? `${dropTargetExtendedWidth}px 24px ${tableWidth}px`
167
- : `${dropTargetExtendedWidth}px 24px`,
170
+ ? `${dropTargetExtendedWidth}px 28px ${tableWidth}px`
171
+ : 'none',
172
+ left: isDragging ? `-${dropTargetExtendedWidth + 2}px` : `-2px`,
168
173
  }}
169
174
  onMouseMove={handleMouseMove}
175
+ contentEditable={false}
170
176
  >
171
177
  {!isResizing &&
172
178
  rowsParams.map(({ startIndex, endIndex }, index) => (
@@ -225,7 +231,7 @@ const DragControlsComponent = ({
225
231
  >
226
232
  <DragHandle
227
233
  tableLocalId={currentNodeLocalId}
228
- indexes={[rowIndex!]}
234
+ indexes={rowIndexes}
229
235
  previewWidth={tableWidth}
230
236
  previewHeight={rowHeights[rowIndex!]}
231
237
  appearance={
@@ -30,7 +30,6 @@ import { TableCssClassName as ClassName } from '../types';
30
30
 
31
31
  import {
32
32
  columnControlsDecorationHeight,
33
- dropTargetExtendedWidth,
34
33
  resizeHandlerAreaWidth,
35
34
  resizeLineWidth,
36
35
  rowControlsZIndex,
@@ -736,7 +735,6 @@ export const tableStyles = (
736
735
  display: grid;
737
736
  align-items: center;
738
737
  position: absolute;
739
- left: -${dropTargetExtendedWidth + 4}px;
740
738
  z-index: ${akEditorUnitZIndex};
741
739
 
742
740
  .${ClassName.DRAG_ROW_FLOATING_INSERT_DOT_WRAPPER} {
@@ -749,7 +747,7 @@ export const tableStyles = (
749
747
  .${ClassName.DRAG_ROW_FLOATING_INSERT_DOT} {
750
748
  position: absolute;
751
749
  bottom: -3px;
752
- left: 6px;
750
+ left: 2px;
753
751
  background-color: ${token(
754
752
  'color.background.accent.gray.subtler',
755
753
  '#C1C7D0',
@@ -800,13 +798,27 @@ export const tableStyles = (
800
798
  align-items: center;
801
799
  outline: none !important;
802
800
 
801
+ &.${ClassName.DRAG_HANDLE_DISABLED} {
802
+ & > svg {
803
+ & > rect.${ClassName.DRAG_HANDLE_MINIMISED} {
804
+ fill: ${token('color.background.accent.gray.subtler', '#DCDFE4')};
805
+ }
806
+ & > rect {
807
+ fill: ${token('color.background.accent.gray.subtlest', '#F4F5F7')};
808
+ }
809
+ & > g > rect {
810
+ fill: ${token('color.icon.disabled', '#BFDBF847')};
811
+ }
812
+ }
813
+ }
814
+
803
815
  &:not(.${ClassName.DRAG_HANDLE_DISABLED}) {
804
816
  & > svg {
805
817
  rect {
806
- fill: ${token('color.background.accent.gray.subtlest', '#F1F2F4')};
818
+ fill: ${token('color.background.accent.gray.subtler', '#DCDFE4')};
807
819
  }
808
820
  g {
809
- fill: ${token('color.icon.subtle', '#626F86')};
821
+ fill: ${token('color.icon.subtle', '#626f86')};
810
822
  }
811
823
  }
812
824
 
@@ -1,7 +1,5 @@
1
1
  import React from 'react';
2
2
 
3
- import { token } from '@atlaskit/tokens';
4
-
5
3
  interface DragHandleDisabledIconProps {
6
4
  style?: React.CSSProperties;
7
5
  }
@@ -17,37 +15,11 @@ export const DragHandleDisabledIcon = ({
17
15
  xmlns="http://www.w3.org/2000/svg"
18
16
  style={style}
19
17
  >
20
- <rect
21
- width="24"
22
- height="16"
23
- rx="4"
24
- fill={token('color.background.accent.gray.subtlest', 'Neutral200')}
25
- />
18
+ <rect width="24" height="16" rx="4" />
26
19
  <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
- />
20
+ <rect x="7" y="4" width="2" height="8" rx="1" />
21
+ <rect x="11" y="4" width="2" height="8" rx="1" />
22
+ <rect x="15" y="4" width="2" height="8" rx="1" />
51
23
  </g>
52
24
  </svg>
53
25
  );
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+
3
+ import { TableCssClassName as ClassName } from '../../types';
4
+
5
+ export const MinimisedHandleIcon = () => (
6
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="5" fill="none">
7
+ <rect
8
+ className={ClassName.DRAG_HANDLE_MINIMISED}
9
+ width="24"
10
+ height="5"
11
+ rx="3"
12
+ />
13
+ </svg>
14
+ );
@@ -1,6 +1,7 @@
1
1
  export { DragHandleIcon } from './DragHandleIcon';
2
2
  export { DragInMotionIcon } from './DragInMotionIcon';
3
3
  export { DragHandleDisabledIcon } from './DragHandleDisabledIcon';
4
+ export { MinimisedHandleIcon } from './MinimisedHandle';
4
5
  export { AddRowAboveIcon } from './AddRowAboveIcon';
5
6
  export { AddRowBelowIcon } from './AddRowBelowIcon';
6
7
  export { AddColLeftIcon } from './AddColLeftIcon';