@atlaskit/editor-plugin-table 7.13.0 → 7.13.1

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.
Files changed (52) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/cjs/commands/insert.js +6 -4
  3. package/dist/cjs/commands-with-analytics.js +4 -2
  4. package/dist/cjs/plugin.js +4 -2
  5. package/dist/cjs/ui/FloatingContextualMenu/ContextualMenu.js +11 -7
  6. package/dist/cjs/ui/FloatingContextualMenu/index.js +4 -2
  7. package/dist/cjs/ui/FloatingDragMenu/DragMenu.js +3 -2
  8. package/dist/cjs/ui/FloatingDragMenu/index.js +7 -2
  9. package/dist/cjs/ui/FloatingInsertButton/index.js +10 -4
  10. package/dist/cjs/utils/drag-menu.js +3 -2
  11. package/dist/es2019/commands/insert.js +6 -6
  12. package/dist/es2019/commands-with-analytics.js +4 -4
  13. package/dist/es2019/plugin.js +4 -2
  14. package/dist/es2019/ui/FloatingContextualMenu/ContextualMenu.js +7 -3
  15. package/dist/es2019/ui/FloatingContextualMenu/index.js +4 -2
  16. package/dist/es2019/ui/FloatingDragMenu/DragMenu.js +3 -2
  17. package/dist/es2019/ui/FloatingDragMenu/index.js +7 -2
  18. package/dist/es2019/ui/FloatingInsertButton/index.js +10 -4
  19. package/dist/es2019/utils/drag-menu.js +3 -3
  20. package/dist/esm/commands/insert.js +6 -4
  21. package/dist/esm/commands-with-analytics.js +4 -2
  22. package/dist/esm/plugin.js +4 -2
  23. package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +11 -7
  24. package/dist/esm/ui/FloatingContextualMenu/index.js +4 -2
  25. package/dist/esm/ui/FloatingDragMenu/DragMenu.js +3 -2
  26. package/dist/esm/ui/FloatingDragMenu/index.js +7 -2
  27. package/dist/esm/ui/FloatingInsertButton/index.js +10 -4
  28. package/dist/esm/utils/drag-menu.js +3 -2
  29. package/dist/types/commands/insert.d.ts +3 -3
  30. package/dist/types/commands-with-analytics.d.ts +2 -2
  31. package/dist/types/ui/FloatingContextualMenu/index.d.ts +1 -1
  32. package/dist/types/ui/FloatingDragMenu/DragMenu.d.ts +2 -1
  33. package/dist/types/ui/FloatingDragMenu/index.d.ts +3 -2
  34. package/dist/types/ui/FloatingInsertButton/index.d.ts +2 -1
  35. package/dist/types/utils/drag-menu.d.ts +1 -1
  36. package/dist/types-ts4.5/commands/insert.d.ts +3 -3
  37. package/dist/types-ts4.5/commands-with-analytics.d.ts +2 -2
  38. package/dist/types-ts4.5/ui/FloatingContextualMenu/index.d.ts +1 -1
  39. package/dist/types-ts4.5/ui/FloatingDragMenu/DragMenu.d.ts +2 -1
  40. package/dist/types-ts4.5/ui/FloatingDragMenu/index.d.ts +3 -2
  41. package/dist/types-ts4.5/ui/FloatingInsertButton/index.d.ts +2 -1
  42. package/dist/types-ts4.5/utils/drag-menu.d.ts +1 -1
  43. package/package.json +1 -1
  44. package/src/commands/insert.ts +16 -6
  45. package/src/commands-with-analytics.ts +13 -3
  46. package/src/plugin.tsx +8 -0
  47. package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +21 -8
  48. package/src/ui/FloatingContextualMenu/index.tsx +2 -0
  49. package/src/ui/FloatingDragMenu/DragMenu.tsx +3 -0
  50. package/src/ui/FloatingDragMenu/index.tsx +11 -1
  51. package/src/ui/FloatingInsertButton/index.tsx +38 -11
  52. package/src/utils/drag-menu.ts +17 -11
@@ -539,12 +539,17 @@ export class ContextualMenu extends Component<
539
539
  selectionRect,
540
540
  editorAnalyticsAPI,
541
541
  getEditorContainerWidth,
542
+ getEditorFeatureFlags,
542
543
  } = this.props;
543
544
  // TargetCellPosition could be outdated: https://product-fabric.atlassian.net/browse/ED-8129
544
545
  const { state, dispatch } = editorView;
545
546
  const { targetCellPosition, isTableScalingEnabled = false } =
546
547
  getPluginState(state);
547
548
 
549
+ const { tableDuplicateCellColouring = false } = getEditorFeatureFlags
550
+ ? getEditorFeatureFlags()
551
+ : {};
552
+
548
553
  switch (item.value.name) {
549
554
  case 'sort_column_desc':
550
555
  sortColumnWithAnalytics(editorAnalyticsAPI)(
@@ -602,17 +607,25 @@ export class ContextualMenu extends Component<
602
607
  this.toggleOpen();
603
608
  break;
604
609
  case 'insert_column':
605
- insertColumnWithAnalytics(editorAnalyticsAPI, isTableScalingEnabled)(
606
- INPUT_METHOD.CONTEXT_MENU,
607
- selectionRect.right,
608
- )(state, dispatch, editorView);
610
+ insertColumnWithAnalytics(
611
+ editorAnalyticsAPI,
612
+ isTableScalingEnabled,
613
+ tableDuplicateCellColouring,
614
+ )(INPUT_METHOD.CONTEXT_MENU, selectionRect.right)(
615
+ state,
616
+ dispatch,
617
+ editorView,
618
+ );
609
619
  this.toggleOpen();
610
620
  break;
611
621
  case 'insert_row':
612
- insertRowWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.CONTEXT_MENU, {
613
- index: selectionRect.bottom,
614
- moveCursorToInsertedRow: true,
615
- })(state, dispatch);
622
+ insertRowWithAnalytics(editorAnalyticsAPI, tableDuplicateCellColouring)(
623
+ INPUT_METHOD.CONTEXT_MENU,
624
+ {
625
+ index: selectionRect.bottom,
626
+ moveCursorToInsertedRow: true,
627
+ },
628
+ )(state, dispatch);
616
629
  this.toggleOpen();
617
630
  break;
618
631
  case 'delete_column':
@@ -53,6 +53,7 @@ const FloatingContextualMenu = ({
53
53
  pluginConfig,
54
54
  editorAnalyticsAPI,
55
55
  getEditorContainerWidth,
56
+ getEditorFeatureFlags,
56
57
  }: Props) => {
57
58
  // TargetCellPosition could be outdated: https://product-fabric.atlassian.net/browse/ED-8129
58
59
  const { targetCellPosition, isDragAndDropEnabled } = getPluginState(
@@ -122,6 +123,7 @@ const FloatingContextualMenu = ({
122
123
  boundariesElement={boundariesElement}
123
124
  editorAnalyticsAPI={editorAnalyticsAPI}
124
125
  getEditorContainerWidth={getEditorContainerWidth}
126
+ getEditorFeatureFlags={getEditorFeatureFlags}
125
127
  />
126
128
  </div>
127
129
  </Popup>
@@ -102,6 +102,7 @@ type DragMenuProps = {
102
102
  boundariesElement?: HTMLElement;
103
103
  scrollableElement?: HTMLElement;
104
104
  isTableScalingEnabled?: boolean;
105
+ tableDuplicateCellColouring?: boolean;
105
106
  };
106
107
 
107
108
  type PluralOptionType = 'noOfCols' | 'noOfRows' | 'noOfCells' | null;
@@ -281,6 +282,7 @@ export const DragMenu = React.memo(
281
282
  scrollableElement,
282
283
  boundariesElement,
283
284
  isTableScalingEnabled,
285
+ tableDuplicateCellColouring,
284
286
  }: DragMenuProps & WrappedComponentProps) => {
285
287
  const { state, dispatch } = editorView;
286
288
  const { selection } = state;
@@ -324,6 +326,7 @@ export const DragMenu = React.memo(
324
326
  editorAnalyticsAPI,
325
327
  pluginConfig?.isHeaderRowRequired,
326
328
  isTableScalingEnabled,
329
+ tableDuplicateCellColouring,
327
330
  );
328
331
 
329
332
  const { menuItems, menuCallback } = convertToDropdownItems(
@@ -1,7 +1,10 @@
1
1
  import React from 'react';
2
2
 
3
3
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
4
- import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
4
+ import type {
5
+ GetEditorContainerWidth,
6
+ GetEditorFeatureFlags,
7
+ } from '@atlaskit/editor-common/types';
5
8
  import { Popup } from '@atlaskit/editor-common/ui';
6
9
  import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
7
10
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
@@ -33,6 +36,7 @@ export interface Props {
33
36
  stickyHeaders?: RowStickyState;
34
37
  pluginConfig?: PluginConfig;
35
38
  isTableScalingEnabled?: boolean;
39
+ getEditorFeatureFlags?: GetEditorFeatureFlags;
36
40
  }
37
41
 
38
42
  const FloatingDragMenu = ({
@@ -50,6 +54,7 @@ const FloatingDragMenu = ({
50
54
  stickyHeaders,
51
55
  pluginConfig,
52
56
  isTableScalingEnabled,
57
+ getEditorFeatureFlags,
53
58
  }: Props) => {
54
59
  if (
55
60
  !isOpen ||
@@ -74,6 +79,10 @@ const FloatingDragMenu = ({
74
79
  return null;
75
80
  }
76
81
 
82
+ const { tableDuplicateCellColouring = false } = getEditorFeatureFlags
83
+ ? getEditorFeatureFlags()
84
+ : {};
85
+
77
86
  return (
78
87
  <Popup
79
88
  alignX={direction === 'row' ? 'right' : undefined}
@@ -113,6 +122,7 @@ const FloatingDragMenu = ({
113
122
  boundariesElement={boundariesElement}
114
123
  scrollableElement={scrollableElement}
115
124
  isTableScalingEnabled={isTableScalingEnabled}
125
+ tableDuplicateCellColouring={tableDuplicateCellColouring}
116
126
  />
117
127
  </Popup>
118
128
  );
@@ -15,7 +15,10 @@ import {
15
15
  EVENT_TYPE,
16
16
  INPUT_METHOD,
17
17
  } from '@atlaskit/editor-common/analytics';
18
- import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
18
+ import type {
19
+ GetEditorContainerWidth,
20
+ GetEditorFeatureFlags,
21
+ } from '@atlaskit/editor-common/types';
19
22
  import { Popup } from '@atlaskit/editor-common/ui';
20
23
  import { closestElement } from '@atlaskit/editor-common/utils';
21
24
  import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
@@ -53,6 +56,7 @@ export interface Props {
53
56
  hasStickyHeaders?: boolean;
54
57
  dispatchAnalyticsEvent?: DispatchAnalyticsEvent;
55
58
  editorAnalyticsAPI?: EditorAnalyticsAPI;
59
+ getEditorFeatureFlags?: GetEditorFeatureFlags;
56
60
  }
57
61
 
58
62
  export class FloatingInsertButton extends React.Component<
@@ -94,8 +98,8 @@ export class FloatingInsertButton extends React.Component<
94
98
  typeof insertColumnButtonIndex !== 'undefined'
95
99
  ? 'column'
96
100
  : typeof insertRowButtonIndex !== 'undefined'
97
- ? 'row'
98
- : null;
101
+ ? 'row'
102
+ : null;
99
103
 
100
104
  if (!tableNode || !tableRef || !type) {
101
105
  return null;
@@ -261,13 +265,23 @@ export class FloatingInsertButton extends React.Component<
261
265
  }
262
266
 
263
267
  private insertRow(event: React.SyntheticEvent) {
264
- const { editorView, insertRowButtonIndex, editorAnalyticsAPI } = this.props;
268
+ const {
269
+ editorView,
270
+ insertRowButtonIndex,
271
+ editorAnalyticsAPI,
272
+ getEditorFeatureFlags,
273
+ } = this.props;
265
274
 
266
275
  if (typeof insertRowButtonIndex !== 'undefined') {
267
276
  event.preventDefault();
268
277
 
269
278
  const { state, dispatch } = editorView;
270
- insertRowWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.BUTTON, {
279
+ const featureFlags = !!getEditorFeatureFlags && getEditorFeatureFlags();
280
+
281
+ insertRowWithAnalytics(
282
+ editorAnalyticsAPI,
283
+ featureFlags && featureFlags.tableDuplicateCellColouring,
284
+ )(INPUT_METHOD.BUTTON, {
271
285
  index: insertRowButtonIndex,
272
286
  moveCursorToInsertedRow: true,
273
287
  })(state, dispatch);
@@ -275,8 +289,12 @@ export class FloatingInsertButton extends React.Component<
275
289
  }
276
290
 
277
291
  private insertColumn(event: React.SyntheticEvent) {
278
- const { editorView, insertColumnButtonIndex, editorAnalyticsAPI } =
279
- this.props;
292
+ const {
293
+ editorView,
294
+ insertColumnButtonIndex,
295
+ editorAnalyticsAPI,
296
+ getEditorFeatureFlags,
297
+ } = this.props;
280
298
 
281
299
  if (typeof insertColumnButtonIndex !== 'undefined') {
282
300
  event.preventDefault();
@@ -285,11 +303,20 @@ export class FloatingInsertButton extends React.Component<
285
303
  editorView.state,
286
304
  );
287
305
 
306
+ const { tableDuplicateCellColouring = false } = getEditorFeatureFlags
307
+ ? getEditorFeatureFlags()
308
+ : {};
309
+
288
310
  const { state, dispatch } = editorView;
289
- insertColumnWithAnalytics(editorAnalyticsAPI, isTableScalingEnabled)(
290
- INPUT_METHOD.BUTTON,
291
- insertColumnButtonIndex,
292
- )(state, dispatch, editorView);
311
+ insertColumnWithAnalytics(
312
+ editorAnalyticsAPI,
313
+ isTableScalingEnabled,
314
+ tableDuplicateCellColouring,
315
+ )(INPUT_METHOD.BUTTON, insertColumnButtonIndex)(
316
+ state,
317
+ dispatch,
318
+ editorView,
319
+ );
293
320
  }
294
321
  }
295
322
  }
@@ -177,6 +177,7 @@ export const getDragMenuConfig = (
177
177
  editorAnalyticsAPI?: EditorAnalyticsAPI,
178
178
  isHeaderRowRequired?: boolean,
179
179
  isTableScalingEnabled = false,
180
+ tableDuplicateCellColouring = false,
180
181
  ): DragMenuConfig[] => {
181
182
  const addOptions =
182
183
  direction === 'row'
@@ -303,18 +304,23 @@ export const getDragMenuConfig = (
303
304
  icon,
304
305
  onClick: (state: EditorState, dispatch?: CommandDispatch) => {
305
306
  if (direction === 'row') {
306
- insertRowWithAnalytics(editorAnalyticsAPI)(
307
- INPUT_METHOD.TABLE_CONTEXT_MENU,
308
- {
309
- index: (index ?? 0) + offset,
310
- moveCursorToInsertedRow: true,
311
- },
312
- )(state, dispatch);
307
+ insertRowWithAnalytics(
308
+ editorAnalyticsAPI,
309
+ tableDuplicateCellColouring,
310
+ )(INPUT_METHOD.TABLE_CONTEXT_MENU, {
311
+ index: (index ?? 0) + offset,
312
+ moveCursorToInsertedRow: true,
313
+ })(state, dispatch);
313
314
  } else {
314
- insertColumnWithAnalytics(editorAnalyticsAPI, isTableScalingEnabled)(
315
- INPUT_METHOD.TABLE_CONTEXT_MENU,
316
- (index ?? 0) + offset,
317
- )(state, dispatch, editorView);
315
+ insertColumnWithAnalytics(
316
+ editorAnalyticsAPI,
317
+ isTableScalingEnabled,
318
+ tableDuplicateCellColouring,
319
+ )(INPUT_METHOD.TABLE_CONTEXT_MENU, (index ?? 0) + offset)(
320
+ state,
321
+ dispatch,
322
+ editorView,
323
+ );
318
324
  }
319
325
  return true;
320
326
  },