@atlaskit/editor-plugin-table 7.6.3 → 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 +7 -0
- package/dist/cjs/commands/misc.js +3 -2
- package/dist/cjs/nodeviews/TableContainer.js +32 -20
- package/dist/cjs/nodeviews/TableResizer.js +39 -27
- package/dist/cjs/plugin.js +2 -1
- package/dist/cjs/toolbar.js +5 -4
- 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/utils/guidelines.js +1 -1
- package/dist/es2019/commands/misc.js +6 -2
- package/dist/es2019/nodeviews/TableContainer.js +17 -3
- package/dist/es2019/nodeviews/TableResizer.js +26 -16
- package/dist/es2019/plugin.js +2 -1
- package/dist/es2019/toolbar.js +5 -4
- 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/utils/guidelines.js +1 -1
- package/dist/esm/commands/misc.js +3 -2
- package/dist/esm/nodeviews/TableContainer.js +32 -20
- package/dist/esm/nodeviews/TableResizer.js +40 -28
- package/dist/esm/plugin.js +2 -1
- package/dist/esm/toolbar.js +5 -4
- 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/utils/guidelines.js +1 -1
- package/dist/types/commands/misc.d.ts +2 -1
- package/dist/types/nodeviews/TableResizer.d.ts +3 -1
- package/dist/types/types.d.ts +6 -3
- package/dist/types-ts4.5/commands/misc.d.ts +2 -1
- package/dist/types-ts4.5/nodeviews/TableResizer.d.ts +3 -1
- package/dist/types-ts4.5/types.d.ts +6 -3
- package/package.json +2 -5
- package/src/commands/misc.ts +6 -3
- package/src/nodeviews/TableContainer.tsx +18 -3
- package/src/nodeviews/TableResizer.tsx +34 -20
- package/src/plugin.tsx +1 -0
- package/src/toolbar.tsx +20 -19
- package/src/types.ts +6 -2
- 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/utils/guidelines.ts +5 -4
package/src/commands/misc.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import isEqual from 'lodash/isEqual';
|
|
2
|
+
|
|
1
3
|
import type { CellAttributes } from '@atlaskit/adf-schema';
|
|
2
4
|
import type { Command } from '@atlaskit/editor-common/types';
|
|
3
5
|
import {
|
|
@@ -45,6 +47,7 @@ import {
|
|
|
45
47
|
} from '../pm-plugins/decorations/utils';
|
|
46
48
|
import { createCommand, getPluginState } from '../pm-plugins/plugin-factory';
|
|
47
49
|
import { fixAutoSizedTable } from '../transforms';
|
|
50
|
+
import type { WidthToWidest } from '../types';
|
|
48
51
|
import { TableCssClassName as ClassName, TableDecorations } from '../types';
|
|
49
52
|
import {
|
|
50
53
|
createColumnControlsDecoration,
|
|
@@ -779,18 +782,18 @@ export const addBoldInEmptyHeaderCells =
|
|
|
779
782
|
return false;
|
|
780
783
|
};
|
|
781
784
|
|
|
782
|
-
export const updateWidthToWidest = (widthToWidest:
|
|
785
|
+
export const updateWidthToWidest = (widthToWidest: WidthToWidest) =>
|
|
783
786
|
createCommand((state) => {
|
|
784
787
|
let { widthToWidest: prevWidthToWidest } = getPluginState(state);
|
|
785
788
|
|
|
786
|
-
if (prevWidthToWidest
|
|
789
|
+
if (isEqual(widthToWidest, prevWidthToWidest)) {
|
|
787
790
|
return false;
|
|
788
791
|
}
|
|
789
792
|
|
|
790
793
|
return {
|
|
791
794
|
type: 'UPDATE_TABLE_WIDTH_TO_WIDEST',
|
|
792
795
|
data: {
|
|
793
|
-
widthToWidest,
|
|
796
|
+
widthToWidest: { ...prevWidthToWidest, ...widthToWidest },
|
|
794
797
|
},
|
|
795
798
|
};
|
|
796
799
|
});
|
|
@@ -5,6 +5,7 @@ import classNames from 'classnames';
|
|
|
5
5
|
|
|
6
6
|
import type { TableEventPayload } from '@atlaskit/editor-common/analytics';
|
|
7
7
|
import type { GuidelineConfig } from '@atlaskit/editor-common/guideline';
|
|
8
|
+
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
8
9
|
import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
|
|
9
10
|
import { calcTableWidth } from '@atlaskit/editor-common/styles';
|
|
10
11
|
import type { EditorContainerWidth } from '@atlaskit/editor-common/types';
|
|
@@ -19,7 +20,7 @@ import {
|
|
|
19
20
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
20
21
|
|
|
21
22
|
import { TABLE_MAX_WIDTH } from '../pm-plugins/table-resizing/utils';
|
|
22
|
-
import type { PluginInjectionAPI } from '../types';
|
|
23
|
+
import type { PluginInjectionAPI, TableSharedStateInternal } from '../types';
|
|
23
24
|
import { TableCssClassName as ClassName } from '../types';
|
|
24
25
|
|
|
25
26
|
import { TableResizer } from './TableResizer';
|
|
@@ -61,7 +62,7 @@ export const InnerContainer = forwardRef<
|
|
|
61
62
|
className={className}
|
|
62
63
|
data-number-column={node.attrs.isNumberColumnEnabled}
|
|
63
64
|
data-layout={node.attrs.layout}
|
|
64
|
-
data-
|
|
65
|
+
data-testid="table-container"
|
|
65
66
|
>
|
|
66
67
|
{children}
|
|
67
68
|
</div>
|
|
@@ -180,6 +181,10 @@ export const ResizableTableContainer = React.memo(
|
|
|
180
181
|
);
|
|
181
182
|
|
|
182
183
|
const tableWidth = getTableContainerWidth(node);
|
|
184
|
+
const { tableState } = useSharedPluginState(pluginInjectionApi, ['table']);
|
|
185
|
+
const { widthToWidest } = tableState as TableSharedStateInternal;
|
|
186
|
+
const currentTableNodeLocalId = node?.attrs?.localId ?? '';
|
|
187
|
+
|
|
183
188
|
// 76 is currently an accepted padding value considering the spacing for resizer handle
|
|
184
189
|
const responsiveContainerWidth = isTableScalingEnabled
|
|
185
190
|
? containerWidth -
|
|
@@ -189,7 +194,16 @@ export const ResizableTableContainer = React.memo(
|
|
|
189
194
|
akEditorGutterPadding * 2 -
|
|
190
195
|
akEditorMediaResizeHandlerPaddingWide;
|
|
191
196
|
|
|
192
|
-
|
|
197
|
+
let width = Math.min(tableWidth, responsiveContainerWidth);
|
|
198
|
+
|
|
199
|
+
if (
|
|
200
|
+
isTableScalingEnabled &&
|
|
201
|
+
currentTableNodeLocalId &&
|
|
202
|
+
widthToWidest &&
|
|
203
|
+
widthToWidest[currentTableNodeLocalId]
|
|
204
|
+
) {
|
|
205
|
+
width = TABLE_MAX_WIDTH;
|
|
206
|
+
}
|
|
193
207
|
|
|
194
208
|
if (!isResizing) {
|
|
195
209
|
tableWidthRef.current = width;
|
|
@@ -210,6 +224,7 @@ export const ResizableTableContainer = React.memo(
|
|
|
210
224
|
displayGapCursor,
|
|
211
225
|
isTableScalingEnabled,
|
|
212
226
|
isWholeTableInDanger,
|
|
227
|
+
pluginInjectionApi,
|
|
213
228
|
};
|
|
214
229
|
|
|
215
230
|
if (getBooleanFF('platform.editor.resizing-table-height-improvement')) {
|
|
@@ -16,6 +16,7 @@ import type { TableEventPayload } from '@atlaskit/editor-common/analytics';
|
|
|
16
16
|
import { TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
|
|
17
17
|
import { getGuidelinesWithHighlights } from '@atlaskit/editor-common/guideline';
|
|
18
18
|
import type { GuidelineConfig } from '@atlaskit/editor-common/guideline';
|
|
19
|
+
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
19
20
|
import {
|
|
20
21
|
focusTableResizer,
|
|
21
22
|
ToolTipContent,
|
|
@@ -27,21 +28,21 @@ import { browser } from '@atlaskit/editor-common/utils';
|
|
|
27
28
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
28
29
|
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
29
30
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
30
|
-
import { akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
31
31
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
32
32
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
33
33
|
import { token } from '@atlaskit/tokens';
|
|
34
34
|
|
|
35
35
|
import { updateWidthToWidest } from '../commands/misc';
|
|
36
|
-
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
37
36
|
import { META_KEYS } from '../pm-plugins/table-analytics';
|
|
38
37
|
import {
|
|
39
38
|
COLUMN_MIN_WIDTH,
|
|
40
39
|
getColgroupChildrenLength,
|
|
41
40
|
previewScaleTable,
|
|
42
41
|
scaleTable,
|
|
42
|
+
TABLE_MAX_WIDTH,
|
|
43
43
|
} from '../pm-plugins/table-resizing/utils';
|
|
44
44
|
import { pluginKey as tableWidthPluginKey } from '../pm-plugins/table-width';
|
|
45
|
+
import type { PluginInjectionAPI, TableSharedStateInternal } from '../types';
|
|
45
46
|
import {
|
|
46
47
|
TABLE_GUIDELINE_VISIBLE_ADJUSTMENT,
|
|
47
48
|
TABLE_HIGHLIGHT_GAP,
|
|
@@ -77,6 +78,7 @@ interface TableResizerProps {
|
|
|
77
78
|
payload: TableEventPayload,
|
|
78
79
|
) => ((tr: Transaction) => boolean) | undefined;
|
|
79
80
|
displayGapCursor: (toggle: boolean) => boolean;
|
|
81
|
+
pluginInjectionApi?: PluginInjectionAPI;
|
|
80
82
|
isTableScalingEnabled?: boolean;
|
|
81
83
|
isWholeTableInDanger?: boolean;
|
|
82
84
|
}
|
|
@@ -172,13 +174,16 @@ export const TableResizer = ({
|
|
|
172
174
|
displayGapCursor,
|
|
173
175
|
isTableScalingEnabled,
|
|
174
176
|
isWholeTableInDanger,
|
|
177
|
+
pluginInjectionApi,
|
|
175
178
|
}: PropsWithChildren<TableResizerImprovementProps>) => {
|
|
176
179
|
const currentGap = useRef(0);
|
|
177
180
|
// track resizing state - use ref over state to avoid re-render
|
|
178
181
|
const isResizing = useRef(false);
|
|
179
182
|
const areResizeMetaKeysPressed = useRef(false);
|
|
180
|
-
|
|
183
|
+
const [localTableWidth, setLocalTableWidth] = useState(width);
|
|
181
184
|
const resizerRef = useRef<ResizerNextHandler>(null);
|
|
185
|
+
const { tableState } = useSharedPluginState(pluginInjectionApi, ['table']);
|
|
186
|
+
const { widthToWidest } = tableState as TableSharedStateInternal;
|
|
182
187
|
|
|
183
188
|
// used to reposition tooltip when table is resizing via keyboard
|
|
184
189
|
const updateTooltip = React.useRef<() => void>();
|
|
@@ -349,25 +354,28 @@ export const TableResizer = ({
|
|
|
349
354
|
// and a table is resized to fit the widest guideline when view port width is between 1011 and 1800
|
|
350
355
|
// set the width of the table to 1800 pixels.
|
|
351
356
|
const { state, dispatch } = editorView;
|
|
352
|
-
const
|
|
357
|
+
const currentTableNodeLocalId = node?.attrs?.localId ?? '';
|
|
358
|
+
|
|
359
|
+
const widestGuideline = defaultGuidelinesForPreserveTable(
|
|
353
360
|
containerWidth,
|
|
354
|
-
)[
|
|
355
|
-
|
|
356
|
-
?.
|
|
357
|
-
|
|
358
|
-
widestGuideLineWidthString || '',
|
|
359
|
-
10,
|
|
360
|
-
);
|
|
361
|
+
).filter((guideline) => guideline.isFullWidth)[0];
|
|
362
|
+
const widestGuideLineWidth = widestGuideline
|
|
363
|
+
? ((widestGuideline.position?.x || 0) as number) * 2
|
|
364
|
+
: null;
|
|
361
365
|
const shouldUpdateWidthToWidest = !!(
|
|
362
366
|
isTableScalingEnabled &&
|
|
363
|
-
|
|
364
|
-
widestGuideLineWidth - newWidth <= 1
|
|
367
|
+
widestGuideLineWidth &&
|
|
368
|
+
Math.abs(widestGuideLineWidth - newWidth) <= 1
|
|
365
369
|
);
|
|
366
|
-
|
|
370
|
+
shouldUpdateWidthToWidest
|
|
371
|
+
? setLocalTableWidth(TABLE_MAX_WIDTH)
|
|
372
|
+
: setLocalTableWidth(newWidth);
|
|
367
373
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
);
|
|
374
|
+
updateWidthToWidest({
|
|
375
|
+
[currentTableNodeLocalId]: shouldUpdateWidthToWidest,
|
|
376
|
+
})(state, dispatch);
|
|
377
|
+
|
|
378
|
+
updateWidth(shouldUpdateWidthToWidest ? TABLE_MAX_WIDTH : newWidth);
|
|
371
379
|
|
|
372
380
|
return newWidth;
|
|
373
381
|
},
|
|
@@ -392,8 +400,13 @@ export const TableResizer = ({
|
|
|
392
400
|
let newWidth = originalState.width + delta.width;
|
|
393
401
|
const { state, dispatch } = editorView;
|
|
394
402
|
const pos = getPos();
|
|
395
|
-
const
|
|
396
|
-
newWidth =
|
|
403
|
+
const currentTableNodeLocalId = node?.attrs?.localId ?? '';
|
|
404
|
+
newWidth =
|
|
405
|
+
widthToWidest &&
|
|
406
|
+
currentTableNodeLocalId &&
|
|
407
|
+
widthToWidest[currentTableNodeLocalId]
|
|
408
|
+
? TABLE_MAX_WIDTH
|
|
409
|
+
: newWidth;
|
|
397
410
|
|
|
398
411
|
let tr = state.tr.setMeta(tableWidthPluginKey, { resizing: false });
|
|
399
412
|
const frameRateSamples = endMeasure();
|
|
@@ -467,6 +480,7 @@ export const TableResizer = ({
|
|
|
467
480
|
endMeasure,
|
|
468
481
|
onResizeStop,
|
|
469
482
|
isTableScalingEnabled,
|
|
483
|
+
widthToWidest,
|
|
470
484
|
],
|
|
471
485
|
);
|
|
472
486
|
|
|
@@ -617,7 +631,7 @@ export const TableResizer = ({
|
|
|
617
631
|
<ResizerNext
|
|
618
632
|
ref={resizerRef}
|
|
619
633
|
enable={handles}
|
|
620
|
-
width={
|
|
634
|
+
width={localTableWidth}
|
|
621
635
|
handleAlignmentMethod="sticky"
|
|
622
636
|
handleSize={handleSize}
|
|
623
637
|
handleStyles={handleStyles}
|
package/src/plugin.tsx
CHANGED
|
@@ -192,6 +192,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
192
192
|
// IMPORTANT: Need to continue to pass tableNode to control re-renders
|
|
193
193
|
// TableComponent listens for node attribute changes to update colgroups
|
|
194
194
|
tableNode: tablePluginState.tableNode,
|
|
195
|
+
widthToWidest: tablePluginState.widthToWidest,
|
|
195
196
|
};
|
|
196
197
|
},
|
|
197
198
|
|
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
|
@@ -49,6 +49,7 @@ export type TableSharedStateInternal = Pick<
|
|
|
49
49
|
| 'hoveredCell'
|
|
50
50
|
| 'isTableHovered'
|
|
51
51
|
| 'tableNode'
|
|
52
|
+
| 'widthToWidest'
|
|
52
53
|
> & {
|
|
53
54
|
isResizing: boolean;
|
|
54
55
|
isTableResizing?: boolean;
|
|
@@ -121,6 +122,9 @@ export interface CellHoverMeta {
|
|
|
121
122
|
colIndex?: number;
|
|
122
123
|
rowIndex?: number;
|
|
123
124
|
}
|
|
125
|
+
export interface WidthToWidest {
|
|
126
|
+
[tableLocalId: string]: boolean;
|
|
127
|
+
}
|
|
124
128
|
|
|
125
129
|
export interface TablePluginState {
|
|
126
130
|
editorHasFocus?: boolean;
|
|
@@ -155,7 +159,7 @@ export interface TablePluginState {
|
|
|
155
159
|
// for table wrap/collapse
|
|
156
160
|
isTableCollapsed?: boolean; // is the current table already in an expand?
|
|
157
161
|
canCollapseTable?: boolean; // enabled/disabled state of collapse option
|
|
158
|
-
widthToWidest?:
|
|
162
|
+
widthToWidest?: WidthToWidest; // is the current table set to the widest width regarding view port
|
|
159
163
|
|
|
160
164
|
getIntl: () => IntlShape;
|
|
161
165
|
|
|
@@ -246,7 +250,7 @@ export type TablePluginAction =
|
|
|
246
250
|
| {
|
|
247
251
|
type: 'UPDATE_TABLE_WIDTH_TO_WIDEST';
|
|
248
252
|
data: {
|
|
249
|
-
widthToWidest:
|
|
253
|
+
widthToWidest: WidthToWidest | undefined;
|
|
250
254
|
};
|
|
251
255
|
}
|
|
252
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()] });
|