@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
|
@@ -12,7 +12,6 @@ var _runtime = require("@compiled/react/runtime");
|
|
|
12
12
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
13
|
var _react = _interopRequireWildcard(require("react"));
|
|
14
14
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
15
|
-
var _toolbar = require("@atlaskit/editor-common/toolbar");
|
|
16
15
|
var _tableMap = require("@atlaskit/editor-tables/table-map");
|
|
17
16
|
var _utils = require("@atlaskit/editor-tables/utils");
|
|
18
17
|
var _editorUiControlModel = require("@atlaskit/editor-ui-control-model");
|
|
@@ -24,9 +23,8 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
24
23
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
25
24
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
26
25
|
var tableMenuContainerStyles = {
|
|
27
|
-
container: "_2rko1qi0
|
|
26
|
+
container: "_2rko1qi0 _1bsb1178 _16qs130s _bfhk1bhr"
|
|
28
27
|
};
|
|
29
|
-
var EMPTY_CONTEXT = {};
|
|
30
28
|
var TableMenu = exports.TableMenu = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
31
29
|
var api = _ref.api,
|
|
32
30
|
editorView = _ref.editorView,
|
|
@@ -46,11 +44,14 @@ var TableMenu = exports.TableMenu = /*#__PURE__*/(0, _react.memo)(function (_ref
|
|
|
46
44
|
selection = _useSharedPluginState.selection;
|
|
47
45
|
var tableMenuContext = (0, _react.useMemo)(function () {
|
|
48
46
|
if (!selection || !tableNode) {
|
|
49
|
-
return
|
|
47
|
+
return {
|
|
48
|
+
editorView: editorView
|
|
49
|
+
};
|
|
50
50
|
}
|
|
51
51
|
var tableMap = _tableMap.TableMap.get(tableNode);
|
|
52
52
|
var selectionRect = (0, _utils.getSelectionRect)(selection);
|
|
53
53
|
var cellOps = {
|
|
54
|
+
editorView: editorView,
|
|
54
55
|
canMergeCells: (0, _merge.canMergeCellSelection)(selection),
|
|
55
56
|
canSplitCell: (0, _splitCell.canSplitCellSelection)(selection),
|
|
56
57
|
hasMergedCellsInTable: tableMap.hasMergedCells()
|
|
@@ -66,13 +67,11 @@ var TableMenu = exports.TableMenu = /*#__PURE__*/(0, _react.memo)(function (_ref
|
|
|
66
67
|
isLastColumn: selectionRect.right === tableMap.width,
|
|
67
68
|
selectedColumnCount: selectionRect.right - selectionRect.left
|
|
68
69
|
});
|
|
69
|
-
}, [selection, tableNode]);
|
|
70
|
+
}, [editorView, selection, tableNode]);
|
|
70
71
|
if (components.length === 0) {
|
|
71
72
|
return null;
|
|
72
73
|
}
|
|
73
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
74
|
-
editorView: editorView !== null && editorView !== void 0 ? editorView : null
|
|
75
|
-
}, /*#__PURE__*/_react.default.createElement(_TableMenuContext.TableMenuProvider, {
|
|
74
|
+
return /*#__PURE__*/_react.default.createElement(_TableMenuContext.TableMenuProvider, {
|
|
76
75
|
value: tableMenuContext
|
|
77
76
|
}, /*#__PURE__*/_react.default.createElement(_compiled.Box, {
|
|
78
77
|
xcss: tableMenuContainerStyles.container,
|
|
@@ -80,6 +79,6 @@ var TableMenu = exports.TableMenu = /*#__PURE__*/(0, _react.memo)(function (_ref
|
|
|
80
79
|
}, /*#__PURE__*/_react.default.createElement(_editorUiControlModel.SurfaceRenderer, {
|
|
81
80
|
surface: surface,
|
|
82
81
|
components: components
|
|
83
|
-
})))
|
|
82
|
+
})));
|
|
84
83
|
});
|
|
85
84
|
TableMenu.displayName = 'TableMenu';
|
|
@@ -31,7 +31,9 @@ var getSharedItems = exports.getSharedItems = function getSharedItems(_ref) {
|
|
|
31
31
|
rank: _keys.CELL_ACTION_SECTION_RANK[_keys4.BACKGROUND_COLOR_ITEM.key]
|
|
32
32
|
}],
|
|
33
33
|
component: function component() {
|
|
34
|
-
return /*#__PURE__*/_react.default.createElement(_BackgroundColorItem.BackgroundColorItem,
|
|
34
|
+
return /*#__PURE__*/_react.default.createElement(_BackgroundColorItem.BackgroundColorItem, {
|
|
35
|
+
api: api
|
|
36
|
+
});
|
|
35
37
|
}
|
|
36
38
|
}, {
|
|
37
39
|
type: _keys4.CLEAR_CELLS_ITEM.type,
|
|
@@ -11,5 +11,5 @@ var _getColumnMenuComponents = require("../column/getColumnMenuComponents");
|
|
|
11
11
|
var _getRowMenuComponents = require("../row/getRowMenuComponents");
|
|
12
12
|
var _getSharedItems = require("./getSharedItems");
|
|
13
13
|
var getTableMenuComponents = exports.getTableMenuComponents = function getTableMenuComponents(params) {
|
|
14
|
-
return [].concat((0, _toConsumableArray2.default)((0, _getRowMenuComponents.getRowMenuComponents)(params)), (0, _toConsumableArray2.default)((0, _getColumnMenuComponents.getColumnMenuComponents)(params)), (0, _toConsumableArray2.default)((0, _getCellMenuComponents.getCellMenuComponents)()), (0, _toConsumableArray2.default)((0, _getSharedItems.getSharedItems)(params)));
|
|
14
|
+
return [].concat((0, _toConsumableArray2.default)((0, _getRowMenuComponents.getRowMenuComponents)(params)), (0, _toConsumableArray2.default)((0, _getColumnMenuComponents.getColumnMenuComponents)(params)), (0, _toConsumableArray2.default)((0, _getCellMenuComponents.getCellMenuComponents)(params)), (0, _toConsumableArray2.default)((0, _getSharedItems.getSharedItems)(params)));
|
|
15
15
|
};
|
|
@@ -10,11 +10,16 @@ require("./BackgroundColorItem.compiled.css");
|
|
|
10
10
|
var _runtime = require("@compiled/react/runtime");
|
|
11
11
|
var _react = _interopRequireWildcard(require("react"));
|
|
12
12
|
var _reactIntl = require("react-intl");
|
|
13
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
13
14
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
14
15
|
var _uiColor = require("@atlaskit/editor-common/ui-color");
|
|
15
16
|
var _editorPalette = require("@atlaskit/editor-palette");
|
|
16
17
|
var _editorToolbar = require("@atlaskit/editor-toolbar");
|
|
17
18
|
var _compiled = require("@atlaskit/primitives/compiled");
|
|
19
|
+
var _commands = require("../../../../pm-plugins/commands");
|
|
20
|
+
var _commandsWithAnalytics = require("../../../../pm-plugins/commands/commands-with-analytics");
|
|
21
|
+
var _pluginFactory = require("../../../../pm-plugins/plugin-factory");
|
|
22
|
+
var _TableMenuContext = require("../TableMenuContext");
|
|
18
23
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
19
24
|
var colorPaletteColumns = 7;
|
|
20
25
|
var colorPaletteStyles = {
|
|
@@ -22,16 +27,37 @@ var colorPaletteStyles = {
|
|
|
22
27
|
elemAfter: "_zulp1b66 _1e0c1txw _4cvr1h6o",
|
|
23
28
|
colorPreview: "_2rko12b0 _1h6d1l7x _1dqonqa1 _189ee4h9 _1bsbdlk8 _4t3idlk8 _1o9zidpf"
|
|
24
29
|
};
|
|
25
|
-
var BackgroundColorItem = exports.BackgroundColorItem = function BackgroundColorItem() {
|
|
30
|
+
var BackgroundColorItem = exports.BackgroundColorItem = function BackgroundColorItem(_ref) {
|
|
31
|
+
var _useTableMenuContext, _api$analytics2;
|
|
32
|
+
var api = _ref.api;
|
|
33
|
+
var _ref2 = (_useTableMenuContext = (0, _TableMenuContext.useTableMenuContext)()) !== null && _useTableMenuContext !== void 0 ? _useTableMenuContext : {},
|
|
34
|
+
editorView = _ref2.editorView;
|
|
26
35
|
var _useIntl = (0, _reactIntl.useIntl)(),
|
|
27
36
|
formatMessage = _useIntl.formatMessage;
|
|
28
|
-
var
|
|
37
|
+
var selectedColor = (0, _react.useMemo)(function () {
|
|
38
|
+
var _node$attrs;
|
|
39
|
+
if (!editorView) {
|
|
40
|
+
return '#ffffff';
|
|
41
|
+
}
|
|
42
|
+
var _getPluginState = (0, _pluginFactory.getPluginState)(editorView.state),
|
|
43
|
+
targetCellPosition = _getPluginState.targetCellPosition;
|
|
44
|
+
var node = targetCellPosition ? editorView.state.doc.nodeAt(targetCellPosition) : null;
|
|
45
|
+
return (0, _editorPalette.hexToEditorBackgroundPaletteColor)((node === null || node === void 0 || (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.background) || '#ffffff');
|
|
46
|
+
}, [editorView]);
|
|
47
|
+
var onClick = (0, _react.useCallback)(function (color) {
|
|
48
|
+
var _api$analytics;
|
|
49
|
+
if (!editorView) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
(0, _commandsWithAnalytics.setColorWithAnalytics)(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)(_analytics.INPUT_METHOD.TABLE_CONTEXT_MENU, color, editorView)(editorView.state, editorView.dispatch);
|
|
53
|
+
(0, _commands.closeActiveTableMenu)()(editorView.state, editorView.dispatch);
|
|
54
|
+
}, [api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, editorView]);
|
|
29
55
|
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
|
|
30
56
|
var colorPreviewStyle = (0, _react.useMemo)(function () {
|
|
31
57
|
return {
|
|
32
|
-
backgroundColor:
|
|
58
|
+
backgroundColor: selectedColor
|
|
33
59
|
};
|
|
34
|
-
}, []);
|
|
60
|
+
}, [selectedColor]);
|
|
35
61
|
var paletteOptions = (0, _react.useMemo)(function () {
|
|
36
62
|
return {
|
|
37
63
|
palette: _uiColor.cellBackgroundColorPalette,
|
|
@@ -10,17 +10,17 @@ var _reactIntl = require("react-intl");
|
|
|
10
10
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
11
11
|
var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
12
12
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
13
|
-
var _toolbar = require("@atlaskit/editor-common/toolbar");
|
|
14
13
|
var _editorToolbar = require("@atlaskit/editor-toolbar");
|
|
14
|
+
var _commands = require("../../../../pm-plugins/commands");
|
|
15
15
|
var _commandsWithAnalytics = require("../../../../pm-plugins/commands/commands-with-analytics");
|
|
16
16
|
var _pluginFactory = require("../../../../pm-plugins/plugin-factory");
|
|
17
17
|
var _TableMenuContext = require("../TableMenuContext");
|
|
18
18
|
var ClearCellsItem = exports.ClearCellsItem = function ClearCellsItem(_ref) {
|
|
19
19
|
var _tableMenuContext$sel, _tableMenuContext$sel2, _tooltip;
|
|
20
20
|
var api = _ref.api;
|
|
21
|
-
var _useEditorToolbar = (0, _toolbar.useEditorToolbar)(),
|
|
22
|
-
editorView = _useEditorToolbar.editorView;
|
|
23
21
|
var tableMenuContext = (0, _TableMenuContext.useTableMenuContext)();
|
|
22
|
+
var _ref2 = tableMenuContext !== null && tableMenuContext !== void 0 ? tableMenuContext : {},
|
|
23
|
+
editorView = _ref2.editorView;
|
|
24
24
|
var _useIntl = (0, _reactIntl.useIntl)(),
|
|
25
25
|
formatMessage = _useIntl.formatMessage;
|
|
26
26
|
var selectedCellCount = Math.max((_tableMenuContext$sel = tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.selectedColumnCount) !== null && _tableMenuContext$sel !== void 0 ? _tableMenuContext$sel : 1, (_tableMenuContext$sel2 = tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.selectedRowCount) !== null && _tableMenuContext$sel2 !== void 0 ? _tableMenuContext$sel2 : 1);
|
|
@@ -32,6 +32,7 @@ var ClearCellsItem = exports.ClearCellsItem = function ClearCellsItem(_ref) {
|
|
|
32
32
|
var _getPluginState = (0, _pluginFactory.getPluginState)(editorView.state),
|
|
33
33
|
targetCellPosition = _getPluginState.targetCellPosition;
|
|
34
34
|
(0, _commandsWithAnalytics.emptyMultipleCellsWithAnalytics)(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)(_analytics.INPUT_METHOD.TABLE_CONTEXT_MENU, targetCellPosition)(editorView.state, editorView.dispatch);
|
|
35
|
+
(0, _commands.closeActiveTableMenu)()(editorView.state, editorView.dispatch);
|
|
35
36
|
};
|
|
36
37
|
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
|
|
37
38
|
onClick: handleClick,
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { createCommand, getPluginState } from '../plugin-factory';
|
|
2
|
+
export const closeActiveTableMenu = () => createCommand(state => {
|
|
3
|
+
const {
|
|
4
|
+
activeTableMenu
|
|
5
|
+
} = getPluginState(state);
|
|
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
|
+
}, tr => tr.setMeta('addToHistory', false));
|
|
18
|
+
const isSameActiveTableMenu = (current, next) => {
|
|
19
|
+
if (!current || current.type !== next.type) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
if (current.type === 'row' || current.type === 'column') {
|
|
23
|
+
return next.type === current.type && current.index === next.index;
|
|
24
|
+
}
|
|
25
|
+
return true;
|
|
26
|
+
};
|
|
27
|
+
export const toggleActiveTableMenu = activeTableMenu => createCommand(state => {
|
|
28
|
+
const {
|
|
29
|
+
activeTableMenu: currentActiveTableMenu
|
|
30
|
+
} = getPluginState(state);
|
|
31
|
+
return {
|
|
32
|
+
type: 'SET_ACTIVE_TABLE_MENU',
|
|
33
|
+
data: {
|
|
34
|
+
activeTableMenu: isSameActiveTableMenu(currentActiveTableMenu, activeTableMenu) ? {
|
|
35
|
+
type: 'none'
|
|
36
|
+
} : activeTableMenu
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}, tr => tr.setMeta('addToHistory', false));
|
|
@@ -10,6 +10,7 @@ import { deleteRows } from '../transforms/delete-rows';
|
|
|
10
10
|
import { mergeCells } from '../transforms/merge';
|
|
11
11
|
import { withEditorAnalyticsAPI, getSelectedCellInfo, getSelectedTableInfo } from '../utils/analytics';
|
|
12
12
|
import { checkIfNumberColumnEnabled } from '../utils/nodes';
|
|
13
|
+
import { toggleActiveTableMenu } from './active-table-menu';
|
|
13
14
|
import { clearMultipleCells } from './clear';
|
|
14
15
|
import { wrapTableInExpand } from './collapse';
|
|
15
16
|
import { changeColumnWidthByStep } from './column-resize';
|
|
@@ -20,8 +21,36 @@ import { deleteTable, deleteTableIfSelected, getTableSelectionType, setMultipleC
|
|
|
20
21
|
import { sortByColumn } from './sort';
|
|
21
22
|
import { splitCell } from './split-cell';
|
|
22
23
|
import { toggleHeaderColumn, toggleHeaderRow, toggleNumberColumn } from './toggle';
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
export const toggleActiveTableMenuWithAnalytics = editorAnalyticsAPI => (direction, index, trigger = 'mouse') => {
|
|
25
|
+
return withEditorAnalyticsAPI(state => {
|
|
26
|
+
const {
|
|
27
|
+
activeTableMenu: previousActiveTableMenu
|
|
28
|
+
} = getPluginState(state);
|
|
29
|
+
const isSameActiveMenu = (previousActiveTableMenu === null || previousActiveTableMenu === void 0 ? void 0 : previousActiveTableMenu.type) === direction && previousActiveTableMenu.index === index;
|
|
30
|
+
if (isSameActiveMenu) {
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
action: TABLE_ACTION.DRAG_MENU_OPENED,
|
|
35
|
+
actionSubject: ACTION_SUBJECT.TABLE,
|
|
36
|
+
actionSubjectId: null,
|
|
37
|
+
eventType: EVENT_TYPE.TRACK,
|
|
38
|
+
attributes: {
|
|
39
|
+
inputMethod: trigger === 'keyboard' ? INPUT_METHOD.KEYBOARD : INPUT_METHOD.MOUSE,
|
|
40
|
+
direction
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
})(editorAnalyticsAPI)((state, dispatch) => {
|
|
44
|
+
if (dispatch) {
|
|
45
|
+
toggleActiveTableMenu({
|
|
46
|
+
type: direction,
|
|
47
|
+
index,
|
|
48
|
+
openedBy: trigger
|
|
49
|
+
})(state, dispatch);
|
|
50
|
+
}
|
|
51
|
+
return true;
|
|
52
|
+
});
|
|
53
|
+
};
|
|
25
54
|
export const emptyMultipleCellsWithAnalytics = editorAnalyticsAPI => (inputMethod, targetCellPosition) => withEditorAnalyticsAPI(({
|
|
26
55
|
selection
|
|
27
56
|
}) => {
|
|
@@ -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';
|
|
@@ -141,6 +141,8 @@ export const cloneSourceWithAnalytics = editorAnalyticsAPI => (inputMethod, sour
|
|
|
141
141
|
return true;
|
|
142
142
|
});
|
|
143
143
|
};
|
|
144
|
+
|
|
145
|
+
// remove when 'platform_editor_table_menu_updates' is cleaned up
|
|
144
146
|
export const toggleDragMenuWithAnalytics = editorAnalyticsAPI => (isDragMenuOpen, direction, index, trigger = 'mouse') => {
|
|
145
147
|
return withEditorAnalyticsAPI(state => {
|
|
146
148
|
const {
|
|
@@ -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';
|
|
@@ -94,6 +95,9 @@ const destroyFn = (editorView, editorAnalyticsAPI, isTableScalingEnabled, isTabl
|
|
|
94
95
|
(_insm$session3 = insm.session) === null || _insm$session3 === void 0 ? void 0 : _insm$session3.startFeature('tableDragAndDrop');
|
|
95
96
|
}
|
|
96
97
|
toggleDragMenu(false)(editorView.state, editorView.dispatch);
|
|
98
|
+
if (expValEquals('platform_editor_table_menu_updates', 'isEnabled', true)) {
|
|
99
|
+
closeActiveTableMenu()(editorView.state, editorView.dispatch);
|
|
100
|
+
}
|
|
97
101
|
api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 ? void 0 : _api$userIntent.commands.setCurrentUserIntent('dragging'));
|
|
98
102
|
},
|
|
99
103
|
onDrag(event) {
|
|
@@ -6,6 +6,7 @@ import { isTextInput } from '@atlaskit/editor-common/utils';
|
|
|
6
6
|
|
|
7
7
|
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
8
8
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
9
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
9
10
|
import { defaultTableSelection } from './default-table-selection';
|
|
10
11
|
import { pluginKey as tableResizingPluginKey } from './table-resizing/plugin-key';
|
|
11
12
|
import { isTableCollapsible } from './utils/collapse';
|
|
@@ -40,9 +41,15 @@ const updateTargetCellPosition = ({
|
|
|
40
41
|
if (pluginState.targetCellPosition === targetCellPosition) {
|
|
41
42
|
return pluginState;
|
|
42
43
|
}
|
|
44
|
+
|
|
45
|
+
// The updated table menu is anchored to the current target cell. When selection moves
|
|
46
|
+
// to another cell, close the active menu so render state cannot point at a stale anchor.
|
|
43
47
|
return {
|
|
44
48
|
...pluginState,
|
|
45
|
-
targetCellPosition
|
|
49
|
+
targetCellPosition,
|
|
50
|
+
activeTableMenu: pluginState.activeTableMenu != null && pluginState.activeTableMenu.type !== 'none' && expValEquals('platform_editor_table_menu_updates', 'isEnabled', true) ? {
|
|
51
|
+
type: 'none'
|
|
52
|
+
} : pluginState.activeTableMenu
|
|
46
53
|
};
|
|
47
54
|
};
|
|
48
55
|
const updateTableNodePluginState = ({
|
|
@@ -34,6 +34,11 @@ export default ((pluginState, action) => {
|
|
|
34
34
|
...pluginState,
|
|
35
35
|
isContextualMenuOpen: !pluginState.isContextualMenuOpen
|
|
36
36
|
};
|
|
37
|
+
case 'SET_ACTIVE_TABLE_MENU':
|
|
38
|
+
return {
|
|
39
|
+
...pluginState,
|
|
40
|
+
...action.data
|
|
41
|
+
};
|
|
37
42
|
case 'SHOW_INSERT_ROW_BUTTON':
|
|
38
43
|
if (action.data.insertRowButtonIndex === pluginState.insertRowButtonIndex) {
|
|
39
44
|
return pluginState;
|
|
@@ -140,6 +140,7 @@ const tablePlugin = ({
|
|
|
140
140
|
insertRowButtonIndex: tablePluginState.insertRowButtonIndex,
|
|
141
141
|
tableWrapperTarget: tablePluginState.tableWrapperTarget,
|
|
142
142
|
isCellMenuOpenByKeyboard: tablePluginState.isCellMenuOpenByKeyboard,
|
|
143
|
+
activeTableMenu: tablePluginState.activeTableMenu,
|
|
143
144
|
stickyHeader,
|
|
144
145
|
dragMenuDirection: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.dragMenuDirection,
|
|
145
146
|
dragMenuIndex: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.dragMenuIndex,
|
|
@@ -93,6 +93,7 @@ const ContentComponentInternal = ({
|
|
|
93
93
|
return null;
|
|
94
94
|
}
|
|
95
95
|
return /*#__PURE__*/React.createElement(React.Fragment, null, targetCellPosition && (tableRef || isCellMenuOpenByKeyboard) && !isResizing && options && options.allowContextualMenu && /*#__PURE__*/React.createElement(FloatingContextualButton, {
|
|
96
|
+
api: api,
|
|
96
97
|
isNumberColumnEnabled: tableNode && tableNode.attrs.isNumberColumnEnabled,
|
|
97
98
|
editorView: editorView,
|
|
98
99
|
tableNode: tableNode,
|
|
@@ -128,7 +129,6 @@ const ContentComponentInternal = ({
|
|
|
128
129
|
editorView: editorView,
|
|
129
130
|
mountPoint: popupsMountPoint,
|
|
130
131
|
boundariesElement: popupsBoundariesElement,
|
|
131
|
-
targetCellPosition: targetCellPosition,
|
|
132
132
|
isOpen: Boolean(isContextualMenuOpen) && !isResizing,
|
|
133
133
|
pluginConfig: pluginConfig,
|
|
134
134
|
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
|
|
|
@@ -34,6 +35,7 @@ const anchorStyles = css({
|
|
|
34
35
|
});
|
|
35
36
|
const FloatingContextualButtonInner = /*#__PURE__*/React.memo(props => {
|
|
36
37
|
const {
|
|
38
|
+
api,
|
|
37
39
|
editorView,
|
|
38
40
|
isContextualMenuOpen,
|
|
39
41
|
mountPoint,
|
|
@@ -46,14 +48,25 @@ const FloatingContextualButtonInner = /*#__PURE__*/React.memo(props => {
|
|
|
46
48
|
formatMessage
|
|
47
49
|
}
|
|
48
50
|
} = props; // : Props & WrappedComponentProps
|
|
49
|
-
|
|
51
|
+
const {
|
|
52
|
+
activeTableMenu
|
|
53
|
+
} = useSharedPluginStateWithSelector(api, ['table'], states => {
|
|
54
|
+
var _states$tableState;
|
|
55
|
+
return {
|
|
56
|
+
activeTableMenu: (_states$tableState = states.tableState) === null || _states$tableState === void 0 ? void 0 : _states$tableState.activeTableMenu
|
|
57
|
+
};
|
|
58
|
+
});
|
|
59
|
+
const isCellMenuOpen = expValEquals('platform_editor_table_menu_updates', 'isEnabled', true) ? (activeTableMenu === null || activeTableMenu === void 0 ? void 0 : activeTableMenu.type) === 'cell' : isContextualMenuOpen;
|
|
50
60
|
const handleClick = () => {
|
|
51
61
|
const {
|
|
52
62
|
state,
|
|
53
63
|
dispatch
|
|
54
64
|
} = editorView;
|
|
55
65
|
if (expValEquals('platform_editor_table_menu_updates', 'isEnabled', true)) {
|
|
56
|
-
|
|
66
|
+
toggleActiveTableMenu({
|
|
67
|
+
type: 'cell',
|
|
68
|
+
openedBy: 'mouse'
|
|
69
|
+
})(state, dispatch);
|
|
57
70
|
return;
|
|
58
71
|
}
|
|
59
72
|
|
|
@@ -69,15 +82,22 @@ const FloatingContextualButtonInner = /*#__PURE__*/React.memo(props => {
|
|
|
69
82
|
const domAtPos = editorView.domAtPos.bind(editorView);
|
|
70
83
|
const targetCellRef = findDomRefAtPos(targetCellPosition, domAtPos);
|
|
71
84
|
useEffect(() => {
|
|
72
|
-
if (isCellMenuOpenByKeyboard && !
|
|
85
|
+
if (isCellMenuOpenByKeyboard && !isCellMenuOpen) {
|
|
73
86
|
const {
|
|
74
87
|
state,
|
|
75
88
|
dispatch
|
|
76
89
|
} = editorView;
|
|
77
90
|
// open the menu when the keyboard shortcut is pressed
|
|
91
|
+
if (expValEquals('platform_editor_table_menu_updates', 'isEnabled', true)) {
|
|
92
|
+
toggleActiveTableMenu({
|
|
93
|
+
type: 'cell',
|
|
94
|
+
openedBy: 'keyboard'
|
|
95
|
+
})(state, dispatch);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
78
98
|
toggleContextualMenu()(state, dispatch);
|
|
79
99
|
}
|
|
80
|
-
}, [isCellMenuOpenByKeyboard,
|
|
100
|
+
}, [isCellMenuOpenByKeyboard, isCellMenuOpen, editorView]);
|
|
81
101
|
if (!targetCellRef || !(targetCellRef instanceof HTMLElement)) {
|
|
82
102
|
return null;
|
|
83
103
|
}
|
|
@@ -87,12 +107,12 @@ const FloatingContextualButtonInner = /*#__PURE__*/React.memo(props => {
|
|
|
87
107
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
|
|
88
108
|
tableFloatingCellButtonStyles(),
|
|
89
109
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
|
|
90
|
-
|
|
110
|
+
isCellMenuOpen && tableFloatingCellButtonSelectedStyles()]
|
|
91
111
|
}, jsx(ToolbarButton
|
|
92
112
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
93
113
|
, {
|
|
94
114
|
className: ClassName.CONTEXTUAL_MENU_BUTTON,
|
|
95
|
-
selected:
|
|
115
|
+
selected: isCellMenuOpen,
|
|
96
116
|
title: labelCellOptions,
|
|
97
117
|
keymap: focusToContextMenuTrigger,
|
|
98
118
|
onClick: handleClick,
|
|
@@ -102,7 +122,7 @@ const FloatingContextualButtonInner = /*#__PURE__*/React.memo(props => {
|
|
|
102
122
|
size: "small"
|
|
103
123
|
}),
|
|
104
124
|
"aria-label": labelCellOptions,
|
|
105
|
-
"aria-expanded":
|
|
125
|
+
"aria-expanded": isCellMenuOpen
|
|
106
126
|
}));
|
|
107
127
|
const parentSticky = targetCellRef.parentElement && targetCellRef.parentElement.className.indexOf('sticky') > -1;
|
|
108
128
|
const 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));
|
|
@@ -157,7 +177,7 @@ const FloatingContextualButtonInner = /*#__PURE__*/React.memo(props => {
|
|
|
157
177
|
targetCellPosition: targetCellPosition,
|
|
158
178
|
targetCellRef: targetCellRef,
|
|
159
179
|
mountTo: tableWrapper,
|
|
160
|
-
isContextualMenuOpen:
|
|
180
|
+
isContextualMenuOpen: isCellMenuOpen
|
|
161
181
|
}, button);
|
|
162
182
|
}
|
|
163
183
|
return jsx(Popup, {
|
|
@@ -1,100 +1,83 @@
|
|
|
1
|
-
import React, { useCallback,
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import React, { useCallback, useContext, useRef } from 'react';
|
|
2
|
+
import { Popup } from '@atlaskit/editor-common/ui';
|
|
3
|
+
import { OutsideClickTargetRefContext, withReactEditorViewOuterListeners } from '@atlaskit/editor-common/ui-react';
|
|
4
4
|
import { UserIntentPopupWrapper } from '@atlaskit/editor-common/user-intent';
|
|
5
|
-
import {
|
|
5
|
+
import { closeActiveTableMenu, setFocusToCellMenu } from '../../pm-plugins/commands';
|
|
6
|
+
import { getPluginState } from '../../pm-plugins/plugin-factory';
|
|
6
7
|
import { TableCssClassName as ClassName } from '../../types';
|
|
8
|
+
import { tablePopupMenuFitHeight } from '../consts';
|
|
7
9
|
import { CELL_MENU } from '../TableMenu/cell/keys';
|
|
10
|
+
import { TABLE_MENU_WIDTH } from '../TableMenu/shared/consts';
|
|
8
11
|
import { TableMenu } from '../TableMenu/shared/TableMenu';
|
|
12
|
+
const PopupWithListeners = withReactEditorViewOuterListeners(Popup);
|
|
13
|
+
const NESTED_DROPDOWN_SELECTOR = '[data-toolbar-nested-dropdown-menu]';
|
|
14
|
+
const CELL_MENU_TRIGGER_SELECTOR = `.${ClassName.CONTEXTUAL_MENU_BUTTON}`;
|
|
9
15
|
export const CellMenuPopup = ({
|
|
10
16
|
api,
|
|
17
|
+
boundariesElement,
|
|
11
18
|
editorView,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
targetCellRef
|
|
19
|
+
mountPoint,
|
|
20
|
+
scrollableElement,
|
|
21
|
+
targetCellRef,
|
|
22
|
+
zIndex
|
|
15
23
|
}) => {
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
currentUserIntent: (_states$userIntentSta = states.userIntentState) === null || _states$userIntentSta === void 0 ? void 0 : _states$userIntentSta.currentUserIntent
|
|
23
|
-
};
|
|
24
|
-
});
|
|
24
|
+
const popupContentRef = useRef(null);
|
|
25
|
+
const setOutsideClickTargetRef = useContext(OutsideClickTargetRefContext);
|
|
26
|
+
const handlePopupRef = useCallback(el => {
|
|
27
|
+
popupContentRef.current = el;
|
|
28
|
+
setOutsideClickTargetRef === null || setOutsideClickTargetRef === void 0 ? void 0 : setOutsideClickTargetRef(el);
|
|
29
|
+
}, [setOutsideClickTargetRef]);
|
|
25
30
|
const closeCellMenu = useCallback(() => {
|
|
26
31
|
const {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
} = editorView;
|
|
31
|
-
toggleContextualMenu()(state, dispatch);
|
|
32
|
+
isCellMenuOpenByKeyboard
|
|
33
|
+
} = getPluginState(editorView.state);
|
|
34
|
+
closeActiveTableMenu()(editorView.state, editorView.dispatch);
|
|
32
35
|
if (isCellMenuOpenByKeyboard) {
|
|
33
|
-
setFocusToCellMenu(false)(state, dispatch);
|
|
34
|
-
dom.focus();
|
|
36
|
+
setFocusToCellMenu(false)(editorView.state, editorView.dispatch);
|
|
35
37
|
}
|
|
36
|
-
}, [editorView
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
}, [editorView]);
|
|
39
|
+
const isEventInsideCellMenu = useCallback(event => {
|
|
40
|
+
var _popupContentRef$curr;
|
|
41
|
+
const target = event.target;
|
|
42
|
+
if (!(target instanceof Node)) {
|
|
43
|
+
return false;
|
|
40
44
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
useEffect(() => {
|
|
44
|
-
if (!isOpen) {
|
|
45
|
-
return;
|
|
45
|
+
if ((_popupContentRef$curr = popupContentRef.current) !== null && _popupContentRef$curr !== void 0 && _popupContentRef$curr.contains(target)) {
|
|
46
|
+
return true;
|
|
46
47
|
}
|
|
47
|
-
|
|
48
|
+
return target instanceof Element && Boolean(target.closest(NESTED_DROPDOWN_SELECTOR) || target.closest(CELL_MENU_TRIGGER_SELECTOR));
|
|
49
|
+
}, []);
|
|
50
|
+
const handleCellMenuClickOutside = useCallback(event => {
|
|
51
|
+
if (isEventInsideCellMenu(event)) {
|
|
48
52
|
return;
|
|
49
53
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
type: 'pointerdown',
|
|
73
|
-
listener: handlePointerDown,
|
|
74
|
-
options: {
|
|
75
|
-
capture: true
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
const unbindKeyDown = bind(ownerDocument, {
|
|
79
|
-
type: 'keydown',
|
|
80
|
-
listener: handleKeyDown,
|
|
81
|
-
options: {
|
|
82
|
-
capture: true
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
return () => {
|
|
86
|
-
unbindPointerDown();
|
|
87
|
-
unbindKeyDown();
|
|
88
|
-
};
|
|
89
|
-
}, [closeCellMenu, isOpen, targetCellRef]);
|
|
90
|
-
return /*#__PURE__*/React.createElement(UserIntentPopupWrapper, {
|
|
54
|
+
closeCellMenu();
|
|
55
|
+
}, [closeCellMenu, isEventInsideCellMenu]);
|
|
56
|
+
return /*#__PURE__*/React.createElement(PopupWithListeners, {
|
|
57
|
+
alignX: "right",
|
|
58
|
+
alignY: "top",
|
|
59
|
+
target: targetCellRef,
|
|
60
|
+
mountTo: mountPoint,
|
|
61
|
+
boundariesElement: boundariesElement,
|
|
62
|
+
scrollableElement: scrollableElement,
|
|
63
|
+
fitHeight: tablePopupMenuFitHeight,
|
|
64
|
+
fitWidth: TABLE_MENU_WIDTH,
|
|
65
|
+
zIndex: zIndex,
|
|
66
|
+
forcePlacement: true
|
|
67
|
+
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
68
|
+
,
|
|
69
|
+
offset: [-7, 0],
|
|
70
|
+
stick: true,
|
|
71
|
+
handleClickOutside: handleCellMenuClickOutside,
|
|
72
|
+
handleEscapeKeydown: closeCellMenu
|
|
73
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
74
|
+
ref: handlePopupRef
|
|
75
|
+
}, /*#__PURE__*/React.createElement(UserIntentPopupWrapper, {
|
|
91
76
|
api: api,
|
|
92
77
|
userIntent: "tableContextualMenuPopupOpen"
|
|
93
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
94
|
-
ref: tableMenuRef
|
|
95
78
|
}, /*#__PURE__*/React.createElement(TableMenu, {
|
|
96
79
|
api: api,
|
|
97
80
|
editorView: editorView,
|
|
98
81
|
surface: CELL_MENU
|
|
99
|
-
})));
|
|
82
|
+
}))));
|
|
100
83
|
};
|