@atlaskit/editor-plugin-table 5.7.5 → 5.7.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/dist/cjs/commands-with-analytics.js +29 -5
- package/dist/cjs/plugin.js +54 -52
- package/dist/cjs/pm-plugins/drag-and-drop/commands-with-analytics.js +49 -4
- package/dist/cjs/pm-plugins/keymap.js +13 -1
- package/dist/cjs/ui/FloatingInsertButton/index.js +1 -1
- package/dist/cjs/ui/common-styles.js +1 -1
- package/dist/cjs/utils/drag-menu.js +14 -7
- package/dist/es2019/commands-with-analytics.js +26 -1
- package/dist/es2019/plugin.js +6 -1
- package/dist/es2019/pm-plugins/drag-and-drop/commands-with-analytics.js +46 -2
- package/dist/es2019/pm-plugins/keymap.js +15 -3
- package/dist/es2019/ui/FloatingInsertButton/index.js +2 -2
- package/dist/es2019/ui/common-styles.js +3 -2
- package/dist/es2019/utils/drag-menu.js +15 -8
- package/dist/esm/commands-with-analytics.js +29 -5
- package/dist/esm/plugin.js +54 -52
- package/dist/esm/pm-plugins/drag-and-drop/commands-with-analytics.js +47 -2
- package/dist/esm/pm-plugins/keymap.js +15 -3
- package/dist/esm/ui/FloatingInsertButton/index.js +2 -2
- package/dist/esm/ui/common-styles.js +2 -2
- package/dist/esm/utils/drag-menu.js +15 -8
- package/dist/types/commands-with-analytics.d.ts +3 -2
- package/dist/types/pm-plugins/drag-and-drop/commands-with-analytics.d.ts +7 -5
- package/dist/types/pm-plugins/keymap.d.ts +1 -1
- package/dist/types-ts4.5/commands-with-analytics.d.ts +3 -2
- package/dist/types-ts4.5/pm-plugins/drag-and-drop/commands-with-analytics.d.ts +7 -5
- package/dist/types-ts4.5/pm-plugins/keymap.d.ts +1 -1
- package/package.json +6 -6
- package/src/__tests__/unit/ui/FloatingDragMenu.tsx +6 -6
- package/src/commands-with-analytics.ts +39 -2
- package/src/plugin.tsx +10 -2
- package/src/pm-plugins/drag-and-drop/commands-with-analytics.ts +85 -7
- package/src/pm-plugins/keymap.ts +52 -0
- package/src/ui/FloatingInsertButton/index.tsx +2 -4
- package/src/ui/common-styles.ts +2 -2
- package/src/utils/drag-menu.ts +13 -1
package/src/pm-plugins/keymap.ts
CHANGED
|
@@ -13,6 +13,12 @@ import {
|
|
|
13
13
|
addRowBefore,
|
|
14
14
|
backspace,
|
|
15
15
|
bindKeymapWithCommand,
|
|
16
|
+
deleteColumn,
|
|
17
|
+
deleteRow,
|
|
18
|
+
moveColumnLeft,
|
|
19
|
+
moveColumnRight,
|
|
20
|
+
moveRowDown,
|
|
21
|
+
moveRowUp,
|
|
16
22
|
nextCell,
|
|
17
23
|
previousCell,
|
|
18
24
|
toggleTable,
|
|
@@ -30,6 +36,7 @@ import {
|
|
|
30
36
|
} from '../commands';
|
|
31
37
|
import {
|
|
32
38
|
addRowAroundSelection,
|
|
39
|
+
deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut,
|
|
33
40
|
deleteTableIfSelectedWithAnalytics,
|
|
34
41
|
emptyMultipleCellsWithAnalytics,
|
|
35
42
|
} from '../commands-with-analytics';
|
|
@@ -37,6 +44,7 @@ import {
|
|
|
37
44
|
addColumnAfter as addColumnAfterCommand,
|
|
38
45
|
addColumnBefore as addColumnBeforeCommand,
|
|
39
46
|
} from '../commands/insert';
|
|
47
|
+
import { moveSourceWithAnalyticsViaShortcut } from '../pm-plugins/drag-and-drop/commands-with-analytics';
|
|
40
48
|
import { withEditorAnalyticsAPI } from '../utils/analytics';
|
|
41
49
|
|
|
42
50
|
const createTableWithAnalytics = (
|
|
@@ -53,6 +61,7 @@ const createTableWithAnalytics = (
|
|
|
53
61
|
export function keymapPlugin(
|
|
54
62
|
getEditorContainerWidth: GetEditorContainerWidth,
|
|
55
63
|
editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null,
|
|
64
|
+
dragAndDropEnabled?: boolean,
|
|
56
65
|
): SafePlugin {
|
|
57
66
|
const list = {};
|
|
58
67
|
|
|
@@ -110,6 +119,49 @@ export function keymapPlugin(
|
|
|
110
119
|
list,
|
|
111
120
|
);
|
|
112
121
|
|
|
122
|
+
if (dragAndDropEnabled) {
|
|
123
|
+
// Move row/column shortcuts
|
|
124
|
+
bindKeymapWithCommand(
|
|
125
|
+
moveRowDown.common!,
|
|
126
|
+
moveSourceWithAnalyticsViaShortcut(editorAnalyticsAPI)('table-row', 1),
|
|
127
|
+
list,
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
bindKeymapWithCommand(
|
|
131
|
+
moveRowUp.common!,
|
|
132
|
+
moveSourceWithAnalyticsViaShortcut(editorAnalyticsAPI)('table-row', -1),
|
|
133
|
+
list,
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
bindKeymapWithCommand(
|
|
137
|
+
moveColumnLeft.common!,
|
|
138
|
+
moveSourceWithAnalyticsViaShortcut(editorAnalyticsAPI)(
|
|
139
|
+
'table-column',
|
|
140
|
+
-1,
|
|
141
|
+
),
|
|
142
|
+
list,
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
bindKeymapWithCommand(
|
|
146
|
+
moveColumnRight.common!,
|
|
147
|
+
moveSourceWithAnalyticsViaShortcut(editorAnalyticsAPI)('table-column', 1),
|
|
148
|
+
list,
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
// Delete row/column shortcuts
|
|
152
|
+
bindKeymapWithCommand(
|
|
153
|
+
deleteColumn.common!,
|
|
154
|
+
deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut(editorAnalyticsAPI),
|
|
155
|
+
list,
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
bindKeymapWithCommand(
|
|
159
|
+
deleteRow.common!,
|
|
160
|
+
deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut(editorAnalyticsAPI),
|
|
161
|
+
list,
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
|
|
113
165
|
return keymap(list) as SafePlugin;
|
|
114
166
|
}
|
|
115
167
|
|
|
@@ -21,7 +21,7 @@ import { closestElement } from '@atlaskit/editor-common/utils';
|
|
|
21
21
|
import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
22
22
|
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
23
23
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
24
|
-
import {
|
|
24
|
+
import { akEditorTableCellOnStickyHeaderZIndex } from '@atlaskit/editor-shared-styles';
|
|
25
25
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
26
26
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
27
27
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
@@ -192,9 +192,7 @@ export class FloatingInsertButton extends React.Component<
|
|
|
192
192
|
// Only when inserting a column, otherwise set to undefined
|
|
193
193
|
// Need to set z-index in the Popup, set z-index in the <InsertButton /> will not work
|
|
194
194
|
const zIndex: number | undefined =
|
|
195
|
-
type === 'column'
|
|
196
|
-
? akEditorTableInsertButtonOnStickyHeaderZIndex
|
|
197
|
-
: undefined;
|
|
195
|
+
type === 'column' ? akEditorTableCellOnStickyHeaderZIndex : undefined;
|
|
198
196
|
|
|
199
197
|
return (
|
|
200
198
|
<Popup
|
package/src/ui/common-styles.ts
CHANGED
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
import type { FeatureFlags } from '@atlaskit/editor-common/types';
|
|
8
8
|
import { browser } from '@atlaskit/editor-common/utils';
|
|
9
9
|
import {
|
|
10
|
-
akEditorFloatingDialogZIndex,
|
|
11
10
|
akEditorSelectedNodeClassName,
|
|
12
11
|
akEditorSmallZIndex,
|
|
13
12
|
akEditorStickyHeaderZIndex,
|
|
@@ -1053,7 +1052,8 @@ export const tableStyles = (props: { featureFlags?: FeatureFlags }) => css`
|
|
|
1053
1052
|
|
|
1054
1053
|
.${ClassName.TABLE_STICKY} .${ClassName.DRAG_COLUMN_CONTROLS_WRAPPER} {
|
|
1055
1054
|
position: fixed;
|
|
1056
|
-
|
|
1055
|
+
/* higher zIndex than sticky header which is akEditorTableCellOnStickyHeaderZIndex - 5 */
|
|
1056
|
+
z-index: ${akEditorTableCellOnStickyHeaderZIndex - 4};
|
|
1057
1057
|
}
|
|
1058
1058
|
|
|
1059
1059
|
${tableWrapperStyles()}
|
package/src/utils/drag-menu.ts
CHANGED
|
@@ -7,6 +7,12 @@ import {
|
|
|
7
7
|
addRowAfter,
|
|
8
8
|
addRowBefore,
|
|
9
9
|
backspace,
|
|
10
|
+
deleteColumn,
|
|
11
|
+
deleteRow,
|
|
12
|
+
moveColumnLeft,
|
|
13
|
+
moveColumnRight,
|
|
14
|
+
moveRowDown,
|
|
15
|
+
moveRowUp,
|
|
10
16
|
tooltip,
|
|
11
17
|
} from '@atlaskit/editor-common/keymaps';
|
|
12
18
|
import type {
|
|
@@ -121,6 +127,7 @@ export const getDragMenuConfig = (
|
|
|
121
127
|
offset: -1,
|
|
122
128
|
canMove: (index?: number) => canDrag && canDecrease(index),
|
|
123
129
|
icon: ArrowUpIcon,
|
|
130
|
+
keymap: moveRowUp,
|
|
124
131
|
},
|
|
125
132
|
{
|
|
126
133
|
label: 'down',
|
|
@@ -128,6 +135,7 @@ export const getDragMenuConfig = (
|
|
|
128
135
|
canMove: (index?: number) =>
|
|
129
136
|
canDrag && canIncrease(index, (tableMap?.height ?? 0) - 1),
|
|
130
137
|
icon: ArrowDownIcon,
|
|
138
|
+
keymap: moveRowDown,
|
|
131
139
|
},
|
|
132
140
|
]
|
|
133
141
|
: [
|
|
@@ -136,6 +144,7 @@ export const getDragMenuConfig = (
|
|
|
136
144
|
offset: -1,
|
|
137
145
|
canMove: (index?: number) => canDrag && canDecrease(index),
|
|
138
146
|
icon: ArrowLeftIcon,
|
|
147
|
+
keymap: moveColumnLeft,
|
|
139
148
|
},
|
|
140
149
|
{
|
|
141
150
|
label: 'right',
|
|
@@ -143,6 +152,7 @@ export const getDragMenuConfig = (
|
|
|
143
152
|
canMove: (index?: number) =>
|
|
144
153
|
canDrag && canIncrease(index, (tableMap?.width ?? 0) - 1),
|
|
145
154
|
icon: ArrowRightIcon,
|
|
155
|
+
keymap: moveColumnRight,
|
|
146
156
|
},
|
|
147
157
|
];
|
|
148
158
|
|
|
@@ -229,8 +239,9 @@ export const getDragMenuConfig = (
|
|
|
229
239
|
return true;
|
|
230
240
|
},
|
|
231
241
|
icon: RemoveIcon,
|
|
242
|
+
keymap: direction === 'row' ? tooltip(deleteRow) : tooltip(deleteColumn),
|
|
232
243
|
},
|
|
233
|
-
...moveOptions.map(({ label, offset, canMove, icon }) => ({
|
|
244
|
+
...moveOptions.map(({ label, offset, canMove, icon, keymap }) => ({
|
|
234
245
|
id: `move_${direction}_${label}`,
|
|
235
246
|
title: `Move ${direction} ${label}`,
|
|
236
247
|
disabled: !canMove(index),
|
|
@@ -249,6 +260,7 @@ export const getDragMenuConfig = (
|
|
|
249
260
|
}
|
|
250
261
|
return false;
|
|
251
262
|
},
|
|
263
|
+
keymap: keymap && tooltip(keymap),
|
|
252
264
|
})),
|
|
253
265
|
|
|
254
266
|
...sortOptions.map(({ label, order, icon }) => ({
|