@atlaskit/editor-plugin-table 10.9.19 → 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.
- package/CHANGELOG.md +19 -0
- package/dist/cjs/nodeviews/TableComponentWithSharedState.js +91 -78
- package/dist/cjs/nodeviews/TableContainer.js +41 -37
- package/dist/cjs/nodeviews/TableResizer.js +15 -11
- package/dist/cjs/tablePlugin.js +14 -10
- package/dist/cjs/ui/ContentComponent.js +21 -64
- package/dist/cjs/ui/DragHandle/index.js +19 -17
- package/dist/cjs/ui/TableFloatingColumnControls/ColumnControls/index.js +14 -11
- package/dist/cjs/ui/TableFloatingControls/CornerControls/DragCornerControls.js +14 -10
- package/dist/cjs/ui/TableFloatingControls/FloatingControlsWithSelection.js +14 -10
- package/dist/cjs/ui/TableFloatingControls/RowControls/DragControls.js +14 -10
- package/dist/cjs/ui/global-styles.js +14 -10
- package/dist/cjs/ui/icons/SortingIconWrapper.js +14 -11
- package/dist/cjs/ui/toolbar.js +5 -0
- package/dist/es2019/nodeviews/TableComponentWithSharedState.js +92 -78
- package/dist/es2019/nodeviews/TableContainer.js +44 -39
- package/dist/es2019/nodeviews/TableResizer.js +17 -12
- package/dist/es2019/tablePlugin.js +16 -11
- package/dist/es2019/ui/ContentComponent.js +21 -64
- package/dist/es2019/ui/DragHandle/index.js +21 -18
- package/dist/es2019/ui/TableFloatingColumnControls/ColumnControls/index.js +16 -12
- package/dist/es2019/ui/TableFloatingControls/CornerControls/DragCornerControls.js +16 -11
- package/dist/es2019/ui/TableFloatingControls/FloatingControlsWithSelection.js +16 -11
- package/dist/es2019/ui/TableFloatingControls/RowControls/DragControls.js +16 -11
- package/dist/es2019/ui/global-styles.js +16 -11
- package/dist/es2019/ui/icons/SortingIconWrapper.js +16 -12
- package/dist/es2019/ui/toolbar.js +5 -0
- package/dist/esm/nodeviews/TableComponentWithSharedState.js +92 -79
- package/dist/esm/nodeviews/TableContainer.js +42 -38
- package/dist/esm/nodeviews/TableResizer.js +16 -12
- package/dist/esm/tablePlugin.js +15 -11
- package/dist/esm/ui/ContentComponent.js +21 -64
- package/dist/esm/ui/DragHandle/index.js +20 -18
- package/dist/esm/ui/TableFloatingColumnControls/ColumnControls/index.js +15 -12
- package/dist/esm/ui/TableFloatingControls/CornerControls/DragCornerControls.js +15 -11
- package/dist/esm/ui/TableFloatingControls/FloatingControlsWithSelection.js +15 -11
- package/dist/esm/ui/TableFloatingControls/RowControls/DragControls.js +15 -11
- package/dist/esm/ui/global-styles.js +15 -11
- package/dist/esm/ui/icons/SortingIconWrapper.js +15 -12
- package/dist/esm/ui/toolbar.js +5 -0
- package/package.json +8 -5
- package/src/nodeviews/TableComponentWithSharedState.tsx +97 -125
- package/src/nodeviews/TableContainer.tsx +59 -67
- package/src/nodeviews/TableResizer.tsx +21 -17
- package/src/tablePlugin.tsx +24 -13
- package/src/ui/ContentComponent.tsx +19 -64
- package/src/ui/DragHandle/index.tsx +24 -24
- package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +21 -14
- package/src/ui/TableFloatingControls/CornerControls/DragCornerControls.tsx +20 -12
- package/src/ui/TableFloatingControls/FloatingControlsWithSelection.tsx +20 -13
- package/src/ui/TableFloatingControls/RowControls/DragControls.tsx +20 -13
- package/src/ui/global-styles.tsx +20 -13
- package/src/ui/icons/SortingIconWrapper.tsx +20 -14
- package/src/ui/toolbar.tsx +7 -0
|
@@ -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 {
|
|
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
|
-
|
|
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}
|
package/src/ui/global-styles.tsx
CHANGED
|
@@ -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 {
|
|
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
|
-
|
|
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 {
|
|
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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
}
|
package/src/ui/toolbar.tsx
CHANGED
|
@@ -676,6 +676,12 @@ export const getToolbarConfig =
|
|
|
676
676
|
editorExperiment('platform_editor_controls', 'variant1') &&
|
|
677
677
|
fg('platform_editor_controls_patch_6');
|
|
678
678
|
|
|
679
|
+
// testId is required to show focus on trigger button on ESC key press
|
|
680
|
+
// see hideOnEsc in platform/packages/editor/editor-plugin-floating-toolbar/src/ui/Dropdown.tsx
|
|
681
|
+
const overflowDropdownTestId = fg('platform_editor_controls_patch_8')
|
|
682
|
+
? 'table-overflow-dropdown-trigger'
|
|
683
|
+
: undefined;
|
|
684
|
+
|
|
679
685
|
return {
|
|
680
686
|
title: toolbarTitle,
|
|
681
687
|
getDomRef,
|
|
@@ -705,6 +711,7 @@ export const getToolbarConfig =
|
|
|
705
711
|
shouldGroupWithoutSeparators && { type: 'separator', fullHeight: true },
|
|
706
712
|
{
|
|
707
713
|
type: 'overflow-dropdown',
|
|
714
|
+
testId: overflowDropdownTestId,
|
|
708
715
|
dropdownWidth: 220,
|
|
709
716
|
options: [
|
|
710
717
|
{
|