@atlaskit/editor-plugin-table 5.7.9 → 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 +19 -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/nodeviews/ExternalDropTargets.js +2 -1
- package/dist/cjs/plugin.js +2 -1
- package/dist/cjs/pm-plugins/drag-and-drop/commands.js +3 -3
- package/dist/cjs/pm-plugins/drag-and-drop/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 +8 -1
- package/dist/cjs/ui/DragHandle/index.js +1 -1
- 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/TableFloatingColumnControls/ColumnControls/index.js +2 -2
- package/dist/cjs/ui/TableFloatingControls/RowControls/DragControls.js +2 -2
- package/dist/cjs/ui/consts.js +2 -1
- package/dist/cjs/ui/ui-styles.js +6 -2
- package/dist/cjs/utils/decoration.js +14 -4
- 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/nodeviews/ExternalDropTargets.js +2 -1
- package/dist/es2019/plugin.js +2 -1
- package/dist/es2019/pm-plugins/drag-and-drop/commands.js +3 -3
- package/dist/es2019/pm-plugins/drag-and-drop/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 +8 -1
- package/dist/es2019/ui/DragHandle/index.js +1 -1
- 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/TableFloatingColumnControls/ColumnControls/index.js +2 -2
- package/dist/es2019/ui/TableFloatingControls/RowControls/DragControls.js +2 -2
- package/dist/es2019/ui/consts.js +2 -1
- package/dist/es2019/ui/ui-styles.js +108 -65
- package/dist/es2019/utils/decoration.js +14 -4
- 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/nodeviews/ExternalDropTargets.js +2 -1
- package/dist/esm/plugin.js +2 -1
- package/dist/esm/pm-plugins/drag-and-drop/commands.js +3 -3
- package/dist/esm/pm-plugins/drag-and-drop/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 +8 -1
- package/dist/esm/ui/DragHandle/index.js +1 -1
- 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/TableFloatingColumnControls/ColumnControls/index.js +2 -2
- package/dist/esm/ui/TableFloatingControls/RowControls/DragControls.js +2 -2
- package/dist/esm/ui/consts.js +2 -1
- package/dist/esm/ui/ui-styles.js +7 -3
- package/dist/esm/utils/decoration.js +14 -4
- package/dist/types/commands/column-resize.d.ts +5 -0
- package/dist/types/pm-plugins/drag-and-drop/commands.d.ts +1 -1
- package/dist/types/pm-plugins/table-resizing/utils/index.d.ts +1 -1
- package/dist/types/types.d.ts +7 -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/utils/decoration.d.ts +2 -2
- package/dist/types-ts4.5/commands/column-resize.d.ts +5 -0
- package/dist/types-ts4.5/pm-plugins/drag-and-drop/commands.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/index.d.ts +1 -1
- package/dist/types-ts4.5/types.d.ts +7 -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/dist/types-ts4.5/utils/decoration.d.ts +2 -2
- package/package.json +8 -4
- package/src/__tests__/unit/analytics.ts +5 -1
- package/src/__tests__/unit/ui/FloatingDragMenu.tsx +295 -0
- package/src/__tests__/unit/ui/RowDragControls.tsx +5 -4
- 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/nodeviews/ExternalDropTargets.tsx +1 -0
- package/src/plugin.tsx +1 -0
- package/src/pm-plugins/drag-and-drop/commands.ts +3 -2
- package/src/pm-plugins/drag-and-drop/plugin.ts +10 -4
- 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 +9 -0
- package/src/ui/DragHandle/index.tsx +1 -1
- 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/TableFloatingColumnControls/ColumnControls/index.tsx +35 -37
- package/src/ui/TableFloatingControls/RowControls/DragControls.tsx +33 -33
- package/src/ui/consts.ts +6 -1
- package/src/ui/ui-styles.ts +115 -64
- package/src/utils/decoration.ts +27 -8
- package/tsconfig.app.json +3 -0
|
@@ -5,18 +5,33 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.DragMenu = void 0;
|
|
8
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
8
9
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
|
-
var _react = require("
|
|
10
|
+
var _react = require("react");
|
|
11
|
+
var _react2 = require("@emotion/react");
|
|
12
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
13
|
+
var _styles = require("@atlaskit/editor-common/styles");
|
|
14
|
+
var _uiColor = require("@atlaskit/editor-common/ui-color");
|
|
10
15
|
var _uiMenu = require("@atlaskit/editor-common/ui-menu");
|
|
16
|
+
var _utils = require("@atlaskit/editor-common/utils");
|
|
17
|
+
var _editorPalette = require("@atlaskit/editor-palette");
|
|
11
18
|
var _shortcut = require("@atlaskit/editor-shared-styles/shortcut");
|
|
12
19
|
var _tableMap = require("@atlaskit/editor-tables/table-map");
|
|
13
|
-
var
|
|
20
|
+
var _utils2 = require("@atlaskit/editor-tables/utils");
|
|
21
|
+
var _backgroundColor = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/background-color"));
|
|
22
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
23
|
+
var _toggle = _interopRequireDefault(require("@atlaskit/toggle"));
|
|
14
24
|
var _commands = require("../../commands");
|
|
25
|
+
var _commandsWithAnalytics = require("../../commands-with-analytics");
|
|
15
26
|
var _commands2 = require("../../pm-plugins/drag-and-drop/commands");
|
|
16
27
|
var _pluginFactory = require("../../pm-plugins/drag-and-drop/plugin-factory");
|
|
17
|
-
var
|
|
28
|
+
var _pluginFactory2 = require("../../pm-plugins/plugin-factory");
|
|
29
|
+
var _types = require("../../types");
|
|
30
|
+
var _utils3 = require("../../utils");
|
|
18
31
|
var _dragMenu = require("../../utils/drag-menu");
|
|
19
32
|
var _consts = require("../consts");
|
|
33
|
+
var _styles2 = require("./styles");
|
|
34
|
+
/* eslint-disable @atlaskit/design-system/prefer-primitives */
|
|
20
35
|
/** @jsx jsx */
|
|
21
36
|
|
|
22
37
|
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']];
|
|
@@ -39,15 +54,14 @@ var convertToDropdownItems = function convertToDropdownItems(dragMenuConfig) {
|
|
|
39
54
|
name: item.id
|
|
40
55
|
},
|
|
41
56
|
isDisabled: item.disabled,
|
|
42
|
-
elemBefore: item.icon ? (0,
|
|
57
|
+
elemBefore: item.icon ? (0, _react2.jsx)("div", {
|
|
43
58
|
style: {
|
|
44
|
-
marginRight: "var(--ds-space-negative-075, -6px)",
|
|
45
59
|
display: 'flex'
|
|
46
60
|
}
|
|
47
|
-
}, (0,
|
|
61
|
+
}, (0, _react2.jsx)(item.icon, {
|
|
48
62
|
label: item.title
|
|
49
63
|
})) : undefined,
|
|
50
|
-
elemAfter: item.keymap ? (0,
|
|
64
|
+
elemAfter: item.keymap ? (0, _react2.jsx)("div", {
|
|
51
65
|
css: _shortcut.shortcutStyle
|
|
52
66
|
}, item.keymap) : undefined
|
|
53
67
|
});
|
|
@@ -65,6 +79,7 @@ var convertToDropdownItems = function convertToDropdownItems(dragMenuConfig) {
|
|
|
65
79
|
};
|
|
66
80
|
};
|
|
67
81
|
var DragMenu = exports.DragMenu = function DragMenu(_ref) {
|
|
82
|
+
var _pluginConfig$allowBa;
|
|
68
83
|
var _ref$direction = _ref.direction,
|
|
69
84
|
direction = _ref$direction === void 0 ? 'row' : _ref$direction,
|
|
70
85
|
index = _ref.index,
|
|
@@ -77,23 +92,136 @@ var DragMenu = exports.DragMenu = function DragMenu(_ref) {
|
|
|
77
92
|
targetCellPosition = _ref.targetCellPosition,
|
|
78
93
|
getEditorContainerWidth = _ref.getEditorContainerWidth,
|
|
79
94
|
canDrag = _ref.canDrag,
|
|
80
|
-
editorAnalyticsAPI = _ref.editorAnalyticsAPI
|
|
81
|
-
|
|
95
|
+
editorAnalyticsAPI = _ref.editorAnalyticsAPI,
|
|
96
|
+
pluginConfig = _ref.pluginConfig;
|
|
82
97
|
var state = editorView.state,
|
|
83
98
|
dispatch = editorView.dispatch;
|
|
84
99
|
var selection = state.selection;
|
|
85
|
-
var
|
|
86
|
-
var
|
|
100
|
+
var tableMap = tableNode ? _tableMap.TableMap.get(tableNode) : undefined;
|
|
101
|
+
var _useState = (0, _react.useState)(false),
|
|
102
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
103
|
+
isSubmenuOpen = _useState2[0],
|
|
104
|
+
setIsSubmenuOpen = _useState2[1];
|
|
105
|
+
var selectionRect = (0, _utils2.isSelectionType)(selection, 'cell') ? (0, _utils2.getSelectionRect)(selection) : (0, _utils2.findCellRectClosestToPos)(selection.$from);
|
|
106
|
+
var hasMergedCells = direction === 'row' ? _utils3.hasMergedCellsInRow : _utils3.hasMergedCellsInColumn;
|
|
87
107
|
var shouldMoveDisabled = index !== undefined && hasMergedCells(index)(selection);
|
|
88
|
-
var hasMergedCellsInTable = (0,
|
|
108
|
+
var hasMergedCellsInTable = (0, _utils3.getMergedCellsPositions)(state.tr).length > 0;
|
|
109
|
+
var allowBackgroundColor = (_pluginConfig$allowBa = pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.allowBackgroundColor) !== null && _pluginConfig$allowBa !== void 0 ? _pluginConfig$allowBa : false;
|
|
89
110
|
var dragMenuConfig = (0, _dragMenu.getDragMenuConfig)(direction, getEditorContainerWidth, !!canDrag && !shouldMoveDisabled, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI);
|
|
90
111
|
var _convertToDropdownIte = convertToDropdownItems(dragMenuConfig),
|
|
91
112
|
menuItems = _convertToDropdownIte.menuItems,
|
|
92
113
|
menuCallback = _convertToDropdownIte.menuCallback;
|
|
114
|
+
var handleSubMenuRef = function handleSubMenuRef(ref) {
|
|
115
|
+
var parent = (0, _utils.closestElement)(editorView.dom, '.fabric-editor-popup-scroll-parent');
|
|
116
|
+
if (!(parent && ref)) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
var boundariesRect = parent.getBoundingClientRect();
|
|
120
|
+
var rect = ref.getBoundingClientRect();
|
|
121
|
+
if (rect.left + rect.width > boundariesRect.width) {
|
|
122
|
+
ref.style.left = "-".concat(rect.width, "px");
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
var setColor = function setColor(color) {
|
|
126
|
+
var _getTablePluginState = (0, _pluginFactory2.getPluginState)(editorView.state),
|
|
127
|
+
targetCellPosition = _getTablePluginState.targetCellPosition;
|
|
128
|
+
var state = editorView.state,
|
|
129
|
+
dispatch = editorView.dispatch;
|
|
130
|
+
(0, _commandsWithAnalytics.setColorWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.CONTEXT_MENU, color, targetCellPosition)(state, dispatch);
|
|
131
|
+
closeMenu();
|
|
132
|
+
setIsSubmenuOpen(false);
|
|
133
|
+
};
|
|
134
|
+
var createBackgroundColorMenuItem = function createBackgroundColorMenuItem() {
|
|
135
|
+
var _node$attrs;
|
|
136
|
+
var _getTablePluginState2 = (0, _pluginFactory2.getPluginState)(editorView.state),
|
|
137
|
+
targetCellPosition = _getTablePluginState2.targetCellPosition;
|
|
138
|
+
var node = targetCellPosition ? state.doc.nodeAt(targetCellPosition) : null;
|
|
139
|
+
var background = (0, _editorPalette.hexToEditorBackgroundPaletteColor)((node === null || node === void 0 || (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.background) || '#ffffff');
|
|
140
|
+
return {
|
|
141
|
+
content: 'Background color',
|
|
142
|
+
value: {
|
|
143
|
+
name: 'background'
|
|
144
|
+
},
|
|
145
|
+
elemBefore: (0, _react2.jsx)(_backgroundColor.default, {
|
|
146
|
+
label: 'background color',
|
|
147
|
+
size: "medium"
|
|
148
|
+
}),
|
|
149
|
+
elemAfter: (0, _react2.jsx)("div", {
|
|
150
|
+
className: _styles.DropdownMenuSharedCssClassName.SUBMENU,
|
|
151
|
+
css: _styles2.dragMenuBackgroundColorStyles
|
|
152
|
+
}, (0, _react2.jsx)("div", {
|
|
153
|
+
css: (0, _styles2.cellColourPreviewStyles)(background),
|
|
154
|
+
className: _types.TableCssClassName.DRAG_SUBMENU_ICON
|
|
155
|
+
}), isSubmenuOpen && (0, _react2.jsx)("div", {
|
|
156
|
+
className: _types.TableCssClassName.DRAG_SUBMENU,
|
|
157
|
+
ref: handleSubMenuRef
|
|
158
|
+
}, (0, _react2.jsx)(_uiColor.ColorPalette, {
|
|
159
|
+
cols: 7,
|
|
160
|
+
onClick: setColor,
|
|
161
|
+
selectedColor: background,
|
|
162
|
+
paletteOptions: {
|
|
163
|
+
palette: _uiColor.cellBackgroundColorPalette,
|
|
164
|
+
paletteColorTooltipMessages: _uiColor.backgroundPaletteTooltipMessages,
|
|
165
|
+
hexToPaletteColor: _editorPalette.hexToEditorBackgroundPaletteColor
|
|
166
|
+
}
|
|
167
|
+
})))
|
|
168
|
+
};
|
|
169
|
+
};
|
|
170
|
+
var toggleHeaderColumn = function toggleHeaderColumn() {
|
|
171
|
+
(0, _commandsWithAnalytics.toggleHeaderColumnWithAnalytics)(editorAnalyticsAPI)(state, dispatch);
|
|
172
|
+
};
|
|
173
|
+
var toggleHeaderRow = function toggleHeaderRow() {
|
|
174
|
+
(0, _commandsWithAnalytics.toggleHeaderRowWithAnalytics)(editorAnalyticsAPI)(state, dispatch);
|
|
175
|
+
};
|
|
176
|
+
var toggleRowNumbers = function toggleRowNumbers() {
|
|
177
|
+
(0, _commandsWithAnalytics.toggleNumberColumnWithAnalytics)(editorAnalyticsAPI)(state, dispatch);
|
|
178
|
+
};
|
|
179
|
+
var createhHeaderRowColumnMenuItem = function createhHeaderRowColumnMenuItem(direction) {
|
|
180
|
+
return direction === 'column' ? {
|
|
181
|
+
content: 'Header column',
|
|
182
|
+
value: {
|
|
183
|
+
name: 'header_column'
|
|
184
|
+
},
|
|
185
|
+
elemAfter: (0, _react2.jsx)("div", {
|
|
186
|
+
css: _styles2.toggleStyles
|
|
187
|
+
}, (0, _react2.jsx)(_toggle.default, {
|
|
188
|
+
id: "toggle-header-column",
|
|
189
|
+
onChange: toggleHeaderColumn,
|
|
190
|
+
isChecked: (0, _utils3.checkIfHeaderColumnEnabled)(selection)
|
|
191
|
+
}))
|
|
192
|
+
} : {
|
|
193
|
+
content: 'Header row',
|
|
194
|
+
value: {
|
|
195
|
+
name: 'header_row'
|
|
196
|
+
},
|
|
197
|
+
elemAfter: (0, _react2.jsx)("div", {
|
|
198
|
+
css: _styles2.toggleStyles
|
|
199
|
+
}, (0, _react2.jsx)(_toggle.default, {
|
|
200
|
+
id: "toggle-header-row",
|
|
201
|
+
onChange: toggleHeaderRow,
|
|
202
|
+
isChecked: (0, _utils3.checkIfHeaderRowEnabled)(selection)
|
|
203
|
+
}))
|
|
204
|
+
};
|
|
205
|
+
};
|
|
206
|
+
var createRowNumbersMenuItem = function createRowNumbersMenuItem() {
|
|
207
|
+
return {
|
|
208
|
+
content: 'Row numbers',
|
|
209
|
+
value: {
|
|
210
|
+
name: 'row_numbers'
|
|
211
|
+
},
|
|
212
|
+
elemAfter: (0, _react2.jsx)("div", {
|
|
213
|
+
css: _styles2.toggleStyles
|
|
214
|
+
}, (0, _react2.jsx)(_toggle.default, {
|
|
215
|
+
id: "toggle-row-numbers",
|
|
216
|
+
onChange: toggleRowNumbers,
|
|
217
|
+
isChecked: (0, _utils3.checkIfNumberColumnEnabled)(selection)
|
|
218
|
+
}))
|
|
219
|
+
};
|
|
220
|
+
};
|
|
93
221
|
|
|
94
222
|
/**
|
|
95
223
|
* This function is to check if the menu should be closed or not.
|
|
96
|
-
* As when continously clicking on
|
|
224
|
+
* As when continously clicking on tyle handle on different rows/columns,
|
|
97
225
|
* should open the menu corresponding to the position of the drag handle.
|
|
98
226
|
* @returns true when the menu should be closed, false otherwise
|
|
99
227
|
*/
|
|
@@ -123,18 +251,42 @@ var DragMenu = exports.DragMenu = function DragMenu(_ref) {
|
|
|
123
251
|
var _menuCallback$item$va;
|
|
124
252
|
var item = _ref2.item;
|
|
125
253
|
(_menuCallback$item$va = menuCallback[item.value.name]) === null || _menuCallback$item$va === void 0 || _menuCallback$item$va.call(menuCallback, state, dispatch);
|
|
126
|
-
|
|
254
|
+
switch (item.value.name) {
|
|
255
|
+
case 'header_column':
|
|
256
|
+
toggleHeaderColumn();
|
|
257
|
+
break;
|
|
258
|
+
case 'header_row':
|
|
259
|
+
toggleHeaderRow();
|
|
260
|
+
break;
|
|
261
|
+
case 'row_numbers':
|
|
262
|
+
toggleRowNumbers();
|
|
263
|
+
break;
|
|
264
|
+
default:
|
|
265
|
+
break;
|
|
266
|
+
}
|
|
267
|
+
if (['header_column', 'header_row', 'row_numbers', 'background'].indexOf(item.value.name) <= -1) {
|
|
268
|
+
closeMenu();
|
|
269
|
+
}
|
|
127
270
|
};
|
|
128
271
|
var handleItemMouseEnter = function handleItemMouseEnter(_ref3) {
|
|
129
272
|
var _item$value$name;
|
|
130
273
|
var item = _ref3.item;
|
|
131
|
-
if (!selectionRect
|
|
274
|
+
if (!selectionRect) {
|
|
132
275
|
return;
|
|
133
276
|
}
|
|
134
|
-
(item.value.name === '
|
|
277
|
+
if (item.value.name === 'background' && !isSubmenuOpen) {
|
|
278
|
+
setIsSubmenuOpen(true);
|
|
279
|
+
}
|
|
280
|
+
if (!((_item$value$name = item.value.name) !== null && _item$value$name !== void 0 && _item$value$name.startsWith('delete'))) {
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
(item.value.name === 'delete_column' ? (0, _commands.hoverColumns)((0, _utils3.getSelectedColumnIndexes)(selectionRect), true) : (0, _commands.hoverRows)((0, _utils3.getSelectedRowIndexes)(selectionRect), true))(state, dispatch);
|
|
135
284
|
};
|
|
136
285
|
var handleItemMouseLeave = function handleItemMouseLeave(_ref4) {
|
|
137
286
|
var item = _ref4.item;
|
|
287
|
+
if (item.value.name === 'background' && isSubmenuOpen) {
|
|
288
|
+
setIsSubmenuOpen(false);
|
|
289
|
+
}
|
|
138
290
|
if (['sort_column_asc', 'sort_column_desc', 'delete_column', 'delete_row'].indexOf(item.value.name) > -1) {
|
|
139
291
|
(0, _commands.clearHoverSelection)()(state, dispatch);
|
|
140
292
|
}
|
|
@@ -142,7 +294,25 @@ var DragMenu = exports.DragMenu = function DragMenu(_ref) {
|
|
|
142
294
|
if (!menuItems) {
|
|
143
295
|
return null;
|
|
144
296
|
}
|
|
145
|
-
|
|
297
|
+
if (allowBackgroundColor && (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.new-cell-context-menu-styling')) {
|
|
298
|
+
menuItems[0].items.unshift(createBackgroundColorMenuItem());
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
// If first row, add toggle for Hearder row, default is true
|
|
302
|
+
// If first column, add toggle for Header column, default is false
|
|
303
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.new-cell-context-menu-styling') && index === 0) {
|
|
304
|
+
menuItems.push({
|
|
305
|
+
items: [createhHeaderRowColumnMenuItem(direction)]
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
// All rows, add toggle for numbered rows, default is false
|
|
310
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.new-cell-context-menu-styling') && direction === 'row') {
|
|
311
|
+
index === 0 ? menuItems[menuItems.length - 1].items.push(createRowNumbersMenuItem()) : menuItems.push({
|
|
312
|
+
items: [createRowNumbersMenuItem()]
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
return (0, _react2.jsx)(_uiMenu.DropdownMenu, {
|
|
146
316
|
mountTo: mountPoint
|
|
147
317
|
//This needs be removed when the a11y is completely handled
|
|
148
318
|
//Disabling key navigation now as it works only partially
|
|
@@ -24,7 +24,8 @@ var FloatingDragMenu = function FloatingDragMenu(_ref) {
|
|
|
24
24
|
getEditorContainerWidth = _ref.getEditorContainerWidth,
|
|
25
25
|
canDrag = _ref.canDrag,
|
|
26
26
|
editorAnalyticsAPI = _ref.editorAnalyticsAPI,
|
|
27
|
-
stickyHeaders = _ref.stickyHeaders
|
|
27
|
+
stickyHeaders = _ref.stickyHeaders,
|
|
28
|
+
pluginConfig = _ref.pluginConfig;
|
|
28
29
|
if (!isOpen || !targetCellPosition || editorView.state.doc.nodeSize <= targetCellPosition) {
|
|
29
30
|
return null;
|
|
30
31
|
}
|
|
@@ -62,7 +63,8 @@ var FloatingDragMenu = function FloatingDragMenu(_ref) {
|
|
|
62
63
|
targetCellPosition: targetCellPosition,
|
|
63
64
|
getEditorContainerWidth: getEditorContainerWidth,
|
|
64
65
|
canDrag: canDrag,
|
|
65
|
-
editorAnalyticsAPI: editorAnalyticsAPI
|
|
66
|
+
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
67
|
+
pluginConfig: pluginConfig
|
|
66
68
|
}));
|
|
67
69
|
};
|
|
68
70
|
FloatingDragMenu.displayName = 'FloatingDragMenu';
|
|
@@ -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"])));
|
|
@@ -153,7 +153,7 @@ var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
|
|
|
153
153
|
|
|
154
154
|
// this indexes are used to calculate the drag and drop source
|
|
155
155
|
var indexes = isColumnsSelected ? isHover ? colIndexes : selectedColIndexes : colIndexes;
|
|
156
|
-
return
|
|
156
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
157
157
|
key: type,
|
|
158
158
|
style: {
|
|
159
159
|
gridColumn: isSelecting ? selectedColumnPosition : gridColumnPosition,
|
|
@@ -165,7 +165,7 @@ var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
|
|
|
165
165
|
zIndex: 99
|
|
166
166
|
},
|
|
167
167
|
"data-column-control-index": hoveredCell.colIndex,
|
|
168
|
-
"data-testid":
|
|
168
|
+
"data-testid": "table-floating-column-".concat(isSelecting ? selectedColIndexes[0] : colIndex, "-drag-handle")
|
|
169
169
|
}, /*#__PURE__*/_react.default.createElement(_DragHandle.DragHandle, {
|
|
170
170
|
isDragMenuTarget: !isHover,
|
|
171
171
|
direction: "column",
|
|
@@ -140,7 +140,7 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
|
|
|
140
140
|
var currentSelectionAppearance = isRowsSelected ? isInDanger ? 'danger' : 'selected' : hoveredAppearance;
|
|
141
141
|
var isSelecting = isRowsSelected && !isHover;
|
|
142
142
|
var indexes = isRowsSelected ? isHover ? rowIndexes : selectedRowIndexes : rowIndexes;
|
|
143
|
-
return
|
|
143
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
144
144
|
key: type,
|
|
145
145
|
style: {
|
|
146
146
|
gridRow: isSelecting ? selectedRowPosition : gridRowPosition,
|
|
@@ -150,7 +150,7 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
|
|
|
150
150
|
position: 'relative',
|
|
151
151
|
right: '-0.5px'
|
|
152
152
|
},
|
|
153
|
-
"data-testid":
|
|
153
|
+
"data-testid": "table-floating-row-".concat(isSelecting ? selectedRowIndexes[0] : rowIndex, "-drag-handle")
|
|
154
154
|
}, /*#__PURE__*/_react.default.createElement(_DragHandle.DragHandle, {
|
|
155
155
|
isDragMenuTarget: !isHover,
|
|
156
156
|
direction: "row",
|
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;
|
package/dist/cjs/ui/ui-styles.js
CHANGED
|
@@ -13,7 +13,7 @@ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
|
13
13
|
var _colors = require("@atlaskit/theme/colors");
|
|
14
14
|
var _types = require("../types");
|
|
15
15
|
var _consts = require("./consts");
|
|
16
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18, _templateObject19, _templateObject20, _templateObject21, _templateObject22, _templateObject23, _templateObject24, _templateObject25, _templateObject26, _templateObject27, _templateObject28, _templateObject29, _templateObject30, _templateObject31, _templateObject32, _templateObject33;
|
|
16
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18, _templateObject19, _templateObject20, _templateObject21, _templateObject22, _templateObject23, _templateObject24, _templateObject25, _templateObject26, _templateObject27, _templateObject28, _templateObject29, _templateObject30, _templateObject31, _templateObject32, _templateObject33, _templateObject34, _templateObject35, _templateObject36, _templateObject37;
|
|
17
17
|
var InsertLine = function InsertLine(cssString) {
|
|
18
18
|
return (0, _react.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n .", " {\n background: ", ";\n display: none;\n position: absolute;\n z-index: ", ";\n ", "\n }\n"])), _types.TableCssClassName.CONTROLS_INSERT_LINE, _consts.tableBorderSelectedColor, _editorSharedStyles.akEditorUnitZIndex, cssString);
|
|
19
19
|
};
|
|
@@ -119,6 +119,10 @@ var resizeHandle = exports.resizeHandle = function resizeHandle() {
|
|
|
119
119
|
};
|
|
120
120
|
|
|
121
121
|
// Drag and Drop: drop target insert line
|
|
122
|
+
var tableCellColumnInsertLineStyles = (0, _react.css)(_templateObject33 || (_templateObject33 = (0, _taggedTemplateLiteral2.default)(["\n content: ' ';\n position: absolute;\n height: calc(100% + ", "px);\n width: ", "px;\n z-index: ", ";\n"])), _styles.tableCellBorderWidth * 2, _consts.insertLineWidth, _consts.columnControlsZIndex * 2);
|
|
123
|
+
var tableCellRowInsertLineStyles = (0, _react.css)(_templateObject34 || (_templateObject34 = (0, _taggedTemplateLiteral2.default)(["\n content: ' ';\n position: absolute;\n left: ", ";\n height: ", "px;\n width: calc(100% + ", "px);\n z-index: ", ";\n"])), "var(--ds-space-negative-025, -2px)", _consts.insertLineWidth, _styles.tableCellBorderWidth * 2, _consts.columnControlsZIndex * 2);
|
|
124
|
+
var insertLineActiveColor = (0, _react.css)(_templateObject35 || (_templateObject35 = (0, _taggedTemplateLiteral2.default)(["\n background-color: ", ";\n"])), _consts.tableBorderSelectedColor);
|
|
125
|
+
var insertLineInactiveColor = (0, _react.css)(_templateObject36 || (_templateObject36 = (0, _taggedTemplateLiteral2.default)(["\n background-color: ", ";\n"])), "var(--ds-background-accent-gray-subtler, ".concat(_editorSharedStyles.akEditorTableBorder, ")"));
|
|
122
126
|
var insertLine = exports.insertLine = function insertLine() {
|
|
123
|
-
return (0, _react.css)(
|
|
127
|
+
return (0, _react.css)(_templateObject37 || (_templateObject37 = (0, _taggedTemplateLiteral2.default)(["\n .", " {\n td.", "::before {\n ", "\n left: -1px;\n top: -1px;\n ", "\n }\n\n td.", "::before {\n ", "\n left: -1px;\n top: -1px;\n ", "\n }\n\n th.", "::before {\n ", "\n left: -1px;\n top: -", "px;\n ", "\n }\n\n th.", "::before {\n ", "\n left: -1px;\n top: -", "px;\n ", "\n }\n\n td.", "::before {\n ", "\n left: ", ";\n top: -1px;\n ", "\n }\n\n td.", "::before {\n ", "\n left: ", ";\n top: -1px;\n ", "\n }\n\n th.", "::before {\n ", "\n left: ", ";\n top: -", "px;\n ", "\n }\n\n th.", "::before {\n ", "\n left: ", ";\n top: -", "px;\n ", "\n }\n\n td.", "::before {\n ", "\n right: -1px;\n top: -1px;\n ", "\n }\n\n td.", "::before {\n ", "\n right: -1px;\n top: -1px;\n ", "\n }\n\n th.", "::before {\n ", "\n right: -1px;\n top: -", "px;\n ", "\n }\n\n th.", "::before {\n ", "\n right: -1px;\n top: -", "px;\n ", "\n }\n\n td.", "::before {\n ", "\n top: -1px;\n ", "\n }\n\n td.", "::before {\n ", "\n top: -1px;\n ", "\n }\n\n th.", "::before {\n ", "\n top: -1px;\n ", "\n }\n\n th.", "::before {\n ", "\n top: -1px;\n ", "\n }\n\n td.", "::before {\n ", "\n bottom: 0;\n ", "\n }\n\n td.", "::before {\n ", "\n bottom: 0;\n ", "\n }\n\n th.", "::before {\n ", "\n bottom: 0;\n ", "\n }\n\n th.", "::before {\n ", "\n bottom: 0;\n ", "\n }\n }\n"])), _types.TableCssClassName.TABLE_CONTAINER, _types.TableCssClassName.WITH_FIRST_COLUMN_INSERT_LINE, tableCellColumnInsertLineStyles, insertLineActiveColor, _types.TableCssClassName.WITH_FIRST_COLUMN_INSERT_LINE_INACTIVE, tableCellColumnInsertLineStyles, insertLineInactiveColor, _types.TableCssClassName.WITH_FIRST_COLUMN_INSERT_LINE, tableCellColumnInsertLineStyles, _styles.tableCellBorderWidth, insertLineActiveColor, _types.TableCssClassName.WITH_FIRST_COLUMN_INSERT_LINE_INACTIVE, tableCellColumnInsertLineStyles, _styles.tableCellBorderWidth, insertLineInactiveColor, _types.TableCssClassName.WITH_COLUMN_INSERT_LINE, tableCellColumnInsertLineStyles, "var(--ds-space-negative-025, -2px)", insertLineActiveColor, _types.TableCssClassName.WITH_COLUMN_INSERT_LINE_INACTIVE, tableCellColumnInsertLineStyles, "var(--ds-space-negative-025, -2px)", insertLineInactiveColor, _types.TableCssClassName.WITH_COLUMN_INSERT_LINE, tableCellColumnInsertLineStyles, "var(--ds-space-negative-025, -2px)", _styles.tableCellBorderWidth, insertLineActiveColor, _types.TableCssClassName.WITH_COLUMN_INSERT_LINE_INACTIVE, tableCellColumnInsertLineStyles, "var(--ds-space-negative-025, -2px)", _styles.tableCellBorderWidth, insertLineInactiveColor, _types.TableCssClassName.WITH_LAST_COLUMN_INSERT_LINE, tableCellColumnInsertLineStyles, insertLineActiveColor, _types.TableCssClassName.WITH_LAST_COLUMN_INSERT_LINE_INACTIVE, tableCellColumnInsertLineStyles, insertLineInactiveColor, _types.TableCssClassName.WITH_LAST_COLUMN_INSERT_LINE, tableCellColumnInsertLineStyles, _styles.tableCellBorderWidth, insertLineActiveColor, _types.TableCssClassName.WITH_LAST_COLUMN_INSERT_LINE_INACTIVE, tableCellColumnInsertLineStyles, _styles.tableCellBorderWidth, insertLineInactiveColor, _types.TableCssClassName.WITH_ROW_INSERT_LINE, tableCellRowInsertLineStyles, insertLineActiveColor, _types.TableCssClassName.WITH_ROW_INSERT_LINE_INACTIVE, tableCellRowInsertLineStyles, insertLineInactiveColor, _types.TableCssClassName.WITH_ROW_INSERT_LINE, tableCellRowInsertLineStyles, insertLineActiveColor, _types.TableCssClassName.WITH_ROW_INSERT_LINE_INACTIVE, tableCellRowInsertLineStyles, insertLineInactiveColor, _types.TableCssClassName.WITH_LAST_ROW_INSERT_LINE, tableCellRowInsertLineStyles, insertLineActiveColor, _types.TableCssClassName.WITH_LAST_ROW_INSERT_LINE_INACTIVE, tableCellRowInsertLineStyles, insertLineInactiveColor, _types.TableCssClassName.WITH_LAST_ROW_INSERT_LINE, tableCellRowInsertLineStyles, insertLineActiveColor, _types.TableCssClassName.WITH_LAST_ROW_INSERT_LINE_INACTIVE, tableCellRowInsertLineStyles, insertLineInactiveColor);
|
|
124
128
|
};
|
|
@@ -459,7 +459,7 @@ var createColumnLineResize = exports.createColumnLineResize = function createCol
|
|
|
459
459
|
});
|
|
460
460
|
}).filter(_utils.nonNullable);
|
|
461
461
|
};
|
|
462
|
-
var createColumnInsertLine = exports.createColumnInsertLine = function createColumnInsertLine(columnIndex, selection) {
|
|
462
|
+
var createColumnInsertLine = exports.createColumnInsertLine = function createColumnInsertLine(columnIndex, selection, hasMergedCells) {
|
|
463
463
|
var table = (0, _utils2.findTable)(selection);
|
|
464
464
|
if (!table) {
|
|
465
465
|
return [];
|
|
@@ -470,7 +470,12 @@ var createColumnInsertLine = exports.createColumnInsertLine = function createCol
|
|
|
470
470
|
if (isLastColumn) {
|
|
471
471
|
columnIndex -= 1;
|
|
472
472
|
}
|
|
473
|
-
var decorationClassName
|
|
473
|
+
var decorationClassName;
|
|
474
|
+
if (hasMergedCells) {
|
|
475
|
+
decorationClassName = isFirstColumn ? _types.TableCssClassName.WITH_FIRST_COLUMN_INSERT_LINE_INACTIVE : isLastColumn ? _types.TableCssClassName.WITH_LAST_COLUMN_INSERT_LINE_INACTIVE : _types.TableCssClassName.WITH_COLUMN_INSERT_LINE_INACTIVE;
|
|
476
|
+
} else {
|
|
477
|
+
decorationClassName = isFirstColumn ? _types.TableCssClassName.WITH_FIRST_COLUMN_INSERT_LINE : isLastColumn ? _types.TableCssClassName.WITH_LAST_COLUMN_INSERT_LINE : _types.TableCssClassName.WITH_COLUMN_INSERT_LINE;
|
|
478
|
+
}
|
|
474
479
|
var cellPositions = makeArray(map.height).map(function (rowIndex) {
|
|
475
480
|
return map.map[map.width * rowIndex + columnIndex];
|
|
476
481
|
}).filter(function (cellPosition, rowIndex) {
|
|
@@ -499,7 +504,7 @@ var createColumnInsertLine = exports.createColumnInsertLine = function createCol
|
|
|
499
504
|
});
|
|
500
505
|
}).filter(_utils.nonNullable);
|
|
501
506
|
};
|
|
502
|
-
var createRowInsertLine = exports.createRowInsertLine = function createRowInsertLine(rowIndex, selection) {
|
|
507
|
+
var createRowInsertLine = exports.createRowInsertLine = function createRowInsertLine(rowIndex, selection, hasMergedCells) {
|
|
503
508
|
var table = (0, _utils2.findTable)(selection);
|
|
504
509
|
if (!table) {
|
|
505
510
|
return [];
|
|
@@ -513,7 +518,12 @@ var createRowInsertLine = exports.createRowInsertLine = function createRowInsert
|
|
|
513
518
|
if (!cells) {
|
|
514
519
|
return [];
|
|
515
520
|
}
|
|
516
|
-
var decorationClassName
|
|
521
|
+
var decorationClassName;
|
|
522
|
+
if (hasMergedCells) {
|
|
523
|
+
decorationClassName = isLastRow ? _types.TableCssClassName.WITH_LAST_ROW_INSERT_LINE_INACTIVE : _types.TableCssClassName.WITH_ROW_INSERT_LINE_INACTIVE;
|
|
524
|
+
} else {
|
|
525
|
+
decorationClassName = isLastRow ? _types.TableCssClassName.WITH_LAST_ROW_INSERT_LINE : _types.TableCssClassName.WITH_ROW_INSERT_LINE;
|
|
526
|
+
}
|
|
517
527
|
return cells.map(function (cell, index) {
|
|
518
528
|
if (!cell || !cell.node) {
|
|
519
529
|
return;
|
|
@@ -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
|
+
};
|