@atlaskit/editor-plugin-table 22.4.15 → 22.4.17
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 +15 -0
- package/dist/cjs/pm-plugins/commands/active-table-menu.js +51 -0
- package/dist/cjs/pm-plugins/commands/commands-with-analytics.js +42 -10
- package/dist/cjs/pm-plugins/commands/index.js +13 -0
- package/dist/cjs/pm-plugins/drag-and-drop/commands-with-analytics.js +2 -0
- package/dist/cjs/pm-plugins/drag-and-drop/plugin.js +4 -0
- package/dist/cjs/pm-plugins/handlers.js +8 -1
- package/dist/cjs/pm-plugins/reducer.js +2 -0
- package/dist/cjs/tablePlugin.js +1 -0
- package/dist/cjs/ui/ContentComponent.js +1 -1
- package/dist/cjs/ui/FloatingContextualButton/index.js +28 -9
- package/dist/cjs/ui/FloatingContextualMenu/CellMenuPopup.js +58 -73
- package/dist/cjs/ui/FloatingContextualMenu/index.js +26 -12
- package/dist/cjs/ui/FloatingDragMenu/index.js +21 -8
- package/dist/cjs/ui/TableFloatingColumnControls/ColumnControls/index.js +13 -5
- package/dist/cjs/ui/TableFloatingControls/RowControls/DragControls.js +14 -5
- package/dist/cjs/ui/TableMenu/cell/getCellMenuComponents.js +8 -3
- package/dist/cjs/ui/TableMenu/cell/items/MergeCellsItem.js +16 -1
- package/dist/cjs/ui/TableMenu/cell/items/SplitCellItem.js +16 -1
- package/dist/cjs/ui/TableMenu/column/items/AddColumnLeftItem.js +4 -4
- package/dist/cjs/ui/TableMenu/column/items/AddColumnRightItem.js +4 -4
- package/dist/cjs/ui/TableMenu/column/items/DeleteColumnItem.js +2 -3
- package/dist/cjs/ui/TableMenu/column/items/DistributeColumnsItem.js +2 -3
- package/dist/cjs/ui/TableMenu/column/items/HeaderColumnToggleItem.js +2 -3
- package/dist/cjs/ui/TableMenu/column/items/MoveColumnLeftItem.js +2 -3
- package/dist/cjs/ui/TableMenu/column/items/MoveColumnRightItem.js +2 -3
- package/dist/cjs/ui/TableMenu/column/items/SortDecreasingItem.js +2 -3
- package/dist/cjs/ui/TableMenu/column/items/SortIncreasingItem.js +2 -3
- package/dist/cjs/ui/TableMenu/row/items/AddRowAboveItem.js +4 -4
- package/dist/cjs/ui/TableMenu/row/items/AddRowBelowItem.js +4 -4
- package/dist/cjs/ui/TableMenu/row/items/DeleteRowItem.js +2 -3
- package/dist/cjs/ui/TableMenu/row/items/HeaderRowToggleItem.js +2 -3
- package/dist/cjs/ui/TableMenu/row/items/MoveRowDownItem.js +2 -3
- package/dist/cjs/ui/TableMenu/row/items/MoveRowUpItem.js +2 -3
- package/dist/cjs/ui/TableMenu/row/items/NumberedRowsToggleItem.js +4 -3
- package/dist/cjs/ui/TableMenu/shared/TableMenu.compiled.css +0 -2
- package/dist/cjs/ui/TableMenu/shared/TableMenu.js +8 -9
- package/dist/cjs/ui/TableMenu/shared/getSharedItems.js +3 -1
- package/dist/cjs/ui/TableMenu/shared/getTableMenuComponents.js +1 -1
- package/dist/cjs/ui/TableMenu/shared/items/BackgroundColorItem.js +30 -4
- package/dist/cjs/ui/TableMenu/shared/items/ClearCellsItem.js +4 -3
- package/dist/es2019/pm-plugins/commands/active-table-menu.js +39 -0
- package/dist/es2019/pm-plugins/commands/commands-with-analytics.js +31 -2
- package/dist/es2019/pm-plugins/commands/index.js +1 -0
- package/dist/es2019/pm-plugins/drag-and-drop/commands-with-analytics.js +2 -0
- package/dist/es2019/pm-plugins/drag-and-drop/plugin.js +4 -0
- package/dist/es2019/pm-plugins/handlers.js +8 -1
- package/dist/es2019/pm-plugins/reducer.js +5 -0
- package/dist/es2019/tablePlugin.js +1 -0
- package/dist/es2019/ui/ContentComponent.js +1 -1
- package/dist/es2019/ui/FloatingContextualButton/index.js +29 -9
- package/dist/es2019/ui/FloatingContextualMenu/CellMenuPopup.js +60 -77
- package/dist/es2019/ui/FloatingContextualMenu/index.js +27 -12
- package/dist/es2019/ui/FloatingDragMenu/index.js +22 -8
- package/dist/es2019/ui/TableFloatingColumnControls/ColumnControls/index.js +12 -4
- package/dist/es2019/ui/TableFloatingControls/RowControls/DragControls.js +13 -4
- package/dist/es2019/ui/TableMenu/cell/getCellMenuComponents.js +9 -3
- package/dist/es2019/ui/TableMenu/cell/items/MergeCellsItem.js +18 -2
- package/dist/es2019/ui/TableMenu/cell/items/SplitCellItem.js +18 -2
- package/dist/es2019/ui/TableMenu/column/items/AddColumnLeftItem.js +3 -3
- package/dist/es2019/ui/TableMenu/column/items/AddColumnRightItem.js +3 -3
- package/dist/es2019/ui/TableMenu/column/items/DeleteColumnItem.js +2 -3
- package/dist/es2019/ui/TableMenu/column/items/DistributeColumnsItem.js +2 -3
- package/dist/es2019/ui/TableMenu/column/items/HeaderColumnToggleItem.js +2 -3
- package/dist/es2019/ui/TableMenu/column/items/MoveColumnLeftItem.js +2 -3
- package/dist/es2019/ui/TableMenu/column/items/MoveColumnRightItem.js +2 -3
- package/dist/es2019/ui/TableMenu/column/items/SortDecreasingItem.js +2 -3
- package/dist/es2019/ui/TableMenu/column/items/SortIncreasingItem.js +2 -3
- package/dist/es2019/ui/TableMenu/row/items/AddRowAboveItem.js +3 -3
- package/dist/es2019/ui/TableMenu/row/items/AddRowBelowItem.js +3 -3
- package/dist/es2019/ui/TableMenu/row/items/DeleteRowItem.js +2 -3
- package/dist/es2019/ui/TableMenu/row/items/HeaderRowToggleItem.js +2 -3
- package/dist/es2019/ui/TableMenu/row/items/MoveRowDownItem.js +2 -3
- package/dist/es2019/ui/TableMenu/row/items/MoveRowUpItem.js +2 -3
- package/dist/es2019/ui/TableMenu/row/items/NumberedRowsToggleItem.js +3 -2
- package/dist/es2019/ui/TableMenu/shared/TableMenu.compiled.css +0 -2
- package/dist/es2019/ui/TableMenu/shared/TableMenu.js +8 -9
- package/dist/es2019/ui/TableMenu/shared/getSharedItems.js +3 -1
- package/dist/es2019/ui/TableMenu/shared/getTableMenuComponents.js +1 -1
- package/dist/es2019/ui/TableMenu/shared/items/BackgroundColorItem.js +33 -4
- package/dist/es2019/ui/TableMenu/shared/items/ClearCellsItem.js +4 -3
- package/dist/esm/pm-plugins/commands/active-table-menu.js +45 -0
- package/dist/esm/pm-plugins/commands/commands-with-analytics.js +41 -10
- package/dist/esm/pm-plugins/commands/index.js +1 -0
- package/dist/esm/pm-plugins/drag-and-drop/commands-with-analytics.js +2 -0
- package/dist/esm/pm-plugins/drag-and-drop/plugin.js +4 -0
- package/dist/esm/pm-plugins/handlers.js +8 -1
- package/dist/esm/pm-plugins/reducer.js +2 -0
- package/dist/esm/tablePlugin.js +1 -0
- package/dist/esm/ui/ContentComponent.js +1 -1
- package/dist/esm/ui/FloatingContextualButton/index.js +29 -10
- package/dist/esm/ui/FloatingContextualMenu/CellMenuPopup.js +60 -75
- package/dist/esm/ui/FloatingContextualMenu/index.js +26 -12
- package/dist/esm/ui/FloatingDragMenu/index.js +21 -8
- package/dist/esm/ui/TableFloatingColumnControls/ColumnControls/index.js +12 -4
- package/dist/esm/ui/TableFloatingControls/RowControls/DragControls.js +13 -4
- package/dist/esm/ui/TableMenu/cell/getCellMenuComponents.js +8 -3
- package/dist/esm/ui/TableMenu/cell/items/MergeCellsItem.js +16 -2
- package/dist/esm/ui/TableMenu/cell/items/SplitCellItem.js +16 -2
- package/dist/esm/ui/TableMenu/column/items/AddColumnLeftItem.js +4 -4
- package/dist/esm/ui/TableMenu/column/items/AddColumnRightItem.js +4 -4
- package/dist/esm/ui/TableMenu/column/items/DeleteColumnItem.js +2 -3
- package/dist/esm/ui/TableMenu/column/items/DistributeColumnsItem.js +2 -3
- package/dist/esm/ui/TableMenu/column/items/HeaderColumnToggleItem.js +2 -3
- package/dist/esm/ui/TableMenu/column/items/MoveColumnLeftItem.js +2 -3
- package/dist/esm/ui/TableMenu/column/items/MoveColumnRightItem.js +2 -3
- package/dist/esm/ui/TableMenu/column/items/SortDecreasingItem.js +2 -3
- package/dist/esm/ui/TableMenu/column/items/SortIncreasingItem.js +2 -3
- package/dist/esm/ui/TableMenu/row/items/AddRowAboveItem.js +4 -4
- package/dist/esm/ui/TableMenu/row/items/AddRowBelowItem.js +4 -4
- package/dist/esm/ui/TableMenu/row/items/DeleteRowItem.js +2 -3
- package/dist/esm/ui/TableMenu/row/items/HeaderRowToggleItem.js +2 -3
- package/dist/esm/ui/TableMenu/row/items/MoveRowDownItem.js +2 -3
- package/dist/esm/ui/TableMenu/row/items/MoveRowUpItem.js +2 -3
- package/dist/esm/ui/TableMenu/row/items/NumberedRowsToggleItem.js +4 -3
- package/dist/esm/ui/TableMenu/shared/TableMenu.compiled.css +0 -2
- package/dist/esm/ui/TableMenu/shared/TableMenu.js +8 -9
- package/dist/esm/ui/TableMenu/shared/getSharedItems.js +3 -1
- package/dist/esm/ui/TableMenu/shared/getTableMenuComponents.js +1 -1
- package/dist/esm/ui/TableMenu/shared/items/BackgroundColorItem.js +30 -4
- package/dist/esm/ui/TableMenu/shared/items/ClearCellsItem.js +4 -3
- package/dist/types/entry-points/types.d.ts +1 -1
- package/dist/types/pm-plugins/commands/active-table-menu.d.ts +6 -0
- package/dist/types/pm-plugins/commands/commands-with-analytics.d.ts +3 -1
- package/dist/types/pm-plugins/commands/index.d.ts +1 -0
- package/dist/types/types/index.d.ts +21 -1
- package/dist/types/ui/FloatingContextualButton/index.d.ts +2 -0
- package/dist/types/ui/FloatingContextualMenu/CellMenuPopup.d.ts +7 -5
- package/dist/types/ui/FloatingContextualMenu/index.d.ts +0 -1
- package/dist/types/ui/TableMenu/cell/getCellMenuComponents.d.ts +2 -1
- package/dist/types/ui/TableMenu/cell/items/MergeCellsItem.d.ts +2 -1
- package/dist/types/ui/TableMenu/cell/items/SplitCellItem.d.ts +2 -1
- package/dist/types/ui/TableMenu/shared/TableMenuContext.d.ts +2 -0
- package/dist/types/ui/TableMenu/shared/items/BackgroundColorItem.d.ts +2 -1
- package/dist/types-ts4.5/entry-points/types.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/commands/active-table-menu.d.ts +6 -0
- package/dist/types-ts4.5/pm-plugins/commands/commands-with-analytics.d.ts +3 -1
- package/dist/types-ts4.5/pm-plugins/commands/index.d.ts +1 -0
- package/dist/types-ts4.5/types/index.d.ts +21 -1
- package/dist/types-ts4.5/ui/FloatingContextualButton/index.d.ts +2 -0
- package/dist/types-ts4.5/ui/FloatingContextualMenu/CellMenuPopup.d.ts +7 -5
- package/dist/types-ts4.5/ui/FloatingContextualMenu/index.d.ts +0 -1
- package/dist/types-ts4.5/ui/TableMenu/cell/getCellMenuComponents.d.ts +2 -1
- package/dist/types-ts4.5/ui/TableMenu/cell/items/MergeCellsItem.d.ts +2 -1
- package/dist/types-ts4.5/ui/TableMenu/cell/items/SplitCellItem.d.ts +2 -1
- package/dist/types-ts4.5/ui/TableMenu/shared/TableMenuContext.d.ts +2 -0
- package/dist/types-ts4.5/ui/TableMenu/shared/items/BackgroundColorItem.d.ts +2 -1
- package/package.json +4 -4
|
@@ -4,7 +4,6 @@ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
|
4
4
|
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
5
5
|
import { moveRowDown, tooltip } from '@atlaskit/editor-common/keymaps';
|
|
6
6
|
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
7
|
-
import { useEditorToolbar } from '@atlaskit/editor-common/toolbar';
|
|
8
7
|
import { getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
9
8
|
import { TableRowMoveDownIcon, ToolbarDropdownItem, ToolbarKeyboardShortcutHint } from '@atlaskit/editor-toolbar';
|
|
10
9
|
import { moveSourceWithAnalytics } from '../../../../pm-plugins/drag-and-drop/commands-with-analytics';
|
|
@@ -18,10 +17,10 @@ export const MoveRowDownItem = props => {
|
|
|
18
17
|
const {
|
|
19
18
|
api
|
|
20
19
|
} = props;
|
|
20
|
+
const tableMenuContext = useTableMenuContext();
|
|
21
21
|
const {
|
|
22
22
|
editorView
|
|
23
|
-
} =
|
|
24
|
-
const tableMenuContext = useTableMenuContext();
|
|
23
|
+
} = tableMenuContext !== null && tableMenuContext !== void 0 ? tableMenuContext : {};
|
|
25
24
|
const {
|
|
26
25
|
tableNode
|
|
27
26
|
} = useSharedPluginStateWithSelector(api !== null && api !== void 0 ? api : undefined, ['table'], states => {
|
|
@@ -4,7 +4,6 @@ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
|
4
4
|
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
5
5
|
import { moveRowUp, tooltip } from '@atlaskit/editor-common/keymaps';
|
|
6
6
|
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
7
|
-
import { useEditorToolbar } from '@atlaskit/editor-common/toolbar';
|
|
8
7
|
import { getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
9
8
|
import { TableRowMoveUpIcon, ToolbarDropdownItem, ToolbarKeyboardShortcutHint } from '@atlaskit/editor-toolbar';
|
|
10
9
|
import { moveSourceWithAnalytics } from '../../../../pm-plugins/drag-and-drop/commands-with-analytics';
|
|
@@ -18,10 +17,10 @@ export const MoveRowUpItem = props => {
|
|
|
18
17
|
const {
|
|
19
18
|
api
|
|
20
19
|
} = props;
|
|
20
|
+
const tableMenuContext = useTableMenuContext();
|
|
21
21
|
const {
|
|
22
22
|
editorView
|
|
23
|
-
} =
|
|
24
|
-
const tableMenuContext = useTableMenuContext();
|
|
23
|
+
} = tableMenuContext !== null && tableMenuContext !== void 0 ? tableMenuContext : {};
|
|
25
24
|
const {
|
|
26
25
|
tableNode
|
|
27
26
|
} = useSharedPluginStateWithSelector(api !== null && api !== void 0 ? api : undefined, ['table'], states => {
|
|
@@ -2,17 +2,18 @@ import React from 'react';
|
|
|
2
2
|
import { useIntl } from 'react-intl';
|
|
3
3
|
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
4
4
|
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
5
|
-
import { useEditorToolbar } from '@atlaskit/editor-common/toolbar';
|
|
6
5
|
import { ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
|
|
7
6
|
import Toggle from '@atlaskit/toggle';
|
|
8
7
|
import { toggleNumberColumnWithAnalytics } from '../../../../pm-plugins/commands/commands-with-analytics';
|
|
8
|
+
import { useTableMenuContext } from '../../shared/TableMenuContext';
|
|
9
9
|
export const NumberedRowsToggleItem = props => {
|
|
10
|
+
var _useTableMenuContext;
|
|
10
11
|
const {
|
|
11
12
|
api
|
|
12
13
|
} = props;
|
|
13
14
|
const {
|
|
14
15
|
editorView
|
|
15
|
-
} =
|
|
16
|
+
} = (_useTableMenuContext = useTableMenuContext()) !== null && _useTableMenuContext !== void 0 ? _useTableMenuContext : {};
|
|
16
17
|
const {
|
|
17
18
|
isNumberColumnAllowed,
|
|
18
19
|
isNumberColumnEnabled
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
|
|
2
2
|
._2rko1qi0{border-radius:var(--ds-radius-medium,6px)}._16qs130s{box-shadow:var(--ds-shadow-overlay,0 8px 9pt #1e1f2126,0 0 1px #1e1f214f)}
|
|
3
|
-
._18m915vq{overflow-y:hidden}
|
|
4
3
|
._1bsb1178{width:280px}
|
|
5
|
-
._1reo15vq{overflow-x:hidden}
|
|
6
4
|
._bfhk1bhr{background-color:var(--ds-surface-overlay,#fff)}
|
|
@@ -3,7 +3,6 @@ import "./TableMenu.compiled.css";
|
|
|
3
3
|
import { ax, ix } from "@compiled/react/runtime";
|
|
4
4
|
import React, { memo, useMemo } from 'react';
|
|
5
5
|
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
6
|
-
import { EditorToolbarProvider } from '@atlaskit/editor-common/toolbar';
|
|
7
6
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
8
7
|
import { getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
9
8
|
import { SurfaceRenderer } from '@atlaskit/editor-ui-control-model';
|
|
@@ -12,9 +11,8 @@ import { canSplitCellSelection } from '../../../pm-plugins/commands/split-cell';
|
|
|
12
11
|
import { canMergeCellSelection } from '../../../pm-plugins/transforms/merge';
|
|
13
12
|
import { TableMenuProvider } from './TableMenuContext';
|
|
14
13
|
const tableMenuContainerStyles = {
|
|
15
|
-
container: "_2rko1qi0
|
|
14
|
+
container: "_2rko1qi0 _1bsb1178 _16qs130s _bfhk1bhr"
|
|
16
15
|
};
|
|
17
|
-
const EMPTY_CONTEXT = {};
|
|
18
16
|
export const TableMenu = /*#__PURE__*/memo(({
|
|
19
17
|
api,
|
|
20
18
|
editorView,
|
|
@@ -36,11 +34,14 @@ export const TableMenu = /*#__PURE__*/memo(({
|
|
|
36
34
|
});
|
|
37
35
|
const tableMenuContext = useMemo(() => {
|
|
38
36
|
if (!selection || !tableNode) {
|
|
39
|
-
return
|
|
37
|
+
return {
|
|
38
|
+
editorView
|
|
39
|
+
};
|
|
40
40
|
}
|
|
41
41
|
const tableMap = TableMap.get(tableNode);
|
|
42
42
|
const selectionRect = getSelectionRect(selection);
|
|
43
43
|
const cellOps = {
|
|
44
|
+
editorView,
|
|
44
45
|
canMergeCells: canMergeCellSelection(selection),
|
|
45
46
|
canSplitCell: canSplitCellSelection(selection),
|
|
46
47
|
hasMergedCellsInTable: tableMap.hasMergedCells()
|
|
@@ -57,13 +58,11 @@ export const TableMenu = /*#__PURE__*/memo(({
|
|
|
57
58
|
isLastColumn: selectionRect.right === tableMap.width,
|
|
58
59
|
selectedColumnCount: selectionRect.right - selectionRect.left
|
|
59
60
|
};
|
|
60
|
-
}, [selection, tableNode]);
|
|
61
|
+
}, [editorView, selection, tableNode]);
|
|
61
62
|
if (components.length === 0) {
|
|
62
63
|
return null;
|
|
63
64
|
}
|
|
64
|
-
return /*#__PURE__*/React.createElement(
|
|
65
|
-
editorView: editorView !== null && editorView !== void 0 ? editorView : null
|
|
66
|
-
}, /*#__PURE__*/React.createElement(TableMenuProvider, {
|
|
65
|
+
return /*#__PURE__*/React.createElement(TableMenuProvider, {
|
|
67
66
|
value: tableMenuContext
|
|
68
67
|
}, /*#__PURE__*/React.createElement(Box, {
|
|
69
68
|
xcss: tableMenuContainerStyles.container,
|
|
@@ -71,6 +70,6 @@ export const TableMenu = /*#__PURE__*/memo(({
|
|
|
71
70
|
}, /*#__PURE__*/React.createElement(SurfaceRenderer, {
|
|
72
71
|
surface: surface,
|
|
73
72
|
components: components
|
|
74
|
-
})))
|
|
73
|
+
})));
|
|
75
74
|
});
|
|
76
75
|
TableMenu.displayName = 'TableMenu';
|
|
@@ -23,7 +23,9 @@ export const getSharedItems = ({
|
|
|
23
23
|
key: CELL_ACTION_SECTION.key,
|
|
24
24
|
rank: CELL_ACTION_SECTION_RANK[BACKGROUND_COLOR_ITEM.key]
|
|
25
25
|
}],
|
|
26
|
-
component: () => /*#__PURE__*/React.createElement(BackgroundColorItem,
|
|
26
|
+
component: () => /*#__PURE__*/React.createElement(BackgroundColorItem, {
|
|
27
|
+
api: api
|
|
28
|
+
})
|
|
27
29
|
}, {
|
|
28
30
|
type: CLEAR_CELLS_ITEM.type,
|
|
29
31
|
key: CLEAR_CELLS_ITEM.key,
|
|
@@ -2,4 +2,4 @@ import { getCellMenuComponents } from '../cell/getCellMenuComponents';
|
|
|
2
2
|
import { getColumnMenuComponents } from '../column/getColumnMenuComponents';
|
|
3
3
|
import { getRowMenuComponents } from '../row/getRowMenuComponents';
|
|
4
4
|
import { getSharedItems } from './getSharedItems';
|
|
5
|
-
export const getTableMenuComponents = params => [...getRowMenuComponents(params), ...getColumnMenuComponents(params), ...getCellMenuComponents(), ...getSharedItems(params)];
|
|
5
|
+
export const getTableMenuComponents = params => [...getRowMenuComponents(params), ...getColumnMenuComponents(params), ...getCellMenuComponents(params), ...getSharedItems(params)];
|
|
@@ -3,26 +3,55 @@ import "./BackgroundColorItem.compiled.css";
|
|
|
3
3
|
import { ax, ix } from "@compiled/react/runtime";
|
|
4
4
|
import React, { useCallback, useMemo } from 'react';
|
|
5
5
|
import { useIntl } from 'react-intl';
|
|
6
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
6
7
|
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
7
8
|
import { backgroundPaletteTooltipMessages, cellBackgroundColorPalette, ColorPalette } from '@atlaskit/editor-common/ui-color';
|
|
8
9
|
import { hexToEditorBackgroundPaletteColor } from '@atlaskit/editor-palette';
|
|
9
10
|
import { NestedDropdownRightIcon, PaintBucketIcon, ToolbarNestedDropdownMenu } from '@atlaskit/editor-toolbar';
|
|
10
11
|
import { Box } from '@atlaskit/primitives/compiled';
|
|
12
|
+
import { closeActiveTableMenu } from '../../../../pm-plugins/commands';
|
|
13
|
+
import { setColorWithAnalytics } from '../../../../pm-plugins/commands/commands-with-analytics';
|
|
14
|
+
import { getPluginState } from '../../../../pm-plugins/plugin-factory';
|
|
15
|
+
import { useTableMenuContext } from '../TableMenuContext';
|
|
11
16
|
const colorPaletteColumns = 7;
|
|
12
17
|
const colorPaletteStyles = {
|
|
13
18
|
container: "_1rjcu2gc",
|
|
14
19
|
elemAfter: "_zulp1b66 _1e0c1txw _4cvr1h6o",
|
|
15
20
|
colorPreview: "_2rko12b0 _1h6d1l7x _1dqonqa1 _189ee4h9 _1bsbdlk8 _4t3idlk8 _1o9zidpf"
|
|
16
21
|
};
|
|
17
|
-
export const BackgroundColorItem = (
|
|
22
|
+
export const BackgroundColorItem = ({
|
|
23
|
+
api
|
|
24
|
+
}) => {
|
|
25
|
+
var _useTableMenuContext, _api$analytics2;
|
|
26
|
+
const {
|
|
27
|
+
editorView
|
|
28
|
+
} = (_useTableMenuContext = useTableMenuContext()) !== null && _useTableMenuContext !== void 0 ? _useTableMenuContext : {};
|
|
18
29
|
const {
|
|
19
30
|
formatMessage
|
|
20
31
|
} = useIntl();
|
|
21
|
-
const
|
|
32
|
+
const selectedColor = useMemo(() => {
|
|
33
|
+
var _node$attrs;
|
|
34
|
+
if (!editorView) {
|
|
35
|
+
return '#ffffff';
|
|
36
|
+
}
|
|
37
|
+
const {
|
|
38
|
+
targetCellPosition
|
|
39
|
+
} = getPluginState(editorView.state);
|
|
40
|
+
const node = targetCellPosition ? editorView.state.doc.nodeAt(targetCellPosition) : null;
|
|
41
|
+
return hexToEditorBackgroundPaletteColor((node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.background) || '#ffffff');
|
|
42
|
+
}, [editorView]);
|
|
43
|
+
const onClick = useCallback(color => {
|
|
44
|
+
var _api$analytics;
|
|
45
|
+
if (!editorView) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
setColorWithAnalytics(api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)(INPUT_METHOD.TABLE_CONTEXT_MENU, color, editorView)(editorView.state, editorView.dispatch);
|
|
49
|
+
closeActiveTableMenu()(editorView.state, editorView.dispatch);
|
|
50
|
+
}, [api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, editorView]);
|
|
22
51
|
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
|
|
23
52
|
const colorPreviewStyle = useMemo(() => ({
|
|
24
|
-
backgroundColor:
|
|
25
|
-
}), []);
|
|
53
|
+
backgroundColor: selectedColor
|
|
54
|
+
}), [selectedColor]);
|
|
26
55
|
const paletteOptions = useMemo(() => {
|
|
27
56
|
return {
|
|
28
57
|
palette: cellBackgroundColorPalette,
|
|
@@ -3,8 +3,8 @@ import { useIntl } from 'react-intl';
|
|
|
3
3
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
4
|
import { backspace, tooltip } from '@atlaskit/editor-common/keymaps';
|
|
5
5
|
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
6
|
-
import { useEditorToolbar } from '@atlaskit/editor-common/toolbar';
|
|
7
6
|
import { CrossIcon, ToolbarDropdownItem, ToolbarKeyboardShortcutHint } from '@atlaskit/editor-toolbar';
|
|
7
|
+
import { closeActiveTableMenu } from '../../../../pm-plugins/commands';
|
|
8
8
|
import { emptyMultipleCellsWithAnalytics } from '../../../../pm-plugins/commands/commands-with-analytics';
|
|
9
9
|
import { getPluginState } from '../../../../pm-plugins/plugin-factory';
|
|
10
10
|
import { useTableMenuContext } from '../TableMenuContext';
|
|
@@ -12,10 +12,10 @@ export const ClearCellsItem = ({
|
|
|
12
12
|
api
|
|
13
13
|
}) => {
|
|
14
14
|
var _tableMenuContext$sel, _tableMenuContext$sel2, _tooltip;
|
|
15
|
+
const tableMenuContext = useTableMenuContext();
|
|
15
16
|
const {
|
|
16
17
|
editorView
|
|
17
|
-
} =
|
|
18
|
-
const tableMenuContext = useTableMenuContext();
|
|
18
|
+
} = tableMenuContext !== null && tableMenuContext !== void 0 ? tableMenuContext : {};
|
|
19
19
|
const {
|
|
20
20
|
formatMessage
|
|
21
21
|
} = useIntl();
|
|
@@ -29,6 +29,7 @@ export const ClearCellsItem = ({
|
|
|
29
29
|
targetCellPosition
|
|
30
30
|
} = getPluginState(editorView.state);
|
|
31
31
|
emptyMultipleCellsWithAnalytics(api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)(INPUT_METHOD.TABLE_CONTEXT_MENU, targetCellPosition)(editorView.state, editorView.dispatch);
|
|
32
|
+
closeActiveTableMenu()(editorView.state, editorView.dispatch);
|
|
32
33
|
};
|
|
33
34
|
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
34
35
|
onClick: handleClick,
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { createCommand, getPluginState } from '../plugin-factory';
|
|
2
|
+
export var closeActiveTableMenu = function closeActiveTableMenu() {
|
|
3
|
+
return createCommand(function (state) {
|
|
4
|
+
var _getPluginState = getPluginState(state),
|
|
5
|
+
activeTableMenu = _getPluginState.activeTableMenu;
|
|
6
|
+
if (!activeTableMenu || activeTableMenu.type === 'none') {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
return {
|
|
10
|
+
type: 'SET_ACTIVE_TABLE_MENU',
|
|
11
|
+
data: {
|
|
12
|
+
activeTableMenu: {
|
|
13
|
+
type: 'none'
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
}, function (tr) {
|
|
18
|
+
return tr.setMeta('addToHistory', false);
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var isSameActiveTableMenu = function isSameActiveTableMenu(current, next) {
|
|
22
|
+
if (!current || current.type !== next.type) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
if (current.type === 'row' || current.type === 'column') {
|
|
26
|
+
return next.type === current.type && current.index === next.index;
|
|
27
|
+
}
|
|
28
|
+
return true;
|
|
29
|
+
};
|
|
30
|
+
export var toggleActiveTableMenu = function toggleActiveTableMenu(activeTableMenu) {
|
|
31
|
+
return createCommand(function (state) {
|
|
32
|
+
var _getPluginState2 = getPluginState(state),
|
|
33
|
+
currentActiveTableMenu = _getPluginState2.activeTableMenu;
|
|
34
|
+
return {
|
|
35
|
+
type: 'SET_ACTIVE_TABLE_MENU',
|
|
36
|
+
data: {
|
|
37
|
+
activeTableMenu: isSameActiveTableMenu(currentActiveTableMenu, activeTableMenu) ? {
|
|
38
|
+
type: 'none'
|
|
39
|
+
} : activeTableMenu
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}, function (tr) {
|
|
43
|
+
return tr.setMeta('addToHistory', false);
|
|
44
|
+
});
|
|
45
|
+
};
|
|
@@ -13,6 +13,7 @@ import { deleteRows } from '../transforms/delete-rows';
|
|
|
13
13
|
import { mergeCells } from '../transforms/merge';
|
|
14
14
|
import { withEditorAnalyticsAPI, getSelectedCellInfo, getSelectedTableInfo } from '../utils/analytics';
|
|
15
15
|
import { checkIfNumberColumnEnabled } from '../utils/nodes';
|
|
16
|
+
import { toggleActiveTableMenu } from './active-table-menu';
|
|
16
17
|
import { clearMultipleCells } from './clear';
|
|
17
18
|
import { wrapTableInExpand } from './collapse';
|
|
18
19
|
import { changeColumnWidthByStep } from './column-resize';
|
|
@@ -23,8 +24,38 @@ import { deleteTable, deleteTableIfSelected, getTableSelectionType, setMultipleC
|
|
|
23
24
|
import { sortByColumn } from './sort';
|
|
24
25
|
import { splitCell } from './split-cell';
|
|
25
26
|
import { toggleHeaderColumn, toggleHeaderRow, toggleNumberColumn } from './toggle';
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
export var toggleActiveTableMenuWithAnalytics = function toggleActiveTableMenuWithAnalytics(editorAnalyticsAPI) {
|
|
28
|
+
return function (direction, index) {
|
|
29
|
+
var trigger = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'mouse';
|
|
30
|
+
return withEditorAnalyticsAPI(function (state) {
|
|
31
|
+
var _getPluginState = getPluginState(state),
|
|
32
|
+
previousActiveTableMenu = _getPluginState.activeTableMenu;
|
|
33
|
+
var isSameActiveMenu = (previousActiveTableMenu === null || previousActiveTableMenu === void 0 ? void 0 : previousActiveTableMenu.type) === direction && previousActiveTableMenu.index === index;
|
|
34
|
+
if (isSameActiveMenu) {
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
action: TABLE_ACTION.DRAG_MENU_OPENED,
|
|
39
|
+
actionSubject: ACTION_SUBJECT.TABLE,
|
|
40
|
+
actionSubjectId: null,
|
|
41
|
+
eventType: EVENT_TYPE.TRACK,
|
|
42
|
+
attributes: {
|
|
43
|
+
inputMethod: trigger === 'keyboard' ? INPUT_METHOD.KEYBOARD : INPUT_METHOD.MOUSE,
|
|
44
|
+
direction: direction
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
})(editorAnalyticsAPI)(function (state, dispatch) {
|
|
48
|
+
if (dispatch) {
|
|
49
|
+
toggleActiveTableMenu({
|
|
50
|
+
type: direction,
|
|
51
|
+
index: index,
|
|
52
|
+
openedBy: trigger
|
|
53
|
+
})(state, dispatch);
|
|
54
|
+
}
|
|
55
|
+
return true;
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
};
|
|
28
59
|
export var emptyMultipleCellsWithAnalytics = function emptyMultipleCellsWithAnalytics(editorAnalyticsAPI) {
|
|
29
60
|
return function (inputMethod, targetCellPosition) {
|
|
30
61
|
return withEditorAnalyticsAPI(function (_ref) {
|
|
@@ -189,8 +220,8 @@ export var changeColumnWidthByStepWithAnalytics = function changeColumnWidthBySt
|
|
|
189
220
|
table = _getSelectedTableInfo2.table,
|
|
190
221
|
totalRowCount = _getSelectedTableInfo2.totalRowCount,
|
|
191
222
|
totalColumnCount = _getSelectedTableInfo2.totalColumnCount;
|
|
192
|
-
var
|
|
193
|
-
colIndex =
|
|
223
|
+
var _getPluginState2 = getPluginState(state),
|
|
224
|
+
colIndex = _getPluginState2.hoveredCell.colIndex;
|
|
194
225
|
return {
|
|
195
226
|
action: TABLE_ACTION.COLUMN_RESIZED,
|
|
196
227
|
actionSubject: ACTION_SUBJECT.TABLE,
|
|
@@ -310,8 +341,8 @@ export var deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut = function delete
|
|
|
310
341
|
}
|
|
311
342
|
var selectionType = getTableSelectionType(selection);
|
|
312
343
|
if (selectionType === 'row') {
|
|
313
|
-
var
|
|
314
|
-
pluginConfig =
|
|
344
|
+
var _getPluginState3 = getPluginState(state),
|
|
345
|
+
pluginConfig = _getPluginState3.pluginConfig;
|
|
315
346
|
var isHeaderRowRequired = pluginConfig.isHeaderRowRequired || false;
|
|
316
347
|
return deleteRowsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.SHORTCUT, rect, isHeaderRowRequired)(state, dispatch);
|
|
317
348
|
} else if (selectionType === 'column') {
|
|
@@ -355,8 +386,8 @@ export var toggleHeaderRowWithAnalytics = function toggleHeaderRowWithAnalytics(
|
|
|
355
386
|
var _getSelectedTableInfo7 = getSelectedTableInfo(state.selection),
|
|
356
387
|
totalRowCount = _getSelectedTableInfo7.totalRowCount,
|
|
357
388
|
totalColumnCount = _getSelectedTableInfo7.totalColumnCount;
|
|
358
|
-
var
|
|
359
|
-
isHeaderRowEnabled =
|
|
389
|
+
var _getPluginState4 = getPluginState(state),
|
|
390
|
+
isHeaderRowEnabled = _getPluginState4.isHeaderRowEnabled;
|
|
360
391
|
return {
|
|
361
392
|
action: TABLE_ACTION.TOGGLED_HEADER_ROW,
|
|
362
393
|
actionSubject: ACTION_SUBJECT.TABLE,
|
|
@@ -375,8 +406,8 @@ export var toggleHeaderColumnWithAnalytics = function toggleHeaderColumnWithAnal
|
|
|
375
406
|
var _getSelectedTableInfo8 = getSelectedTableInfo(state.selection),
|
|
376
407
|
totalRowCount = _getSelectedTableInfo8.totalRowCount,
|
|
377
408
|
totalColumnCount = _getSelectedTableInfo8.totalColumnCount;
|
|
378
|
-
var
|
|
379
|
-
isHeaderColumnEnabled =
|
|
409
|
+
var _getPluginState5 = getPluginState(state),
|
|
410
|
+
isHeaderColumnEnabled = _getPluginState5.isHeaderColumnEnabled;
|
|
380
411
|
return {
|
|
381
412
|
action: TABLE_ACTION.TOGGLED_HEADER_COLUMN,
|
|
382
413
|
actionSubject: ACTION_SUBJECT.TABLE,
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
export { hoverColumns, hoverRows, hoverTable, hoverCell, hoverMergedCells, clearHoverSelection, showResizeHandleLine, hideResizeHandleLine, setTableHovered } from './hover';
|
|
5
5
|
export { insertColumn, insertRow, createTable } from './insert';
|
|
6
6
|
export { getNextLayout, toggleContextualMenu, toggleHeaderColumn, toggleHeaderRow, toggleNumberColumn, toggleTableLayout } from './toggle';
|
|
7
|
+
export { closeActiveTableMenu, toggleActiveTableMenu } from './active-table-menu';
|
|
7
8
|
export { clearMultipleCells } from './clear';
|
|
8
9
|
export { autoSizeTable, convertFirstRowToHeader, deleteTable, hideInsertColumnOrRowButton, moveCursorBackward, selectColumn, selectColumns, selectRow, selectRows, setCellAttr, setEditorFocus, setMultipleCellAttrs, setTableRef, showInsertColumnButton, showInsertRowButton, transformSliceToAddTableHeaders, triggerUnlessTableHeader, addBoldInEmptyHeaderCells, addResizeHandleDecorations, updateWidthToWidest, setFocusToCellMenu } from './misc';
|
|
9
10
|
export { sortByColumn } from './sort';
|
|
@@ -146,6 +146,8 @@ export var cloneSourceWithAnalytics = function cloneSourceWithAnalytics(editorAn
|
|
|
146
146
|
});
|
|
147
147
|
};
|
|
148
148
|
};
|
|
149
|
+
|
|
150
|
+
// remove when 'platform_editor_table_menu_updates' is cleaned up
|
|
149
151
|
export var toggleDragMenuWithAnalytics = function toggleDragMenuWithAnalytics(editorAnalyticsAPI) {
|
|
150
152
|
return function (isDragMenuOpen, direction, index) {
|
|
151
153
|
var trigger = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'mouse';
|
|
@@ -8,6 +8,7 @@ import { autoScrollForElements } from '@atlaskit/pragmatic-drag-and-drop-auto-sc
|
|
|
8
8
|
import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';
|
|
9
9
|
import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
10
10
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
11
|
+
import { closeActiveTableMenu } from '../commands/active-table-menu';
|
|
11
12
|
import { getPluginState as getTablePluginState } from '../plugin-factory';
|
|
12
13
|
import { pluginKey as tablePluginKey } from '../plugin-key';
|
|
13
14
|
import { insertColgroupFromNode } from '../table-resizing/utils/colgroup';
|
|
@@ -87,6 +88,9 @@ var destroyFn = function destroyFn(editorView, editorAnalyticsAPI, isTableScalin
|
|
|
87
88
|
(_insm$session3 = insm.session) === null || _insm$session3 === void 0 || _insm$session3.startFeature('tableDragAndDrop');
|
|
88
89
|
}
|
|
89
90
|
toggleDragMenu(false)(editorView.state, editorView.dispatch);
|
|
91
|
+
if (expValEquals('platform_editor_table_menu_updates', 'isEnabled', true)) {
|
|
92
|
+
closeActiveTableMenu()(editorView.state, editorView.dispatch);
|
|
93
|
+
}
|
|
90
94
|
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 || (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 ? void 0 : _api$userIntent.commands.setCurrentUserIntent('dragging'));
|
|
91
95
|
},
|
|
92
96
|
onDrag: function onDrag(event) {
|
|
@@ -9,6 +9,7 @@ import { isTextInput } from '@atlaskit/editor-common/utils';
|
|
|
9
9
|
|
|
10
10
|
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
11
11
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
12
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
12
13
|
import { defaultTableSelection } from './default-table-selection';
|
|
13
14
|
import { pluginKey as tableResizingPluginKey } from './table-resizing/plugin-key';
|
|
14
15
|
import { isTableCollapsible } from './utils/collapse';
|
|
@@ -43,8 +44,14 @@ var updateTargetCellPosition = function updateTargetCellPosition(_ref) {
|
|
|
43
44
|
if (pluginState.targetCellPosition === targetCellPosition) {
|
|
44
45
|
return pluginState;
|
|
45
46
|
}
|
|
47
|
+
|
|
48
|
+
// The updated table menu is anchored to the current target cell. When selection moves
|
|
49
|
+
// to another cell, close the active menu so render state cannot point at a stale anchor.
|
|
46
50
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
47
|
-
targetCellPosition: targetCellPosition
|
|
51
|
+
targetCellPosition: targetCellPosition,
|
|
52
|
+
activeTableMenu: pluginState.activeTableMenu != null && pluginState.activeTableMenu.type !== 'none' && expValEquals('platform_editor_table_menu_updates', 'isEnabled', true) ? {
|
|
53
|
+
type: 'none'
|
|
54
|
+
} : pluginState.activeTableMenu
|
|
48
55
|
});
|
|
49
56
|
};
|
|
50
57
|
};
|
|
@@ -26,6 +26,8 @@ export default (function (pluginState, action) {
|
|
|
26
26
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
27
27
|
isContextualMenuOpen: !pluginState.isContextualMenuOpen
|
|
28
28
|
});
|
|
29
|
+
case 'SET_ACTIVE_TABLE_MENU':
|
|
30
|
+
return _objectSpread(_objectSpread({}, pluginState), action.data);
|
|
29
31
|
case 'SHOW_INSERT_ROW_BUTTON':
|
|
30
32
|
if (action.data.insertRowButtonIndex === pluginState.insertRowButtonIndex) {
|
|
31
33
|
return pluginState;
|
package/dist/esm/tablePlugin.js
CHANGED
|
@@ -143,6 +143,7 @@ var tablePlugin = function tablePlugin(_ref) {
|
|
|
143
143
|
insertRowButtonIndex: tablePluginState.insertRowButtonIndex,
|
|
144
144
|
tableWrapperTarget: tablePluginState.tableWrapperTarget,
|
|
145
145
|
isCellMenuOpenByKeyboard: tablePluginState.isCellMenuOpenByKeyboard,
|
|
146
|
+
activeTableMenu: tablePluginState.activeTableMenu,
|
|
146
147
|
stickyHeader: stickyHeader,
|
|
147
148
|
dragMenuDirection: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.dragMenuDirection,
|
|
148
149
|
dragMenuIndex: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.dragMenuIndex,
|
|
@@ -90,6 +90,7 @@ var ContentComponentInternal = function ContentComponentInternal(_ref) {
|
|
|
90
90
|
return null;
|
|
91
91
|
}
|
|
92
92
|
return /*#__PURE__*/React.createElement(React.Fragment, null, targetCellPosition && (tableRef || isCellMenuOpenByKeyboard) && !isResizing && options && options.allowContextualMenu && /*#__PURE__*/React.createElement(FloatingContextualButton, {
|
|
93
|
+
api: api,
|
|
93
94
|
isNumberColumnEnabled: tableNode && tableNode.attrs.isNumberColumnEnabled,
|
|
94
95
|
editorView: editorView,
|
|
95
96
|
tableNode: tableNode,
|
|
@@ -125,7 +126,6 @@ var ContentComponentInternal = function ContentComponentInternal(_ref) {
|
|
|
125
126
|
editorView: editorView,
|
|
126
127
|
mountPoint: popupsMountPoint,
|
|
127
128
|
boundariesElement: popupsBoundariesElement,
|
|
128
|
-
targetCellPosition: targetCellPosition,
|
|
129
129
|
isOpen: Boolean(isContextualMenuOpen) && !isResizing,
|
|
130
130
|
pluginConfig: pluginConfig,
|
|
131
131
|
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
@@ -8,6 +8,7 @@ import { css, jsx } from '@emotion/react';
|
|
|
8
8
|
import { injectIntl } from 'react-intl';
|
|
9
9
|
import { ACTION_SUBJECT } from '@atlaskit/editor-common/analytics';
|
|
10
10
|
import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
|
|
11
|
+
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
11
12
|
import { focusToContextMenuTrigger } from '@atlaskit/editor-common/keymaps';
|
|
12
13
|
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
13
14
|
import { Popup } from '@atlaskit/editor-common/ui';
|
|
@@ -17,7 +18,7 @@ import { akEditorSmallZIndex } from '@atlaskit/editor-shared-styles';
|
|
|
17
18
|
import ExpandIcon from '@atlaskit/icon/core/chevron-down';
|
|
18
19
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
19
20
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
20
|
-
import { toggleContextualMenu } from '../../pm-plugins/commands';
|
|
21
|
+
import { toggleActiveTableMenu, toggleContextualMenu } from '../../pm-plugins/commands';
|
|
21
22
|
import { isNativeStickySupported } from '../../pm-plugins/utils/sticky-header';
|
|
22
23
|
import { TableCssClassName as ClassName } from '../../types';
|
|
23
24
|
|
|
@@ -33,7 +34,8 @@ var anchorStyles = css({
|
|
|
33
34
|
zIndex: CONTEXTUAL_MENU_BUTTON_Z_INDEX
|
|
34
35
|
});
|
|
35
36
|
var FloatingContextualButtonInner = /*#__PURE__*/React.memo(function (props) {
|
|
36
|
-
var
|
|
37
|
+
var api = props.api,
|
|
38
|
+
editorView = props.editorView,
|
|
37
39
|
isContextualMenuOpen = props.isContextualMenuOpen,
|
|
38
40
|
mountPoint = props.mountPoint,
|
|
39
41
|
scrollableElement = props.scrollableElement,
|
|
@@ -42,12 +44,22 @@ var FloatingContextualButtonInner = /*#__PURE__*/React.memo(function (props) {
|
|
|
42
44
|
targetCellPosition = props.targetCellPosition,
|
|
43
45
|
isCellMenuOpenByKeyboard = props.isCellMenuOpenByKeyboard,
|
|
44
46
|
formatMessage = props.intl.formatMessage; // : Props & WrappedComponentProps
|
|
45
|
-
|
|
47
|
+
var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['table'], function (states) {
|
|
48
|
+
var _states$tableState;
|
|
49
|
+
return {
|
|
50
|
+
activeTableMenu: (_states$tableState = states.tableState) === null || _states$tableState === void 0 ? void 0 : _states$tableState.activeTableMenu
|
|
51
|
+
};
|
|
52
|
+
}),
|
|
53
|
+
activeTableMenu = _useSharedPluginState.activeTableMenu;
|
|
54
|
+
var isCellMenuOpen = expValEquals('platform_editor_table_menu_updates', 'isEnabled', true) ? (activeTableMenu === null || activeTableMenu === void 0 ? void 0 : activeTableMenu.type) === 'cell' : isContextualMenuOpen;
|
|
46
55
|
var handleClick = function handleClick() {
|
|
47
56
|
var state = editorView.state,
|
|
48
57
|
dispatch = editorView.dispatch;
|
|
49
58
|
if (expValEquals('platform_editor_table_menu_updates', 'isEnabled', true)) {
|
|
50
|
-
|
|
59
|
+
toggleActiveTableMenu({
|
|
60
|
+
type: 'cell',
|
|
61
|
+
openedBy: 'mouse'
|
|
62
|
+
})(state, dispatch);
|
|
51
63
|
return;
|
|
52
64
|
}
|
|
53
65
|
|
|
@@ -63,13 +75,20 @@ var FloatingContextualButtonInner = /*#__PURE__*/React.memo(function (props) {
|
|
|
63
75
|
var domAtPos = editorView.domAtPos.bind(editorView);
|
|
64
76
|
var targetCellRef = findDomRefAtPos(targetCellPosition, domAtPos);
|
|
65
77
|
useEffect(function () {
|
|
66
|
-
if (isCellMenuOpenByKeyboard && !
|
|
78
|
+
if (isCellMenuOpenByKeyboard && !isCellMenuOpen) {
|
|
67
79
|
var state = editorView.state,
|
|
68
80
|
dispatch = editorView.dispatch;
|
|
69
81
|
// open the menu when the keyboard shortcut is pressed
|
|
82
|
+
if (expValEquals('platform_editor_table_menu_updates', 'isEnabled', true)) {
|
|
83
|
+
toggleActiveTableMenu({
|
|
84
|
+
type: 'cell',
|
|
85
|
+
openedBy: 'keyboard'
|
|
86
|
+
})(state, dispatch);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
70
89
|
toggleContextualMenu()(state, dispatch);
|
|
71
90
|
}
|
|
72
|
-
}, [isCellMenuOpenByKeyboard,
|
|
91
|
+
}, [isCellMenuOpenByKeyboard, isCellMenuOpen, editorView]);
|
|
73
92
|
if (!targetCellRef || !(targetCellRef instanceof HTMLElement)) {
|
|
74
93
|
return null;
|
|
75
94
|
}
|
|
@@ -79,12 +98,12 @@ var FloatingContextualButtonInner = /*#__PURE__*/React.memo(function (props) {
|
|
|
79
98
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
|
|
80
99
|
tableFloatingCellButtonStyles(),
|
|
81
100
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
|
|
82
|
-
|
|
101
|
+
isCellMenuOpen && tableFloatingCellButtonSelectedStyles()]
|
|
83
102
|
}, jsx(ToolbarButton
|
|
84
103
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
85
104
|
, {
|
|
86
105
|
className: ClassName.CONTEXTUAL_MENU_BUTTON,
|
|
87
|
-
selected:
|
|
106
|
+
selected: isCellMenuOpen,
|
|
88
107
|
title: labelCellOptions,
|
|
89
108
|
keymap: focusToContextMenuTrigger,
|
|
90
109
|
onClick: handleClick,
|
|
@@ -94,7 +113,7 @@ var FloatingContextualButtonInner = /*#__PURE__*/React.memo(function (props) {
|
|
|
94
113
|
size: "small"
|
|
95
114
|
}),
|
|
96
115
|
"aria-label": labelCellOptions,
|
|
97
|
-
"aria-expanded":
|
|
116
|
+
"aria-expanded": isCellMenuOpen
|
|
98
117
|
}));
|
|
99
118
|
var parentSticky = targetCellRef.parentElement && targetCellRef.parentElement.className.indexOf('sticky') > -1;
|
|
100
119
|
var parentStickyNative = targetCellRef.parentElement && (fg('platform_editor_table_sticky_header_patch_4') ? tableWrapper === null || tableWrapper === void 0 ? void 0 : tableWrapper.classList.contains(ClassName.TABLE_NODE_WRAPPER_NO_OVERFLOW) : targetCellRef.parentElement.classList.contains(ClassName.NATIVE_STICKY));
|
|
@@ -149,7 +168,7 @@ var FloatingContextualButtonInner = /*#__PURE__*/React.memo(function (props) {
|
|
|
149
168
|
targetCellPosition: targetCellPosition,
|
|
150
169
|
targetCellRef: targetCellRef,
|
|
151
170
|
mountTo: tableWrapper,
|
|
152
|
-
isContextualMenuOpen:
|
|
171
|
+
isContextualMenuOpen: isCellMenuOpen
|
|
153
172
|
}, button);
|
|
154
173
|
}
|
|
155
174
|
return jsx(Popup, {
|