@atlaskit/editor-plugin-table 5.3.1 → 5.3.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.
- package/CHANGELOG.md +12 -0
- package/dist/cjs/plugins/table/commands/hover.js +17 -8
- package/dist/cjs/plugins/table/commands/index.js +6 -0
- package/dist/cjs/plugins/table/commands/misc.js +1 -7
- package/dist/cjs/plugins/table/event-handlers.js +29 -2
- package/dist/cjs/plugins/table/index.js +1 -1
- package/dist/cjs/plugins/table/nodeviews/TableComponent.js +5 -3
- package/dist/cjs/plugins/table/nodeviews/table.js +4 -2
- package/dist/cjs/plugins/table/pm-plugins/decorations/plugin.js +7 -3
- package/dist/cjs/plugins/table/pm-plugins/decorations/utils/column-controls.js +7 -2
- package/dist/cjs/plugins/table/pm-plugins/default-table-selection.js +14 -1
- package/dist/cjs/plugins/table/pm-plugins/main.js +5 -5
- package/dist/cjs/plugins/table/reducer.js +2 -1
- package/dist/cjs/plugins/table/types.js +6 -0
- package/dist/cjs/plugins/table/ui/DragHandle/index.js +50 -0
- package/dist/cjs/plugins/table/ui/DragPreview/index.js +39 -0
- package/dist/cjs/plugins/table/ui/Icons/DragInMotionIcon.js +55 -0
- package/dist/cjs/plugins/table/ui/TableFloatingControls/NumberColumn/index.js +53 -14
- package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/ClassicControls.js +114 -0
- package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +53 -0
- package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/index.js +11 -106
- package/dist/cjs/plugins/table/ui/TableFloatingControls/index.js +16 -6
- package/dist/cjs/plugins/table/ui/common-styles.js +9 -6
- package/dist/cjs/plugins/table/ui/consts.js +2 -1
- package/dist/cjs/plugins/table/ui/ui-styles.js +18 -9
- package/dist/cjs/plugins/table/utils/decoration.js +44 -18
- package/dist/cjs/plugins/table/utils/dom.js +7 -1
- package/dist/cjs/plugins/table/utils/index.js +12 -0
- package/dist/es2019/plugins/table/commands/hover.js +12 -8
- package/dist/es2019/plugins/table/commands/index.js +1 -1
- package/dist/es2019/plugins/table/commands/misc.js +1 -7
- package/dist/es2019/plugins/table/event-handlers.js +28 -2
- package/dist/es2019/plugins/table/index.js +1 -1
- package/dist/es2019/plugins/table/nodeviews/TableComponent.js +5 -3
- package/dist/es2019/plugins/table/nodeviews/table.js +4 -2
- package/dist/es2019/plugins/table/pm-plugins/decorations/plugin.js +8 -6
- package/dist/es2019/plugins/table/pm-plugins/decorations/utils/column-controls.js +7 -2
- package/dist/es2019/plugins/table/pm-plugins/default-table-selection.js +13 -0
- package/dist/es2019/plugins/table/pm-plugins/main.js +6 -5
- package/dist/es2019/plugins/table/reducer.js +2 -1
- package/dist/es2019/plugins/table/types.js +6 -0
- package/dist/es2019/plugins/table/ui/DragHandle/index.js +41 -0
- package/dist/es2019/plugins/table/ui/DragPreview/index.js +33 -0
- package/dist/es2019/plugins/table/ui/Icons/DragInMotionIcon.js +47 -0
- package/dist/es2019/plugins/table/ui/TableFloatingControls/NumberColumn/index.js +54 -10
- package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/ClassicControls.js +86 -0
- package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +43 -0
- package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/index.js +2 -88
- package/dist/es2019/plugins/table/ui/TableFloatingControls/index.js +17 -7
- package/dist/es2019/plugins/table/ui/common-styles.js +47 -12
- package/dist/es2019/plugins/table/ui/consts.js +1 -0
- package/dist/es2019/plugins/table/ui/ui-styles.js +57 -14
- package/dist/es2019/plugins/table/utils/decoration.js +44 -18
- package/dist/es2019/plugins/table/utils/dom.js +2 -0
- package/dist/es2019/plugins/table/utils/index.js +1 -1
- package/dist/esm/plugins/table/commands/hover.js +16 -8
- package/dist/esm/plugins/table/commands/index.js +1 -1
- package/dist/esm/plugins/table/commands/misc.js +1 -7
- package/dist/esm/plugins/table/event-handlers.js +29 -2
- package/dist/esm/plugins/table/index.js +1 -1
- package/dist/esm/plugins/table/nodeviews/TableComponent.js +5 -3
- package/dist/esm/plugins/table/nodeviews/table.js +4 -2
- package/dist/esm/plugins/table/pm-plugins/decorations/plugin.js +8 -6
- package/dist/esm/plugins/table/pm-plugins/decorations/utils/column-controls.js +7 -2
- package/dist/esm/plugins/table/pm-plugins/default-table-selection.js +13 -0
- package/dist/esm/plugins/table/pm-plugins/main.js +7 -7
- package/dist/esm/plugins/table/reducer.js +2 -1
- package/dist/esm/plugins/table/types.js +6 -0
- package/dist/esm/plugins/table/ui/DragHandle/index.js +41 -0
- package/dist/esm/plugins/table/ui/DragPreview/index.js +32 -0
- package/dist/esm/plugins/table/ui/Icons/DragInMotionIcon.js +48 -0
- package/dist/esm/plugins/table/ui/TableFloatingControls/NumberColumn/index.js +54 -15
- package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/ClassicControls.js +104 -0
- package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +46 -0
- package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/index.js +2 -104
- package/dist/esm/plugins/table/ui/TableFloatingControls/index.js +17 -7
- package/dist/esm/plugins/table/ui/common-styles.js +10 -7
- package/dist/esm/plugins/table/ui/consts.js +1 -0
- package/dist/esm/plugins/table/ui/ui-styles.js +18 -9
- package/dist/esm/plugins/table/utils/decoration.js +44 -18
- package/dist/esm/plugins/table/utils/dom.js +6 -0
- package/dist/esm/plugins/table/utils/index.js +1 -1
- package/dist/types/plugins/table/commands/hover.d.ts +2 -1
- package/dist/types/plugins/table/commands/index.d.ts +1 -1
- package/dist/types/plugins/table/event-handlers.d.ts +1 -0
- package/dist/types/plugins/table/nodeviews/types.d.ts +4 -3
- package/dist/types/plugins/table/pm-plugins/decorations/plugin.d.ts +2 -1
- package/dist/types/plugins/table/pm-plugins/decorations/utils/column-controls.d.ts +1 -1
- package/dist/types/plugins/table/pm-plugins/default-table-selection.d.ts +12 -0
- package/dist/types/plugins/table/pm-plugins/main.d.ts +1 -1
- package/dist/types/plugins/table/types.d.ts +16 -1
- package/dist/types/plugins/table/ui/DragHandle/index.d.ts +11 -0
- package/dist/types/plugins/table/ui/DragPreview/index.d.ts +6 -0
- package/dist/types/plugins/table/ui/Icons/DragInMotionIcon.d.ts +6 -0
- package/dist/types/plugins/table/ui/TableFloatingControls/NumberColumn/index.d.ts +4 -1
- package/dist/types/plugins/table/ui/TableFloatingControls/RowControls/ClassicControls.d.ts +17 -0
- package/dist/types/plugins/table/ui/TableFloatingControls/RowControls/DragControls.d.ts +16 -0
- package/dist/types/plugins/table/ui/TableFloatingControls/RowControls/index.d.ts +2 -17
- package/dist/types/plugins/table/ui/TableFloatingControls/index.d.ts +3 -2
- package/dist/types/plugins/table/ui/consts.d.ts +1 -0
- package/dist/types/plugins/table/utils/decoration.d.ts +2 -2
- package/dist/types/plugins/table/utils/dom.d.ts +2 -0
- package/dist/types/plugins/table/utils/index.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/commands/hover.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/commands/index.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/event-handlers.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/nodeviews/types.d.ts +4 -3
- package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/plugin.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/utils/column-controls.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/pm-plugins/default-table-selection.d.ts +12 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/main.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/types.d.ts +16 -1
- package/dist/types-ts4.5/plugins/table/ui/DragHandle/index.d.ts +11 -0
- package/dist/types-ts4.5/plugins/table/ui/DragPreview/index.d.ts +6 -0
- package/dist/types-ts4.5/plugins/table/ui/Icons/DragInMotionIcon.d.ts +6 -0
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/NumberColumn/index.d.ts +4 -1
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/RowControls/ClassicControls.d.ts +17 -0
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/RowControls/DragControls.d.ts +16 -0
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/RowControls/index.d.ts +2 -17
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/index.d.ts +3 -2
- package/dist/types-ts4.5/plugins/table/ui/consts.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/utils/decoration.d.ts +2 -2
- package/dist/types-ts4.5/plugins/table/utils/dom.d.ts +2 -0
- package/dist/types-ts4.5/plugins/table/utils/index.d.ts +1 -1
- package/package.json +5 -3
- package/src/__tests__/unit/event-handlers.ts +74 -1
- package/src/__tests__/unit/pm-plugins/decorations/column-controls.ts +35 -15
- package/src/__tests__/unit/pm-plugins/decorations/plugin.ts +146 -42
- package/src/__tests__/unit/ui/NumberColumn.tsx +148 -0
- package/src/__tests__/unit/ui/RowControls.tsx +4 -4
- package/src/__tests__/unit/ui/RowDragControls.tsx +118 -0
- package/src/__tests__/unit/ui/TableFloatingControls.tsx +9 -5
- package/src/plugins/table/commands/hover.ts +16 -7
- package/src/plugins/table/commands/index.ts +1 -0
- package/src/plugins/table/commands/misc.ts +0 -5
- package/src/plugins/table/event-handlers.ts +49 -2
- package/src/plugins/table/index.tsx +1 -1
- package/src/plugins/table/nodeviews/TableComponent.tsx +3 -2
- package/src/plugins/table/nodeviews/table.tsx +2 -0
- package/src/plugins/table/nodeviews/types.ts +4 -3
- package/src/plugins/table/pm-plugins/decorations/plugin.ts +13 -4
- package/src/plugins/table/pm-plugins/decorations/utils/column-controls.ts +10 -5
- package/src/plugins/table/pm-plugins/default-table-selection.ts +10 -0
- package/src/plugins/table/pm-plugins/main.ts +9 -4
- package/src/plugins/table/reducer.ts +2 -1
- package/src/plugins/table/types.ts +14 -2
- package/src/plugins/table/ui/DragHandle/index.tsx +57 -0
- package/src/plugins/table/ui/DragPreview/index.tsx +45 -0
- package/src/plugins/table/ui/Icons/DragInMotionIcon.tsx +60 -0
- package/src/plugins/table/ui/TableFloatingControls/NumberColumn/index.tsx +68 -30
- package/src/plugins/table/ui/TableFloatingControls/RowControls/ClassicControls.tsx +129 -0
- package/src/plugins/table/ui/TableFloatingControls/RowControls/DragControls.tsx +75 -0
- package/src/plugins/table/ui/TableFloatingControls/RowControls/index.tsx +2 -135
- package/src/plugins/table/ui/TableFloatingControls/index.tsx +43 -24
- package/src/plugins/table/ui/common-styles.ts +52 -11
- package/src/plugins/table/ui/consts.ts +1 -0
- package/src/plugins/table/ui/ui-styles.ts +58 -14
- package/src/plugins/table/utils/decoration.ts +75 -27
- package/src/plugins/table/utils/dom.ts +8 -0
- package/src/plugins/table/utils/index.ts +2 -0
- package/tsconfig.app.json +6 -0
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
columnControlsDecorationHeight,
|
|
32
32
|
resizeHandlerAreaWidth,
|
|
33
33
|
resizeLineWidth,
|
|
34
|
+
rowControlsZIndex,
|
|
34
35
|
stickyHeaderBorderBottomWidth,
|
|
35
36
|
stickyRowOffsetTop,
|
|
36
37
|
tableBorderColor,
|
|
@@ -240,6 +241,26 @@ const tableStickyHeaderColumnControlsDecorationsStyle = (
|
|
|
240
241
|
}
|
|
241
242
|
};
|
|
242
243
|
|
|
244
|
+
const tableRowControlStyles = () => {
|
|
245
|
+
return getBooleanFF('platform.editor.table.drag-and-drop')
|
|
246
|
+
? css`
|
|
247
|
+
.${ClassName.ROW_CONTROLS_WRAPPER} {
|
|
248
|
+
position: absolute;
|
|
249
|
+
margin-top: ${tableMarginTop}px;
|
|
250
|
+
left: -${tableToolbarSize + 1}px;
|
|
251
|
+
z-index: ${rowControlsZIndex};
|
|
252
|
+
}
|
|
253
|
+
`
|
|
254
|
+
: css`
|
|
255
|
+
.${ClassName.ROW_CONTROLS_WRAPPER} {
|
|
256
|
+
position: absolute;
|
|
257
|
+
/* top of corner control is table margin top - corner control height + 1 pixel of table border. */
|
|
258
|
+
top: ${tableMarginTop - cornerControlHeight + 1}px;
|
|
259
|
+
left: -${tableToolbarSize}px;
|
|
260
|
+
}
|
|
261
|
+
`;
|
|
262
|
+
};
|
|
263
|
+
|
|
243
264
|
const tableWrapperStyles = () => {
|
|
244
265
|
if (getBooleanFF('platform.editor.custom-table-width')) {
|
|
245
266
|
return css`
|
|
@@ -677,6 +698,12 @@ export const tableStyles = (
|
|
|
677
698
|
)}
|
|
678
699
|
}
|
|
679
700
|
|
|
701
|
+
.${ClassName.ROW_CONTROLS_WITH_DRAG} {
|
|
702
|
+
display: grid;
|
|
703
|
+
align-items: center;
|
|
704
|
+
position: absolute;
|
|
705
|
+
}
|
|
706
|
+
|
|
680
707
|
${floatingColumnControls(props)}
|
|
681
708
|
|
|
682
709
|
:not(.${ClassName.IS_RESIZING}) .${ClassName.ROW_CONTROLS} {
|
|
@@ -691,7 +718,9 @@ export const tableStyles = (
|
|
|
691
718
|
margin-left: ${getBooleanFF('platform.editor.custom-table-width')
|
|
692
719
|
? akEditorTableToolbarSize
|
|
693
720
|
: akEditorTableToolbarSize - 1}px;
|
|
694
|
-
top: ${
|
|
721
|
+
top: ${getBooleanFF('platform.editor.table.drag-and-drop')
|
|
722
|
+
? 0
|
|
723
|
+
: akEditorTableToolbarSize}px;
|
|
695
724
|
width: ${akEditorTableNumberColumnWidth + 1}px;
|
|
696
725
|
box-sizing: border-box;
|
|
697
726
|
}
|
|
@@ -717,6 +746,21 @@ export const tableStyles = (
|
|
|
717
746
|
}
|
|
718
747
|
}
|
|
719
748
|
|
|
749
|
+
// add a background above the first numbered column cell when sticky header is engaged
|
|
750
|
+
// which hides the table when scrolling
|
|
751
|
+
.${ClassName.NUMBERED_COLUMN_BUTTON_DISABLED}:first-of-type::after {
|
|
752
|
+
content: '';
|
|
753
|
+
display: block;
|
|
754
|
+
height: 33px;
|
|
755
|
+
width: 100%;
|
|
756
|
+
background-color: ${token('elevation.surface', 'white')};
|
|
757
|
+
position: absolute;
|
|
758
|
+
|
|
759
|
+
// the extra pixel is accounting for borders
|
|
760
|
+
top: -34px;
|
|
761
|
+
left: -1px;
|
|
762
|
+
}
|
|
763
|
+
|
|
720
764
|
.${ClassName.WITH_CONTROLS} {
|
|
721
765
|
.${ClassName.CORNER_CONTROLS}, .${ClassName.ROW_CONTROLS} {
|
|
722
766
|
display: block;
|
|
@@ -741,10 +785,10 @@ export const tableStyles = (
|
|
|
741
785
|
}
|
|
742
786
|
}
|
|
743
787
|
:not(.${ClassName.IS_RESIZING}) .${ClassName.WITH_CONTROLS} {
|
|
744
|
-
.${ClassName.NUMBERED_COLUMN_BUTTON} {
|
|
788
|
+
.${ClassName.NUMBERED_COLUMN_BUTTON}:not(.${ClassName.NUMBERED_COLUMN_BUTTON_DISABLED}) {
|
|
745
789
|
cursor: pointer;
|
|
746
790
|
}
|
|
747
|
-
.${ClassName.NUMBERED_COLUMN_BUTTON}:hover {
|
|
791
|
+
.${ClassName.NUMBERED_COLUMN_BUTTON}:not(.${ClassName.NUMBERED_COLUMN_BUTTON_DISABLED}):hover {
|
|
748
792
|
border-bottom: 1px solid ${tableBorderSelectedColor(props)};
|
|
749
793
|
border-color: ${tableBorderSelectedColor(props)};
|
|
750
794
|
background-color: ${tableToolbarSelectedColor(props)};
|
|
@@ -780,6 +824,10 @@ export const tableStyles = (
|
|
|
780
824
|
margin-top: 0;
|
|
781
825
|
}
|
|
782
826
|
|
|
827
|
+
.${ClassName.COLUMN_CONTROLS_DECORATIONS_WITH_DRAG} + * {
|
|
828
|
+
margin-top: 0;
|
|
829
|
+
}
|
|
830
|
+
|
|
783
831
|
/*
|
|
784
832
|
* Headings have a top margin by default, but we don't want this on the
|
|
785
833
|
* first heading within table header cells.
|
|
@@ -853,17 +901,10 @@ export const tableStyles = (
|
|
|
853
901
|
}
|
|
854
902
|
}
|
|
855
903
|
}
|
|
856
|
-
|
|
857
|
-
position: absolute;
|
|
858
|
-
/* top of corner control is table margin top - corner control height + 1 pixel of table border. */
|
|
859
|
-
top: ${tableMarginTop - cornerControlHeight + 1}px;
|
|
860
|
-
}
|
|
904
|
+
${tableRowControlStyles()}
|
|
861
905
|
.${ClassName.ROW_CONTROLS_WRAPPER}.${ClassName.TABLE_LEFT_SHADOW} {
|
|
862
906
|
z-index: ${akEditorUnitZIndex};
|
|
863
907
|
}
|
|
864
|
-
.${ClassName.ROW_CONTROLS_WRAPPER} {
|
|
865
|
-
left: -${tableToolbarSize}px;
|
|
866
|
-
}
|
|
867
908
|
|
|
868
909
|
.${ClassName.COLUMN_CONTROLS_WRAPPER} {
|
|
869
910
|
position: absolute;
|
|
@@ -130,6 +130,7 @@ export const lineMarkerSize = 4;
|
|
|
130
130
|
export const columnControlsDecorationHeight = 25;
|
|
131
131
|
export const columnControlsZIndex = akEditorUnitZIndex * 10;
|
|
132
132
|
export const columnControlsSelectedZIndex = columnControlsZIndex + 1;
|
|
133
|
+
export const rowControlsZIndex = akEditorUnitZIndex * 10;
|
|
133
134
|
export const columnResizeHandleZIndex = columnControlsSelectedZIndex + 1;
|
|
134
135
|
export const insertLineWidth = 3;
|
|
135
136
|
export const resizeHandlerAreaWidth = RESIZE_HANDLE_AREA_DECORATION_GAP / 3;
|
|
@@ -390,6 +390,17 @@ export const floatingColumnControls = (props: ThemeProps) => {
|
|
|
390
390
|
};
|
|
391
391
|
|
|
392
392
|
export const columnControlsDecoration = (props: ThemeProps) => {
|
|
393
|
+
if (getBooleanFF('platform.editor.table.drag-and-drop')) {
|
|
394
|
+
return css`
|
|
395
|
+
.${ClassName.COLUMN_CONTROLS_DECORATIONS_WITH_DRAG} {
|
|
396
|
+
position: absolute;
|
|
397
|
+
// kinda a hacky way to center an element with absolute positioning inside a relative element
|
|
398
|
+
top: 25%;
|
|
399
|
+
left: 50%;
|
|
400
|
+
transform: translate(-50%, -100%);
|
|
401
|
+
}
|
|
402
|
+
`;
|
|
403
|
+
}
|
|
393
404
|
if (getBooleanFF('platform.editor.table.column-controls-styles-updated')) {
|
|
394
405
|
return css`
|
|
395
406
|
.${ClassName.COLUMN_CONTROLS_DECORATIONS} {
|
|
@@ -675,21 +686,35 @@ const getLastColumnResizerOverrides = () => {
|
|
|
675
686
|
: '';
|
|
676
687
|
};
|
|
677
688
|
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
689
|
+
const resizeHandleOverrides = (props: ThemeProps) => {
|
|
690
|
+
if (getBooleanFF('platform.editor.table.drag-and-drop')) {
|
|
691
|
+
return css`
|
|
692
|
+
th.${ClassName.WITH_RESIZE_LINE}::before,
|
|
693
|
+
td.${ClassName.WITH_RESIZE_LINE}::before {
|
|
694
|
+
content: ' ';
|
|
695
|
+
position: absolute;
|
|
696
|
+
left: ${token('space.negative.025', '-2px')};
|
|
697
|
+
top: -1px;
|
|
698
|
+
width: ${resizeLineWidth}px;
|
|
699
|
+
height: calc(100% + 2px);
|
|
700
|
+
background-color: ${tableBorderSelectedColor(props)};
|
|
701
|
+
z-index: ${columnControlsZIndex * 2};
|
|
702
|
+
}
|
|
692
703
|
|
|
704
|
+
th.${ClassName.WITH_RESIZE_LINE_LAST_COLUMN}::before,
|
|
705
|
+
td.${ClassName.WITH_RESIZE_LINE_LAST_COLUMN}::before {
|
|
706
|
+
content: ' ';
|
|
707
|
+
position: absolute;
|
|
708
|
+
right: -1px;
|
|
709
|
+
top: -1px;
|
|
710
|
+
width: ${resizeLineWidth}px;
|
|
711
|
+
height: calc(100% + 2px);
|
|
712
|
+
background-color: ${tableBorderSelectedColor(props)};
|
|
713
|
+
z-index: ${columnControlsZIndex * 2};
|
|
714
|
+
}
|
|
715
|
+
`;
|
|
716
|
+
}
|
|
717
|
+
return css`
|
|
693
718
|
td.${ClassName.WITH_RESIZE_LINE}::before {
|
|
694
719
|
content: ' ';
|
|
695
720
|
position: absolute;
|
|
@@ -733,6 +758,25 @@ export const resizeHandle = (props: ThemeProps) => css`
|
|
|
733
758
|
z-index: ${columnControlsZIndex * 2};
|
|
734
759
|
top: -${tableToolbarSize + tableCellBorderWidth}px;
|
|
735
760
|
}
|
|
761
|
+
`;
|
|
762
|
+
};
|
|
763
|
+
|
|
764
|
+
export const resizeHandle = (props: ThemeProps) => css`
|
|
765
|
+
.${ClassName.TABLE_CONTAINER} {
|
|
766
|
+
.${ClassName.RESIZE_HANDLE_DECORATION} {
|
|
767
|
+
background-color: transparent;
|
|
768
|
+
position: absolute;
|
|
769
|
+
width: ${resizeHandlerAreaWidth}px;
|
|
770
|
+
height: 100%;
|
|
771
|
+
top: 0;
|
|
772
|
+
right: -${resizeHandlerAreaWidth / 2}px;
|
|
773
|
+
cursor: col-resize;
|
|
774
|
+
z-index: ${resizeHandlerZIndex};
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
${getLastColumnResizerOverrides()}
|
|
778
|
+
|
|
779
|
+
${resizeHandleOverrides(props)}
|
|
736
780
|
|
|
737
781
|
table
|
|
738
782
|
tr:first-of-type
|
|
@@ -22,10 +22,16 @@ import {
|
|
|
22
22
|
getCellsInRow,
|
|
23
23
|
getSelectionRect,
|
|
24
24
|
} from '@atlaskit/editor-tables/utils';
|
|
25
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
25
26
|
|
|
26
|
-
import type {
|
|
27
|
+
import type {
|
|
28
|
+
Cell,
|
|
29
|
+
CellColumnPositioning,
|
|
30
|
+
CellHoverCoordinates,
|
|
31
|
+
} from '../types';
|
|
27
32
|
import { TableCssClassName as ClassName, TableDecorations } from '../types';
|
|
28
33
|
import { ColumnResizeWidget } from '../ui/ColumnResizeWidget';
|
|
34
|
+
import { DragHandle } from '../ui/DragHandle';
|
|
29
35
|
|
|
30
36
|
const filterDecorationByKey = (
|
|
31
37
|
key: TableDecorations,
|
|
@@ -206,35 +212,77 @@ export const createColumnSelectedDecoration = (
|
|
|
206
212
|
|
|
207
213
|
export const createColumnControlsDecoration = (
|
|
208
214
|
selection: Selection,
|
|
215
|
+
hoverLocation?: CellHoverCoordinates,
|
|
209
216
|
): Decoration[] => {
|
|
217
|
+
// todo: issue here where table may not be selected yet
|
|
210
218
|
const cells: ContentNodeWithPos[] = getCellsInRow(0)(selection) || [];
|
|
211
|
-
|
|
212
|
-
return cells.map((cell) => {
|
|
213
|
-
const colspan = (cell.node.attrs as CellAttributes).colspan || 1;
|
|
214
|
-
// It's important these values are scoped locally as the widget callback could be executed anytime in the future
|
|
215
|
-
// and we want to avoid value leak
|
|
216
|
-
const startIndex = index;
|
|
217
|
-
const endIndex = startIndex + colspan;
|
|
218
|
-
|
|
219
|
-
// The next cell start index will commence from the current cell end index.
|
|
220
|
-
index = endIndex;
|
|
219
|
+
const table = findTable(selection);
|
|
221
220
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
221
|
+
if (
|
|
222
|
+
getBooleanFF('platform.editor.table.drag-and-drop') &&
|
|
223
|
+
hoverLocation &&
|
|
224
|
+
!Number.isNaN(hoverLocation?.colIndex) &&
|
|
225
|
+
table
|
|
226
|
+
) {
|
|
227
|
+
const colIndex = hoverLocation.colIndex as number;
|
|
228
|
+
const cell = cells[colIndex];
|
|
229
|
+
return [
|
|
230
|
+
Decoration.widget(
|
|
231
|
+
cell.pos + 1,
|
|
232
|
+
() => {
|
|
233
|
+
const element = document.createElement('div');
|
|
234
|
+
element.classList.add(
|
|
235
|
+
ClassName.COLUMN_CONTROLS_DECORATIONS_WITH_DRAG,
|
|
236
|
+
);
|
|
237
|
+
ReactDOM.render(
|
|
238
|
+
createElement(DragHandle, {
|
|
239
|
+
tableLocalId: table.node.attrs.localId,
|
|
240
|
+
direction: 'column',
|
|
241
|
+
indexes: [colIndex],
|
|
242
|
+
}),
|
|
243
|
+
element,
|
|
244
|
+
);
|
|
245
|
+
return element;
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
key: `${TableDecorations.COLUMN_CONTROLS_DECORATIONS}_${colIndex}`,
|
|
249
|
+
// this decoration should be the first one, even before gap cursor.
|
|
250
|
+
side: -100,
|
|
251
|
+
destroy: (node) => {
|
|
252
|
+
ReactDOM.unmountComponentAtNode(node as HTMLDivElement);
|
|
253
|
+
},
|
|
254
|
+
},
|
|
255
|
+
),
|
|
256
|
+
];
|
|
257
|
+
} else {
|
|
258
|
+
let index = 0;
|
|
259
|
+
return cells.map((cell) => {
|
|
260
|
+
const colspan = (cell.node.attrs as CellAttributes).colspan || 1;
|
|
261
|
+
// It's important these values are scoped locally as the widget callback could be executed anytime in the future
|
|
262
|
+
// and we want to avoid value leak
|
|
263
|
+
const startIndex = index;
|
|
264
|
+
const endIndex = startIndex + colspan;
|
|
265
|
+
|
|
266
|
+
// The next cell start index will commence from the current cell end index.
|
|
267
|
+
index = endIndex;
|
|
268
|
+
|
|
269
|
+
return Decoration.widget(
|
|
270
|
+
cell.pos + 1,
|
|
271
|
+
() => {
|
|
272
|
+
const element = document.createElement('div');
|
|
273
|
+
element.classList.add(ClassName.COLUMN_CONTROLS_DECORATIONS);
|
|
274
|
+
element.dataset.startIndex = `${startIndex}`;
|
|
275
|
+
element.dataset.endIndex = `${endIndex}`;
|
|
276
|
+
return element;
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
key: `${TableDecorations.COLUMN_CONTROLS_DECORATIONS}_${endIndex}`,
|
|
280
|
+
// this decoration should be the first one, even before gap cursor.
|
|
281
|
+
side: -100,
|
|
282
|
+
},
|
|
283
|
+
);
|
|
284
|
+
});
|
|
285
|
+
}
|
|
238
286
|
};
|
|
239
287
|
|
|
240
288
|
export const updateDecorations = (
|
|
@@ -36,10 +36,18 @@ export const isColumnControlsDecorations = (
|
|
|
36
36
|
node: HTMLElement | null,
|
|
37
37
|
): boolean => containsClassName(node, ClassName.COLUMN_CONTROLS_DECORATIONS);
|
|
38
38
|
|
|
39
|
+
export const isColumnDragControlsDecorations = (node: HTMLElement | null) =>
|
|
40
|
+
containsClassName(node, ClassName.COLUMN_CONTROLS_DECORATIONS_WITH_DRAG) ||
|
|
41
|
+
closestElement(node, `.${ClassName.COLUMN_CONTROLS_DECORATIONS_WITH_DRAG}`);
|
|
42
|
+
|
|
39
43
|
export const isRowControlsButton = (node: HTMLElement | null): boolean =>
|
|
40
44
|
containsClassName(node, ClassName.ROW_CONTROLS_BUTTON) ||
|
|
41
45
|
containsClassName(node, ClassName.NUMBERED_COLUMN_BUTTON);
|
|
42
46
|
|
|
47
|
+
export const isRowDragControlsButton = (node: HTMLElement | null) =>
|
|
48
|
+
containsClassName(node, ClassName.ROW_CONTROLS_WITH_DRAG) ||
|
|
49
|
+
closestElement(node, `.${ClassName.ROW_CONTROLS_WITH_DRAG}`);
|
|
50
|
+
|
|
43
51
|
export const isResizeHandleDecoration = (node: HTMLElement | null): boolean =>
|
|
44
52
|
containsClassName(node, ClassName.RESIZE_HANDLE_DECORATION);
|
|
45
53
|
|
package/tsconfig.app.json
CHANGED
|
@@ -75,6 +75,12 @@
|
|
|
75
75
|
{
|
|
76
76
|
"path": "../../pragmatic-drag-and-drop/hitbox/tsconfig.app.json"
|
|
77
77
|
},
|
|
78
|
+
{
|
|
79
|
+
"path": "../../pragmatic-drag-and-drop/react-accessibility/tsconfig.app.json"
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"path": "../../design-system/primitives/tsconfig.app.json"
|
|
83
|
+
},
|
|
78
84
|
{
|
|
79
85
|
"path": "../../design-system/theme/tsconfig.app.json"
|
|
80
86
|
},
|