@atlaskit/editor-plugin-table 5.7.1 → 5.7.3
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 +16 -0
- package/dist/cjs/nodeviews/TableComponent.js +4 -1
- package/dist/cjs/plugin.js +2 -1
- package/dist/cjs/pm-plugins/main.js +5 -16
- package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +0 -4
- package/dist/cjs/toolbar.js +87 -14
- package/dist/cjs/types.js +0 -2
- package/dist/cjs/ui/FloatingDragMenu/index.js +5 -2
- package/dist/cjs/ui/FloatingInsertButton/InsertButton.js +3 -3
- package/dist/cjs/ui/FloatingInsertButton/index.js +1 -1
- package/dist/cjs/ui/TableFloatingColumnControls/ColumnControls/index.js +49 -18
- package/dist/cjs/ui/TableFloatingColumnControls/index.js +17 -8
- package/dist/cjs/ui/common-styles.js +1 -1
- package/dist/cjs/utils/decoration.js +48 -34
- package/dist/cjs/utils/dom.js +1 -19
- package/dist/cjs/utils/index.js +0 -6
- package/dist/es2019/nodeviews/TableComponent.js +5 -2
- package/dist/es2019/plugin.js +2 -1
- package/dist/es2019/pm-plugins/main.js +1 -12
- package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +1 -5
- package/dist/es2019/toolbar.js +77 -9
- package/dist/es2019/types.js +0 -2
- package/dist/es2019/ui/FloatingDragMenu/index.js +6 -3
- package/dist/es2019/ui/FloatingInsertButton/InsertButton.js +3 -3
- package/dist/es2019/ui/FloatingInsertButton/index.js +2 -2
- package/dist/es2019/ui/TableFloatingColumnControls/ColumnControls/index.js +42 -12
- package/dist/es2019/ui/TableFloatingColumnControls/index.js +18 -9
- package/dist/es2019/ui/common-styles.js +6 -1
- package/dist/es2019/utils/decoration.js +47 -33
- package/dist/es2019/utils/dom.js +0 -18
- package/dist/es2019/utils/index.js +1 -1
- package/dist/esm/nodeviews/TableComponent.js +5 -2
- package/dist/esm/plugin.js +2 -1
- package/dist/esm/pm-plugins/main.js +1 -12
- package/dist/esm/pm-plugins/table-resizing/event-handlers.js +1 -5
- package/dist/esm/toolbar.js +86 -13
- package/dist/esm/types.js +0 -2
- package/dist/esm/ui/FloatingDragMenu/index.js +6 -3
- package/dist/esm/ui/FloatingInsertButton/InsertButton.js +3 -3
- package/dist/esm/ui/FloatingInsertButton/index.js +2 -2
- package/dist/esm/ui/TableFloatingColumnControls/ColumnControls/index.js +45 -14
- package/dist/esm/ui/TableFloatingColumnControls/index.js +18 -9
- package/dist/esm/ui/common-styles.js +2 -2
- package/dist/esm/utils/decoration.js +48 -34
- package/dist/esm/utils/dom.js +0 -18
- package/dist/esm/utils/index.js +1 -1
- package/dist/types/toolbar.d.ts +3 -1
- package/dist/types/types.d.ts +1 -1
- package/dist/types/ui/FloatingDragMenu/index.d.ts +3 -1
- package/dist/types/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +3 -1
- package/dist/types/ui/TableFloatingColumnControls/index.d.ts +2 -0
- package/dist/types/utils/dom.d.ts +0 -1
- package/dist/types/utils/index.d.ts +1 -1
- package/dist/types-ts4.5/toolbar.d.ts +3 -1
- package/dist/types-ts4.5/types.d.ts +1 -1
- package/dist/types-ts4.5/ui/FloatingDragMenu/index.d.ts +3 -1
- package/dist/types-ts4.5/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +3 -1
- package/dist/types-ts4.5/ui/TableFloatingColumnControls/index.d.ts +2 -0
- package/dist/types-ts4.5/utils/dom.d.ts +0 -1
- package/dist/types-ts4.5/utils/index.d.ts +1 -1
- package/package.json +8 -8
- package/src/nodeviews/TableComponent.tsx +7 -2
- package/src/plugin.tsx +1 -0
- package/src/pm-plugins/main.ts +0 -18
- package/src/pm-plugins/table-resizing/event-handlers.ts +1 -8
- package/src/toolbar.tsx +135 -9
- package/src/types.ts +1 -2
- package/src/ui/FloatingDragMenu/index.tsx +14 -2
- package/src/ui/FloatingInsertButton/InsertButton.tsx +6 -2
- package/src/ui/FloatingInsertButton/index.tsx +4 -2
- package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +53 -19
- package/src/ui/TableFloatingColumnControls/index.tsx +23 -11
- package/src/ui/TableFloatingControls/RowControls/DragControls.tsx +0 -10
- package/src/ui/common-styles.ts +6 -0
- package/src/utils/decoration.ts +41 -28
- package/src/utils/dom.ts +0 -23
- package/src/utils/index.ts +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 5.7.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#63290](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/63290) [`52ea8e908f57`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/52ea8e908f57) - ED-19613: Cleaned references for feature flag: platform.editor.table-remove-update-resize-handles_djvab.
|
|
8
|
+
- [#63606](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/63606) [`196f99e732d6`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/196f99e732d6) - [ux] Add support for drag handle for sticky header in table
|
|
9
|
+
- [#61531](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/61531) [`4f1e82618f55`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/4f1e82618f55) - [ux] fix in danger selection been re-calcuate with merged cells
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 5.7.2
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [#63416](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/63416) [`cfa23683ae92`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/cfa23683ae92) - update floating tool bar button
|
|
17
|
+
- [#63569](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/63569) [`bf5ed730bc99`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/bf5ed730bc99) - Use start position to calculate insert column buttons to cater for merged cells
|
|
18
|
+
|
|
3
19
|
## 5.7.1
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -561,6 +561,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
561
561
|
headerRowHeight: headerRow ? headerRow.offsetHeight : undefined,
|
|
562
562
|
stickyHeader: this.state.stickyHeader
|
|
563
563
|
});
|
|
564
|
+
var tableContainerWidth = (0, _nodeWidth.getTableContainerWidth)(node);
|
|
564
565
|
var colControls = isDragAndDropEnabled ? /*#__PURE__*/_react.default.createElement(_TableFloatingColumnControls.default, {
|
|
565
566
|
editorView: view,
|
|
566
567
|
tableRef: tableRef,
|
|
@@ -579,7 +580,9 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
579
580
|
headerRowHeight: headerRow ? headerRow.offsetHeight : undefined,
|
|
580
581
|
stickyHeader: this.state.stickyHeader,
|
|
581
582
|
canDrag: canDrag,
|
|
582
|
-
getEditorFeatureFlags: getEditorFeatureFlags
|
|
583
|
+
getEditorFeatureFlags: getEditorFeatureFlags,
|
|
584
|
+
tableContainerWidth: tableContainerWidth,
|
|
585
|
+
isNumberColumnEnabled: node.attrs.isNumberColumnEnabled
|
|
583
586
|
}) : null;
|
|
584
587
|
var shadowPadding = allowControls && tableActive ? -_editorSharedStyles.akEditorTableToolbarSize : _styles.tableMarginSides;
|
|
585
588
|
var shadowStyle = (0, _memoizeOne.default)(function (visible) {
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -359,7 +359,8 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
359
359
|
isOpen: !!(dragAndDropState !== null && dragAndDropState !== void 0 && dragAndDropState.isDragMenuOpen) && !isResizing,
|
|
360
360
|
canDrag: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.canDrag,
|
|
361
361
|
getEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
362
|
-
editorAnalyticsAPI: editorAnalyticsAPI
|
|
362
|
+
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
363
|
+
stickyHeaders: stickyHeader
|
|
363
364
|
}), allowControls && !isDragAndDropEnabled && !isResizing && /*#__PURE__*/_react.default.createElement(_FloatingDeleteButton.default, {
|
|
364
365
|
editorView: editorView,
|
|
365
366
|
selection: editorView.state.selection,
|
|
@@ -12,8 +12,6 @@ var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
|
12
12
|
var _transforms = require("@atlaskit/editor-common/transforms");
|
|
13
13
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
14
14
|
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
15
|
-
var _utils3 = require("@atlaskit/editor-tables/utils");
|
|
16
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
17
15
|
var _commands = require("../commands");
|
|
18
16
|
var _misc = require("../commands/misc");
|
|
19
17
|
var _eventHandlers = require("../event-handlers");
|
|
@@ -23,7 +21,7 @@ var _TableRow = _interopRequireDefault(require("../nodeviews/TableRow"));
|
|
|
23
21
|
var _plugin = require("../pm-plugins/decorations/plugin");
|
|
24
22
|
var _transforms2 = require("../transforms");
|
|
25
23
|
var _types = require("../types");
|
|
26
|
-
var
|
|
24
|
+
var _utils3 = require("../utils");
|
|
27
25
|
var _paste = require("../utils/paste");
|
|
28
26
|
var _defaultTableSelection = require("./default-table-selection");
|
|
29
27
|
var _pluginFactory = require("./plugin-factory");
|
|
@@ -114,24 +112,15 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatchAnalytic
|
|
|
114
112
|
var selection = state.selection;
|
|
115
113
|
var pluginState = (0, _pluginFactory.getPluginState)(state);
|
|
116
114
|
var tableRef;
|
|
117
|
-
var tableNode;
|
|
118
115
|
if (pluginState.editorHasFocus) {
|
|
119
116
|
var parent = (0, _utils2.findParentDomRefOfType)(state.schema.nodes.table, domAtPos)(selection);
|
|
120
117
|
if (parent) {
|
|
121
118
|
tableRef = parent.querySelector('table') || undefined;
|
|
122
119
|
}
|
|
123
|
-
tableNode = (0, _utils3.findTable)(state.selection);
|
|
124
120
|
}
|
|
125
121
|
if (pluginState.tableRef !== tableRef) {
|
|
126
122
|
(0, _commands.setTableRef)(tableRef)(state, dispatch);
|
|
127
123
|
}
|
|
128
|
-
|
|
129
|
-
// Removes updateResizeHandles
|
|
130
|
-
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.table-remove-update-resize-handles_djvab')) {} else {
|
|
131
|
-
if (pluginState.tableNode !== tableNode) {
|
|
132
|
-
(0, _utils4.updateResizeHandles)(tableRef);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
124
|
if (pluginState.editorHasFocus && pluginState.tableRef) {
|
|
136
125
|
var _ref = state.selection,
|
|
137
126
|
$cursor = _ref.$cursor;
|
|
@@ -167,7 +156,7 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatchAnalytic
|
|
|
167
156
|
if (!(0, _coreUtils.insideTable)(editorState) && (0, _paste.isHeaderRowRequired)(editorState)) {
|
|
168
157
|
slice = (0, _misc.transformSliceToAddTableHeaders)(slice, schema);
|
|
169
158
|
}
|
|
170
|
-
slice = (0,
|
|
159
|
+
slice = (0, _utils3.transformSliceToFixHardBreakProblemOnCopyFromCell)(slice, schema);
|
|
171
160
|
|
|
172
161
|
// We do this separately, so it also applies to drag/drop events
|
|
173
162
|
// This needs to go before `transformSliceToRemoveOpenExpand`
|
|
@@ -178,11 +167,11 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatchAnalytic
|
|
|
178
167
|
slice = (0, _transforms.transformSliceToRemoveOpenExpand)(slice, schema);
|
|
179
168
|
|
|
180
169
|
/** If a partial paste of table, paste only table's content */
|
|
181
|
-
slice = (0,
|
|
170
|
+
slice = (0, _utils3.transformSliceToRemoveOpenTable)(slice, schema);
|
|
182
171
|
|
|
183
172
|
/** If a partial paste of bodied extension, paste only text */
|
|
184
173
|
slice = (0, _transforms.transformSliceToRemoveOpenBodiedExtension)(slice, schema);
|
|
185
|
-
slice = (0,
|
|
174
|
+
slice = (0, _utils3.transformSliceToCorrectEmptyTableCells)(slice, schema);
|
|
186
175
|
if (!pluginConfig.allowColumnResizing) {
|
|
187
176
|
slice = (0, _misc.transformSliceToRemoveColumnsWidths)(slice, schema);
|
|
188
177
|
}
|
|
@@ -198,7 +187,7 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatchAnalytic
|
|
|
198
187
|
var state = _ref2.state,
|
|
199
188
|
dispatch = _ref2.dispatch;
|
|
200
189
|
var decorationSet = _plugin.pluginKey.getState(state);
|
|
201
|
-
if ((0,
|
|
190
|
+
if ((0, _utils3.findControlsHoverDecoration)(decorationSet).length) {
|
|
202
191
|
(0, _commands.clearHoverSelection)()(state, dispatch);
|
|
203
192
|
}
|
|
204
193
|
|
|
@@ -151,10 +151,6 @@ var handleMouseDown = exports.handleMouseDown = function handleMouseDown(view, e
|
|
|
151
151
|
var colIndex = map.colCount($cell.pos - $cell.start(-1)) + $cell.nodeAfter.attrs.colspan - 1;
|
|
152
152
|
(0, _utils3.resizeColumn)(resizeState, colIndex, clientX - dragging.startX, dom);
|
|
153
153
|
(0, _utils3.updateControls)()(state);
|
|
154
|
-
// Remove updateResizeHandles
|
|
155
|
-
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.table-remove-update-resize-handles_djvab')) {} else {
|
|
156
|
-
(0, _utils2.updateResizeHandles)(dom);
|
|
157
|
-
}
|
|
158
154
|
}
|
|
159
155
|
window.addEventListener('mouseup', finish);
|
|
160
156
|
window.addEventListener('mousemove', move);
|
package/dist/cjs/toolbar.js
CHANGED
|
@@ -5,7 +5,7 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.getToolbarMenuConfig = exports.getToolbarConfig = exports.getToolbarCellOptionsConfig = exports.getClosestSelectionRect = void 0;
|
|
8
|
+
exports.getToolbarMenuConfig = exports.getToolbarConfig = exports.getToolbarCellOptionsConfig = exports.getDistributeConfig = exports.getClosestSelectionRect = exports.getClosestSelectionOrTableRect = void 0;
|
|
9
9
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
10
10
|
var _react = require("@emotion/react");
|
|
11
11
|
var _customSteps = require("@atlaskit/custom-steps");
|
|
@@ -17,8 +17,12 @@ var _utils = require("@atlaskit/editor-common/utils");
|
|
|
17
17
|
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
18
18
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
19
19
|
var _shortcut = require("@atlaskit/editor-shared-styles/shortcut");
|
|
20
|
+
var _tableMap = require("@atlaskit/editor-tables/table-map");
|
|
20
21
|
var _utils3 = require("@atlaskit/editor-tables/utils");
|
|
22
|
+
var _layoutThreeEqual = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/layout-three-equal"));
|
|
21
23
|
var _remove = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/remove"));
|
|
24
|
+
var _preferences = _interopRequireDefault(require("@atlaskit/icon/glyph/preferences"));
|
|
25
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
22
26
|
var _commands = require("./commands");
|
|
23
27
|
var _commandsWithAnalytics = require("./commands-with-analytics");
|
|
24
28
|
var _pluginFactory = require("./pm-plugins/plugin-factory");
|
|
@@ -60,16 +64,30 @@ var getToolbarMenuConfig = exports.getToolbarMenuConfig = function getToolbarMen
|
|
|
60
64
|
disabled: !state.canCollapseTable,
|
|
61
65
|
hidden: !config.allowCollapse
|
|
62
66
|
}];
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
67
|
+
if (state.isDragAndDropEnabled && (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.new-cell-context-menu-styling')) {
|
|
68
|
+
return {
|
|
69
|
+
id: 'editor.table.tableOptions',
|
|
70
|
+
type: 'dropdown',
|
|
71
|
+
testId: 'table_options',
|
|
72
|
+
icon: _preferences.default,
|
|
73
|
+
title: formatMessage(_messages.tableMessages.tableOptions),
|
|
74
|
+
hidden: options.every(function (option) {
|
|
75
|
+
return option.hidden;
|
|
76
|
+
}),
|
|
77
|
+
options: options
|
|
78
|
+
};
|
|
79
|
+
} else {
|
|
80
|
+
return {
|
|
81
|
+
id: 'editor.table.tableOptions',
|
|
82
|
+
type: 'dropdown',
|
|
83
|
+
testId: 'table_options',
|
|
84
|
+
title: formatMessage(_messages.tableMessages.tableOptions),
|
|
85
|
+
hidden: options.every(function (option) {
|
|
86
|
+
return option.hidden;
|
|
87
|
+
}),
|
|
88
|
+
options: options
|
|
89
|
+
};
|
|
90
|
+
}
|
|
73
91
|
};
|
|
74
92
|
|
|
75
93
|
// Added these options for mobile. Mobile bridge translates this menu and
|
|
@@ -268,6 +286,16 @@ var getClosestSelectionRect = exports.getClosestSelectionRect = function getClos
|
|
|
268
286
|
var selection = state.selection;
|
|
269
287
|
return (0, _utils3.isSelectionType)(selection, 'cell') ? (0, _utils3.getSelectionRect)(selection) : (0, _utils3.findCellRectClosestToPos)(selection.$from);
|
|
270
288
|
};
|
|
289
|
+
var getClosestSelectionOrTableRect = exports.getClosestSelectionOrTableRect = function getClosestSelectionOrTableRect(state) {
|
|
290
|
+
var selection = state.selection;
|
|
291
|
+
var tableObject = (0, _utils3.findTable)(state.selection);
|
|
292
|
+
if (!tableObject) {
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
var map = _tableMap.TableMap.get(tableObject.node);
|
|
296
|
+
var tableRect = new _tableMap.Rect(0, 0, map.width, map.height);
|
|
297
|
+
return (0, _utils3.isSelectionType)(selection, 'cell') ? (0, _utils3.getSelectionRect)(selection) : tableRect;
|
|
298
|
+
};
|
|
271
299
|
var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(getEditorContainerWidth, editorAnalyticsAPI, getEditorFeatureFlags, getEditorView) {
|
|
272
300
|
return function (config) {
|
|
273
301
|
return function (state, intl) {
|
|
@@ -283,6 +311,8 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(getE
|
|
|
283
311
|
var menu = getToolbarMenuConfig(config, pluginState, intl, editorAnalyticsAPI);
|
|
284
312
|
var cellItems;
|
|
285
313
|
cellItems = pluginState.isDragAndDropEnabled ? [] : getCellItems(config, state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI);
|
|
314
|
+
var columnSettingsItems;
|
|
315
|
+
columnSettingsItems = pluginState.isDragAndDropEnabled && (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.new-cell-context-menu-styling') ? getColumnSettingItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI) : [];
|
|
286
316
|
var colorPicker = getColorPicker(state, menu, intl, editorAnalyticsAPI);
|
|
287
317
|
|
|
288
318
|
// Check if we need to show confirm dialog for delete button
|
|
@@ -335,7 +365,7 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(getE
|
|
|
335
365
|
},
|
|
336
366
|
zIndex: _editorSharedStyles.akEditorFloatingPanelZIndex + 1,
|
|
337
367
|
// Place the context menu slightly above the others
|
|
338
|
-
items: [menu, separator(menu.hidden)].concat((0, _toConsumableArray2.default)(cellItems), colorPicker, [{
|
|
368
|
+
items: [menu, separator(menu.hidden)].concat((0, _toConsumableArray2.default)(cellItems), (0, _toConsumableArray2.default)(columnSettingsItems), colorPicker, [{
|
|
339
369
|
type: 'extensions-placeholder',
|
|
340
370
|
separator: 'end'
|
|
341
371
|
}, {
|
|
@@ -390,9 +420,52 @@ var getCellItems = function getCellItems(pluginConfig, state, view, _ref3, getEd
|
|
|
390
420
|
}
|
|
391
421
|
return [];
|
|
392
422
|
};
|
|
393
|
-
var
|
|
394
|
-
|
|
423
|
+
var getDistributeConfig = exports.getDistributeConfig = function getDistributeConfig(getEditorContainerWidth, editorAnalyticsAPI) {
|
|
424
|
+
return function (state, dispatch, editorView) {
|
|
425
|
+
var selectionOrTableRect = getClosestSelectionOrTableRect(state);
|
|
426
|
+
if (!editorView || !selectionOrTableRect) {
|
|
427
|
+
return false;
|
|
428
|
+
}
|
|
429
|
+
var newResizeStateWithAnalytics = (0, _resizeState.getNewResizeStateFromSelectedColumns)(selectionOrTableRect, state, editorView.domAtPos.bind(editorView), getEditorContainerWidth);
|
|
430
|
+
if (newResizeStateWithAnalytics) {
|
|
431
|
+
(0, _commandsWithAnalytics.distributeColumnsWidthsWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.FLOATING_TB, newResizeStateWithAnalytics)(state, dispatch);
|
|
432
|
+
return true;
|
|
433
|
+
}
|
|
434
|
+
return false;
|
|
435
|
+
};
|
|
436
|
+
};
|
|
437
|
+
|
|
438
|
+
// this create the button group for distribute column and also fixed column width
|
|
439
|
+
// fixed column button should be in this function call in the future
|
|
440
|
+
var getColumnSettingItems = function getColumnSettingItems(editorState, editorView, _ref4, getEditorContainerWidth, editorAnalyticsAPI) {
|
|
441
|
+
var _newResizeStateWithAn2, _pluginState$pluginCo3;
|
|
395
442
|
var formatMessage = _ref4.formatMessage;
|
|
443
|
+
var pluginState = (0, _pluginFactory.getPluginState)(editorState);
|
|
444
|
+
var selectionOrTableRect = getClosestSelectionOrTableRect(editorState);
|
|
445
|
+
if (!selectionOrTableRect || !editorView) {
|
|
446
|
+
return [];
|
|
447
|
+
}
|
|
448
|
+
var newResizeStateWithAnalytics = (0, _resizeState.getNewResizeStateFromSelectedColumns)(selectionOrTableRect, editorState, editorView.domAtPos.bind(editorView), getEditorContainerWidth);
|
|
449
|
+
var wouldChange = (_newResizeStateWithAn2 = newResizeStateWithAnalytics === null || newResizeStateWithAnalytics === void 0 ? void 0 : newResizeStateWithAnalytics.changed) !== null && _newResizeStateWithAn2 !== void 0 ? _newResizeStateWithAn2 : false;
|
|
450
|
+
if (pluginState !== null && pluginState !== void 0 && (_pluginState$pluginCo3 = pluginState.pluginConfig) !== null && _pluginState$pluginCo3 !== void 0 && _pluginState$pluginCo3.allowDistributeColumns && pluginState.isDragAndDropEnabled) {
|
|
451
|
+
return [{
|
|
452
|
+
id: 'editor.table.distributeColumns',
|
|
453
|
+
type: 'button',
|
|
454
|
+
title: formatMessage(_messages.tableMessages.distributeColumns),
|
|
455
|
+
icon: _layoutThreeEqual.default,
|
|
456
|
+
onClick: function onClick(state, dispatch, view) {
|
|
457
|
+
return getDistributeConfig(getEditorContainerWidth, editorAnalyticsAPI)(state, dispatch, view);
|
|
458
|
+
},
|
|
459
|
+
disabled: !wouldChange
|
|
460
|
+
}, {
|
|
461
|
+
type: 'separator'
|
|
462
|
+
}];
|
|
463
|
+
}
|
|
464
|
+
return [];
|
|
465
|
+
};
|
|
466
|
+
var getColorPicker = function getColorPicker(state, menu, _ref5, editorAnalyticsAPI) {
|
|
467
|
+
var _node$attrs;
|
|
468
|
+
var formatMessage = _ref5.formatMessage;
|
|
396
469
|
var _getPluginState2 = (0, _pluginFactory.getPluginState)(state),
|
|
397
470
|
targetCellPosition = _getPluginState2.targetCellPosition,
|
|
398
471
|
pluginConfig = _getPluginState2.pluginConfig;
|
package/dist/cjs/types.js
CHANGED
|
@@ -122,8 +122,6 @@ var TableCssClassName = exports.TableCssClassName = _objectSpread(_objectSpread(
|
|
|
122
122
|
RESIZING_PLUGIN: "".concat(_adfSchema.tablePrefixSelector, "-resizing-plugin"),
|
|
123
123
|
RESIZE_CURSOR: "".concat(_adfSchema.tablePrefixSelector, "-resize-cursor"),
|
|
124
124
|
IS_RESIZING: "".concat(_adfSchema.tablePrefixSelector, "-is-resizing"),
|
|
125
|
-
// Resize handle is going to be removed together with updateResizeHandles - table's utility function
|
|
126
|
-
RESIZE_HANDLE: "".concat(_adfSchema.tablePrefixSelector, "-resize-handle"),
|
|
127
125
|
RESIZE_HANDLE_DECORATION: "".concat(_adfSchema.tablePrefixSelector, "-resize-decoration"),
|
|
128
126
|
CONTEXTUAL_SUBMENU: "".concat(_adfSchema.tablePrefixSelector, "-contextual-submenu"),
|
|
129
127
|
CONTEXTUAL_MENU_BUTTON_WRAP: "".concat(_adfSchema.tablePrefixSelector, "-contextual-menu-button-wrap"),
|
|
@@ -23,10 +23,12 @@ var FloatingDragMenu = function FloatingDragMenu(_ref) {
|
|
|
23
23
|
targetCellPosition = _ref.targetCellPosition,
|
|
24
24
|
getEditorContainerWidth = _ref.getEditorContainerWidth,
|
|
25
25
|
canDrag = _ref.canDrag,
|
|
26
|
-
editorAnalyticsAPI = _ref.editorAnalyticsAPI
|
|
26
|
+
editorAnalyticsAPI = _ref.editorAnalyticsAPI,
|
|
27
|
+
stickyHeaders = _ref.stickyHeaders;
|
|
27
28
|
if (!isOpen || !targetCellPosition || editorView.state.doc.nodeSize <= targetCellPosition) {
|
|
28
29
|
return null;
|
|
29
30
|
}
|
|
31
|
+
var inStickyMode = stickyHeaders === null || stickyHeaders === void 0 ? void 0 : stickyHeaders.sticky;
|
|
30
32
|
var targetHandleRef = direction === 'row' ? document.querySelector('#drag-handle-button-row') : document.querySelector('#drag-handle-button-column');
|
|
31
33
|
if (!targetHandleRef || !(editorView.state.selection instanceof _cellSelection.CellSelection)) {
|
|
32
34
|
return null;
|
|
@@ -44,8 +46,9 @@ var FloatingDragMenu = function FloatingDragMenu(_ref) {
|
|
|
44
46
|
fitWidth: _consts.dragMenuDropdownWidth
|
|
45
47
|
// z-index value below is to ensure that this menu is above other floating menu
|
|
46
48
|
// in table, but below floating dialogs like typeaheads, pickers, etc.
|
|
49
|
+
// In sticky mode, we want to show the menu above the sticky header
|
|
47
50
|
,
|
|
48
|
-
zIndex: _editorSharedStyles.akEditorFloatingOverlapPanelZIndex,
|
|
51
|
+
zIndex: inStickyMode ? _editorSharedStyles.akEditorFloatingDialogZIndex : _editorSharedStyles.akEditorFloatingOverlapPanelZIndex,
|
|
49
52
|
forcePlacement: true,
|
|
50
53
|
offset: offset,
|
|
51
54
|
stick: true
|
|
@@ -19,12 +19,12 @@ var _types = require("../../types");
|
|
|
19
19
|
var _consts = require("../consts");
|
|
20
20
|
/* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
|
|
21
21
|
|
|
22
|
-
var getInsertLineHeight = function getInsertLineHeight(tableRef, hasStickyHeaders) {
|
|
22
|
+
var getInsertLineHeight = function getInsertLineHeight(tableRef, hasStickyHeaders, isDragAndDropEnabled) {
|
|
23
23
|
// The line gets height 100% from the table,
|
|
24
24
|
// but since we have an overflow on the left,
|
|
25
25
|
// we should add an offset to make up for it.
|
|
26
26
|
var LINE_OFFSET = 3;
|
|
27
|
-
var ADDITIONAL_HEIGHT = hasStickyHeaders ? tableRef.getBoundingClientRect().top - _styles.tableMarginTop * 4 - LINE_OFFSET : _consts.tableToolbarSize + LINE_OFFSET;
|
|
27
|
+
var ADDITIONAL_HEIGHT = hasStickyHeaders ? tableRef.getBoundingClientRect().top - _styles.tableMarginTop * (isDragAndDropEnabled ? 3 : 4) - LINE_OFFSET : _consts.tableToolbarSize + LINE_OFFSET;
|
|
28
28
|
return tableRef.offsetHeight + ADDITIONAL_HEIGHT;
|
|
29
29
|
};
|
|
30
30
|
var getToolbarSize = function getToolbarSize(tableRef) {
|
|
@@ -89,7 +89,7 @@ var InsertButtonForDragAndDrop = exports.InsertButtonForDragAndDrop = function I
|
|
|
89
89
|
width: getInsertLineWidth(tableRef, true),
|
|
90
90
|
left: "var(--ds-space-150, 12px)"
|
|
91
91
|
} : {
|
|
92
|
-
height: getInsertLineHeight(tableRef, hasStickyHeaders) - 8,
|
|
92
|
+
height: getInsertLineHeight(tableRef, hasStickyHeaders, true) - 8,
|
|
93
93
|
top: '-3px'
|
|
94
94
|
}
|
|
95
95
|
})));
|
|
@@ -126,7 +126,7 @@ var FloatingInsertButton = exports.FloatingInsertButton = /*#__PURE__*/function
|
|
|
126
126
|
// By setting the Popup z-index higher than the sticky header z-index ( common-styles.ts tr.sticky)
|
|
127
127
|
// Only when inserting a column, otherwise set to undefined
|
|
128
128
|
// Need to set z-index in the Popup, set z-index in the <InsertButton /> will not work
|
|
129
|
-
var zIndex = type === 'column' ? _editorSharedStyles.
|
|
129
|
+
var zIndex = type === 'column' ? _editorSharedStyles.akEditorTableInsertButtonOnStickyHeaderZIndex : undefined;
|
|
130
130
|
return /*#__PURE__*/_react.default.createElement(_ui.Popup, (0, _extends2.default)({
|
|
131
131
|
target: targetCellRef,
|
|
132
132
|
mountTo: tableContainerWrapper || mountPoint,
|
|
@@ -7,12 +7,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = exports.ColumnControls = void 0;
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
10
|
+
var _utils = require("@atlaskit/editor-common/utils");
|
|
11
|
+
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
10
12
|
var _editorTables = require("@atlaskit/editor-tables");
|
|
11
|
-
var
|
|
13
|
+
var _utils2 = require("@atlaskit/editor-tables/utils");
|
|
12
14
|
var _commands = require("../../../commands");
|
|
13
15
|
var _commands2 = require("../../../pm-plugins/drag-and-drop/commands");
|
|
14
16
|
var _types = require("../../../types");
|
|
15
|
-
var
|
|
17
|
+
var _utils3 = require("../../../utils");
|
|
16
18
|
var _DragHandle = require("../../DragHandle");
|
|
17
19
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
18
20
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -20,16 +22,16 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
20
22
|
|
|
21
23
|
var getSelectedColumns = function getSelectedColumns(selection) {
|
|
22
24
|
if (selection instanceof _editorTables.CellSelection && selection.isColSelection()) {
|
|
23
|
-
var rect = (0,
|
|
25
|
+
var rect = (0, _utils2.getSelectionRect)(selection);
|
|
24
26
|
if (!rect) {
|
|
25
27
|
return [];
|
|
26
28
|
}
|
|
27
|
-
return (0,
|
|
29
|
+
return (0, _utils3.getSelectedColumnIndexes)(rect);
|
|
28
30
|
}
|
|
29
31
|
return [];
|
|
30
32
|
};
|
|
31
33
|
var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
|
|
32
|
-
var _colWidths$map$join, _rowHeights
|
|
34
|
+
var _colWidths$map$join, _rowHeights$;
|
|
33
35
|
var editorView = _ref.editorView,
|
|
34
36
|
tableActive = _ref.tableActive,
|
|
35
37
|
tableRef = _ref.tableRef,
|
|
@@ -42,12 +44,19 @@ var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
|
|
|
42
44
|
colWidths = _ref.colWidths,
|
|
43
45
|
hasHeaderColumn = _ref.hasHeaderColumn,
|
|
44
46
|
isTableHovered = _ref.isTableHovered,
|
|
45
|
-
canDrag = _ref.canDrag
|
|
47
|
+
canDrag = _ref.canDrag,
|
|
48
|
+
tableContainerWidth = _ref.tableContainerWidth,
|
|
49
|
+
isNumberColumnEnabled = _ref.isNumberColumnEnabled;
|
|
50
|
+
var columnControlsRef = (0, _react.useRef)(null);
|
|
46
51
|
var widths = (_colWidths$map$join = colWidths === null || colWidths === void 0 ? void 0 : colWidths.map(function (width) {
|
|
47
|
-
return
|
|
52
|
+
return (
|
|
53
|
+
// when there is sticky header, a `margin-right: -1px` applied to `tr.sticky th` so it causes colWidths to be 1px wider
|
|
54
|
+
// we need to reduce the width by 1px to avoid misalignment of column controls.
|
|
55
|
+
width ? stickyTop ? "".concat(width - 2, "px") : "".concat(width - 1, "px") : '0px'
|
|
56
|
+
);
|
|
48
57
|
}).join(' ')) !== null && _colWidths$map$join !== void 0 ? _colWidths$map$join : '0px';
|
|
49
58
|
// TODO: reusing getRowsParams here because it's generic enough to work for columns -> rename
|
|
50
|
-
var columnParams = (0,
|
|
59
|
+
var columnParams = (0, _utils3.getRowsParams)(colWidths !== null && colWidths !== void 0 ? colWidths : []);
|
|
51
60
|
var colIndex = hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.colIndex;
|
|
52
61
|
var selectedColIndexes = getSelectedColumns(editorView.state.selection);
|
|
53
62
|
var firstRow = tableRef.querySelector('tr');
|
|
@@ -104,16 +113,34 @@ var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
|
|
|
104
113
|
var colIndexes = (0, _react.useMemo)(function () {
|
|
105
114
|
return [colIndex];
|
|
106
115
|
}, [colIndex]);
|
|
107
|
-
var
|
|
108
|
-
|
|
109
|
-
|
|
116
|
+
var tableWrapper = (0, _utils.closestElement)(tableRef, ".".concat(_types.TableCssClassName.TABLE_NODE_WRAPPER));
|
|
117
|
+
var handleScroll = (0, _react.useCallback)(function (event) {
|
|
118
|
+
if (stickyTop) {
|
|
119
|
+
if (columnControlsRef && columnControlsRef.current) {
|
|
120
|
+
var _tableWrapper$scrollL;
|
|
121
|
+
columnControlsRef.current.scrollLeft = (_tableWrapper$scrollL = tableWrapper === null || tableWrapper === void 0 ? void 0 : tableWrapper.scrollLeft) !== null && _tableWrapper$scrollL !== void 0 ? _tableWrapper$scrollL : 0;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}, [stickyTop, tableWrapper]);
|
|
125
|
+
(0, _react.useEffect)(function () {
|
|
126
|
+
handleScroll();
|
|
127
|
+
}, [handleScroll]);
|
|
128
|
+
(0, _react.useEffect)(function () {
|
|
129
|
+
tableWrapper === null || tableWrapper === void 0 || tableWrapper.addEventListener('scroll', handleScroll);
|
|
130
|
+
return function () {
|
|
131
|
+
tableWrapper === null || tableWrapper === void 0 || tableWrapper.removeEventListener('scroll', handleScroll);
|
|
132
|
+
};
|
|
133
|
+
}, [tableWrapper, handleScroll]);
|
|
110
134
|
var generateHandleByType = function generateHandleByType(type) {
|
|
111
|
-
var _colWidths;
|
|
135
|
+
var _rowHeights$reduce, _colWidths;
|
|
112
136
|
if (!hoveredCell || !(colWidths !== null && colWidths !== void 0 && colWidths.length)) {
|
|
113
137
|
return null;
|
|
114
138
|
}
|
|
115
139
|
var isHover = type === 'hover';
|
|
116
140
|
var isColumnsSelected = selectedColIndexes.length > 0;
|
|
141
|
+
var previewHeight = (_rowHeights$reduce = rowHeights === null || rowHeights === void 0 ? void 0 : rowHeights.reduce(function (sum, cur) {
|
|
142
|
+
return sum + cur;
|
|
143
|
+
}, 0)) !== null && _rowHeights$reduce !== void 0 ? _rowHeights$reduce : 0;
|
|
117
144
|
var showCondition = isHover ? isColumnsSelected && !selectedColIndexes.includes(colIndex) && Number.isFinite(hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.colIndex) : selectedColIndexes.length < (colWidths === null || colWidths === void 0 ? void 0 : colWidths.length) && Number.isFinite(hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.colIndex);
|
|
118
145
|
if (!showCondition) {
|
|
119
146
|
return null;
|
|
@@ -121,15 +148,15 @@ var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
|
|
|
121
148
|
var gridColumnPosition = "".concat(colIndex + 1, " / span 1");
|
|
122
149
|
var selectedColumnPosition = "".concat(selectedColIndexes[0] + 1, " / span ").concat(selectedColIndexes.length);
|
|
123
150
|
var hoveredAppearance = selectedColIndexes.includes(colIndex) ? isInDanger ? 'danger' : 'selected' : 'default';
|
|
124
|
-
var
|
|
125
|
-
var
|
|
151
|
+
var currentSelectionAppearance = isColumnsSelected ? isInDanger ? 'danger' : 'selected' : hoveredAppearance;
|
|
152
|
+
var isSelecting = isColumnsSelected && !isHover;
|
|
126
153
|
|
|
127
154
|
// this indexes are used to calculate the drag and drop source
|
|
128
155
|
var indexes = isColumnsSelected ? isHover ? colIndexes : selectedColIndexes : colIndexes;
|
|
129
156
|
return showCondition && /*#__PURE__*/_react.default.createElement("div", {
|
|
130
157
|
key: type,
|
|
131
158
|
style: {
|
|
132
|
-
gridColumn:
|
|
159
|
+
gridColumn: isSelecting ? selectedColumnPosition : gridColumnPosition,
|
|
133
160
|
display: 'flex',
|
|
134
161
|
justifyContent: 'center',
|
|
135
162
|
alignItems: 'center',
|
|
@@ -147,7 +174,7 @@ var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
|
|
|
147
174
|
forceDefaultHandle: isHover ? false : isColumnsSelected,
|
|
148
175
|
previewWidth: (_colWidths = colWidths === null || colWidths === void 0 ? void 0 : colWidths[colIndex]) !== null && _colWidths !== void 0 ? _colWidths : _styles.tableCellMinWidth,
|
|
149
176
|
previewHeight: previewHeight,
|
|
150
|
-
appearance:
|
|
177
|
+
appearance: isSelecting ? currentSelectionAppearance : hoveredAppearance,
|
|
151
178
|
onClick: handleClick,
|
|
152
179
|
onMouseOver: handleMouseOver,
|
|
153
180
|
onMouseOut: handleMouseOut,
|
|
@@ -166,22 +193,26 @@ var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
|
|
|
166
193
|
var sortedHandles = [generateHandleByType('hover'), generateHandleByType('selected')];
|
|
167
194
|
return hoveredCell.colIndex < selectedColIndexes[0] ? sortedHandles : sortedHandles.reverse();
|
|
168
195
|
};
|
|
196
|
+
var containerWidth = isNumberColumnEnabled && tableContainerWidth ? tableContainerWidth - _editorSharedStyles.akEditorTableNumberColumnWidth : tableContainerWidth;
|
|
169
197
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
170
198
|
className: _types.TableCssClassName.DRAG_COLUMN_CONTROLS,
|
|
171
199
|
onMouseMove: handleMouseMove
|
|
172
200
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
201
|
+
ref: columnControlsRef,
|
|
173
202
|
className: _types.TableCssClassName.DRAG_COLUMN_CONTROLS_INNER,
|
|
174
203
|
"data-testid": "table-floating-column-controls",
|
|
175
204
|
style: {
|
|
176
205
|
gridTemplateColumns: widths,
|
|
177
|
-
marginTop: marginTop
|
|
206
|
+
marginTop: marginTop,
|
|
207
|
+
width: stickyTop ? containerWidth : undefined,
|
|
208
|
+
overflowX: stickyTop ? 'hidden' : 'visible'
|
|
178
209
|
}
|
|
179
210
|
}, !isResizing && columnParams.map(function (_ref2, index) {
|
|
180
211
|
var startIndex = _ref2.startIndex,
|
|
181
212
|
endIndex = _ref2.endIndex;
|
|
182
213
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
183
214
|
style: {
|
|
184
|
-
gridColumn: "".concat(
|
|
215
|
+
gridColumn: "".concat(startIndex + 1, " / span 1")
|
|
185
216
|
},
|
|
186
217
|
"data-start-index": startIndex,
|
|
187
218
|
"data-end-index": endIndex,
|
|
@@ -30,7 +30,9 @@ var TableFloatingColumnControls = exports.TableFloatingColumnControls = function
|
|
|
30
30
|
selection = _ref.selection,
|
|
31
31
|
isInDanger = _ref.isInDanger,
|
|
32
32
|
isTableHovered = _ref.isTableHovered,
|
|
33
|
-
canDrag = _ref.canDrag
|
|
33
|
+
canDrag = _ref.canDrag,
|
|
34
|
+
tableContainerWidth = _ref.tableContainerWidth,
|
|
35
|
+
isNumberColumnEnabled = _ref.isNumberColumnEnabled;
|
|
34
36
|
var _useState = (0, _react.useState)({
|
|
35
37
|
width: 0,
|
|
36
38
|
height: 0
|
|
@@ -42,9 +44,11 @@ var TableFloatingColumnControls = exports.TableFloatingColumnControls = function
|
|
|
42
44
|
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
43
45
|
hasDropTargets = _useState4[0],
|
|
44
46
|
setHasDropTargets = _useState4[1];
|
|
47
|
+
var containerRef = (0, _react.useRef)(null);
|
|
45
48
|
var node = getNode();
|
|
46
49
|
var currentNodeLocalId = node === null || node === void 0 ? void 0 : node.attrs.localId;
|
|
47
50
|
var hasHeaderColumn = (0, _utils.containsHeaderColumn)(node);
|
|
51
|
+
var stickyTop = stickyHeader && stickyHeader.sticky && hasHeaderRow ? stickyHeader.top : undefined;
|
|
48
52
|
(0, _react.useEffect)(function () {
|
|
49
53
|
var _window;
|
|
50
54
|
if (tableRef && (_window = window) !== null && _window !== void 0 && _window.ResizeObserver) {
|
|
@@ -105,14 +109,17 @@ var TableFloatingColumnControls = exports.TableFloatingColumnControls = function
|
|
|
105
109
|
return null;
|
|
106
110
|
}
|
|
107
111
|
var colWidths = (0, _utils.getColumnsWidths)(editorView);
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
112
|
+
if (stickyTop) {
|
|
113
|
+
var _rowHeights$, _containerRef$current;
|
|
114
|
+
var headerRowHeight = hasHeaderRow && stickyTop !== undefined ? (_rowHeights$ = rowHeights === null || rowHeights === void 0 ? void 0 : rowHeights[0]) !== null && _rowHeights$ !== void 0 ? _rowHeights$ : 0 : 0;
|
|
115
|
+
containerRef === null || containerRef === void 0 || (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 || _containerRef$current.style.setProperty('top', "".concat(stickyTop - headerRowHeight + 33, "px") // 33px is padding and margin applied on tr.sticky
|
|
116
|
+
);
|
|
117
|
+
} else {
|
|
118
|
+
var _containerRef$current2;
|
|
119
|
+
containerRef === null || containerRef === void 0 || (_containerRef$current2 = containerRef.current) === null || _containerRef$current2 === void 0 || _containerRef$current2.style.removeProperty('top');
|
|
114
120
|
}
|
|
115
121
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
122
|
+
ref: containerRef,
|
|
116
123
|
className: _types.TableCssClassName.DRAG_COLUMN_CONTROLS_WRAPPER,
|
|
117
124
|
"data-testid": "table-floating-column-controls-wrapper"
|
|
118
125
|
}, /*#__PURE__*/_react.default.createElement(_ColumnControls.ColumnControls, {
|
|
@@ -128,7 +135,9 @@ var TableFloatingColumnControls = exports.TableFloatingColumnControls = function
|
|
|
128
135
|
rowHeights: rowHeights,
|
|
129
136
|
colWidths: colWidths,
|
|
130
137
|
hasHeaderColumn: hasHeaderColumn,
|
|
131
|
-
canDrag: canDrag
|
|
138
|
+
canDrag: canDrag,
|
|
139
|
+
tableContainerWidth: tableContainerWidth,
|
|
140
|
+
isNumberColumnEnabled: isNumberColumnEnabled
|
|
132
141
|
}), hasDropTargets && /*#__PURE__*/_react.default.createElement(_ColumnDropTargets.ColumnDropTargets, {
|
|
133
142
|
tableRef: tableRef,
|
|
134
143
|
stickyTop: tableActive ? stickyTop : undefined,
|