@atlaskit/editor-plugin-table 22.4.7 → 22.4.9
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 +18 -0
- package/dist/cjs/pm-plugins/commands/split-cell.js +18 -1
- package/dist/cjs/pm-plugins/transforms/merge.js +5 -2
- package/dist/cjs/ui/FloatingContextualButton/index.js +5 -0
- package/dist/cjs/ui/FloatingContextualMenu/CellMenuPopup.js +104 -0
- package/dist/cjs/ui/FloatingContextualMenu/index.js +13 -2
- package/dist/cjs/ui/FloatingDragMenu/index.js +7 -2
- package/dist/cjs/ui/TableMenu/cell/getCellMenuComponents.js +70 -0
- package/dist/cjs/ui/TableMenu/cell/items/MergeCellsItem.js +33 -0
- package/dist/cjs/ui/TableMenu/cell/items/SplitCellItem.js +33 -0
- package/dist/cjs/ui/TableMenu/cell/keys.js +40 -0
- package/dist/cjs/ui/TableMenu/column/getColumnMenuComponents.js +4 -11
- package/dist/cjs/ui/TableMenu/column/items/ColumnBackgroundSection.js +25 -0
- package/dist/cjs/ui/TableMenu/column/items/ColumnToggleSection.js +24 -0
- package/dist/cjs/ui/TableMenu/column/items/DistributeColumnsItem.js +10 -0
- package/dist/cjs/ui/TableMenu/column/items/HeaderColumnToggleItem.js +17 -1
- package/dist/cjs/ui/TableMenu/column/items/MoveColumnRightItem.js +2 -6
- package/dist/cjs/ui/TableMenu/column/items/SortDecreasingItem.js +3 -1
- package/dist/cjs/ui/TableMenu/column/items/SortIncreasingItem.js +3 -1
- package/dist/cjs/ui/TableMenu/row/getRowMenuComponents.js +0 -7
- package/dist/cjs/ui/TableMenu/row/items/HeaderRowToggleItem.js +9 -0
- package/dist/cjs/ui/TableMenu/row/items/MoveRowDownItem.js +10 -0
- package/dist/cjs/ui/TableMenu/row/items/MoveRowUpItem.js +10 -0
- package/dist/cjs/ui/TableMenu/shared/TableMenu.js +53 -3
- package/dist/cjs/ui/TableMenu/shared/TableMenuContext.js +13 -0
- package/dist/cjs/ui/TableMenu/shared/consts.js +3 -2
- package/dist/cjs/ui/TableMenu/shared/getSharedItems.js +28 -19
- package/dist/cjs/ui/TableMenu/shared/getTableMenuComponents.js +2 -1
- package/dist/cjs/ui/event-handlers.js +6 -1
- package/dist/es2019/pm-plugins/commands/split-cell.js +17 -1
- package/dist/es2019/pm-plugins/transforms/merge.js +4 -4
- package/dist/es2019/ui/FloatingContextualButton/index.js +5 -0
- package/dist/es2019/ui/FloatingContextualMenu/CellMenuPopup.js +100 -0
- package/dist/es2019/ui/FloatingContextualMenu/index.js +13 -3
- package/dist/es2019/ui/FloatingDragMenu/index.js +7 -2
- package/dist/es2019/ui/TableMenu/cell/getCellMenuComponents.js +53 -0
- package/dist/es2019/ui/TableMenu/cell/items/MergeCellsItem.js +26 -0
- package/dist/es2019/ui/TableMenu/cell/items/SplitCellItem.js +26 -0
- package/dist/es2019/ui/TableMenu/cell/keys.js +42 -0
- package/dist/es2019/ui/TableMenu/column/getColumnMenuComponents.js +4 -12
- package/dist/es2019/ui/TableMenu/column/items/ColumnBackgroundSection.js +20 -0
- package/dist/es2019/ui/TableMenu/column/items/ColumnToggleSection.js +19 -0
- package/dist/es2019/ui/TableMenu/column/items/DistributeColumnsItem.js +11 -0
- package/dist/es2019/ui/TableMenu/column/items/HeaderColumnToggleItem.js +15 -0
- package/dist/es2019/ui/TableMenu/column/items/MoveColumnRightItem.js +3 -5
- package/dist/es2019/ui/TableMenu/column/items/SortDecreasingItem.js +3 -1
- package/dist/es2019/ui/TableMenu/column/items/SortIncreasingItem.js +3 -1
- package/dist/es2019/ui/TableMenu/row/getRowMenuComponents.js +0 -8
- package/dist/es2019/ui/TableMenu/row/items/HeaderRowToggleItem.js +8 -0
- package/dist/es2019/ui/TableMenu/row/items/MoveRowDownItem.js +8 -0
- package/dist/es2019/ui/TableMenu/row/items/MoveRowUpItem.js +8 -0
- package/dist/es2019/ui/TableMenu/shared/TableMenu.js +51 -3
- package/dist/es2019/ui/TableMenu/shared/TableMenuContext.js +4 -0
- package/dist/es2019/ui/TableMenu/shared/consts.js +2 -1
- package/dist/es2019/ui/TableMenu/shared/getSharedItems.js +9 -0
- package/dist/es2019/ui/TableMenu/shared/getTableMenuComponents.js +2 -1
- package/dist/es2019/ui/event-handlers.js +4 -1
- package/dist/esm/pm-plugins/commands/split-cell.js +17 -1
- package/dist/esm/pm-plugins/transforms/merge.js +4 -2
- package/dist/esm/ui/FloatingContextualButton/index.js +5 -0
- package/dist/esm/ui/FloatingContextualMenu/CellMenuPopup.js +96 -0
- package/dist/esm/ui/FloatingContextualMenu/index.js +13 -3
- package/dist/esm/ui/FloatingDragMenu/index.js +7 -2
- package/dist/esm/ui/TableMenu/cell/getCellMenuComponents.js +63 -0
- package/dist/esm/ui/TableMenu/cell/items/MergeCellsItem.js +27 -0
- package/dist/esm/ui/TableMenu/cell/items/SplitCellItem.js +27 -0
- package/dist/esm/ui/TableMenu/cell/keys.js +34 -0
- package/dist/esm/ui/TableMenu/column/getColumnMenuComponents.js +4 -12
- package/dist/esm/ui/TableMenu/column/items/ColumnBackgroundSection.js +19 -0
- package/dist/esm/ui/TableMenu/column/items/ColumnToggleSection.js +18 -0
- package/dist/esm/ui/TableMenu/column/items/DistributeColumnsItem.js +11 -0
- package/dist/esm/ui/TableMenu/column/items/HeaderColumnToggleItem.js +17 -0
- package/dist/esm/ui/TableMenu/column/items/MoveColumnRightItem.js +3 -7
- package/dist/esm/ui/TableMenu/column/items/SortDecreasingItem.js +3 -1
- package/dist/esm/ui/TableMenu/column/items/SortIncreasingItem.js +3 -1
- package/dist/esm/ui/TableMenu/row/getRowMenuComponents.js +0 -8
- package/dist/esm/ui/TableMenu/row/items/HeaderRowToggleItem.js +10 -0
- package/dist/esm/ui/TableMenu/row/items/MoveRowDownItem.js +10 -0
- package/dist/esm/ui/TableMenu/row/items/MoveRowUpItem.js +10 -0
- package/dist/esm/ui/TableMenu/shared/TableMenu.js +52 -3
- package/dist/esm/ui/TableMenu/shared/TableMenuContext.js +6 -0
- package/dist/esm/ui/TableMenu/shared/consts.js +2 -1
- package/dist/esm/ui/TableMenu/shared/getSharedItems.js +9 -0
- package/dist/esm/ui/TableMenu/shared/getTableMenuComponents.js +2 -1
- package/dist/esm/ui/event-handlers.js +6 -1
- package/dist/types/pm-plugins/commands/split-cell.d.ts +2 -0
- package/dist/types/pm-plugins/transforms/merge.d.ts +2 -0
- package/dist/types/ui/FloatingContextualMenu/CellMenuPopup.d.ts +12 -0
- package/dist/types/ui/TableMenu/cell/getCellMenuComponents.d.ts +2 -0
- package/dist/types/ui/TableMenu/cell/items/MergeCellsItem.d.ts +2 -0
- package/dist/types/ui/TableMenu/cell/items/SplitCellItem.d.ts +2 -0
- package/dist/types/ui/TableMenu/cell/keys.d.ts +9 -0
- package/dist/types/ui/TableMenu/column/getColumnMenuComponents.d.ts +0 -7
- package/dist/types/ui/TableMenu/column/items/ColumnBackgroundSection.d.ts +10 -0
- package/dist/types/ui/TableMenu/column/items/ColumnToggleSection.d.ts +9 -0
- package/dist/types/ui/TableMenu/column/items/DistributeColumnsItem.d.ts +1 -1
- package/dist/types/ui/TableMenu/column/items/HeaderColumnToggleItem.d.ts +11 -1
- package/dist/types/ui/TableMenu/row/getRowMenuComponents.d.ts +0 -7
- package/dist/types/ui/TableMenu/row/items/HeaderRowToggleItem.d.ts +1 -1
- package/dist/types/ui/TableMenu/row/items/MoveRowDownItem.d.ts +1 -1
- package/dist/types/ui/TableMenu/row/items/MoveRowUpItem.d.ts +1 -1
- package/dist/types/ui/TableMenu/shared/TableMenu.d.ts +3 -1
- package/dist/types/ui/TableMenu/shared/TableMenuContext.d.ts +14 -0
- package/dist/types/ui/TableMenu/shared/consts.d.ts +1 -0
- package/dist/types-ts4.5/pm-plugins/commands/split-cell.d.ts +2 -0
- package/dist/types-ts4.5/pm-plugins/transforms/merge.d.ts +2 -0
- package/dist/types-ts4.5/ui/FloatingContextualMenu/CellMenuPopup.d.ts +12 -0
- package/dist/types-ts4.5/ui/TableMenu/cell/getCellMenuComponents.d.ts +2 -0
- package/dist/types-ts4.5/ui/TableMenu/cell/items/MergeCellsItem.d.ts +2 -0
- package/dist/types-ts4.5/ui/TableMenu/cell/items/SplitCellItem.d.ts +2 -0
- package/dist/types-ts4.5/ui/TableMenu/cell/keys.d.ts +9 -0
- package/dist/types-ts4.5/ui/TableMenu/column/getColumnMenuComponents.d.ts +0 -7
- package/dist/types-ts4.5/ui/TableMenu/column/items/ColumnBackgroundSection.d.ts +10 -0
- package/dist/types-ts4.5/ui/TableMenu/column/items/ColumnToggleSection.d.ts +9 -0
- package/dist/types-ts4.5/ui/TableMenu/column/items/DistributeColumnsItem.d.ts +1 -1
- package/dist/types-ts4.5/ui/TableMenu/column/items/HeaderColumnToggleItem.d.ts +11 -1
- package/dist/types-ts4.5/ui/TableMenu/row/getRowMenuComponents.d.ts +0 -7
- package/dist/types-ts4.5/ui/TableMenu/row/items/HeaderRowToggleItem.d.ts +1 -1
- package/dist/types-ts4.5/ui/TableMenu/row/items/MoveRowDownItem.d.ts +1 -1
- package/dist/types-ts4.5/ui/TableMenu/row/items/MoveRowUpItem.d.ts +1 -1
- package/dist/types-ts4.5/ui/TableMenu/shared/TableMenu.d.ts +3 -1
- package/dist/types-ts4.5/ui/TableMenu/shared/TableMenuContext.d.ts +14 -0
- package/dist/types-ts4.5/ui/TableMenu/shared/consts.d.ts +1 -0
- package/package.json +5 -5
|
@@ -15,13 +15,6 @@ var _MoveRowDownItem = require("./items/MoveRowDownItem");
|
|
|
15
15
|
var _MoveRowUpItem = require("./items/MoveRowUpItem");
|
|
16
16
|
var _NumberedRowsToggleItem = require("./items/NumberedRowsToggleItem");
|
|
17
17
|
var _keys = require("./keys");
|
|
18
|
-
/**
|
|
19
|
-
* Returns the RegisterComponent[] array defining the row menu surface.
|
|
20
|
-
*
|
|
21
|
-
* This is a **UI-only stub** — all items are always visible with no conditional
|
|
22
|
-
* logic and no wired actions. Functional behaviour (actions, conditional visibility)
|
|
23
|
-
* will be connected in follow-up tickets.
|
|
24
|
-
*/
|
|
25
18
|
var getRowMenuComponents = exports.getRowMenuComponents = function getRowMenuComponents() {
|
|
26
19
|
return [
|
|
27
20
|
// --- Menu surface ---
|
|
@@ -10,10 +10,19 @@ var _reactIntl = require("react-intl");
|
|
|
10
10
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
11
11
|
var _editorToolbar = require("@atlaskit/editor-toolbar");
|
|
12
12
|
var _toggle = _interopRequireDefault(require("@atlaskit/toggle"));
|
|
13
|
+
var _TableMenuContext = require("../../shared/TableMenuContext");
|
|
14
|
+
/** Header row toggle is only visible when the first row is the entire selection. */
|
|
15
|
+
var shouldShowHeaderRowToggle = function shouldShowHeaderRowToggle(tableMenuContext) {
|
|
16
|
+
return (tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.isFirstRow) === true && tableMenuContext.selectedRowCount === 1;
|
|
17
|
+
};
|
|
13
18
|
var HeaderRowToggleItem = exports.HeaderRowToggleItem = function HeaderRowToggleItem() {
|
|
19
|
+
var tableMenuContext = (0, _TableMenuContext.useTableMenuContext)();
|
|
14
20
|
var _useIntl = (0, _reactIntl.useIntl)(),
|
|
15
21
|
formatMessage = _useIntl.formatMessage;
|
|
16
22
|
var label = formatMessage(_messages.tableMessages.headerRow);
|
|
23
|
+
if (!shouldShowHeaderRowToggle(tableMenuContext)) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
17
26
|
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
|
|
18
27
|
elemAfter: /*#__PURE__*/_react.default.createElement(_toggle.default, {
|
|
19
28
|
label: label,
|
|
@@ -11,13 +11,23 @@ var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
|
11
11
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
12
12
|
var _editorToolbar = require("@atlaskit/editor-toolbar");
|
|
13
13
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
14
|
+
var _TableMenuContext = require("../../shared/TableMenuContext");
|
|
14
15
|
var getMoveRowDownShortcut = function getMoveRowDownShortcut() {
|
|
15
16
|
return (0, _keymaps.tooltip)((0, _expValEquals.expValEquals)('editor-a11y-fy26-keyboard-move-row-column', 'isEnabled', true) ? _keymaps.moveRowDown : _keymaps.moveRowDownOld);
|
|
16
17
|
};
|
|
18
|
+
|
|
19
|
+
/** Move row down is hidden when the selection includes the last row (cannot move further down). */
|
|
20
|
+
var shouldShowMoveRowDown = function shouldShowMoveRowDown(tableMenuContext) {
|
|
21
|
+
return !(tableMenuContext !== null && tableMenuContext !== void 0 && tableMenuContext.isLastRow);
|
|
22
|
+
};
|
|
17
23
|
var MoveRowDownItem = exports.MoveRowDownItem = function MoveRowDownItem() {
|
|
18
24
|
var _getMoveRowDownShortc;
|
|
25
|
+
var tableMenuContext = (0, _TableMenuContext.useTableMenuContext)();
|
|
19
26
|
var _useIntl = (0, _reactIntl.useIntl)(),
|
|
20
27
|
formatMessage = _useIntl.formatMessage;
|
|
28
|
+
if (!shouldShowMoveRowDown(tableMenuContext)) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
21
31
|
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
|
|
22
32
|
elemBefore: /*#__PURE__*/_react.default.createElement(_editorToolbar.TableRowMoveDownIcon, {
|
|
23
33
|
color: "currentColor",
|
|
@@ -11,13 +11,23 @@ var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
|
11
11
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
12
12
|
var _editorToolbar = require("@atlaskit/editor-toolbar");
|
|
13
13
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
14
|
+
var _TableMenuContext = require("../../shared/TableMenuContext");
|
|
14
15
|
var getMoveRowUpShortcut = function getMoveRowUpShortcut() {
|
|
15
16
|
return (0, _keymaps.tooltip)((0, _expValEquals.expValEquals)('editor-a11y-fy26-keyboard-move-row-column', 'isEnabled', true) ? _keymaps.moveRowUp : _keymaps.moveRowUpOld);
|
|
16
17
|
};
|
|
18
|
+
|
|
19
|
+
/** Move row up is hidden when the selection includes row 0 (cannot move further up). */
|
|
20
|
+
var shouldShowMoveRowUp = function shouldShowMoveRowUp(tableMenuContext) {
|
|
21
|
+
return !(tableMenuContext !== null && tableMenuContext !== void 0 && tableMenuContext.isFirstRow);
|
|
22
|
+
};
|
|
17
23
|
var MoveRowUpItem = exports.MoveRowUpItem = function MoveRowUpItem() {
|
|
18
24
|
var _getMoveRowUpShortcut;
|
|
25
|
+
var tableMenuContext = (0, _TableMenuContext.useTableMenuContext)();
|
|
19
26
|
var _useIntl = (0, _reactIntl.useIntl)(),
|
|
20
27
|
formatMessage = _useIntl.formatMessage;
|
|
28
|
+
if (!shouldShowMoveRowUp(tableMenuContext)) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
21
31
|
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
|
|
22
32
|
elemBefore: /*#__PURE__*/_react.default.createElement(_editorToolbar.TableRowMoveUpIcon, {
|
|
23
33
|
color: "currentColor",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* TableMenu.tsx generated by @compiled/babel-plugin v0.39.1 */
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
5
|
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
6
|
Object.defineProperty(exports, "__esModule", {
|
|
6
7
|
value: true
|
|
@@ -8,28 +9,77 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
9
|
exports.TableMenu = void 0;
|
|
9
10
|
require("./TableMenu.compiled.css");
|
|
10
11
|
var _runtime = require("@compiled/react/runtime");
|
|
12
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
13
|
var _react = _interopRequireWildcard(require("react"));
|
|
14
|
+
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
15
|
+
var _toolbar = require("@atlaskit/editor-common/toolbar");
|
|
16
|
+
var _tableMap = require("@atlaskit/editor-tables/table-map");
|
|
17
|
+
var _utils = require("@atlaskit/editor-tables/utils");
|
|
12
18
|
var _editorUiControlModel = require("@atlaskit/editor-ui-control-model");
|
|
13
19
|
var _compiled = require("@atlaskit/primitives/compiled");
|
|
20
|
+
var _splitCell = require("../../../pm-plugins/commands/split-cell");
|
|
21
|
+
var _merge = require("../../../pm-plugins/transforms/merge");
|
|
22
|
+
var _TableMenuContext = require("./TableMenuContext");
|
|
14
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); }
|
|
24
|
+
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
|
+
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; }
|
|
15
26
|
var tableMenuContainerStyles = {
|
|
16
27
|
container: "_2rko1qi0 _1reo15vq _18m915vq _1bsb1178 _16qs130s _bfhk1bhr"
|
|
17
28
|
};
|
|
29
|
+
var EMPTY_CONTEXT = {};
|
|
18
30
|
var TableMenu = exports.TableMenu = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
19
31
|
var api = _ref.api,
|
|
32
|
+
editorView = _ref.editorView,
|
|
20
33
|
surface = _ref.surface;
|
|
21
34
|
var components = (0, _react.useMemo)(function () {
|
|
22
35
|
var _api$uiControlRegistr, _api$uiControlRegistr2;
|
|
23
36
|
return (_api$uiControlRegistr = api === null || api === void 0 || (_api$uiControlRegistr2 = api.uiControlRegistry) === null || _api$uiControlRegistr2 === void 0 ? void 0 : _api$uiControlRegistr2.actions.getComponents(surface.key)) !== null && _api$uiControlRegistr !== void 0 ? _api$uiControlRegistr : [];
|
|
24
37
|
}, [api, surface.key]);
|
|
38
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api !== null && api !== void 0 ? api : undefined, ['table', 'selection'], function (states) {
|
|
39
|
+
var _states$tableState, _states$selectionStat;
|
|
40
|
+
return {
|
|
41
|
+
tableNode: (_states$tableState = states.tableState) === null || _states$tableState === void 0 ? void 0 : _states$tableState.tableNode,
|
|
42
|
+
selection: (_states$selectionStat = states.selectionState) === null || _states$selectionStat === void 0 ? void 0 : _states$selectionStat.selection
|
|
43
|
+
};
|
|
44
|
+
}),
|
|
45
|
+
tableNode = _useSharedPluginState.tableNode,
|
|
46
|
+
selection = _useSharedPluginState.selection;
|
|
47
|
+
var tableMenuContext = (0, _react.useMemo)(function () {
|
|
48
|
+
if (!selection || !tableNode) {
|
|
49
|
+
return EMPTY_CONTEXT;
|
|
50
|
+
}
|
|
51
|
+
var tableMap = _tableMap.TableMap.get(tableNode);
|
|
52
|
+
var selectionRect = (0, _utils.getSelectionRect)(selection);
|
|
53
|
+
var cellOps = {
|
|
54
|
+
canMergeCells: (0, _merge.canMergeCellSelection)(selection),
|
|
55
|
+
canSplitCell: (0, _splitCell.canSplitCellSelection)(selection),
|
|
56
|
+
hasMergedCellsInTable: tableMap.hasMergedCells()
|
|
57
|
+
};
|
|
58
|
+
if (!selectionRect) {
|
|
59
|
+
return cellOps;
|
|
60
|
+
}
|
|
61
|
+
return _objectSpread(_objectSpread({}, cellOps), {}, {
|
|
62
|
+
isFirstRow: selectionRect.top === 0,
|
|
63
|
+
isLastRow: selectionRect.bottom === tableMap.height,
|
|
64
|
+
selectedRowCount: selectionRect.bottom - selectionRect.top,
|
|
65
|
+
isFirstColumn: selectionRect.left === 0,
|
|
66
|
+
isLastColumn: selectionRect.right === tableMap.width,
|
|
67
|
+
selectedColumnCount: selectionRect.right - selectionRect.left
|
|
68
|
+
});
|
|
69
|
+
}, [selection, tableNode]);
|
|
25
70
|
if (components.length === 0) {
|
|
26
71
|
return null;
|
|
27
72
|
}
|
|
28
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
73
|
+
return /*#__PURE__*/_react.default.createElement(_toolbar.EditorToolbarProvider, {
|
|
74
|
+
editorView: editorView !== null && editorView !== void 0 ? editorView : null
|
|
75
|
+
}, /*#__PURE__*/_react.default.createElement(_TableMenuContext.TableMenuProvider, {
|
|
76
|
+
value: tableMenuContext
|
|
77
|
+
}, /*#__PURE__*/_react.default.createElement(_compiled.Box, {
|
|
29
78
|
xcss: tableMenuContainerStyles.container,
|
|
30
79
|
testId: surface.key
|
|
31
80
|
}, /*#__PURE__*/_react.default.createElement(_editorUiControlModel.SurfaceRenderer, {
|
|
32
81
|
surface: surface,
|
|
33
82
|
components: components
|
|
34
|
-
}));
|
|
35
|
-
});
|
|
83
|
+
}))));
|
|
84
|
+
});
|
|
85
|
+
TableMenu.displayName = 'TableMenu';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.useTableMenuContext = exports.TableMenuProvider = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var TableMenuContext = /*#__PURE__*/_react.default.createContext(undefined);
|
|
10
|
+
var TableMenuProvider = exports.TableMenuProvider = TableMenuContext.Provider;
|
|
11
|
+
var useTableMenuContext = exports.useTableMenuContext = function useTableMenuContext() {
|
|
12
|
+
return _react.default.useContext(TableMenuContext);
|
|
13
|
+
};
|
|
@@ -3,5 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.TABLE_MENU_WIDTH = void 0;
|
|
7
|
-
var TABLE_MENU_WIDTH = exports.TABLE_MENU_WIDTH = 280;
|
|
6
|
+
exports.TABLE_MENU_WIDTH = exports.TABLE_MENU_SELECTOR = void 0;
|
|
7
|
+
var TABLE_MENU_WIDTH = exports.TABLE_MENU_WIDTH = 280;
|
|
8
|
+
var TABLE_MENU_SELECTOR = exports.TABLE_MENU_SELECTOR = '[data-testid="column-handle-menu"], [data-testid="row-handle-menu"], [data-toolbar-nested-dropdown-menu]';
|
|
@@ -6,38 +6,47 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.getSharedItems = void 0;
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
var _keys = require("../
|
|
10
|
-
var _keys2 = require("../
|
|
9
|
+
var _keys = require("../cell/keys");
|
|
10
|
+
var _keys2 = require("../column/keys");
|
|
11
|
+
var _keys3 = require("../row/keys");
|
|
11
12
|
var _BackgroundColorItem = require("./items/BackgroundColorItem");
|
|
12
13
|
var _ClearCellsItem = require("./items/ClearCellsItem");
|
|
13
|
-
var
|
|
14
|
+
var _keys4 = require("./keys");
|
|
14
15
|
var getSharedItems = exports.getSharedItems = function getSharedItems() {
|
|
15
16
|
return [{
|
|
16
|
-
type:
|
|
17
|
-
key:
|
|
17
|
+
type: _keys4.BACKGROUND_COLOR_ITEM.type,
|
|
18
|
+
key: _keys4.BACKGROUND_COLOR_ITEM.key,
|
|
18
19
|
parents: [{
|
|
19
|
-
type:
|
|
20
|
-
key:
|
|
21
|
-
rank:
|
|
20
|
+
type: _keys3.ROW_BACKGROUND_SECTION.type,
|
|
21
|
+
key: _keys3.ROW_BACKGROUND_SECTION.key,
|
|
22
|
+
rank: _keys3.ROW_BACKGROUND_SECTION_RANK[_keys4.BACKGROUND_COLOR_ITEM.key]
|
|
22
23
|
}, {
|
|
23
|
-
type:
|
|
24
|
-
key:
|
|
25
|
-
rank:
|
|
24
|
+
type: _keys2.COLUMN_BACKGROUND_SECTION.type,
|
|
25
|
+
key: _keys2.COLUMN_BACKGROUND_SECTION.key,
|
|
26
|
+
rank: _keys2.COLUMN_BACKGROUND_SECTION_RANK[_keys4.BACKGROUND_COLOR_ITEM.key]
|
|
27
|
+
}, {
|
|
28
|
+
type: _keys.CELL_ACTION_SECTION.type,
|
|
29
|
+
key: _keys.CELL_ACTION_SECTION.key,
|
|
30
|
+
rank: _keys.CELL_ACTION_SECTION_RANK[_keys4.BACKGROUND_COLOR_ITEM.key]
|
|
26
31
|
}],
|
|
27
32
|
component: function component() {
|
|
28
33
|
return /*#__PURE__*/_react.default.createElement(_BackgroundColorItem.BackgroundColorItem, null);
|
|
29
34
|
}
|
|
30
35
|
}, {
|
|
31
|
-
type:
|
|
32
|
-
key:
|
|
36
|
+
type: _keys4.CLEAR_CELLS_ITEM.type,
|
|
37
|
+
key: _keys4.CLEAR_CELLS_ITEM.key,
|
|
33
38
|
parents: [{
|
|
34
|
-
type:
|
|
35
|
-
key:
|
|
36
|
-
rank:
|
|
39
|
+
type: _keys3.ROW_DANGER_SECTION.type,
|
|
40
|
+
key: _keys3.ROW_DANGER_SECTION.key,
|
|
41
|
+
rank: _keys3.ROW_DANGER_SECTION_RANK[_keys4.CLEAR_CELLS_ITEM.key]
|
|
42
|
+
}, {
|
|
43
|
+
type: _keys2.COLUMN_DANGER_SECTION.type,
|
|
44
|
+
key: _keys2.COLUMN_DANGER_SECTION.key,
|
|
45
|
+
rank: _keys2.COLUMN_DANGER_SECTION_RANK[_keys4.CLEAR_CELLS_ITEM.key]
|
|
37
46
|
}, {
|
|
38
|
-
type: _keys.
|
|
39
|
-
key: _keys.
|
|
40
|
-
rank: _keys.
|
|
47
|
+
type: _keys.CELL_DANGER_SECTION.type,
|
|
48
|
+
key: _keys.CELL_DANGER_SECTION.key,
|
|
49
|
+
rank: _keys.CELL_DANGER_SECTION_RANK[_keys4.CLEAR_CELLS_ITEM.key]
|
|
41
50
|
}],
|
|
42
51
|
component: function component() {
|
|
43
52
|
return /*#__PURE__*/_react.default.createElement(_ClearCellsItem.ClearCellsItem, null);
|
|
@@ -6,9 +6,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.getTableMenuComponents = void 0;
|
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
|
+
var _getCellMenuComponents = require("../cell/getCellMenuComponents");
|
|
9
10
|
var _getColumnMenuComponents = require("../column/getColumnMenuComponents");
|
|
10
11
|
var _getRowMenuComponents = require("../row/getRowMenuComponents");
|
|
11
12
|
var _getSharedItems = require("./getSharedItems");
|
|
12
13
|
var getTableMenuComponents = exports.getTableMenuComponents = function getTableMenuComponents() {
|
|
13
|
-
return [].concat((0, _toConsumableArray2.default)((0, _getRowMenuComponents.getRowMenuComponents)()), (0, _toConsumableArray2.default)((0, _getColumnMenuComponents.getColumnMenuComponents)()), (0, _toConsumableArray2.default)((0, _getSharedItems.getSharedItems)()));
|
|
14
|
+
return [].concat((0, _toConsumableArray2.default)((0, _getRowMenuComponents.getRowMenuComponents)()), (0, _toConsumableArray2.default)((0, _getColumnMenuComponents.getColumnMenuComponents)()), (0, _toConsumableArray2.default)((0, _getCellMenuComponents.getCellMenuComponents)()), (0, _toConsumableArray2.default)((0, _getSharedItems.getSharedItems)()));
|
|
14
15
|
};
|
|
@@ -18,6 +18,7 @@ var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
|
18
18
|
var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
|
|
19
19
|
var _tableMap = require("@atlaskit/editor-tables/table-map");
|
|
20
20
|
var _utils3 = require("@atlaskit/editor-tables/utils");
|
|
21
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
21
22
|
var _commands = require("../pm-plugins/commands");
|
|
22
23
|
var _pluginFactory = require("../pm-plugins/drag-and-drop/plugin-factory");
|
|
23
24
|
var _pluginFactory2 = require("../pm-plugins/plugin-factory");
|
|
@@ -29,6 +30,7 @@ var _columnControls = require("../pm-plugins/utils/column-controls");
|
|
|
29
30
|
var _dom = require("../pm-plugins/utils/dom");
|
|
30
31
|
var _getAllowAddColumnCustomStep = require("../pm-plugins/utils/get-allow-add-column-custom-step");
|
|
31
32
|
var _types = require("../types");
|
|
33
|
+
var _consts = require("./TableMenu/shared/consts");
|
|
32
34
|
var isFocusingCalendar = function isFocusingCalendar(event) {
|
|
33
35
|
return event instanceof FocusEvent && event.relatedTarget instanceof HTMLElement && event.relatedTarget.getAttribute('aria-label') === 'calendar';
|
|
34
36
|
};
|
|
@@ -44,12 +46,15 @@ var isFocusingDragHandles = function isFocusingDragHandles(event) {
|
|
|
44
46
|
var isFocusingDragHandlesClickableZone = function isFocusingDragHandlesClickableZone(event) {
|
|
45
47
|
return event instanceof FocusEvent && event.relatedTarget instanceof HTMLElement && event.relatedTarget.closest('button') && event.relatedTarget.classList.contains(_types.TableCssClassName.DRAG_HANDLE_BUTTON_CLICKABLE_ZONE);
|
|
46
48
|
};
|
|
49
|
+
var isFocusingTableMenu = function isFocusingTableMenu(event) {
|
|
50
|
+
return (0, _expValEquals.expValEquals)('platform_editor_table_menu_updates', 'isEnabled', true) && event instanceof FocusEvent && event.relatedTarget instanceof HTMLElement && Boolean(event.relatedTarget.closest(_consts.TABLE_MENU_SELECTOR));
|
|
51
|
+
};
|
|
47
52
|
var handleBlur = exports.handleBlur = function handleBlur(view, event) {
|
|
48
53
|
var state = view.state,
|
|
49
54
|
dispatch = view.dispatch;
|
|
50
55
|
// IE version check for ED-4665
|
|
51
56
|
// Calendar focus check for ED-10466
|
|
52
|
-
if ((0, _browser.getBrowserInfo)().ie_version !== 11 && !isFocusingCalendar(event) && !isFocusingModal(event) && !isFocusingFloatingToolbar(event) && !isFocusingDragHandles(event) && !isFocusingDragHandlesClickableZone(event)) {
|
|
57
|
+
if ((0, _browser.getBrowserInfo)().ie_version !== 11 && !isFocusingCalendar(event) && !isFocusingModal(event) && !isFocusingFloatingToolbar(event) && !isFocusingDragHandles(event) && !isFocusingDragHandlesClickableZone(event) && !isFocusingTableMenu(event)) {
|
|
53
58
|
(0, _commands.setEditorFocus)(false)(state, dispatch);
|
|
54
59
|
}
|
|
55
60
|
event.preventDefault();
|
|
@@ -1,5 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
2
|
+
import { cellWrapping, splitCellWithType } from '@atlaskit/editor-tables/utils';
|
|
2
3
|
import { getPluginState } from '../plugin-factory';
|
|
4
|
+
export const canSplitCellSelection = selection => {
|
|
5
|
+
let cellNode;
|
|
6
|
+
if (!(selection instanceof CellSelection)) {
|
|
7
|
+
cellNode = cellWrapping(selection.$from);
|
|
8
|
+
if (!cellNode) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
} else {
|
|
12
|
+
if (selection.$anchorCell.pos !== selection.$headCell.pos) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
cellNode = selection.$anchorCell.nodeAfter;
|
|
16
|
+
}
|
|
17
|
+
return Boolean(cellNode && (cellNode.attrs.colspan !== 1 || cellNode.attrs.rowspan !== 1));
|
|
18
|
+
};
|
|
3
19
|
|
|
4
20
|
/**
|
|
5
21
|
* We need to split cell keeping the right type of cell given current table configuration.
|
|
@@ -116,10 +116,7 @@ export function mergeCells(tr) {
|
|
|
116
116
|
}
|
|
117
117
|
return tr.replaceWith(table.pos, table.pos + table.node.nodeSize, fixedTable).setSelection(Selection.near(tr.doc.resolve((mergedCellPos || 0) + table.start)));
|
|
118
118
|
}
|
|
119
|
-
export function
|
|
120
|
-
const {
|
|
121
|
-
selection
|
|
122
|
-
} = tr;
|
|
119
|
+
export function canMergeCellSelection(selection) {
|
|
123
120
|
if (!(selection instanceof CellSelection) || selection.$anchorCell.pos === selection.$headCell.pos) {
|
|
124
121
|
return false;
|
|
125
122
|
}
|
|
@@ -134,6 +131,9 @@ export function canMergeCells(tr) {
|
|
|
134
131
|
}
|
|
135
132
|
return true;
|
|
136
133
|
}
|
|
134
|
+
export function canMergeCells(tr) {
|
|
135
|
+
return canMergeCellSelection(tr.selection);
|
|
136
|
+
}
|
|
137
137
|
function isEmptyCell(cell) {
|
|
138
138
|
const {
|
|
139
139
|
content
|
|
@@ -52,6 +52,11 @@ const FloatingContextualButtonInner = /*#__PURE__*/React.memo(props => {
|
|
|
52
52
|
state,
|
|
53
53
|
dispatch
|
|
54
54
|
} = editorView;
|
|
55
|
+
if (expValEquals('platform_editor_table_menu_updates', 'isEnabled', true)) {
|
|
56
|
+
toggleContextualMenu()(state, dispatch);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
55
60
|
// Clicking outside the dropdown handles toggling the menu closed
|
|
56
61
|
// (otherwise these two toggles combat each other).
|
|
57
62
|
// In the event a user clicks the chevron button again
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useRef } from 'react';
|
|
2
|
+
import { bind } from 'bind-event-listener';
|
|
3
|
+
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
4
|
+
import { UserIntentPopupWrapper } from '@atlaskit/editor-common/user-intent';
|
|
5
|
+
import { setFocusToCellMenu, toggleContextualMenu } from '../../pm-plugins/commands';
|
|
6
|
+
import { TableCssClassName as ClassName } from '../../types';
|
|
7
|
+
import { CELL_MENU } from '../TableMenu/cell/keys';
|
|
8
|
+
import { TableMenu } from '../TableMenu/shared/TableMenu';
|
|
9
|
+
export const CellMenuPopup = ({
|
|
10
|
+
api,
|
|
11
|
+
editorView,
|
|
12
|
+
isCellMenuOpenByKeyboard,
|
|
13
|
+
isOpen,
|
|
14
|
+
targetCellRef
|
|
15
|
+
}) => {
|
|
16
|
+
const tableMenuRef = useRef(null);
|
|
17
|
+
const {
|
|
18
|
+
currentUserIntent
|
|
19
|
+
} = useSharedPluginStateWithSelector(api, ['userIntent'], states => {
|
|
20
|
+
var _states$userIntentSta;
|
|
21
|
+
return {
|
|
22
|
+
currentUserIntent: (_states$userIntentSta = states.userIntentState) === null || _states$userIntentSta === void 0 ? void 0 : _states$userIntentSta.currentUserIntent
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
const closeCellMenu = useCallback(() => {
|
|
26
|
+
const {
|
|
27
|
+
state,
|
|
28
|
+
dispatch,
|
|
29
|
+
dom
|
|
30
|
+
} = editorView;
|
|
31
|
+
toggleContextualMenu()(state, dispatch);
|
|
32
|
+
if (isCellMenuOpenByKeyboard) {
|
|
33
|
+
setFocusToCellMenu(false)(state, dispatch);
|
|
34
|
+
dom.focus();
|
|
35
|
+
}
|
|
36
|
+
}, [editorView, isCellMenuOpenByKeyboard]);
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
if (!isOpen || currentUserIntent !== 'tableDragMenuPopupOpen') {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
closeCellMenu();
|
|
42
|
+
}, [closeCellMenu, currentUserIntent, isOpen]);
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
if (!isOpen) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (!(targetCellRef instanceof HTMLElement)) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const ownerDocument = targetCellRef.ownerDocument;
|
|
51
|
+
const handlePointerDown = event => {
|
|
52
|
+
var _tableMenuRef$current;
|
|
53
|
+
const target = event.target;
|
|
54
|
+
if (!(target instanceof Node)) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if ((_tableMenuRef$current = tableMenuRef.current) !== null && _tableMenuRef$current !== void 0 && _tableMenuRef$current.contains(target)) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const cellMenuButton = ownerDocument.querySelector(`.${ClassName.CONTEXTUAL_MENU_BUTTON}`);
|
|
61
|
+
if (cellMenuButton !== null && cellMenuButton !== void 0 && cellMenuButton.contains(target)) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
closeCellMenu();
|
|
65
|
+
};
|
|
66
|
+
const handleKeyDown = event => {
|
|
67
|
+
if (event.key === 'Escape') {
|
|
68
|
+
closeCellMenu();
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
const unbindPointerDown = bind(ownerDocument, {
|
|
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, {
|
|
91
|
+
api: api,
|
|
92
|
+
userIntent: "tableContextualMenuPopupOpen"
|
|
93
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
94
|
+
ref: tableMenuRef
|
|
95
|
+
}, /*#__PURE__*/React.createElement(TableMenu, {
|
|
96
|
+
api: api,
|
|
97
|
+
editorView: editorView,
|
|
98
|
+
surface: CELL_MENU
|
|
99
|
+
})));
|
|
100
|
+
};
|
|
@@ -8,9 +8,11 @@ import { Popup } from '@atlaskit/editor-common/ui';
|
|
|
8
8
|
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
9
9
|
import { akEditorFloatingDialogZIndex, akEditorFloatingOverlapPanelZIndex } from '@atlaskit/editor-shared-styles';
|
|
10
10
|
import { findCellRectClosestToPos, getSelectionRect, isSelectionType } from '@atlaskit/editor-tables/utils';
|
|
11
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
11
12
|
import { getPluginState } from '../../pm-plugins/plugin-factory';
|
|
12
13
|
import { contextualMenuDropdownWidthDnD, contextualMenuTriggerSize, tablePopupMenuFitHeight } from '../consts';
|
|
13
|
-
|
|
14
|
+
import { TABLE_MENU_WIDTH } from '../TableMenu/shared/consts';
|
|
15
|
+
import { CellMenuPopup } from './CellMenuPopup';
|
|
14
16
|
// Ignored via go/ees005
|
|
15
17
|
// eslint-disable-next-line import/no-named-as-default
|
|
16
18
|
import ContextualMenu from './ContextualMenu';
|
|
@@ -68,7 +70,7 @@ const FloatingContextualMenu = ({
|
|
|
68
70
|
boundariesElement: boundariesElement,
|
|
69
71
|
scrollableElement: scrollableElement,
|
|
70
72
|
fitHeight: tablePopupMenuFitHeight,
|
|
71
|
-
fitWidth: contextualMenuDropdownWidthDnD
|
|
73
|
+
fitWidth: expValEquals('platform_editor_table_menu_updates', 'isEnabled', true) ? TABLE_MENU_WIDTH : contextualMenuDropdownWidthDnD
|
|
72
74
|
// z-index value below is to ensure that this menu is above other floating menu
|
|
73
75
|
// in table, but below floating dialogs like typeaheads, pickers, etc.
|
|
74
76
|
,
|
|
@@ -78,7 +80,15 @@ const FloatingContextualMenu = ({
|
|
|
78
80
|
,
|
|
79
81
|
offset: [-7, 0],
|
|
80
82
|
stick: true
|
|
81
|
-
}, jsx(
|
|
83
|
+
}, expValEquals('platform_editor_table_menu_updates', 'isEnabled', true) ? jsx(CellMenuPopup, {
|
|
84
|
+
api: api,
|
|
85
|
+
editorView: editorView,
|
|
86
|
+
isCellMenuOpenByKeyboard: isCellMenuOpenByKeyboard,
|
|
87
|
+
isOpen: isOpen,
|
|
88
|
+
targetCellRef: targetCellRef
|
|
89
|
+
}) :
|
|
90
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
|
|
91
|
+
jsx("div", {
|
|
82
92
|
css: tablePopupStyles()
|
|
83
93
|
}, jsx(ContextualMenu, {
|
|
84
94
|
editorView: editorView
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Popup } from '@atlaskit/editor-common/ui';
|
|
3
|
+
import { UserIntentPopupWrapper } from '@atlaskit/editor-common/user-intent';
|
|
3
4
|
import { akEditorFloatingDialogZIndex, akEditorFloatingOverlapPanelZIndex } from '@atlaskit/editor-shared-styles';
|
|
4
5
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
5
6
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
@@ -66,10 +67,14 @@ const FloatingDragMenu = ({
|
|
|
66
67
|
forcePlacement: true,
|
|
67
68
|
offset: expValEquals('platform_editor_table_menu_updates', 'isEnabled', true) ? [TABLE_MENU_OFFSET, 0] : direction === 'row' ? [-9, 0] : [0, -7],
|
|
68
69
|
stick: true
|
|
69
|
-
}, expValEquals('platform_editor_table_menu_updates', 'isEnabled', true) ? /*#__PURE__*/React.createElement(
|
|
70
|
+
}, expValEquals('platform_editor_table_menu_updates', 'isEnabled', true) ? /*#__PURE__*/React.createElement(UserIntentPopupWrapper, {
|
|
70
71
|
api: api,
|
|
72
|
+
userIntent: "tableDragMenuPopupOpen"
|
|
73
|
+
}, /*#__PURE__*/React.createElement(TableMenu, {
|
|
74
|
+
api: api,
|
|
75
|
+
editorView: editorView,
|
|
71
76
|
surface: direction === 'row' ? ROW_MENU : COLUMN_MENU
|
|
72
|
-
}) : /*#__PURE__*/React.createElement(DragMenu, {
|
|
77
|
+
})) : /*#__PURE__*/React.createElement(DragMenu, {
|
|
73
78
|
editorView: editorView,
|
|
74
79
|
isOpen: isOpen,
|
|
75
80
|
tableNode: tableNode,
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
|
|
3
|
+
import { MergeCellsItem } from './items/MergeCellsItem';
|
|
4
|
+
import { SplitCellItem } from './items/SplitCellItem';
|
|
5
|
+
import { CELL_MENU, CELL_ACTION_SECTION, CELL_DANGER_SECTION, CELL_MENU_RANK, MERGE_CELLS_ITEM, SPLIT_CELL_ITEM, CELL_ACTION_SECTION_RANK } from './keys';
|
|
6
|
+
export const getCellMenuComponents = () => [
|
|
7
|
+
// --- Menu surface ---
|
|
8
|
+
{
|
|
9
|
+
type: CELL_MENU.type,
|
|
10
|
+
key: CELL_MENU.key
|
|
11
|
+
},
|
|
12
|
+
// --- Main action section (Background color, Merge cells, Split cell) ---
|
|
13
|
+
{
|
|
14
|
+
type: CELL_ACTION_SECTION.type,
|
|
15
|
+
key: CELL_ACTION_SECTION.key,
|
|
16
|
+
parents: [{
|
|
17
|
+
type: CELL_MENU.type,
|
|
18
|
+
key: CELL_MENU.key,
|
|
19
|
+
rank: CELL_MENU_RANK[CELL_ACTION_SECTION.key]
|
|
20
|
+
}],
|
|
21
|
+
component: props => /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, null, props.children)
|
|
22
|
+
}, {
|
|
23
|
+
type: MERGE_CELLS_ITEM.type,
|
|
24
|
+
key: MERGE_CELLS_ITEM.key,
|
|
25
|
+
parents: [{
|
|
26
|
+
type: CELL_ACTION_SECTION.type,
|
|
27
|
+
key: CELL_ACTION_SECTION.key,
|
|
28
|
+
rank: CELL_ACTION_SECTION_RANK[MERGE_CELLS_ITEM.key]
|
|
29
|
+
}],
|
|
30
|
+
component: () => /*#__PURE__*/React.createElement(MergeCellsItem, null)
|
|
31
|
+
}, {
|
|
32
|
+
type: SPLIT_CELL_ITEM.type,
|
|
33
|
+
key: SPLIT_CELL_ITEM.key,
|
|
34
|
+
parents: [{
|
|
35
|
+
type: CELL_ACTION_SECTION.type,
|
|
36
|
+
key: CELL_ACTION_SECTION.key,
|
|
37
|
+
rank: CELL_ACTION_SECTION_RANK[SPLIT_CELL_ITEM.key]
|
|
38
|
+
}],
|
|
39
|
+
component: () => /*#__PURE__*/React.createElement(SplitCellItem, null)
|
|
40
|
+
},
|
|
41
|
+
// --- Danger section (Clear cell) ---
|
|
42
|
+
{
|
|
43
|
+
type: CELL_DANGER_SECTION.type,
|
|
44
|
+
key: CELL_DANGER_SECTION.key,
|
|
45
|
+
parents: [{
|
|
46
|
+
type: CELL_MENU.type,
|
|
47
|
+
key: CELL_MENU.key,
|
|
48
|
+
rank: CELL_MENU_RANK[CELL_DANGER_SECTION.key]
|
|
49
|
+
}],
|
|
50
|
+
component: props => /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
|
|
51
|
+
hasSeparator: true
|
|
52
|
+
}, props.children)
|
|
53
|
+
}];
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useIntl } from 'react-intl';
|
|
3
|
+
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
4
|
+
import { TableCellMergeIcon, ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
|
|
5
|
+
import { useTableMenuContext } from '../../shared/TableMenuContext';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Merge cells is only visible when the active selection can actually be merged
|
|
9
|
+
* (multi-cell, non-overlapping).
|
|
10
|
+
*/
|
|
11
|
+
const shouldShowMergeCells = tableMenuContext => (tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.canMergeCells) === true;
|
|
12
|
+
export const MergeCellsItem = () => {
|
|
13
|
+
const tableMenuContext = useTableMenuContext();
|
|
14
|
+
const {
|
|
15
|
+
formatMessage
|
|
16
|
+
} = useIntl();
|
|
17
|
+
if (!shouldShowMergeCells(tableMenuContext)) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
21
|
+
elemBefore: /*#__PURE__*/React.createElement(TableCellMergeIcon, {
|
|
22
|
+
label: "",
|
|
23
|
+
size: "small"
|
|
24
|
+
})
|
|
25
|
+
}, formatMessage(messages.mergeCells));
|
|
26
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useIntl } from 'react-intl';
|
|
3
|
+
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
4
|
+
import { TableCellSplitIcon, ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
|
|
5
|
+
import { useTableMenuContext } from '../../shared/TableMenuContext';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Split cell is only visible when the active selection sits in a cell whose
|
|
9
|
+
* `rowspan` or `colspan` is greater than one.
|
|
10
|
+
*/
|
|
11
|
+
const shouldShowSplitCell = tableMenuContext => (tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.canSplitCell) === true;
|
|
12
|
+
export const SplitCellItem = () => {
|
|
13
|
+
const tableMenuContext = useTableMenuContext();
|
|
14
|
+
const {
|
|
15
|
+
formatMessage
|
|
16
|
+
} = useIntl();
|
|
17
|
+
if (!shouldShowSplitCell(tableMenuContext)) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
21
|
+
elemBefore: /*#__PURE__*/React.createElement(TableCellSplitIcon, {
|
|
22
|
+
label: "",
|
|
23
|
+
size: "small"
|
|
24
|
+
})
|
|
25
|
+
}, formatMessage(messages.splitCell));
|
|
26
|
+
};
|