@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
|
@@ -4,7 +4,7 @@ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, TA
|
|
|
4
4
|
import { browser } from '@atlaskit/editor-common/browser';
|
|
5
5
|
import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
|
|
6
6
|
import { getDomRefFromSelection } from '@atlaskit/editor-common/get-dom-ref-from-selection';
|
|
7
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
7
|
+
import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
8
8
|
import { IconTable } from '@atlaskit/editor-common/icons';
|
|
9
9
|
import { toggleTable, tooltip } from '@atlaskit/editor-common/keymaps';
|
|
10
10
|
import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
@@ -59,6 +59,19 @@ import { SizeSelector } from './ui/SizeSelector';
|
|
|
59
59
|
import { FullWidthDisplay } from './ui/TableFullWidthLabel';
|
|
60
60
|
import { getToolbarConfig } from './ui/toolbar';
|
|
61
61
|
const defaultGetEditorFeatureFlags = () => ({});
|
|
62
|
+
const useTableSharedState = sharedPluginStateHookMigratorFactory(api => {
|
|
63
|
+
const mode = useSharedPluginStateSelector(api, 'editorViewMode.mode');
|
|
64
|
+
return {
|
|
65
|
+
mode
|
|
66
|
+
};
|
|
67
|
+
}, api => {
|
|
68
|
+
const {
|
|
69
|
+
editorViewModeState
|
|
70
|
+
} = useSharedPluginState(api, ['editorViewMode']);
|
|
71
|
+
return {
|
|
72
|
+
mode: editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode
|
|
73
|
+
};
|
|
74
|
+
});
|
|
62
75
|
|
|
63
76
|
/**
|
|
64
77
|
* Table plugin to be added to an `EditorPresetBuilder` and used with `ComposableEditor`
|
|
@@ -681,16 +694,8 @@ const tablePlugin = ({
|
|
|
681
694
|
editorView
|
|
682
695
|
}) {
|
|
683
696
|
const {
|
|
684
|
-
|
|
685
|
-
} =
|
|
686
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
|
|
687
|
-
});
|
|
688
|
-
|
|
689
|
-
// mode
|
|
690
|
-
const modeSelector = useSharedPluginStateSelector(api, 'editorViewMode.mode', {
|
|
691
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
692
|
-
});
|
|
693
|
-
const mode = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? modeSelector : editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode;
|
|
697
|
+
mode
|
|
698
|
+
} = useTableSharedState(api);
|
|
694
699
|
useEffect(() => {
|
|
695
700
|
const {
|
|
696
701
|
state,
|
|
@@ -2,7 +2,6 @@ import React from 'react';
|
|
|
2
2
|
import { ACTION_SUBJECT } from '@atlaskit/editor-common/analytics';
|
|
3
3
|
import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
|
|
4
4
|
import { akEditorFloatingPanelZIndex } from '@atlaskit/editor-shared-styles';
|
|
5
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
6
5
|
import FloatingContextualButton from './FloatingContextualButton';
|
|
7
6
|
import FloatingContextualMenu from './FloatingContextualMenu';
|
|
8
7
|
import FloatingDeleteButton from './FloatingDeleteButton';
|
|
@@ -28,72 +27,30 @@ const ContentComponentInternal = ({
|
|
|
28
27
|
var _api$analytics, _api$accessibilityUti;
|
|
29
28
|
const editorAnalyticsAPI = api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
|
|
30
29
|
const ariaNotifyPlugin = api === null || api === void 0 ? void 0 : (_api$accessibilityUti = api.accessibilityUtils) === null || _api$accessibilityUti === void 0 ? void 0 : _api$accessibilityUti.actions.ariaNotify;
|
|
31
|
-
const resizingTableLocalId = useInternalTablePluginStateSelector(api, 'resizingTableLocalId'
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
});
|
|
49
|
-
const targetCellPosition = useInternalTablePluginStateSelector(api, 'targetCellPosition', {
|
|
50
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
51
|
-
});
|
|
52
|
-
const isContextualMenuOpen = useInternalTablePluginStateSelector(api, 'isContextualMenuOpen', {
|
|
53
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
54
|
-
});
|
|
55
|
-
const tableRef = useInternalTablePluginStateSelector(api, 'tableRef', {
|
|
56
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
57
|
-
});
|
|
58
|
-
const pluginConfig = useInternalTablePluginStateSelector(api, 'pluginConfig', {
|
|
59
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
60
|
-
});
|
|
61
|
-
const insertColumnButtonIndex = useInternalTablePluginStateSelector(api, 'insertColumnButtonIndex', {
|
|
62
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
63
|
-
});
|
|
64
|
-
const insertRowButtonIndex = useInternalTablePluginStateSelector(api, 'insertRowButtonIndex', {
|
|
65
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
66
|
-
});
|
|
67
|
-
const isHeaderColumnEnabled = useInternalTablePluginStateSelector(api, 'isHeaderColumnEnabled', {
|
|
68
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
69
|
-
});
|
|
70
|
-
const isHeaderRowEnabled = useInternalTablePluginStateSelector(api, 'isHeaderRowEnabled', {
|
|
71
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
72
|
-
});
|
|
73
|
-
const isDragAndDropEnabled = useInternalTablePluginStateSelector(api, 'isDragAndDropEnabled', {
|
|
74
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
75
|
-
});
|
|
76
|
-
const tableWrapperTarget = useInternalTablePluginStateSelector(api, 'tableWrapperTarget', {
|
|
77
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
78
|
-
});
|
|
79
|
-
const isCellMenuOpenByKeyboard = useInternalTablePluginStateSelector(api, 'isCellMenuOpenByKeyboard', {
|
|
80
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
81
|
-
});
|
|
30
|
+
const resizingTableLocalId = useInternalTablePluginStateSelector(api, 'resizingTableLocalId');
|
|
31
|
+
const resizingTableRef = useInternalTablePluginStateSelector(api, 'resizingTableRef');
|
|
32
|
+
const isTableResizing = useInternalTablePluginStateSelector(api, 'isTableResizing');
|
|
33
|
+
const isResizing = useInternalTablePluginStateSelector(api, 'isResizing');
|
|
34
|
+
const widthToWidest = useInternalTablePluginStateSelector(api, 'widthToWidest');
|
|
35
|
+
const tableNode = useInternalTablePluginStateSelector(api, 'tableNode');
|
|
36
|
+
const targetCellPosition = useInternalTablePluginStateSelector(api, 'targetCellPosition');
|
|
37
|
+
const isContextualMenuOpen = useInternalTablePluginStateSelector(api, 'isContextualMenuOpen');
|
|
38
|
+
const tableRef = useInternalTablePluginStateSelector(api, 'tableRef');
|
|
39
|
+
const pluginConfig = useInternalTablePluginStateSelector(api, 'pluginConfig');
|
|
40
|
+
const insertColumnButtonIndex = useInternalTablePluginStateSelector(api, 'insertColumnButtonIndex');
|
|
41
|
+
const insertRowButtonIndex = useInternalTablePluginStateSelector(api, 'insertRowButtonIndex');
|
|
42
|
+
const isHeaderColumnEnabled = useInternalTablePluginStateSelector(api, 'isHeaderColumnEnabled');
|
|
43
|
+
const isHeaderRowEnabled = useInternalTablePluginStateSelector(api, 'isHeaderRowEnabled');
|
|
44
|
+
const isDragAndDropEnabled = useInternalTablePluginStateSelector(api, 'isDragAndDropEnabled');
|
|
45
|
+
const tableWrapperTarget = useInternalTablePluginStateSelector(api, 'tableWrapperTarget');
|
|
46
|
+
const isCellMenuOpenByKeyboard = useInternalTablePluginStateSelector(api, 'isCellMenuOpenByKeyboard');
|
|
82
47
|
const {
|
|
83
48
|
allowControls
|
|
84
49
|
} = pluginConfig !== null && pluginConfig !== void 0 ? pluginConfig : {};
|
|
85
|
-
const stickyHeader = useInternalTablePluginStateSelector(api, 'stickyHeader'
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
const
|
|
89
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
90
|
-
});
|
|
91
|
-
const dragMenuIndex = useInternalTablePluginStateSelector(api, 'dragMenuIndex', {
|
|
92
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
93
|
-
});
|
|
94
|
-
const isDragMenuOpen = useInternalTablePluginStateSelector(api, 'isDragMenuOpen', {
|
|
95
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
96
|
-
});
|
|
50
|
+
const stickyHeader = useInternalTablePluginStateSelector(api, 'stickyHeader');
|
|
51
|
+
const dragMenuDirection = useInternalTablePluginStateSelector(api, 'dragMenuDirection');
|
|
52
|
+
const dragMenuIndex = useInternalTablePluginStateSelector(api, 'dragMenuIndex');
|
|
53
|
+
const isDragMenuOpen = useInternalTablePluginStateSelector(api, 'isDragMenuOpen');
|
|
97
54
|
return /*#__PURE__*/React.createElement(React.Fragment, null, targetCellPosition && (tableRef || isCellMenuOpenByKeyboard) && !isResizing && options && options.allowContextualMenu && /*#__PURE__*/React.createElement(FloatingContextualButton, {
|
|
98
55
|
isNumberColumnEnabled: tableNode && tableNode.attrs.isNumberColumnEnabled,
|
|
99
56
|
editorView: editorView,
|
|
@@ -5,13 +5,12 @@ import classnames from 'classnames';
|
|
|
5
5
|
import ReactDOM from 'react-dom';
|
|
6
6
|
import { injectIntl } from 'react-intl-next';
|
|
7
7
|
import { browser } from '@atlaskit/editor-common/browser';
|
|
8
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
8
|
+
import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
9
9
|
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
10
10
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
11
11
|
import { findTable, TableMap } from '@atlaskit/editor-tables';
|
|
12
12
|
import { draggable } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
13
13
|
import { setCustomNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview';
|
|
14
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
15
14
|
import { getPluginState as getDnDPluginState } from '../../pm-plugins/drag-and-drop/plugin-factory';
|
|
16
15
|
import { getPluginState } from '../../pm-plugins/plugin-factory';
|
|
17
16
|
import { findDuplicatePosition, hasMergedCellsInSelection } from '../../pm-plugins/utils/merged-cells';
|
|
@@ -250,6 +249,23 @@ const DragHandleComponent = ({
|
|
|
250
249
|
height: previewHeight
|
|
251
250
|
}), previewContainer));
|
|
252
251
|
};
|
|
252
|
+
const useSharedState = sharedPluginStateHookMigratorFactory(api => {
|
|
253
|
+
const hoveredColumns = useInternalTablePluginStateSelector(api, 'hoveredColumns');
|
|
254
|
+
const hoveredRows = useInternalTablePluginStateSelector(api, 'hoveredRows');
|
|
255
|
+
return {
|
|
256
|
+
hoveredColumns,
|
|
257
|
+
hoveredRows
|
|
258
|
+
};
|
|
259
|
+
}, api => {
|
|
260
|
+
const {
|
|
261
|
+
tableState
|
|
262
|
+
} = useSharedPluginState(api, ['table']);
|
|
263
|
+
const tableStateInternal = tableState;
|
|
264
|
+
return {
|
|
265
|
+
hoveredColumns: tableStateInternal === null || tableStateInternal === void 0 ? void 0 : tableStateInternal.hoveredColumns,
|
|
266
|
+
hoveredRows: tableStateInternal === null || tableStateInternal === void 0 ? void 0 : tableStateInternal.hoveredRows
|
|
267
|
+
};
|
|
268
|
+
});
|
|
253
269
|
const DragHandleComponentWithSharedState = ({
|
|
254
270
|
isDragMenuTarget,
|
|
255
271
|
tableLocalId,
|
|
@@ -269,22 +285,9 @@ const DragHandleComponentWithSharedState = ({
|
|
|
269
285
|
api
|
|
270
286
|
}) => {
|
|
271
287
|
const {
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
// hoveredColumns
|
|
278
|
-
const hoveredColumnsSelector = useInternalTablePluginStateSelector(api, 'hoveredColumns', {
|
|
279
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
280
|
-
});
|
|
281
|
-
const hoveredColumns = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? hoveredColumnsSelector : tableState === null || tableState === void 0 ? void 0 : tableState.hoveredColumns;
|
|
282
|
-
|
|
283
|
-
// hoveredRows
|
|
284
|
-
const hoveredRowsSelector = useInternalTablePluginStateSelector(api, 'hoveredRows', {
|
|
285
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
286
|
-
});
|
|
287
|
-
const hoveredRows = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? hoveredRowsSelector : tableState === null || tableState === void 0 ? void 0 : tableState.hoveredRows;
|
|
288
|
+
hoveredColumns,
|
|
289
|
+
hoveredRows
|
|
290
|
+
} = useSharedState(api);
|
|
288
291
|
return /*#__PURE__*/React.createElement(DragHandleComponent, {
|
|
289
292
|
isDragMenuTarget: isDragMenuTarget,
|
|
290
293
|
tableLocalId: tableLocalId,
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
/* eslint-disable @atlaskit/design-system/prefer-primitives */
|
|
2
2
|
|
|
3
3
|
import React, { useCallback, useMemo, useRef } from 'react';
|
|
4
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
4
|
+
import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
5
5
|
import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
6
6
|
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
7
7
|
import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
|
|
8
8
|
import { CellSelection } from '@atlaskit/editor-tables';
|
|
9
9
|
import { getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
10
10
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
11
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
12
11
|
import { clearHoverSelection, hoverCell, hoverColumns, selectColumn, selectColumns } from '../../../pm-plugins/commands';
|
|
13
12
|
import { toggleDragMenu } from '../../../pm-plugins/drag-and-drop/commands';
|
|
14
13
|
import { getRowsParams } from '../../../pm-plugins/utils/row-controls';
|
|
@@ -25,6 +24,19 @@ const getSelectedColumns = selection => {
|
|
|
25
24
|
}
|
|
26
25
|
return [];
|
|
27
26
|
};
|
|
27
|
+
const useSharedState = sharedPluginStateHookMigratorFactory(api => {
|
|
28
|
+
const selection = useSharedPluginStateSelector(api, 'selection.selection');
|
|
29
|
+
return {
|
|
30
|
+
selection
|
|
31
|
+
};
|
|
32
|
+
}, api => {
|
|
33
|
+
const {
|
|
34
|
+
selectionState
|
|
35
|
+
} = useSharedPluginState(api, ['selection']);
|
|
36
|
+
return {
|
|
37
|
+
selection: selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection
|
|
38
|
+
};
|
|
39
|
+
});
|
|
28
40
|
export const ColumnControls = ({
|
|
29
41
|
editorView,
|
|
30
42
|
tableActive,
|
|
@@ -44,17 +56,9 @@ export const ColumnControls = ({
|
|
|
44
56
|
}) => {
|
|
45
57
|
var _colWidths$map$join;
|
|
46
58
|
const columnControlsRef = useRef(null);
|
|
47
|
-
|
|
48
|
-
// selection
|
|
49
59
|
const {
|
|
50
|
-
|
|
51
|
-
} =
|
|
52
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
|
|
53
|
-
});
|
|
54
|
-
const selectionsSelector = useSharedPluginStateSelector(api, 'selection.selection', {
|
|
55
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
56
|
-
});
|
|
57
|
-
const selection = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? selectionsSelector : selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection;
|
|
60
|
+
selection
|
|
61
|
+
} = useSharedState(api);
|
|
58
62
|
const widths = (_colWidths$map$join = colWidths === null || colWidths === void 0 ? void 0 : colWidths.map(width =>
|
|
59
63
|
// when there is sticky header, a `margin-right: -1px` applied to `tr.sticky th` so it causes colWidths to be 1px wider
|
|
60
64
|
// we need to reduce the width by 1px to avoid misalignment of column controls.
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import React, { useMemo } from 'react';
|
|
2
2
|
import classnames from 'classnames';
|
|
3
3
|
import { injectIntl } from 'react-intl-next';
|
|
4
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
4
|
+
import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
5
5
|
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
6
6
|
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
7
7
|
import { findTable, isTableSelected, selectTable } from '@atlaskit/editor-tables/utils';
|
|
8
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
9
8
|
import { clearHoverSelection } from '../../../pm-plugins/commands';
|
|
10
9
|
import { TableCssClassName as ClassName } from '../../../types';
|
|
11
10
|
const DragCornerControlsComponent = ({
|
|
@@ -60,6 +59,19 @@ const DragCornerControlsComponent = ({
|
|
|
60
59
|
className: ClassName.DRAG_CORNER_BUTTON_INNER
|
|
61
60
|
}));
|
|
62
61
|
};
|
|
62
|
+
const useSharedState = sharedPluginStateHookMigratorFactory(api => {
|
|
63
|
+
const selectionsSelector = useSharedPluginStateSelector(api, 'selection.selection');
|
|
64
|
+
return {
|
|
65
|
+
selection: selectionsSelector
|
|
66
|
+
};
|
|
67
|
+
}, api => {
|
|
68
|
+
const {
|
|
69
|
+
selectionState
|
|
70
|
+
} = useSharedPluginState(api, ['selection']);
|
|
71
|
+
return {
|
|
72
|
+
selection: selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection
|
|
73
|
+
};
|
|
74
|
+
});
|
|
63
75
|
const DragCornerControlsComponentWithSelection = ({
|
|
64
76
|
editorView,
|
|
65
77
|
isInDanger,
|
|
@@ -69,16 +81,9 @@ const DragCornerControlsComponentWithSelection = ({
|
|
|
69
81
|
},
|
|
70
82
|
api
|
|
71
83
|
}) => {
|
|
72
|
-
// selection
|
|
73
84
|
const {
|
|
74
|
-
|
|
75
|
-
} =
|
|
76
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
|
|
77
|
-
});
|
|
78
|
-
const selectionsSelector = useSharedPluginStateSelector(api, 'selection.selection', {
|
|
79
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
80
|
-
});
|
|
81
|
-
const selection = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? selectionsSelector : selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection;
|
|
85
|
+
selection
|
|
86
|
+
} = useSharedState(api);
|
|
82
87
|
const handleOnClick = () => {
|
|
83
88
|
const {
|
|
84
89
|
state,
|
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
2
|
+
import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
3
3
|
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
4
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
5
4
|
import { CornerControls } from './CornerControls/ClassicCornerControls';
|
|
6
5
|
import { RowControls } from './RowControls/ClassicControls';
|
|
6
|
+
const useSharedState = sharedPluginStateHookMigratorFactory(api => {
|
|
7
|
+
const selectionsSelector = useSharedPluginStateSelector(api, 'selection.selection');
|
|
8
|
+
return {
|
|
9
|
+
selection: selectionsSelector
|
|
10
|
+
};
|
|
11
|
+
}, api => {
|
|
12
|
+
const {
|
|
13
|
+
selectionState
|
|
14
|
+
} = useSharedPluginState(api, ['selection']);
|
|
15
|
+
return {
|
|
16
|
+
selection: selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection
|
|
17
|
+
};
|
|
18
|
+
});
|
|
7
19
|
export const FloatingControlsWithSelection = ({
|
|
8
20
|
editorView,
|
|
9
21
|
tableRef,
|
|
@@ -18,16 +30,9 @@ export const FloatingControlsWithSelection = ({
|
|
|
18
30
|
tableActive,
|
|
19
31
|
api
|
|
20
32
|
}) => {
|
|
21
|
-
// selection
|
|
22
33
|
const {
|
|
23
|
-
|
|
24
|
-
} =
|
|
25
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
|
|
26
|
-
});
|
|
27
|
-
const selectionsSelector = useSharedPluginStateSelector(api, 'selection.selection', {
|
|
28
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
29
|
-
});
|
|
30
|
-
const selection = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? selectionsSelector : selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection;
|
|
34
|
+
selection
|
|
35
|
+
} = useSharedState(api);
|
|
31
36
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CornerControls, {
|
|
32
37
|
editorView: editorView,
|
|
33
38
|
tableRef: tableRef,
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
/* eslint-disable @atlaskit/design-system/prefer-primitives */
|
|
2
2
|
|
|
3
3
|
import React, { Fragment, useCallback, useEffect, useMemo, useState } from 'react';
|
|
4
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
4
|
+
import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
5
5
|
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
6
6
|
import { CellSelection } from '@atlaskit/editor-tables';
|
|
7
7
|
import { getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
8
8
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
9
|
import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
10
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
11
10
|
import { clearHoverSelection } from '../../../pm-plugins/commands';
|
|
12
11
|
import { toggleDragMenu } from '../../../pm-plugins/drag-and-drop/commands';
|
|
13
12
|
import { getPluginState as getTablePluginState } from '../../../pm-plugins/plugin-factory';
|
|
@@ -277,6 +276,19 @@ export const DragControls = ({
|
|
|
277
276
|
}))), rowHandles())
|
|
278
277
|
);
|
|
279
278
|
};
|
|
279
|
+
const useSharedState = sharedPluginStateHookMigratorFactory(api => {
|
|
280
|
+
const selectionsSelector = useSharedPluginStateSelector(api, 'selection.selection');
|
|
281
|
+
return {
|
|
282
|
+
selection: selectionsSelector
|
|
283
|
+
};
|
|
284
|
+
}, api => {
|
|
285
|
+
const {
|
|
286
|
+
selectionState
|
|
287
|
+
} = useSharedPluginState(api, ['selection']);
|
|
288
|
+
return {
|
|
289
|
+
selection: selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection
|
|
290
|
+
};
|
|
291
|
+
});
|
|
280
292
|
export const DragControlsWithSelection = ({
|
|
281
293
|
editorView,
|
|
282
294
|
tableRef,
|
|
@@ -293,16 +305,9 @@ export const DragControlsWithSelection = ({
|
|
|
293
305
|
updateCellHoverLocation,
|
|
294
306
|
api
|
|
295
307
|
}) => {
|
|
296
|
-
// selection
|
|
297
308
|
const {
|
|
298
|
-
|
|
299
|
-
} =
|
|
300
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
|
|
301
|
-
});
|
|
302
|
-
const selectionsSelector = useSharedPluginStateSelector(api, 'selection.selection', {
|
|
303
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
304
|
-
});
|
|
305
|
-
const selection = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? selectionsSelector : selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection;
|
|
309
|
+
selection
|
|
310
|
+
} = useSharedState(api);
|
|
306
311
|
return /*#__PURE__*/React.createElement(DragControls, {
|
|
307
312
|
editorView: editorView,
|
|
308
313
|
tableRef: tableRef,
|
|
@@ -4,25 +4,30 @@
|
|
|
4
4
|
*/
|
|
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
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
7
|
+
import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
8
8
|
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
9
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
10
9
|
import { tableStyles } from './common-styles';
|
|
10
|
+
const useSharedState = sharedPluginStateHookMigratorFactory(api => {
|
|
11
|
+
const mode = useSharedPluginStateSelector(api, 'editorViewMode.mode');
|
|
12
|
+
return {
|
|
13
|
+
mode
|
|
14
|
+
};
|
|
15
|
+
}, api => {
|
|
16
|
+
const {
|
|
17
|
+
editorViewModeState
|
|
18
|
+
} = useSharedPluginState(api, ['editorViewMode']);
|
|
19
|
+
return {
|
|
20
|
+
mode: editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode
|
|
21
|
+
};
|
|
22
|
+
});
|
|
11
23
|
export const GlobalStylesWrapper = ({
|
|
12
24
|
featureFlags,
|
|
13
25
|
isDragAndDropEnabledOption,
|
|
14
26
|
api
|
|
15
27
|
}) => {
|
|
16
|
-
// mode
|
|
17
28
|
const {
|
|
18
|
-
|
|
19
|
-
} =
|
|
20
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
|
|
21
|
-
});
|
|
22
|
-
const modeSelector = useSharedPluginStateSelector(api, 'editorViewMode.mode', {
|
|
23
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
24
|
-
});
|
|
25
|
-
const mode = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? modeSelector : editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode;
|
|
29
|
+
mode
|
|
30
|
+
} = useSharedState(api);
|
|
26
31
|
const isLivePageViewMode = mode === 'view';
|
|
27
32
|
return jsx(Global, {
|
|
28
33
|
styles: tableStyles({
|
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
2
|
+
import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
3
3
|
import { SortingIcon } from '@atlaskit/editor-common/table';
|
|
4
4
|
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
const useSharedState = sharedPluginStateHookMigratorFactory(api => {
|
|
6
|
+
const mode = useSharedPluginStateSelector(api, 'editorViewMode.mode');
|
|
7
|
+
return {
|
|
8
|
+
mode
|
|
9
|
+
};
|
|
10
|
+
}, api => {
|
|
7
11
|
const {
|
|
8
12
|
editorViewModeState
|
|
9
|
-
} = useSharedPluginState(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
} = useSharedPluginState(api, ['editorViewMode']);
|
|
14
|
+
return {
|
|
15
|
+
mode: editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode
|
|
16
|
+
};
|
|
17
|
+
});
|
|
18
|
+
export const SortingIconWrapper = props => {
|
|
19
|
+
const {
|
|
20
|
+
mode
|
|
21
|
+
} = useSharedState(props.api);
|
|
18
22
|
if (mode === 'edit') {
|
|
19
23
|
return null;
|
|
20
24
|
}
|
|
@@ -464,6 +464,10 @@ export const getToolbarConfig = (getEditorContainerWidth, api, editorAnalyticsAP
|
|
|
464
464
|
onBlur: clearHoverSelection()
|
|
465
465
|
});
|
|
466
466
|
const shouldGroupWithoutSeparators = editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_6');
|
|
467
|
+
|
|
468
|
+
// testId is required to show focus on trigger button on ESC key press
|
|
469
|
+
// see hideOnEsc in platform/packages/editor/editor-plugin-floating-toolbar/src/ui/Dropdown.tsx
|
|
470
|
+
const overflowDropdownTestId = fg('platform_editor_controls_patch_8') ? 'table-overflow-dropdown-trigger' : undefined;
|
|
467
471
|
return {
|
|
468
472
|
title: toolbarTitle,
|
|
469
473
|
getDomRef,
|
|
@@ -484,6 +488,7 @@ export const getToolbarConfig = (getEditorContainerWidth, api, editorAnalyticsAP
|
|
|
484
488
|
fullHeight: true
|
|
485
489
|
}, {
|
|
486
490
|
type: 'overflow-dropdown',
|
|
491
|
+
testId: overflowDropdownTestId,
|
|
487
492
|
dropdownWidth: 220,
|
|
488
493
|
options: [{
|
|
489
494
|
type: 'custom',
|