@atlaskit/editor-plugin-table 7.6.2 → 7.6.4
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/misc.js +3 -2
- package/dist/cjs/nodeviews/TableComponent.js +25 -11
- package/dist/cjs/nodeviews/TableComponentWithSharedState.js +87 -0
- package/dist/cjs/nodeviews/TableContainer.js +37 -21
- package/dist/cjs/nodeviews/TableResizer.js +40 -29
- package/dist/cjs/nodeviews/table.js +21 -1
- package/dist/cjs/plugin.js +25 -2
- package/dist/cjs/toolbar.js +5 -4
- package/dist/cjs/types.js +3 -0
- package/dist/cjs/ui/FloatingContextualMenu/ContextualMenu.js +16 -16
- package/dist/cjs/ui/FloatingDragMenu/DragMenu.js +3 -3
- package/dist/cjs/ui/FloatingDragMenu/DropdownMenu.js +21 -28
- package/dist/cjs/ui/TableFloatingColumnControls/ColumnControls/index.js +6 -2
- package/dist/cjs/ui/TableFloatingColumnControls/index.js +5 -2
- package/dist/cjs/ui/TableFloatingControls/CornerControls/DragCornerControls.js +48 -1
- package/dist/cjs/ui/TableFloatingControls/CornerControls/index.js +6 -0
- package/dist/cjs/ui/TableFloatingControls/FloatingControlsWithSelection.js +47 -0
- package/dist/cjs/ui/TableFloatingControls/RowControls/ClassicControls.js +3 -2
- package/dist/cjs/ui/TableFloatingControls/index.js +25 -3
- package/dist/cjs/ui/common-styles.js +11 -6
- package/dist/cjs/utils/guidelines.js +1 -1
- package/dist/es2019/commands/misc.js +6 -2
- package/dist/es2019/nodeviews/TableComponent.js +27 -12
- package/dist/es2019/nodeviews/TableComponentWithSharedState.js +83 -0
- package/dist/es2019/nodeviews/TableContainer.js +24 -6
- package/dist/es2019/nodeviews/TableResizer.js +27 -19
- package/dist/es2019/nodeviews/table.js +21 -1
- package/dist/es2019/plugin.js +26 -3
- package/dist/es2019/toolbar.js +5 -4
- package/dist/es2019/types.js +3 -0
- package/dist/es2019/ui/FloatingContextualMenu/ContextualMenu.js +16 -16
- package/dist/es2019/ui/FloatingDragMenu/DragMenu.js +3 -3
- package/dist/es2019/ui/FloatingDragMenu/DropdownMenu.js +20 -27
- package/dist/es2019/ui/TableFloatingColumnControls/ColumnControls/index.js +7 -2
- package/dist/es2019/ui/TableFloatingColumnControls/index.js +5 -2
- package/dist/es2019/ui/TableFloatingControls/CornerControls/DragCornerControls.js +55 -0
- package/dist/es2019/ui/TableFloatingControls/CornerControls/index.js +1 -1
- package/dist/es2019/ui/TableFloatingControls/FloatingControlsWithSelection.js +42 -0
- package/dist/es2019/ui/TableFloatingControls/RowControls/ClassicControls.js +3 -2
- package/dist/es2019/ui/TableFloatingControls/index.js +26 -4
- package/dist/es2019/ui/common-styles.js +589 -588
- package/dist/es2019/utils/guidelines.js +1 -1
- package/dist/esm/commands/misc.js +3 -2
- package/dist/esm/nodeviews/TableComponent.js +25 -11
- package/dist/esm/nodeviews/TableComponentWithSharedState.js +80 -0
- package/dist/esm/nodeviews/TableContainer.js +37 -21
- package/dist/esm/nodeviews/TableResizer.js +41 -30
- package/dist/esm/nodeviews/table.js +21 -1
- package/dist/esm/plugin.js +26 -3
- package/dist/esm/toolbar.js +5 -4
- package/dist/esm/types.js +3 -0
- package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +16 -16
- package/dist/esm/ui/FloatingDragMenu/DragMenu.js +3 -3
- package/dist/esm/ui/FloatingDragMenu/DropdownMenu.js +21 -28
- package/dist/esm/ui/TableFloatingColumnControls/ColumnControls/index.js +6 -2
- package/dist/esm/ui/TableFloatingColumnControls/index.js +5 -2
- package/dist/esm/ui/TableFloatingControls/CornerControls/DragCornerControls.js +47 -0
- package/dist/esm/ui/TableFloatingControls/CornerControls/index.js +1 -1
- package/dist/esm/ui/TableFloatingControls/FloatingControlsWithSelection.js +40 -0
- package/dist/esm/ui/TableFloatingControls/RowControls/ClassicControls.js +3 -2
- package/dist/esm/ui/TableFloatingControls/index.js +26 -4
- package/dist/esm/ui/common-styles.js +10 -5
- package/dist/esm/utils/guidelines.js +1 -1
- package/dist/types/commands/misc.d.ts +2 -1
- package/dist/types/nodeviews/TableComponent.d.ts +7 -2
- package/dist/types/nodeviews/TableComponentWithSharedState.d.ts +27 -0
- package/dist/types/nodeviews/TableContainer.d.ts +4 -2
- package/dist/types/nodeviews/TableResizer.d.ts +4 -1
- package/dist/types/nodeviews/types.d.ts +1 -0
- package/dist/types/plugin.d.ts +11 -7
- package/dist/types/types.d.ts +13 -4
- package/dist/types/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +113 -1
- package/dist/types/ui/TableFloatingColumnControls/index.d.ts +3 -2
- package/dist/types/ui/TableFloatingControls/CornerControls/DragCornerControls.d.ts +223 -0
- package/dist/types/ui/TableFloatingControls/CornerControls/index.d.ts +1 -1
- package/dist/types/ui/TableFloatingControls/FloatingControlsWithSelection.d.ts +20 -0
- package/dist/types/ui/TableFloatingControls/RowControls/ClassicControls.d.ts +2 -0
- package/dist/types/ui/TableFloatingControls/index.d.ts +113 -1
- package/dist/types/ui/common-styles.d.ts +3 -0
- package/dist/types-ts4.5/commands/misc.d.ts +2 -1
- package/dist/types-ts4.5/nodeviews/TableComponent.d.ts +7 -2
- package/dist/types-ts4.5/nodeviews/TableComponentWithSharedState.d.ts +27 -0
- package/dist/types-ts4.5/nodeviews/TableContainer.d.ts +4 -2
- package/dist/types-ts4.5/nodeviews/TableResizer.d.ts +4 -1
- package/dist/types-ts4.5/nodeviews/types.d.ts +1 -0
- package/dist/types-ts4.5/plugin.d.ts +11 -7
- package/dist/types-ts4.5/types.d.ts +13 -4
- package/dist/types-ts4.5/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +144 -1
- package/dist/types-ts4.5/ui/TableFloatingColumnControls/index.d.ts +3 -2
- package/dist/types-ts4.5/ui/TableFloatingControls/CornerControls/DragCornerControls.d.ts +285 -0
- package/dist/types-ts4.5/ui/TableFloatingControls/CornerControls/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/TableFloatingControls/FloatingControlsWithSelection.d.ts +20 -0
- package/dist/types-ts4.5/ui/TableFloatingControls/RowControls/ClassicControls.d.ts +2 -0
- package/dist/types-ts4.5/ui/TableFloatingControls/index.d.ts +144 -1
- package/dist/types-ts4.5/ui/common-styles.d.ts +3 -0
- package/package.json +6 -6
- package/src/commands/misc.ts +6 -3
- package/src/nodeviews/TableComponent.tsx +36 -7
- package/src/nodeviews/TableComponentWithSharedState.tsx +125 -0
- package/src/nodeviews/TableContainer.tsx +24 -3
- package/src/nodeviews/TableResizer.tsx +36 -21
- package/src/nodeviews/table.tsx +22 -1
- package/src/nodeviews/types.ts +1 -0
- package/src/plugin.tsx +47 -6
- package/src/toolbar.tsx +20 -19
- package/src/types.ts +33 -4
- package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +66 -112
- package/src/ui/FloatingDragMenu/DragMenu.tsx +3 -12
- package/src/ui/FloatingDragMenu/DropdownMenu.tsx +19 -28
- package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +10 -2
- package/src/ui/TableFloatingColumnControls/index.tsx +13 -1
- package/src/ui/TableFloatingControls/CornerControls/DragCornerControls.tsx +58 -0
- package/src/ui/TableFloatingControls/CornerControls/index.tsx +4 -1
- package/src/ui/TableFloatingControls/FloatingControlsWithSelection.tsx +68 -0
- package/src/ui/TableFloatingControls/RowControls/ClassicControls.tsx +4 -1
- package/src/ui/TableFloatingControls/index.tsx +42 -8
- package/src/ui/common-styles.ts +611 -610
- package/src/utils/guidelines.ts +5 -4
package/src/toolbar.tsx
CHANGED
|
@@ -51,7 +51,6 @@ import {
|
|
|
51
51
|
import DistributeColumnIcon from '@atlaskit/icon/glyph/editor/layout-three-equal';
|
|
52
52
|
import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
|
|
53
53
|
import TableOptionsIcon from '@atlaskit/icon/glyph/preferences';
|
|
54
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
55
54
|
|
|
56
55
|
import {
|
|
57
56
|
clearHoverSelection,
|
|
@@ -135,10 +134,7 @@ export const getToolbarMenuConfig = (
|
|
|
135
134
|
},
|
|
136
135
|
];
|
|
137
136
|
|
|
138
|
-
if (
|
|
139
|
-
state.isDragAndDropEnabled &&
|
|
140
|
-
getBooleanFF('platform.editor.table.new-cell-context-menu-styling')
|
|
141
|
-
) {
|
|
137
|
+
if (state.isDragAndDropEnabled) {
|
|
142
138
|
return {
|
|
143
139
|
id: 'editor.table.tableOptions',
|
|
144
140
|
type: 'dropdown',
|
|
@@ -454,8 +450,15 @@ export const getToolbarConfig =
|
|
|
454
450
|
const isWidthResizing = tableWidthState?.resizing;
|
|
455
451
|
|
|
456
452
|
const { isTableScalingEnabled, widthToWidest } = pluginState;
|
|
457
|
-
|
|
458
|
-
|
|
453
|
+
const currentTableNodeLocalId = tableObject?.node?.attrs?.localId ?? '';
|
|
454
|
+
|
|
455
|
+
if (
|
|
456
|
+
isTableScalingEnabled &&
|
|
457
|
+
isWidthResizing &&
|
|
458
|
+
widthToWidest &&
|
|
459
|
+
currentTableNodeLocalId &&
|
|
460
|
+
widthToWidest[currentTableNodeLocalId]
|
|
461
|
+
) {
|
|
459
462
|
const { stickyScrollbar } = getEditorFeatureFlags();
|
|
460
463
|
|
|
461
464
|
const nodeType = state.schema.nodes.table;
|
|
@@ -526,18 +529,16 @@ export const getToolbarConfig =
|
|
|
526
529
|
);
|
|
527
530
|
|
|
528
531
|
let columnSettingsItems;
|
|
529
|
-
columnSettingsItems =
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
)
|
|
540
|
-
: [];
|
|
532
|
+
columnSettingsItems = pluginState.isDragAndDropEnabled
|
|
533
|
+
? getColumnSettingItems(
|
|
534
|
+
state,
|
|
535
|
+
getEditorView(),
|
|
536
|
+
intl,
|
|
537
|
+
getEditorContainerWidth,
|
|
538
|
+
editorAnalyticsAPI,
|
|
539
|
+
isTableScalingEnabled,
|
|
540
|
+
)
|
|
541
|
+
: [];
|
|
541
542
|
const colorPicker = getColorPicker(state, menu, intl, editorAnalyticsAPI);
|
|
542
543
|
|
|
543
544
|
// Check if we need to show confirm dialog for delete button
|
package/src/types.ts
CHANGED
|
@@ -16,7 +16,7 @@ import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
|
16
16
|
import type { Rect } from '@atlaskit/editor-tables/table-map';
|
|
17
17
|
import type { Edge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge';
|
|
18
18
|
|
|
19
|
-
import type
|
|
19
|
+
import type { TablePlugin } from './plugin';
|
|
20
20
|
|
|
21
21
|
export const RESIZE_HANDLE_AREA_DECORATION_GAP = 30;
|
|
22
22
|
export type RowInsertPosition = 'TOP' | 'BOTTOM';
|
|
@@ -33,7 +33,33 @@ export interface InsertRowOptions {
|
|
|
33
33
|
moveCursorToInsertedRow: boolean;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
export type PluginInjectionAPI = ExtractInjectionAPI<
|
|
36
|
+
export type PluginInjectionAPI = ExtractInjectionAPI<TablePlugin>;
|
|
37
|
+
|
|
38
|
+
// override getPluginState but do not expose publicly as this type is experimental and will change
|
|
39
|
+
// in the future
|
|
40
|
+
export type TableSharedStateInternal = Pick<
|
|
41
|
+
TablePluginState,
|
|
42
|
+
| 'isFullWidthModeEnabled'
|
|
43
|
+
| 'wasFullWidthModeEnabled'
|
|
44
|
+
| 'isHeaderRowEnabled'
|
|
45
|
+
| 'isHeaderColumnEnabled'
|
|
46
|
+
| 'ordering'
|
|
47
|
+
| 'isInDanger'
|
|
48
|
+
| 'hoveredRows'
|
|
49
|
+
| 'hoveredCell'
|
|
50
|
+
| 'isTableHovered'
|
|
51
|
+
| 'tableNode'
|
|
52
|
+
| 'widthToWidest'
|
|
53
|
+
> & {
|
|
54
|
+
isResizing: boolean;
|
|
55
|
+
isTableResizing?: boolean;
|
|
56
|
+
isWholeTableInDanger?: boolean;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export type TableSharedState = Pick<
|
|
60
|
+
TablePluginState,
|
|
61
|
+
'isFullWidthModeEnabled' | 'wasFullWidthModeEnabled'
|
|
62
|
+
>;
|
|
37
63
|
|
|
38
64
|
export type InsertRowMethods =
|
|
39
65
|
| INPUT_METHOD.CONTEXT_MENU
|
|
@@ -96,6 +122,9 @@ export interface CellHoverMeta {
|
|
|
96
122
|
colIndex?: number;
|
|
97
123
|
rowIndex?: number;
|
|
98
124
|
}
|
|
125
|
+
export interface WidthToWidest {
|
|
126
|
+
[tableLocalId: string]: boolean;
|
|
127
|
+
}
|
|
99
128
|
|
|
100
129
|
export interface TablePluginState {
|
|
101
130
|
editorHasFocus?: boolean;
|
|
@@ -130,7 +159,7 @@ export interface TablePluginState {
|
|
|
130
159
|
// for table wrap/collapse
|
|
131
160
|
isTableCollapsed?: boolean; // is the current table already in an expand?
|
|
132
161
|
canCollapseTable?: boolean; // enabled/disabled state of collapse option
|
|
133
|
-
widthToWidest?:
|
|
162
|
+
widthToWidest?: WidthToWidest; // is the current table set to the widest width regarding view port
|
|
134
163
|
|
|
135
164
|
getIntl: () => IntlShape;
|
|
136
165
|
|
|
@@ -221,7 +250,7 @@ export type TablePluginAction =
|
|
|
221
250
|
| {
|
|
222
251
|
type: 'UPDATE_TABLE_WIDTH_TO_WIDEST';
|
|
223
252
|
data: {
|
|
224
|
-
widthToWidest:
|
|
253
|
+
widthToWidest: WidthToWidest | undefined;
|
|
225
254
|
};
|
|
226
255
|
}
|
|
227
256
|
| {
|
|
@@ -126,11 +126,9 @@ export class ContextualMenu extends Component<
|
|
|
126
126
|
const { isOpen, mountPoint, offset, boundariesElement, editorView } =
|
|
127
127
|
this.props;
|
|
128
128
|
const { isDragAndDropEnabled } = getPluginState(editorView.state);
|
|
129
|
-
const items =
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
? this.createNewContextMenuItems()
|
|
133
|
-
: this.createOriginalContextMenuItems();
|
|
129
|
+
const items = isDragAndDropEnabled
|
|
130
|
+
? this.createNewContextMenuItems()
|
|
131
|
+
: this.createOriginalContextMenuItems();
|
|
134
132
|
|
|
135
133
|
return (
|
|
136
134
|
<div
|
|
@@ -161,9 +159,6 @@ export class ContextualMenu extends Component<
|
|
|
161
159
|
offset={offset}
|
|
162
160
|
section={
|
|
163
161
|
isDragAndDropEnabled &&
|
|
164
|
-
getBooleanFF(
|
|
165
|
-
'platform.editor.table.new-cell-context-menu-styling',
|
|
166
|
-
) &&
|
|
167
162
|
getBooleanFF('platform.editor.menu.group-items')
|
|
168
163
|
? { hasSeparator: true }
|
|
169
164
|
: undefined
|
|
@@ -210,33 +205,24 @@ export class ContextualMenu extends Component<
|
|
|
210
205
|
node?.attrs?.background || '#ffffff',
|
|
211
206
|
);
|
|
212
207
|
return {
|
|
213
|
-
content:
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
? formatMessage(messages.backgroundColor)
|
|
217
|
-
: formatMessage(messages.cellBackground),
|
|
208
|
+
content: isDragAndDropEnabled
|
|
209
|
+
? formatMessage(messages.backgroundColor)
|
|
210
|
+
: formatMessage(messages.cellBackground),
|
|
218
211
|
value: { name: 'background' },
|
|
219
|
-
elemBefore:
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
size="medium"
|
|
228
|
-
/>
|
|
229
|
-
</span>
|
|
230
|
-
) : undefined,
|
|
212
|
+
elemBefore: isDragAndDropEnabled ? (
|
|
213
|
+
<span css={elementBeforeIconStyles}>
|
|
214
|
+
<EditorBackgroundColorIcon
|
|
215
|
+
label={formatMessage(messages.backgroundColor)}
|
|
216
|
+
size="medium"
|
|
217
|
+
/>
|
|
218
|
+
</span>
|
|
219
|
+
) : undefined,
|
|
231
220
|
elemAfter: (
|
|
232
221
|
<div className={DropdownMenuSharedCssClassName.SUBMENU}>
|
|
233
222
|
<div
|
|
234
223
|
css={cellColourPreviewStyles(background)}
|
|
235
224
|
className={
|
|
236
|
-
isDragAndDropEnabled
|
|
237
|
-
getBooleanFF(
|
|
238
|
-
'platform.editor.table.new-cell-context-menu-styling',
|
|
239
|
-
)
|
|
225
|
+
isDragAndDropEnabled
|
|
240
226
|
? ClassName.CONTEXTUAL_MENU_ICON_SMALL
|
|
241
227
|
: ClassName.CONTEXTUAL_MENU_ICON
|
|
242
228
|
}
|
|
@@ -280,29 +266,21 @@ export class ContextualMenu extends Component<
|
|
|
280
266
|
content: formatMessage(messages.mergeCells),
|
|
281
267
|
value: { name: 'merge' },
|
|
282
268
|
isDisabled: !canMergeCells(state.tr),
|
|
283
|
-
elemBefore:
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
<span css={elementBeforeIconStyles}>
|
|
289
|
-
<MergeCellsIcon />
|
|
290
|
-
</span>
|
|
291
|
-
) : undefined,
|
|
269
|
+
elemBefore: isDragAndDropEnabled ? (
|
|
270
|
+
<span css={elementBeforeIconStyles}>
|
|
271
|
+
<MergeCellsIcon />
|
|
272
|
+
</span>
|
|
273
|
+
) : undefined,
|
|
292
274
|
},
|
|
293
275
|
{
|
|
294
276
|
content: formatMessage(messages.splitCell),
|
|
295
277
|
value: { name: 'split' },
|
|
296
278
|
isDisabled: !splitCell(state),
|
|
297
|
-
elemBefore:
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
<span css={elementBeforeIconStyles}>
|
|
303
|
-
<SplitCellIcon />
|
|
304
|
-
</span>
|
|
305
|
-
) : undefined,
|
|
279
|
+
elemBefore: isDragAndDropEnabled ? (
|
|
280
|
+
<span css={elementBeforeIconStyles}>
|
|
281
|
+
<SplitCellIcon />
|
|
282
|
+
</span>
|
|
283
|
+
) : undefined,
|
|
306
284
|
},
|
|
307
285
|
] as MenuItem[];
|
|
308
286
|
}
|
|
@@ -318,20 +296,15 @@ export class ContextualMenu extends Component<
|
|
|
318
296
|
|
|
319
297
|
return {
|
|
320
298
|
content: formatMessage(
|
|
321
|
-
isDragAndDropEnabled
|
|
322
|
-
getBooleanFF('platform.editor.table.new-cell-context-menu-styling')
|
|
323
|
-
? messages.addColumnRight
|
|
324
|
-
: messages.insertColumn,
|
|
299
|
+
isDragAndDropEnabled ? messages.addColumnRight : messages.insertColumn,
|
|
325
300
|
),
|
|
326
301
|
value: { name: 'insert_column' },
|
|
327
302
|
elemAfter: <div css={shortcutStyle}>{tooltip(addColumnAfter)}</div>,
|
|
328
|
-
elemBefore:
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
</span>
|
|
334
|
-
) : undefined,
|
|
303
|
+
elemBefore: isDragAndDropEnabled ? (
|
|
304
|
+
<span css={elementBeforeIconStyles}>
|
|
305
|
+
<AddColRightIcon />
|
|
306
|
+
</span>
|
|
307
|
+
) : undefined,
|
|
335
308
|
} as MenuItem;
|
|
336
309
|
};
|
|
337
310
|
|
|
@@ -344,20 +317,15 @@ export class ContextualMenu extends Component<
|
|
|
344
317
|
|
|
345
318
|
return {
|
|
346
319
|
content: formatMessage(
|
|
347
|
-
isDragAndDropEnabled
|
|
348
|
-
getBooleanFF('platform.editor.table.new-cell-context-menu-styling')
|
|
349
|
-
? messages.addRowBelow
|
|
350
|
-
: messages.insertRow,
|
|
320
|
+
isDragAndDropEnabled ? messages.addRowBelow : messages.insertRow,
|
|
351
321
|
),
|
|
352
322
|
value: { name: 'insert_row' },
|
|
353
323
|
elemAfter: <div css={shortcutStyle}>{tooltip(addRowAfter)}</div>,
|
|
354
|
-
elemBefore:
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
</span>
|
|
360
|
-
) : undefined,
|
|
324
|
+
elemBefore: isDragAndDropEnabled ? (
|
|
325
|
+
<span css={elementBeforeIconStyles}>
|
|
326
|
+
<AddRowBelowIcon />
|
|
327
|
+
</span>
|
|
328
|
+
) : undefined,
|
|
361
329
|
} as MenuItem;
|
|
362
330
|
};
|
|
363
331
|
|
|
@@ -378,17 +346,15 @@ export class ContextualMenu extends Component<
|
|
|
378
346
|
}),
|
|
379
347
|
value: { name: 'clear' },
|
|
380
348
|
elemAfter: <div css={shortcutStyle}>{tooltip(backspace)}</div>,
|
|
381
|
-
elemBefore:
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
</span>
|
|
391
|
-
) : undefined,
|
|
349
|
+
elemBefore: isDragAndDropEnabled ? (
|
|
350
|
+
<span css={elementBeforeIconStyles}>
|
|
351
|
+
<CrossCircleIcon
|
|
352
|
+
label={formatMessage(messages.clearCells, {
|
|
353
|
+
0: Math.max(noOfColumns, noOfRows),
|
|
354
|
+
})}
|
|
355
|
+
/>
|
|
356
|
+
</span>
|
|
357
|
+
) : undefined,
|
|
392
358
|
} as MenuItem;
|
|
393
359
|
};
|
|
394
360
|
|
|
@@ -408,17 +374,15 @@ export class ContextualMenu extends Component<
|
|
|
408
374
|
0: noOfColumns,
|
|
409
375
|
}),
|
|
410
376
|
value: { name: 'delete_column' },
|
|
411
|
-
elemBefore:
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
</span>
|
|
421
|
-
) : undefined,
|
|
377
|
+
elemBefore: isDragAndDropEnabled ? (
|
|
378
|
+
<span css={elementBeforeIconStyles}>
|
|
379
|
+
<RemoveIcon
|
|
380
|
+
label={formatMessage(messages.removeColumns, {
|
|
381
|
+
0: noOfColumns,
|
|
382
|
+
})}
|
|
383
|
+
/>
|
|
384
|
+
</span>
|
|
385
|
+
) : undefined,
|
|
422
386
|
} as MenuItem;
|
|
423
387
|
};
|
|
424
388
|
|
|
@@ -438,17 +402,15 @@ export class ContextualMenu extends Component<
|
|
|
438
402
|
0: noOfRows,
|
|
439
403
|
}),
|
|
440
404
|
value: { name: 'delete_row' },
|
|
441
|
-
elemBefore:
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
</span>
|
|
451
|
-
) : undefined,
|
|
405
|
+
elemBefore: isDragAndDropEnabled ? (
|
|
406
|
+
<span css={elementBeforeIconStyles}>
|
|
407
|
+
<RemoveIcon
|
|
408
|
+
label={formatMessage(messages.removeRows, {
|
|
409
|
+
0: noOfRows,
|
|
410
|
+
})}
|
|
411
|
+
/>
|
|
412
|
+
</span>
|
|
413
|
+
) : undefined,
|
|
452
414
|
} as MenuItem;
|
|
453
415
|
};
|
|
454
416
|
|
|
@@ -463,11 +425,7 @@ export class ContextualMenu extends Component<
|
|
|
463
425
|
isDragAndDropEnabled,
|
|
464
426
|
pluginConfig: { allowDistributeColumns },
|
|
465
427
|
} = getPluginState(editorView.state);
|
|
466
|
-
if (
|
|
467
|
-
allowDistributeColumns &&
|
|
468
|
-
(!isDragAndDropEnabled ||
|
|
469
|
-
!getBooleanFF('platform.editor.table.new-cell-context-menu-styling'))
|
|
470
|
-
) {
|
|
428
|
+
if (allowDistributeColumns && !isDragAndDropEnabled) {
|
|
471
429
|
const { isTableScalingEnabled = false } = getPluginState(
|
|
472
430
|
editorView.state,
|
|
473
431
|
);
|
|
@@ -498,11 +456,7 @@ export class ContextualMenu extends Component<
|
|
|
498
456
|
} = this.props;
|
|
499
457
|
const { isDragAndDropEnabled } = getPluginState(editorView.state);
|
|
500
458
|
|
|
501
|
-
if (
|
|
502
|
-
allowColumnSorting &&
|
|
503
|
-
(!isDragAndDropEnabled ||
|
|
504
|
-
!getBooleanFF('platform.editor.table.new-cell-context-menu-styling'))
|
|
505
|
-
) {
|
|
459
|
+
if (allowColumnSorting && !isDragAndDropEnabled) {
|
|
506
460
|
const hasMergedCellsInTable =
|
|
507
461
|
getMergedCellsPositions(editorView.state.tr).length > 0;
|
|
508
462
|
const warning = hasMergedCellsInTable
|
|
@@ -620,27 +620,18 @@ export const DragMenu = React.memo(
|
|
|
620
620
|
return null;
|
|
621
621
|
}
|
|
622
622
|
|
|
623
|
-
if (
|
|
624
|
-
allowBackgroundColor &&
|
|
625
|
-
getBooleanFF('platform.editor.table.new-cell-context-menu-styling')
|
|
626
|
-
) {
|
|
623
|
+
if (allowBackgroundColor) {
|
|
627
624
|
menuItems[0].items.unshift(createBackgroundColorMenuItem());
|
|
628
625
|
}
|
|
629
626
|
|
|
630
627
|
// If first row, add toggle for Header row, default is true
|
|
631
628
|
// If first column, add toggle for Header column, default is false
|
|
632
|
-
if (
|
|
633
|
-
getBooleanFF('platform.editor.table.new-cell-context-menu-styling') &&
|
|
634
|
-
index === 0
|
|
635
|
-
) {
|
|
629
|
+
if (index === 0) {
|
|
636
630
|
menuItems.push({ items: [createHeaderRowColumnMenuItem(direction)] });
|
|
637
631
|
}
|
|
638
632
|
|
|
639
633
|
// All rows, add toggle for numbered rows, default is false
|
|
640
|
-
if (
|
|
641
|
-
getBooleanFF('platform.editor.table.new-cell-context-menu-styling') &&
|
|
642
|
-
direction === 'row'
|
|
643
|
-
) {
|
|
634
|
+
if (direction === 'row') {
|
|
644
635
|
index === 0
|
|
645
636
|
? menuItems[menuItems.length - 1].items.push(createRowNumbersMenuItem())
|
|
646
637
|
: menuItems.push({ items: [createRowNumbersMenuItem()] });
|
|
@@ -11,7 +11,6 @@ import {
|
|
|
11
11
|
import { withReactEditorViewOuterListeners } from '@atlaskit/editor-common/ui-react';
|
|
12
12
|
import { akEditorFloatingPanelZIndex } from '@atlaskit/editor-shared-styles';
|
|
13
13
|
import { MenuGroup, Section } from '@atlaskit/menu';
|
|
14
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
15
14
|
|
|
16
15
|
import { dragMenuDropdownWidth } from '../consts';
|
|
17
16
|
|
|
@@ -150,39 +149,31 @@ export const DropdownMenu = ({
|
|
|
150
149
|
// The logic below normalises the index value based on the number
|
|
151
150
|
// of menu items with 2 focusable elements, and adjusts the index to ensure
|
|
152
151
|
// the correct menu item is sent in onItemActivated callback
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
'platform.editor.table.new-cell-context-menu-styling',
|
|
156
|
-
)
|
|
157
|
-
) {
|
|
158
|
-
const keys = ['row_numbers', 'header_row', 'header_column'];
|
|
159
|
-
let doubleItemCount = 0;
|
|
152
|
+
const keys = ['row_numbers', 'header_row', 'header_column'];
|
|
153
|
+
let doubleItemCount = 0;
|
|
160
154
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
155
|
+
const firstIndex = results.findIndex((value) =>
|
|
156
|
+
keys.includes(value.key!),
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
if (firstIndex === -1 || index <= firstIndex) {
|
|
160
|
+
onItemActivated && onItemActivated({ item: results[index] });
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
164
163
|
|
|
165
|
-
|
|
166
|
-
|
|
164
|
+
for (let i = firstIndex; i < results.length; i += 1) {
|
|
165
|
+
if (keys.includes(results[i].key!)) {
|
|
166
|
+
doubleItemCount += 1;
|
|
167
|
+
}
|
|
168
|
+
if (firstIndex % 2 === 0 && index - doubleItemCount === i) {
|
|
169
|
+
onItemActivated && onItemActivated({ item: results[i] });
|
|
167
170
|
return;
|
|
168
171
|
}
|
|
169
172
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
}
|
|
174
|
-
if (firstIndex % 2 === 0 && index - doubleItemCount === i) {
|
|
175
|
-
onItemActivated && onItemActivated({ item: results[i] });
|
|
176
|
-
return;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
if (firstIndex % 2 === 1 && index - doubleItemCount === i) {
|
|
180
|
-
onItemActivated && onItemActivated({ item: results[i] });
|
|
181
|
-
return;
|
|
182
|
-
}
|
|
173
|
+
if (firstIndex % 2 === 1 && index - doubleItemCount === i) {
|
|
174
|
+
onItemActivated && onItemActivated({ item: results[i] });
|
|
175
|
+
return;
|
|
183
176
|
}
|
|
184
|
-
} else {
|
|
185
|
-
onItemActivated && onItemActivated({ item: results[index] });
|
|
186
177
|
}
|
|
187
178
|
}}
|
|
188
179
|
>
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
import type { MouseEvent } from 'react';
|
|
3
3
|
import React, { useCallback, useMemo, useRef } from 'react';
|
|
4
4
|
|
|
5
|
+
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
5
6
|
import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
7
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
6
8
|
import type { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
7
9
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
8
10
|
import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
|
|
@@ -16,6 +18,7 @@ import {
|
|
|
16
18
|
selectColumn,
|
|
17
19
|
selectColumns,
|
|
18
20
|
} from '../../../commands';
|
|
21
|
+
import type { TablePlugin } from '../../../plugin';
|
|
19
22
|
import { toggleDragMenu } from '../../../pm-plugins/drag-and-drop/commands';
|
|
20
23
|
import type { TriggerType } from '../../../pm-plugins/drag-and-drop/types';
|
|
21
24
|
import type { CellHoverMeta, HandleTypes } from '../../../types';
|
|
@@ -69,8 +72,11 @@ export const ColumnControls = ({
|
|
|
69
72
|
isNumberColumnEnabled,
|
|
70
73
|
isDragging,
|
|
71
74
|
getScrollOffset,
|
|
72
|
-
|
|
75
|
+
api,
|
|
76
|
+
}: ColumnControlsProps & { api?: ExtractInjectionAPI<TablePlugin> }) => {
|
|
73
77
|
const columnControlsRef = useRef<HTMLDivElement>(null);
|
|
78
|
+
const { selectionState } = useSharedPluginState(api, ['selection']);
|
|
79
|
+
|
|
74
80
|
const widths =
|
|
75
81
|
colWidths
|
|
76
82
|
?.map((width) =>
|
|
@@ -82,7 +88,9 @@ export const ColumnControls = ({
|
|
|
82
88
|
// TODO: reusing getRowsParams here because it's generic enough to work for columns -> rename
|
|
83
89
|
const columnParams = getRowsParams(colWidths ?? []);
|
|
84
90
|
const colIndex = hoveredCell?.colIndex;
|
|
85
|
-
const selectedColIndexes = getSelectedColumns(
|
|
91
|
+
const selectedColIndexes = getSelectedColumns(
|
|
92
|
+
selectionState?.selection || editorView.state.selection,
|
|
93
|
+
);
|
|
86
94
|
|
|
87
95
|
const firstRow = tableRef.querySelector('tr');
|
|
88
96
|
const hasHeaderRow = firstRow
|
|
@@ -5,10 +5,15 @@ import type { GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
|
|
|
5
5
|
import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
6
6
|
import type { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
7
7
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
8
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
8
9
|
import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
9
10
|
|
|
10
11
|
import type { RowStickyState } from '../../pm-plugins/sticky-headers';
|
|
11
|
-
import type {
|
|
12
|
+
import type {
|
|
13
|
+
CellHoverMeta,
|
|
14
|
+
DraggableSourceData,
|
|
15
|
+
PluginInjectionAPI,
|
|
16
|
+
} from '../../types';
|
|
12
17
|
import { TableCssClassName as ClassName } from '../../types';
|
|
13
18
|
import {
|
|
14
19
|
containsHeaderColumn,
|
|
@@ -39,6 +44,7 @@ export interface Props {
|
|
|
39
44
|
isNumberColumnEnabled?: boolean;
|
|
40
45
|
getScrollOffset?: () => number;
|
|
41
46
|
tableWrapperHeight?: number;
|
|
47
|
+
api?: PluginInjectionAPI;
|
|
42
48
|
}
|
|
43
49
|
|
|
44
50
|
export const TableFloatingColumnControls = ({
|
|
@@ -57,6 +63,7 @@ export const TableFloatingColumnControls = ({
|
|
|
57
63
|
isNumberColumnEnabled,
|
|
58
64
|
getScrollOffset,
|
|
59
65
|
tableWrapperHeight,
|
|
66
|
+
api,
|
|
60
67
|
}: Props) => {
|
|
61
68
|
const [isDragging, setIsDragging] = useState(false);
|
|
62
69
|
const containerRef = useRef<HTMLDivElement>(null);
|
|
@@ -136,6 +143,11 @@ export const TableFloatingColumnControls = ({
|
|
|
136
143
|
isNumberColumnEnabled={isNumberColumnEnabled}
|
|
137
144
|
isDragging={isDragging}
|
|
138
145
|
getScrollOffset={getScrollOffset}
|
|
146
|
+
api={
|
|
147
|
+
getBooleanFF('platform.editor.table.use-shared-state-hook')
|
|
148
|
+
? api
|
|
149
|
+
: undefined
|
|
150
|
+
}
|
|
139
151
|
/>
|
|
140
152
|
{isDragging && (
|
|
141
153
|
<ColumnDropTargets
|
|
@@ -4,7 +4,9 @@ import classnames from 'classnames';
|
|
|
4
4
|
import type { WrappedComponentProps } from 'react-intl-next';
|
|
5
5
|
import { injectIntl } from 'react-intl-next';
|
|
6
6
|
|
|
7
|
+
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
7
8
|
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
9
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
8
10
|
import {
|
|
9
11
|
findTable,
|
|
10
12
|
isTableSelected,
|
|
@@ -12,6 +14,7 @@ import {
|
|
|
12
14
|
} from '@atlaskit/editor-tables/utils';
|
|
13
15
|
|
|
14
16
|
import { clearHoverSelection } from '../../../commands';
|
|
17
|
+
import type { TablePlugin } from '../../../plugin';
|
|
15
18
|
import { TableCssClassName as ClassName } from '../../../types';
|
|
16
19
|
|
|
17
20
|
import type { CornerControlProps } from './types';
|
|
@@ -62,4 +65,59 @@ const DragCornerControlsComponent = ({
|
|
|
62
65
|
);
|
|
63
66
|
};
|
|
64
67
|
|
|
68
|
+
const DragCornerControlsComponentWithSelection = ({
|
|
69
|
+
editorView,
|
|
70
|
+
isInDanger,
|
|
71
|
+
isResizing,
|
|
72
|
+
intl: { formatMessage },
|
|
73
|
+
api,
|
|
74
|
+
}: CornerControlProps &
|
|
75
|
+
WrappedComponentProps & { api?: ExtractInjectionAPI<TablePlugin> }) => {
|
|
76
|
+
const { selectionState } = useSharedPluginState(api, ['selection']);
|
|
77
|
+
|
|
78
|
+
const handleOnClick = () => {
|
|
79
|
+
const { state, dispatch } = editorView;
|
|
80
|
+
dispatch(selectTable(state.tr).setMeta('addToHistory', false));
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const handleMouseOut = () => {
|
|
84
|
+
const { state, dispatch } = editorView;
|
|
85
|
+
clearHoverSelection()(state, dispatch);
|
|
86
|
+
};
|
|
87
|
+
const isActive = useMemo(() => {
|
|
88
|
+
if (!selectionState?.selection) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const table = findTable(selectionState.selection);
|
|
92
|
+
if (!table) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
return isTableSelected(selectionState.selection);
|
|
96
|
+
}, [selectionState]);
|
|
97
|
+
|
|
98
|
+
if (isResizing) {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return (
|
|
103
|
+
<button
|
|
104
|
+
className={classnames(ClassName.DRAG_CORNER_BUTTON, {
|
|
105
|
+
active: isActive,
|
|
106
|
+
danger: isActive && isInDanger,
|
|
107
|
+
})}
|
|
108
|
+
aria-label={formatMessage(messages.cornerControl)}
|
|
109
|
+
type="button"
|
|
110
|
+
onClick={handleOnClick}
|
|
111
|
+
onMouseOut={handleMouseOut}
|
|
112
|
+
contentEditable={false}
|
|
113
|
+
>
|
|
114
|
+
<div className={ClassName.DRAG_CORNER_BUTTON_INNER} />
|
|
115
|
+
</button>
|
|
116
|
+
);
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
export const DragCornerControlsWithSelection = injectIntl(
|
|
120
|
+
DragCornerControlsComponentWithSelection,
|
|
121
|
+
);
|
|
122
|
+
|
|
65
123
|
export const DragCornerControls = injectIntl(DragCornerControlsComponent);
|