@atlaskit/editor-plugin-table 10.9.20 → 10.9.22
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 +21 -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/pm-plugins/main.js +4 -12
- package/dist/cjs/tablePlugin.js +22 -12
- package/dist/cjs/ui/ContentComponent.js +40 -65
- 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/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/pm-plugins/main.js +4 -12
- package/dist/es2019/tablePlugin.js +24 -13
- package/dist/es2019/ui/ContentComponent.js +41 -66
- 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/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/pm-plugins/main.js +4 -12
- package/dist/esm/tablePlugin.js +23 -13
- package/dist/esm/ui/ContentComponent.js +41 -66
- 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/types/types/index.d.ts +2 -0
- package/dist/types/ui/ContentComponent.d.ts +2 -1
- package/dist/types/ui/hooks/useInternalTablePluginStateSelector.d.ts +1 -1
- package/dist/types-ts4.5/types/index.d.ts +2 -0
- package/dist/types-ts4.5/ui/ContentComponent.d.ts +2 -1
- package/dist/types-ts4.5/ui/hooks/useInternalTablePluginStateSelector.d.ts +1 -1
- package/package.json +4 -7
- package/src/nodeviews/TableComponentWithSharedState.tsx +97 -125
- package/src/nodeviews/TableContainer.tsx +59 -67
- package/src/nodeviews/TableResizer.tsx +21 -17
- package/src/pm-plugins/main.ts +5 -13
- package/src/tablePlugin.tsx +30 -13
- package/src/types/index.ts +2 -0
- package/src/ui/ContentComponent.tsx +59 -65
- package/src/ui/DragHandle/index.tsx +24 -24
- package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +20 -13
- 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
|
@@ -1,5 +1,5 @@
|
|
|
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
4
|
import { findTable } from '@atlaskit/editor-tables';
|
|
5
5
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
@@ -9,6 +9,80 @@ import TableComponent from './TableComponent';
|
|
|
9
9
|
// Ignored via go/ees005
|
|
10
10
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11
11
|
|
|
12
|
+
const useSharedState = sharedPluginStateHookMigratorFactory(api => {
|
|
13
|
+
// tableState
|
|
14
|
+
const isTableResizing = useInternalTablePluginStateSelector(api, 'isTableResizing');
|
|
15
|
+
const isHeaderColumnEnabled = useInternalTablePluginStateSelector(api, 'isHeaderColumnEnabled');
|
|
16
|
+
const isHeaderRowEnabled = useInternalTablePluginStateSelector(api, 'isHeaderRowEnabled');
|
|
17
|
+
const ordering = useInternalTablePluginStateSelector(api, 'ordering');
|
|
18
|
+
const isResizing = useInternalTablePluginStateSelector(api, 'isResizing');
|
|
19
|
+
const isInDanger = useInternalTablePluginStateSelector(api, 'isInDanger');
|
|
20
|
+
const hoveredCell = useInternalTablePluginStateSelector(api, 'hoveredCell');
|
|
21
|
+
const hoveredRows = useInternalTablePluginStateSelector(api, 'hoveredRows');
|
|
22
|
+
const isTableHovered = useInternalTablePluginStateSelector(api, 'isTableHovered');
|
|
23
|
+
const isWholeTableInDanger = useInternalTablePluginStateSelector(api, 'isWholeTableInDanger');
|
|
24
|
+
|
|
25
|
+
// mediaState
|
|
26
|
+
const isFullscreen = useSharedPluginStateSelector(api, 'media.isFullscreen');
|
|
27
|
+
|
|
28
|
+
// selectionState
|
|
29
|
+
const selection = useSharedPluginStateSelector(api, 'selection.selection');
|
|
30
|
+
|
|
31
|
+
// editorViewModeState
|
|
32
|
+
const mode = useSharedPluginStateSelector(api, 'editorViewMode.mode');
|
|
33
|
+
|
|
34
|
+
// widthState
|
|
35
|
+
const width = useSharedPluginStateSelector(api, 'width.width');
|
|
36
|
+
const lineLength = useSharedPluginStateSelector(api, 'width.lineLength');
|
|
37
|
+
return {
|
|
38
|
+
tableState: undefined,
|
|
39
|
+
widthState: undefined,
|
|
40
|
+
isTableResizing,
|
|
41
|
+
isHeaderColumnEnabled,
|
|
42
|
+
isHeaderRowEnabled,
|
|
43
|
+
ordering,
|
|
44
|
+
isResizing,
|
|
45
|
+
isInDanger,
|
|
46
|
+
hoveredCell,
|
|
47
|
+
hoveredRows,
|
|
48
|
+
isTableHovered,
|
|
49
|
+
isWholeTableInDanger,
|
|
50
|
+
isFullscreen,
|
|
51
|
+
selection,
|
|
52
|
+
mode,
|
|
53
|
+
width,
|
|
54
|
+
lineLength
|
|
55
|
+
};
|
|
56
|
+
}, api => {
|
|
57
|
+
const {
|
|
58
|
+
widthState,
|
|
59
|
+
tableState,
|
|
60
|
+
mediaState,
|
|
61
|
+
selectionState,
|
|
62
|
+
editorViewModeState
|
|
63
|
+
} = useSharedPluginState(api, ['width', 'table', 'media', 'selection', 'editorViewMode']);
|
|
64
|
+
const tableStateInternal = tableState;
|
|
65
|
+
return {
|
|
66
|
+
tableState,
|
|
67
|
+
widthState,
|
|
68
|
+
isTableResizing: tableStateInternal === null || tableStateInternal === void 0 ? void 0 : tableStateInternal.isTableResizing,
|
|
69
|
+
isHeaderColumnEnabled: tableStateInternal === null || tableStateInternal === void 0 ? void 0 : tableStateInternal.isHeaderColumnEnabled,
|
|
70
|
+
isHeaderRowEnabled: tableStateInternal === null || tableStateInternal === void 0 ? void 0 : tableStateInternal.isHeaderRowEnabled,
|
|
71
|
+
ordering: tableStateInternal === null || tableStateInternal === void 0 ? void 0 : tableStateInternal.ordering,
|
|
72
|
+
isResizing: tableStateInternal === null || tableStateInternal === void 0 ? void 0 : tableStateInternal.isResizing,
|
|
73
|
+
isInDanger: tableStateInternal === null || tableStateInternal === void 0 ? void 0 : tableStateInternal.isInDanger,
|
|
74
|
+
hoveredCell: tableStateInternal === null || tableStateInternal === void 0 ? void 0 : tableStateInternal.hoveredCell,
|
|
75
|
+
hoveredRows: tableStateInternal === null || tableStateInternal === void 0 ? void 0 : tableStateInternal.hoveredRows,
|
|
76
|
+
isTableHovered: tableStateInternal === null || tableStateInternal === void 0 ? void 0 : tableStateInternal.isTableHovered,
|
|
77
|
+
isWholeTableInDanger: tableStateInternal === null || tableStateInternal === void 0 ? void 0 : tableStateInternal.isWholeTableInDanger,
|
|
78
|
+
isFullscreen: mediaState === null || mediaState === void 0 ? void 0 : mediaState.isFullscreen,
|
|
79
|
+
selection: selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection,
|
|
80
|
+
mode: editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode,
|
|
81
|
+
width: widthState === null || widthState === void 0 ? void 0 : widthState.width,
|
|
82
|
+
lineLength: widthState === null || widthState === void 0 ? void 0 : widthState.lineLength
|
|
83
|
+
};
|
|
84
|
+
});
|
|
85
|
+
|
|
12
86
|
/**
|
|
13
87
|
* Use useSharedPluginState to control re-renders from plugin dependencies
|
|
14
88
|
*/
|
|
@@ -28,89 +102,29 @@ export const TableComponentWithSharedState = ({
|
|
|
28
102
|
allowTableResizing
|
|
29
103
|
}) => {
|
|
30
104
|
const {
|
|
31
|
-
widthState,
|
|
32
105
|
tableState,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
});
|
|
51
|
-
const isResizingSelector = useInternalTablePluginStateSelector(api, 'isResizing', {
|
|
52
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
53
|
-
});
|
|
54
|
-
const isInDangerSelector = useInternalTablePluginStateSelector(api, 'isInDanger', {
|
|
55
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
56
|
-
});
|
|
57
|
-
const hoveredCellSelector = useInternalTablePluginStateSelector(api, 'hoveredCell', {
|
|
58
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
59
|
-
});
|
|
60
|
-
const hoveredRowsSelector = useInternalTablePluginStateSelector(api, 'hoveredRows', {
|
|
61
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
62
|
-
});
|
|
63
|
-
const isTableHoveredSelector = useInternalTablePluginStateSelector(api, 'isTableHovered', {
|
|
64
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
65
|
-
});
|
|
66
|
-
const isWholeTableInDangerSelector = useInternalTablePluginStateSelector(api, 'isWholeTableInDanger', {
|
|
67
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
// mediaState
|
|
71
|
-
const isFullscreenSelector = useSharedPluginStateSelector(api, 'media.isFullscreen', {
|
|
72
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
73
|
-
});
|
|
74
|
-
const isFullscreen = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isFullscreenSelector : mediaState === null || mediaState === void 0 ? void 0 : mediaState.isFullscreen;
|
|
75
|
-
|
|
76
|
-
// selectionState
|
|
77
|
-
const selectionSelector = useSharedPluginStateSelector(api, 'selection.selection', {
|
|
78
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
79
|
-
});
|
|
80
|
-
const selection = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? selectionSelector : selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection;
|
|
81
|
-
|
|
82
|
-
// editorViewModeState
|
|
83
|
-
const editorViewModeSelector = useSharedPluginStateSelector(api, 'editorViewMode.mode', {
|
|
84
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
85
|
-
});
|
|
86
|
-
const mode = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? editorViewModeSelector : editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode;
|
|
106
|
+
widthState,
|
|
107
|
+
mode,
|
|
108
|
+
hoveredCell,
|
|
109
|
+
hoveredRows,
|
|
110
|
+
isFullscreen,
|
|
111
|
+
isHeaderColumnEnabled,
|
|
112
|
+
isHeaderRowEnabled,
|
|
113
|
+
isInDanger,
|
|
114
|
+
isResizing,
|
|
115
|
+
isTableHovered,
|
|
116
|
+
isTableResizing,
|
|
117
|
+
isWholeTableInDanger,
|
|
118
|
+
lineLength,
|
|
119
|
+
ordering,
|
|
120
|
+
selection,
|
|
121
|
+
width
|
|
122
|
+
} = useSharedState(api);
|
|
87
123
|
const isLivePageViewMode = mode === 'view';
|
|
88
|
-
|
|
89
|
-
// widthState
|
|
90
|
-
const widthSelector = useSharedPluginStateSelector(api, 'width.width', {
|
|
91
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
92
|
-
});
|
|
93
|
-
const width = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? widthSelector : widthState === null || widthState === void 0 ? void 0 : widthState.width;
|
|
94
|
-
const lineLengthSelector = useSharedPluginStateSelector(api, 'width.lineLength', {
|
|
95
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
96
|
-
});
|
|
97
|
-
const lineLength = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? lineLengthSelector : widthState === null || widthState === void 0 ? void 0 : widthState.lineLength;
|
|
98
124
|
if (editorExperiment('platform_editor_usesharedpluginstateselector', false) && !tableState) {
|
|
99
125
|
return null;
|
|
100
126
|
}
|
|
101
127
|
|
|
102
|
-
// tableState
|
|
103
|
-
const isTableResizing = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isTableResizingSelector : tableState.isTableResizing;
|
|
104
|
-
const isHeaderColumnEnabled = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isHeaderColumnEnabledSelector : tableState.isHeaderColumnEnabled;
|
|
105
|
-
const isHeaderRowEnabled = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isHeaderRowEnabledSelector : tableState.isHeaderRowEnabled;
|
|
106
|
-
const ordering = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? orderingSelector : tableState.ordering;
|
|
107
|
-
const isResizing = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isResizingSelector : tableState.isResizing;
|
|
108
|
-
const isInDanger = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isInDangerSelector : tableState.isInDanger;
|
|
109
|
-
const hoveredCell = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? hoveredCellSelector : tableState.hoveredCell;
|
|
110
|
-
const hoveredRows = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? hoveredRowsSelector : tableState.hoveredRows;
|
|
111
|
-
const isTableHovered = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isTableHoveredSelector : tableState.isTableHovered;
|
|
112
|
-
const isWholeTableInDanger = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isWholeTableInDangerSelector : tableState.isWholeTableInDanger;
|
|
113
|
-
|
|
114
128
|
/**
|
|
115
129
|
* ED-19810
|
|
116
130
|
* There is a getPos issue coming from this code. We need to apply this workaround for now and apply a patch
|
|
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
import React, { forwardRef, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import { CHANGE_ALIGNMENT_REASON, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
5
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
5
|
+
import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
6
6
|
import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
|
|
7
7
|
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
8
8
|
import { akEditorDefaultLayoutWidth, akEditorGutterPaddingDynamic, akEditorMobileBreakoutPoint } from '@atlaskit/editor-shared-styles';
|
|
@@ -34,6 +34,24 @@ const InnerContainer = /*#__PURE__*/forwardRef(({
|
|
|
34
34
|
"data-testid": "table-container"
|
|
35
35
|
}, children);
|
|
36
36
|
});
|
|
37
|
+
const useAlignmentStableContainerSharedState = sharedPluginStateHookMigratorFactory(pluginInjectionApi => {
|
|
38
|
+
const isFullWidthModeEnabled = useSharedPluginStateSelector(pluginInjectionApi, 'table.isFullWidthModeEnabled');
|
|
39
|
+
const wasFullWidthModeEnabled = useSharedPluginStateSelector(pluginInjectionApi, 'table.wasFullWidthModeEnabled');
|
|
40
|
+
return {
|
|
41
|
+
tableState: undefined,
|
|
42
|
+
isFullWidthModeEnabled,
|
|
43
|
+
wasFullWidthModeEnabled
|
|
44
|
+
};
|
|
45
|
+
}, pluginInjectionApi => {
|
|
46
|
+
const {
|
|
47
|
+
tableState
|
|
48
|
+
} = useSharedPluginState(pluginInjectionApi, ['table']);
|
|
49
|
+
return {
|
|
50
|
+
tableState,
|
|
51
|
+
isFullWidthModeEnabled: tableState === null || tableState === void 0 ? void 0 : tableState.isFullWidthModeEnabled,
|
|
52
|
+
wasFullWidthModeEnabled: tableState === null || tableState === void 0 ? void 0 : tableState.wasFullWidthModeEnabled
|
|
53
|
+
};
|
|
54
|
+
});
|
|
37
55
|
const AlignmentTableContainer = ({
|
|
38
56
|
node,
|
|
39
57
|
children,
|
|
@@ -43,22 +61,10 @@ const AlignmentTableContainer = ({
|
|
|
43
61
|
}) => {
|
|
44
62
|
const alignment = node.attrs.layout !== ALIGN_START ? ALIGN_CENTER : ALIGN_START;
|
|
45
63
|
const {
|
|
46
|
-
tableState
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
// isFullWidthModeEnabled
|
|
52
|
-
const isTableFullWidthModeEnabledSelector = useSharedPluginStateSelector(pluginInjectionApi, 'table.isFullWidthModeEnabled', {
|
|
53
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
54
|
-
});
|
|
55
|
-
const isFullWidthModeEnabled = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isTableFullWidthModeEnabledSelector : tableState === null || tableState === void 0 ? void 0 : tableState.isFullWidthModeEnabled;
|
|
56
|
-
|
|
57
|
-
// wasFullWidthModeEnabled
|
|
58
|
-
const wasFullWidthModeEnabledSelector = useSharedPluginStateSelector(pluginInjectionApi, 'table.wasFullWidthModeEnabled', {
|
|
59
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
60
|
-
});
|
|
61
|
-
const wasFullWidthModeEnabled = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? wasFullWidthModeEnabledSelector : tableState === null || tableState === void 0 ? void 0 : tableState.wasFullWidthModeEnabled;
|
|
64
|
+
tableState,
|
|
65
|
+
isFullWidthModeEnabled,
|
|
66
|
+
wasFullWidthModeEnabled
|
|
67
|
+
} = useAlignmentStableContainerSharedState(pluginInjectionApi);
|
|
62
68
|
useEffect(() => {
|
|
63
69
|
if (!tableState && editorExperiment('platform_editor_usesharedpluginstateselector', false)) {
|
|
64
70
|
return;
|
|
@@ -120,6 +126,23 @@ const AlignmentTableContainerWrapper = ({
|
|
|
120
126
|
editorView: editorView
|
|
121
127
|
}, children);
|
|
122
128
|
};
|
|
129
|
+
const useResizeableTableContainerSharedState = sharedPluginStateHookMigratorFactory(pluginInjectionApi => {
|
|
130
|
+
const isFullWidthModeEnabled = useSharedPluginStateSelector(pluginInjectionApi, 'table.isFullWidthModeEnabled');
|
|
131
|
+
const mode = useSharedPluginStateSelector(pluginInjectionApi, 'editorViewMode.mode');
|
|
132
|
+
return {
|
|
133
|
+
isFullWidthModeEnabled,
|
|
134
|
+
mode
|
|
135
|
+
};
|
|
136
|
+
}, pluginInjectionApi => {
|
|
137
|
+
const {
|
|
138
|
+
tableState,
|
|
139
|
+
editorViewModeState
|
|
140
|
+
} = useSharedPluginState(pluginInjectionApi, ['table', 'editorViewMode']);
|
|
141
|
+
return {
|
|
142
|
+
isFullWidthModeEnabled: tableState === null || tableState === void 0 ? void 0 : tableState.isFullWidthModeEnabled,
|
|
143
|
+
mode: editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode
|
|
144
|
+
};
|
|
145
|
+
});
|
|
123
146
|
export const ResizableTableContainer = /*#__PURE__*/React.memo(({
|
|
124
147
|
children,
|
|
125
148
|
className,
|
|
@@ -143,16 +166,9 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
|
|
|
143
166
|
const tableWidthRef = useRef(akEditorDefaultLayoutWidth);
|
|
144
167
|
const [resizing, setIsResizing] = useState(false);
|
|
145
168
|
const {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
// isFullWidthModeEnabled
|
|
152
|
-
const isFullWidthModeEnabledSelector = useSharedPluginStateSelector(pluginInjectionApi, 'table.isFullWidthModeEnabled', {
|
|
153
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
154
|
-
});
|
|
155
|
-
const isFullWidthModeEnabled = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isFullWidthModeEnabledSelector : tableState === null || tableState === void 0 ? void 0 : tableState.isFullWidthModeEnabled;
|
|
169
|
+
isFullWidthModeEnabled,
|
|
170
|
+
mode
|
|
171
|
+
} = useResizeableTableContainerSharedState(pluginInjectionApi);
|
|
156
172
|
const updateContainerHeight = useCallback(height => {
|
|
157
173
|
var _containerRef$current;
|
|
158
174
|
// current StickyHeader State is not stable to be fetch.
|
|
@@ -206,17 +222,6 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
|
|
|
206
222
|
return (_pluginInjectionApi$c = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$c2 = pluginInjectionApi.core) === null || _pluginInjectionApi$c2 === void 0 ? void 0 : _pluginInjectionApi$c2.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$s = pluginInjectionApi.selection) === null || _pluginInjectionApi$s === void 0 ? void 0 : _pluginInjectionApi$s.commands.displayGapCursor(toggle))) !== null && _pluginInjectionApi$c !== void 0 ? _pluginInjectionApi$c : false;
|
|
207
223
|
}, [pluginInjectionApi]);
|
|
208
224
|
const tableWidth = getTableContainerWidth(node);
|
|
209
|
-
const {
|
|
210
|
-
editorViewModeState
|
|
211
|
-
} = useSharedPluginState(pluginInjectionApi, ['editorViewMode'], {
|
|
212
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
// mode
|
|
216
|
-
const modeSelector = useSharedPluginStateSelector(pluginInjectionApi, 'editorViewMode.mode', {
|
|
217
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
218
|
-
});
|
|
219
|
-
const mode = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? modeSelector : editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode;
|
|
220
225
|
let responsiveContainerWidth = 0;
|
|
221
226
|
const resizeHandleSpacing = 12;
|
|
222
227
|
// When Full width editor enabled, a Mac OS user can change "ak-editor-content-area" width by
|
|
@@ -267,7 +272,7 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
|
|
|
267
272
|
onResizeStop,
|
|
268
273
|
isCommentEditor
|
|
269
274
|
};
|
|
270
|
-
const isLivePageViewMode =
|
|
275
|
+
const isLivePageViewMode = mode === 'view';
|
|
271
276
|
return /*#__PURE__*/React.createElement(AlignmentTableContainerWrapper, {
|
|
272
277
|
isTableAlignmentEnabled: isTableAlignmentEnabled,
|
|
273
278
|
node: node,
|
|
@@ -4,7 +4,7 @@ import { useIntl } from 'react-intl-next';
|
|
|
4
4
|
import { CHANGE_ALIGNMENT_REASON, INPUT_METHOD, TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
|
|
5
5
|
import { browser } from '@atlaskit/editor-common/browser';
|
|
6
6
|
import { getGuidelinesWithHighlights } from '@atlaskit/editor-common/guideline';
|
|
7
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
7
|
+
import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
8
8
|
import { focusTableResizer, ToolTipContent } from '@atlaskit/editor-common/keymaps';
|
|
9
9
|
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
10
10
|
import { logException } from '@atlaskit/editor-common/monitoring';
|
|
@@ -13,7 +13,6 @@ import { chainCommands } from '@atlaskit/editor-prosemirror/commands';
|
|
|
13
13
|
import { akEditorGutterPaddingDynamic } from '@atlaskit/editor-shared-styles';
|
|
14
14
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
15
15
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
16
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
17
16
|
import { setTableAlignmentWithTableContentWithPosWithAnalytics } from '../pm-plugins/commands/commands-with-analytics';
|
|
18
17
|
import { updateWidthToWidest } from '../pm-plugins/commands/misc';
|
|
19
18
|
import { META_KEYS } from '../pm-plugins/table-analytics';
|
|
@@ -92,6 +91,20 @@ const getVisibleGuidelines = (guidelines, containerWidth, lineLength, isTableSca
|
|
|
92
91
|
return guideline.position && guideline.position.x !== undefined && typeof guideline.position.x === 'number' && Math.abs(guideline.position.x * 2) < width + guidelineVisibleAdjustment;
|
|
93
92
|
});
|
|
94
93
|
};
|
|
94
|
+
const useSharedState = sharedPluginStateHookMigratorFactory(pluginInjectionApi => {
|
|
95
|
+
const widthToWidest = useInternalTablePluginStateSelector(pluginInjectionApi, 'widthToWidest');
|
|
96
|
+
return {
|
|
97
|
+
widthToWidest
|
|
98
|
+
};
|
|
99
|
+
}, pluginInjectionApi => {
|
|
100
|
+
const {
|
|
101
|
+
tableState
|
|
102
|
+
} = useSharedPluginState(pluginInjectionApi, ['table']);
|
|
103
|
+
const tableStateInternal = tableState;
|
|
104
|
+
return {
|
|
105
|
+
widthToWidest: tableStateInternal.widthToWidest
|
|
106
|
+
};
|
|
107
|
+
});
|
|
95
108
|
export const TableResizer = ({
|
|
96
109
|
children,
|
|
97
110
|
width,
|
|
@@ -125,16 +138,8 @@ export const TableResizer = ({
|
|
|
125
138
|
const areResizeMetaKeysPressed = useRef(false);
|
|
126
139
|
const resizerRef = useRef(null);
|
|
127
140
|
const {
|
|
128
|
-
|
|
129
|
-
} =
|
|
130
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
// widthToWidest
|
|
134
|
-
const widthToWidestSelector = useInternalTablePluginStateSelector(pluginInjectionApi, 'widthToWidest', {
|
|
135
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
136
|
-
});
|
|
137
|
-
const widthToWidest = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? widthToWidestSelector : tableState.widthToWidest;
|
|
141
|
+
widthToWidest
|
|
142
|
+
} = useSharedState(pluginInjectionApi);
|
|
138
143
|
|
|
139
144
|
// used to reposition tooltip when table is resizing via keyboard
|
|
140
145
|
const updateTooltip = React.useRef();
|
|
@@ -210,19 +210,11 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
|
|
|
210
210
|
|
|
211
211
|
// transformSliceToRemoveOpenTable() transforms based on the depth of the root node, assuming that the tables will be at the root
|
|
212
212
|
// Bodied extensions will contribute to the depth of the table selection so we need to remove them first
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
slice = transformSliceToRemoveOpenBodiedExtension(slice, schema);
|
|
213
|
+
/** If a partial paste of bodied extension, paste only text */
|
|
214
|
+
slice = transformSliceToRemoveOpenBodiedExtension(slice, schema);
|
|
216
215
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
} else {
|
|
220
|
-
/** If a partial paste of table, paste only table's content */
|
|
221
|
-
slice = transformSliceToRemoveOpenTable(slice, schema);
|
|
222
|
-
|
|
223
|
-
/** If a partial paste of bodied extension, paste only text */
|
|
224
|
-
slice = transformSliceToRemoveOpenBodiedExtension(slice, schema);
|
|
225
|
-
}
|
|
216
|
+
/** If a partial paste of table, paste only table's content */
|
|
217
|
+
slice = transformSliceToRemoveOpenTable(slice, schema);
|
|
226
218
|
|
|
227
219
|
/** If a partial paste of multi bodied extension, paste only children */
|
|
228
220
|
slice = transformSliceToRemoveOpenMultiBodiedExtension(slice, schema);
|
|
@@ -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`
|
|
@@ -103,6 +116,7 @@ const tablePlugin = ({
|
|
|
103
116
|
const stickyHeadersState = stickyHeadersPluginKey.getState(editorState);
|
|
104
117
|
const stickyHeader = stickyHeadersState ? findStickyHeaderForTable(stickyHeadersState, tablePluginState === null || tablePluginState === void 0 ? void 0 : tablePluginState.tablePos) : undefined;
|
|
105
118
|
const dragAndDropState = dragAndDropPluginKey.getState(editorState);
|
|
119
|
+
const sizeSelectorPluginState = sizeSelectorPluginKey.getState(editorState);
|
|
106
120
|
const sharedStateInternal = {
|
|
107
121
|
isFullWidthModeEnabled: !!(options !== null && options !== void 0 && options.fullWidthEnabled),
|
|
108
122
|
wasFullWidthModeEnabled: !!(options !== null && options !== void 0 && options.wasFullWidthEnabled),
|
|
@@ -136,7 +150,9 @@ const tablePlugin = ({
|
|
|
136
150
|
stickyHeader,
|
|
137
151
|
dragMenuDirection: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.dragMenuDirection,
|
|
138
152
|
dragMenuIndex: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.dragMenuIndex,
|
|
139
|
-
isDragMenuOpen: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.isDragMenuOpen
|
|
153
|
+
isDragMenuOpen: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.isDragMenuOpen,
|
|
154
|
+
isSizeSelectorOpen: sizeSelectorPluginState === null || sizeSelectorPluginState === void 0 ? void 0 : sizeSelectorPluginState.isSelectorOpen,
|
|
155
|
+
sizeSelectorTargetRef: sizeSelectorPluginState === null || sizeSelectorPluginState === void 0 ? void 0 : sizeSelectorPluginState.targetRef
|
|
140
156
|
};
|
|
141
157
|
return sharedStateInternal;
|
|
142
158
|
},
|
|
@@ -450,7 +466,8 @@ const tablePlugin = ({
|
|
|
450
466
|
popupsBoundariesElement: popupsBoundariesElement,
|
|
451
467
|
popupsScrollableElement: popupsScrollableElement,
|
|
452
468
|
defaultGetEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
453
|
-
defaultGetEditorFeatureFlags: defaultGetEditorFeatureFlags
|
|
469
|
+
defaultGetEditorFeatureFlags: defaultGetEditorFeatureFlags,
|
|
470
|
+
isTableSelectorEnabled: isTableSelectorEnabled
|
|
454
471
|
});
|
|
455
472
|
}
|
|
456
473
|
return /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
@@ -480,6 +497,8 @@ const tablePlugin = ({
|
|
|
480
497
|
sizeSelectorPluginState
|
|
481
498
|
}) => {
|
|
482
499
|
var _sizeSelectorPluginSt, _api$analytics3;
|
|
500
|
+
// Any changes made inside `<WithPluginState>` need to be reflected in the
|
|
501
|
+
// `<ContentComponent>` as well.
|
|
483
502
|
const isColumnResizing = resizingPluginState === null || resizingPluginState === void 0 ? void 0 : resizingPluginState.dragging;
|
|
484
503
|
const isTableResizing = tableWidthPluginState === null || tableWidthPluginState === void 0 ? void 0 : tableWidthPluginState.resizing;
|
|
485
504
|
const resizingTableLocalId = tableWidthPluginState === null || tableWidthPluginState === void 0 ? void 0 : tableWidthPluginState.tableLocalId;
|
|
@@ -681,16 +700,8 @@ const tablePlugin = ({
|
|
|
681
700
|
editorView
|
|
682
701
|
}) {
|
|
683
702
|
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;
|
|
703
|
+
mode
|
|
704
|
+
} = useTableSharedState(api);
|
|
694
705
|
useEffect(() => {
|
|
695
706
|
const {
|
|
696
707
|
state,
|