@atlaskit/editor-plugin-table 23.3.4 → 23.3.6
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 +13 -0
- package/dist/cjs/pm-plugins/commands/active-table-menu.js +19 -8
- package/dist/cjs/pm-plugins/commands/commands-with-analytics.js +9 -49
- package/dist/cjs/pm-plugins/drag-and-drop/plugin.js +1 -1
- package/dist/cjs/pm-plugins/handlers.js +1 -1
- package/dist/cjs/pm-plugins/main.js +4 -1
- package/dist/cjs/ui/ContentComponent.js +11 -1
- package/dist/cjs/ui/FloatingContextualButton/index.js +2 -2
- package/dist/cjs/ui/FloatingContextualMenu/CellMenuPopup.js +2 -2
- package/dist/cjs/ui/FloatingDragMenu/index.js +10 -38
- package/dist/cjs/ui/FloatingTableMenu/index.js +175 -0
- package/dist/cjs/ui/TableFloatingColumnControls/ColumnControls/index.js +43 -11
- package/dist/cjs/ui/TableFloatingControls/RowControls/DragControls.js +57 -26
- package/dist/cjs/ui/TableMenu/cell/items/MergeCellsItem.js +1 -1
- package/dist/cjs/ui/TableMenu/cell/items/SplitCellItem.js +1 -1
- package/dist/cjs/ui/TableMenu/cell/items/VerticalAlignDropdownItem.js +1 -1
- package/dist/cjs/ui/TableMenu/column/items/AddColumnLeftItem.js +1 -1
- package/dist/cjs/ui/TableMenu/column/items/AddColumnRightItem.js +1 -1
- package/dist/cjs/ui/TableMenu/column/items/DeleteColumnItem.js +1 -1
- package/dist/cjs/ui/TableMenu/column/items/DistributeColumnsItem.js +1 -1
- package/dist/cjs/ui/TableMenu/column/items/MoveColumnLeftItem.js +1 -1
- package/dist/cjs/ui/TableMenu/column/items/MoveColumnRightItem.js +1 -1
- package/dist/cjs/ui/TableMenu/column/items/SortDecreasingItem.js +1 -1
- package/dist/cjs/ui/TableMenu/column/items/SortIncreasingItem.js +1 -1
- package/dist/cjs/ui/TableMenu/row/items/AddRowAboveItem.js +1 -1
- package/dist/cjs/ui/TableMenu/row/items/AddRowBelowItem.js +1 -1
- package/dist/cjs/ui/TableMenu/row/items/DeleteRowItem.js +1 -1
- package/dist/cjs/ui/TableMenu/row/items/MoveRowDownItem.js +1 -1
- package/dist/cjs/ui/TableMenu/row/items/MoveRowUpItem.js +1 -1
- package/dist/cjs/ui/TableMenu/shared/TableMenu.js +8 -8
- package/dist/cjs/ui/TableMenu/shared/consts.js +1 -1
- package/dist/cjs/ui/TableMenu/shared/items/BackgroundColorItem.js +1 -1
- package/dist/cjs/ui/TableMenu/shared/items/ClearCellsItem.js +1 -1
- package/dist/es2019/pm-plugins/commands/active-table-menu.js +19 -8
- package/dist/es2019/pm-plugins/commands/commands-with-analytics.js +0 -39
- package/dist/es2019/pm-plugins/drag-and-drop/plugin.js +1 -1
- package/dist/es2019/pm-plugins/handlers.js +1 -1
- package/dist/es2019/pm-plugins/main.js +3 -0
- package/dist/es2019/ui/ContentComponent.js +11 -1
- package/dist/es2019/ui/FloatingContextualButton/index.js +2 -2
- package/dist/es2019/ui/FloatingContextualMenu/CellMenuPopup.js +2 -2
- package/dist/es2019/ui/FloatingDragMenu/index.js +11 -40
- package/dist/es2019/ui/FloatingTableMenu/index.js +165 -0
- package/dist/es2019/ui/TableFloatingColumnControls/ColumnControls/index.js +41 -7
- package/dist/es2019/ui/TableFloatingControls/RowControls/DragControls.js +40 -7
- package/dist/es2019/ui/TableMenu/cell/items/MergeCellsItem.js +1 -1
- package/dist/es2019/ui/TableMenu/cell/items/SplitCellItem.js +1 -1
- package/dist/es2019/ui/TableMenu/cell/items/VerticalAlignDropdownItem.js +1 -1
- package/dist/es2019/ui/TableMenu/column/items/AddColumnLeftItem.js +1 -1
- package/dist/es2019/ui/TableMenu/column/items/AddColumnRightItem.js +1 -1
- package/dist/es2019/ui/TableMenu/column/items/DeleteColumnItem.js +1 -1
- package/dist/es2019/ui/TableMenu/column/items/DistributeColumnsItem.js +1 -1
- package/dist/es2019/ui/TableMenu/column/items/MoveColumnLeftItem.js +1 -1
- package/dist/es2019/ui/TableMenu/column/items/MoveColumnRightItem.js +1 -1
- package/dist/es2019/ui/TableMenu/column/items/SortDecreasingItem.js +1 -1
- package/dist/es2019/ui/TableMenu/column/items/SortIncreasingItem.js +1 -1
- package/dist/es2019/ui/TableMenu/row/items/AddRowAboveItem.js +1 -1
- package/dist/es2019/ui/TableMenu/row/items/AddRowBelowItem.js +1 -1
- package/dist/es2019/ui/TableMenu/row/items/DeleteRowItem.js +1 -1
- package/dist/es2019/ui/TableMenu/row/items/MoveRowDownItem.js +1 -1
- package/dist/es2019/ui/TableMenu/row/items/MoveRowUpItem.js +1 -1
- package/dist/es2019/ui/TableMenu/shared/TableMenu.js +8 -8
- package/dist/es2019/ui/TableMenu/shared/consts.js +1 -1
- package/dist/es2019/ui/TableMenu/shared/items/BackgroundColorItem.js +1 -1
- package/dist/es2019/ui/TableMenu/shared/items/ClearCellsItem.js +1 -1
- package/dist/esm/pm-plugins/commands/active-table-menu.js +19 -8
- package/dist/esm/pm-plugins/commands/commands-with-analytics.js +8 -48
- package/dist/esm/pm-plugins/drag-and-drop/plugin.js +1 -1
- package/dist/esm/pm-plugins/handlers.js +1 -1
- package/dist/esm/pm-plugins/main.js +4 -1
- package/dist/esm/ui/ContentComponent.js +11 -1
- package/dist/esm/ui/FloatingContextualButton/index.js +2 -2
- package/dist/esm/ui/FloatingContextualMenu/CellMenuPopup.js +2 -2
- package/dist/esm/ui/FloatingDragMenu/index.js +11 -39
- package/dist/esm/ui/FloatingTableMenu/index.js +167 -0
- package/dist/esm/ui/TableFloatingColumnControls/ColumnControls/index.js +42 -10
- package/dist/esm/ui/TableFloatingControls/RowControls/DragControls.js +56 -25
- package/dist/esm/ui/TableMenu/cell/items/MergeCellsItem.js +1 -1
- package/dist/esm/ui/TableMenu/cell/items/SplitCellItem.js +1 -1
- package/dist/esm/ui/TableMenu/cell/items/VerticalAlignDropdownItem.js +1 -1
- package/dist/esm/ui/TableMenu/column/items/AddColumnLeftItem.js +1 -1
- package/dist/esm/ui/TableMenu/column/items/AddColumnRightItem.js +1 -1
- package/dist/esm/ui/TableMenu/column/items/DeleteColumnItem.js +1 -1
- package/dist/esm/ui/TableMenu/column/items/DistributeColumnsItem.js +1 -1
- package/dist/esm/ui/TableMenu/column/items/MoveColumnLeftItem.js +1 -1
- package/dist/esm/ui/TableMenu/column/items/MoveColumnRightItem.js +1 -1
- package/dist/esm/ui/TableMenu/column/items/SortDecreasingItem.js +1 -1
- package/dist/esm/ui/TableMenu/column/items/SortIncreasingItem.js +1 -1
- package/dist/esm/ui/TableMenu/row/items/AddRowAboveItem.js +1 -1
- package/dist/esm/ui/TableMenu/row/items/AddRowBelowItem.js +1 -1
- package/dist/esm/ui/TableMenu/row/items/DeleteRowItem.js +1 -1
- package/dist/esm/ui/TableMenu/row/items/MoveRowDownItem.js +1 -1
- package/dist/esm/ui/TableMenu/row/items/MoveRowUpItem.js +1 -1
- package/dist/esm/ui/TableMenu/shared/TableMenu.js +8 -8
- package/dist/esm/ui/TableMenu/shared/consts.js +1 -1
- package/dist/esm/ui/TableMenu/shared/items/BackgroundColorItem.js +1 -1
- package/dist/esm/ui/TableMenu/shared/items/ClearCellsItem.js +1 -1
- package/dist/types/pm-plugins/commands/active-table-menu.d.ts +3 -3
- package/dist/types/pm-plugins/commands/commands-with-analytics.d.ts +1 -3
- package/dist/types/ui/FloatingTableMenu/index.d.ts +23 -0
- package/dist/types/ui/TableMenu/shared/consts.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/commands/active-table-menu.d.ts +3 -3
- package/dist/types-ts4.5/pm-plugins/commands/commands-with-analytics.d.ts +1 -3
- package/dist/types-ts4.5/ui/FloatingTableMenu/index.d.ts +23 -0
- package/dist/types-ts4.5/ui/TableMenu/shared/consts.d.ts +1 -1
- package/package.json +5 -5
|
@@ -57,7 +57,7 @@ export const DeleteRowItem = props => {
|
|
|
57
57
|
return;
|
|
58
58
|
}
|
|
59
59
|
deleteRowsWithAnalytics(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, selectionRect, !!isHeaderRowRequired)(editorView.state, editorView.dispatch);
|
|
60
|
-
api === null || api === void 0 ? void 0 : api.core.actions.execute(closeActiveTableMenu());
|
|
60
|
+
api === null || api === void 0 ? void 0 : api.core.actions.execute(closeActiveTableMenu(api));
|
|
61
61
|
api === null || api === void 0 ? void 0 : api.core.actions.focus();
|
|
62
62
|
};
|
|
63
63
|
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
@@ -44,7 +44,7 @@ export const MoveRowDownItem = props => {
|
|
|
44
44
|
return;
|
|
45
45
|
}
|
|
46
46
|
moveSourceWithAnalytics(api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, api === null || api === void 0 ? void 0 : (_api$accessibilityUti = api.accessibilityUtils) === null || _api$accessibilityUti === void 0 ? void 0 : _api$accessibilityUti.actions.ariaNotify, getPluginState(editorView.state).getIntl)(INPUT_METHOD.TABLE_CONTEXT_MENU, TABLE_ROW, getSelectedRowIndexes(selectionRect), selectionRect.bottom)(editorView.state, editorView.dispatch);
|
|
47
|
-
api === null || api === void 0 ? void 0 : api.core.actions.execute(closeActiveTableMenu());
|
|
47
|
+
api === null || api === void 0 ? void 0 : api.core.actions.execute(closeActiveTableMenu(api));
|
|
48
48
|
api === null || api === void 0 ? void 0 : api.core.actions.focus();
|
|
49
49
|
};
|
|
50
50
|
if (!tableNode || !shouldShowMoveRowDown(tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.isLastRow)) {
|
|
@@ -44,7 +44,7 @@ export const MoveRowUpItem = props => {
|
|
|
44
44
|
return;
|
|
45
45
|
}
|
|
46
46
|
moveSourceWithAnalytics(api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, api === null || api === void 0 ? void 0 : (_api$accessibilityUti = api.accessibilityUtils) === null || _api$accessibilityUti === void 0 ? void 0 : _api$accessibilityUti.actions.ariaNotify, getPluginState(editorView.state).getIntl)(INPUT_METHOD.TABLE_CONTEXT_MENU, TABLE_ROW, getSelectedRowIndexes(selectionRect), selectionRect.top - 1)(editorView.state, editorView.dispatch);
|
|
47
|
-
api === null || api === void 0 ? void 0 : api.core.actions.execute(closeActiveTableMenu());
|
|
47
|
+
api === null || api === void 0 ? void 0 : api.core.actions.execute(closeActiveTableMenu(api));
|
|
48
48
|
api === null || api === void 0 ? void 0 : api.core.actions.focus();
|
|
49
49
|
};
|
|
50
50
|
if (!tableNode || !shouldShowMoveRowUp(tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.isFirstRow)) {
|
|
@@ -27,17 +27,17 @@ export const TableMenu = /*#__PURE__*/memo(({
|
|
|
27
27
|
};
|
|
28
28
|
});
|
|
29
29
|
const tableMenuContext = useMemo(() => {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
// rely on selection plugins state to re-render the row/column menu, but use editorView.selection
|
|
31
|
+
// for cell menu state as the selection plugin won't update when text selection changes within cells
|
|
32
|
+
if (!tableNode || !editorView || !selection) {
|
|
33
|
+
return undefined;
|
|
34
34
|
}
|
|
35
35
|
const tableMap = TableMap.get(tableNode);
|
|
36
|
-
const selectionRect = getSelectionRect(selection);
|
|
36
|
+
const selectionRect = getSelectionRect(editorView.state.selection);
|
|
37
37
|
const cellOps = {
|
|
38
38
|
editorView,
|
|
39
|
-
canMergeCells: canMergeCellSelection(selection),
|
|
40
|
-
canSplitCell: canSplitCellSelection(selection),
|
|
39
|
+
canMergeCells: canMergeCellSelection(editorView.state.selection),
|
|
40
|
+
canSplitCell: canSplitCellSelection(editorView.state.selection),
|
|
41
41
|
hasMergedCellsInTable: tableMap.hasMergedCells()
|
|
42
42
|
};
|
|
43
43
|
if (!selectionRect) {
|
|
@@ -52,7 +52,7 @@ export const TableMenu = /*#__PURE__*/memo(({
|
|
|
52
52
|
isLastColumn: selectionRect.right === tableMap.width,
|
|
53
53
|
selectedColumnCount: selectionRect.right - selectionRect.left
|
|
54
54
|
};
|
|
55
|
-
}, [editorView,
|
|
55
|
+
}, [editorView, tableNode, selection]);
|
|
56
56
|
if (components.length === 0) {
|
|
57
57
|
return null;
|
|
58
58
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export const TABLE_MENU_WIDTH = 280;
|
|
2
|
-
export const TABLE_MENU_SELECTOR = '[data-testid="column-handle-menu"], [data-testid="row-handle-menu"], [data-toolbar-nested-dropdown-menu]';
|
|
2
|
+
export const TABLE_MENU_SELECTOR = '[data-testid="column-handle-menu"], [data-testid="row-handle-menu"], [data-toolbar-component="menu"], [data-toolbar-nested-dropdown-menu]';
|
|
3
3
|
export const TABLE_ROW = 'table-row';
|
|
4
4
|
export const TABLE_COLUMN = 'table-column';
|
|
@@ -46,7 +46,7 @@ export const BackgroundColorItem = ({
|
|
|
46
46
|
return;
|
|
47
47
|
}
|
|
48
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
|
-
api === null || api === void 0 ? void 0 : api.core.actions.execute(closeActiveTableMenu());
|
|
49
|
+
api === null || api === void 0 ? void 0 : api.core.actions.execute(closeActiveTableMenu(api));
|
|
50
50
|
api === null || api === void 0 ? void 0 : api.core.actions.focus();
|
|
51
51
|
}, [api, editorView]);
|
|
52
52
|
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
|
|
@@ -29,7 +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
|
-
api === null || api === void 0 ? void 0 : api.core.actions.execute(closeActiveTableMenu());
|
|
32
|
+
api === null || api === void 0 ? void 0 : api.core.actions.execute(closeActiveTableMenu(api));
|
|
33
33
|
api === null || api === void 0 ? void 0 : api.core.actions.focus();
|
|
34
34
|
};
|
|
35
35
|
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
import { pluginKey } from '../plugin-key';
|
|
2
|
-
|
|
2
|
+
var applyMenuUserIntent = function applyMenuUserIntent(tr, api, nextActiveTableMenu) {
|
|
3
|
+
var _api$userIntent;
|
|
4
|
+
var isRowOrColumnMenuOpen = nextActiveTableMenu.type === 'row' || nextActiveTableMenu.type === 'column';
|
|
5
|
+
api === null || api === void 0 || (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 || _api$userIntent.commands.setCurrentUserIntent(isRowOrColumnMenuOpen ? 'tableDragMenuPopupOpen' : 'default')({
|
|
6
|
+
tr: tr
|
|
7
|
+
});
|
|
8
|
+
};
|
|
9
|
+
export var closeActiveTableMenu = function closeActiveTableMenu(api) {
|
|
3
10
|
return function (_ref) {
|
|
4
11
|
var tr = _ref.tr;
|
|
12
|
+
var nextActiveTableMenu = {
|
|
13
|
+
type: 'none'
|
|
14
|
+
};
|
|
5
15
|
tr.setMeta(pluginKey, {
|
|
6
16
|
type: 'SET_ACTIVE_TABLE_MENU',
|
|
7
17
|
data: {
|
|
8
|
-
activeTableMenu:
|
|
9
|
-
type: 'none'
|
|
10
|
-
}
|
|
18
|
+
activeTableMenu: nextActiveTableMenu
|
|
11
19
|
}
|
|
12
20
|
});
|
|
21
|
+
applyMenuUserIntent(tr, api, nextActiveTableMenu);
|
|
13
22
|
if (!tr.docChanged) {
|
|
14
23
|
tr.setMeta('addToHistory', false);
|
|
15
24
|
}
|
|
@@ -25,17 +34,19 @@ var isSameActiveTableMenu = function isSameActiveTableMenu(current, next) {
|
|
|
25
34
|
}
|
|
26
35
|
return true;
|
|
27
36
|
};
|
|
28
|
-
export var toggleActiveTableMenu = function toggleActiveTableMenu(activeTableMenu, currentActiveTableMenu) {
|
|
37
|
+
export var toggleActiveTableMenu = function toggleActiveTableMenu(activeTableMenu, currentActiveTableMenu, api) {
|
|
29
38
|
return function (_ref2) {
|
|
30
39
|
var tr = _ref2.tr;
|
|
40
|
+
var nextActiveTableMenu = isSameActiveTableMenu(currentActiveTableMenu, activeTableMenu) ? {
|
|
41
|
+
type: 'none'
|
|
42
|
+
} : activeTableMenu;
|
|
31
43
|
tr.setMeta(pluginKey, {
|
|
32
44
|
type: 'SET_ACTIVE_TABLE_MENU',
|
|
33
45
|
data: {
|
|
34
|
-
activeTableMenu:
|
|
35
|
-
type: 'none'
|
|
36
|
-
} : activeTableMenu
|
|
46
|
+
activeTableMenu: nextActiveTableMenu
|
|
37
47
|
}
|
|
38
48
|
});
|
|
49
|
+
applyMenuUserIntent(tr, api, nextActiveTableMenu);
|
|
39
50
|
tr.setMeta('addToHistory', false);
|
|
40
51
|
return tr;
|
|
41
52
|
};
|
|
@@ -13,7 +13,6 @@ 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';
|
|
17
16
|
import { clearMultipleCells } from './clear';
|
|
18
17
|
import { wrapTableInExpand } from './collapse';
|
|
19
18
|
import { changeColumnWidthByStep } from './column-resize';
|
|
@@ -24,45 +23,6 @@ import { deleteTable, deleteTableIfSelected, getTableSelectionType, setMultipleC
|
|
|
24
23
|
import { sortByColumn } from './sort';
|
|
25
24
|
import { splitCell } from './split-cell';
|
|
26
25
|
import { toggleHeaderColumn, toggleHeaderRow, toggleNumberColumn } from './toggle';
|
|
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
|
-
var _getPluginState2 = getPluginState(state),
|
|
50
|
-
currentActiveTableMenu = _getPluginState2.activeTableMenu;
|
|
51
|
-
var newTr = toggleActiveTableMenu({
|
|
52
|
-
type: direction,
|
|
53
|
-
index: index,
|
|
54
|
-
openedBy: trigger
|
|
55
|
-
}, currentActiveTableMenu)({
|
|
56
|
-
tr: state.tr
|
|
57
|
-
});
|
|
58
|
-
if (newTr) {
|
|
59
|
-
dispatch(newTr);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return true;
|
|
63
|
-
});
|
|
64
|
-
};
|
|
65
|
-
};
|
|
66
26
|
export var emptyMultipleCellsWithAnalytics = function emptyMultipleCellsWithAnalytics(editorAnalyticsAPI) {
|
|
67
27
|
return function (inputMethod, targetCellPosition) {
|
|
68
28
|
return withEditorAnalyticsAPI(function (_ref) {
|
|
@@ -227,8 +187,8 @@ export var changeColumnWidthByStepWithAnalytics = function changeColumnWidthBySt
|
|
|
227
187
|
table = _getSelectedTableInfo2.table,
|
|
228
188
|
totalRowCount = _getSelectedTableInfo2.totalRowCount,
|
|
229
189
|
totalColumnCount = _getSelectedTableInfo2.totalColumnCount;
|
|
230
|
-
var
|
|
231
|
-
colIndex =
|
|
190
|
+
var _getPluginState = getPluginState(state),
|
|
191
|
+
colIndex = _getPluginState.hoveredCell.colIndex;
|
|
232
192
|
return {
|
|
233
193
|
action: TABLE_ACTION.COLUMN_RESIZED,
|
|
234
194
|
actionSubject: ACTION_SUBJECT.TABLE,
|
|
@@ -348,8 +308,8 @@ export var deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut = function delete
|
|
|
348
308
|
}
|
|
349
309
|
var selectionType = getTableSelectionType(selection);
|
|
350
310
|
if (selectionType === 'row') {
|
|
351
|
-
var
|
|
352
|
-
pluginConfig =
|
|
311
|
+
var _getPluginState2 = getPluginState(state),
|
|
312
|
+
pluginConfig = _getPluginState2.pluginConfig;
|
|
353
313
|
var isHeaderRowRequired = pluginConfig.isHeaderRowRequired || false;
|
|
354
314
|
return deleteRowsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.SHORTCUT, rect, isHeaderRowRequired)(state, dispatch);
|
|
355
315
|
} else if (selectionType === 'column') {
|
|
@@ -393,8 +353,8 @@ export var toggleHeaderRowWithAnalytics = function toggleHeaderRowWithAnalytics(
|
|
|
393
353
|
var _getSelectedTableInfo7 = getSelectedTableInfo(state.selection),
|
|
394
354
|
totalRowCount = _getSelectedTableInfo7.totalRowCount,
|
|
395
355
|
totalColumnCount = _getSelectedTableInfo7.totalColumnCount;
|
|
396
|
-
var
|
|
397
|
-
isHeaderRowEnabled =
|
|
356
|
+
var _getPluginState3 = getPluginState(state),
|
|
357
|
+
isHeaderRowEnabled = _getPluginState3.isHeaderRowEnabled;
|
|
398
358
|
return {
|
|
399
359
|
action: TABLE_ACTION.TOGGLED_HEADER_ROW,
|
|
400
360
|
actionSubject: ACTION_SUBJECT.TABLE,
|
|
@@ -413,8 +373,8 @@ export var toggleHeaderColumnWithAnalytics = function toggleHeaderColumnWithAnal
|
|
|
413
373
|
var _getSelectedTableInfo8 = getSelectedTableInfo(state.selection),
|
|
414
374
|
totalRowCount = _getSelectedTableInfo8.totalRowCount,
|
|
415
375
|
totalColumnCount = _getSelectedTableInfo8.totalColumnCount;
|
|
416
|
-
var
|
|
417
|
-
isHeaderColumnEnabled =
|
|
376
|
+
var _getPluginState4 = getPluginState(state),
|
|
377
|
+
isHeaderColumnEnabled = _getPluginState4.isHeaderColumnEnabled;
|
|
418
378
|
return {
|
|
419
379
|
action: TABLE_ACTION.TOGGLED_HEADER_COLUMN,
|
|
420
380
|
actionSubject: ACTION_SUBJECT.TABLE,
|
|
@@ -90,7 +90,7 @@ var destroyFn = function destroyFn(editorView, editorAnalyticsAPI, isTableScalin
|
|
|
90
90
|
api === null || api === void 0 || api.core.actions.execute(function (_ref7) {
|
|
91
91
|
var _api$userIntent;
|
|
92
92
|
var tr = _ref7.tr;
|
|
93
|
-
closeActiveTableMenu()({
|
|
93
|
+
closeActiveTableMenu(api)({
|
|
94
94
|
tr: tr
|
|
95
95
|
});
|
|
96
96
|
api === null || api === void 0 || (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 || _api$userIntent.commands.setCurrentUserIntent('dragging')({
|
|
@@ -49,7 +49,7 @@ var updateTargetCellPosition = function updateTargetCellPosition(_ref2) {
|
|
|
49
49
|
}
|
|
50
50
|
var hasTargetCellChanged = pluginState.targetCellPosition !== _targetCellPosition;
|
|
51
51
|
var hasActiveTableMenu = pluginState.activeTableMenu != null && pluginState.activeTableMenu.type !== 'none';
|
|
52
|
-
var shouldCloseMenu = hasActiveTableMenu && (!tableNode || hasTargetCellChanged || !(tr.selection instanceof CellSelection));
|
|
52
|
+
var shouldCloseMenu = hasActiveTableMenu && tr.selectionSet && (!tableNode || hasTargetCellChanged || !(tr.selection instanceof CellSelection));
|
|
53
53
|
if (!hasTargetCellChanged && !shouldCloseMenu) {
|
|
54
54
|
return pluginState;
|
|
55
55
|
}
|
|
@@ -43,7 +43,10 @@ export var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch
|
|
|
43
43
|
wasFullWidthModeEnabled: previousFullWidthModeEnabled,
|
|
44
44
|
isHeaderRowEnabled: !!pluginConfig.allowHeaderRow,
|
|
45
45
|
isHeaderColumnEnabled: false,
|
|
46
|
-
isTableScalingEnabled: isTableScalingEnabled
|
|
46
|
+
isTableScalingEnabled: isTableScalingEnabled,
|
|
47
|
+
activeTableMenu: {
|
|
48
|
+
type: 'none'
|
|
49
|
+
}
|
|
47
50
|
}, defaultHoveredCell), defaultTableSelection), {}, {
|
|
48
51
|
getIntl: getIntl
|
|
49
52
|
}));
|
|
@@ -5,6 +5,7 @@ import { getDomRefFromSelection } from '@atlaskit/editor-common/get-dom-ref-from
|
|
|
5
5
|
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
6
6
|
import { ResizerBreakoutModeLabel } from '@atlaskit/editor-common/resizer';
|
|
7
7
|
import { akEditorFloatingPanelZIndex } from '@atlaskit/editor-shared-styles';
|
|
8
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
8
9
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
9
10
|
import FloatingContextualButton from './FloatingContextualButton';
|
|
10
11
|
import FloatingContextualMenu from './FloatingContextualMenu';
|
|
@@ -12,6 +13,7 @@ import FloatingDragMenu from './FloatingDragMenu';
|
|
|
12
13
|
// Ignored via go/ees005
|
|
13
14
|
// eslint-disable-next-line import/no-named-as-default
|
|
14
15
|
import FloatingInsertButton from './FloatingInsertButton';
|
|
16
|
+
import FloatingTableMenu from './FloatingTableMenu';
|
|
15
17
|
import { FloatingToolbarLabel } from './FloatingToolbarLabel/FloatingToolbarLabel';
|
|
16
18
|
import { GlobalStylesWrapper } from './global-styles';
|
|
17
19
|
import { SizeSelector } from './SizeSelector';
|
|
@@ -135,7 +137,15 @@ var ContentComponentInternal = function ContentComponentInternal(_ref) {
|
|
|
135
137
|
isCommentEditor: options === null || options === void 0 ? void 0 : options.isCommentEditor,
|
|
136
138
|
api: api,
|
|
137
139
|
isDragMenuOpen: isDragMenuOpen
|
|
138
|
-
}), /*#__PURE__*/React.createElement(
|
|
140
|
+
}), expValEquals('platform_editor_table_menu_updates', 'isEnabled', true) ? /*#__PURE__*/React.createElement(FloatingTableMenu, {
|
|
141
|
+
api: api,
|
|
142
|
+
boundariesElement: popupsBoundariesElement,
|
|
143
|
+
editorView: editorView,
|
|
144
|
+
mountPoint: popupsMountPoint,
|
|
145
|
+
stickyHeaders: stickyHeader,
|
|
146
|
+
tableWrapper: tableWrapperTarget,
|
|
147
|
+
targetCellPosition: targetCellPosition
|
|
148
|
+
}) : /*#__PURE__*/React.createElement(FloatingDragMenu, {
|
|
139
149
|
editorView: editorView,
|
|
140
150
|
mountPoint: popupsMountPoint,
|
|
141
151
|
boundariesElement: popupsBoundariesElement,
|
|
@@ -67,7 +67,7 @@ var FloatingContextualButtonInner = /*#__PURE__*/React.memo(function (props) {
|
|
|
67
67
|
toggleActiveTableMenu({
|
|
68
68
|
type: 'cell',
|
|
69
69
|
openedBy: 'mouse'
|
|
70
|
-
}, currentActiveTableMenu)({
|
|
70
|
+
}, currentActiveTableMenu, api)({
|
|
71
71
|
tr: tr
|
|
72
72
|
});
|
|
73
73
|
return tr;
|
|
@@ -102,7 +102,7 @@ var FloatingContextualButtonInner = /*#__PURE__*/React.memo(function (props) {
|
|
|
102
102
|
toggleActiveTableMenu({
|
|
103
103
|
type: 'cell',
|
|
104
104
|
openedBy: 'keyboard'
|
|
105
|
-
}, currentActiveTableMenu)({
|
|
105
|
+
}, currentActiveTableMenu, api)({
|
|
106
106
|
tr: tr
|
|
107
107
|
});
|
|
108
108
|
return tr;
|
|
@@ -34,11 +34,11 @@ export var CellMenuPopup = function CellMenuPopup(_ref) {
|
|
|
34
34
|
var closeCellMenu = useCallback(function () {
|
|
35
35
|
var _getPluginState = getPluginState(editorView.state),
|
|
36
36
|
isCellMenuOpenByKeyboard = _getPluginState.isCellMenuOpenByKeyboard;
|
|
37
|
-
api === null || api === void 0 || api.core.actions.execute(closeActiveTableMenu());
|
|
37
|
+
api === null || api === void 0 || api.core.actions.execute(closeActiveTableMenu(api));
|
|
38
38
|
if (isCellMenuOpenByKeyboard) {
|
|
39
39
|
setFocusToCellMenu(false)(editorView.state, editorView.dispatch);
|
|
40
40
|
}
|
|
41
|
-
}, [api
|
|
41
|
+
}, [api, editorView]);
|
|
42
42
|
var isEventInsideCellMenu = useCallback(function (event) {
|
|
43
43
|
var _popupContentRef$curr;
|
|
44
44
|
var target = event.target;
|
|
@@ -1,19 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
3
2
|
import { Popup } from '@atlaskit/editor-common/ui';
|
|
4
|
-
import { UserIntentPopupWrapper } from '@atlaskit/editor-common/user-intent';
|
|
5
3
|
import { akEditorFloatingDialogZIndex, akEditorFloatingOverlapPanelZIndex } from '@atlaskit/editor-shared-styles';
|
|
6
4
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
7
5
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
|
-
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
9
6
|
import { TableCssClassName as ClassName } from '../../types';
|
|
10
|
-
import { dragMenuDropdownWidth,
|
|
11
|
-
import { COLUMN_MENU } from '../TableMenu/column/keys';
|
|
12
|
-
import { ROW_MENU } from '../TableMenu/row/keys';
|
|
13
|
-
import { TABLE_MENU_WIDTH } from '../TableMenu/shared/consts';
|
|
14
|
-
import { TableMenu } from '../TableMenu/shared/TableMenu';
|
|
7
|
+
import { dragMenuDropdownWidth, tablePopupMenuFitHeight } from '../consts';
|
|
15
8
|
import DragMenu from './DragMenu';
|
|
16
|
-
var TABLE_MENU_OFFSET = dragTableInsertColumnButtonSize + 4;
|
|
17
9
|
var FloatingDragMenu = function FloatingDragMenu(_ref) {
|
|
18
10
|
var _getEditorFeatureFlag;
|
|
19
11
|
var mountPoint = _ref.mountPoint,
|
|
@@ -35,23 +27,11 @@ var FloatingDragMenu = function FloatingDragMenu(_ref) {
|
|
|
35
27
|
api = _ref.api,
|
|
36
28
|
isCommentEditor = _ref.isCommentEditor,
|
|
37
29
|
tableWrapper = _ref.tableWrapper;
|
|
38
|
-
|
|
39
|
-
var _states$tableState;
|
|
40
|
-
return {
|
|
41
|
-
activeTableMenu: (_states$tableState = states.tableState) === null || _states$tableState === void 0 ? void 0 : _states$tableState.activeTableMenu
|
|
42
|
-
};
|
|
43
|
-
}),
|
|
44
|
-
activeTableMenu = _useSharedPluginState.activeTableMenu;
|
|
45
|
-
var isActiveTableMenuDragMenu = (activeTableMenu === null || activeTableMenu === void 0 ? void 0 : activeTableMenu.type) === 'row' || (activeTableMenu === null || activeTableMenu === void 0 ? void 0 : activeTableMenu.type) === 'column';
|
|
46
|
-
var hasActiveTableMenuState = activeTableMenu !== undefined;
|
|
47
|
-
var isDragMenuOpen = expValEquals('platform_editor_table_menu_updates', 'isEnabled', true) && hasActiveTableMenuState ? isActiveTableMenuDragMenu : isOpen;
|
|
48
|
-
var dragMenuDirection = expValEquals('platform_editor_table_menu_updates', 'isEnabled', true) && hasActiveTableMenuState ? isActiveTableMenuDragMenu ? activeTableMenu.type : undefined : direction;
|
|
49
|
-
var dragMenuIndex = expValEquals('platform_editor_table_menu_updates', 'isEnabled', true) && hasActiveTableMenuState ? isActiveTableMenuDragMenu ? activeTableMenu.index : undefined : index;
|
|
50
|
-
if (!isDragMenuOpen || !targetCellPosition || editorView.state.doc.nodeSize <= targetCellPosition) {
|
|
30
|
+
if (!isOpen || !targetCellPosition || editorView.state.doc.nodeSize <= targetCellPosition) {
|
|
51
31
|
return null;
|
|
52
32
|
}
|
|
53
33
|
var inStickyMode = (stickyHeaders === null || stickyHeaders === void 0 ? void 0 : stickyHeaders.sticky) || (tableWrapper === null || tableWrapper === void 0 ? void 0 : tableWrapper.classList.contains(ClassName.TABLE_NODE_WRAPPER_NO_OVERFLOW)) && fg('platform_editor_table_sticky_header_patch_7');
|
|
54
|
-
var targetHandleRef =
|
|
34
|
+
var targetHandleRef = direction === 'row' ? document.querySelector('#drag-handle-button-row') : document.querySelector('#drag-handle-button-column');
|
|
55
35
|
if (!targetHandleRef || !(editorView.state.selection instanceof CellSelection)) {
|
|
56
36
|
return null;
|
|
57
37
|
}
|
|
@@ -60,8 +40,8 @@ var FloatingDragMenu = function FloatingDragMenu(_ref) {
|
|
|
60
40
|
tableWithFixedColumnWidthsOption = _ref2$tableWithFixedC === void 0 ? false : _ref2$tableWithFixedC;
|
|
61
41
|
var shouldUseIncreasedScalingPercent = isTableScalingEnabled && (tableWithFixedColumnWidthsOption || isCommentEditor);
|
|
62
42
|
return /*#__PURE__*/React.createElement(Popup, {
|
|
63
|
-
alignX:
|
|
64
|
-
alignY:
|
|
43
|
+
alignX: direction === 'row' ? 'right' : undefined,
|
|
44
|
+
alignY: direction === 'row' ? 'start' : undefined
|
|
65
45
|
// Ignored via go/ees005
|
|
66
46
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
67
47
|
,
|
|
@@ -69,7 +49,7 @@ var FloatingDragMenu = function FloatingDragMenu(_ref) {
|
|
|
69
49
|
mountTo: mountPoint,
|
|
70
50
|
boundariesElement: boundariesElement,
|
|
71
51
|
scrollableElement: scrollableElement,
|
|
72
|
-
fitWidth:
|
|
52
|
+
fitWidth: dragMenuDropdownWidth,
|
|
73
53
|
fitHeight: tablePopupMenuFitHeight
|
|
74
54
|
// z-index value below is to ensure that this menu is above other floating menu
|
|
75
55
|
// in table, but below floating dialogs like typeaheads, pickers, etc.
|
|
@@ -77,22 +57,14 @@ var FloatingDragMenu = function FloatingDragMenu(_ref) {
|
|
|
77
57
|
,
|
|
78
58
|
zIndex: inStickyMode ? akEditorFloatingDialogZIndex : akEditorFloatingOverlapPanelZIndex,
|
|
79
59
|
forcePlacement: true,
|
|
80
|
-
|
|
81
|
-
offset: expValEquals('platform_editor_table_menu_updates', 'isEnabled', true) ? [TABLE_MENU_OFFSET, 0] : direction === 'row' ? [-9, 0] : [0, -7],
|
|
60
|
+
offset: direction === 'row' ? [-9, 0] : [0, -7],
|
|
82
61
|
stick: true
|
|
83
|
-
},
|
|
84
|
-
api: api,
|
|
85
|
-
userIntent: "tableDragMenuPopupOpen"
|
|
86
|
-
}, /*#__PURE__*/React.createElement(TableMenu, {
|
|
87
|
-
api: api,
|
|
88
|
-
editorView: editorView,
|
|
89
|
-
surface: dragMenuDirection === 'row' ? ROW_MENU : COLUMN_MENU
|
|
90
|
-
})) : /*#__PURE__*/React.createElement(DragMenu, {
|
|
62
|
+
}, /*#__PURE__*/React.createElement(DragMenu, {
|
|
91
63
|
editorView: editorView,
|
|
92
|
-
isOpen:
|
|
64
|
+
isOpen: isOpen,
|
|
93
65
|
tableNode: tableNode,
|
|
94
|
-
direction:
|
|
95
|
-
index:
|
|
66
|
+
direction: direction,
|
|
67
|
+
index: index,
|
|
96
68
|
target: targetHandleRef || undefined,
|
|
97
69
|
targetCellPosition: targetCellPosition,
|
|
98
70
|
getEditorContainerWidth: getEditorContainerWidth,
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import React, { useCallback, useContext, useMemo, useRef } from 'react';
|
|
2
|
+
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
3
|
+
import { Popup } from '@atlaskit/editor-common/ui';
|
|
4
|
+
import { OutsideClickTargetRefContext, withReactEditorViewOuterListeners } from '@atlaskit/editor-common/ui-react';
|
|
5
|
+
import { akEditorFloatingDialogZIndex, akEditorFloatingOverlapPanelZIndex } from '@atlaskit/editor-shared-styles';
|
|
6
|
+
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
7
|
+
import { ToolbarKeyboardNavigationProvider } from '@atlaskit/editor-toolbar/toolbar-keyboard-navigation-provider';
|
|
8
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
|
+
import { closeActiveTableMenu } from '../../pm-plugins/commands';
|
|
10
|
+
import { TableCssClassName as ClassName } from '../../types';
|
|
11
|
+
import { dragTableInsertColumnButtonSize, tablePopupMenuFitHeight } from '../consts';
|
|
12
|
+
import { COLUMN_MENU } from '../TableMenu/column/keys';
|
|
13
|
+
import { ROW_MENU } from '../TableMenu/row/keys';
|
|
14
|
+
import { TABLE_MENU_WIDTH } from '../TableMenu/shared/consts';
|
|
15
|
+
import { TableMenu } from '../TableMenu/shared/TableMenu';
|
|
16
|
+
var PopupWithListeners = withReactEditorViewOuterListeners(Popup);
|
|
17
|
+
|
|
18
|
+
// Defer drag-handle clicks to the drag handle's own toggle/select handlers — those own
|
|
19
|
+
// the open/switch/close semantics for moving between rows/columns.
|
|
20
|
+
var DRAG_HANDLE_CONTROLS_SELECTOR = ".".concat(ClassName.DRAG_ROW_CONTROLS, ", .").concat(ClassName.DRAG_COLUMN_CONTROLS);
|
|
21
|
+
var NESTED_DROPDOWN_SELECTOR = '[data-toolbar-nested-dropdown-menu]';
|
|
22
|
+
|
|
23
|
+
// Marks the menu subtree that ToolbarKeyboardNavigationProvider scopes its
|
|
24
|
+
// keyboard handling to. The provider only reacts to events whose target sits
|
|
25
|
+
// inside this selector.
|
|
26
|
+
var TABLE_MENU_NAV_SELECTOR = '[data-table-drag-menu-nav="true"]';
|
|
27
|
+
var TABLE_MENU_OFFSET = dragTableInsertColumnButtonSize + 4;
|
|
28
|
+
var POPUP_OFFSET = [TABLE_MENU_OFFSET, 0];
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Row and column menu for table.
|
|
32
|
+
*/
|
|
33
|
+
var FloatingTableMenu = function FloatingTableMenu(_ref) {
|
|
34
|
+
var api = _ref.api,
|
|
35
|
+
boundariesElement = _ref.boundariesElement,
|
|
36
|
+
editorView = _ref.editorView,
|
|
37
|
+
mountPoint = _ref.mountPoint,
|
|
38
|
+
scrollableElement = _ref.scrollableElement,
|
|
39
|
+
stickyHeaders = _ref.stickyHeaders,
|
|
40
|
+
tableWrapper = _ref.tableWrapper,
|
|
41
|
+
targetCellPosition = _ref.targetCellPosition;
|
|
42
|
+
var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['table'], function (states) {
|
|
43
|
+
var _states$tableState;
|
|
44
|
+
return {
|
|
45
|
+
activeTableMenu: (_states$tableState = states.tableState) === null || _states$tableState === void 0 ? void 0 : _states$tableState.activeTableMenu
|
|
46
|
+
};
|
|
47
|
+
}),
|
|
48
|
+
activeTableMenu = _useSharedPluginState.activeTableMenu;
|
|
49
|
+
var isDragMenuOpen = (activeTableMenu === null || activeTableMenu === void 0 ? void 0 : activeTableMenu.type) === 'row' || (activeTableMenu === null || activeTableMenu === void 0 ? void 0 : activeTableMenu.type) === 'column';
|
|
50
|
+
var dragMenuDirection = isDragMenuOpen ? activeTableMenu.type : undefined;
|
|
51
|
+
var isOpenedByKeyboard = isDragMenuOpen && activeTableMenu.openedBy === 'keyboard';
|
|
52
|
+
var popupContentRef = useRef(null);
|
|
53
|
+
var setOutsideClickTargetRef = useContext(OutsideClickTargetRefContext);
|
|
54
|
+
var navWrapperRef = useRef(null);
|
|
55
|
+
var handlePopupRef = useCallback(function (el) {
|
|
56
|
+
popupContentRef.current = el;
|
|
57
|
+
setOutsideClickTargetRef === null || setOutsideClickTargetRef === void 0 || setOutsideClickTargetRef(el);
|
|
58
|
+
}, [setOutsideClickTargetRef]);
|
|
59
|
+
var dismiss = useCallback(function () {
|
|
60
|
+
api === null || api === void 0 || api.core.actions.execute(closeActiveTableMenu(api));
|
|
61
|
+
}, [api]);
|
|
62
|
+
var returnFocusToDragHandle = useCallback(function () {
|
|
63
|
+
// Match legacy DragMenu's closeMenu('handle') behaviour.
|
|
64
|
+
var handleId = dragMenuDirection === 'row' ? '#drag-handle-button-row' : '#drag-handle-button-column';
|
|
65
|
+
var handle = document.querySelector(handleId);
|
|
66
|
+
handle === null || handle === void 0 || handle.focus();
|
|
67
|
+
}, [dragMenuDirection]);
|
|
68
|
+
var focusFirstMenuItem = useCallback(function () {
|
|
69
|
+
var root = navWrapperRef.current;
|
|
70
|
+
if (!root) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
var firstItem = root.querySelector('[role="menuitem"]:not([disabled]), [role="menuitemcheckbox"]:not([disabled]), [role="menuitemradio"]:not([disabled]), button:not([disabled])');
|
|
74
|
+
firstItem === null || firstItem === void 0 || firstItem.focus();
|
|
75
|
+
}, []);
|
|
76
|
+
|
|
77
|
+
// Focus the first menu item when the menu opens via keyboard (Enter/Space on
|
|
78
|
+
// the drag handle). Mouse-opened menus leave focus where the user clicked.
|
|
79
|
+
var setNavWrapperRef = useCallback(function (el) {
|
|
80
|
+
navWrapperRef.current = el;
|
|
81
|
+
if (el && isOpenedByKeyboard) {
|
|
82
|
+
// rAF allows the popup to finish positioning before focusing.
|
|
83
|
+
requestAnimationFrame(function () {
|
|
84
|
+
focusFirstMenuItem();
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}, [focusFirstMenuItem, isOpenedByKeyboard]);
|
|
88
|
+
var handleKeyboardFocus = useCallback(function (_event) {
|
|
89
|
+
focusFirstMenuItem();
|
|
90
|
+
}, [focusFirstMenuItem]);
|
|
91
|
+
var handleEscape = useCallback(function (event) {
|
|
92
|
+
event.preventDefault();
|
|
93
|
+
event.stopPropagation();
|
|
94
|
+
dismiss();
|
|
95
|
+
returnFocusToDragHandle();
|
|
96
|
+
}, [dismiss, returnFocusToDragHandle]);
|
|
97
|
+
|
|
98
|
+
// Memoize the editor DOM reference so the provider doesn't re-bind listeners
|
|
99
|
+
// on every render (the provider depends on `dom` in its effect's deps).
|
|
100
|
+
var editorDom = useMemo(function () {
|
|
101
|
+
return editorView.dom instanceof HTMLElement ? editorView.dom : undefined;
|
|
102
|
+
}, [editorView.dom]);
|
|
103
|
+
|
|
104
|
+
// The drag menu is opened by interacting with the drag handle directly, not
|
|
105
|
+
// by a global page-level shortcut.
|
|
106
|
+
var isShortcutToFocusToolbar = useCallback(function () {
|
|
107
|
+
return false;
|
|
108
|
+
}, []);
|
|
109
|
+
var handleClickOutside = useCallback(function (event) {
|
|
110
|
+
var _popupContentRef$curr;
|
|
111
|
+
var target = event.target;
|
|
112
|
+
// Ignore clicks handled by this popup, drag handles, or nested portalled
|
|
113
|
+
// dropdowns so those controls can manage their own open/close behavior.
|
|
114
|
+
if (target instanceof Node && (_popupContentRef$curr = popupContentRef.current) !== null && _popupContentRef$curr !== void 0 && _popupContentRef$curr.contains(target) || target instanceof Element && (target.closest(DRAG_HANDLE_CONTROLS_SELECTOR) || target.closest(NESTED_DROPDOWN_SELECTOR))) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
dismiss();
|
|
118
|
+
}, [dismiss]);
|
|
119
|
+
if (!isDragMenuOpen || !targetCellPosition || editorView.state.doc.nodeSize <= targetCellPosition) {
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
var inStickyMode = (stickyHeaders === null || stickyHeaders === void 0 ? void 0 : stickyHeaders.sticky) || (tableWrapper === null || tableWrapper === void 0 ? void 0 : tableWrapper.classList.contains(ClassName.TABLE_NODE_WRAPPER_NO_OVERFLOW)) && fg('platform_editor_table_sticky_header_patch_7');
|
|
123
|
+
var targetHandleRef = dragMenuDirection === 'row' ? document.querySelector('#drag-handle-button-row') : document.querySelector('#drag-handle-button-column');
|
|
124
|
+
if (!targetHandleRef || !(editorView.state.selection instanceof CellSelection)) {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
return /*#__PURE__*/React.createElement(PopupWithListeners, {
|
|
128
|
+
alignX: dragMenuDirection === 'row' ? 'right' : undefined,
|
|
129
|
+
alignY: dragMenuDirection === 'row' ? 'start' : undefined
|
|
130
|
+
// Ignored via go/ees005
|
|
131
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
132
|
+
,
|
|
133
|
+
target: targetHandleRef,
|
|
134
|
+
mountTo: mountPoint,
|
|
135
|
+
boundariesElement: boundariesElement,
|
|
136
|
+
scrollableElement: scrollableElement,
|
|
137
|
+
fitWidth: TABLE_MENU_WIDTH,
|
|
138
|
+
fitHeight: tablePopupMenuFitHeight
|
|
139
|
+
// z-index value below is to ensure that this menu is above other floating menu
|
|
140
|
+
// in table, but below floating dialogs like typeaheads, pickers, etc.
|
|
141
|
+
// In sticky mode, we want to show the menu above the sticky header
|
|
142
|
+
,
|
|
143
|
+
zIndex: inStickyMode ? akEditorFloatingDialogZIndex : akEditorFloatingOverlapPanelZIndex,
|
|
144
|
+
forcePlacement: true,
|
|
145
|
+
preventOverflow: dragMenuDirection === 'row',
|
|
146
|
+
offset: POPUP_OFFSET,
|
|
147
|
+
stick: true,
|
|
148
|
+
handleClickOutside: handleClickOutside
|
|
149
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
150
|
+
ref: handlePopupRef
|
|
151
|
+
}, /*#__PURE__*/React.createElement(ToolbarKeyboardNavigationProvider, {
|
|
152
|
+
childComponentSelector: TABLE_MENU_NAV_SELECTOR,
|
|
153
|
+
dom: editorDom,
|
|
154
|
+
isShortcutToFocusToolbar: isShortcutToFocusToolbar,
|
|
155
|
+
handleFocus: handleKeyboardFocus,
|
|
156
|
+
handleEscape: handleEscape
|
|
157
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
158
|
+
"data-table-drag-menu-nav": "true",
|
|
159
|
+
ref: setNavWrapperRef
|
|
160
|
+
}, /*#__PURE__*/React.createElement(TableMenu, {
|
|
161
|
+
api: api,
|
|
162
|
+
editorView: editorView,
|
|
163
|
+
surface: dragMenuDirection === 'row' ? ROW_MENU : COLUMN_MENU
|
|
164
|
+
})))));
|
|
165
|
+
};
|
|
166
|
+
FloatingTableMenu.displayName = 'FloatingTableMenu';
|
|
167
|
+
export default FloatingTableMenu;
|