@atlaskit/editor-plugin-table 10.9.20 → 10.9.21

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 (50) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/cjs/nodeviews/TableComponentWithSharedState.js +91 -78
  3. package/dist/cjs/nodeviews/TableContainer.js +41 -37
  4. package/dist/cjs/nodeviews/TableResizer.js +15 -11
  5. package/dist/cjs/tablePlugin.js +14 -10
  6. package/dist/cjs/ui/ContentComponent.js +21 -64
  7. package/dist/cjs/ui/DragHandle/index.js +19 -17
  8. package/dist/cjs/ui/TableFloatingColumnControls/ColumnControls/index.js +14 -11
  9. package/dist/cjs/ui/TableFloatingControls/CornerControls/DragCornerControls.js +14 -10
  10. package/dist/cjs/ui/TableFloatingControls/FloatingControlsWithSelection.js +14 -10
  11. package/dist/cjs/ui/TableFloatingControls/RowControls/DragControls.js +14 -10
  12. package/dist/cjs/ui/global-styles.js +14 -10
  13. package/dist/cjs/ui/icons/SortingIconWrapper.js +14 -11
  14. package/dist/es2019/nodeviews/TableComponentWithSharedState.js +92 -78
  15. package/dist/es2019/nodeviews/TableContainer.js +44 -39
  16. package/dist/es2019/nodeviews/TableResizer.js +17 -12
  17. package/dist/es2019/tablePlugin.js +16 -11
  18. package/dist/es2019/ui/ContentComponent.js +21 -64
  19. package/dist/es2019/ui/DragHandle/index.js +21 -18
  20. package/dist/es2019/ui/TableFloatingColumnControls/ColumnControls/index.js +16 -12
  21. package/dist/es2019/ui/TableFloatingControls/CornerControls/DragCornerControls.js +16 -11
  22. package/dist/es2019/ui/TableFloatingControls/FloatingControlsWithSelection.js +16 -11
  23. package/dist/es2019/ui/TableFloatingControls/RowControls/DragControls.js +16 -11
  24. package/dist/es2019/ui/global-styles.js +16 -11
  25. package/dist/es2019/ui/icons/SortingIconWrapper.js +16 -12
  26. package/dist/esm/nodeviews/TableComponentWithSharedState.js +92 -79
  27. package/dist/esm/nodeviews/TableContainer.js +42 -38
  28. package/dist/esm/nodeviews/TableResizer.js +16 -12
  29. package/dist/esm/tablePlugin.js +15 -11
  30. package/dist/esm/ui/ContentComponent.js +21 -64
  31. package/dist/esm/ui/DragHandle/index.js +20 -18
  32. package/dist/esm/ui/TableFloatingColumnControls/ColumnControls/index.js +15 -12
  33. package/dist/esm/ui/TableFloatingControls/CornerControls/DragCornerControls.js +15 -11
  34. package/dist/esm/ui/TableFloatingControls/FloatingControlsWithSelection.js +15 -11
  35. package/dist/esm/ui/TableFloatingControls/RowControls/DragControls.js +15 -11
  36. package/dist/esm/ui/global-styles.js +15 -11
  37. package/dist/esm/ui/icons/SortingIconWrapper.js +15 -12
  38. package/package.json +4 -4
  39. package/src/nodeviews/TableComponentWithSharedState.tsx +97 -125
  40. package/src/nodeviews/TableContainer.tsx +59 -67
  41. package/src/nodeviews/TableResizer.tsx +21 -17
  42. package/src/tablePlugin.tsx +24 -13
  43. package/src/ui/ContentComponent.tsx +19 -64
  44. package/src/ui/DragHandle/index.tsx +24 -24
  45. package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +21 -14
  46. package/src/ui/TableFloatingControls/CornerControls/DragCornerControls.tsx +20 -12
  47. package/src/ui/TableFloatingControls/FloatingControlsWithSelection.tsx +20 -13
  48. package/src/ui/TableFloatingControls/RowControls/DragControls.tsx +20 -13
  49. package/src/ui/global-styles.tsx +20 -13
  50. package/src/ui/icons/SortingIconWrapper.tsx +20 -14
@@ -2,7 +2,10 @@
2
2
  import type { MouseEvent } from 'react';
3
3
  import React, { Fragment, useCallback, useEffect, useMemo, useState } from 'react';
4
4
 
5
- import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
5
+ import {
6
+ sharedPluginStateHookMigratorFactory,
7
+ useSharedPluginState,
8
+ } from '@atlaskit/editor-common/hooks';
6
9
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
7
10
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
8
11
  import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
@@ -12,7 +15,6 @@ import { CellSelection } from '@atlaskit/editor-tables';
12
15
  import { getSelectionRect } from '@atlaskit/editor-tables/utils';
13
16
  import { fg } from '@atlaskit/platform-feature-flags';
14
17
  import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
15
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
16
18
  import { token } from '@atlaskit/tokens';
17
19
 
18
20
  import { clearHoverSelection } from '../../../pm-plugins/commands';
@@ -371,6 +373,21 @@ export const DragControls = ({
371
373
  );
372
374
  };
373
375
 
376
+ const useSharedState = sharedPluginStateHookMigratorFactory(
377
+ (api: ExtractInjectionAPI<TablePlugin> | undefined) => {
378
+ const selectionsSelector = useSharedPluginStateSelector(api, 'selection.selection');
379
+ return {
380
+ selection: selectionsSelector,
381
+ };
382
+ },
383
+ (api: ExtractInjectionAPI<TablePlugin> | undefined) => {
384
+ const { selectionState } = useSharedPluginState(api, ['selection']);
385
+ return {
386
+ selection: selectionState?.selection,
387
+ };
388
+ },
389
+ );
390
+
374
391
  export const DragControlsWithSelection = ({
375
392
  editorView,
376
393
  tableRef,
@@ -387,17 +404,7 @@ export const DragControlsWithSelection = ({
387
404
  updateCellHoverLocation,
388
405
  api,
389
406
  }: Exclude<DragControlsProps, 'selection'>) => {
390
- // selection
391
- const { selectionState } = useSharedPluginState(api, ['selection'], {
392
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true),
393
- });
394
- const selectionsSelector = useSharedPluginStateSelector(api, 'selection.selection', {
395
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
396
- });
397
- const selection = editorExperiment('platform_editor_usesharedpluginstateselector', true)
398
- ? selectionsSelector
399
- : selectionState?.selection;
400
-
407
+ const { selection } = useSharedState(api);
401
408
  return (
402
409
  <DragControls
403
410
  editorView={editorView}
@@ -5,15 +5,32 @@
5
5
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-global-styles, @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
6
6
  import { Global, jsx } from '@emotion/react';
7
7
 
8
- import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
8
+ import {
9
+ sharedPluginStateHookMigratorFactory,
10
+ useSharedPluginState,
11
+ } from '@atlaskit/editor-common/hooks';
9
12
  import type { FeatureFlags } from '@atlaskit/editor-common/types';
10
13
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
11
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
12
14
 
13
15
  import type { PluginInjectionAPI } from '../types';
14
16
 
15
17
  import { tableStyles } from './common-styles';
16
18
 
19
+ const useSharedState = sharedPluginStateHookMigratorFactory(
20
+ (api: PluginInjectionAPI | undefined) => {
21
+ const mode = useSharedPluginStateSelector(api, 'editorViewMode.mode');
22
+ return {
23
+ mode,
24
+ };
25
+ },
26
+ (api: PluginInjectionAPI | undefined) => {
27
+ const { editorViewModeState } = useSharedPluginState(api, ['editorViewMode']);
28
+ return {
29
+ mode: editorViewModeState?.mode,
30
+ };
31
+ },
32
+ );
33
+
17
34
  export const GlobalStylesWrapper = ({
18
35
  featureFlags,
19
36
  isDragAndDropEnabledOption,
@@ -23,17 +40,7 @@ export const GlobalStylesWrapper = ({
23
40
  isDragAndDropEnabledOption?: boolean;
24
41
  api?: PluginInjectionAPI;
25
42
  }) => {
26
- // mode
27
- const { editorViewModeState } = useSharedPluginState(api, ['editorViewMode'], {
28
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true),
29
- });
30
- const modeSelector = useSharedPluginStateSelector(api, 'editorViewMode.mode', {
31
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
32
- });
33
- const mode = editorExperiment('platform_editor_usesharedpluginstateselector', true)
34
- ? modeSelector
35
- : editorViewModeState?.mode;
36
-
43
+ const { mode } = useSharedState(api);
37
44
  const isLivePageViewMode = mode === 'view';
38
45
  return (
39
46
  <Global
@@ -1,10 +1,12 @@
1
1
  import React from 'react';
2
2
 
3
- import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
3
+ import {
4
+ sharedPluginStateHookMigratorFactory,
5
+ useSharedPluginState,
6
+ } from '@atlaskit/editor-common/hooks';
4
7
  import { SortingIcon } from '@atlaskit/editor-common/table';
5
8
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
6
9
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
7
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
8
10
 
9
11
  import type { TablePlugin } from '../../tablePluginType';
10
12
 
@@ -13,19 +15,23 @@ type SortingIconWrapperProps = SortingIconProps & {
13
15
  api: ExtractInjectionAPI<TablePlugin>;
14
16
  };
15
17
 
16
- export const SortingIconWrapper = (props: SortingIconWrapperProps) => {
17
- const { editorViewModeState } = useSharedPluginState(props.api, ['editorViewMode'], {
18
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true),
19
- });
20
-
21
- // mode
22
- const modeSelector = useSharedPluginStateSelector(props.api, 'editorViewMode.mode', {
23
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
24
- });
25
- const mode = editorExperiment('platform_editor_usesharedpluginstateselector', true)
26
- ? modeSelector
27
- : editorViewModeState?.mode;
18
+ const useSharedState = sharedPluginStateHookMigratorFactory(
19
+ (api: ExtractInjectionAPI<TablePlugin> | undefined) => {
20
+ const mode = useSharedPluginStateSelector(api, 'editorViewMode.mode');
21
+ return {
22
+ mode,
23
+ };
24
+ },
25
+ (api: ExtractInjectionAPI<TablePlugin> | undefined) => {
26
+ const { editorViewModeState } = useSharedPluginState(api, ['editorViewMode']);
27
+ return {
28
+ mode: editorViewModeState?.mode,
29
+ };
30
+ },
31
+ );
28
32
 
33
+ export const SortingIconWrapper = (props: SortingIconWrapperProps) => {
34
+ const { mode } = useSharedState(props.api);
29
35
  if (mode === 'edit') {
30
36
  return null;
31
37
  }