@atlaskit/editor-plugin-table 5.7.10 → 5.8.1
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 +17 -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 +7 -3
- 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,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.toggleStyles = exports.dragMenuBackgroundColorStyles = exports.cellColourPreviewStyles = void 0;
|
|
8
|
+
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
9
|
+
var _react = require("@emotion/react");
|
|
10
|
+
var _adfSchema = require("@atlaskit/adf-schema");
|
|
11
|
+
var _colors = require("@atlaskit/theme/colors");
|
|
12
|
+
var _types = require("../../types");
|
|
13
|
+
var _consts = require("../consts");
|
|
14
|
+
var _templateObject, _templateObject2, _templateObject3;
|
|
15
|
+
var cellColourPreviewStyles = exports.cellColourPreviewStyles = function cellColourPreviewStyles(selectedColor) {
|
|
16
|
+
return (0, _react.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n &::before {\n background: ", ";\n }\n"])), selectedColor);
|
|
17
|
+
};
|
|
18
|
+
var dragMenuBackgroundColorStyles = exports.dragMenuBackgroundColorStyles = (0, _react.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n .", " {\n border-radius: ", ";\n background: ", ";\n box-shadow: ", ";\n display: block;\n position: absolute;\n top: 0;\n left: ", "px;\n padding: ", ";\n\n > div {\n padding: 0;\n }\n }\n\n .", " {\n display: flex;\n\n &::before {\n content: '';\n display: block;\n border: 1px solid ", ";\n border-radius: ", ";\n width: 14px;\n height: 14px;\n }\n\n &::after {\n content: '\u203A';\n margin-left: ", ";\n line-height: 14px;\n color: ", ";\n }\n }\n"])), _types.TableCssClassName.DRAG_SUBMENU, "var(--ds-border-radius, 3px)", "var(--ds-surface-overlay, white)", "var(--ds-shadow-overlay, ".concat("0 4px 8px -2px ".concat(_colors.N60A, ", 0 0 1px ").concat(_colors.N60A), ")"), _consts.dragMenuDropdownWidth, "var(--ds-space-100, 8px)", _types.TableCssClassName.DRAG_SUBMENU_ICON, _adfSchema.tableBackgroundBorderColor, "var(--ds-border-radius, 3px)", "var(--ds-space-050, 4px)", "var(--ds-icon, ".concat(_colors.N90, ")"));
|
|
19
|
+
var toggleStyles = exports.toggleStyles = (0, _react.css)(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n input[type='checkbox'] {\n width: 30px;\n height: 14px;\n pointer-events: initial;\n cursor: pointer;\n }\n > label {\n margin: 0px;\n pointer-events: none;\n > span {\n pointer-events: none;\n }\n }\n"])));
|
package/dist/cjs/ui/consts.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.tableToolbarSize = exports.tableToolbarSelectedColor = exports.tableToolbarDeleteColor = exports.tableToolbarColor = exports.tableTextColor = exports.tableScrollbarOffset = exports.tablePadding = exports.tableOverflowShadowWidthWide = exports.tableOverflowShadowWidth = exports.tableMarginFullWidthMode = exports.tableInsertColumnButtonSize = exports.tableInsertColumnButtonOffset = exports.tableHeaderCellBackgroundColor = exports.tableFloatingControlsColor = exports.tableDeleteButtonSize = exports.tableDeleteButtonOffset = exports.tableControlsSpacing = exports.tableCellSelectedDeleteIconColor = exports.tableCellSelectedDeleteIconBackground = exports.tableCellSelectedColor = exports.tableCellHoverDeleteIconColor = exports.tableCellHoverDeleteIconBackground = exports.tableCellDeleteColor = exports.tableCellBackgroundColor = exports.tableBorderSelectedColor = exports.tableBorderRadiusSize = exports.tableBorderDeleteColor = exports.tableBorderColor = exports.stickyRowZIndex = exports.stickyRowOffsetTop = exports.stickyHeaderBorderBottomWidth = exports.rowControlsZIndex = exports.resizeLineWidth = exports.resizeHandlerZIndex = exports.resizeHandlerAreaWidth = exports.lineMarkerSize = exports.lineMarkerOffsetFromColumnControls = exports.layoutButtonSize = exports.insertLineWidth = exports.dropTargetsZIndex = exports.dropTargetExtendedWidth = exports.dragTableInsertColumnButtonSize = exports.dragMenuDropdownWidth = exports.contextualMenuTriggerSize = exports.contextualMenuDropdownWidth = exports.columnResizeHandleZIndex = exports.columnControlsZIndex = exports.columnControlsSelectedZIndex = exports.columnControlsDecorationHeight = exports.TABLE_SNAP_GAP = exports.TABLE_HIGHLIGHT_TOLERANCE = exports.TABLE_HIGHLIGHT_GAP = exports.TABLE_GUIDELINE_VISIBLE_ADJUSTMENT = exports.STICKY_HEADER_TOGGLE_TOLERANCE_MS = void 0;
|
|
7
7
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
8
8
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
9
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
9
10
|
var _colors = require("@atlaskit/theme/colors");
|
|
10
11
|
var _types = require("../types");
|
|
11
12
|
/**
|
|
@@ -54,7 +55,7 @@ var resizeHandlerAreaWidth = exports.resizeHandlerAreaWidth = _types.RESIZE_HAND
|
|
|
54
55
|
var resizeLineWidth = exports.resizeLineWidth = 2;
|
|
55
56
|
var resizeHandlerZIndex = exports.resizeHandlerZIndex = columnControlsZIndex + _editorSharedStyles.akRichMediaResizeZIndex;
|
|
56
57
|
var contextualMenuTriggerSize = exports.contextualMenuTriggerSize = 16;
|
|
57
|
-
var contextualMenuDropdownWidth = exports.contextualMenuDropdownWidth = 180;
|
|
58
|
+
var contextualMenuDropdownWidth = exports.contextualMenuDropdownWidth = (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.drag-and-drop') ? 250 : 180;
|
|
58
59
|
var stickyRowZIndex = exports.stickyRowZIndex = resizeHandlerZIndex + 2;
|
|
59
60
|
var stickyRowOffsetTop = exports.stickyRowOffsetTop = 8;
|
|
60
61
|
var stickyHeaderBorderBottomWidth = exports.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
|
+
const updateResizeHandleAndStatePosition = (rowIndex, columnIndex, nextResizeHandlePos) => (state, dispatch) => {
|
|
11
|
+
addResizeHandleDecorations(rowIndex, columnIndex, true)(state, dispatch);
|
|
12
|
+
// Currently only 'right' position is used in showResizeHandleLine
|
|
13
|
+
showResizeHandleLine({
|
|
14
|
+
left: 0,
|
|
15
|
+
right: columnIndex
|
|
16
|
+
})(state, dispatch);
|
|
17
|
+
tableResizingPluginCreateCommand({
|
|
18
|
+
type: 'SET_RESIZE_HANDLE_POSITION',
|
|
19
|
+
data: {
|
|
20
|
+
resizeHandlePos: nextResizeHandlePos
|
|
21
|
+
}
|
|
22
|
+
})(state, dispatch);
|
|
23
|
+
return false;
|
|
24
|
+
};
|
|
25
|
+
export const initiateKeyboardColumnResizing = (state, dispatch, view) => {
|
|
26
|
+
if (!getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
const {
|
|
30
|
+
selection
|
|
31
|
+
} = state;
|
|
32
|
+
const selectionRect = isSelectionType(selection, 'cell') ? getSelectionRect(selection) : findCellRectClosestToPos(selection.$from);
|
|
33
|
+
const cell = findCellClosestToPos(selection.$from);
|
|
34
|
+
if (selectionRect && cell && view) {
|
|
35
|
+
const cellAttrs = cell.node.attrs;
|
|
36
|
+
const 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 const activateNextResizeArea = direction => (state, dispatch) => {
|
|
52
|
+
if (!getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
const {
|
|
56
|
+
resizeHandlePos,
|
|
57
|
+
dragging
|
|
58
|
+
} = getTableResizingPluginState(state) || {};
|
|
59
|
+
// If No resizing has initiated, skip to regular handler
|
|
60
|
+
if (!resizeHandlePos || !dragging) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
const {
|
|
64
|
+
selection
|
|
65
|
+
} = state;
|
|
66
|
+
const cell = findCellClosestToPos(selection.$from);
|
|
67
|
+
if (!cell) {
|
|
68
|
+
// cursor position may be changed by mouse to be outside of table;
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
const $currentCell = state.doc.resolve(resizeHandlePos);
|
|
72
|
+
if (!$currentCell) {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
const tableNode = $currentCell.node(-1);
|
|
76
|
+
const closestTable = findTableClosestToPos($currentCell);
|
|
77
|
+
const tableMap = TableMap.get(tableNode);
|
|
78
|
+
if (!tableNode || !closestTable || !tableMap) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
const currentCellRect = tableMap.findCell($currentCell.pos - $currentCell.start(-1));
|
|
82
|
+
const $nextCell = nextCell($currentCell, 'horiz', direction);
|
|
83
|
+
if ($nextCell) {
|
|
84
|
+
// we are somewhere in between the side columns of the table
|
|
85
|
+
const offset = $nextCell.pos - $nextCell.start(-1);
|
|
86
|
+
const rectForNextCell = tableMap.findCell(offset);
|
|
87
|
+
updateResizeHandleAndStatePosition(rectForNextCell.top, rectForNextCell.right, $nextCell.pos)(state, dispatch);
|
|
88
|
+
} else {
|
|
89
|
+
// current position is in the one of the side columns of the table(left or right)
|
|
90
|
+
if (currentCellRect.left === 0) {
|
|
91
|
+
const lastCellInCurrentRow = tableMap.positionAt(currentCellRect.top, tableMap.width - 1, tableNode) + closestTable.start;
|
|
92
|
+
const $lastCell = state.doc.resolve(lastCellInCurrentRow);
|
|
93
|
+
updateResizeHandleAndStatePosition(currentCellRect.top, tableMap.width, $lastCell.pos)(state, dispatch);
|
|
94
|
+
} else if (tableMap.width === currentCellRect.right) {
|
|
95
|
+
const firsCellInCurrentRow = tableMap.positionAt(currentCellRect.top, 0, tableNode) + closestTable.start;
|
|
96
|
+
const $nextCell = state.doc.resolve(firsCellInCurrentRow);
|
|
97
|
+
updateResizeHandleAndStatePosition(currentCellRect.top, 1, $nextCell.pos)(state, dispatch);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return true;
|
|
101
|
+
};
|
|
102
|
+
export const changeColumnWidthByStep = (stepSize, getEditorContainerWidth) => (state, dispatch, view) => {
|
|
103
|
+
if (!getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
const {
|
|
107
|
+
resizeHandlePos,
|
|
108
|
+
dragging
|
|
109
|
+
} = getTableResizingPluginState(state);
|
|
110
|
+
if (!view || !resizeHandlePos || !dragging) {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
const $cell = state.doc.resolve(resizeHandlePos);
|
|
114
|
+
const tableStartPosition = $cell.start(-1);
|
|
115
|
+
const originalTable = $cell.node(-1);
|
|
116
|
+
const map = TableMap.get(originalTable);
|
|
117
|
+
const domAtPos = view.domAtPos.bind(view);
|
|
118
|
+
const colIndex = map.colCount($cell.pos - tableStartPosition) + ($cell.nodeAfter ? $cell.nodeAfter.attrs.colspan : 1) - 1;
|
|
119
|
+
let dom = domAtPos(tableStartPosition).node;
|
|
120
|
+
if (dom && dom.nodeName !== 'TABLE') {
|
|
121
|
+
dom = dom.closest('table');
|
|
122
|
+
}
|
|
123
|
+
const maxSize = getTableMaxWidth({
|
|
124
|
+
table: originalTable,
|
|
125
|
+
tableStart: tableStartPosition,
|
|
126
|
+
state,
|
|
127
|
+
layout: originalTable.attrs.layout,
|
|
128
|
+
getEditorContainerWidth
|
|
129
|
+
});
|
|
130
|
+
const initialResizeState = getResizeState({
|
|
131
|
+
minWidth: tableCellMinWidth,
|
|
132
|
+
maxSize,
|
|
133
|
+
table: originalTable,
|
|
134
|
+
tableRef: dom,
|
|
135
|
+
start: tableStartPosition,
|
|
136
|
+
domAtPos
|
|
137
|
+
});
|
|
138
|
+
updateControls()(state);
|
|
139
|
+
const selectionRect = getSelectionRect(state.selection);
|
|
140
|
+
const selectedColumns = selectionRect ? getSelectedColumnIndexes(selectionRect) : [];
|
|
141
|
+
// only selected (or selected - 1) columns should be distributed
|
|
142
|
+
const resizingSelectedColumns = selectedColumns.indexOf(colIndex) > -1 || selectedColumns.indexOf(colIndex + 1) > -1;
|
|
143
|
+
const newResizeState = resizeColumn(initialResizeState, colIndex, stepSize, dom, resizingSelectedColumns ? selectedColumns : undefined);
|
|
144
|
+
const tr = updateColumnWidths(newResizeState, originalTable, tableStartPosition)(state.tr);
|
|
145
|
+
if (dispatch) {
|
|
146
|
+
dispatch(tr);
|
|
147
|
+
}
|
|
148
|
+
return true;
|
|
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
|
const TAB_FORWARD_DIRECTION = 1;
|
|
9
12
|
const TAB_BACKWARD_DIRECTION = -1;
|
|
10
13
|
export const goToNextCell = editorAnalyticsAPI => direction => (state, dispatch) => {
|
|
@@ -12,6 +15,16 @@ export const goToNextCell = editorAnalyticsAPI => direction => (state, dispatch)
|
|
|
12
15
|
if (!table) {
|
|
13
16
|
return false;
|
|
14
17
|
}
|
|
18
|
+
if (getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
|
|
19
|
+
var _getResizePluginState;
|
|
20
|
+
const isColumnResizing = !!((_getResizePluginState = getResizePluginState(state)) !== null && _getResizePluginState !== void 0 && _getResizePluginState.dragging);
|
|
21
|
+
if (isColumnResizing) {
|
|
22
|
+
tableResizingPluginCreateCommand({
|
|
23
|
+
type: 'STOP_RESIZING'
|
|
24
|
+
}, originalTr => (state.tr || originalTr).setMeta('scrollIntoView', false))(state, dispatch);
|
|
25
|
+
hideResizeHandleLine()(state, dispatch);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
15
28
|
const map = TableMap.get(table.node);
|
|
16
29
|
const {
|
|
17
30
|
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 let TableSelectionDirection = /*#__PURE__*/function (TableSelectionDirection) {
|
|
9
11
|
TableSelectionDirection["TopToBottom"] = "TopToBottom";
|
|
@@ -175,9 +177,14 @@ const arrowLeftFromText = editorSelectionAPI => selection => (state, dispatch) =
|
|
|
175
177
|
const {
|
|
176
178
|
$from
|
|
177
179
|
} = selection;
|
|
180
|
+
let isColumnResizing = false;
|
|
181
|
+
if (getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
|
|
182
|
+
const columResizePluginState = getResizePluginState(state) || {};
|
|
183
|
+
isColumnResizing = Boolean(columResizePluginState === null || columResizePluginState === void 0 ? void 0 : columResizePluginState.dragging);
|
|
184
|
+
}
|
|
178
185
|
if (isSelectionAtStartOfTable($from, selection) && $from.parent.type.name === 'paragraph' && $from.depth === table.depth + 3 &&
|
|
179
186
|
// + 3 for: row, cell & paragraph nodes
|
|
180
|
-
editorSelectionAPI) {
|
|
187
|
+
editorSelectionAPI && !isColumnResizing) {
|
|
181
188
|
const selectionState = editorSelectionAPI.sharedState.currentState() || {};
|
|
182
189
|
if ((selectionState === null || selectionState === void 0 ? void 0 : selectionState.selectionRelativeToNode) === RelativeSelectionPos.Before) {
|
|
183
190
|
// we have a text selection at start of first table cell, directly inside a top level paragraph,
|
|
@@ -202,8 +209,14 @@ const arrowRightFromText = editorSelectionAPI => selection => (state, dispatch)
|
|
|
202
209
|
const {
|
|
203
210
|
$to
|
|
204
211
|
} = selection;
|
|
205
|
-
|
|
206
|
-
) {
|
|
212
|
+
let isColumnResizing = false;
|
|
213
|
+
if (getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
|
|
214
|
+
const columResizePluginState = getResizePluginState(state) || {};
|
|
215
|
+
isColumnResizing = Boolean(columResizePluginState === null || columResizePluginState === void 0 ? void 0 : columResizePluginState.dragging);
|
|
216
|
+
}
|
|
217
|
+
if (isSelectionAtEndOfTable($to, selection) && $to.parent.type.name === 'paragraph' && $to.depth === table.depth + 3 &&
|
|
218
|
+
// + 3 for: row, cell & paragraph nodes
|
|
219
|
+
!isColumnResizing) {
|
|
207
220
|
// we have a text selection at end of last table cell, directly inside a top level paragraph,
|
|
208
221
|
// and want to set a full table cell selection
|
|
209
222
|
return selectFullTable(editorSelectionAPI)({
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -359,7 +359,8 @@ const tablesPlugin = ({
|
|
|
359
359
|
canDrag: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.canDrag,
|
|
360
360
|
getEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
361
361
|
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
362
|
-
stickyHeaders: stickyHeader
|
|
362
|
+
stickyHeaders: stickyHeader,
|
|
363
|
+
pluginConfig: pluginConfig
|
|
363
364
|
}), allowControls && !isDragAndDropEnabled && !isResizing && /*#__PURE__*/React.createElement(FloatingDeleteButton, {
|
|
364
365
|
editorView: editorView,
|
|
365
366
|
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';
|
|
@@ -40,6 +42,13 @@ export function keymapPlugin(getEditorContainerWidth, editorAnalyticsAPI, dragAn
|
|
|
40
42
|
bindKeymapWithCommand(deleteColumn.common, deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut(editorAnalyticsAPI), list);
|
|
41
43
|
bindKeymapWithCommand(deleteRow.common, deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut(editorAnalyticsAPI), list);
|
|
42
44
|
}
|
|
45
|
+
if (getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
|
|
46
|
+
bindKeymapWithCommand(startColumnResizing.common, initiateKeyboardColumnResizing, list);
|
|
47
|
+
bindKeymapWithCommand(moveRight.common, activateNextResizeArea(1), list);
|
|
48
|
+
bindKeymapWithCommand(moveLeft.common, activateNextResizeArea(-1), list);
|
|
49
|
+
bindKeymapWithCommand(decreaseMediaSize.common, changeColumnWidthByStep(-10, getEditorContainerWidth), list);
|
|
50
|
+
bindKeymapWithCommand(increaseMediaSize.common, changeColumnWidthByStep(10, getEditorContainerWidth), list);
|
|
51
|
+
}
|
|
43
52
|
return keymap(list);
|
|
44
53
|
}
|
|
45
54
|
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 const handleMouseDown = (view, event, localResizeHandlePos, getEditorContainerWidth, getEditorFeatureFlags, editorAnalyticsAPI) => {
|
|
16
16
|
const {
|
|
17
17
|
state,
|
|
@@ -37,13 +37,24 @@ export const handleMouseDown = (view, event, localResizeHandlePos, getEditorCont
|
|
|
37
37
|
if (dom && dom.nodeName !== 'TABLE') {
|
|
38
38
|
dom = dom.closest('table');
|
|
39
39
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
40
|
+
let maxSize;
|
|
41
|
+
if (!getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
|
|
42
|
+
const containerWidth = getEditorContainerWidth();
|
|
43
|
+
const parentWidth = getParentNodeWidth(start, state, containerWidth);
|
|
44
|
+
maxSize = getBooleanFF('platform.editor.custom-table-width') ? parentWidth ||
|
|
45
|
+
// its safe to reference table width from node as this will not have changed
|
|
46
|
+
originalTable.attrs.width || getLayoutSize(dom.getAttribute('data-layout'), containerWidth.width, {}) : parentWidth || getLayoutSize(dom.getAttribute('data-layout'), containerWidth.width, {});
|
|
47
|
+
if (originalTable.attrs.isNumberColumnEnabled) {
|
|
48
|
+
maxSize -= akEditorTableNumberColumnWidth;
|
|
49
|
+
}
|
|
50
|
+
} else {
|
|
51
|
+
maxSize = getTableMaxWidth({
|
|
52
|
+
table: originalTable,
|
|
53
|
+
tableStart: start,
|
|
54
|
+
state,
|
|
55
|
+
layout: originalTable.attrs.layout,
|
|
56
|
+
getEditorContainerWidth
|
|
57
|
+
});
|
|
47
58
|
}
|
|
48
59
|
const resizeState = getResizeState({
|
|
49
60
|
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/es2019/types.js
CHANGED
|
@@ -97,6 +97,8 @@ export const TableCssClassName = {
|
|
|
97
97
|
DRAG_HANDLE_DISABLED: `${tablePrefixSelector}-drag-handle-disabled`,
|
|
98
98
|
/** minimised handle class */
|
|
99
99
|
DRAG_HANDLE_MINIMISED: `${tablePrefixSelector}-drag-handle-minimised`,
|
|
100
|
+
DRAG_SUBMENU: `${tablePrefixSelector}-drag-submenu`,
|
|
101
|
+
DRAG_SUBMENU_ICON: `${tablePrefixSelector}-drag-submenu-icon`,
|
|
100
102
|
/** Other classes */
|
|
101
103
|
NUMBERED_COLUMN: `${tablePrefixSelector}-numbered-column`,
|
|
102
104
|
NUMBERED_COLUMN_BUTTON: `${tablePrefixSelector}-numbered-column__button`,
|
|
@@ -1,15 +1,29 @@
|
|
|
1
|
+
/* eslint-disable @atlaskit/design-system/prefer-primitives */
|
|
1
2
|
/** @jsx jsx */
|
|
3
|
+
import { useState } from 'react';
|
|
2
4
|
import { jsx } from '@emotion/react';
|
|
5
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
6
|
+
import { DropdownMenuSharedCssClassName } from '@atlaskit/editor-common/styles';
|
|
7
|
+
import { backgroundPaletteTooltipMessages, cellBackgroundColorPalette, ColorPalette } from '@atlaskit/editor-common/ui-color';
|
|
3
8
|
import { ArrowKeyNavigationType, DropdownMenu } from '@atlaskit/editor-common/ui-menu';
|
|
9
|
+
import { closestElement } from '@atlaskit/editor-common/utils';
|
|
10
|
+
import { hexToEditorBackgroundPaletteColor } from '@atlaskit/editor-palette';
|
|
4
11
|
import { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
|
|
5
12
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
6
13
|
import { findCellRectClosestToPos, getSelectionRect, isSelectionType } from '@atlaskit/editor-tables/utils';
|
|
14
|
+
import EditorBackgroundColorIcon from '@atlaskit/icon/glyph/editor/background-color';
|
|
15
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
16
|
+
import Toggle from '@atlaskit/toggle';
|
|
7
17
|
import { clearHoverSelection, hoverColumns, hoverRows } from '../../commands';
|
|
18
|
+
import { setColorWithAnalytics, toggleHeaderColumnWithAnalytics, toggleHeaderRowWithAnalytics, toggleNumberColumnWithAnalytics } from '../../commands-with-analytics';
|
|
8
19
|
import { toggleDragMenu } from '../../pm-plugins/drag-and-drop/commands';
|
|
9
20
|
import { getPluginState } from '../../pm-plugins/drag-and-drop/plugin-factory';
|
|
10
|
-
import {
|
|
21
|
+
import { getPluginState as getTablePluginState } from '../../pm-plugins/plugin-factory';
|
|
22
|
+
import { TableCssClassName as ClassName } from '../../types';
|
|
23
|
+
import { checkIfHeaderColumnEnabled, checkIfHeaderRowEnabled, checkIfNumberColumnEnabled, getMergedCellsPositions, getSelectedColumnIndexes, getSelectedRowIndexes, hasMergedCellsInColumn, hasMergedCellsInRow } from '../../utils';
|
|
11
24
|
import { getDragMenuConfig } from '../../utils/drag-menu';
|
|
12
25
|
import { dragMenuDropdownWidth } from '../consts';
|
|
26
|
+
import { cellColourPreviewStyles, dragMenuBackgroundColorStyles, toggleStyles } from './styles';
|
|
13
27
|
const 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']];
|
|
14
28
|
const convertToDropdownItems = dragMenuConfig => {
|
|
15
29
|
let menuItemsArr = [...Array(groupedDragMenuConfig.length)].map(() => []);
|
|
@@ -28,7 +42,6 @@ const convertToDropdownItems = dragMenuConfig => {
|
|
|
28
42
|
isDisabled: item.disabled,
|
|
29
43
|
elemBefore: item.icon ? jsx("div", {
|
|
30
44
|
style: {
|
|
31
|
-
marginRight: "var(--ds-space-negative-075, -6px)",
|
|
32
45
|
display: 'flex'
|
|
33
46
|
}
|
|
34
47
|
}, jsx(item.icon, {
|
|
@@ -63,9 +76,10 @@ export const DragMenu = ({
|
|
|
63
76
|
targetCellPosition,
|
|
64
77
|
getEditorContainerWidth,
|
|
65
78
|
canDrag,
|
|
66
|
-
editorAnalyticsAPI
|
|
79
|
+
editorAnalyticsAPI,
|
|
80
|
+
pluginConfig
|
|
67
81
|
}) => {
|
|
68
|
-
|
|
82
|
+
var _pluginConfig$allowBa;
|
|
69
83
|
const {
|
|
70
84
|
state,
|
|
71
85
|
dispatch
|
|
@@ -73,19 +87,133 @@ export const DragMenu = ({
|
|
|
73
87
|
const {
|
|
74
88
|
selection
|
|
75
89
|
} = state;
|
|
90
|
+
const tableMap = tableNode ? TableMap.get(tableNode) : undefined;
|
|
91
|
+
const [isSubmenuOpen, setIsSubmenuOpen] = useState(false);
|
|
76
92
|
const selectionRect = isSelectionType(selection, 'cell') ? getSelectionRect(selection) : findCellRectClosestToPos(selection.$from);
|
|
77
93
|
const hasMergedCells = direction === 'row' ? hasMergedCellsInRow : hasMergedCellsInColumn;
|
|
78
94
|
const shouldMoveDisabled = index !== undefined && hasMergedCells(index)(selection);
|
|
79
95
|
const hasMergedCellsInTable = getMergedCellsPositions(state.tr).length > 0;
|
|
96
|
+
const allowBackgroundColor = (_pluginConfig$allowBa = pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.allowBackgroundColor) !== null && _pluginConfig$allowBa !== void 0 ? _pluginConfig$allowBa : false;
|
|
80
97
|
const dragMenuConfig = getDragMenuConfig(direction, getEditorContainerWidth, !!canDrag && !shouldMoveDisabled, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI);
|
|
81
98
|
const {
|
|
82
99
|
menuItems,
|
|
83
100
|
menuCallback
|
|
84
101
|
} = convertToDropdownItems(dragMenuConfig);
|
|
102
|
+
const handleSubMenuRef = ref => {
|
|
103
|
+
const parent = closestElement(editorView.dom, '.fabric-editor-popup-scroll-parent');
|
|
104
|
+
if (!(parent && ref)) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const boundariesRect = parent.getBoundingClientRect();
|
|
108
|
+
const rect = ref.getBoundingClientRect();
|
|
109
|
+
if (rect.left + rect.width > boundariesRect.width) {
|
|
110
|
+
ref.style.left = `-${rect.width}px`;
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
const setColor = color => {
|
|
114
|
+
const {
|
|
115
|
+
targetCellPosition
|
|
116
|
+
} = getTablePluginState(editorView.state);
|
|
117
|
+
const {
|
|
118
|
+
state,
|
|
119
|
+
dispatch
|
|
120
|
+
} = editorView;
|
|
121
|
+
setColorWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.CONTEXT_MENU, color, targetCellPosition)(state, dispatch);
|
|
122
|
+
closeMenu();
|
|
123
|
+
setIsSubmenuOpen(false);
|
|
124
|
+
};
|
|
125
|
+
const createBackgroundColorMenuItem = () => {
|
|
126
|
+
var _node$attrs;
|
|
127
|
+
const {
|
|
128
|
+
targetCellPosition
|
|
129
|
+
} = getTablePluginState(editorView.state);
|
|
130
|
+
const node = targetCellPosition ? state.doc.nodeAt(targetCellPosition) : null;
|
|
131
|
+
const background = hexToEditorBackgroundPaletteColor((node === null || node === void 0 ? 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
|
+
const toggleHeaderColumn = () => {
|
|
163
|
+
toggleHeaderColumnWithAnalytics(editorAnalyticsAPI)(state, dispatch);
|
|
164
|
+
};
|
|
165
|
+
const toggleHeaderRow = () => {
|
|
166
|
+
toggleHeaderRowWithAnalytics(editorAnalyticsAPI)(state, dispatch);
|
|
167
|
+
};
|
|
168
|
+
const toggleRowNumbers = () => {
|
|
169
|
+
toggleNumberColumnWithAnalytics(editorAnalyticsAPI)(state, dispatch);
|
|
170
|
+
};
|
|
171
|
+
const 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
|
+
const 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
|
*/
|
|
@@ -119,13 +247,34 @@ export const DragMenu = ({
|
|
|
119
247
|
}) => {
|
|
120
248
|
var _menuCallback$item$va;
|
|
121
249
|
(_menuCallback$item$va = menuCallback[item.value.name]) === null || _menuCallback$item$va === void 0 ? void 0 : _menuCallback$item$va.call(menuCallback, state, dispatch);
|
|
122
|
-
|
|
250
|
+
switch (item.value.name) {
|
|
251
|
+
case 'header_column':
|
|
252
|
+
toggleHeaderColumn();
|
|
253
|
+
break;
|
|
254
|
+
case 'header_row':
|
|
255
|
+
toggleHeaderRow();
|
|
256
|
+
break;
|
|
257
|
+
case 'row_numbers':
|
|
258
|
+
toggleRowNumbers();
|
|
259
|
+
break;
|
|
260
|
+
default:
|
|
261
|
+
break;
|
|
262
|
+
}
|
|
263
|
+
if (['header_column', 'header_row', 'row_numbers', 'background'].indexOf(item.value.name) <= -1) {
|
|
264
|
+
closeMenu();
|
|
265
|
+
}
|
|
123
266
|
};
|
|
124
267
|
const handleItemMouseEnter = ({
|
|
125
268
|
item
|
|
126
269
|
}) => {
|
|
127
270
|
var _item$value$name;
|
|
128
|
-
if (!selectionRect
|
|
271
|
+
if (!selectionRect) {
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
if (item.value.name === 'background' && !isSubmenuOpen) {
|
|
275
|
+
setIsSubmenuOpen(true);
|
|
276
|
+
}
|
|
277
|
+
if (!((_item$value$name = item.value.name) !== null && _item$value$name !== void 0 && _item$value$name.startsWith('delete'))) {
|
|
129
278
|
return;
|
|
130
279
|
}
|
|
131
280
|
(item.value.name === 'delete_column' ? hoverColumns(getSelectedColumnIndexes(selectionRect), true) : hoverRows(getSelectedRowIndexes(selectionRect), true))(state, dispatch);
|
|
@@ -133,6 +282,9 @@ export const DragMenu = ({
|
|
|
133
282
|
const handleItemMouseLeave = ({
|
|
134
283
|
item
|
|
135
284
|
}) => {
|
|
285
|
+
if (item.value.name === 'background' && isSubmenuOpen) {
|
|
286
|
+
setIsSubmenuOpen(false);
|
|
287
|
+
}
|
|
136
288
|
if (['sort_column_asc', 'sort_column_desc', 'delete_column', 'delete_row'].indexOf(item.value.name) > -1) {
|
|
137
289
|
clearHoverSelection()(state, dispatch);
|
|
138
290
|
}
|
|
@@ -140,6 +292,24 @@ export const DragMenu = ({
|
|
|
140
292
|
if (!menuItems) {
|
|
141
293
|
return null;
|
|
142
294
|
}
|
|
295
|
+
if (allowBackgroundColor && getBooleanFF('platform.editor.table.new-cell-context-menu-styling')) {
|
|
296
|
+
menuItems[0].items.unshift(createBackgroundColorMenuItem());
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// If first row, add toggle for Hearder row, default is true
|
|
300
|
+
// If first column, add toggle for Header column, default is false
|
|
301
|
+
if (getBooleanFF('platform.editor.table.new-cell-context-menu-styling') && index === 0) {
|
|
302
|
+
menuItems.push({
|
|
303
|
+
items: [createhHeaderRowColumnMenuItem(direction)]
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
// All rows, add toggle for numbered rows, default is false
|
|
308
|
+
if (getBooleanFF('platform.editor.table.new-cell-context-menu-styling') && direction === 'row') {
|
|
309
|
+
index === 0 ? menuItems[menuItems.length - 1].items.push(createRowNumbersMenuItem()) : menuItems.push({
|
|
310
|
+
items: [createRowNumbersMenuItem()]
|
|
311
|
+
});
|
|
312
|
+
}
|
|
143
313
|
return jsx(DropdownMenu, {
|
|
144
314
|
mountTo: mountPoint
|
|
145
315
|
//This needs be removed when the a11y is completely handled
|
|
@@ -17,7 +17,8 @@ const FloatingDragMenu = ({
|
|
|
17
17
|
getEditorContainerWidth,
|
|
18
18
|
canDrag,
|
|
19
19
|
editorAnalyticsAPI,
|
|
20
|
-
stickyHeaders
|
|
20
|
+
stickyHeaders,
|
|
21
|
+
pluginConfig
|
|
21
22
|
}) => {
|
|
22
23
|
if (!isOpen || !targetCellPosition || editorView.state.doc.nodeSize <= targetCellPosition) {
|
|
23
24
|
return null;
|
|
@@ -56,7 +57,8 @@ const FloatingDragMenu = ({
|
|
|
56
57
|
targetCellPosition: targetCellPosition,
|
|
57
58
|
getEditorContainerWidth: getEditorContainerWidth,
|
|
58
59
|
canDrag: canDrag,
|
|
59
|
-
editorAnalyticsAPI: editorAnalyticsAPI
|
|
60
|
+
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
61
|
+
pluginConfig: pluginConfig
|
|
60
62
|
}));
|
|
61
63
|
};
|
|
62
64
|
FloatingDragMenu.displayName = 'FloatingDragMenu';
|