@atlaskit/editor-plugin-table 7.4.8 → 7.5.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 +12 -0
- package/dist/cjs/commands/column-resize.js +4 -2
- package/dist/cjs/commands/delete.js +2 -1
- package/dist/cjs/commands/insert.js +6 -3
- package/dist/cjs/commands-with-analytics.js +4 -2
- package/dist/cjs/event-handlers.js +2 -1
- package/dist/cjs/nodeviews/TableComponent.js +116 -47
- package/dist/cjs/nodeviews/TableContainer.js +8 -4
- package/dist/cjs/nodeviews/TableResizer.js +6 -5
- package/dist/cjs/nodeviews/table.js +12 -4
- package/dist/cjs/plugin.js +50 -47
- package/dist/cjs/pm-plugins/drag-and-drop/plugin.js +9 -6
- package/dist/cjs/pm-plugins/keymap.js +6 -3
- package/dist/cjs/pm-plugins/main.js +4 -1
- package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +7 -3
- package/dist/cjs/pm-plugins/table-resizing/utils/colgroup.js +32 -11
- package/dist/cjs/pm-plugins/table-resizing/utils/consts.js +4 -2
- package/dist/cjs/pm-plugins/table-resizing/utils/index.js +24 -0
- package/dist/cjs/pm-plugins/table-resizing/utils/misc.js +20 -1
- package/dist/cjs/pm-plugins/table-resizing/utils/resize-column.js +2 -1
- package/dist/cjs/pm-plugins/table-resizing/utils/resize-state.js +52 -11
- package/dist/cjs/pm-plugins/table-resizing/utils/scale-table.js +19 -8
- package/dist/cjs/toolbar.js +17 -10
- package/dist/cjs/transforms/column-width.js +22 -7
- package/dist/cjs/transforms/delete-columns.js +2 -1
- package/dist/cjs/ui/FloatingContextualMenu/ContextualMenu.js +45 -38
- package/dist/cjs/ui/FloatingContextualMenu/index.js +5 -3
- package/dist/cjs/ui/FloatingDragMenu/DragMenu.js +15 -4
- package/dist/cjs/ui/FloatingDragMenu/DropdownMenu.js +53 -8
- package/dist/cjs/ui/FloatingDragMenu/index.js +15 -6
- package/dist/cjs/ui/FloatingInsertButton/index.js +5 -1
- package/dist/cjs/ui/consts.js +2 -1
- package/dist/cjs/utils/create.js +1 -1
- package/dist/cjs/utils/drag-menu.js +4 -3
- package/dist/es2019/commands/column-resize.js +4 -3
- package/dist/es2019/commands/delete.js +2 -2
- package/dist/es2019/commands/insert.js +6 -6
- package/dist/es2019/commands-with-analytics.js +4 -4
- package/dist/es2019/event-handlers.js +2 -2
- package/dist/es2019/nodeviews/TableComponent.js +77 -8
- package/dist/es2019/nodeviews/TableContainer.js +8 -4
- package/dist/es2019/nodeviews/TableResizer.js +6 -5
- package/dist/es2019/nodeviews/table.js +12 -4
- package/dist/es2019/plugin.js +14 -8
- package/dist/es2019/pm-plugins/drag-and-drop/plugin.js +7 -4
- package/dist/es2019/pm-plugins/keymap.js +6 -3
- package/dist/es2019/pm-plugins/main.js +4 -1
- package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +7 -3
- package/dist/es2019/pm-plugins/table-resizing/utils/colgroup.js +31 -12
- package/dist/es2019/pm-plugins/table-resizing/utils/consts.js +3 -1
- package/dist/es2019/pm-plugins/table-resizing/utils/index.js +2 -2
- package/dist/es2019/pm-plugins/table-resizing/utils/misc.js +20 -2
- package/dist/es2019/pm-plugins/table-resizing/utils/resize-column.js +2 -2
- package/dist/es2019/pm-plugins/table-resizing/utils/resize-state.js +47 -10
- package/dist/es2019/pm-plugins/table-resizing/utils/scale-table.js +19 -12
- package/dist/es2019/toolbar.js +15 -12
- package/dist/es2019/transforms/column-width.js +24 -10
- package/dist/es2019/transforms/delete-columns.js +2 -2
- package/dist/es2019/ui/FloatingContextualMenu/ContextualMenu.js +12 -5
- package/dist/es2019/ui/FloatingContextualMenu/index.js +6 -4
- package/dist/es2019/ui/FloatingDragMenu/DragMenu.js +15 -4
- package/dist/es2019/ui/FloatingDragMenu/DropdownMenu.js +42 -8
- package/dist/es2019/ui/FloatingDragMenu/index.js +16 -7
- package/dist/es2019/ui/FloatingInsertButton/index.js +5 -1
- package/dist/es2019/ui/consts.js +1 -0
- package/dist/es2019/utils/create.js +1 -1
- package/dist/es2019/utils/drag-menu.js +4 -4
- package/dist/esm/commands/column-resize.js +4 -2
- package/dist/esm/commands/delete.js +2 -1
- package/dist/esm/commands/insert.js +6 -3
- package/dist/esm/commands-with-analytics.js +4 -2
- package/dist/esm/event-handlers.js +2 -1
- package/dist/esm/nodeviews/TableComponent.js +118 -49
- package/dist/esm/nodeviews/TableContainer.js +8 -4
- package/dist/esm/nodeviews/TableResizer.js +6 -5
- package/dist/esm/nodeviews/table.js +12 -4
- package/dist/esm/plugin.js +50 -47
- package/dist/esm/pm-plugins/drag-and-drop/plugin.js +9 -6
- package/dist/esm/pm-plugins/keymap.js +6 -3
- package/dist/esm/pm-plugins/main.js +4 -1
- package/dist/esm/pm-plugins/table-resizing/event-handlers.js +7 -3
- package/dist/esm/pm-plugins/table-resizing/utils/colgroup.js +32 -11
- package/dist/esm/pm-plugins/table-resizing/utils/consts.js +3 -1
- package/dist/esm/pm-plugins/table-resizing/utils/index.js +2 -2
- package/dist/esm/pm-plugins/table-resizing/utils/misc.js +22 -2
- package/dist/esm/pm-plugins/table-resizing/utils/resize-column.js +2 -1
- package/dist/esm/pm-plugins/table-resizing/utils/resize-state.js +52 -11
- package/dist/esm/pm-plugins/table-resizing/utils/scale-table.js +19 -8
- package/dist/esm/toolbar.js +17 -10
- package/dist/esm/transforms/column-width.js +23 -8
- package/dist/esm/transforms/delete-columns.js +2 -1
- package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +45 -38
- package/dist/esm/ui/FloatingContextualMenu/index.js +6 -4
- package/dist/esm/ui/FloatingDragMenu/DragMenu.js +15 -4
- package/dist/esm/ui/FloatingDragMenu/DropdownMenu.js +50 -9
- package/dist/esm/ui/FloatingDragMenu/index.js +16 -7
- package/dist/esm/ui/FloatingInsertButton/index.js +5 -1
- package/dist/esm/ui/consts.js +1 -0
- package/dist/esm/utils/create.js +1 -1
- package/dist/esm/utils/drag-menu.js +4 -3
- package/dist/types/commands/column-resize.d.ts +1 -1
- package/dist/types/commands/delete.d.ts +1 -1
- package/dist/types/commands/insert.d.ts +3 -3
- package/dist/types/commands-with-analytics.d.ts +2 -2
- package/dist/types/event-handlers.d.ts +1 -1
- package/dist/types/nodeviews/TableComponent.d.ts +3 -0
- package/dist/types/nodeviews/TableContainer.d.ts +4 -2
- package/dist/types/nodeviews/TableResizer.d.ts +2 -1
- package/dist/types/nodeviews/table.d.ts +1 -0
- package/dist/types/pm-plugins/drag-and-drop/plugin.d.ts +3 -2
- package/dist/types/pm-plugins/keymap.d.ts +2 -2
- package/dist/types/pm-plugins/table-resizing/utils/colgroup.d.ts +2 -2
- package/dist/types/pm-plugins/table-resizing/utils/consts.d.ts +2 -0
- package/dist/types/pm-plugins/table-resizing/utils/index.d.ts +2 -2
- package/dist/types/pm-plugins/table-resizing/utils/misc.d.ts +7 -0
- package/dist/types/pm-plugins/table-resizing/utils/resize-column.d.ts +1 -1
- package/dist/types/pm-plugins/table-resizing/utils/resize-state.d.ts +4 -3
- package/dist/types/pm-plugins/table-resizing/utils/scale-table.d.ts +4 -4
- package/dist/types/toolbar.d.ts +2 -2
- package/dist/types/transforms/column-width.d.ts +1 -1
- package/dist/types/transforms/delete-columns.d.ts +1 -1
- package/dist/types/ui/FloatingContextualMenu/ContextualMenu.d.ts +2 -1
- package/dist/types/ui/FloatingContextualMenu/index.d.ts +1 -1
- package/dist/types/ui/FloatingDragMenu/DragMenu.d.ts +7 -1
- package/dist/types/ui/FloatingDragMenu/DropdownMenu.d.ts +8 -2
- package/dist/types/ui/FloatingDragMenu/index.d.ts +3 -2
- package/dist/types/ui/FloatingInsertButton/index.d.ts +2 -1
- package/dist/types/ui/consts.d.ts +1 -0
- package/dist/types/utils/drag-menu.d.ts +1 -1
- package/dist/types-ts4.5/commands/column-resize.d.ts +1 -1
- package/dist/types-ts4.5/commands/delete.d.ts +1 -1
- package/dist/types-ts4.5/commands/insert.d.ts +3 -3
- package/dist/types-ts4.5/commands-with-analytics.d.ts +2 -2
- package/dist/types-ts4.5/event-handlers.d.ts +1 -1
- package/dist/types-ts4.5/nodeviews/TableComponent.d.ts +3 -0
- package/dist/types-ts4.5/nodeviews/TableContainer.d.ts +4 -2
- package/dist/types-ts4.5/nodeviews/TableResizer.d.ts +2 -1
- package/dist/types-ts4.5/nodeviews/table.d.ts +1 -0
- package/dist/types-ts4.5/pm-plugins/drag-and-drop/plugin.d.ts +3 -2
- package/dist/types-ts4.5/pm-plugins/keymap.d.ts +2 -2
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/colgroup.d.ts +2 -2
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/consts.d.ts +2 -0
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/index.d.ts +2 -2
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/misc.d.ts +7 -0
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/resize-column.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/resize-state.d.ts +4 -3
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/scale-table.d.ts +4 -4
- package/dist/types-ts4.5/toolbar.d.ts +2 -2
- package/dist/types-ts4.5/transforms/column-width.d.ts +1 -1
- package/dist/types-ts4.5/transforms/delete-columns.d.ts +1 -1
- package/dist/types-ts4.5/ui/FloatingContextualMenu/ContextualMenu.d.ts +2 -1
- package/dist/types-ts4.5/ui/FloatingContextualMenu/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/FloatingDragMenu/DragMenu.d.ts +7 -1
- package/dist/types-ts4.5/ui/FloatingDragMenu/DropdownMenu.d.ts +8 -2
- package/dist/types-ts4.5/ui/FloatingDragMenu/index.d.ts +3 -2
- package/dist/types-ts4.5/ui/FloatingInsertButton/index.d.ts +2 -1
- package/dist/types-ts4.5/ui/consts.d.ts +1 -0
- package/dist/types-ts4.5/utils/drag-menu.d.ts +1 -1
- package/package.json +3 -3
- package/src/commands/column-resize.ts +3 -0
- package/src/commands/delete.ts +2 -1
- package/src/commands/insert.ts +15 -6
- package/src/commands-with-analytics.ts +9 -3
- package/src/event-handlers.ts +2 -0
- package/src/nodeviews/TableComponent.tsx +91 -5
- package/src/nodeviews/TableContainer.tsx +6 -0
- package/src/nodeviews/TableResizer.tsx +6 -0
- package/src/nodeviews/table.tsx +15 -10
- package/src/plugin.tsx +17 -5
- package/src/pm-plugins/drag-and-drop/plugin.ts +16 -8
- package/src/pm-plugins/keymap.ts +11 -3
- package/src/pm-plugins/main.ts +3 -0
- package/src/pm-plugins/table-resizing/event-handlers.ts +11 -1
- package/src/pm-plugins/table-resizing/utils/colgroup.ts +49 -17
- package/src/pm-plugins/table-resizing/utils/consts.ts +2 -0
- package/src/pm-plugins/table-resizing/utils/index.ts +8 -1
- package/src/pm-plugins/table-resizing/utils/misc.ts +25 -1
- package/src/pm-plugins/table-resizing/utils/resize-column.ts +2 -1
- package/src/pm-plugins/table-resizing/utils/resize-state.ts +56 -11
- package/src/pm-plugins/table-resizing/utils/scale-table.ts +24 -6
- package/src/toolbar.tsx +18 -5
- package/src/transforms/column-width.ts +33 -11
- package/src/transforms/delete-columns.ts +7 -2
- package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +20 -5
- package/src/ui/FloatingContextualMenu/index.tsx +4 -1
- package/src/ui/FloatingDragMenu/DragMenu.tsx +19 -1
- package/src/ui/FloatingDragMenu/DropdownMenu.tsx +94 -50
- package/src/ui/FloatingDragMenu/index.tsx +17 -4
- package/src/ui/FloatingInsertButton/index.tsx +17 -5
- package/src/ui/consts.ts +1 -0
- package/src/utils/create.ts +1 -3
- package/src/utils/drag-menu.ts +4 -1
|
@@ -24,18 +24,20 @@ var FloatingDragMenu = function FloatingDragMenu(_ref) {
|
|
|
24
24
|
getEditorContainerWidth = _ref.getEditorContainerWidth,
|
|
25
25
|
editorAnalyticsAPI = _ref.editorAnalyticsAPI,
|
|
26
26
|
stickyHeaders = _ref.stickyHeaders,
|
|
27
|
-
pluginConfig = _ref.pluginConfig
|
|
27
|
+
pluginConfig = _ref.pluginConfig,
|
|
28
|
+
getEditorFeatureFlags = _ref.getEditorFeatureFlags;
|
|
28
29
|
if (!isOpen || !targetCellPosition || editorView.state.doc.nodeSize <= targetCellPosition) {
|
|
29
30
|
return null;
|
|
30
31
|
}
|
|
31
32
|
var inStickyMode = stickyHeaders === null || stickyHeaders === void 0 ? void 0 : stickyHeaders.sticky;
|
|
32
33
|
var targetHandleRef = direction === 'row' ? document.querySelector('#drag-handle-button-row') : document.querySelector('#drag-handle-button-column');
|
|
33
|
-
var offset = direction === 'row' ? [-9,
|
|
34
|
+
var offset = direction === 'row' ? [-9, 0] : [0, -7];
|
|
34
35
|
if (!targetHandleRef || !(editorView.state.selection instanceof _cellSelection.CellSelection)) {
|
|
35
36
|
return null;
|
|
36
37
|
}
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
var _getEditorFeatureFlag = getEditorFeatureFlags(),
|
|
39
|
+
_getEditorFeatureFlag2 = _getEditorFeatureFlag.tablePreserveWidth,
|
|
40
|
+
tablePreserveWidth = _getEditorFeatureFlag2 === void 0 ? false : _getEditorFeatureFlag2;
|
|
39
41
|
return /*#__PURE__*/_react.default.createElement(_ui.Popup, {
|
|
40
42
|
alignX: direction === 'row' ? 'right' : undefined,
|
|
41
43
|
alignY: direction === 'row' ? 'start' : undefined,
|
|
@@ -43,7 +45,8 @@ var FloatingDragMenu = function FloatingDragMenu(_ref) {
|
|
|
43
45
|
mountTo: mountPoint,
|
|
44
46
|
boundariesElement: boundariesElement,
|
|
45
47
|
scrollableElement: scrollableElement,
|
|
46
|
-
fitWidth: _consts.dragMenuDropdownWidth
|
|
48
|
+
fitWidth: _consts.dragMenuDropdownWidth,
|
|
49
|
+
fitHeight: _consts.tablePopupMenuFitHeight
|
|
47
50
|
// z-index value below is to ensure that this menu is above other floating menu
|
|
48
51
|
// in table, but below floating dialogs like typeaheads, pickers, etc.
|
|
49
52
|
// In sticky mode, we want to show the menu above the sticky header
|
|
@@ -62,7 +65,13 @@ var FloatingDragMenu = function FloatingDragMenu(_ref) {
|
|
|
62
65
|
targetCellPosition: targetCellPosition,
|
|
63
66
|
getEditorContainerWidth: getEditorContainerWidth,
|
|
64
67
|
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
65
|
-
pluginConfig: pluginConfig
|
|
68
|
+
pluginConfig: pluginConfig,
|
|
69
|
+
fitWidth: _consts.dragMenuDropdownWidth,
|
|
70
|
+
fitHeight: _consts.tablePopupMenuFitHeight,
|
|
71
|
+
mountPoint: mountPoint,
|
|
72
|
+
boundariesElement: boundariesElement,
|
|
73
|
+
scrollableElement: scrollableElement,
|
|
74
|
+
tablePreserveWidth: tablePreserveWidth
|
|
66
75
|
}));
|
|
67
76
|
};
|
|
68
77
|
FloatingDragMenu.displayName = 'FloatingDragMenu';
|
|
@@ -198,10 +198,14 @@ var FloatingInsertButton = exports.FloatingInsertButton = /*#__PURE__*/function
|
|
|
198
198
|
editorAnalyticsAPI = _this$props4.editorAnalyticsAPI,
|
|
199
199
|
getEditorContainerWidth = _this$props4.getEditorContainerWidth;
|
|
200
200
|
if (typeof insertColumnButtonIndex !== 'undefined') {
|
|
201
|
+
var _this$props$getEditor, _this$props5;
|
|
201
202
|
event.preventDefault();
|
|
203
|
+
var _ref = ((_this$props$getEditor = (_this$props5 = this.props).getEditorFeatureFlags) === null || _this$props$getEditor === void 0 ? void 0 : _this$props$getEditor.call(_this$props5)) || {},
|
|
204
|
+
_ref$tablePreserveWid = _ref.tablePreserveWidth,
|
|
205
|
+
tablePreserveWidth = _ref$tablePreserveWid === void 0 ? false : _ref$tablePreserveWid;
|
|
202
206
|
var state = editorView.state,
|
|
203
207
|
dispatch = editorView.dispatch;
|
|
204
|
-
(0, _commandsWithAnalytics.insertColumnWithAnalytics)(getEditorContainerWidth, editorAnalyticsAPI)(_analytics.INPUT_METHOD.BUTTON, insertColumnButtonIndex)(state, dispatch, editorView);
|
|
208
|
+
(0, _commandsWithAnalytics.insertColumnWithAnalytics)(getEditorContainerWidth, editorAnalyticsAPI, tablePreserveWidth)(_analytics.INPUT_METHOD.BUTTON, insertColumnButtonIndex)(state, dispatch, editorView);
|
|
205
209
|
}
|
|
206
210
|
}
|
|
207
211
|
}]);
|
package/dist/cjs/ui/consts.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
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.contextualMenuDropdownWidthDnD = exports.contextualMenuDropdownWidth = exports.columnResizeHandleZIndex = exports.columnControlsZIndex = exports.columnControlsSelectedZIndex = exports.columnControlsDecorationHeight = exports.colorPalletteColumns = 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;
|
|
6
|
+
exports.tableToolbarSize = exports.tableToolbarSelectedColor = exports.tableToolbarDeleteColor = exports.tableToolbarColor = exports.tableTextColor = exports.tableScrollbarOffset = exports.tablePopupMenuFitHeight = 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.contextualMenuDropdownWidthDnD = exports.contextualMenuDropdownWidth = exports.columnResizeHandleZIndex = exports.columnControlsZIndex = exports.columnControlsSelectedZIndex = exports.columnControlsDecorationHeight = exports.colorPalletteColumns = 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
9
|
var _colors = require("@atlaskit/theme/colors");
|
|
@@ -61,6 +61,7 @@ var stickyRowOffsetTop = exports.stickyRowOffsetTop = 8;
|
|
|
61
61
|
var stickyHeaderBorderBottomWidth = exports.stickyHeaderBorderBottomWidth = 1;
|
|
62
62
|
var tableOverflowShadowWidth = exports.tableOverflowShadowWidth = 8;
|
|
63
63
|
var tableOverflowShadowWidthWide = exports.tableOverflowShadowWidthWide = 32;
|
|
64
|
+
var tablePopupMenuFitHeight = exports.tablePopupMenuFitHeight = 188;
|
|
64
65
|
var dropTargetsZIndex = exports.dropTargetsZIndex = 14;
|
|
65
66
|
var TABLE_SNAP_GAP = exports.TABLE_SNAP_GAP = 9;
|
|
66
67
|
var TABLE_HIGHLIGHT_GAP = exports.TABLE_HIGHLIGHT_GAP = 10;
|
package/dist/cjs/utils/create.js
CHANGED
|
@@ -12,7 +12,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
12
12
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
13
13
|
var createTableWithWidth = exports.createTableWithWidth = function createTableWithWidth(isFullWidthModeEnabled, getEditorFeatureFlags, createTableProps) {
|
|
14
14
|
return function (schema) {
|
|
15
|
-
var _ref = getEditorFeatureFlags ? getEditorFeatureFlags()
|
|
15
|
+
var _ref = (getEditorFeatureFlags === null || getEditorFeatureFlags === void 0 ? void 0 : getEditorFeatureFlags()) || {},
|
|
16
16
|
_ref$tablePreserveWid = _ref.tablePreserveWidth,
|
|
17
17
|
tablePreserveWidth = _ref$tablePreserveWid === void 0 ? false : _ref$tablePreserveWid;
|
|
18
18
|
if (tablePreserveWidth && isFullWidthModeEnabled) {
|
|
@@ -70,6 +70,7 @@ var defaultSelectionRect = {
|
|
|
70
70
|
};
|
|
71
71
|
var getDragMenuConfig = exports.getDragMenuConfig = function getDragMenuConfig(direction, getEditorContainerWidth, canDrag, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI, isHeaderRowRequired) {
|
|
72
72
|
var _tableMap$height, _tableMap$height2, _tableMap$width, _tableMap$width2;
|
|
73
|
+
var tablePreserveWidth = arguments.length > 11 && arguments[11] !== undefined ? arguments[11] : false;
|
|
73
74
|
var addOptions = direction === 'row' ? [{
|
|
74
75
|
label: 'above',
|
|
75
76
|
offset: 0,
|
|
@@ -154,7 +155,7 @@ var getDragMenuConfig = exports.getDragMenuConfig = function getDragMenuConfig(d
|
|
|
154
155
|
moveCursorToInsertedRow: true
|
|
155
156
|
})(state, dispatch);
|
|
156
157
|
} else {
|
|
157
|
-
(0, _commandsWithAnalytics.insertColumnWithAnalytics)(getEditorContainerWidth, editorAnalyticsAPI)(_analytics.INPUT_METHOD.TABLE_CONTEXT_MENU, (index !== null && index !== void 0 ? index : 0) + offset)(state, dispatch, editorView);
|
|
158
|
+
(0, _commandsWithAnalytics.insertColumnWithAnalytics)(getEditorContainerWidth, editorAnalyticsAPI, tablePreserveWidth)(_analytics.INPUT_METHOD.TABLE_CONTEXT_MENU, (index !== null && index !== void 0 ? index : 0) + offset)(state, dispatch, editorView);
|
|
158
159
|
}
|
|
159
160
|
return true;
|
|
160
161
|
},
|
|
@@ -167,7 +168,7 @@ var getDragMenuConfig = exports.getDragMenuConfig = function getDragMenuConfig(d
|
|
|
167
168
|
onClick: function onClick(state, dispatch) {
|
|
168
169
|
var selectionRect = (0, _toolbar.getClosestSelectionRect)(state);
|
|
169
170
|
if (selectionRect) {
|
|
170
|
-
var newResizeState = (0, _resizeState.getNewResizeStateFromSelectedColumns)(selectionRect, state, editorView.domAtPos.bind(editorView), getEditorContainerWidth);
|
|
171
|
+
var newResizeState = (0, _resizeState.getNewResizeStateFromSelectedColumns)(selectionRect, state, editorView.domAtPos.bind(editorView), getEditorContainerWidth, tablePreserveWidth);
|
|
171
172
|
if (newResizeState) {
|
|
172
173
|
(0, _commandsWithAnalytics.distributeColumnsWidthsWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.TABLE_CONTEXT_MENU, newResizeState)(state, dispatch);
|
|
173
174
|
return true;
|
|
@@ -193,7 +194,7 @@ var getDragMenuConfig = exports.getDragMenuConfig = function getDragMenuConfig(d
|
|
|
193
194
|
if (direction === 'row') {
|
|
194
195
|
(0, _commandsWithAnalytics.deleteRowsWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.TABLE_CONTEXT_MENU, selectionRect !== null && selectionRect !== void 0 ? selectionRect : defaultSelectionRect, !!isHeaderRowRequired)(state, dispatch);
|
|
195
196
|
} else {
|
|
196
|
-
(0, _commandsWithAnalytics.deleteColumnsWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.TABLE_CONTEXT_MENU, selectionRect !== null && selectionRect !== void 0 ? selectionRect : defaultSelectionRect)(state, dispatch, editorView);
|
|
197
|
+
(0, _commandsWithAnalytics.deleteColumnsWithAnalytics)(editorAnalyticsAPI, tablePreserveWidth)(_analytics.INPUT_METHOD.TABLE_CONTEXT_MENU, selectionRect !== null && selectionRect !== void 0 ? selectionRect : defaultSelectionRect)(state, dispatch, editorView);
|
|
197
198
|
}
|
|
198
199
|
return true;
|
|
199
200
|
},
|
|
@@ -121,7 +121,7 @@ export const activateNextResizeArea = direction => (state, dispatch, view) => {
|
|
|
121
121
|
}
|
|
122
122
|
return false;
|
|
123
123
|
};
|
|
124
|
-
export const changeColumnWidthByStep = (stepSize, getEditorContainerWidth) => (state, dispatch, view) => {
|
|
124
|
+
export const changeColumnWidthByStep = (stepSize, getEditorContainerWidth, tablePreserveWidth = false) => (state, dispatch, view) => {
|
|
125
125
|
let customTr = state.tr;
|
|
126
126
|
const fakeDispatch = tr => {
|
|
127
127
|
customTr = tr;
|
|
@@ -170,14 +170,15 @@ export const changeColumnWidthByStep = (stepSize, getEditorContainerWidth) => (s
|
|
|
170
170
|
table: originalTable,
|
|
171
171
|
tableRef: dom,
|
|
172
172
|
start: tableStartPosition,
|
|
173
|
-
domAtPos
|
|
173
|
+
domAtPos,
|
|
174
|
+
tablePreserveWidth
|
|
174
175
|
});
|
|
175
176
|
updateControls()(state);
|
|
176
177
|
const selectionRect = getSelectionRect(state.selection);
|
|
177
178
|
const selectedColumns = selectionRect ? getSelectedColumnIndexes(selectionRect) : [];
|
|
178
179
|
// only selected (or selected - 1) columns should be distributed
|
|
179
180
|
const resizingSelectedColumns = selectedColumns.indexOf(colIndex) > -1 || selectedColumns.indexOf(colIndex + 1) > -1;
|
|
180
|
-
const newResizeState = resizeColumn(initialResizeState, colIndex, stepSize, dom, resizingSelectedColumns ? selectedColumns : undefined);
|
|
181
|
+
const newResizeState = resizeColumn(initialResizeState, colIndex, stepSize, dom, resizingSelectedColumns ? selectedColumns : undefined, tablePreserveWidth);
|
|
181
182
|
customTr = updateColumnWidths(newResizeState, originalTable, tableStartPosition)(customTr);
|
|
182
183
|
if (dispatch) {
|
|
183
184
|
dispatch(customTr);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { deleteColumns } from '../transforms/delete-columns';
|
|
2
2
|
import { getAllowAddColumnCustomStep } from '../utils/get-allow-add-column-custom-step';
|
|
3
|
-
export const deleteColumnsCommand = rect => (state, dispatch, view) => {
|
|
4
|
-
const tr = deleteColumns(rect, getAllowAddColumnCustomStep(state), view)(state.tr);
|
|
3
|
+
export const deleteColumnsCommand = (rect, tablePreserveWidth = false) => (state, dispatch, view) => {
|
|
4
|
+
const tr = deleteColumns(rect, getAllowAddColumnCustomStep(state), view, tablePreserveWidth)(state.tr);
|
|
5
5
|
if (dispatch) {
|
|
6
6
|
dispatch(tr);
|
|
7
7
|
return true;
|
|
@@ -20,7 +20,7 @@ function addColumnAtCustomStep(column) {
|
|
|
20
20
|
return tr;
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
-
export function addColumnAt(getEditorContainerWidth) {
|
|
23
|
+
export function addColumnAt(getEditorContainerWidth, tablePreserveWidth = false) {
|
|
24
24
|
return (column, allowAddColumnCustomStep = false, view) => {
|
|
25
25
|
return tr => {
|
|
26
26
|
let updatedTr = tr;
|
|
@@ -32,7 +32,7 @@ export function addColumnAt(getEditorContainerWidth) {
|
|
|
32
32
|
const table = findTable(updatedTr.selection);
|
|
33
33
|
if (table) {
|
|
34
34
|
// [ED-8288] Update colwidths manually to avoid multiple dispatch in TableComponent
|
|
35
|
-
updatedTr = rescaleColumns()(table, view)(updatedTr);
|
|
35
|
+
updatedTr = rescaleColumns(tablePreserveWidth)(table, view)(updatedTr);
|
|
36
36
|
}
|
|
37
37
|
if (getBooleanFF('platform.editor.table.analytics-plugin-moved-event') && view) {
|
|
38
38
|
updatedTr = updateRowOrColumnMovedTransform({
|
|
@@ -49,14 +49,14 @@ export function addColumnAt(getEditorContainerWidth) {
|
|
|
49
49
|
|
|
50
50
|
// :: (EditorState, dispatch: ?(tr: Transaction)) → bool
|
|
51
51
|
// Command to add a column before the column with the selection.
|
|
52
|
-
export const addColumnBefore = getEditorContainerWidth => (state, dispatch, view) => {
|
|
52
|
+
export const addColumnBefore = (getEditorContainerWidth, tablePreserveWidth = false) => (state, dispatch, view) => {
|
|
53
53
|
const table = findTable(state.selection);
|
|
54
54
|
if (!table) {
|
|
55
55
|
return false;
|
|
56
56
|
}
|
|
57
57
|
if (dispatch) {
|
|
58
58
|
let rect = selectedRect(state);
|
|
59
|
-
dispatch(addColumnAt(getEditorContainerWidth)(rect.left, getAllowAddColumnCustomStep(state), view)(state.tr));
|
|
59
|
+
dispatch(addColumnAt(getEditorContainerWidth, tablePreserveWidth)(rect.left, getAllowAddColumnCustomStep(state), view)(state.tr));
|
|
60
60
|
}
|
|
61
61
|
return true;
|
|
62
62
|
};
|
|
@@ -74,8 +74,8 @@ export const addColumnAfter = getEditorContainerWidth => (state, dispatch, view)
|
|
|
74
74
|
}
|
|
75
75
|
return true;
|
|
76
76
|
};
|
|
77
|
-
export const insertColumn = getEditorContainerWidth => column => (state, dispatch, view) => {
|
|
78
|
-
let tr = addColumnAt(getEditorContainerWidth)(column, getAllowAddColumnCustomStep(state), view)(state.tr);
|
|
77
|
+
export const insertColumn = (getEditorContainerWidth, tablePreserveWidth = false) => column => (state, dispatch, view) => {
|
|
78
|
+
let tr = addColumnAt(getEditorContainerWidth, tablePreserveWidth)(column, getAllowAddColumnCustomStep(state), view)(state.tr);
|
|
79
79
|
const table = findTable(tr.selection);
|
|
80
80
|
if (!table) {
|
|
81
81
|
return false;
|
|
@@ -167,7 +167,7 @@ export const insertRowWithAnalytics = editorAnalyticsAPI => (inputMethod, option
|
|
|
167
167
|
eventType: EVENT_TYPE.TRACK
|
|
168
168
|
};
|
|
169
169
|
})(editorAnalyticsAPI)(insertRow(options.index, options.moveCursorToInsertedRow));
|
|
170
|
-
export const insertColumnWithAnalytics = (getEditorContainerWidth, editorAnalyticsAPI) => (inputMethod, position) => withEditorAnalyticsAPI(state => {
|
|
170
|
+
export const insertColumnWithAnalytics = (getEditorContainerWidth, editorAnalyticsAPI, tablePreserveWidth = false) => (inputMethod, position) => withEditorAnalyticsAPI(state => {
|
|
171
171
|
const {
|
|
172
172
|
totalRowCount,
|
|
173
173
|
totalColumnCount
|
|
@@ -184,7 +184,7 @@ export const insertColumnWithAnalytics = (getEditorContainerWidth, editorAnalyti
|
|
|
184
184
|
},
|
|
185
185
|
eventType: EVENT_TYPE.TRACK
|
|
186
186
|
};
|
|
187
|
-
})(editorAnalyticsAPI)(insertColumn(getEditorContainerWidth)(position));
|
|
187
|
+
})(editorAnalyticsAPI)(insertColumn(getEditorContainerWidth, tablePreserveWidth)(position));
|
|
188
188
|
export const deleteRowsWithAnalytics = editorAnalyticsAPI => (inputMethod, rect, isHeaderRowRequired) => withEditorAnalyticsAPI(({
|
|
189
189
|
selection
|
|
190
190
|
}) => {
|
|
@@ -211,7 +211,7 @@ export const deleteRowsWithAnalytics = editorAnalyticsAPI => (inputMethod, rect,
|
|
|
211
211
|
}
|
|
212
212
|
return true;
|
|
213
213
|
});
|
|
214
|
-
export const deleteColumnsWithAnalytics = editorAnalyticsAPI => (inputMethod, rect) => withEditorAnalyticsAPI(({
|
|
214
|
+
export const deleteColumnsWithAnalytics = (editorAnalyticsAPI, tablePreserveWidth = false) => (inputMethod, rect) => withEditorAnalyticsAPI(({
|
|
215
215
|
selection
|
|
216
216
|
}) => {
|
|
217
217
|
const {
|
|
@@ -231,7 +231,7 @@ export const deleteColumnsWithAnalytics = editorAnalyticsAPI => (inputMethod, re
|
|
|
231
231
|
},
|
|
232
232
|
eventType: EVENT_TYPE.TRACK
|
|
233
233
|
};
|
|
234
|
-
})(editorAnalyticsAPI)(deleteColumnsCommand(rect));
|
|
234
|
+
})(editorAnalyticsAPI)(deleteColumnsCommand(rect, tablePreserveWidth));
|
|
235
235
|
export const deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut = editorAnalyticsAPI => (state, dispatch) => {
|
|
236
236
|
const {
|
|
237
237
|
selection
|
|
@@ -345,7 +345,7 @@ export function handleTripleClick(view, pos) {
|
|
|
345
345
|
}
|
|
346
346
|
return false;
|
|
347
347
|
}
|
|
348
|
-
export const handleCut = (oldTr, oldState, newState, editorAnalyticsAPI, editorView) => {
|
|
348
|
+
export const handleCut = (oldTr, oldState, newState, editorAnalyticsAPI, editorView, tablePreserveWidth = false) => {
|
|
349
349
|
const oldSelection = oldState.tr.selection;
|
|
350
350
|
let {
|
|
351
351
|
tr
|
|
@@ -394,7 +394,7 @@ export const handleCut = (oldTr, oldState, newState, editorAnalyticsAPI, editorV
|
|
|
394
394
|
} = getPluginState(newState);
|
|
395
395
|
tr = deleteRows(rect, isHeaderRowRequired)(tr);
|
|
396
396
|
} else if (tr.selection.isColSelection()) {
|
|
397
|
-
tr = deleteColumns(rect, getAllowAddColumnCustomStep(oldState), editorView)(tr);
|
|
397
|
+
tr = deleteColumns(rect, getAllowAddColumnCustomStep(oldState), editorView, tablePreserveWidth)(tr);
|
|
398
398
|
}
|
|
399
399
|
}
|
|
400
400
|
}
|
|
@@ -6,7 +6,7 @@ import rafSchedule from 'raf-schd';
|
|
|
6
6
|
import { ACTION_SUBJECT, EVENT_TYPE, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
|
|
7
7
|
import { getParentNodeWidth, getTableContainerWidth } from '@atlaskit/editor-common/node-width';
|
|
8
8
|
import { tableMarginSides } from '@atlaskit/editor-common/styles';
|
|
9
|
-
import { browser, isValidPosition } from '@atlaskit/editor-common/utils';
|
|
9
|
+
import { browser, calcTableColumnWidths, isValidPosition } from '@atlaskit/editor-common/utils';
|
|
10
10
|
import { MAX_BROWSER_SCROLLBAR_HEIGHT, akEditorTableToolbarSize as tableToolbarSize } from '@atlaskit/editor-shared-styles';
|
|
11
11
|
import { findTable, isTableSelected } from '@atlaskit/editor-tables/utils';
|
|
12
12
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
@@ -16,7 +16,7 @@ import { autoScrollerFactory } from '../pm-plugins/drag-and-drop/utils';
|
|
|
16
16
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
17
17
|
import { findStickyHeaderForTable, pluginKey as stickyHeadersPluginKey } from '../pm-plugins/sticky-headers';
|
|
18
18
|
import { META_KEYS } from '../pm-plugins/table-analytics';
|
|
19
|
-
import { getLayoutSize, insertColgroupFromNode
|
|
19
|
+
import { COLUMN_MIN_WIDTH, getLayoutSize, getResizeState, insertColgroupFromNode, scaleTable, updateColgroup } from '../pm-plugins/table-resizing/utils';
|
|
20
20
|
import { hasTableBeenResized } from '../pm-plugins/table-resizing/utils/colgroup';
|
|
21
21
|
import { updateControls } from '../pm-plugins/table-resizing/utils/dom';
|
|
22
22
|
import { TableCssClassName as ClassName, ShadowEvent } from '../types';
|
|
@@ -160,7 +160,8 @@ class TableComponent extends React.Component {
|
|
|
160
160
|
getNode,
|
|
161
161
|
getPos,
|
|
162
162
|
containerWidth,
|
|
163
|
-
options
|
|
163
|
+
options,
|
|
164
|
+
getEditorFeatureFlags
|
|
164
165
|
} = this.props;
|
|
165
166
|
const node = getNode();
|
|
166
167
|
const {
|
|
@@ -176,6 +177,9 @@ class TableComponent extends React.Component {
|
|
|
176
177
|
width
|
|
177
178
|
} = containerWidth;
|
|
178
179
|
this.scaleTableDebounced.cancel();
|
|
180
|
+
const {
|
|
181
|
+
tablePreserveWidth = false
|
|
182
|
+
} = getEditorFeatureFlags();
|
|
179
183
|
const tr = scaleTable(this.table, {
|
|
180
184
|
...scaleOptions,
|
|
181
185
|
node,
|
|
@@ -184,7 +188,7 @@ class TableComponent extends React.Component {
|
|
|
184
188
|
containerWidth: width,
|
|
185
189
|
previousContainerWidth: this.containerWidth.width || width,
|
|
186
190
|
...options
|
|
187
|
-
}, domAtPos)(state.tr);
|
|
191
|
+
}, domAtPos, tablePreserveWidth)(state.tr);
|
|
188
192
|
dispatch(tr);
|
|
189
193
|
});
|
|
190
194
|
_defineProperty(this, "setTimerToSendInitialOverflowCaptured", isOverflowing => {
|
|
@@ -388,6 +392,62 @@ class TableComponent extends React.Component {
|
|
|
388
392
|
clearTimeout(this.initialOverflowCaptureTimerId);
|
|
389
393
|
}
|
|
390
394
|
}
|
|
395
|
+
handleColgroupUpdates() {
|
|
396
|
+
var _this$containerWidth;
|
|
397
|
+
const {
|
|
398
|
+
getNode,
|
|
399
|
+
containerWidth,
|
|
400
|
+
isResizing,
|
|
401
|
+
view,
|
|
402
|
+
getPos,
|
|
403
|
+
tableRef
|
|
404
|
+
} = this.props;
|
|
405
|
+
if (!tableRef) {
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
const TABLE_MARGIN = 76;
|
|
409
|
+
|
|
410
|
+
// Remove any widths styles after resizing preview is completed
|
|
411
|
+
tableRef.style.width = '';
|
|
412
|
+
const tableRenderWidth = containerWidth.width - TABLE_MARGIN;
|
|
413
|
+
const tableNode = getNode();
|
|
414
|
+
const start = getPos() || 0;
|
|
415
|
+
const depth = view.state.doc.resolve(start).depth;
|
|
416
|
+
|
|
417
|
+
// TODO - remove this when support is added for nested tables
|
|
418
|
+
if (depth !== 0) {
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
const {
|
|
422
|
+
width: tableNodeWidth
|
|
423
|
+
} = tableNode.attrs;
|
|
424
|
+
const tableColumnWidths = calcTableColumnWidths(tableNode);
|
|
425
|
+
const shouldTableScale = tableRenderWidth < tableNodeWidth;
|
|
426
|
+
let isTableColumnWidthsSame = false;
|
|
427
|
+
if (this.tableColumnWidths) {
|
|
428
|
+
isTableColumnWidthsSame = tableColumnWidths === null || tableColumnWidths === void 0 ? void 0 : tableColumnWidths.every((width, index) => width === this.tableColumnWidths[index]);
|
|
429
|
+
}
|
|
430
|
+
const {
|
|
431
|
+
width: containerWidthValue
|
|
432
|
+
} = containerWidth;
|
|
433
|
+
const isWidthChanged = ((_this$containerWidth = this.containerWidth) === null || _this$containerWidth === void 0 ? void 0 : _this$containerWidth.width) !== containerWidthValue;
|
|
434
|
+
if (shouldTableScale && !isResizing && (!isTableColumnWidthsSame || isWidthChanged)) {
|
|
435
|
+
const resizeState = getResizeState({
|
|
436
|
+
minWidth: COLUMN_MIN_WIDTH,
|
|
437
|
+
maxSize: tableRenderWidth,
|
|
438
|
+
table: tableNode,
|
|
439
|
+
tableRef: this.table,
|
|
440
|
+
start,
|
|
441
|
+
domAtPos: view.domAtPos,
|
|
442
|
+
tablePreserveWidth: true
|
|
443
|
+
});
|
|
444
|
+
requestAnimationFrame(() => {
|
|
445
|
+
updateColgroup(resizeState, this.table, true);
|
|
446
|
+
});
|
|
447
|
+
this.tableColumnWidths = tableColumnWidths;
|
|
448
|
+
this.containerWidth = containerWidth;
|
|
449
|
+
}
|
|
450
|
+
}
|
|
391
451
|
componentDidUpdate(_, prevState) {
|
|
392
452
|
var _this$wrapper;
|
|
393
453
|
const {
|
|
@@ -396,12 +456,19 @@ class TableComponent extends React.Component {
|
|
|
396
456
|
isMediaFullscreen,
|
|
397
457
|
allowColumnResizing,
|
|
398
458
|
isResizing,
|
|
399
|
-
options
|
|
459
|
+
options,
|
|
460
|
+
getEditorFeatureFlags
|
|
400
461
|
} = this.props;
|
|
401
462
|
const {
|
|
402
463
|
isInDanger
|
|
403
464
|
} = getPluginState(view.state);
|
|
465
|
+
const {
|
|
466
|
+
tablePreserveWidth = false
|
|
467
|
+
} = getEditorFeatureFlags();
|
|
404
468
|
const table = findTable(view.state.selection);
|
|
469
|
+
if (tablePreserveWidth) {
|
|
470
|
+
this.handleColgroupUpdates();
|
|
471
|
+
}
|
|
405
472
|
if (isInDanger && !table) {
|
|
406
473
|
clearHoverSelection()(view.state, view.dispatch);
|
|
407
474
|
}
|
|
@@ -438,7 +505,7 @@ class TableComponent extends React.Component {
|
|
|
438
505
|
} = this.props;
|
|
439
506
|
const shouldRecreateResizeCols = !(options !== null && options !== void 0 && options.isTableResizingEnabled) || !isResizing || tablesHaveDifferentNoOfColumns(currentTable, previousTable) && isResizing;
|
|
440
507
|
if (shouldRecreateResizeCols) {
|
|
441
|
-
|
|
508
|
+
insertColgroupFromNode(this.table, currentTable, tablePreserveWidth);
|
|
442
509
|
}
|
|
443
510
|
updateControls()(view.state);
|
|
444
511
|
}
|
|
@@ -568,7 +635,8 @@ class TableComponent extends React.Component {
|
|
|
568
635
|
const isNested = isTableNested(view.state, tablePos);
|
|
569
636
|
const topStickyShadowPosition = isDragAndDropEnabled ? this.state.stickyHeader && this.state.stickyHeader.top + this.state.stickyHeader.padding + 2 : this.state.stickyHeader && this.state.stickyHeader.top + this.state.stickyHeader.padding + shadowPadding + 2;
|
|
570
637
|
const {
|
|
571
|
-
stickyScrollbar
|
|
638
|
+
stickyScrollbar,
|
|
639
|
+
tablePreserveWidth
|
|
572
640
|
} = getEditorFeatureFlags();
|
|
573
641
|
return /*#__PURE__*/React.createElement(TableContainer, {
|
|
574
642
|
className: classnames(ClassName.TABLE_CONTAINER, {
|
|
@@ -586,7 +654,8 @@ class TableComponent extends React.Component {
|
|
|
586
654
|
isNested: isNested,
|
|
587
655
|
pluginInjectionApi: pluginInjectionApi,
|
|
588
656
|
isTableResizingEnabled: options === null || options === void 0 ? void 0 : options.isTableResizingEnabled,
|
|
589
|
-
isResizing: isResizing
|
|
657
|
+
isResizing: isResizing,
|
|
658
|
+
tablePreserveWidth: tablePreserveWidth
|
|
590
659
|
}, /*#__PURE__*/React.createElement("div", {
|
|
591
660
|
className: ClassName.TABLE_STICKY_SENTINEL_TOP,
|
|
592
661
|
"data-testid": "sticky-sentinel-top"
|
|
@@ -41,7 +41,8 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
|
|
|
41
41
|
getPos,
|
|
42
42
|
tableRef,
|
|
43
43
|
isResizing,
|
|
44
|
-
pluginInjectionApi
|
|
44
|
+
pluginInjectionApi,
|
|
45
|
+
tablePreserveWidth
|
|
45
46
|
}) => {
|
|
46
47
|
const containerRef = useRef(null);
|
|
47
48
|
const tableWidthRef = useRef(akEditorDefaultLayoutWidth);
|
|
@@ -123,7 +124,8 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
|
|
|
123
124
|
tableRef,
|
|
124
125
|
displayGuideline,
|
|
125
126
|
attachAnalyticsEvent,
|
|
126
|
-
displayGapCursor
|
|
127
|
+
displayGapCursor,
|
|
128
|
+
tablePreserveWidth
|
|
127
129
|
};
|
|
128
130
|
if (getBooleanFF('platform.editor.resizing-table-height-improvement')) {
|
|
129
131
|
tableResizerProps = {
|
|
@@ -163,7 +165,8 @@ export const TableContainer = ({
|
|
|
163
165
|
tableRef,
|
|
164
166
|
isNested,
|
|
165
167
|
isResizing,
|
|
166
|
-
pluginInjectionApi
|
|
168
|
+
pluginInjectionApi,
|
|
169
|
+
tablePreserveWidth
|
|
167
170
|
}) => {
|
|
168
171
|
if (isTableResizingEnabled && !isNested) {
|
|
169
172
|
return /*#__PURE__*/React.createElement(ResizableTableContainer, {
|
|
@@ -174,7 +177,8 @@ export const TableContainer = ({
|
|
|
174
177
|
getPos: getPos,
|
|
175
178
|
tableRef: tableRef,
|
|
176
179
|
isResizing: isResizing,
|
|
177
|
-
pluginInjectionApi: pluginInjectionApi
|
|
180
|
+
pluginInjectionApi: pluginInjectionApi,
|
|
181
|
+
tablePreserveWidth: tablePreserveWidth
|
|
178
182
|
}, children);
|
|
179
183
|
}
|
|
180
184
|
const tableWidth = isBreakoutEnabled ? calcTableWidth(node.attrs.layout, editorWidth) : 'inherit';
|
|
@@ -82,7 +82,8 @@ export const TableResizer = ({
|
|
|
82
82
|
tableRef,
|
|
83
83
|
displayGuideline,
|
|
84
84
|
attachAnalyticsEvent,
|
|
85
|
-
displayGapCursor
|
|
85
|
+
displayGapCursor,
|
|
86
|
+
tablePreserveWidth
|
|
86
87
|
}) => {
|
|
87
88
|
var _findTable, _editorView$state;
|
|
88
89
|
const currentGap = useRef(0);
|
|
@@ -196,11 +197,11 @@ export const TableResizer = ({
|
|
|
196
197
|
prevNode: node,
|
|
197
198
|
start: pos + 1,
|
|
198
199
|
parentWidth: newWidth
|
|
199
|
-
}, editorView.domAtPos.bind(editorView));
|
|
200
|
+
}, editorView.domAtPos.bind(editorView), tablePreserveWidth);
|
|
200
201
|
updateActiveGuidelines(findClosestSnap(newWidth, defaultSnappingWidths, defaultGuidelines, TABLE_HIGHLIGHT_GAP, TABLE_HIGHLIGHT_TOLERANCE));
|
|
201
202
|
updateWidth(newWidth);
|
|
202
203
|
return newWidth;
|
|
203
|
-
}, [editorView, getPos, node, tableRef, updateWidth, updateActiveGuidelines, countFrames]);
|
|
204
|
+
}, [editorView, getPos, node, tableRef, updateWidth, updateActiveGuidelines, countFrames, tablePreserveWidth]);
|
|
204
205
|
const scheduleResize = useMemo(() => rafSchd(handleResize), [handleResize]);
|
|
205
206
|
const handleResizeStop = useCallback((originalState, delta) => {
|
|
206
207
|
isResizing.current = false;
|
|
@@ -237,7 +238,7 @@ export const TableResizer = ({
|
|
|
237
238
|
prevNode: node,
|
|
238
239
|
start: pos + 1,
|
|
239
240
|
parentWidth: newWidth
|
|
240
|
-
}, editorView.domAtPos.bind(editorView))(tr);
|
|
241
|
+
}, editorView.domAtPos.bind(editorView), tablePreserveWidth)(tr);
|
|
241
242
|
const scaledNode = tr.doc.nodeAt(pos);
|
|
242
243
|
(_attachAnalyticsEvent2 = attachAnalyticsEvent(generateResizedPayload({
|
|
243
244
|
originalNode: node,
|
|
@@ -255,7 +256,7 @@ export const TableResizer = ({
|
|
|
255
256
|
onResizeStop();
|
|
256
257
|
}
|
|
257
258
|
return newWidth;
|
|
258
|
-
}, [displayGapCursor, updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, attachAnalyticsEvent, endMeasure, onResizeStop]);
|
|
259
|
+
}, [displayGapCursor, updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, attachAnalyticsEvent, endMeasure, onResizeStop, tablePreserveWidth]);
|
|
259
260
|
const handleTableSizeChangeOnKeypress = useCallback(step => {
|
|
260
261
|
const newWidth = width + step;
|
|
261
262
|
if (newWidth > maxWidth || newWidth < resizerMinWidth) {
|
|
@@ -57,14 +57,21 @@ export default class TableView extends ReactNodeView {
|
|
|
57
57
|
_defineProperty(this, "hasHoveredRows", false);
|
|
58
58
|
this.getPos = props.getPos;
|
|
59
59
|
this.eventDispatcher = props.eventDispatcher;
|
|
60
|
+
this.getEditorFeatureFlags = props.getEditorFeatureFlags;
|
|
60
61
|
}
|
|
61
62
|
getContentDOM() {
|
|
62
63
|
const rendered = DOMSerializer.renderSpec(document, toDOM(this.node, this.reactComponentProps));
|
|
63
|
-
const tableInlineWidth = getInlineWidth(this.node, this.reactComponentProps.options, this.reactComponentProps.view.state, this.reactComponentProps.getPos());
|
|
64
64
|
if (rendered.dom) {
|
|
65
65
|
this.table = rendered.dom;
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
const {
|
|
67
|
+
tablePreserveWidth = false
|
|
68
|
+
} = this.getEditorFeatureFlags();
|
|
69
|
+
// Preserve Table Width cannot have inline width set on the table
|
|
70
|
+
if (!tablePreserveWidth) {
|
|
71
|
+
const tableInlineWidth = getInlineWidth(this.node, this.reactComponentProps.options, this.reactComponentProps.view.state, this.reactComponentProps.getPos());
|
|
72
|
+
if (tableInlineWidth) {
|
|
73
|
+
handleInlineTableWidth(this.table, tableInlineWidth);
|
|
74
|
+
}
|
|
68
75
|
}
|
|
69
76
|
}
|
|
70
77
|
return rendered;
|
|
@@ -158,7 +165,8 @@ export default class TableView extends ReactNodeView {
|
|
|
158
165
|
contentDOM: forwardRef,
|
|
159
166
|
getEditorFeatureFlags: props.getEditorFeatureFlags,
|
|
160
167
|
dispatchAnalyticsEvent: props.dispatchAnalyticsEvent,
|
|
161
|
-
pluginInjectionApi: props.pluginInjectionApi
|
|
168
|
+
pluginInjectionApi: props.pluginInjectionApi,
|
|
169
|
+
tableRef: this.table
|
|
162
170
|
});
|
|
163
171
|
}
|
|
164
172
|
});
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -147,9 +147,10 @@ const tablesPlugin = ({
|
|
|
147
147
|
name: 'tableKeymap',
|
|
148
148
|
plugin: () => {
|
|
149
149
|
const {
|
|
150
|
-
dragAndDropEnabled
|
|
150
|
+
dragAndDropEnabled,
|
|
151
|
+
getEditorFeatureFlags
|
|
151
152
|
} = options || {};
|
|
152
|
-
return keymapPlugin(defaultGetEditorContainerWidth, editorAnalyticsAPI, dragAndDropEnabled);
|
|
153
|
+
return keymapPlugin(defaultGetEditorContainerWidth, editorAnalyticsAPI, getEditorFeatureFlags, dragAndDropEnabled);
|
|
153
154
|
}
|
|
154
155
|
}, {
|
|
155
156
|
name: 'tableSelectionKeymap',
|
|
@@ -187,10 +188,13 @@ const tablesPlugin = ({
|
|
|
187
188
|
}, {
|
|
188
189
|
name: 'tableDragAndDrop',
|
|
189
190
|
plugin: ({
|
|
190
|
-
dispatch
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
191
|
+
dispatch
|
|
192
|
+
}) => {
|
|
193
|
+
const {
|
|
194
|
+
getEditorFeatureFlags
|
|
195
|
+
} = options || {};
|
|
196
|
+
return options !== null && options !== void 0 && options.dragAndDropEnabled ? createDragAndDropPlugin(dispatch, getEditorFeatureFlags, editorAnalyticsAPI) : undefined;
|
|
197
|
+
}
|
|
194
198
|
}, {
|
|
195
199
|
name: 'tableLocalId',
|
|
196
200
|
plugin: ({
|
|
@@ -340,7 +344,8 @@ const tablesPlugin = ({
|
|
|
340
344
|
hasStickyHeaders: stickyHeader && stickyHeader.sticky,
|
|
341
345
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
342
346
|
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
343
|
-
getEditorContainerWidth: defaultGetEditorContainerWidth
|
|
347
|
+
getEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
348
|
+
getEditorFeatureFlags: (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags
|
|
344
349
|
}), (options === null || options === void 0 ? void 0 : options.allowContextualMenu) && /*#__PURE__*/React.createElement(FloatingContextualMenu, {
|
|
345
350
|
editorView: editorView,
|
|
346
351
|
mountPoint: popupsMountPoint,
|
|
@@ -364,7 +369,8 @@ const tablesPlugin = ({
|
|
|
364
369
|
getEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
365
370
|
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
366
371
|
stickyHeaders: stickyHeader,
|
|
367
|
-
pluginConfig: pluginConfig
|
|
372
|
+
pluginConfig: pluginConfig,
|
|
373
|
+
getEditorFeatureFlags: (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags
|
|
368
374
|
}), allowControls && !isDragAndDropEnabled && !isResizing && /*#__PURE__*/React.createElement(FloatingDeleteButton, {
|
|
369
375
|
editorView: editorView,
|
|
370
376
|
selection: editorView.state.selection,
|
|
@@ -17,7 +17,7 @@ import { DropTargetType } from './consts';
|
|
|
17
17
|
import { createPluginState, getPluginState } from './plugin-factory';
|
|
18
18
|
import { pluginKey } from './plugin-key';
|
|
19
19
|
import { getDraggableDataFromEvent } from './utils/monitor';
|
|
20
|
-
const destroyFn = (editorView, editorAnalyticsAPI) => {
|
|
20
|
+
const destroyFn = (editorView, editorAnalyticsAPI, getEditorFeatureFlags) => {
|
|
21
21
|
const editorPageScrollContainer = document.querySelector('.fabric-editor-popup-scroll-parent');
|
|
22
22
|
const rowAutoScrollers = editorPageScrollContainer ? [monitorForElements({
|
|
23
23
|
canMonitor({
|
|
@@ -161,7 +161,10 @@ const destroyFn = (editorView, editorAnalyticsAPI) => {
|
|
|
161
161
|
tableNode
|
|
162
162
|
} = getTablePluginState(editorView.state);
|
|
163
163
|
if (tableRef && tableNode) {
|
|
164
|
-
|
|
164
|
+
const {
|
|
165
|
+
tablePreserveWidth = false
|
|
166
|
+
} = (getEditorFeatureFlags === null || getEditorFeatureFlags === void 0 ? void 0 : getEditorFeatureFlags()) || {};
|
|
167
|
+
insertColgroupFromNode(tableRef, tableNode, tablePreserveWidth);
|
|
165
168
|
}
|
|
166
169
|
}
|
|
167
170
|
editorView.focus();
|
|
@@ -169,7 +172,7 @@ const destroyFn = (editorView, editorAnalyticsAPI) => {
|
|
|
169
172
|
}
|
|
170
173
|
}));
|
|
171
174
|
};
|
|
172
|
-
export const createPlugin = (dispatch,
|
|
175
|
+
export const createPlugin = (dispatch, getEditorFeatureFlags, editorAnalyticsAPI) => {
|
|
173
176
|
return new SafePlugin({
|
|
174
177
|
state: createPluginState(dispatch, state => ({
|
|
175
178
|
decorationSet: DecorationSet.empty,
|
|
@@ -238,7 +241,7 @@ export const createPlugin = (dispatch, eventDispatcher, editorAnalyticsAPI) => {
|
|
|
238
241
|
},
|
|
239
242
|
view: editorView => {
|
|
240
243
|
return {
|
|
241
|
-
destroy: destroyFn(editorView, editorAnalyticsAPI)
|
|
244
|
+
destroy: destroyFn(editorView, editorAnalyticsAPI, getEditorFeatureFlags)
|
|
242
245
|
};
|
|
243
246
|
},
|
|
244
247
|
props: {
|