@atlaskit/editor-plugin-table 5.3.13 → 5.3.15
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 +16 -0
- package/dist/cjs/plugins/table/event-handlers.js +6 -3
- package/dist/cjs/plugins/table/index.js +6 -4
- package/dist/cjs/plugins/table/pm-plugins/decorations/plugin.js +3 -7
- package/dist/cjs/plugins/table/pm-plugins/decorations/utils/column-controls.js +1 -3
- package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/plugin.js +11 -0
- package/dist/cjs/plugins/table/types.js +9 -2
- package/dist/cjs/plugins/table/ui/FloatingDragMenu/DragMenu.js +49 -11
- package/dist/cjs/plugins/table/ui/FloatingDragMenu/index.js +10 -5
- package/dist/cjs/plugins/table/ui/FloatingInsertButton/InsertButton.js +57 -9
- package/dist/cjs/plugins/table/ui/FloatingInsertButton/getPopupOptions.js +9 -7
- package/dist/cjs/plugins/table/ui/FloatingInsertButton/index.js +13 -4
- package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +44 -5
- package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/index.js +6 -4
- package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +35 -13
- package/dist/cjs/plugins/table/ui/TableFloatingControls/index.js +2 -0
- package/dist/cjs/plugins/table/ui/common-styles.js +1 -1
- package/dist/cjs/plugins/table/ui/icons/AddColLeftIcon.js +44 -0
- package/dist/cjs/plugins/table/ui/icons/AddColRightIcon.js +44 -0
- package/dist/cjs/plugins/table/ui/icons/AddRowAboveIcon.js +45 -0
- package/dist/cjs/plugins/table/ui/icons/AddRowBelowIcon.js +40 -0
- package/dist/cjs/plugins/table/ui/icons/index.js +29 -1
- package/dist/cjs/plugins/table/ui/ui-styles.js +27 -24
- package/dist/cjs/plugins/table/utils/dom.js +12 -4
- package/dist/cjs/plugins/table/utils/drag-menu.js +122 -10
- package/dist/cjs/plugins/table/utils/index.js +12 -0
- package/dist/es2019/plugins/table/event-handlers.js +5 -4
- package/dist/es2019/plugins/table/index.js +6 -4
- package/dist/es2019/plugins/table/pm-plugins/decorations/plugin.js +3 -7
- package/dist/es2019/plugins/table/pm-plugins/decorations/utils/column-controls.js +1 -3
- package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/plugin.js +12 -0
- package/dist/es2019/plugins/table/types.js +9 -2
- package/dist/es2019/plugins/table/ui/FloatingDragMenu/DragMenu.js +52 -8
- package/dist/es2019/plugins/table/ui/FloatingDragMenu/index.js +10 -5
- package/dist/es2019/plugins/table/ui/FloatingInsertButton/InsertButton.js +58 -7
- package/dist/es2019/plugins/table/ui/FloatingInsertButton/getPopupOptions.js +9 -7
- package/dist/es2019/plugins/table/ui/FloatingInsertButton/index.js +10 -4
- package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +46 -6
- package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/index.js +7 -5
- package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +35 -14
- package/dist/es2019/plugins/table/ui/TableFloatingControls/index.js +2 -0
- package/dist/es2019/plugins/table/ui/common-styles.js +51 -3
- package/dist/es2019/plugins/table/ui/icons/AddColLeftIcon.js +35 -0
- package/dist/es2019/plugins/table/ui/icons/AddColRightIcon.js +35 -0
- package/dist/es2019/plugins/table/ui/icons/AddRowAboveIcon.js +36 -0
- package/dist/es2019/plugins/table/ui/icons/AddRowBelowIcon.js +31 -0
- package/dist/es2019/plugins/table/ui/icons/index.js +5 -1
- package/dist/es2019/plugins/table/ui/ui-styles.js +23 -1
- package/dist/es2019/plugins/table/utils/dom.js +5 -1
- package/dist/es2019/plugins/table/utils/drag-menu.js +118 -8
- package/dist/es2019/plugins/table/utils/index.js +1 -1
- package/dist/esm/plugins/table/event-handlers.js +7 -4
- package/dist/esm/plugins/table/index.js +6 -4
- package/dist/esm/plugins/table/pm-plugins/decorations/plugin.js +3 -7
- package/dist/esm/plugins/table/pm-plugins/decorations/utils/column-controls.js +1 -3
- package/dist/esm/plugins/table/pm-plugins/drag-and-drop/plugin.js +11 -0
- package/dist/esm/plugins/table/types.js +9 -2
- package/dist/esm/plugins/table/ui/FloatingDragMenu/DragMenu.js +46 -8
- package/dist/esm/plugins/table/ui/FloatingDragMenu/index.js +10 -5
- package/dist/esm/plugins/table/ui/FloatingInsertButton/InsertButton.js +56 -8
- package/dist/esm/plugins/table/ui/FloatingInsertButton/getPopupOptions.js +9 -7
- package/dist/esm/plugins/table/ui/FloatingInsertButton/index.js +10 -4
- package/dist/esm/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +45 -6
- package/dist/esm/plugins/table/ui/TableFloatingColumnControls/index.js +7 -5
- package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +36 -14
- package/dist/esm/plugins/table/ui/TableFloatingControls/index.js +2 -0
- package/dist/esm/plugins/table/ui/common-styles.js +2 -2
- package/dist/esm/plugins/table/ui/icons/AddColLeftIcon.js +37 -0
- package/dist/esm/plugins/table/ui/icons/AddColRightIcon.js +37 -0
- package/dist/esm/plugins/table/ui/icons/AddRowAboveIcon.js +38 -0
- package/dist/esm/plugins/table/ui/icons/AddRowBelowIcon.js +33 -0
- package/dist/esm/plugins/table/ui/icons/index.js +5 -1
- package/dist/esm/plugins/table/ui/ui-styles.js +26 -23
- package/dist/esm/plugins/table/utils/dom.js +11 -3
- package/dist/esm/plugins/table/utils/drag-menu.js +120 -8
- package/dist/esm/plugins/table/utils/index.js +1 -1
- package/dist/types/plugins/table/types.d.ts +9 -2
- package/dist/types/plugins/table/ui/FloatingDragMenu/DragMenu.d.ts +5 -2
- package/dist/types/plugins/table/ui/FloatingDragMenu/index.d.ts +3 -1
- package/dist/types/plugins/table/ui/FloatingInsertButton/InsertButton.d.ts +5 -1
- package/dist/types/plugins/table/ui/FloatingInsertButton/getPopupOptions.d.ts +1 -1
- package/dist/types/plugins/table/ui/FloatingInsertButton/index.d.ts +1 -0
- package/dist/types/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +2 -1
- package/dist/types/plugins/table/ui/TableFloatingControls/RowControls/DragControls.d.ts +2 -0
- package/dist/types/plugins/table/ui/icons/AddColLeftIcon.d.ts +2 -0
- package/dist/types/plugins/table/ui/icons/AddColRightIcon.d.ts +2 -0
- package/dist/types/plugins/table/ui/icons/AddRowAboveIcon.d.ts +2 -0
- package/dist/types/plugins/table/ui/icons/AddRowBelowIcon.d.ts +2 -0
- package/dist/types/plugins/table/ui/icons/index.d.ts +4 -0
- package/dist/types/plugins/table/ui/ui-styles.d.ts +1 -0
- package/dist/types/plugins/table/utils/dom.d.ts +4 -1
- package/dist/types/plugins/table/utils/drag-menu.d.ts +6 -3
- package/dist/types/plugins/table/utils/index.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/types.d.ts +9 -2
- package/dist/types-ts4.5/plugins/table/ui/FloatingDragMenu/DragMenu.d.ts +5 -2
- package/dist/types-ts4.5/plugins/table/ui/FloatingDragMenu/index.d.ts +3 -1
- package/dist/types-ts4.5/plugins/table/ui/FloatingInsertButton/InsertButton.d.ts +5 -1
- package/dist/types-ts4.5/plugins/table/ui/FloatingInsertButton/getPopupOptions.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/ui/FloatingInsertButton/index.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/RowControls/DragControls.d.ts +2 -0
- package/dist/types-ts4.5/plugins/table/ui/icons/AddColLeftIcon.d.ts +2 -0
- package/dist/types-ts4.5/plugins/table/ui/icons/AddColRightIcon.d.ts +2 -0
- package/dist/types-ts4.5/plugins/table/ui/icons/AddRowAboveIcon.d.ts +2 -0
- package/dist/types-ts4.5/plugins/table/ui/icons/AddRowBelowIcon.d.ts +2 -0
- package/dist/types-ts4.5/plugins/table/ui/icons/index.d.ts +4 -0
- package/dist/types-ts4.5/plugins/table/ui/ui-styles.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/utils/dom.d.ts +4 -1
- package/dist/types-ts4.5/plugins/table/utils/drag-menu.d.ts +6 -3
- package/dist/types-ts4.5/plugins/table/utils/index.d.ts +1 -1
- package/package.json +2 -1
- package/src/__tests__/unit/pm-plugins/decorations/plugin.ts +40 -194
- package/src/__tests__/unit/ui/RowDragControls.tsx +9 -11
- package/src/plugins/table/event-handlers.ts +15 -3
- package/src/plugins/table/index.tsx +4 -2
- package/src/plugins/table/pm-plugins/decorations/plugin.ts +2 -9
- package/src/plugins/table/pm-plugins/decorations/utils/column-controls.ts +1 -3
- package/src/plugins/table/pm-plugins/drag-and-drop/plugin.ts +9 -0
- package/src/plugins/table/types.ts +12 -2
- package/src/plugins/table/ui/FloatingDragMenu/DragMenu.tsx +73 -6
- package/src/plugins/table/ui/FloatingDragMenu/index.tsx +15 -3
- package/src/plugins/table/ui/FloatingInsertButton/InsertButton.tsx +82 -8
- package/src/plugins/table/ui/FloatingInsertButton/getPopupOptions.ts +28 -5
- package/src/plugins/table/ui/FloatingInsertButton/index.tsx +19 -7
- package/src/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.tsx +47 -3
- package/src/plugins/table/ui/TableFloatingColumnControls/index.tsx +11 -4
- package/src/plugins/table/ui/TableFloatingControls/RowControls/DragControls.tsx +49 -18
- package/src/plugins/table/ui/TableFloatingControls/index.tsx +2 -0
- package/src/plugins/table/ui/common-styles.ts +57 -2
- package/src/plugins/table/ui/icons/AddColLeftIcon.tsx +43 -0
- package/src/plugins/table/ui/icons/AddColRightIcon.tsx +43 -0
- package/src/plugins/table/ui/icons/AddRowAboveIcon.tsx +42 -0
- package/src/plugins/table/ui/icons/AddRowBelowIcon.tsx +36 -0
- package/src/plugins/table/ui/icons/index.ts +4 -0
- package/src/plugins/table/ui/ui-styles.ts +27 -1
- package/src/plugins/table/utils/dom.ts +11 -4
- package/src/plugins/table/utils/drag-menu.ts +158 -5
- package/src/plugins/table/utils/index.ts +2 -0
- package/tsconfig.app.json +3 -0
|
@@ -56,6 +56,7 @@ import {
|
|
|
56
56
|
columnControlsDecoration,
|
|
57
57
|
columnControlsLineMarker,
|
|
58
58
|
DeleteButton,
|
|
59
|
+
dragInsertButtonWrapper,
|
|
59
60
|
floatingColumnControls,
|
|
60
61
|
HeaderButton,
|
|
61
62
|
HeaderButtonDanger,
|
|
@@ -357,6 +358,8 @@ export const tableStyles = (
|
|
|
357
358
|
${insertRowButtonWrapper(props)}
|
|
358
359
|
}
|
|
359
360
|
|
|
361
|
+
${dragInsertButtonWrapper(props)}
|
|
362
|
+
|
|
360
363
|
/* Delete button */
|
|
361
364
|
${DeleteButton(props)}
|
|
362
365
|
/* Ends Delete button */
|
|
@@ -700,12 +703,64 @@ export const tableStyles = (
|
|
|
700
703
|
)}
|
|
701
704
|
}
|
|
702
705
|
|
|
703
|
-
.${ClassName.
|
|
706
|
+
.${ClassName.DRAG_ROW_CONTROLS} {
|
|
704
707
|
display: grid;
|
|
705
708
|
align-items: center;
|
|
706
709
|
position: absolute;
|
|
707
710
|
left: -4px;
|
|
708
711
|
z-index: ${akEditorUnitZIndex};
|
|
712
|
+
|
|
713
|
+
.${ClassName.DRAG_ROW_FLOATING_INSERT_DOT_WRAPPER} {
|
|
714
|
+
align-self: end;
|
|
715
|
+
position: absolute;
|
|
716
|
+
height: 100%;
|
|
717
|
+
width: 24px;
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
.${ClassName.DRAG_ROW_FLOATING_INSERT_DOT} {
|
|
721
|
+
position: absolute;
|
|
722
|
+
bottom: -3px;
|
|
723
|
+
left: 6px;
|
|
724
|
+
background-color: ${token(
|
|
725
|
+
'color.background.accent.gray.subtler',
|
|
726
|
+
'#C1C7D0',
|
|
727
|
+
)};
|
|
728
|
+
height: 4px;
|
|
729
|
+
width: 4px;
|
|
730
|
+
border-radius: 50%;
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
.${ClassName.DRAG_COLUMN_CONTROLS} {
|
|
735
|
+
.${ClassName.COLUMN_CONTROLS_INNER} {
|
|
736
|
+
height: 24px;
|
|
737
|
+
position: absolute;
|
|
738
|
+
top: ${token('space.negative.150', '-12px')};
|
|
739
|
+
z-index: ${akEditorUnitZIndex};
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
.${ClassName.DRAG_COLUMN_FLOATING_INSERT_DOT_WRAPPER} {
|
|
743
|
+
position: absolute;
|
|
744
|
+
height: 24px;
|
|
745
|
+
width: 100%;
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
.${ClassName.DRAG_COLUMN_FLOATING_INSERT_DOT} {
|
|
749
|
+
background-color: ${token(
|
|
750
|
+
'color.background.accent.gray.subtler',
|
|
751
|
+
'#C1C7D0',
|
|
752
|
+
)};
|
|
753
|
+
height: 4px;
|
|
754
|
+
width: 4px;
|
|
755
|
+
border-radius: 50%;
|
|
756
|
+
position: absolute;
|
|
757
|
+
right: -2px;
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
.${ClassName.CONTROLS_FLOATING_BUTTON_ROW}
|
|
762
|
+
.${ClassName.DRAG_CONTROLS_INSERT_BUTTON_INNER} {
|
|
763
|
+
bottom: -1px;
|
|
709
764
|
}
|
|
710
765
|
|
|
711
766
|
.${ClassName.DRAG_HANDLE_BUTTON_CONTAINER} {
|
|
@@ -719,10 +774,10 @@ export const tableStyles = (
|
|
|
719
774
|
display: flex;
|
|
720
775
|
justify-content: center;
|
|
721
776
|
align-items: center;
|
|
777
|
+
outline: none !important;
|
|
722
778
|
|
|
723
779
|
svg {
|
|
724
780
|
rect {
|
|
725
|
-
//
|
|
726
781
|
fill: ${token('color.background.accent.gray.subtlest', '#F1F2F4')};
|
|
727
782
|
}
|
|
728
783
|
g {
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
export const AddColLeftIcon = () => (
|
|
4
|
+
<svg
|
|
5
|
+
width="24"
|
|
6
|
+
height="24"
|
|
7
|
+
viewBox="0 0 24 24"
|
|
8
|
+
fill="currentColor"
|
|
9
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
10
|
+
>
|
|
11
|
+
<rect
|
|
12
|
+
width="24"
|
|
13
|
+
height="24"
|
|
14
|
+
transform="matrix(0 -1 1 0 0 24)"
|
|
15
|
+
fill="none"
|
|
16
|
+
fillOpacity="0.01"
|
|
17
|
+
/>
|
|
18
|
+
<rect
|
|
19
|
+
x="12"
|
|
20
|
+
y="18"
|
|
21
|
+
width="12"
|
|
22
|
+
height="3"
|
|
23
|
+
rx="0.5"
|
|
24
|
+
transform="rotate(-90 12 18)"
|
|
25
|
+
fill="currentColor"
|
|
26
|
+
/>
|
|
27
|
+
<rect
|
|
28
|
+
x="16"
|
|
29
|
+
y="18"
|
|
30
|
+
width="12"
|
|
31
|
+
height="3"
|
|
32
|
+
rx="0.5"
|
|
33
|
+
transform="rotate(-90 16 18)"
|
|
34
|
+
fill="currentColor"
|
|
35
|
+
/>
|
|
36
|
+
<path
|
|
37
|
+
fillRule="evenodd"
|
|
38
|
+
clipRule="evenodd"
|
|
39
|
+
d="M7 11H5.99C5.72652 11.0026 5.47473 11.1092 5.28935 11.2964C5.10397 11.4837 4.99999 11.7365 5 12C5 12.556 5.444 13 5.99 13H7V14C7 14.2652 7.10536 14.5196 7.29289 14.7071C7.48043 14.8946 7.73478 15 8 15C8.26522 15 8.51957 14.8946 8.70711 14.7071C8.89464 14.5196 9 14.2652 9 14V13H10.01C10.2735 12.9974 10.5253 12.8908 10.7107 12.7036C10.896 12.5163 11 12.2635 11 12C11 11.444 10.556 11 10.01 11H9V10C9 9.73478 8.89464 9.48043 8.70711 9.29289C8.51957 9.10536 8.26522 9 8 9C7.73478 9 7.48043 9.10536 7.29289 9.29289C7.10536 9.48043 7 9.73478 7 10V11Z"
|
|
40
|
+
fill="currentColor"
|
|
41
|
+
/>
|
|
42
|
+
</svg>
|
|
43
|
+
);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
export const AddColRightIcon = () => (
|
|
4
|
+
<svg
|
|
5
|
+
width="24"
|
|
6
|
+
height="24"
|
|
7
|
+
viewBox="0 0 24 24"
|
|
8
|
+
fill="none"
|
|
9
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
10
|
+
>
|
|
11
|
+
<rect
|
|
12
|
+
width="24"
|
|
13
|
+
height="24"
|
|
14
|
+
transform="translate(0 24) rotate(-90)"
|
|
15
|
+
fill="none"
|
|
16
|
+
fillOpacity="0.01"
|
|
17
|
+
/>
|
|
18
|
+
<rect
|
|
19
|
+
x="9"
|
|
20
|
+
y="18"
|
|
21
|
+
width="12"
|
|
22
|
+
height="3"
|
|
23
|
+
rx="0.5"
|
|
24
|
+
transform="rotate(-90 9 18)"
|
|
25
|
+
fill="currentColor"
|
|
26
|
+
/>
|
|
27
|
+
<rect
|
|
28
|
+
x="5"
|
|
29
|
+
y="18"
|
|
30
|
+
width="12"
|
|
31
|
+
height="3"
|
|
32
|
+
rx="0.5"
|
|
33
|
+
transform="rotate(-90 5 18)"
|
|
34
|
+
fill="currentColor"
|
|
35
|
+
/>
|
|
36
|
+
<path
|
|
37
|
+
fillRule="evenodd"
|
|
38
|
+
clipRule="evenodd"
|
|
39
|
+
d="M15 11L13.99 11C13.7265 11.0026 13.4747 11.1092 13.2893 11.2964C13.104 11.4837 13 11.7365 13 12C13 12.556 13.444 13 13.99 13L15 13L15 14C15 14.2652 15.1054 14.5196 15.2929 14.7071C15.4804 14.8946 15.7348 15 16 15C16.2652 15 16.5196 14.8946 16.7071 14.7071C16.8946 14.5196 17 14.2652 17 14L17 13L18.01 13C18.2735 12.9974 18.5253 12.8908 18.7107 12.7036C18.896 12.5163 19 12.2635 19 12C19 11.444 18.556 11 18.01 11L17 11L17 10C17 9.73478 16.8946 9.48043 16.7071 9.29289C16.5196 9.10536 16.2652 9 16 9C15.7348 9 15.4804 9.10536 15.2929 9.29289C15.1054 9.48043 15 9.73478 15 10L15 11Z"
|
|
40
|
+
fill="currentColor"
|
|
41
|
+
/>
|
|
42
|
+
</svg>
|
|
43
|
+
);
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { token } from '@atlaskit/tokens';
|
|
4
|
+
|
|
5
|
+
export const AddRowAboveIcon = () => (
|
|
6
|
+
<svg
|
|
7
|
+
width="24"
|
|
8
|
+
height="24"
|
|
9
|
+
viewBox="0 0 24 24"
|
|
10
|
+
fill="none"
|
|
11
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
12
|
+
>
|
|
13
|
+
<rect
|
|
14
|
+
width="24"
|
|
15
|
+
height="24"
|
|
16
|
+
fill={token('color.border.inverse', '#FFFFFF')}
|
|
17
|
+
fillOpacity="0.01"
|
|
18
|
+
/>
|
|
19
|
+
<mask
|
|
20
|
+
id="path-1-inside-1_896_17822"
|
|
21
|
+
fill={token('color.border.inverse', '#FFFFFF')}
|
|
22
|
+
>
|
|
23
|
+
<rect x="6" y="12" width="12" height="8" rx="0.5" />
|
|
24
|
+
</mask>
|
|
25
|
+
<rect
|
|
26
|
+
x="6"
|
|
27
|
+
y="12"
|
|
28
|
+
width="12"
|
|
29
|
+
height="8"
|
|
30
|
+
rx="0.5"
|
|
31
|
+
stroke="currentColor"
|
|
32
|
+
strokeWidth="4"
|
|
33
|
+
mask="url(#path-1-inside-1_896_17822)"
|
|
34
|
+
/>
|
|
35
|
+
<path
|
|
36
|
+
fillRule="evenodd"
|
|
37
|
+
clipRule="evenodd"
|
|
38
|
+
d="M13 7V5.99C12.9974 5.72652 12.8908 5.47473 12.7036 5.28935C12.5163 5.10397 12.2635 4.99999 12 5C11.444 5 11 5.444 11 5.99V7H10C9.73478 7 9.48043 7.10536 9.29289 7.29289C9.10536 7.48043 9 7.73478 9 8C9 8.26522 9.10536 8.51957 9.29289 8.70711C9.48043 8.89464 9.73478 9 10 9H11V10.01C11.0026 10.2735 11.1092 10.5253 11.2964 10.7107C11.4837 10.896 11.7365 11 12 11C12.556 11 13 10.556 13 10.01V9H14C14.2652 9 14.5196 8.89464 14.7071 8.70711C14.8946 8.51957 15 8.26522 15 8C15 7.73478 14.8946 7.48043 14.7071 7.29289C14.5196 7.10536 14.2652 7 14 7H13Z"
|
|
39
|
+
fill="currentColor"
|
|
40
|
+
/>
|
|
41
|
+
</svg>
|
|
42
|
+
);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { token } from '@atlaskit/tokens';
|
|
4
|
+
|
|
5
|
+
export const AddRowBelowIcon = () => (
|
|
6
|
+
<svg
|
|
7
|
+
width="24"
|
|
8
|
+
height="24"
|
|
9
|
+
viewBox="0 0 24 24"
|
|
10
|
+
fill="none"
|
|
11
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
12
|
+
>
|
|
13
|
+
<mask
|
|
14
|
+
id="path-1-inside-1_920_47112"
|
|
15
|
+
fill={token('color.border.inverse', '#FFFFFF')}
|
|
16
|
+
>
|
|
17
|
+
<rect x="6" y="4" width="12" height="8" rx="0.5" />
|
|
18
|
+
</mask>
|
|
19
|
+
<rect
|
|
20
|
+
x="6"
|
|
21
|
+
y="4"
|
|
22
|
+
width="12"
|
|
23
|
+
height="8"
|
|
24
|
+
rx="0.5"
|
|
25
|
+
stroke="currentColor"
|
|
26
|
+
strokeWidth="4"
|
|
27
|
+
mask="url(#path-1-inside-1_920_47112)"
|
|
28
|
+
/>
|
|
29
|
+
<path
|
|
30
|
+
fillRule="evenodd"
|
|
31
|
+
clipRule="evenodd"
|
|
32
|
+
d="M13 15V13.99C12.9974 13.7265 12.8908 13.4747 12.7036 13.2893C12.5163 13.104 12.2635 13 12 13C11.444 13 11 13.444 11 13.99V15H10C9.73478 15 9.48043 15.1054 9.29289 15.2929C9.10536 15.4804 9 15.7348 9 16C9 16.2652 9.10536 16.5196 9.29289 16.7071C9.48043 16.8946 9.73478 17 10 17H11V18.01C11.0026 18.2735 11.1092 18.5253 11.2964 18.7107C11.4837 18.896 11.7365 19 12 19C12.556 19 13 18.556 13 18.01V17H14C14.2652 17 14.5196 16.8946 14.7071 16.7071C14.8946 16.5196 15 16.2652 15 16C15 15.7348 14.8946 15.4804 14.7071 15.2929C14.5196 15.1054 14.2652 15 14 15H13Z"
|
|
33
|
+
fill="currentColor"
|
|
34
|
+
/>
|
|
35
|
+
</svg>
|
|
36
|
+
);
|
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
export { DragHandleIcon } from './DragHandleIcon';
|
|
2
2
|
export { DragInMotionIcon } from './DragInMotionIcon';
|
|
3
|
+
export { AddRowAboveIcon } from './AddRowAboveIcon';
|
|
4
|
+
export { AddRowBelowIcon } from './AddRowBelowIcon';
|
|
5
|
+
export { AddColLeftIcon } from './AddColLeftIcon';
|
|
6
|
+
export { AddColRightIcon } from './AddColRightIcon';
|
|
@@ -180,6 +180,32 @@ const InsertButtonHover = () => css`
|
|
|
180
180
|
}
|
|
181
181
|
`;
|
|
182
182
|
|
|
183
|
+
export const dragInsertButtonWrapper = (props: ThemeProps) => css`
|
|
184
|
+
.${ClassName.DRAG_CONTROLS_INSERT_BUTTON_INNER} {
|
|
185
|
+
position: absolute;
|
|
186
|
+
z-index: ${akEditorUnitZIndex + 10};
|
|
187
|
+
bottom: -5px;
|
|
188
|
+
left: 3px;
|
|
189
|
+
}
|
|
190
|
+
.${ClassName.DRAG_CONTROLS_INSERT_BUTTON} {
|
|
191
|
+
${Button(`
|
|
192
|
+
background: ${token('elevation.surface.overlay', 'white')};
|
|
193
|
+
color: ${token('color.icon', N300)};
|
|
194
|
+
border: 1px solid ${token(
|
|
195
|
+
'color.background.accent.gray.subtler',
|
|
196
|
+
'#C1C7D0',
|
|
197
|
+
)};
|
|
198
|
+
border-radius: 50%;
|
|
199
|
+
`)}
|
|
200
|
+
}
|
|
201
|
+
.${ClassName.DRAG_CONTROLS_INSERT_BUTTON}:hover {
|
|
202
|
+
background: ${token('color.background.brand.bold', B300)};
|
|
203
|
+
border: 1px solid ${token('color.background.brand.bold', B300)};
|
|
204
|
+
color: ${token('color.icon.inverse', 'white')};
|
|
205
|
+
cursor: pointer;
|
|
206
|
+
}
|
|
207
|
+
`;
|
|
208
|
+
|
|
183
209
|
export const insertColumnButtonWrapper = (props: ThemeProps) => css`
|
|
184
210
|
${InsertButton()}
|
|
185
211
|
${InsertButtonHover()}
|
|
@@ -388,7 +414,7 @@ export const floatingColumnControls = (props: ThemeProps) => {
|
|
|
388
414
|
}
|
|
389
415
|
}
|
|
390
416
|
|
|
391
|
-
.${ClassName.
|
|
417
|
+
.${ClassName.DRAG_COLUMN_CONTROLS} {
|
|
392
418
|
box-sizing: border-box;
|
|
393
419
|
|
|
394
420
|
.${ClassName.COLUMN_CONTROLS_INNER} {
|
|
@@ -40,10 +40,6 @@ export const isRowControlsButton = (node: HTMLElement | null): boolean =>
|
|
|
40
40
|
containsClassName(node, ClassName.ROW_CONTROLS_BUTTON) ||
|
|
41
41
|
containsClassName(node, ClassName.NUMBERED_COLUMN_BUTTON);
|
|
42
42
|
|
|
43
|
-
export const isRowDragControlsButton = (node: HTMLElement | null) =>
|
|
44
|
-
containsClassName(node, ClassName.ROW_CONTROLS_WITH_DRAG) ||
|
|
45
|
-
closestElement(node, `.${ClassName.ROW_CONTROLS_WITH_DRAG}`);
|
|
46
|
-
|
|
47
43
|
export const isResizeHandleDecoration = (node: HTMLElement | null): boolean =>
|
|
48
44
|
containsClassName(node, ClassName.RESIZE_HANDLE_DECORATION);
|
|
49
45
|
|
|
@@ -55,6 +51,17 @@ export const isTableContainerOrWrapper = (node: HTMLElement | null): boolean =>
|
|
|
55
51
|
containsClassName(node, ClassName.TABLE_CONTAINER) ||
|
|
56
52
|
containsClassName(node, ClassName.TABLE_NODE_WRAPPER);
|
|
57
53
|
|
|
54
|
+
/** drag-and-drop classes */
|
|
55
|
+
export const isRowDragControlsButton = (node: HTMLElement | null) =>
|
|
56
|
+
containsClassName(node, ClassName.DRAG_ROW_CONTROLS) ||
|
|
57
|
+
closestElement(node, `.${ClassName.DRAG_ROW_CONTROLS}`);
|
|
58
|
+
|
|
59
|
+
export const isDragRowFloatingInsertDot = (node: HTMLElement | null) =>
|
|
60
|
+
containsClassName(node, ClassName.DRAG_ROW_FLOATING_INSERT_DOT_WRAPPER);
|
|
61
|
+
|
|
62
|
+
export const isDragColumnFloatingInsertDot = (node: HTMLElement | null) =>
|
|
63
|
+
containsClassName(node, ClassName.DRAG_COLUMN_FLOATING_INSERT_DOT_WRAPPER);
|
|
64
|
+
|
|
58
65
|
/*
|
|
59
66
|
* This function returns which side of a given element the mouse cursor is,
|
|
60
67
|
* using as a base the half of the width by default, for example:
|
|
@@ -1,13 +1,47 @@
|
|
|
1
|
+
import { TableSortOrder as SortOrder } from '@atlaskit/custom-steps';
|
|
2
|
+
import {
|
|
3
|
+
addColumnAfter,
|
|
4
|
+
addColumnBefore,
|
|
5
|
+
addRowAfter,
|
|
6
|
+
addRowBefore,
|
|
7
|
+
backspace,
|
|
8
|
+
tooltip,
|
|
9
|
+
} from '@atlaskit/editor-common/keymaps';
|
|
1
10
|
import type {
|
|
2
11
|
Command,
|
|
3
12
|
CommandDispatch,
|
|
4
13
|
DropdownOptionT,
|
|
14
|
+
GetEditorContainerWidth,
|
|
15
|
+
IconProps,
|
|
5
16
|
} from '@atlaskit/editor-common/types';
|
|
6
17
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
7
|
-
import type { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
18
|
+
import type { Rect, TableMap } from '@atlaskit/editor-tables/table-map';
|
|
19
|
+
import ArrowDownIcon from '@atlaskit/icon/glyph/arrow-down';
|
|
20
|
+
import ArrowLeftIcon from '@atlaskit/icon/glyph/arrow-left';
|
|
21
|
+
import ArrowRightIcon from '@atlaskit/icon/glyph/arrow-right';
|
|
22
|
+
import ArrowUpIcon from '@atlaskit/icon/glyph/arrow-up';
|
|
23
|
+
import CrossCircleIcon from '@atlaskit/icon/glyph/cross-circle';
|
|
24
|
+
import EditorLayoutThreeEqualIcon from '@atlaskit/icon/glyph/editor/layout-three-equal';
|
|
25
|
+
import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
|
|
26
|
+
import HipchatChevronDoubleDownIcon from '@atlaskit/icon/glyph/hipchat/chevron-double-down';
|
|
27
|
+
import HipchatChevronDoubleUpIcon from '@atlaskit/icon/glyph/hipchat/chevron-double-up';
|
|
8
28
|
|
|
29
|
+
import {
|
|
30
|
+
clearMultipleCells,
|
|
31
|
+
insertColumn,
|
|
32
|
+
insertRow,
|
|
33
|
+
sortByColumn,
|
|
34
|
+
} from '../commands';
|
|
35
|
+
import { deleteColumnsCommand } from '../commands/delete';
|
|
9
36
|
import { moveSource } from '../pm-plugins/drag-and-drop/commands';
|
|
37
|
+
import { deleteRows } from '../transforms';
|
|
10
38
|
import type { TableDirection } from '../types';
|
|
39
|
+
import {
|
|
40
|
+
AddColLeftIcon,
|
|
41
|
+
AddColRightIcon,
|
|
42
|
+
AddRowAboveIcon,
|
|
43
|
+
AddRowBelowIcon,
|
|
44
|
+
} from '../ui/icons';
|
|
11
45
|
|
|
12
46
|
const canDecrease = (index?: number, min: number = 0) =>
|
|
13
47
|
index !== undefined && index > min;
|
|
@@ -16,39 +50,148 @@ const canIncrease = (index?: number, max: number = 0) =>
|
|
|
16
50
|
|
|
17
51
|
export interface DragMenuConfig extends DropdownOptionT<Command> {
|
|
18
52
|
id: string;
|
|
53
|
+
icon?: React.ComponentType<IconProps>;
|
|
54
|
+
keymap?: string;
|
|
19
55
|
}
|
|
20
56
|
|
|
21
57
|
export const getDragMenuConfig = (
|
|
22
58
|
direction: TableDirection,
|
|
59
|
+
getEditorContainerWidth: GetEditorContainerWidth,
|
|
23
60
|
tableMap?: TableMap,
|
|
24
61
|
index?: number,
|
|
62
|
+
targetCellPosition?: number,
|
|
63
|
+
selectionRect?: Rect,
|
|
25
64
|
): DragMenuConfig[] => {
|
|
65
|
+
const addOptions =
|
|
66
|
+
direction === 'row'
|
|
67
|
+
? [
|
|
68
|
+
{
|
|
69
|
+
label: 'above',
|
|
70
|
+
offset: 0,
|
|
71
|
+
icon: AddRowAboveIcon,
|
|
72
|
+
keymap: addRowBefore,
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
label: 'below',
|
|
76
|
+
offset: 1,
|
|
77
|
+
icon: AddRowBelowIcon,
|
|
78
|
+
keymap: addRowAfter,
|
|
79
|
+
},
|
|
80
|
+
]
|
|
81
|
+
: [
|
|
82
|
+
{
|
|
83
|
+
label: 'left',
|
|
84
|
+
offset: 0,
|
|
85
|
+
icon: AddColLeftIcon,
|
|
86
|
+
keymap: addColumnBefore,
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
label: 'right',
|
|
90
|
+
offset: 1,
|
|
91
|
+
icon: AddColRightIcon,
|
|
92
|
+
keymap: addColumnAfter,
|
|
93
|
+
},
|
|
94
|
+
];
|
|
26
95
|
const moveOptions =
|
|
27
96
|
direction === 'row'
|
|
28
97
|
? [
|
|
29
|
-
{ label: 'up', offset: -1, canMove: canDecrease },
|
|
98
|
+
{ label: 'up', offset: -1, canMove: canDecrease, icon: ArrowUpIcon },
|
|
30
99
|
{
|
|
31
100
|
label: 'down',
|
|
32
101
|
offset: 1,
|
|
33
102
|
canMove: (index?: number) =>
|
|
34
103
|
canIncrease(index, (tableMap?.height ?? 0) - 1),
|
|
104
|
+
icon: ArrowDownIcon,
|
|
35
105
|
},
|
|
36
106
|
]
|
|
37
107
|
: [
|
|
38
|
-
{
|
|
108
|
+
{
|
|
109
|
+
label: 'left',
|
|
110
|
+
offset: -1,
|
|
111
|
+
canMove: canDecrease,
|
|
112
|
+
icon: ArrowLeftIcon,
|
|
113
|
+
},
|
|
39
114
|
{
|
|
40
115
|
label: 'right',
|
|
41
116
|
offset: 1,
|
|
42
117
|
canMove: (index?: number) =>
|
|
43
118
|
canIncrease(index, (tableMap?.width ?? 0) - 1),
|
|
119
|
+
icon: ArrowRightIcon,
|
|
44
120
|
},
|
|
45
121
|
];
|
|
46
122
|
|
|
123
|
+
const sortOptions =
|
|
124
|
+
direction === 'column'
|
|
125
|
+
? [
|
|
126
|
+
{
|
|
127
|
+
label: 'increasing',
|
|
128
|
+
order: SortOrder.ASC,
|
|
129
|
+
icon: HipchatChevronDoubleUpIcon,
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
label: 'decreasing',
|
|
133
|
+
order: SortOrder.DESC,
|
|
134
|
+
icon: HipchatChevronDoubleDownIcon,
|
|
135
|
+
},
|
|
136
|
+
]
|
|
137
|
+
: [];
|
|
47
138
|
return [
|
|
48
|
-
...
|
|
139
|
+
...addOptions.map(({ label, offset, icon, keymap }) => ({
|
|
140
|
+
id: `add_${direction}_${label}`,
|
|
141
|
+
title: `Add ${direction} ${label}`,
|
|
142
|
+
icon,
|
|
143
|
+
onClick: (state: EditorState, dispatch?: CommandDispatch) => {
|
|
144
|
+
if (direction === 'row') {
|
|
145
|
+
insertRow(index! + offset, true)(state, dispatch);
|
|
146
|
+
} else {
|
|
147
|
+
insertColumn(getEditorContainerWidth)(index! + offset)(
|
|
148
|
+
state,
|
|
149
|
+
dispatch,
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
return true;
|
|
153
|
+
},
|
|
154
|
+
keymap: keymap && tooltip(keymap),
|
|
155
|
+
})),
|
|
156
|
+
direction === 'column'
|
|
157
|
+
? {
|
|
158
|
+
id: 'distribute_columns',
|
|
159
|
+
title: 'Distribute columns',
|
|
160
|
+
disabled: true,
|
|
161
|
+
onClick: () => {
|
|
162
|
+
return false;
|
|
163
|
+
},
|
|
164
|
+
icon: EditorLayoutThreeEqualIcon,
|
|
165
|
+
}
|
|
166
|
+
: undefined,
|
|
167
|
+
{
|
|
168
|
+
id: 'clear_cells',
|
|
169
|
+
title: 'Clear cells',
|
|
170
|
+
onClick: (state: EditorState, dispatch?: CommandDispatch) => {
|
|
171
|
+
clearMultipleCells(targetCellPosition)(state, dispatch);
|
|
172
|
+
return true;
|
|
173
|
+
},
|
|
174
|
+
icon: CrossCircleIcon,
|
|
175
|
+
keymap: tooltip(backspace),
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
id: `delete_${direction}`,
|
|
179
|
+
title: `Delete ${direction}`,
|
|
180
|
+
onClick: (state: EditorState, dispatch?: CommandDispatch) => {
|
|
181
|
+
if (direction === 'row') {
|
|
182
|
+
dispatch?.(deleteRows(selectionRect!, false)(state.tr));
|
|
183
|
+
} else {
|
|
184
|
+
deleteColumnsCommand(selectionRect!)(state, dispatch);
|
|
185
|
+
}
|
|
186
|
+
return true;
|
|
187
|
+
},
|
|
188
|
+
icon: RemoveIcon,
|
|
189
|
+
},
|
|
190
|
+
...moveOptions.map(({ label, offset, canMove, icon }) => ({
|
|
49
191
|
id: `move_${direction}_${label}`,
|
|
50
192
|
title: `Move ${direction} ${label}`,
|
|
51
193
|
disabled: !canMove(index),
|
|
194
|
+
icon,
|
|
52
195
|
onClick: (state: EditorState, dispatch?: CommandDispatch) => {
|
|
53
196
|
if (canMove(index)) {
|
|
54
197
|
moveSource(
|
|
@@ -61,5 +204,15 @@ export const getDragMenuConfig = (
|
|
|
61
204
|
return false;
|
|
62
205
|
},
|
|
63
206
|
})),
|
|
64
|
-
|
|
207
|
+
|
|
208
|
+
...sortOptions.map(({ label, order, icon }) => ({
|
|
209
|
+
id: `sort_column_${order}`,
|
|
210
|
+
title: `Sort ${label}`,
|
|
211
|
+
icon,
|
|
212
|
+
onClick: (state: EditorState, dispatch?: CommandDispatch) => {
|
|
213
|
+
sortByColumn(index!, order)(state, dispatch);
|
|
214
|
+
return true;
|
|
215
|
+
},
|
|
216
|
+
})),
|
|
217
|
+
].filter(Boolean) as DragMenuConfig[];
|
|
65
218
|
};
|
|
@@ -48,6 +48,8 @@ export {
|
|
|
48
48
|
isTableContainerOrWrapper,
|
|
49
49
|
isRowDragControlsButton,
|
|
50
50
|
isRowControlsButton,
|
|
51
|
+
isDragColumnFloatingInsertDot,
|
|
52
|
+
isDragRowFloatingInsertDot,
|
|
51
53
|
getColumnOrRowIndex,
|
|
52
54
|
getMousePositionHorizontalRelativeByElement,
|
|
53
55
|
getMousePositionVerticalRelativeByElement,
|
package/tsconfig.app.json
CHANGED