@atlaskit/editor-plugin-table 10.9.4 → 10.9.5
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 +8 -0
- package/dist/cjs/ui/TableFloatingColumnControls/ColumnControls/index.js +12 -2
- package/dist/cjs/ui/TableFloatingControls/CornerControls/DragCornerControls.js +14 -5
- package/dist/cjs/ui/TableFloatingControls/FloatingControlsWithSelection.js +11 -2
- package/dist/cjs/ui/TableFloatingControls/NumberColumn/index.js +1 -1
- package/dist/cjs/ui/TableFloatingControls/RowControls/DragControls.js +11 -2
- package/dist/cjs/ui/icons/SortingIconWrapper.js +12 -2
- package/dist/es2019/ui/TableFloatingColumnControls/ColumnControls/index.js +12 -2
- package/dist/es2019/ui/TableFloatingControls/CornerControls/DragCornerControls.js +14 -5
- package/dist/es2019/ui/TableFloatingControls/FloatingControlsWithSelection.js +11 -2
- package/dist/es2019/ui/TableFloatingControls/NumberColumn/index.js +1 -1
- package/dist/es2019/ui/TableFloatingControls/RowControls/DragControls.js +11 -2
- package/dist/es2019/ui/icons/SortingIconWrapper.js +12 -2
- package/dist/esm/ui/TableFloatingColumnControls/ColumnControls/index.js +12 -2
- package/dist/esm/ui/TableFloatingControls/CornerControls/DragCornerControls.js +14 -5
- package/dist/esm/ui/TableFloatingControls/FloatingControlsWithSelection.js +11 -2
- package/dist/esm/ui/TableFloatingControls/NumberColumn/index.js +1 -1
- package/dist/esm/ui/TableFloatingControls/RowControls/DragControls.js +11 -2
- package/dist/esm/ui/icons/SortingIconWrapper.js +12 -2
- package/package.json +1 -1
- package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +15 -5
- package/src/ui/TableFloatingControls/CornerControls/DragCornerControls.tsx +16 -5
- package/src/ui/TableFloatingControls/FloatingControlsWithSelection.tsx +13 -2
- package/src/ui/TableFloatingControls/NumberColumn/index.tsx +4 -4
- package/src/ui/TableFloatingControls/RowControls/DragControls.tsx +13 -2
- package/src/ui/icons/SortingIconWrapper.tsx +15 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 10.9.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#145710](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/145710)
|
|
8
|
+
[`0cccd72c0228f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/0cccd72c0228f) -
|
|
9
|
+
ED-27559 Enable useSharedPluginStateSelector in Table
|
|
10
|
+
|
|
3
11
|
## 10.9.4
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -8,10 +8,12 @@ exports.ColumnControls = void 0;
|
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
10
10
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
11
|
+
var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
|
|
11
12
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
12
13
|
var _editorTables = require("@atlaskit/editor-tables");
|
|
13
14
|
var _utils = require("@atlaskit/editor-tables/utils");
|
|
14
15
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
16
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
15
17
|
var _commands = require("../../../pm-plugins/commands");
|
|
16
18
|
var _commands2 = require("../../../pm-plugins/drag-and-drop/commands");
|
|
17
19
|
var _rowControls = require("../../../pm-plugins/utils/row-controls");
|
|
@@ -50,8 +52,16 @@ var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
|
|
|
50
52
|
getScrollOffset = _ref.getScrollOffset,
|
|
51
53
|
api = _ref.api;
|
|
52
54
|
var columnControlsRef = (0, _react.useRef)(null);
|
|
53
|
-
|
|
55
|
+
|
|
56
|
+
// selection
|
|
57
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['selection'], {
|
|
58
|
+
disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true)
|
|
59
|
+
}),
|
|
54
60
|
selectionState = _useSharedPluginState.selectionState;
|
|
61
|
+
var selectionsSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'selection.selection', {
|
|
62
|
+
disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
|
|
63
|
+
});
|
|
64
|
+
var selection = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? selectionsSelector : selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection;
|
|
55
65
|
var widths = (_colWidths$map$join = colWidths === null || colWidths === void 0 ? void 0 : colWidths.map(function (width) {
|
|
56
66
|
return (
|
|
57
67
|
// when there is sticky header, a `margin-right: -1px` applied to `tr.sticky th` so it causes colWidths to be 1px wider
|
|
@@ -62,7 +72,7 @@ var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
|
|
|
62
72
|
// TODO: ED-26961 - reusing getRowsParams here because it's generic enough to work for columns -> rename
|
|
63
73
|
var columnParams = (0, _rowControls.getRowsParams)(colWidths !== null && colWidths !== void 0 ? colWidths : []);
|
|
64
74
|
var colIndex = hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.colIndex;
|
|
65
|
-
var selectedColIndexes = getSelectedColumns(
|
|
75
|
+
var selectedColIndexes = getSelectedColumns(selection || editorView.state.selection);
|
|
66
76
|
var firstRow = tableRef.querySelector('tr');
|
|
67
77
|
var hasHeaderRow = firstRow ? firstRow.getAttribute('data-header-row') : false;
|
|
68
78
|
var rowControlStickyTop = 45;
|
|
@@ -11,7 +11,9 @@ var _classnames = _interopRequireDefault(require("classnames"));
|
|
|
11
11
|
var _reactIntlNext = require("react-intl-next");
|
|
12
12
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
13
13
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
14
|
+
var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
|
|
14
15
|
var _utils = require("@atlaskit/editor-tables/utils");
|
|
16
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
15
17
|
var _commands = require("../../../pm-plugins/commands");
|
|
16
18
|
var _types = require("../../../types");
|
|
17
19
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
@@ -65,8 +67,15 @@ var DragCornerControlsComponentWithSelection = function DragCornerControlsCompon
|
|
|
65
67
|
isResizing = _ref2.isResizing,
|
|
66
68
|
formatMessage = _ref2.intl.formatMessage,
|
|
67
69
|
api = _ref2.api;
|
|
68
|
-
|
|
70
|
+
// selection
|
|
71
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['selection'], {
|
|
72
|
+
disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true)
|
|
73
|
+
}),
|
|
69
74
|
selectionState = _useSharedPluginState.selectionState;
|
|
75
|
+
var selectionsSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'selection.selection', {
|
|
76
|
+
disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
|
|
77
|
+
});
|
|
78
|
+
var selection = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? selectionsSelector : selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection;
|
|
70
79
|
var handleOnClick = function handleOnClick() {
|
|
71
80
|
var state = editorView.state,
|
|
72
81
|
dispatch = editorView.dispatch;
|
|
@@ -78,15 +87,15 @@ var DragCornerControlsComponentWithSelection = function DragCornerControlsCompon
|
|
|
78
87
|
(0, _commands.clearHoverSelection)()(state, dispatch);
|
|
79
88
|
};
|
|
80
89
|
var isActive = (0, _react.useMemo)(function () {
|
|
81
|
-
if (!
|
|
90
|
+
if (!selection) {
|
|
82
91
|
return;
|
|
83
92
|
}
|
|
84
|
-
var table = (0, _utils.findTable)(
|
|
93
|
+
var table = (0, _utils.findTable)(selection);
|
|
85
94
|
if (!table) {
|
|
86
95
|
return false;
|
|
87
96
|
}
|
|
88
|
-
return (0, _utils.isTableSelected)(
|
|
89
|
-
}, [
|
|
97
|
+
return (0, _utils.isTableSelected)(selection);
|
|
98
|
+
}, [selection]);
|
|
90
99
|
if (isResizing) {
|
|
91
100
|
return null;
|
|
92
101
|
}
|
|
@@ -7,6 +7,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.FloatingControlsWithSelection = void 0;
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
10
|
+
var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
|
|
11
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
10
12
|
var _ClassicCornerControls = require("./CornerControls/ClassicCornerControls");
|
|
11
13
|
var _ClassicControls = require("./RowControls/ClassicControls");
|
|
12
14
|
var FloatingControlsWithSelection = exports.FloatingControlsWithSelection = function FloatingControlsWithSelection(_ref) {
|
|
@@ -22,8 +24,15 @@ var FloatingControlsWithSelection = exports.FloatingControlsWithSelection = func
|
|
|
22
24
|
selectRow = _ref.selectRow,
|
|
23
25
|
tableActive = _ref.tableActive,
|
|
24
26
|
api = _ref.api;
|
|
25
|
-
|
|
27
|
+
// selection
|
|
28
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['selection'], {
|
|
29
|
+
disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true)
|
|
30
|
+
}),
|
|
26
31
|
selectionState = _useSharedPluginState.selectionState;
|
|
32
|
+
var selectionsSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'selection.selection', {
|
|
33
|
+
disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
|
|
34
|
+
});
|
|
35
|
+
var selection = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? selectionsSelector : selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection;
|
|
27
36
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_ClassicCornerControls.CornerControls, {
|
|
28
37
|
editorView: editorView,
|
|
29
38
|
tableRef: tableRef,
|
|
@@ -34,7 +43,7 @@ var FloatingControlsWithSelection = exports.FloatingControlsWithSelection = func
|
|
|
34
43
|
hoveredRows: hoveredRows,
|
|
35
44
|
stickyTop: tableActive ? stickyTop : undefined
|
|
36
45
|
}), /*#__PURE__*/_react.default.createElement(_ClassicControls.RowControls, {
|
|
37
|
-
selection:
|
|
46
|
+
selection: selection,
|
|
38
47
|
editorView: editorView,
|
|
39
48
|
tableRef: tableRef,
|
|
40
49
|
hoverRows: hoverRows,
|
|
@@ -148,7 +148,7 @@ var NumberColumn = exports.default = /*#__PURE__*/function (_Component) {
|
|
|
148
148
|
}
|
|
149
149
|
}, hasHeaderRow ? index > 0 ? index : null : index + 1) :
|
|
150
150
|
/*#__PURE__*/
|
|
151
|
-
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
|
|
151
|
+
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions, @atlassian/a11y/interactive-element-not-keyboard-focusable
|
|
152
152
|
_react.default.createElement("div", {
|
|
153
153
|
// Ignored via go/ees005
|
|
154
154
|
// eslint-disable-next-line react/no-array-index-key
|
|
@@ -9,10 +9,12 @@ exports.DragControlsWithSelection = exports.DragControls = void 0;
|
|
|
9
9
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
11
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
12
|
+
var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
|
|
12
13
|
var _editorTables = require("@atlaskit/editor-tables");
|
|
13
14
|
var _utils = require("@atlaskit/editor-tables/utils");
|
|
14
15
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
15
16
|
var _adapter = require("@atlaskit/pragmatic-drag-and-drop/element/adapter");
|
|
17
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
16
18
|
var _commands = require("../../../pm-plugins/commands");
|
|
17
19
|
var _commands2 = require("../../../pm-plugins/drag-and-drop/commands");
|
|
18
20
|
var _pluginFactory = require("../../../pm-plugins/plugin-factory");
|
|
@@ -302,8 +304,15 @@ var DragControlsWithSelection = exports.DragControlsWithSelection = function Dra
|
|
|
302
304
|
selectRows = _ref5.selectRows,
|
|
303
305
|
updateCellHoverLocation = _ref5.updateCellHoverLocation,
|
|
304
306
|
api = _ref5.api;
|
|
305
|
-
|
|
307
|
+
// selection
|
|
308
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['selection'], {
|
|
309
|
+
disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true)
|
|
310
|
+
}),
|
|
306
311
|
selectionState = _useSharedPluginState.selectionState;
|
|
312
|
+
var selectionsSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'selection.selection', {
|
|
313
|
+
disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
|
|
314
|
+
});
|
|
315
|
+
var selection = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? selectionsSelector : selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection;
|
|
307
316
|
return /*#__PURE__*/_react.default.createElement(DragControls, {
|
|
308
317
|
editorView: editorView,
|
|
309
318
|
tableRef: tableRef,
|
|
@@ -319,6 +328,6 @@ var DragControlsWithSelection = exports.DragControlsWithSelection = function Dra
|
|
|
319
328
|
selectRows: selectRows,
|
|
320
329
|
updateCellHoverLocation: updateCellHoverLocation,
|
|
321
330
|
api: api,
|
|
322
|
-
selection:
|
|
331
|
+
selection: selection
|
|
323
332
|
});
|
|
324
333
|
};
|
|
@@ -8,10 +8,20 @@ exports.SortingIconWrapper = void 0;
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
10
10
|
var _table = require("@atlaskit/editor-common/table");
|
|
11
|
+
var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
|
|
12
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
11
13
|
var SortingIconWrapper = exports.SortingIconWrapper = function SortingIconWrapper(props) {
|
|
12
|
-
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(props.api, ['editorViewMode']
|
|
14
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(props.api, ['editorViewMode'], {
|
|
15
|
+
disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true)
|
|
16
|
+
}),
|
|
13
17
|
editorViewModeState = _useSharedPluginState.editorViewModeState;
|
|
14
|
-
|
|
18
|
+
|
|
19
|
+
// mode
|
|
20
|
+
var modeSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(props.api, 'editorViewMode.mode', {
|
|
21
|
+
disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
|
|
22
|
+
});
|
|
23
|
+
var mode = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? modeSelector : editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode;
|
|
24
|
+
if (mode === 'edit') {
|
|
15
25
|
return null;
|
|
16
26
|
}
|
|
17
27
|
// Ignored via go/ees005
|
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
import React, { useCallback, useMemo, useRef } from 'react';
|
|
4
4
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
5
5
|
import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
6
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
6
7
|
import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
|
|
7
8
|
import { CellSelection } from '@atlaskit/editor-tables';
|
|
8
9
|
import { getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
9
10
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
11
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
10
12
|
import { clearHoverSelection, hoverCell, hoverColumns, selectColumn, selectColumns } from '../../../pm-plugins/commands';
|
|
11
13
|
import { toggleDragMenu } from '../../../pm-plugins/drag-and-drop/commands';
|
|
12
14
|
import { getRowsParams } from '../../../pm-plugins/utils/row-controls';
|
|
@@ -42,9 +44,17 @@ export const ColumnControls = ({
|
|
|
42
44
|
}) => {
|
|
43
45
|
var _colWidths$map$join;
|
|
44
46
|
const columnControlsRef = useRef(null);
|
|
47
|
+
|
|
48
|
+
// selection
|
|
45
49
|
const {
|
|
46
50
|
selectionState
|
|
47
|
-
} = useSharedPluginState(api, ['selection']
|
|
51
|
+
} = useSharedPluginState(api, ['selection'], {
|
|
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;
|
|
48
58
|
const widths = (_colWidths$map$join = colWidths === null || colWidths === void 0 ? void 0 : colWidths.map(width =>
|
|
49
59
|
// when there is sticky header, a `margin-right: -1px` applied to `tr.sticky th` so it causes colWidths to be 1px wider
|
|
50
60
|
// we need to reduce the width by 1px to avoid misalignment of column controls.
|
|
@@ -52,7 +62,7 @@ export const ColumnControls = ({
|
|
|
52
62
|
// TODO: ED-26961 - reusing getRowsParams here because it's generic enough to work for columns -> rename
|
|
53
63
|
const columnParams = getRowsParams(colWidths !== null && colWidths !== void 0 ? colWidths : []);
|
|
54
64
|
const colIndex = hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.colIndex;
|
|
55
|
-
const selectedColIndexes = getSelectedColumns(
|
|
65
|
+
const selectedColIndexes = getSelectedColumns(selection || editorView.state.selection);
|
|
56
66
|
const firstRow = tableRef.querySelector('tr');
|
|
57
67
|
const hasHeaderRow = firstRow ? firstRow.getAttribute('data-header-row') : false;
|
|
58
68
|
const rowControlStickyTop = 45;
|
|
@@ -3,7 +3,9 @@ import classnames from 'classnames';
|
|
|
3
3
|
import { injectIntl } from 'react-intl-next';
|
|
4
4
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
5
5
|
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
6
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
6
7
|
import { findTable, isTableSelected, selectTable } from '@atlaskit/editor-tables/utils';
|
|
8
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
7
9
|
import { clearHoverSelection } from '../../../pm-plugins/commands';
|
|
8
10
|
import { TableCssClassName as ClassName } from '../../../types';
|
|
9
11
|
const DragCornerControlsComponent = ({
|
|
@@ -67,9 +69,16 @@ const DragCornerControlsComponentWithSelection = ({
|
|
|
67
69
|
},
|
|
68
70
|
api
|
|
69
71
|
}) => {
|
|
72
|
+
// selection
|
|
70
73
|
const {
|
|
71
74
|
selectionState
|
|
72
|
-
} = useSharedPluginState(api, ['selection']
|
|
75
|
+
} = useSharedPluginState(api, ['selection'], {
|
|
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;
|
|
73
82
|
const handleOnClick = () => {
|
|
74
83
|
const {
|
|
75
84
|
state,
|
|
@@ -85,15 +94,15 @@ const DragCornerControlsComponentWithSelection = ({
|
|
|
85
94
|
clearHoverSelection()(state, dispatch);
|
|
86
95
|
};
|
|
87
96
|
const isActive = useMemo(() => {
|
|
88
|
-
if (!
|
|
97
|
+
if (!selection) {
|
|
89
98
|
return;
|
|
90
99
|
}
|
|
91
|
-
const table = findTable(
|
|
100
|
+
const table = findTable(selection);
|
|
92
101
|
if (!table) {
|
|
93
102
|
return false;
|
|
94
103
|
}
|
|
95
|
-
return isTableSelected(
|
|
96
|
-
}, [
|
|
104
|
+
return isTableSelected(selection);
|
|
105
|
+
}, [selection]);
|
|
97
106
|
if (isResizing) {
|
|
98
107
|
return null;
|
|
99
108
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
3
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
4
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
3
5
|
import { CornerControls } from './CornerControls/ClassicCornerControls';
|
|
4
6
|
import { RowControls } from './RowControls/ClassicControls';
|
|
5
7
|
export const FloatingControlsWithSelection = ({
|
|
@@ -16,9 +18,16 @@ export const FloatingControlsWithSelection = ({
|
|
|
16
18
|
tableActive,
|
|
17
19
|
api
|
|
18
20
|
}) => {
|
|
21
|
+
// selection
|
|
19
22
|
const {
|
|
20
23
|
selectionState
|
|
21
|
-
} = useSharedPluginState(api, ['selection']
|
|
24
|
+
} = useSharedPluginState(api, ['selection'], {
|
|
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;
|
|
22
31
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CornerControls, {
|
|
23
32
|
editorView: editorView,
|
|
24
33
|
tableRef: tableRef,
|
|
@@ -29,7 +38,7 @@ export const FloatingControlsWithSelection = ({
|
|
|
29
38
|
hoveredRows: hoveredRows,
|
|
30
39
|
stickyTop: tableActive ? stickyTop : undefined
|
|
31
40
|
}), /*#__PURE__*/React.createElement(RowControls, {
|
|
32
|
-
selection:
|
|
41
|
+
selection: selection,
|
|
33
42
|
editorView: editorView,
|
|
34
43
|
tableRef: tableRef,
|
|
35
44
|
hoverRows: hoverRows,
|
|
@@ -133,7 +133,7 @@ export default class NumberColumn extends Component {
|
|
|
133
133
|
onMouseOver: () => updateCellHoverLocation(index)
|
|
134
134
|
}, hasHeaderRow ? index > 0 ? index : null : index + 1) :
|
|
135
135
|
/*#__PURE__*/
|
|
136
|
-
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
|
|
136
|
+
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions, @atlassian/a11y/interactive-element-not-keyboard-focusable
|
|
137
137
|
React.createElement("div", {
|
|
138
138
|
// Ignored via go/ees005
|
|
139
139
|
// eslint-disable-next-line react/no-array-index-key
|
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
import React, { Fragment, useCallback, useEffect, useMemo, useState } from 'react';
|
|
4
4
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
5
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
5
6
|
import { CellSelection } from '@atlaskit/editor-tables';
|
|
6
7
|
import { getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
7
8
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
9
|
import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
10
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
9
11
|
import { clearHoverSelection } from '../../../pm-plugins/commands';
|
|
10
12
|
import { toggleDragMenu } from '../../../pm-plugins/drag-and-drop/commands';
|
|
11
13
|
import { getPluginState as getTablePluginState } from '../../../pm-plugins/plugin-factory';
|
|
@@ -291,9 +293,16 @@ export const DragControlsWithSelection = ({
|
|
|
291
293
|
updateCellHoverLocation,
|
|
292
294
|
api
|
|
293
295
|
}) => {
|
|
296
|
+
// selection
|
|
294
297
|
const {
|
|
295
298
|
selectionState
|
|
296
|
-
} = useSharedPluginState(api, ['selection']
|
|
299
|
+
} = useSharedPluginState(api, ['selection'], {
|
|
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;
|
|
297
306
|
return /*#__PURE__*/React.createElement(DragControls, {
|
|
298
307
|
editorView: editorView,
|
|
299
308
|
tableRef: tableRef,
|
|
@@ -309,6 +318,6 @@ export const DragControlsWithSelection = ({
|
|
|
309
318
|
selectRows: selectRows,
|
|
310
319
|
updateCellHoverLocation: updateCellHoverLocation,
|
|
311
320
|
api: api,
|
|
312
|
-
selection:
|
|
321
|
+
selection: selection
|
|
313
322
|
});
|
|
314
323
|
};
|
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
3
3
|
import { SortingIcon } from '@atlaskit/editor-common/table';
|
|
4
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
5
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
4
6
|
export const SortingIconWrapper = props => {
|
|
5
7
|
const {
|
|
6
8
|
editorViewModeState
|
|
7
|
-
} = useSharedPluginState(props.api, ['editorViewMode']
|
|
8
|
-
|
|
9
|
+
} = useSharedPluginState(props.api, ['editorViewMode'], {
|
|
10
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
// mode
|
|
14
|
+
const modeSelector = useSharedPluginStateSelector(props.api, 'editorViewMode.mode', {
|
|
15
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
16
|
+
});
|
|
17
|
+
const mode = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? modeSelector : editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode;
|
|
18
|
+
if (mode === 'edit') {
|
|
9
19
|
return null;
|
|
10
20
|
}
|
|
11
21
|
// Ignored via go/ees005
|
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
import React, { useCallback, useMemo, useRef } from 'react';
|
|
4
4
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
5
5
|
import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
6
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
6
7
|
import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
|
|
7
8
|
import { CellSelection } from '@atlaskit/editor-tables';
|
|
8
9
|
import { getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
9
10
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
11
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
10
12
|
import { clearHoverSelection, hoverCell, hoverColumns, selectColumn, selectColumns } from '../../../pm-plugins/commands';
|
|
11
13
|
import { toggleDragMenu } from '../../../pm-plugins/drag-and-drop/commands';
|
|
12
14
|
import { getRowsParams } from '../../../pm-plugins/utils/row-controls';
|
|
@@ -41,8 +43,16 @@ export var ColumnControls = function ColumnControls(_ref) {
|
|
|
41
43
|
getScrollOffset = _ref.getScrollOffset,
|
|
42
44
|
api = _ref.api;
|
|
43
45
|
var columnControlsRef = useRef(null);
|
|
44
|
-
|
|
46
|
+
|
|
47
|
+
// selection
|
|
48
|
+
var _useSharedPluginState = useSharedPluginState(api, ['selection'], {
|
|
49
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
|
|
50
|
+
}),
|
|
45
51
|
selectionState = _useSharedPluginState.selectionState;
|
|
52
|
+
var selectionsSelector = useSharedPluginStateSelector(api, 'selection.selection', {
|
|
53
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
54
|
+
});
|
|
55
|
+
var selection = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? selectionsSelector : selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection;
|
|
46
56
|
var widths = (_colWidths$map$join = colWidths === null || colWidths === void 0 ? void 0 : colWidths.map(function (width) {
|
|
47
57
|
return (
|
|
48
58
|
// when there is sticky header, a `margin-right: -1px` applied to `tr.sticky th` so it causes colWidths to be 1px wider
|
|
@@ -53,7 +63,7 @@ export var ColumnControls = function ColumnControls(_ref) {
|
|
|
53
63
|
// TODO: ED-26961 - reusing getRowsParams here because it's generic enough to work for columns -> rename
|
|
54
64
|
var columnParams = getRowsParams(colWidths !== null && colWidths !== void 0 ? colWidths : []);
|
|
55
65
|
var colIndex = hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.colIndex;
|
|
56
|
-
var selectedColIndexes = getSelectedColumns(
|
|
66
|
+
var selectedColIndexes = getSelectedColumns(selection || editorView.state.selection);
|
|
57
67
|
var firstRow = tableRef.querySelector('tr');
|
|
58
68
|
var hasHeaderRow = firstRow ? firstRow.getAttribute('data-header-row') : false;
|
|
59
69
|
var rowControlStickyTop = 45;
|
|
@@ -3,7 +3,9 @@ import classnames from 'classnames';
|
|
|
3
3
|
import { injectIntl } from 'react-intl-next';
|
|
4
4
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
5
5
|
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
6
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
6
7
|
import { findTable, isTableSelected, selectTable } from '@atlaskit/editor-tables/utils';
|
|
8
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
7
9
|
import { clearHoverSelection } from '../../../pm-plugins/commands';
|
|
8
10
|
import { TableCssClassName as ClassName } from '../../../types';
|
|
9
11
|
var DragCornerControlsComponent = function DragCornerControlsComponent(_ref) {
|
|
@@ -55,8 +57,15 @@ var DragCornerControlsComponentWithSelection = function DragCornerControlsCompon
|
|
|
55
57
|
isResizing = _ref2.isResizing,
|
|
56
58
|
formatMessage = _ref2.intl.formatMessage,
|
|
57
59
|
api = _ref2.api;
|
|
58
|
-
|
|
60
|
+
// selection
|
|
61
|
+
var _useSharedPluginState = useSharedPluginState(api, ['selection'], {
|
|
62
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
|
|
63
|
+
}),
|
|
59
64
|
selectionState = _useSharedPluginState.selectionState;
|
|
65
|
+
var selectionsSelector = useSharedPluginStateSelector(api, 'selection.selection', {
|
|
66
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
67
|
+
});
|
|
68
|
+
var selection = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? selectionsSelector : selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection;
|
|
60
69
|
var handleOnClick = function handleOnClick() {
|
|
61
70
|
var state = editorView.state,
|
|
62
71
|
dispatch = editorView.dispatch;
|
|
@@ -68,15 +77,15 @@ var DragCornerControlsComponentWithSelection = function DragCornerControlsCompon
|
|
|
68
77
|
clearHoverSelection()(state, dispatch);
|
|
69
78
|
};
|
|
70
79
|
var isActive = useMemo(function () {
|
|
71
|
-
if (!
|
|
80
|
+
if (!selection) {
|
|
72
81
|
return;
|
|
73
82
|
}
|
|
74
|
-
var table = findTable(
|
|
83
|
+
var table = findTable(selection);
|
|
75
84
|
if (!table) {
|
|
76
85
|
return false;
|
|
77
86
|
}
|
|
78
|
-
return isTableSelected(
|
|
79
|
-
}, [
|
|
87
|
+
return isTableSelected(selection);
|
|
88
|
+
}, [selection]);
|
|
80
89
|
if (isResizing) {
|
|
81
90
|
return null;
|
|
82
91
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
3
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
4
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
3
5
|
import { CornerControls } from './CornerControls/ClassicCornerControls';
|
|
4
6
|
import { RowControls } from './RowControls/ClassicControls';
|
|
5
7
|
export var FloatingControlsWithSelection = function FloatingControlsWithSelection(_ref) {
|
|
@@ -15,8 +17,15 @@ export var FloatingControlsWithSelection = function FloatingControlsWithSelectio
|
|
|
15
17
|
selectRow = _ref.selectRow,
|
|
16
18
|
tableActive = _ref.tableActive,
|
|
17
19
|
api = _ref.api;
|
|
18
|
-
|
|
20
|
+
// selection
|
|
21
|
+
var _useSharedPluginState = useSharedPluginState(api, ['selection'], {
|
|
22
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
|
|
23
|
+
}),
|
|
19
24
|
selectionState = _useSharedPluginState.selectionState;
|
|
25
|
+
var selectionsSelector = useSharedPluginStateSelector(api, 'selection.selection', {
|
|
26
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
27
|
+
});
|
|
28
|
+
var selection = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? selectionsSelector : selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection;
|
|
20
29
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CornerControls, {
|
|
21
30
|
editorView: editorView,
|
|
22
31
|
tableRef: tableRef,
|
|
@@ -27,7 +36,7 @@ export var FloatingControlsWithSelection = function FloatingControlsWithSelectio
|
|
|
27
36
|
hoveredRows: hoveredRows,
|
|
28
37
|
stickyTop: tableActive ? stickyTop : undefined
|
|
29
38
|
}), /*#__PURE__*/React.createElement(RowControls, {
|
|
30
|
-
selection:
|
|
39
|
+
selection: selection,
|
|
31
40
|
editorView: editorView,
|
|
32
41
|
tableRef: tableRef,
|
|
33
42
|
hoverRows: hoverRows,
|
|
@@ -138,7 +138,7 @@ var NumberColumn = /*#__PURE__*/function (_Component) {
|
|
|
138
138
|
}
|
|
139
139
|
}, hasHeaderRow ? index > 0 ? index : null : index + 1) :
|
|
140
140
|
/*#__PURE__*/
|
|
141
|
-
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
|
|
141
|
+
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions, @atlassian/a11y/interactive-element-not-keyboard-focusable
|
|
142
142
|
React.createElement("div", {
|
|
143
143
|
// Ignored via go/ees005
|
|
144
144
|
// eslint-disable-next-line react/no-array-index-key
|
|
@@ -3,10 +3,12 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
|
3
3
|
|
|
4
4
|
import React, { Fragment, useCallback, useEffect, useMemo, useState } from 'react';
|
|
5
5
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
6
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
6
7
|
import { CellSelection } from '@atlaskit/editor-tables';
|
|
7
8
|
import { getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
8
9
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
10
|
import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
11
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
10
12
|
import { clearHoverSelection } from '../../../pm-plugins/commands';
|
|
11
13
|
import { toggleDragMenu } from '../../../pm-plugins/drag-and-drop/commands';
|
|
12
14
|
import { getPluginState as getTablePluginState } from '../../../pm-plugins/plugin-factory';
|
|
@@ -292,8 +294,15 @@ export var DragControlsWithSelection = function DragControlsWithSelection(_ref5)
|
|
|
292
294
|
selectRows = _ref5.selectRows,
|
|
293
295
|
updateCellHoverLocation = _ref5.updateCellHoverLocation,
|
|
294
296
|
api = _ref5.api;
|
|
295
|
-
|
|
297
|
+
// selection
|
|
298
|
+
var _useSharedPluginState = useSharedPluginState(api, ['selection'], {
|
|
299
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
|
|
300
|
+
}),
|
|
296
301
|
selectionState = _useSharedPluginState.selectionState;
|
|
302
|
+
var selectionsSelector = useSharedPluginStateSelector(api, 'selection.selection', {
|
|
303
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
304
|
+
});
|
|
305
|
+
var selection = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? selectionsSelector : selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection;
|
|
297
306
|
return /*#__PURE__*/React.createElement(DragControls, {
|
|
298
307
|
editorView: editorView,
|
|
299
308
|
tableRef: tableRef,
|
|
@@ -309,6 +318,6 @@ export var DragControlsWithSelection = function DragControlsWithSelection(_ref5)
|
|
|
309
318
|
selectRows: selectRows,
|
|
310
319
|
updateCellHoverLocation: updateCellHoverLocation,
|
|
311
320
|
api: api,
|
|
312
|
-
selection:
|
|
321
|
+
selection: selection
|
|
313
322
|
});
|
|
314
323
|
};
|
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
3
3
|
import { SortingIcon } from '@atlaskit/editor-common/table';
|
|
4
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
5
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
4
6
|
export var SortingIconWrapper = function SortingIconWrapper(props) {
|
|
5
|
-
var _useSharedPluginState = useSharedPluginState(props.api, ['editorViewMode']
|
|
7
|
+
var _useSharedPluginState = useSharedPluginState(props.api, ['editorViewMode'], {
|
|
8
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
|
|
9
|
+
}),
|
|
6
10
|
editorViewModeState = _useSharedPluginState.editorViewModeState;
|
|
7
|
-
|
|
11
|
+
|
|
12
|
+
// mode
|
|
13
|
+
var modeSelector = useSharedPluginStateSelector(props.api, 'editorViewMode.mode', {
|
|
14
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
15
|
+
});
|
|
16
|
+
var mode = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? modeSelector : editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode;
|
|
17
|
+
if (mode === 'edit') {
|
|
8
18
|
return null;
|
|
9
19
|
}
|
|
10
20
|
// Ignored via go/ees005
|
package/package.json
CHANGED
|
@@ -5,12 +5,14 @@ import React, { useCallback, useMemo, useRef } from 'react';
|
|
|
5
5
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
6
6
|
import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
7
7
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
8
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
8
9
|
import type { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
9
10
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
10
11
|
import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
|
|
11
12
|
import { CellSelection } from '@atlaskit/editor-tables';
|
|
12
13
|
import { getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
13
14
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
15
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
14
16
|
|
|
15
17
|
import {
|
|
16
18
|
clearHoverSelection,
|
|
@@ -76,7 +78,17 @@ export const ColumnControls = ({
|
|
|
76
78
|
api,
|
|
77
79
|
}: ColumnControlsProps & { api?: ExtractInjectionAPI<TablePlugin> }) => {
|
|
78
80
|
const columnControlsRef = useRef<HTMLDivElement>(null);
|
|
79
|
-
|
|
81
|
+
|
|
82
|
+
// selection
|
|
83
|
+
const { selectionState } = useSharedPluginState(api, ['selection'], {
|
|
84
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true),
|
|
85
|
+
});
|
|
86
|
+
const selectionsSelector = useSharedPluginStateSelector(api, 'selection.selection', {
|
|
87
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
|
|
88
|
+
});
|
|
89
|
+
const selection = editorExperiment('platform_editor_usesharedpluginstateselector', true)
|
|
90
|
+
? selectionsSelector
|
|
91
|
+
: selectionState?.selection;
|
|
80
92
|
|
|
81
93
|
const widths =
|
|
82
94
|
colWidths
|
|
@@ -89,15 +101,13 @@ export const ColumnControls = ({
|
|
|
89
101
|
// TODO: ED-26961 - reusing getRowsParams here because it's generic enough to work for columns -> rename
|
|
90
102
|
const columnParams = getRowsParams(colWidths ?? []);
|
|
91
103
|
const colIndex = hoveredCell?.colIndex;
|
|
92
|
-
const selectedColIndexes = getSelectedColumns(
|
|
93
|
-
selectionState?.selection || editorView.state.selection,
|
|
94
|
-
);
|
|
104
|
+
const selectedColIndexes = getSelectedColumns(selection || editorView.state.selection);
|
|
95
105
|
|
|
96
106
|
const firstRow = tableRef.querySelector('tr');
|
|
97
107
|
const hasHeaderRow = firstRow ? firstRow.getAttribute('data-header-row') : false;
|
|
98
108
|
|
|
99
109
|
const rowControlStickyTop = 45;
|
|
100
|
-
const marginTop = hasHeaderRow && stickyTop !== undefined ? rowControlStickyTop ?? 0 : 0;
|
|
110
|
+
const marginTop = hasHeaderRow && stickyTop !== undefined ? (rowControlStickyTop ?? 0) : 0;
|
|
101
111
|
|
|
102
112
|
const handleClick = useCallback(
|
|
103
113
|
(event: MouseEvent) => {
|
|
@@ -7,7 +7,9 @@ import { injectIntl } from 'react-intl-next';
|
|
|
7
7
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
8
8
|
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
9
9
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
10
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
10
11
|
import { findTable, isTableSelected, selectTable } from '@atlaskit/editor-tables/utils';
|
|
12
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
11
13
|
|
|
12
14
|
import { clearHoverSelection } from '../../../pm-plugins/commands';
|
|
13
15
|
import type { TablePlugin } from '../../../tablePluginType';
|
|
@@ -71,7 +73,16 @@ const DragCornerControlsComponentWithSelection = ({
|
|
|
71
73
|
intl: { formatMessage },
|
|
72
74
|
api,
|
|
73
75
|
}: CornerControlProps & WrappedComponentProps & { api?: ExtractInjectionAPI<TablePlugin> }) => {
|
|
74
|
-
|
|
76
|
+
// selection
|
|
77
|
+
const { selectionState } = useSharedPluginState(api, ['selection'], {
|
|
78
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true),
|
|
79
|
+
});
|
|
80
|
+
const selectionsSelector = useSharedPluginStateSelector(api, 'selection.selection', {
|
|
81
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
|
|
82
|
+
});
|
|
83
|
+
const selection = editorExperiment('platform_editor_usesharedpluginstateselector', true)
|
|
84
|
+
? selectionsSelector
|
|
85
|
+
: selectionState?.selection;
|
|
75
86
|
|
|
76
87
|
const handleOnClick = () => {
|
|
77
88
|
const { state, dispatch } = editorView;
|
|
@@ -83,15 +94,15 @@ const DragCornerControlsComponentWithSelection = ({
|
|
|
83
94
|
clearHoverSelection()(state, dispatch);
|
|
84
95
|
};
|
|
85
96
|
const isActive = useMemo(() => {
|
|
86
|
-
if (!
|
|
97
|
+
if (!selection) {
|
|
87
98
|
return;
|
|
88
99
|
}
|
|
89
|
-
const table = findTable(
|
|
100
|
+
const table = findTable(selection);
|
|
90
101
|
if (!table) {
|
|
91
102
|
return false;
|
|
92
103
|
}
|
|
93
|
-
return isTableSelected(
|
|
94
|
-
}, [
|
|
104
|
+
return isTableSelected(selection);
|
|
105
|
+
}, [selection]);
|
|
95
106
|
|
|
96
107
|
if (isResizing) {
|
|
97
108
|
return null;
|
|
@@ -2,7 +2,9 @@ import React from 'react';
|
|
|
2
2
|
|
|
3
3
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
4
4
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
5
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
5
6
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
7
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
6
8
|
|
|
7
9
|
import type { TablePlugin } from '../../tablePluginType';
|
|
8
10
|
|
|
@@ -38,7 +40,16 @@ export const FloatingControlsWithSelection = ({
|
|
|
38
40
|
tableActive,
|
|
39
41
|
api,
|
|
40
42
|
}: FloatingControlsWithSelectionProps) => {
|
|
41
|
-
|
|
43
|
+
// selection
|
|
44
|
+
const { selectionState } = useSharedPluginState(api, ['selection'], {
|
|
45
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true),
|
|
46
|
+
});
|
|
47
|
+
const selectionsSelector = useSharedPluginStateSelector(api, 'selection.selection', {
|
|
48
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
|
|
49
|
+
});
|
|
50
|
+
const selection = editorExperiment('platform_editor_usesharedpluginstateselector', true)
|
|
51
|
+
? selectionsSelector
|
|
52
|
+
: selectionState?.selection;
|
|
42
53
|
|
|
43
54
|
return (
|
|
44
55
|
<>
|
|
@@ -53,7 +64,7 @@ export const FloatingControlsWithSelection = ({
|
|
|
53
64
|
stickyTop={tableActive ? stickyTop : undefined}
|
|
54
65
|
/>
|
|
55
66
|
<RowControls
|
|
56
|
-
selection={
|
|
67
|
+
selection={selection}
|
|
57
68
|
editorView={editorView}
|
|
58
69
|
tableRef={tableRef}
|
|
59
70
|
hoverRows={hoverRows}
|
|
@@ -66,7 +66,7 @@ export default class NumberColumn extends Component<Props, any> {
|
|
|
66
66
|
{hasHeaderRow ? (index > 0 ? index : null) : index + 1}
|
|
67
67
|
</div>
|
|
68
68
|
) : (
|
|
69
|
-
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
|
|
69
|
+
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions, @atlassian/a11y/interactive-element-not-keyboard-focusable
|
|
70
70
|
<div
|
|
71
71
|
// Ignored via go/ees005
|
|
72
72
|
// eslint-disable-next-line react/no-array-index-key
|
|
@@ -103,10 +103,10 @@ export default class NumberColumn extends Component<Props, any> {
|
|
|
103
103
|
const newPos =
|
|
104
104
|
selection.head > pos
|
|
105
105
|
? // Selection is after table
|
|
106
|
-
|
|
107
|
-
|
|
106
|
+
// nodeSize - 3 will move the position inside last table cell
|
|
107
|
+
Selection.near(doc.resolve(pos + ($pos.parent.nodeSize - 3)), -1)
|
|
108
108
|
: // Selection is before table
|
|
109
|
-
|
|
109
|
+
Selection.near($pos);
|
|
110
110
|
editorView.dispatch(tr.setSelection(newPos));
|
|
111
111
|
}
|
|
112
112
|
selectRow(index, event.shiftKey);
|
|
@@ -4,6 +4,7 @@ import React, { Fragment, useCallback, useEffect, useMemo, useState } from 'reac
|
|
|
4
4
|
|
|
5
5
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
6
6
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
7
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
7
8
|
import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
8
9
|
import type { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
9
10
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
@@ -11,6 +12,7 @@ import { CellSelection } from '@atlaskit/editor-tables';
|
|
|
11
12
|
import { getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
12
13
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
13
14
|
import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
15
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
14
16
|
import { token } from '@atlaskit/tokens';
|
|
15
17
|
|
|
16
18
|
import { clearHoverSelection } from '../../../pm-plugins/commands';
|
|
@@ -385,7 +387,16 @@ export const DragControlsWithSelection = ({
|
|
|
385
387
|
updateCellHoverLocation,
|
|
386
388
|
api,
|
|
387
389
|
}: Exclude<DragControlsProps, 'selection'>) => {
|
|
388
|
-
|
|
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;
|
|
389
400
|
|
|
390
401
|
return (
|
|
391
402
|
<DragControls
|
|
@@ -403,7 +414,7 @@ export const DragControlsWithSelection = ({
|
|
|
403
414
|
selectRows={selectRows}
|
|
404
415
|
updateCellHoverLocation={updateCellHoverLocation}
|
|
405
416
|
api={api}
|
|
406
|
-
selection={
|
|
417
|
+
selection={selection}
|
|
407
418
|
/>
|
|
408
419
|
);
|
|
409
420
|
};
|
|
@@ -3,6 +3,8 @@ import React from 'react';
|
|
|
3
3
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
4
4
|
import { SortingIcon } from '@atlaskit/editor-common/table';
|
|
5
5
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
6
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
7
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
6
8
|
|
|
7
9
|
import type { TablePlugin } from '../../tablePluginType';
|
|
8
10
|
|
|
@@ -12,8 +14,19 @@ type SortingIconWrapperProps = SortingIconProps & {
|
|
|
12
14
|
};
|
|
13
15
|
|
|
14
16
|
export const SortingIconWrapper = (props: SortingIconWrapperProps) => {
|
|
15
|
-
const { editorViewModeState } = useSharedPluginState(props.api, ['editorViewMode']
|
|
16
|
-
|
|
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;
|
|
28
|
+
|
|
29
|
+
if (mode === 'edit') {
|
|
17
30
|
return null;
|
|
18
31
|
}
|
|
19
32
|
// Ignored via go/ees005
|