@atlaskit/editor-plugin-table 5.7.10 → 5.8.0
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 +11 -0
- package/afm-cc/tsconfig.json +3 -0
- package/dist/cjs/commands/column-resize.js +155 -0
- package/dist/cjs/commands/go-to-next-cell.js +15 -0
- package/dist/cjs/commands/selection.js +16 -3
- package/dist/cjs/plugin.js +2 -1
- package/dist/cjs/pm-plugins/keymap.js +9 -0
- package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +18 -7
- package/dist/cjs/pm-plugins/table-resizing/utils/index.js +6 -0
- package/dist/cjs/types.js +2 -0
- package/dist/cjs/ui/FloatingDragMenu/DragMenu.js +187 -17
- package/dist/cjs/ui/FloatingDragMenu/index.js +4 -2
- package/dist/cjs/ui/FloatingDragMenu/styles.js +19 -0
- package/dist/cjs/ui/consts.js +2 -1
- package/dist/es2019/commands/column-resize.js +149 -0
- package/dist/es2019/commands/go-to-next-cell.js +13 -0
- package/dist/es2019/commands/selection.js +16 -3
- package/dist/es2019/plugin.js +2 -1
- package/dist/es2019/pm-plugins/keymap.js +10 -1
- package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +19 -8
- package/dist/es2019/pm-plugins/table-resizing/utils/index.js +1 -1
- package/dist/es2019/types.js +2 -0
- package/dist/es2019/ui/FloatingDragMenu/DragMenu.js +177 -7
- package/dist/es2019/ui/FloatingDragMenu/index.js +4 -2
- package/dist/es2019/ui/FloatingDragMenu/styles.js +62 -0
- package/dist/es2019/ui/consts.js +2 -1
- package/dist/esm/commands/column-resize.js +149 -0
- package/dist/esm/commands/go-to-next-cell.js +15 -0
- package/dist/esm/commands/selection.js +16 -3
- package/dist/esm/plugin.js +2 -1
- package/dist/esm/pm-plugins/keymap.js +10 -1
- package/dist/esm/pm-plugins/table-resizing/event-handlers.js +19 -8
- package/dist/esm/pm-plugins/table-resizing/utils/index.js +1 -1
- package/dist/esm/types.js +2 -0
- package/dist/esm/ui/FloatingDragMenu/DragMenu.js +177 -7
- package/dist/esm/ui/FloatingDragMenu/index.js +4 -2
- package/dist/esm/ui/FloatingDragMenu/styles.js +12 -0
- package/dist/esm/ui/consts.js +2 -1
- package/dist/types/commands/column-resize.d.ts +5 -0
- package/dist/types/pm-plugins/table-resizing/utils/index.d.ts +1 -1
- package/dist/types/types.d.ts +2 -0
- package/dist/types/ui/FloatingDragMenu/DragMenu.d.ts +1 -2
- package/dist/types/ui/FloatingDragMenu/index.d.ts +3 -2
- package/dist/types/ui/FloatingDragMenu/styles.d.ts +3 -0
- package/dist/types/ui/consts.d.ts +1 -1
- package/dist/types-ts4.5/commands/column-resize.d.ts +5 -0
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/index.d.ts +1 -1
- package/dist/types-ts4.5/types.d.ts +2 -0
- package/dist/types-ts4.5/ui/FloatingDragMenu/DragMenu.d.ts +1 -2
- package/dist/types-ts4.5/ui/FloatingDragMenu/index.d.ts +3 -2
- package/dist/types-ts4.5/ui/FloatingDragMenu/styles.d.ts +3 -0
- package/dist/types-ts4.5/ui/consts.d.ts +1 -1
- package/package.json +6 -2
- package/src/__tests__/unit/ui/FloatingDragMenu.tsx +295 -0
- package/src/commands/column-resize.ts +257 -0
- package/src/commands/go-to-next-cell.ts +21 -0
- package/src/commands/selection.ts +19 -2
- package/src/plugin.tsx +1 -0
- package/src/pm-plugins/keymap.ts +35 -0
- package/src/pm-plugins/table-resizing/event-handlers.ts +33 -21
- package/src/pm-plugins/table-resizing/utils/index.ts +1 -0
- package/src/types.ts +3 -0
- package/src/ui/FloatingDragMenu/DragMenu.tsx +226 -7
- package/src/ui/FloatingDragMenu/index.tsx +4 -1
- package/src/ui/FloatingDragMenu/styles.ts +71 -0
- package/src/ui/consts.ts +6 -1
- package/tsconfig.app.json +3 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { css } from '@emotion/react';
|
|
2
|
+
import { tableBackgroundBorderColor } from '@atlaskit/adf-schema';
|
|
3
|
+
import { N60A, N90 } from '@atlaskit/theme/colors';
|
|
4
|
+
import { TableCssClassName as ClassName } from '../../types';
|
|
5
|
+
import { dragMenuDropdownWidth } from '../consts';
|
|
6
|
+
export const cellColourPreviewStyles = selectedColor => css`
|
|
7
|
+
&::before {
|
|
8
|
+
background: ${selectedColor};
|
|
9
|
+
}
|
|
10
|
+
`;
|
|
11
|
+
export const dragMenuBackgroundColorStyles = css`
|
|
12
|
+
.${ClassName.DRAG_SUBMENU} {
|
|
13
|
+
border-radius: ${"var(--ds-border-radius, 3px)"};
|
|
14
|
+
background: ${"var(--ds-surface-overlay, white)"};
|
|
15
|
+
box-shadow: ${`var(--ds-shadow-overlay, ${`0 4px 8px -2px ${N60A}, 0 0 1px ${N60A}`})`};
|
|
16
|
+
display: block;
|
|
17
|
+
position: absolute;
|
|
18
|
+
top: 0;
|
|
19
|
+
left: ${dragMenuDropdownWidth}px;
|
|
20
|
+
padding: ${"var(--ds-space-100, 8px)"};
|
|
21
|
+
|
|
22
|
+
> div {
|
|
23
|
+
padding: 0;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.${ClassName.DRAG_SUBMENU_ICON} {
|
|
28
|
+
display: flex;
|
|
29
|
+
|
|
30
|
+
&::before {
|
|
31
|
+
content: '';
|
|
32
|
+
display: block;
|
|
33
|
+
border: 1px solid ${tableBackgroundBorderColor};
|
|
34
|
+
border-radius: ${"var(--ds-border-radius, 3px)"};
|
|
35
|
+
width: 14px;
|
|
36
|
+
height: 14px;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
&::after {
|
|
40
|
+
content: '›';
|
|
41
|
+
margin-left: ${"var(--ds-space-050, 4px)"};
|
|
42
|
+
line-height: 14px;
|
|
43
|
+
color: ${`var(--ds-icon, ${N90})`};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
`;
|
|
47
|
+
export const toggleStyles = css`
|
|
48
|
+
display: flex;
|
|
49
|
+
input[type='checkbox'] {
|
|
50
|
+
width: 30px;
|
|
51
|
+
height: 14px;
|
|
52
|
+
pointer-events: initial;
|
|
53
|
+
cursor: pointer;
|
|
54
|
+
}
|
|
55
|
+
> label {
|
|
56
|
+
margin: 0px;
|
|
57
|
+
pointer-events: none;
|
|
58
|
+
> span {
|
|
59
|
+
pointer-events: none;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
`;
|
package/dist/es2019/ui/consts.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { tableCellBorderWidth, tableMarginTop } from '@atlaskit/editor-common/styles';
|
|
2
2
|
import { akEditorTableBorder, akEditorTableBorderSelected, akEditorTableCellBlanketDeleted, akEditorTableCellBlanketSelected, akEditorTableHeaderCellBackground, akEditorTableToolbar, akEditorTableToolbarSize, akEditorUnitZIndex, akRichMediaResizeZIndex } from '@atlaskit/editor-shared-styles';
|
|
3
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
3
4
|
import { B200, N0, N20, N200, N20A, N300, R300, R400, R75 } from '@atlaskit/theme/colors';
|
|
4
5
|
import { RESIZE_HANDLE_AREA_DECORATION_GAP } from '../types';
|
|
5
6
|
|
|
@@ -49,7 +50,7 @@ export const resizeHandlerAreaWidth = RESIZE_HANDLE_AREA_DECORATION_GAP / 3;
|
|
|
49
50
|
export const resizeLineWidth = 2;
|
|
50
51
|
export const resizeHandlerZIndex = columnControlsZIndex + akRichMediaResizeZIndex;
|
|
51
52
|
export const contextualMenuTriggerSize = 16;
|
|
52
|
-
export const contextualMenuDropdownWidth = 180;
|
|
53
|
+
export const contextualMenuDropdownWidth = getBooleanFF('platform.editor.table.drag-and-drop') ? 250 : 180;
|
|
53
54
|
export const stickyRowZIndex = resizeHandlerZIndex + 2;
|
|
54
55
|
export const stickyRowOffsetTop = 8;
|
|
55
56
|
export const stickyHeaderBorderBottomWidth = 1;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
2
|
+
import { TableMap } from '@atlaskit/editor-tables';
|
|
3
|
+
import { findCellClosestToPos, findCellRectClosestToPos, findTableClosestToPos, getSelectionRect, isSelectionType, nextCell } from '@atlaskit/editor-tables/src/utils';
|
|
4
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
5
|
+
import { getPluginState as getTableResizingPluginState, createCommand as tableResizingPluginCreateCommand } from '../pm-plugins/table-resizing/plugin-factory';
|
|
6
|
+
import { currentColWidth, getResizeState, getTableMaxWidth, resizeColumn, updateControls } from '../pm-plugins/table-resizing/utils';
|
|
7
|
+
import { updateColumnWidths } from '../transforms';
|
|
8
|
+
import { getSelectedColumnIndexes } from '../utils';
|
|
9
|
+
import { addResizeHandleDecorations, showResizeHandleLine } from './index';
|
|
10
|
+
var updateResizeHandleAndStatePosition = function updateResizeHandleAndStatePosition(rowIndex, columnIndex, nextResizeHandlePos) {
|
|
11
|
+
return function (state, dispatch) {
|
|
12
|
+
addResizeHandleDecorations(rowIndex, columnIndex, true)(state, dispatch);
|
|
13
|
+
// Currently only 'right' position is used in showResizeHandleLine
|
|
14
|
+
showResizeHandleLine({
|
|
15
|
+
left: 0,
|
|
16
|
+
right: columnIndex
|
|
17
|
+
})(state, dispatch);
|
|
18
|
+
tableResizingPluginCreateCommand({
|
|
19
|
+
type: 'SET_RESIZE_HANDLE_POSITION',
|
|
20
|
+
data: {
|
|
21
|
+
resizeHandlePos: nextResizeHandlePos
|
|
22
|
+
}
|
|
23
|
+
})(state, dispatch);
|
|
24
|
+
return false;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export var initiateKeyboardColumnResizing = function initiateKeyboardColumnResizing(state, dispatch, view) {
|
|
28
|
+
if (!getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
var selection = state.selection;
|
|
32
|
+
var selectionRect = isSelectionType(selection, 'cell') ? getSelectionRect(selection) : findCellRectClosestToPos(selection.$from);
|
|
33
|
+
var cell = findCellClosestToPos(selection.$from);
|
|
34
|
+
if (selectionRect && cell && view) {
|
|
35
|
+
var cellAttrs = cell.node.attrs;
|
|
36
|
+
var width = currentColWidth(view, cell.pos, cellAttrs);
|
|
37
|
+
updateResizeHandleAndStatePosition(selectionRect.top, selectionRect.right, cell.pos)(state, dispatch);
|
|
38
|
+
tableResizingPluginCreateCommand({
|
|
39
|
+
type: 'SET_DRAGGING',
|
|
40
|
+
data: {
|
|
41
|
+
dragging: {
|
|
42
|
+
startX: 0,
|
|
43
|
+
startWidth: width
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
})(state, dispatch);
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
return false;
|
|
50
|
+
};
|
|
51
|
+
export var activateNextResizeArea = function activateNextResizeArea(direction) {
|
|
52
|
+
return function (state, dispatch) {
|
|
53
|
+
if (!getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
var _ref = getTableResizingPluginState(state) || {},
|
|
57
|
+
resizeHandlePos = _ref.resizeHandlePos,
|
|
58
|
+
dragging = _ref.dragging;
|
|
59
|
+
// If No resizing has initiated, skip to regular handler
|
|
60
|
+
if (!resizeHandlePos || !dragging) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
var selection = state.selection;
|
|
64
|
+
var cell = findCellClosestToPos(selection.$from);
|
|
65
|
+
if (!cell) {
|
|
66
|
+
// cursor position may be changed by mouse to be outside of table;
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
var $currentCell = state.doc.resolve(resizeHandlePos);
|
|
70
|
+
if (!$currentCell) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
var tableNode = $currentCell.node(-1);
|
|
74
|
+
var closestTable = findTableClosestToPos($currentCell);
|
|
75
|
+
var tableMap = TableMap.get(tableNode);
|
|
76
|
+
if (!tableNode || !closestTable || !tableMap) {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
var currentCellRect = tableMap.findCell($currentCell.pos - $currentCell.start(-1));
|
|
80
|
+
var $nextCell = nextCell($currentCell, 'horiz', direction);
|
|
81
|
+
if ($nextCell) {
|
|
82
|
+
// we are somewhere in between the side columns of the table
|
|
83
|
+
var offset = $nextCell.pos - $nextCell.start(-1);
|
|
84
|
+
var rectForNextCell = tableMap.findCell(offset);
|
|
85
|
+
updateResizeHandleAndStatePosition(rectForNextCell.top, rectForNextCell.right, $nextCell.pos)(state, dispatch);
|
|
86
|
+
} else {
|
|
87
|
+
// current position is in the one of the side columns of the table(left or right)
|
|
88
|
+
if (currentCellRect.left === 0) {
|
|
89
|
+
var lastCellInCurrentRow = tableMap.positionAt(currentCellRect.top, tableMap.width - 1, tableNode) + closestTable.start;
|
|
90
|
+
var $lastCell = state.doc.resolve(lastCellInCurrentRow);
|
|
91
|
+
updateResizeHandleAndStatePosition(currentCellRect.top, tableMap.width, $lastCell.pos)(state, dispatch);
|
|
92
|
+
} else if (tableMap.width === currentCellRect.right) {
|
|
93
|
+
var firsCellInCurrentRow = tableMap.positionAt(currentCellRect.top, 0, tableNode) + closestTable.start;
|
|
94
|
+
var _$nextCell = state.doc.resolve(firsCellInCurrentRow);
|
|
95
|
+
updateResizeHandleAndStatePosition(currentCellRect.top, 1, _$nextCell.pos)(state, dispatch);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return true;
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
export var changeColumnWidthByStep = function changeColumnWidthByStep(stepSize, getEditorContainerWidth) {
|
|
102
|
+
return function (state, dispatch, view) {
|
|
103
|
+
if (!getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
var _getTableResizingPlug = getTableResizingPluginState(state),
|
|
107
|
+
resizeHandlePos = _getTableResizingPlug.resizeHandlePos,
|
|
108
|
+
dragging = _getTableResizingPlug.dragging;
|
|
109
|
+
if (!view || !resizeHandlePos || !dragging) {
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
var $cell = state.doc.resolve(resizeHandlePos);
|
|
113
|
+
var tableStartPosition = $cell.start(-1);
|
|
114
|
+
var originalTable = $cell.node(-1);
|
|
115
|
+
var map = TableMap.get(originalTable);
|
|
116
|
+
var domAtPos = view.domAtPos.bind(view);
|
|
117
|
+
var colIndex = map.colCount($cell.pos - tableStartPosition) + ($cell.nodeAfter ? $cell.nodeAfter.attrs.colspan : 1) - 1;
|
|
118
|
+
var dom = domAtPos(tableStartPosition).node;
|
|
119
|
+
if (dom && dom.nodeName !== 'TABLE') {
|
|
120
|
+
dom = dom.closest('table');
|
|
121
|
+
}
|
|
122
|
+
var maxSize = getTableMaxWidth({
|
|
123
|
+
table: originalTable,
|
|
124
|
+
tableStart: tableStartPosition,
|
|
125
|
+
state: state,
|
|
126
|
+
layout: originalTable.attrs.layout,
|
|
127
|
+
getEditorContainerWidth: getEditorContainerWidth
|
|
128
|
+
});
|
|
129
|
+
var initialResizeState = getResizeState({
|
|
130
|
+
minWidth: tableCellMinWidth,
|
|
131
|
+
maxSize: maxSize,
|
|
132
|
+
table: originalTable,
|
|
133
|
+
tableRef: dom,
|
|
134
|
+
start: tableStartPosition,
|
|
135
|
+
domAtPos: domAtPos
|
|
136
|
+
});
|
|
137
|
+
updateControls()(state);
|
|
138
|
+
var selectionRect = getSelectionRect(state.selection);
|
|
139
|
+
var selectedColumns = selectionRect ? getSelectedColumnIndexes(selectionRect) : [];
|
|
140
|
+
// only selected (or selected - 1) columns should be distributed
|
|
141
|
+
var resizingSelectedColumns = selectedColumns.indexOf(colIndex) > -1 || selectedColumns.indexOf(colIndex + 1) > -1;
|
|
142
|
+
var newResizeState = resizeColumn(initialResizeState, colIndex, stepSize, dom, resizingSelectedColumns ? selectedColumns : undefined);
|
|
143
|
+
var tr = updateColumnWidths(newResizeState, originalTable, tableStartPosition)(state.tr);
|
|
144
|
+
if (dispatch) {
|
|
145
|
+
dispatch(tr);
|
|
146
|
+
}
|
|
147
|
+
return true;
|
|
148
|
+
};
|
|
149
|
+
};
|
|
@@ -4,7 +4,10 @@ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
|
4
4
|
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
5
5
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
6
6
|
import { goToNextCell as baseGotoNextCell, findTable } from '@atlaskit/editor-tables/utils';
|
|
7
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
7
8
|
import { insertRowWithAnalytics } from '../commands-with-analytics';
|
|
9
|
+
import { getPluginState as getResizePluginState, createCommand as tableResizingPluginCreateCommand } from '../pm-plugins/table-resizing/plugin-factory';
|
|
10
|
+
import { hideResizeHandleLine } from './hover';
|
|
8
11
|
var TAB_FORWARD_DIRECTION = 1;
|
|
9
12
|
var TAB_BACKWARD_DIRECTION = -1;
|
|
10
13
|
export var goToNextCell = function goToNextCell(editorAnalyticsAPI) {
|
|
@@ -14,6 +17,18 @@ export var goToNextCell = function goToNextCell(editorAnalyticsAPI) {
|
|
|
14
17
|
if (!table) {
|
|
15
18
|
return false;
|
|
16
19
|
}
|
|
20
|
+
if (getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
|
|
21
|
+
var _getResizePluginState;
|
|
22
|
+
var isColumnResizing = !!((_getResizePluginState = getResizePluginState(state)) !== null && _getResizePluginState !== void 0 && _getResizePluginState.dragging);
|
|
23
|
+
if (isColumnResizing) {
|
|
24
|
+
tableResizingPluginCreateCommand({
|
|
25
|
+
type: 'STOP_RESIZING'
|
|
26
|
+
}, function (originalTr) {
|
|
27
|
+
return (state.tr || originalTr).setMeta('scrollIntoView', false);
|
|
28
|
+
})(state, dispatch);
|
|
29
|
+
hideResizeHandleLine()(state, dispatch);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
17
32
|
var map = TableMap.get(table.node);
|
|
18
33
|
var _state$schema$nodes = state.schema.nodes,
|
|
19
34
|
tableCell = _state$schema$nodes.tableCell,
|
|
@@ -3,7 +3,9 @@ import { Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
|
3
3
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
4
4
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
5
5
|
import { findTable, isColumnSelected, isRowSelected, isTableSelected, selectedRect } from '@atlaskit/editor-tables/utils';
|
|
6
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
6
7
|
import { selectColumn, selectRow } from '../commands/misc';
|
|
8
|
+
import { getPluginState as getResizePluginState } from '../pm-plugins/table-resizing/plugin-factory';
|
|
7
9
|
import { getClosestSelectionRect } from '../toolbar';
|
|
8
10
|
export var TableSelectionDirection = /*#__PURE__*/function (TableSelectionDirection) {
|
|
9
11
|
TableSelectionDirection["TopToBottom"] = "TopToBottom";
|
|
@@ -192,9 +194,14 @@ var arrowLeftFromText = function arrowLeftFromText(editorSelectionAPI) {
|
|
|
192
194
|
var table = findTable(selection);
|
|
193
195
|
if (table) {
|
|
194
196
|
var $from = selection.$from;
|
|
197
|
+
var isColumnResizing = false;
|
|
198
|
+
if (getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
|
|
199
|
+
var columResizePluginState = getResizePluginState(state) || {};
|
|
200
|
+
isColumnResizing = Boolean(columResizePluginState === null || columResizePluginState === void 0 ? void 0 : columResizePluginState.dragging);
|
|
201
|
+
}
|
|
195
202
|
if (isSelectionAtStartOfTable($from, selection) && $from.parent.type.name === 'paragraph' && $from.depth === table.depth + 3 &&
|
|
196
203
|
// + 3 for: row, cell & paragraph nodes
|
|
197
|
-
editorSelectionAPI) {
|
|
204
|
+
editorSelectionAPI && !isColumnResizing) {
|
|
198
205
|
var selectionState = editorSelectionAPI.sharedState.currentState() || {};
|
|
199
206
|
if ((selectionState === null || selectionState === void 0 ? void 0 : selectionState.selectionRelativeToNode) === RelativeSelectionPos.Before) {
|
|
200
207
|
// we have a text selection at start of first table cell, directly inside a top level paragraph,
|
|
@@ -221,8 +228,14 @@ var arrowRightFromText = function arrowRightFromText(editorSelectionAPI) {
|
|
|
221
228
|
var table = findTable(selection);
|
|
222
229
|
if (table) {
|
|
223
230
|
var $to = selection.$to;
|
|
224
|
-
|
|
225
|
-
) {
|
|
231
|
+
var isColumnResizing = false;
|
|
232
|
+
if (getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
|
|
233
|
+
var columResizePluginState = getResizePluginState(state) || {};
|
|
234
|
+
isColumnResizing = Boolean(columResizePluginState === null || columResizePluginState === void 0 ? void 0 : columResizePluginState.dragging);
|
|
235
|
+
}
|
|
236
|
+
if (isSelectionAtEndOfTable($to, selection) && $to.parent.type.name === 'paragraph' && $to.depth === table.depth + 3 &&
|
|
237
|
+
// + 3 for: row, cell & paragraph nodes
|
|
238
|
+
!isColumnResizing) {
|
|
226
239
|
// we have a text selection at end of last table cell, directly inside a top level paragraph,
|
|
227
240
|
// and want to set a full table cell selection
|
|
228
241
|
return selectFullTable(editorSelectionAPI)({
|
package/dist/esm/plugin.js
CHANGED
|
@@ -355,7 +355,8 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
355
355
|
canDrag: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.canDrag,
|
|
356
356
|
getEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
357
357
|
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
358
|
-
stickyHeaders: stickyHeader
|
|
358
|
+
stickyHeaders: stickyHeader,
|
|
359
|
+
pluginConfig: pluginConfig
|
|
359
360
|
}), allowControls && !isDragAndDropEnabled && !isResizing && /*#__PURE__*/React.createElement(FloatingDeleteButton, {
|
|
360
361
|
editorView: editorView,
|
|
361
362
|
selection: editorView.state.selection,
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
|
-
import { addColumnAfter, addColumnBefore, addRowAfter, addRowBefore, backspace, bindKeymapWithCommand, deleteColumn, deleteRow, moveColumnLeft, moveColumnRight, moveRowDown, moveRowUp, nextCell, previousCell, toggleTable } from '@atlaskit/editor-common/keymaps';
|
|
2
|
+
import { addColumnAfter, addColumnBefore, addRowAfter, addRowBefore, backspace, bindKeymapWithCommand, decreaseMediaSize, deleteColumn, deleteRow, increaseMediaSize, moveColumnLeft, moveColumnRight, moveLeft, moveRight, moveRowDown, moveRowUp, nextCell, previousCell, startColumnResizing, toggleTable } from '@atlaskit/editor-common/keymaps';
|
|
3
3
|
import { chainCommands } from '@atlaskit/editor-prosemirror/commands';
|
|
4
4
|
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
5
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
5
6
|
import { createTable, goToNextCell, moveCursorBackward, triggerUnlessTableHeader } from '../commands';
|
|
6
7
|
import { addRowAroundSelection, deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut, deleteTableIfSelectedWithAnalytics, emptyMultipleCellsWithAnalytics } from '../commands-with-analytics';
|
|
8
|
+
import { activateNextResizeArea, changeColumnWidthByStep, initiateKeyboardColumnResizing } from '../commands/column-resize';
|
|
7
9
|
import { addColumnAfter as addColumnAfterCommand, addColumnBefore as addColumnBeforeCommand } from '../commands/insert';
|
|
8
10
|
import { moveSourceWithAnalyticsViaShortcut } from '../pm-plugins/drag-and-drop/commands-with-analytics';
|
|
9
11
|
import { withEditorAnalyticsAPI } from '../utils/analytics';
|
|
@@ -42,6 +44,13 @@ export function keymapPlugin(getEditorContainerWidth, editorAnalyticsAPI, dragAn
|
|
|
42
44
|
bindKeymapWithCommand(deleteColumn.common, deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut(editorAnalyticsAPI), list);
|
|
43
45
|
bindKeymapWithCommand(deleteRow.common, deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut(editorAnalyticsAPI), list);
|
|
44
46
|
}
|
|
47
|
+
if (getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
|
|
48
|
+
bindKeymapWithCommand(startColumnResizing.common, initiateKeyboardColumnResizing, list);
|
|
49
|
+
bindKeymapWithCommand(moveRight.common, activateNextResizeArea(1), list);
|
|
50
|
+
bindKeymapWithCommand(moveLeft.common, activateNextResizeArea(-1), list);
|
|
51
|
+
bindKeymapWithCommand(decreaseMediaSize.common, changeColumnWidthByStep(-10, getEditorContainerWidth), list);
|
|
52
|
+
bindKeymapWithCommand(increaseMediaSize.common, changeColumnWidthByStep(10, getEditorContainerWidth), list);
|
|
53
|
+
}
|
|
45
54
|
return keymap(list);
|
|
46
55
|
}
|
|
47
56
|
export default keymapPlugin;
|
|
@@ -11,7 +11,7 @@ import { getSelectedColumnIndexes } from '../../utils';
|
|
|
11
11
|
import { META_KEYS } from '../table-analytics';
|
|
12
12
|
import { evenColumns, setDragging, stopResizing } from './commands';
|
|
13
13
|
import { getPluginState } from './plugin-factory';
|
|
14
|
-
import { currentColWidth, getLayoutSize, getResizeState, pointsAtCell, resizeColumn, updateControls } from './utils';
|
|
14
|
+
import { currentColWidth, getLayoutSize, getResizeState, getTableMaxWidth, pointsAtCell, resizeColumn, updateControls } from './utils';
|
|
15
15
|
export var handleMouseDown = function handleMouseDown(view, event, localResizeHandlePos, getEditorContainerWidth, getEditorFeatureFlags, editorAnalyticsAPI) {
|
|
16
16
|
var state = view.state,
|
|
17
17
|
dispatch = view.dispatch;
|
|
@@ -35,13 +35,24 @@ export var handleMouseDown = function handleMouseDown(view, event, localResizeHa
|
|
|
35
35
|
if (dom && dom.nodeName !== 'TABLE') {
|
|
36
36
|
dom = dom.closest('table');
|
|
37
37
|
}
|
|
38
|
-
var
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
38
|
+
var maxSize;
|
|
39
|
+
if (!getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
|
|
40
|
+
var containerWidth = getEditorContainerWidth();
|
|
41
|
+
var parentWidth = getParentNodeWidth(start, state, containerWidth);
|
|
42
|
+
maxSize = getBooleanFF('platform.editor.custom-table-width') ? parentWidth ||
|
|
43
|
+
// its safe to reference table width from node as this will not have changed
|
|
44
|
+
originalTable.attrs.width || getLayoutSize(dom.getAttribute('data-layout'), containerWidth.width, {}) : parentWidth || getLayoutSize(dom.getAttribute('data-layout'), containerWidth.width, {});
|
|
45
|
+
if (originalTable.attrs.isNumberColumnEnabled) {
|
|
46
|
+
maxSize -= akEditorTableNumberColumnWidth;
|
|
47
|
+
}
|
|
48
|
+
} else {
|
|
49
|
+
maxSize = getTableMaxWidth({
|
|
50
|
+
table: originalTable,
|
|
51
|
+
tableStart: start,
|
|
52
|
+
state: state,
|
|
53
|
+
layout: originalTable.attrs.layout,
|
|
54
|
+
getEditorContainerWidth: getEditorContainerWidth
|
|
55
|
+
});
|
|
45
56
|
}
|
|
46
57
|
var resizeState = getResizeState({
|
|
47
58
|
minWidth: tableCellMinWidth,
|
|
@@ -3,7 +3,7 @@ export { contentWidth } from './content-width';
|
|
|
3
3
|
export { getColumnStateFromDOM, getFreeSpace, getCellsRefsInColumn, calculateColumnWidth, addContainerLeftRightPadding } from './column-state';
|
|
4
4
|
export { growColumn, shrinkColumn, reduceSpace } from './resize-logic';
|
|
5
5
|
export { getResizeState, updateColgroup, getTotalWidth, evenAllColumnsWidths, bulkColumnsResize, areColumnsEven, adjustColumnsWidths } from './resize-state';
|
|
6
|
-
export { getLayoutSize, getDefaultLayoutMaxWidth, pointsAtCell, currentColWidth, domCellAround } from './misc';
|
|
6
|
+
export { getLayoutSize, getDefaultLayoutMaxWidth, pointsAtCell, currentColWidth, domCellAround, getTableMaxWidth } from './misc';
|
|
7
7
|
export { updateControls, isClickNear, getResizeCellPos } from './dom';
|
|
8
8
|
export { scale, scaleWithParent, scaleTable, previewScaleTable } from './scale-table';
|
|
9
9
|
export { resizeColumn } from './resize-column';
|
package/dist/esm/types.js
CHANGED
|
@@ -99,6 +99,8 @@ export var TableCssClassName = _objectSpread(_objectSpread({}, TableSharedCssCla
|
|
|
99
99
|
DRAG_HANDLE_DISABLED: "".concat(tablePrefixSelector, "-drag-handle-disabled"),
|
|
100
100
|
/** minimised handle class */
|
|
101
101
|
DRAG_HANDLE_MINIMISED: "".concat(tablePrefixSelector, "-drag-handle-minimised"),
|
|
102
|
+
DRAG_SUBMENU: "".concat(tablePrefixSelector, "-drag-submenu"),
|
|
103
|
+
DRAG_SUBMENU_ICON: "".concat(tablePrefixSelector, "-drag-submenu-icon"),
|
|
102
104
|
/** Other classes */
|
|
103
105
|
NUMBERED_COLUMN: "".concat(tablePrefixSelector, "-numbered-column"),
|
|
104
106
|
NUMBERED_COLUMN_BUTTON: "".concat(tablePrefixSelector, "-numbered-column__button"),
|
|
@@ -1,16 +1,31 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
1
2
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
3
|
+
/* eslint-disable @atlaskit/design-system/prefer-primitives */
|
|
2
4
|
/** @jsx jsx */
|
|
5
|
+
import { useState } from 'react';
|
|
3
6
|
import { jsx } from '@emotion/react';
|
|
7
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
8
|
+
import { DropdownMenuSharedCssClassName } from '@atlaskit/editor-common/styles';
|
|
9
|
+
import { backgroundPaletteTooltipMessages, cellBackgroundColorPalette, ColorPalette } from '@atlaskit/editor-common/ui-color';
|
|
4
10
|
import { ArrowKeyNavigationType, DropdownMenu } from '@atlaskit/editor-common/ui-menu';
|
|
11
|
+
import { closestElement } from '@atlaskit/editor-common/utils';
|
|
12
|
+
import { hexToEditorBackgroundPaletteColor } from '@atlaskit/editor-palette';
|
|
5
13
|
import { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
|
|
6
14
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
7
15
|
import { findCellRectClosestToPos, getSelectionRect, isSelectionType } from '@atlaskit/editor-tables/utils';
|
|
16
|
+
import EditorBackgroundColorIcon from '@atlaskit/icon/glyph/editor/background-color';
|
|
17
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
18
|
+
import Toggle from '@atlaskit/toggle';
|
|
8
19
|
import { clearHoverSelection, hoverColumns, hoverRows } from '../../commands';
|
|
20
|
+
import { setColorWithAnalytics, toggleHeaderColumnWithAnalytics, toggleHeaderRowWithAnalytics, toggleNumberColumnWithAnalytics } from '../../commands-with-analytics';
|
|
9
21
|
import { toggleDragMenu } from '../../pm-plugins/drag-and-drop/commands';
|
|
10
22
|
import { getPluginState } from '../../pm-plugins/drag-and-drop/plugin-factory';
|
|
11
|
-
import {
|
|
23
|
+
import { getPluginState as getTablePluginState } from '../../pm-plugins/plugin-factory';
|
|
24
|
+
import { TableCssClassName as ClassName } from '../../types';
|
|
25
|
+
import { checkIfHeaderColumnEnabled, checkIfHeaderRowEnabled, checkIfNumberColumnEnabled, getMergedCellsPositions, getSelectedColumnIndexes, getSelectedRowIndexes, hasMergedCellsInColumn, hasMergedCellsInRow } from '../../utils';
|
|
12
26
|
import { getDragMenuConfig } from '../../utils/drag-menu';
|
|
13
27
|
import { dragMenuDropdownWidth } from '../consts';
|
|
28
|
+
import { cellColourPreviewStyles, dragMenuBackgroundColorStyles, toggleStyles } from './styles';
|
|
14
29
|
var groupedDragMenuConfig = [['add_row_above', 'add_row_below', 'add_column_left', 'add_column_right', 'distribute_columns', 'clear_cells', 'delete_row', 'delete_column'], ['move_column_left', 'move_column_right', 'move_row_up', 'move_row_down'], ['sort_column_asc', 'sort_column_desc']];
|
|
15
30
|
var convertToDropdownItems = function convertToDropdownItems(dragMenuConfig) {
|
|
16
31
|
var menuItemsArr = _toConsumableArray(Array(groupedDragMenuConfig.length)).map(function () {
|
|
@@ -33,7 +48,6 @@ var convertToDropdownItems = function convertToDropdownItems(dragMenuConfig) {
|
|
|
33
48
|
isDisabled: item.disabled,
|
|
34
49
|
elemBefore: item.icon ? jsx("div", {
|
|
35
50
|
style: {
|
|
36
|
-
marginRight: "var(--ds-space-negative-075, -6px)",
|
|
37
51
|
display: 'flex'
|
|
38
52
|
}
|
|
39
53
|
}, jsx(item.icon, {
|
|
@@ -57,6 +71,7 @@ var convertToDropdownItems = function convertToDropdownItems(dragMenuConfig) {
|
|
|
57
71
|
};
|
|
58
72
|
};
|
|
59
73
|
export var DragMenu = function DragMenu(_ref) {
|
|
74
|
+
var _pluginConfig$allowBa;
|
|
60
75
|
var _ref$direction = _ref.direction,
|
|
61
76
|
direction = _ref$direction === void 0 ? 'row' : _ref$direction,
|
|
62
77
|
index = _ref.index,
|
|
@@ -69,23 +84,136 @@ export var DragMenu = function DragMenu(_ref) {
|
|
|
69
84
|
targetCellPosition = _ref.targetCellPosition,
|
|
70
85
|
getEditorContainerWidth = _ref.getEditorContainerWidth,
|
|
71
86
|
canDrag = _ref.canDrag,
|
|
72
|
-
editorAnalyticsAPI = _ref.editorAnalyticsAPI
|
|
73
|
-
|
|
87
|
+
editorAnalyticsAPI = _ref.editorAnalyticsAPI,
|
|
88
|
+
pluginConfig = _ref.pluginConfig;
|
|
74
89
|
var state = editorView.state,
|
|
75
90
|
dispatch = editorView.dispatch;
|
|
76
91
|
var selection = state.selection;
|
|
92
|
+
var tableMap = tableNode ? TableMap.get(tableNode) : undefined;
|
|
93
|
+
var _useState = useState(false),
|
|
94
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
95
|
+
isSubmenuOpen = _useState2[0],
|
|
96
|
+
setIsSubmenuOpen = _useState2[1];
|
|
77
97
|
var selectionRect = isSelectionType(selection, 'cell') ? getSelectionRect(selection) : findCellRectClosestToPos(selection.$from);
|
|
78
98
|
var hasMergedCells = direction === 'row' ? hasMergedCellsInRow : hasMergedCellsInColumn;
|
|
79
99
|
var shouldMoveDisabled = index !== undefined && hasMergedCells(index)(selection);
|
|
80
100
|
var hasMergedCellsInTable = getMergedCellsPositions(state.tr).length > 0;
|
|
101
|
+
var allowBackgroundColor = (_pluginConfig$allowBa = pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.allowBackgroundColor) !== null && _pluginConfig$allowBa !== void 0 ? _pluginConfig$allowBa : false;
|
|
81
102
|
var dragMenuConfig = getDragMenuConfig(direction, getEditorContainerWidth, !!canDrag && !shouldMoveDisabled, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI);
|
|
82
103
|
var _convertToDropdownIte = convertToDropdownItems(dragMenuConfig),
|
|
83
104
|
menuItems = _convertToDropdownIte.menuItems,
|
|
84
105
|
menuCallback = _convertToDropdownIte.menuCallback;
|
|
106
|
+
var handleSubMenuRef = function handleSubMenuRef(ref) {
|
|
107
|
+
var parent = closestElement(editorView.dom, '.fabric-editor-popup-scroll-parent');
|
|
108
|
+
if (!(parent && ref)) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
var boundariesRect = parent.getBoundingClientRect();
|
|
112
|
+
var rect = ref.getBoundingClientRect();
|
|
113
|
+
if (rect.left + rect.width > boundariesRect.width) {
|
|
114
|
+
ref.style.left = "-".concat(rect.width, "px");
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
var setColor = function setColor(color) {
|
|
118
|
+
var _getTablePluginState = getTablePluginState(editorView.state),
|
|
119
|
+
targetCellPosition = _getTablePluginState.targetCellPosition;
|
|
120
|
+
var state = editorView.state,
|
|
121
|
+
dispatch = editorView.dispatch;
|
|
122
|
+
setColorWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.CONTEXT_MENU, color, targetCellPosition)(state, dispatch);
|
|
123
|
+
closeMenu();
|
|
124
|
+
setIsSubmenuOpen(false);
|
|
125
|
+
};
|
|
126
|
+
var createBackgroundColorMenuItem = function createBackgroundColorMenuItem() {
|
|
127
|
+
var _node$attrs;
|
|
128
|
+
var _getTablePluginState2 = getTablePluginState(editorView.state),
|
|
129
|
+
targetCellPosition = _getTablePluginState2.targetCellPosition;
|
|
130
|
+
var node = targetCellPosition ? state.doc.nodeAt(targetCellPosition) : null;
|
|
131
|
+
var background = hexToEditorBackgroundPaletteColor((node === null || node === void 0 || (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.background) || '#ffffff');
|
|
132
|
+
return {
|
|
133
|
+
content: 'Background color',
|
|
134
|
+
value: {
|
|
135
|
+
name: 'background'
|
|
136
|
+
},
|
|
137
|
+
elemBefore: jsx(EditorBackgroundColorIcon, {
|
|
138
|
+
label: 'background color',
|
|
139
|
+
size: "medium"
|
|
140
|
+
}),
|
|
141
|
+
elemAfter: jsx("div", {
|
|
142
|
+
className: DropdownMenuSharedCssClassName.SUBMENU,
|
|
143
|
+
css: dragMenuBackgroundColorStyles
|
|
144
|
+
}, jsx("div", {
|
|
145
|
+
css: cellColourPreviewStyles(background),
|
|
146
|
+
className: ClassName.DRAG_SUBMENU_ICON
|
|
147
|
+
}), isSubmenuOpen && jsx("div", {
|
|
148
|
+
className: ClassName.DRAG_SUBMENU,
|
|
149
|
+
ref: handleSubMenuRef
|
|
150
|
+
}, jsx(ColorPalette, {
|
|
151
|
+
cols: 7,
|
|
152
|
+
onClick: setColor,
|
|
153
|
+
selectedColor: background,
|
|
154
|
+
paletteOptions: {
|
|
155
|
+
palette: cellBackgroundColorPalette,
|
|
156
|
+
paletteColorTooltipMessages: backgroundPaletteTooltipMessages,
|
|
157
|
+
hexToPaletteColor: hexToEditorBackgroundPaletteColor
|
|
158
|
+
}
|
|
159
|
+
})))
|
|
160
|
+
};
|
|
161
|
+
};
|
|
162
|
+
var toggleHeaderColumn = function toggleHeaderColumn() {
|
|
163
|
+
toggleHeaderColumnWithAnalytics(editorAnalyticsAPI)(state, dispatch);
|
|
164
|
+
};
|
|
165
|
+
var toggleHeaderRow = function toggleHeaderRow() {
|
|
166
|
+
toggleHeaderRowWithAnalytics(editorAnalyticsAPI)(state, dispatch);
|
|
167
|
+
};
|
|
168
|
+
var toggleRowNumbers = function toggleRowNumbers() {
|
|
169
|
+
toggleNumberColumnWithAnalytics(editorAnalyticsAPI)(state, dispatch);
|
|
170
|
+
};
|
|
171
|
+
var createhHeaderRowColumnMenuItem = function createhHeaderRowColumnMenuItem(direction) {
|
|
172
|
+
return direction === 'column' ? {
|
|
173
|
+
content: 'Header column',
|
|
174
|
+
value: {
|
|
175
|
+
name: 'header_column'
|
|
176
|
+
},
|
|
177
|
+
elemAfter: jsx("div", {
|
|
178
|
+
css: toggleStyles
|
|
179
|
+
}, jsx(Toggle, {
|
|
180
|
+
id: "toggle-header-column",
|
|
181
|
+
onChange: toggleHeaderColumn,
|
|
182
|
+
isChecked: checkIfHeaderColumnEnabled(selection)
|
|
183
|
+
}))
|
|
184
|
+
} : {
|
|
185
|
+
content: 'Header row',
|
|
186
|
+
value: {
|
|
187
|
+
name: 'header_row'
|
|
188
|
+
},
|
|
189
|
+
elemAfter: jsx("div", {
|
|
190
|
+
css: toggleStyles
|
|
191
|
+
}, jsx(Toggle, {
|
|
192
|
+
id: "toggle-header-row",
|
|
193
|
+
onChange: toggleHeaderRow,
|
|
194
|
+
isChecked: checkIfHeaderRowEnabled(selection)
|
|
195
|
+
}))
|
|
196
|
+
};
|
|
197
|
+
};
|
|
198
|
+
var createRowNumbersMenuItem = function createRowNumbersMenuItem() {
|
|
199
|
+
return {
|
|
200
|
+
content: 'Row numbers',
|
|
201
|
+
value: {
|
|
202
|
+
name: 'row_numbers'
|
|
203
|
+
},
|
|
204
|
+
elemAfter: jsx("div", {
|
|
205
|
+
css: toggleStyles
|
|
206
|
+
}, jsx(Toggle, {
|
|
207
|
+
id: "toggle-row-numbers",
|
|
208
|
+
onChange: toggleRowNumbers,
|
|
209
|
+
isChecked: checkIfNumberColumnEnabled(selection)
|
|
210
|
+
}))
|
|
211
|
+
};
|
|
212
|
+
};
|
|
85
213
|
|
|
86
214
|
/**
|
|
87
215
|
* This function is to check if the menu should be closed or not.
|
|
88
|
-
* As when continously clicking on
|
|
216
|
+
* As when continously clicking on tyle handle on different rows/columns,
|
|
89
217
|
* should open the menu corresponding to the position of the drag handle.
|
|
90
218
|
* @returns true when the menu should be closed, false otherwise
|
|
91
219
|
*/
|
|
@@ -115,18 +243,42 @@ export var DragMenu = function DragMenu(_ref) {
|
|
|
115
243
|
var _menuCallback$item$va;
|
|
116
244
|
var item = _ref2.item;
|
|
117
245
|
(_menuCallback$item$va = menuCallback[item.value.name]) === null || _menuCallback$item$va === void 0 || _menuCallback$item$va.call(menuCallback, state, dispatch);
|
|
118
|
-
|
|
246
|
+
switch (item.value.name) {
|
|
247
|
+
case 'header_column':
|
|
248
|
+
toggleHeaderColumn();
|
|
249
|
+
break;
|
|
250
|
+
case 'header_row':
|
|
251
|
+
toggleHeaderRow();
|
|
252
|
+
break;
|
|
253
|
+
case 'row_numbers':
|
|
254
|
+
toggleRowNumbers();
|
|
255
|
+
break;
|
|
256
|
+
default:
|
|
257
|
+
break;
|
|
258
|
+
}
|
|
259
|
+
if (['header_column', 'header_row', 'row_numbers', 'background'].indexOf(item.value.name) <= -1) {
|
|
260
|
+
closeMenu();
|
|
261
|
+
}
|
|
119
262
|
};
|
|
120
263
|
var handleItemMouseEnter = function handleItemMouseEnter(_ref3) {
|
|
121
264
|
var _item$value$name;
|
|
122
265
|
var item = _ref3.item;
|
|
123
|
-
if (!selectionRect
|
|
266
|
+
if (!selectionRect) {
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
if (item.value.name === 'background' && !isSubmenuOpen) {
|
|
270
|
+
setIsSubmenuOpen(true);
|
|
271
|
+
}
|
|
272
|
+
if (!((_item$value$name = item.value.name) !== null && _item$value$name !== void 0 && _item$value$name.startsWith('delete'))) {
|
|
124
273
|
return;
|
|
125
274
|
}
|
|
126
275
|
(item.value.name === 'delete_column' ? hoverColumns(getSelectedColumnIndexes(selectionRect), true) : hoverRows(getSelectedRowIndexes(selectionRect), true))(state, dispatch);
|
|
127
276
|
};
|
|
128
277
|
var handleItemMouseLeave = function handleItemMouseLeave(_ref4) {
|
|
129
278
|
var item = _ref4.item;
|
|
279
|
+
if (item.value.name === 'background' && isSubmenuOpen) {
|
|
280
|
+
setIsSubmenuOpen(false);
|
|
281
|
+
}
|
|
130
282
|
if (['sort_column_asc', 'sort_column_desc', 'delete_column', 'delete_row'].indexOf(item.value.name) > -1) {
|
|
131
283
|
clearHoverSelection()(state, dispatch);
|
|
132
284
|
}
|
|
@@ -134,6 +286,24 @@ export var DragMenu = function DragMenu(_ref) {
|
|
|
134
286
|
if (!menuItems) {
|
|
135
287
|
return null;
|
|
136
288
|
}
|
|
289
|
+
if (allowBackgroundColor && getBooleanFF('platform.editor.table.new-cell-context-menu-styling')) {
|
|
290
|
+
menuItems[0].items.unshift(createBackgroundColorMenuItem());
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// If first row, add toggle for Hearder row, default is true
|
|
294
|
+
// If first column, add toggle for Header column, default is false
|
|
295
|
+
if (getBooleanFF('platform.editor.table.new-cell-context-menu-styling') && index === 0) {
|
|
296
|
+
menuItems.push({
|
|
297
|
+
items: [createhHeaderRowColumnMenuItem(direction)]
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
// All rows, add toggle for numbered rows, default is false
|
|
302
|
+
if (getBooleanFF('platform.editor.table.new-cell-context-menu-styling') && direction === 'row') {
|
|
303
|
+
index === 0 ? menuItems[menuItems.length - 1].items.push(createRowNumbersMenuItem()) : menuItems.push({
|
|
304
|
+
items: [createRowNumbersMenuItem()]
|
|
305
|
+
});
|
|
306
|
+
}
|
|
137
307
|
return jsx(DropdownMenu, {
|
|
138
308
|
mountTo: mountPoint
|
|
139
309
|
//This needs be removed when the a11y is completely handled
|