@atlaskit/editor-plugin-table 5.3.14 → 5.3.16
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 +14 -0
- package/dist/cjs/plugins/table/event-handlers.js +4 -3
- package/dist/cjs/plugins/table/index.js +2 -1
- package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/plugin.js +1 -0
- package/dist/cjs/plugins/table/types.js +5 -3
- package/dist/cjs/plugins/table/ui/FloatingDragMenu/DragMenu.js +49 -11
- package/dist/cjs/plugins/table/ui/FloatingDragMenu/index.js +5 -2
- package/dist/cjs/plugins/table/ui/FloatingInsertButton/index.js +5 -0
- package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +3 -11
- package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/index.js +2 -2
- package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/index.js +1 -1
- package/dist/cjs/plugins/table/ui/TableFloatingControls/CornerControls/ClassicCornerControls.js +114 -0
- package/dist/cjs/plugins/table/ui/TableFloatingControls/CornerControls/DragCornerControls.js +60 -0
- package/dist/cjs/plugins/table/ui/TableFloatingControls/CornerControls/index.js +11 -112
- package/dist/cjs/plugins/table/ui/TableFloatingControls/CornerControls/types.js +5 -0
- package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +1 -7
- package/dist/cjs/plugins/table/ui/TableFloatingControls/index.js +7 -2
- 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/messages.js +5 -0
- package/dist/cjs/plugins/table/ui/ui-styles.js +28 -25
- package/dist/cjs/plugins/table/utils/dom.js +16 -7
- package/dist/cjs/plugins/table/utils/drag-menu.js +122 -10
- package/dist/cjs/plugins/table/utils/index.js +12 -6
- package/dist/es2019/plugins/table/event-handlers.js +5 -4
- package/dist/es2019/plugins/table/index.js +2 -1
- package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/plugin.js +2 -1
- package/dist/es2019/plugins/table/types.js +5 -3
- package/dist/es2019/plugins/table/ui/FloatingDragMenu/DragMenu.js +52 -8
- package/dist/es2019/plugins/table/ui/FloatingDragMenu/index.js +5 -2
- package/dist/es2019/plugins/table/ui/FloatingInsertButton/index.js +5 -0
- package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +3 -11
- package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/index.js +2 -2
- package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/index.js +1 -1
- package/dist/es2019/plugins/table/ui/TableFloatingControls/CornerControls/ClassicCornerControls.js +93 -0
- package/dist/es2019/plugins/table/ui/TableFloatingControls/CornerControls/DragCornerControls.js +61 -0
- package/dist/es2019/plugins/table/ui/TableFloatingControls/CornerControls/index.js +2 -99
- package/dist/es2019/plugins/table/ui/TableFloatingControls/CornerControls/types.js +1 -0
- package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +1 -7
- package/dist/es2019/plugins/table/ui/TableFloatingControls/index.js +8 -3
- package/dist/es2019/plugins/table/ui/common-styles.js +8 -6
- 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/messages.js +5 -0
- package/dist/es2019/plugins/table/ui/ui-styles.js +44 -3
- package/dist/es2019/plugins/table/utils/dom.js +13 -6
- 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 +5 -4
- package/dist/esm/plugins/table/index.js +2 -1
- package/dist/esm/plugins/table/pm-plugins/drag-and-drop/plugin.js +2 -1
- package/dist/esm/plugins/table/types.js +5 -3
- package/dist/esm/plugins/table/ui/FloatingDragMenu/DragMenu.js +46 -8
- package/dist/esm/plugins/table/ui/FloatingDragMenu/index.js +5 -2
- package/dist/esm/plugins/table/ui/FloatingInsertButton/index.js +5 -0
- package/dist/esm/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +3 -11
- package/dist/esm/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/index.js +2 -2
- package/dist/esm/plugins/table/ui/TableFloatingColumnControls/index.js +1 -1
- package/dist/esm/plugins/table/ui/TableFloatingControls/CornerControls/ClassicCornerControls.js +104 -0
- package/dist/esm/plugins/table/ui/TableFloatingControls/CornerControls/DragCornerControls.js +50 -0
- package/dist/esm/plugins/table/ui/TableFloatingControls/CornerControls/index.js +2 -110
- package/dist/esm/plugins/table/ui/TableFloatingControls/CornerControls/types.js +1 -0
- package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +1 -7
- package/dist/esm/plugins/table/ui/TableFloatingControls/index.js +8 -3
- 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/messages.js +5 -0
- package/dist/esm/plugins/table/ui/ui-styles.js +27 -24
- package/dist/esm/plugins/table/utils/dom.js +15 -6
- 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 +5 -3
- 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/TableFloatingControls/CornerControls/ClassicCornerControls.d.ts +6 -0
- package/dist/types/plugins/table/ui/TableFloatingControls/CornerControls/DragCornerControls.d.ts +6 -0
- package/dist/types/plugins/table/ui/TableFloatingControls/CornerControls/index.d.ts +2 -16
- package/dist/types/plugins/table/ui/TableFloatingControls/CornerControls/types.d.ts +11 -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/messages.d.ts +5 -0
- package/dist/types/plugins/table/ui/ui-styles.d.ts +1 -0
- package/dist/types/plugins/table/utils/dom.d.ts +3 -2
- 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 +5 -3
- 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/TableFloatingControls/CornerControls/ClassicCornerControls.d.ts +6 -0
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/CornerControls/DragCornerControls.d.ts +6 -0
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/CornerControls/index.d.ts +2 -16
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/CornerControls/types.d.ts +11 -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/messages.d.ts +5 -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 +3 -2
- 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 -2
- package/src/plugins/table/event-handlers.ts +7 -2
- package/src/plugins/table/index.tsx +1 -0
- package/src/plugins/table/pm-plugins/drag-and-drop/plugin.ts +7 -1
- package/src/plugins/table/types.ts +7 -4
- package/src/plugins/table/ui/FloatingDragMenu/DragMenu.tsx +73 -6
- package/src/plugins/table/ui/FloatingDragMenu/index.tsx +5 -0
- package/src/plugins/table/ui/FloatingInsertButton/index.tsx +8 -0
- package/src/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.tsx +5 -7
- package/src/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/index.tsx +2 -2
- package/src/plugins/table/ui/TableFloatingColumnControls/index.tsx +1 -1
- package/src/plugins/table/ui/TableFloatingControls/CornerControls/ClassicCornerControls.tsx +107 -0
- package/src/plugins/table/ui/TableFloatingControls/CornerControls/DragCornerControls.tsx +66 -0
- package/src/plugins/table/ui/TableFloatingControls/CornerControls/index.tsx +2 -125
- package/src/plugins/table/ui/TableFloatingControls/CornerControls/types.ts +12 -0
- package/src/plugins/table/ui/TableFloatingControls/RowControls/DragControls.tsx +3 -3
- package/src/plugins/table/ui/TableFloatingControls/index.tsx +22 -14
- package/src/plugins/table/ui/common-styles.ts +8 -5
- 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/messages.ts +6 -0
- package/src/plugins/table/ui/ui-styles.ts +45 -3
- package/src/plugins/table/utils/dom.ts +16 -4
- package/src/plugins/table/utils/drag-menu.ts +158 -5
- package/src/plugins/table/utils/index.ts +2 -1
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export const AddRowAboveIcon = () => /*#__PURE__*/React.createElement("svg", {
|
|
3
|
+
width: "24",
|
|
4
|
+
height: "24",
|
|
5
|
+
viewBox: "0 0 24 24",
|
|
6
|
+
fill: "none",
|
|
7
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
8
|
+
}, /*#__PURE__*/React.createElement("rect", {
|
|
9
|
+
width: "24",
|
|
10
|
+
height: "24",
|
|
11
|
+
fill: "var(--ds-border-inverse, #FFFFFF)",
|
|
12
|
+
fillOpacity: "0.01"
|
|
13
|
+
}), /*#__PURE__*/React.createElement("mask", {
|
|
14
|
+
id: "path-1-inside-1_896_17822",
|
|
15
|
+
fill: "var(--ds-border-inverse, #FFFFFF)"
|
|
16
|
+
}, /*#__PURE__*/React.createElement("rect", {
|
|
17
|
+
x: "6",
|
|
18
|
+
y: "12",
|
|
19
|
+
width: "12",
|
|
20
|
+
height: "8",
|
|
21
|
+
rx: "0.5"
|
|
22
|
+
})), /*#__PURE__*/React.createElement("rect", {
|
|
23
|
+
x: "6",
|
|
24
|
+
y: "12",
|
|
25
|
+
width: "12",
|
|
26
|
+
height: "8",
|
|
27
|
+
rx: "0.5",
|
|
28
|
+
stroke: "currentColor",
|
|
29
|
+
strokeWidth: "4",
|
|
30
|
+
mask: "url(#path-1-inside-1_896_17822)"
|
|
31
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
32
|
+
fillRule: "evenodd",
|
|
33
|
+
clipRule: "evenodd",
|
|
34
|
+
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",
|
|
35
|
+
fill: "currentColor"
|
|
36
|
+
}));
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export const AddRowBelowIcon = () => /*#__PURE__*/React.createElement("svg", {
|
|
3
|
+
width: "24",
|
|
4
|
+
height: "24",
|
|
5
|
+
viewBox: "0 0 24 24",
|
|
6
|
+
fill: "none",
|
|
7
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
8
|
+
}, /*#__PURE__*/React.createElement("mask", {
|
|
9
|
+
id: "path-1-inside-1_920_47112",
|
|
10
|
+
fill: "var(--ds-border-inverse, #FFFFFF)"
|
|
11
|
+
}, /*#__PURE__*/React.createElement("rect", {
|
|
12
|
+
x: "6",
|
|
13
|
+
y: "4",
|
|
14
|
+
width: "12",
|
|
15
|
+
height: "8",
|
|
16
|
+
rx: "0.5"
|
|
17
|
+
})), /*#__PURE__*/React.createElement("rect", {
|
|
18
|
+
x: "6",
|
|
19
|
+
y: "4",
|
|
20
|
+
width: "12",
|
|
21
|
+
height: "8",
|
|
22
|
+
rx: "0.5",
|
|
23
|
+
stroke: "currentColor",
|
|
24
|
+
strokeWidth: "4",
|
|
25
|
+
mask: "url(#path-1-inside-1_920_47112)"
|
|
26
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
27
|
+
fillRule: "evenodd",
|
|
28
|
+
clipRule: "evenodd",
|
|
29
|
+
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",
|
|
30
|
+
fill: "currentColor"
|
|
31
|
+
}));
|
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
export { DragHandleIcon } from './DragHandleIcon';
|
|
2
|
-
export { DragInMotionIcon } from './DragInMotionIcon';
|
|
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';
|
|
@@ -59,5 +59,10 @@ export default defineMessages({
|
|
|
59
59
|
id: 'fabric.editor.tables.adjustColumn',
|
|
60
60
|
defaultMessage: 'Adjust column',
|
|
61
61
|
description: 'Tooltip displayed on table column resize handle'
|
|
62
|
+
},
|
|
63
|
+
cornerControl: {
|
|
64
|
+
id: 'fabric.editor.cornerControl',
|
|
65
|
+
defaultMessage: 'Highlight table',
|
|
66
|
+
description: 'A button on the upper left corner of the table that shows up when the table is in focus. Clicking on it will select the entire table.'
|
|
62
67
|
}
|
|
63
68
|
});
|
|
@@ -136,6 +136,7 @@ export const dragInsertButtonWrapper = props => css`
|
|
|
136
136
|
bottom: -5px;
|
|
137
137
|
left: 3px;
|
|
138
138
|
}
|
|
139
|
+
|
|
139
140
|
.${ClassName.DRAG_CONTROLS_INSERT_BUTTON} {
|
|
140
141
|
${Button(`
|
|
141
142
|
background: ${"var(--ds-surface-overlay, white)"};
|
|
@@ -144,6 +145,7 @@ export const dragInsertButtonWrapper = props => css`
|
|
|
144
145
|
border-radius: 50%;
|
|
145
146
|
`)}
|
|
146
147
|
}
|
|
148
|
+
|
|
147
149
|
.${ClassName.DRAG_CONTROLS_INSERT_BUTTON}:hover {
|
|
148
150
|
background: ${`var(--ds-background-brand-bold, ${B300})`};
|
|
149
151
|
border: 1px solid ${`var(--ds-background-brand-bold, ${B300})`};
|
|
@@ -151,6 +153,45 @@ export const dragInsertButtonWrapper = props => css`
|
|
|
151
153
|
cursor: pointer;
|
|
152
154
|
}
|
|
153
155
|
`;
|
|
156
|
+
export const dragCornerControlButton = props => css`
|
|
157
|
+
.${ClassName.DRAG_CORNER_BUTTON} {
|
|
158
|
+
width: 12px;
|
|
159
|
+
height: 12px;
|
|
160
|
+
display: flex;
|
|
161
|
+
justify-content: center;
|
|
162
|
+
align-items: center;
|
|
163
|
+
position: absolute;
|
|
164
|
+
top: ${"var(--ds-space-negative-075, -6px)"};
|
|
165
|
+
left: ${"var(--ds-space-075, 6px)"};
|
|
166
|
+
background-color: ${"var(--ds-surface, #FFF)"};
|
|
167
|
+
border-radius: 50%;
|
|
168
|
+
border: none;
|
|
169
|
+
padding: 0;
|
|
170
|
+
outline: none;
|
|
171
|
+
z-index: ${akEditorUnitZIndex * 99};
|
|
172
|
+
|
|
173
|
+
&.active .${ClassName.DRAG_CORNER_BUTTON_INNER} {
|
|
174
|
+
background-color: ${"var(--ds-border-selected, #0C66E4)"};
|
|
175
|
+
border-color: ${"var(--ds-border-selected, #0C66E4)"};
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
&:hover {
|
|
179
|
+
cursor: pointer;
|
|
180
|
+
|
|
181
|
+
.${ClassName.DRAG_CORNER_BUTTON_INNER} {
|
|
182
|
+
border-color: ${"var(--ds-border-selected, #0C66E4)"};
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.${ClassName.DRAG_CORNER_BUTTON_INNER} {
|
|
188
|
+
border: 1px solid
|
|
189
|
+
${"var(--ds-background-accent-gray-subtler, #DCDFE4)"};
|
|
190
|
+
border-radius: 50%;
|
|
191
|
+
width: 6px;
|
|
192
|
+
height: 6px;
|
|
193
|
+
}
|
|
194
|
+
`;
|
|
154
195
|
export const insertColumnButtonWrapper = props => css`
|
|
155
196
|
${InsertButton()}
|
|
156
197
|
${InsertButtonHover()}
|
|
@@ -310,12 +351,12 @@ const getFloatingDotOverrides = props => {
|
|
|
310
351
|
};
|
|
311
352
|
export const floatingColumnControls = props => {
|
|
312
353
|
return css`
|
|
313
|
-
.${ClassName.
|
|
354
|
+
.${ClassName.DRAG_COLUMN_DROP_TARGET_CONTROLS} {
|
|
314
355
|
box-sizing: border-box;
|
|
315
356
|
position: absolute;
|
|
316
357
|
top: 0;
|
|
317
358
|
|
|
318
|
-
.${ClassName.
|
|
359
|
+
.${ClassName.DRAG_COLUMN_CONTROLS_INNER} {
|
|
319
360
|
display: flex;
|
|
320
361
|
flex-direction: row;
|
|
321
362
|
}
|
|
@@ -324,7 +365,7 @@ export const floatingColumnControls = props => {
|
|
|
324
365
|
.${ClassName.DRAG_COLUMN_CONTROLS} {
|
|
325
366
|
box-sizing: border-box;
|
|
326
367
|
|
|
327
|
-
.${ClassName.
|
|
368
|
+
.${ClassName.DRAG_COLUMN_CONTROLS_INNER} {
|
|
328
369
|
display: grid;
|
|
329
370
|
justify-items: center;
|
|
330
371
|
}
|
|
@@ -15,9 +15,10 @@ export const isTableControlsButton = node => containsClassName(node, ClassName.C
|
|
|
15
15
|
export const isTableContainerOrWrapper = node => containsClassName(node, ClassName.TABLE_CONTAINER) || containsClassName(node, ClassName.TABLE_NODE_WRAPPER);
|
|
16
16
|
|
|
17
17
|
/** drag-and-drop classes */
|
|
18
|
-
export const
|
|
18
|
+
export const isDragRowControlsButton = node => containsClassName(node, ClassName.DRAG_ROW_CONTROLS) || closestElement(node, `.${ClassName.DRAG_ROW_CONTROLS}`);
|
|
19
19
|
export const isDragRowFloatingInsertDot = node => containsClassName(node, ClassName.DRAG_ROW_FLOATING_INSERT_DOT_WRAPPER);
|
|
20
20
|
export const isDragColumnFloatingInsertDot = node => containsClassName(node, ClassName.DRAG_COLUMN_FLOATING_INSERT_DOT_WRAPPER);
|
|
21
|
+
export const isDragCornerButton = node => containsClassName(node, ClassName.DRAG_CORNER_BUTTON) || containsClassName(node, ClassName.DRAG_CORNER_BUTTON_INNER);
|
|
21
22
|
|
|
22
23
|
/*
|
|
23
24
|
* This function returns which side of a given element the mouse cursor is,
|
|
@@ -73,14 +74,20 @@ export const isDragColumnFloatingInsertDot = node => containsClassName(node, Cla
|
|
|
73
74
|
* the same is valid to the right side.
|
|
74
75
|
*/
|
|
75
76
|
|
|
76
|
-
export const getMousePositionHorizontalRelativeByElement = (mouseEvent, elementContentRects, gapInPixels) => {
|
|
77
|
+
export const getMousePositionHorizontalRelativeByElement = (mouseEvent, elementContentRects, gapInPixels, isDragAndDropEnabled) => {
|
|
77
78
|
const element = mouseEvent.target;
|
|
78
79
|
if (element instanceof HTMLElement) {
|
|
79
|
-
var _closestCell$id, _elementContentRects$, _elementContentRects$2;
|
|
80
80
|
let width, x;
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
if (isDragAndDropEnabled) {
|
|
82
|
+
// mouse event fires for new overlapping column controls, so the cell can not get detected. Get width
|
|
83
|
+
// directly from element that will be .pm-table-drag-columns-floating-insert-dot-wrapper
|
|
84
|
+
width = element.clientWidth;
|
|
85
|
+
} else {
|
|
86
|
+
var _closestCell$id, _elementContentRects$, _elementContentRects$2;
|
|
87
|
+
const closestCell = element.closest(SELECTOR_TABLE_LEAFS);
|
|
88
|
+
const id = (_closestCell$id = closestCell === null || closestCell === void 0 ? void 0 : closestCell.id) !== null && _closestCell$id !== void 0 ? _closestCell$id : '';
|
|
89
|
+
width = (_elementContentRects$ = elementContentRects === null || elementContentRects === void 0 ? void 0 : (_elementContentRects$2 = elementContentRects[id]) === null || _elementContentRects$2 === void 0 ? void 0 : _elementContentRects$2.width) !== null && _elementContentRects$ !== void 0 ? _elementContentRects$ : 0;
|
|
90
|
+
}
|
|
84
91
|
x = mouseEvent.offsetX;
|
|
85
92
|
if (width <= 0) {
|
|
86
93
|
return null;
|
|
@@ -1,38 +1,136 @@
|
|
|
1
|
+
import { TableSortOrder as SortOrder } from '@atlaskit/custom-steps';
|
|
2
|
+
import { addColumnAfter, addColumnBefore, addRowAfter, addRowBefore, backspace, tooltip } from '@atlaskit/editor-common/keymaps';
|
|
3
|
+
import ArrowDownIcon from '@atlaskit/icon/glyph/arrow-down';
|
|
4
|
+
import ArrowLeftIcon from '@atlaskit/icon/glyph/arrow-left';
|
|
5
|
+
import ArrowRightIcon from '@atlaskit/icon/glyph/arrow-right';
|
|
6
|
+
import ArrowUpIcon from '@atlaskit/icon/glyph/arrow-up';
|
|
7
|
+
import CrossCircleIcon from '@atlaskit/icon/glyph/cross-circle';
|
|
8
|
+
import EditorLayoutThreeEqualIcon from '@atlaskit/icon/glyph/editor/layout-three-equal';
|
|
9
|
+
import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
|
|
10
|
+
import HipchatChevronDoubleDownIcon from '@atlaskit/icon/glyph/hipchat/chevron-double-down';
|
|
11
|
+
import HipchatChevronDoubleUpIcon from '@atlaskit/icon/glyph/hipchat/chevron-double-up';
|
|
12
|
+
import { clearMultipleCells, insertColumn, insertRow, sortByColumn } from '../commands';
|
|
13
|
+
import { deleteColumnsCommand } from '../commands/delete';
|
|
1
14
|
import { moveSource } from '../pm-plugins/drag-and-drop/commands';
|
|
15
|
+
import { deleteRows } from '../transforms';
|
|
16
|
+
import { AddColLeftIcon, AddColRightIcon, AddRowAboveIcon, AddRowBelowIcon } from '../ui/icons';
|
|
2
17
|
const canDecrease = (index, min = 0) => index !== undefined && index > min;
|
|
3
18
|
const canIncrease = (index, max = 0) => index !== undefined && index < max;
|
|
4
|
-
export const getDragMenuConfig = (direction, tableMap, index) => {
|
|
19
|
+
export const getDragMenuConfig = (direction, getEditorContainerWidth, tableMap, index, targetCellPosition, selectionRect) => {
|
|
20
|
+
const addOptions = direction === 'row' ? [{
|
|
21
|
+
label: 'above',
|
|
22
|
+
offset: 0,
|
|
23
|
+
icon: AddRowAboveIcon,
|
|
24
|
+
keymap: addRowBefore
|
|
25
|
+
}, {
|
|
26
|
+
label: 'below',
|
|
27
|
+
offset: 1,
|
|
28
|
+
icon: AddRowBelowIcon,
|
|
29
|
+
keymap: addRowAfter
|
|
30
|
+
}] : [{
|
|
31
|
+
label: 'left',
|
|
32
|
+
offset: 0,
|
|
33
|
+
icon: AddColLeftIcon,
|
|
34
|
+
keymap: addColumnBefore
|
|
35
|
+
}, {
|
|
36
|
+
label: 'right',
|
|
37
|
+
offset: 1,
|
|
38
|
+
icon: AddColRightIcon,
|
|
39
|
+
keymap: addColumnAfter
|
|
40
|
+
}];
|
|
5
41
|
const moveOptions = direction === 'row' ? [{
|
|
6
42
|
label: 'up',
|
|
7
43
|
offset: -1,
|
|
8
|
-
canMove: canDecrease
|
|
44
|
+
canMove: canDecrease,
|
|
45
|
+
icon: ArrowUpIcon
|
|
9
46
|
}, {
|
|
10
47
|
label: 'down',
|
|
11
48
|
offset: 1,
|
|
12
49
|
canMove: index => {
|
|
13
50
|
var _tableMap$height;
|
|
14
51
|
return canIncrease(index, ((_tableMap$height = tableMap === null || tableMap === void 0 ? void 0 : tableMap.height) !== null && _tableMap$height !== void 0 ? _tableMap$height : 0) - 1);
|
|
15
|
-
}
|
|
52
|
+
},
|
|
53
|
+
icon: ArrowDownIcon
|
|
16
54
|
}] : [{
|
|
17
55
|
label: 'left',
|
|
18
56
|
offset: -1,
|
|
19
|
-
canMove: canDecrease
|
|
57
|
+
canMove: canDecrease,
|
|
58
|
+
icon: ArrowLeftIcon
|
|
20
59
|
}, {
|
|
21
60
|
label: 'right',
|
|
22
61
|
offset: 1,
|
|
23
62
|
canMove: index => {
|
|
24
63
|
var _tableMap$width;
|
|
25
64
|
return canIncrease(index, ((_tableMap$width = tableMap === null || tableMap === void 0 ? void 0 : tableMap.width) !== null && _tableMap$width !== void 0 ? _tableMap$width : 0) - 1);
|
|
26
|
-
}
|
|
65
|
+
},
|
|
66
|
+
icon: ArrowRightIcon
|
|
27
67
|
}];
|
|
28
|
-
|
|
68
|
+
const sortOptions = direction === 'column' ? [{
|
|
69
|
+
label: 'increasing',
|
|
70
|
+
order: SortOrder.ASC,
|
|
71
|
+
icon: HipchatChevronDoubleUpIcon
|
|
72
|
+
}, {
|
|
73
|
+
label: 'decreasing',
|
|
74
|
+
order: SortOrder.DESC,
|
|
75
|
+
icon: HipchatChevronDoubleDownIcon
|
|
76
|
+
}] : [];
|
|
77
|
+
return [...addOptions.map(({
|
|
29
78
|
label,
|
|
30
79
|
offset,
|
|
31
|
-
|
|
80
|
+
icon,
|
|
81
|
+
keymap
|
|
82
|
+
}) => ({
|
|
83
|
+
id: `add_${direction}_${label}`,
|
|
84
|
+
title: `Add ${direction} ${label}`,
|
|
85
|
+
icon,
|
|
86
|
+
onClick: (state, dispatch) => {
|
|
87
|
+
if (direction === 'row') {
|
|
88
|
+
insertRow(index + offset, true)(state, dispatch);
|
|
89
|
+
} else {
|
|
90
|
+
insertColumn(getEditorContainerWidth)(index + offset)(state, dispatch);
|
|
91
|
+
}
|
|
92
|
+
return true;
|
|
93
|
+
},
|
|
94
|
+
keymap: keymap && tooltip(keymap)
|
|
95
|
+
})), direction === 'column' ? {
|
|
96
|
+
id: 'distribute_columns',
|
|
97
|
+
title: 'Distribute columns',
|
|
98
|
+
disabled: true,
|
|
99
|
+
onClick: () => {
|
|
100
|
+
return false;
|
|
101
|
+
},
|
|
102
|
+
icon: EditorLayoutThreeEqualIcon
|
|
103
|
+
} : undefined, {
|
|
104
|
+
id: 'clear_cells',
|
|
105
|
+
title: 'Clear cells',
|
|
106
|
+
onClick: (state, dispatch) => {
|
|
107
|
+
clearMultipleCells(targetCellPosition)(state, dispatch);
|
|
108
|
+
return true;
|
|
109
|
+
},
|
|
110
|
+
icon: CrossCircleIcon,
|
|
111
|
+
keymap: tooltip(backspace)
|
|
112
|
+
}, {
|
|
113
|
+
id: `delete_${direction}`,
|
|
114
|
+
title: `Delete ${direction}`,
|
|
115
|
+
onClick: (state, dispatch) => {
|
|
116
|
+
if (direction === 'row') {
|
|
117
|
+
dispatch === null || dispatch === void 0 ? void 0 : dispatch(deleteRows(selectionRect, false)(state.tr));
|
|
118
|
+
} else {
|
|
119
|
+
deleteColumnsCommand(selectionRect)(state, dispatch);
|
|
120
|
+
}
|
|
121
|
+
return true;
|
|
122
|
+
},
|
|
123
|
+
icon: RemoveIcon
|
|
124
|
+
}, ...moveOptions.map(({
|
|
125
|
+
label,
|
|
126
|
+
offset,
|
|
127
|
+
canMove,
|
|
128
|
+
icon
|
|
32
129
|
}) => ({
|
|
33
130
|
id: `move_${direction}_${label}`,
|
|
34
131
|
title: `Move ${direction} ${label}`,
|
|
35
132
|
disabled: !canMove(index),
|
|
133
|
+
icon,
|
|
36
134
|
onClick: (state, dispatch) => {
|
|
37
135
|
if (canMove(index)) {
|
|
38
136
|
moveSource(`table-${direction}`, index, index + offset)(state, dispatch);
|
|
@@ -40,5 +138,17 @@ export const getDragMenuConfig = (direction, tableMap, index) => {
|
|
|
40
138
|
}
|
|
41
139
|
return false;
|
|
42
140
|
}
|
|
43
|
-
}))
|
|
141
|
+
})), ...sortOptions.map(({
|
|
142
|
+
label,
|
|
143
|
+
order,
|
|
144
|
+
icon
|
|
145
|
+
}) => ({
|
|
146
|
+
id: `sort_column_${order}`,
|
|
147
|
+
title: `Sort ${label}`,
|
|
148
|
+
icon,
|
|
149
|
+
onClick: (state, dispatch) => {
|
|
150
|
+
sortByColumn(index, order)(state, dispatch);
|
|
151
|
+
return true;
|
|
152
|
+
}
|
|
153
|
+
}))].filter(Boolean);
|
|
44
154
|
};
|
|
@@ -2,7 +2,7 @@ export { getSelectedColumnIndexes, getSelectedRowIndexes, normalizeSelection, is
|
|
|
2
2
|
export { findControlsHoverDecoration, createControlsHoverDecoration, createColumnControlsDecoration, createColumnSelectedDecoration, createCellHoverDecoration, updateDecorations, createResizeHandleDecoration, createColumnInsertLine, createColumnLineResize, createRowInsertLine } from './decoration';
|
|
3
3
|
export { isIsolating, containsHeaderColumn, containsHeaderRow, checkIfHeaderColumnEnabled, checkIfHeaderRowEnabled, checkIfNumberColumnEnabled, isLayoutSupported, getTableWidth, tablesHaveDifferentColumnWidths, tablesHaveDifferentNoOfColumns, isTableNested, anyChildCellMergedAcrossRow, supportedHeaderRow } from './nodes';
|
|
4
4
|
export { unwrapContentFromTable, removeTableFromFirstChild, removeTableFromLastChild, transformSliceToRemoveOpenTable, transformSliceToCorrectEmptyTableCells, transformSliceToFixHardBreakProblemOnCopyFromCell } from './paste';
|
|
5
|
-
export { isCell, isCornerButton, isInsertRowButton, isColumnControlsDecorations, isTableControlsButton, isTableContainerOrWrapper,
|
|
5
|
+
export { isCell, isCornerButton, isInsertRowButton, isColumnControlsDecorations, isTableControlsButton, isTableContainerOrWrapper, isRowControlsButton, isDragRowControlsButton, isDragColumnFloatingInsertDot, isDragRowFloatingInsertDot, isDragCornerButton, getColumnOrRowIndex, getMousePositionHorizontalRelativeByElement, getMousePositionVerticalRelativeByElement, updateResizeHandles, isResizeHandleDecoration, hasResizeHandler } from './dom';
|
|
6
6
|
export { getColumnsWidths, isColumnDeleteButtonVisible, getColumnDeleteButtonParams, getColumnClassNames } from './column-controls';
|
|
7
7
|
export { getRowHeights, isRowDeleteButtonVisible, getRowDeleteButtonParams, getRowsParams, getRowClassNames, copyPreviousRow } from './row-controls';
|
|
8
8
|
export { getSelectedTableInfo, getSelectedCellInfo } from './analytics';
|
|
@@ -10,7 +10,7 @@ import { getPluginState } from './pm-plugins/plugin-factory';
|
|
|
10
10
|
import { getPluginState as getResizePluginState } from './pm-plugins/table-resizing/plugin-factory';
|
|
11
11
|
import { deleteColumns, deleteRows } from './transforms';
|
|
12
12
|
import { RESIZE_HANDLE_AREA_DECORATION_GAP } from './types';
|
|
13
|
-
import { getColumnOrRowIndex, getMousePositionHorizontalRelativeByElement, getMousePositionVerticalRelativeByElement, getSelectedCellInfo, hasResizeHandler, isCell, isColumnControlsDecorations, isCornerButton, isDragColumnFloatingInsertDot, isDragRowFloatingInsertDot, isInsertRowButton, isResizeHandleDecoration, isRowControlsButton, isTableContainerOrWrapper, isTableControlsButton } from './utils';
|
|
13
|
+
import { getColumnOrRowIndex, getMousePositionHorizontalRelativeByElement, getMousePositionVerticalRelativeByElement, getSelectedCellInfo, hasResizeHandler, isCell, isColumnControlsDecorations, isCornerButton, isDragColumnFloatingInsertDot, isDragCornerButton, isDragRowFloatingInsertDot, isInsertRowButton, isResizeHandleDecoration, isRowControlsButton, isTableContainerOrWrapper, isTableControlsButton } from './utils';
|
|
14
14
|
import { getAllowAddColumnCustomStep } from './utils/get-allow-add-column-custom-step';
|
|
15
15
|
var isFocusingCalendar = function isFocusingCalendar(event) {
|
|
16
16
|
return event instanceof FocusEvent && event.relatedTarget instanceof HTMLElement && event.relatedTarget.getAttribute('aria-label') === 'calendar';
|
|
@@ -133,7 +133,7 @@ export var handleMouseOver = function handleMouseOver(view, mouseEvent) {
|
|
|
133
133
|
// Ignore any `mousedown` `event` from control and numbered column buttons
|
|
134
134
|
// PM end up changing selection during shift selection if not prevented
|
|
135
135
|
export var handleMouseDown = function handleMouseDown(_, event) {
|
|
136
|
-
var isControl = !!(event.target && event.target instanceof HTMLElement && (isTableContainerOrWrapper(event.target) || isColumnControlsDecorations(event.target) || isRowControlsButton(event.target)));
|
|
136
|
+
var isControl = !!(event.target && event.target instanceof HTMLElement && (isTableContainerOrWrapper(event.target) || isColumnControlsDecorations(event.target) || isRowControlsButton(event.target) || isDragCornerButton(event.target)));
|
|
137
137
|
if (isControl) {
|
|
138
138
|
event.preventDefault();
|
|
139
139
|
}
|
|
@@ -190,12 +190,13 @@ export var handleMouseMove = function handleMouseMove(view, event, elementConten
|
|
|
190
190
|
var state = view.state,
|
|
191
191
|
dispatch = view.dispatch;
|
|
192
192
|
var _getPluginState3 = getPluginState(state),
|
|
193
|
-
insertColumnButtonIndex = _getPluginState3.insertColumnButtonIndex
|
|
193
|
+
insertColumnButtonIndex = _getPluginState3.insertColumnButtonIndex,
|
|
194
|
+
isDragAndDropEnabled = _getPluginState3.isDragAndDropEnabled;
|
|
194
195
|
var _getColumnOrRowIndex9 = getColumnOrRowIndex(element),
|
|
195
196
|
_getColumnOrRowIndex10 = _slicedToArray(_getColumnOrRowIndex9, 2),
|
|
196
197
|
startIndex = _getColumnOrRowIndex10[0],
|
|
197
198
|
endIndex = _getColumnOrRowIndex10[1];
|
|
198
|
-
var positionColumn = getMousePositionHorizontalRelativeByElement(event, elementContentRects) === 'right' ? endIndex : startIndex;
|
|
199
|
+
var positionColumn = getMousePositionHorizontalRelativeByElement(event, elementContentRects, undefined, isDragAndDropEnabled) === 'right' ? endIndex : startIndex;
|
|
199
200
|
if (positionColumn !== insertColumnButtonIndex) {
|
|
200
201
|
return showInsertColumnButton(positionColumn)(state, dispatch);
|
|
201
202
|
}
|
|
@@ -330,7 +330,8 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
330
330
|
targetCellPosition: targetCellPosition,
|
|
331
331
|
direction: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.dragMenuDirection,
|
|
332
332
|
index: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.dragMenuIndex,
|
|
333
|
-
isOpen: !!(dragAndDropState !== null && dragAndDropState !== void 0 && dragAndDropState.isDragMenuOpen) && !isResizing
|
|
333
|
+
isOpen: !!(dragAndDropState !== null && dragAndDropState !== void 0 && dragAndDropState.isDragMenuOpen) && !isResizing,
|
|
334
|
+
getEditorContainerWidth: defaultGetEditorContainerWidth
|
|
334
335
|
}), allowControls && !isDragAndDropEnabled && !isResizing && /*#__PURE__*/React.createElement(FloatingDeleteButton, {
|
|
335
336
|
editorView: editorView,
|
|
336
337
|
selection: editorView.state.selection,
|
|
@@ -7,7 +7,7 @@ import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/adapter/el
|
|
|
7
7
|
import { hasMergedCellsInColumn, hasMergedCellsInRow } from '../../utils/merged-cells';
|
|
8
8
|
import { getPluginState as getTablePluginState } from '../plugin-factory';
|
|
9
9
|
import { DragAndDropActionType } from './actions';
|
|
10
|
-
import { clearDropTarget, moveSource, setDropTarget } from './commands';
|
|
10
|
+
import { clearDropTarget, moveSource, setDropTarget, toggleDragMenu } from './commands';
|
|
11
11
|
import { DropTargetType } from './consts';
|
|
12
12
|
import { createPluginState, getPluginState } from './plugin-factory';
|
|
13
13
|
import { pluginKey } from './plugin-key';
|
|
@@ -86,6 +86,7 @@ export var createPlugin = function createPlugin(dispatch, eventDispatcher) {
|
|
|
86
86
|
autoScroller.start({
|
|
87
87
|
input: location.current.input
|
|
88
88
|
});
|
|
89
|
+
toggleDragMenu(false)(editorView.state, editorView.dispatch);
|
|
89
90
|
},
|
|
90
91
|
onDrag: function onDrag(event) {
|
|
91
92
|
autoScroller.updateInput({
|
|
@@ -52,9 +52,6 @@ export var TableCssClassName = _objectSpread(_objectSpread({}, TableSharedCssCla
|
|
|
52
52
|
COLUMN_CONTROLS: "".concat(tablePrefixSelector, "-column-controls"),
|
|
53
53
|
COLUMN_CONTROLS_DECORATIONS: "".concat(tablePrefixSelector, "-column-controls-decoration"),
|
|
54
54
|
COLUMN_SELECTED: "".concat(tablePrefixSelector, "-column__selected"),
|
|
55
|
-
COLUMN_CONTROLS_WRAPPER: "".concat(tablePrefixSelector, "-col-controls-wrapper"),
|
|
56
|
-
COLUMN_DROP_TARGET_CONTROLS: "".concat(tablePrefixSelector, "-col-drop-target-controls"),
|
|
57
|
-
COLUMN_CONTROLS_INNER: "".concat(tablePrefixSelector, "-col-controls__inner"),
|
|
58
55
|
ROW_CONTROLS_WRAPPER: "".concat(tablePrefixSelector, "-row-controls-wrapper"),
|
|
59
56
|
ROW_CONTROLS: "".concat(tablePrefixSelector, "-row-controls"),
|
|
60
57
|
ROW_CONTROLS_INNER: "".concat(tablePrefixSelector, "-row-controls__inner"),
|
|
@@ -89,7 +86,12 @@ export var TableCssClassName = _objectSpread(_objectSpread({}, TableSharedCssCla
|
|
|
89
86
|
DRAG_COLUMN_CONTROLS: "".concat(tablePrefixSelector, "-drag-column-controls"),
|
|
90
87
|
DRAG_COLUMN_FLOATING_INSERT_DOT_WRAPPER: "".concat(tablePrefixSelector, "-drag-columns-floating-insert-dot-wrapper"),
|
|
91
88
|
DRAG_COLUMN_FLOATING_INSERT_DOT: "".concat(tablePrefixSelector, "-drag-columns-floating-insert-dot"),
|
|
89
|
+
DRAG_COLUMN_CONTROLS_WRAPPER: "".concat(tablePrefixSelector, "-col-controls-wrapper"),
|
|
90
|
+
DRAG_COLUMN_DROP_TARGET_CONTROLS: "".concat(tablePrefixSelector, "-col-drop-target-controls"),
|
|
91
|
+
DRAG_COLUMN_CONTROLS_INNER: "".concat(tablePrefixSelector, "-col-controls__inner"),
|
|
92
92
|
DRAG_HANDLE_BUTTON_CONTAINER: "".concat(tablePrefixSelector, "-drag-handle-button-container"),
|
|
93
|
+
DRAG_CORNER_BUTTON: "".concat(tablePrefixSelector, "-drag-corner-button"),
|
|
94
|
+
DRAG_CORNER_BUTTON_INNER: "".concat(tablePrefixSelector, "-drag-corner-button-inner"),
|
|
93
95
|
/** Other classes */
|
|
94
96
|
NUMBERED_COLUMN: "".concat(tablePrefixSelector, "-numbered-column"),
|
|
95
97
|
NUMBERED_COLUMN_BUTTON: "".concat(tablePrefixSelector, "-numbered-column__button"),
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { jsx } from '@emotion/react';
|
|
2
3
|
import { ArrowKeyNavigationType, DropdownMenu } from '@atlaskit/editor-common/ui-menu';
|
|
4
|
+
import { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
|
|
3
5
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
6
|
+
import { findCellRectClosestToPos, getSelectionRect, isSelectionType } from '@atlaskit/editor-tables/utils';
|
|
7
|
+
import { clearHoverSelection, hoverColumns, hoverRows } from '../../commands';
|
|
4
8
|
import { toggleDragMenu } from '../../pm-plugins/drag-and-drop/commands';
|
|
9
|
+
import { getSelectedColumnIndexes, getSelectedRowIndexes } from '../../utils';
|
|
5
10
|
import { getDragMenuConfig } from '../../utils/drag-menu';
|
|
6
11
|
import { dragMenuDropdownWidth } from '../consts';
|
|
7
12
|
var convertToDropdownItems = function convertToDropdownItems(dragMenuConfig) {
|
|
@@ -14,7 +19,18 @@ var convertToDropdownItems = function convertToDropdownItems(dragMenuConfig) {
|
|
|
14
19
|
value: {
|
|
15
20
|
name: item.id
|
|
16
21
|
},
|
|
17
|
-
isDisabled: item.disabled
|
|
22
|
+
isDisabled: item.disabled,
|
|
23
|
+
elemBefore: item.icon ? jsx("div", {
|
|
24
|
+
style: {
|
|
25
|
+
marginRight: "var(--ds-space-negative-075, -6px)",
|
|
26
|
+
display: 'flex'
|
|
27
|
+
}
|
|
28
|
+
}, jsx(item.icon, {
|
|
29
|
+
label: item.title
|
|
30
|
+
})) : undefined,
|
|
31
|
+
elemAfter: item.keymap ? jsx("div", {
|
|
32
|
+
css: shortcutStyle
|
|
33
|
+
}, item.keymap) : undefined
|
|
18
34
|
});
|
|
19
35
|
item.onClick && (menuCallback[item.id] = item.onClick);
|
|
20
36
|
});
|
|
@@ -32,9 +48,15 @@ export var DragMenu = function DragMenu(_ref) {
|
|
|
32
48
|
tableNode = _ref.tableNode,
|
|
33
49
|
mountPoint = _ref.mountPoint,
|
|
34
50
|
boundariesElement = _ref.boundariesElement,
|
|
35
|
-
scrollableElement = _ref.scrollableElement
|
|
51
|
+
scrollableElement = _ref.scrollableElement,
|
|
52
|
+
targetCellPosition = _ref.targetCellPosition,
|
|
53
|
+
getEditorContainerWidth = _ref.getEditorContainerWidth;
|
|
36
54
|
var tableMap = tableNode ? TableMap.get(tableNode) : undefined;
|
|
37
|
-
var
|
|
55
|
+
var state = editorView.state,
|
|
56
|
+
dispatch = editorView.dispatch;
|
|
57
|
+
var selection = state.selection;
|
|
58
|
+
var selectionRect = isSelectionType(selection, 'cell') ? getSelectionRect(selection) : findCellRectClosestToPos(selection.$from);
|
|
59
|
+
var dragMenuConfig = getDragMenuConfig(direction, getEditorContainerWidth, tableMap, index, targetCellPosition, selectionRect);
|
|
38
60
|
var _convertToDropdownIte = convertToDropdownItems(dragMenuConfig),
|
|
39
61
|
menuItems = _convertToDropdownIte.menuItems,
|
|
40
62
|
menuCallback = _convertToDropdownIte.menuCallback;
|
|
@@ -43,16 +65,30 @@ export var DragMenu = function DragMenu(_ref) {
|
|
|
43
65
|
dispatch = editorView.dispatch;
|
|
44
66
|
toggleDragMenu(false)(state, dispatch);
|
|
45
67
|
};
|
|
46
|
-
var
|
|
68
|
+
var handleMenuItemActivated = function handleMenuItemActivated(_ref2) {
|
|
47
69
|
var _menuCallback$item$va;
|
|
48
70
|
var item = _ref2.item;
|
|
49
|
-
(_menuCallback$item$va = menuCallback[item.value.name]) === null || _menuCallback$item$va === void 0 || _menuCallback$item$va.call(menuCallback,
|
|
71
|
+
(_menuCallback$item$va = menuCallback[item.value.name]) === null || _menuCallback$item$va === void 0 || _menuCallback$item$va.call(menuCallback, state, dispatch);
|
|
50
72
|
closeMenu();
|
|
51
73
|
};
|
|
74
|
+
var handleItemMouseEnter = function handleItemMouseEnter(_ref3) {
|
|
75
|
+
var _item$value$name;
|
|
76
|
+
var item = _ref3.item;
|
|
77
|
+
if (!selectionRect || !((_item$value$name = item.value.name) !== null && _item$value$name !== void 0 && _item$value$name.startsWith('delete'))) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
(item.value.name === 'delete_column' ? hoverColumns(getSelectedColumnIndexes(selectionRect), true) : hoverRows(getSelectedRowIndexes(selectionRect), true))(state, dispatch);
|
|
81
|
+
};
|
|
82
|
+
var handleItemMouseLeave = function handleItemMouseLeave(_ref4) {
|
|
83
|
+
var item = _ref4.item;
|
|
84
|
+
if (['sort_column_asc', 'sort_column_desc', 'delete_column', 'delete_row'].indexOf(item.value.name) > -1) {
|
|
85
|
+
clearHoverSelection()(state, dispatch);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
52
88
|
if (!menuItems) {
|
|
53
89
|
return null;
|
|
54
90
|
}
|
|
55
|
-
return
|
|
91
|
+
return jsx(DropdownMenu, {
|
|
56
92
|
mountTo: mountPoint
|
|
57
93
|
//This needs be removed when the a11y is completely handled
|
|
58
94
|
//Disabling key navigation now as it works only partially
|
|
@@ -66,7 +102,9 @@ export var DragMenu = function DragMenu(_ref) {
|
|
|
66
102
|
}],
|
|
67
103
|
isOpen: isOpen,
|
|
68
104
|
onOpenChange: closeMenu,
|
|
69
|
-
onItemActivated:
|
|
105
|
+
onItemActivated: handleMenuItemActivated,
|
|
106
|
+
onMouseEnter: handleItemMouseEnter,
|
|
107
|
+
onMouseLeave: handleItemMouseLeave,
|
|
70
108
|
fitWidth: dragMenuDropdownWidth,
|
|
71
109
|
boundariesElement: boundariesElement
|
|
72
110
|
});
|
|
@@ -15,7 +15,8 @@ var FloatingDragMenu = function FloatingDragMenu(_ref) {
|
|
|
15
15
|
tableNode = _ref.tableNode,
|
|
16
16
|
direction = _ref.direction,
|
|
17
17
|
index = _ref.index,
|
|
18
|
-
targetCellPosition = _ref.targetCellPosition
|
|
18
|
+
targetCellPosition = _ref.targetCellPosition,
|
|
19
|
+
getEditorContainerWidth = _ref.getEditorContainerWidth;
|
|
19
20
|
if (!isOpen || !targetCellPosition || editorView.state.doc.nodeSize <= targetCellPosition) {
|
|
20
21
|
return null;
|
|
21
22
|
}
|
|
@@ -48,7 +49,9 @@ var FloatingDragMenu = function FloatingDragMenu(_ref) {
|
|
|
48
49
|
boundariesElement: boundariesElement,
|
|
49
50
|
tableNode: tableNode,
|
|
50
51
|
direction: direction,
|
|
51
|
-
index: index
|
|
52
|
+
index: index,
|
|
53
|
+
targetCellPosition: targetCellPosition,
|
|
54
|
+
getEditorContainerWidth: getEditorContainerWidth
|
|
52
55
|
}));
|
|
53
56
|
};
|
|
54
57
|
FloatingDragMenu.displayName = 'FloatingDragMenu';
|
|
@@ -49,6 +49,11 @@ export var FloatingInsertButton = /*#__PURE__*/function (_React$Component) {
|
|
|
49
49
|
isHeaderRowEnabled = _this$props.isHeaderRowEnabled,
|
|
50
50
|
isDragAndDropEnabled = _this$props.isDragAndDropEnabled,
|
|
51
51
|
dispatchAnalyticsEvent = _this$props.dispatchAnalyticsEvent;
|
|
52
|
+
|
|
53
|
+
// TODO: temporarily disable insert button for first column and row https://atlassian.slack.com/archives/C05U8HRQM50/p1698363744682219?thread_ts=1698209039.104909&cid=C05U8HRQM50
|
|
54
|
+
if (isDragAndDropEnabled && (insertColumnButtonIndex === 0 || insertRowButtonIndex === 0)) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
52
57
|
var type = typeof insertColumnButtonIndex !== 'undefined' ? 'column' : typeof insertRowButtonIndex !== 'undefined' ? 'row' : null;
|
|
53
58
|
if (!tableNode || !tableRef || !type) {
|
|
54
59
|
return null;
|
|
@@ -71,7 +71,7 @@ export var ColumnControls = function ColumnControls(_ref) {
|
|
|
71
71
|
return /*#__PURE__*/React.createElement("div", {
|
|
72
72
|
className: ClassName.DRAG_COLUMN_CONTROLS
|
|
73
73
|
}, /*#__PURE__*/React.createElement("div", {
|
|
74
|
-
className: ClassName.
|
|
74
|
+
className: ClassName.DRAG_COLUMN_CONTROLS_INNER,
|
|
75
75
|
"data-testid": "table-floating-column-controls",
|
|
76
76
|
style: {
|
|
77
77
|
gridTemplateColumns: widths,
|
|
@@ -89,13 +89,7 @@ export var ColumnControls = function ColumnControls(_ref) {
|
|
|
89
89
|
className: ClassName.DRAG_COLUMN_FLOATING_INSERT_DOT_WRAPPER,
|
|
90
90
|
contentEditable: false,
|
|
91
91
|
key: index
|
|
92
|
-
},
|
|
93
|
-
style: {
|
|
94
|
-
left: '0px',
|
|
95
|
-
right: 'unset'
|
|
96
|
-
},
|
|
97
|
-
className: ClassName.DRAG_COLUMN_FLOATING_INSERT_DOT
|
|
98
|
-
}), /*#__PURE__*/React.createElement("div", {
|
|
92
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
99
93
|
className: ClassName.DRAG_COLUMN_FLOATING_INSERT_DOT,
|
|
100
94
|
style: columnParams.length - 1 === index ? {
|
|
101
95
|
right: '0'
|
|
@@ -104,12 +98,10 @@ export var ColumnControls = function ColumnControls(_ref) {
|
|
|
104
98
|
}), tableActive && !isResizing && !!hoveredCell && Number.isFinite(hoveredCell.colIndex) && /*#__PURE__*/React.createElement("div", {
|
|
105
99
|
style: {
|
|
106
100
|
gridColumn: gridColumnPosition,
|
|
107
|
-
zIndex: 99,
|
|
108
101
|
display: 'flex',
|
|
109
|
-
width: '100%',
|
|
110
102
|
justifyContent: 'center',
|
|
111
103
|
alignItems: 'center',
|
|
112
|
-
|
|
104
|
+
zIndex: 99
|
|
113
105
|
},
|
|
114
106
|
"data-column-control-index": hoveredCell.colIndex,
|
|
115
107
|
"data-testid": "table-floating-column-control"
|