@atlaskit/editor-plugin-table 7.5.3 → 7.5.5
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 +14 -0
- package/dist/cjs/commands/column-resize.js +3 -3
- package/dist/cjs/commands/delete.js +2 -2
- package/dist/cjs/commands/insert.js +15 -15
- package/dist/cjs/commands-with-analytics.js +7 -7
- package/dist/cjs/event-handlers.js +2 -2
- package/dist/cjs/nodeviews/TableComponent.js +46 -59
- package/dist/cjs/nodeviews/TableContainer.js +5 -5
- package/dist/cjs/nodeviews/TableResizer.js +12 -12
- package/dist/cjs/nodeviews/table.js +9 -9
- package/dist/cjs/plugin.js +58 -56
- package/dist/cjs/pm-plugins/drag-and-drop/plugin.js +13 -13
- package/dist/cjs/pm-plugins/keymap.js +6 -8
- package/dist/cjs/pm-plugins/main.js +4 -6
- package/dist/cjs/pm-plugins/sticky-headers/plugin.js +2 -3
- package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +12 -12
- package/dist/cjs/pm-plugins/table-resizing/utils/colgroup.js +2 -2
- package/dist/cjs/pm-plugins/table-resizing/utils/consts.js +4 -2
- package/dist/cjs/pm-plugins/table-resizing/utils/index.js +2 -2
- package/dist/cjs/pm-plugins/table-resizing/utils/misc.js +3 -3
- package/dist/cjs/pm-plugins/table-resizing/utils/resize-column.js +3 -3
- package/dist/cjs/pm-plugins/table-resizing/utils/resize-state.js +11 -12
- package/dist/cjs/pm-plugins/table-resizing/utils/scale-table.js +13 -13
- package/dist/cjs/pm-plugins/table-width.js +6 -2
- package/dist/cjs/toolbar.js +21 -21
- package/dist/cjs/transforms/column-width.js +4 -4
- package/dist/cjs/transforms/delete-columns.js +2 -2
- package/dist/cjs/ui/ColumnResizeWidget/index.js +4 -5
- package/dist/cjs/ui/FloatingContextualMenu/ContextualMenu.js +53 -55
- package/dist/cjs/ui/FloatingContextualMenu/index.js +2 -4
- package/dist/cjs/ui/FloatingDragMenu/DragMenu.js +2 -2
- package/dist/cjs/ui/FloatingDragMenu/index.js +6 -6
- package/dist/cjs/ui/FloatingInsertButton/index.js +6 -7
- package/dist/cjs/utils/create.js +2 -5
- package/dist/cjs/utils/drag-menu.js +4 -4
- package/dist/cjs/utils/guidelines.js +5 -2
- package/dist/cjs/utils/snapping.js +14 -1
- package/dist/es2019/commands/column-resize.js +3 -3
- package/dist/es2019/commands/delete.js +2 -2
- package/dist/es2019/commands/insert.js +12 -12
- package/dist/es2019/commands-with-analytics.js +6 -6
- package/dist/es2019/event-handlers.js +2 -2
- package/dist/es2019/nodeviews/TableComponent.js +25 -36
- package/dist/es2019/nodeviews/TableContainer.js +6 -6
- package/dist/es2019/nodeviews/TableResizer.js +14 -14
- package/dist/es2019/nodeviews/table.js +9 -9
- package/dist/es2019/plugin.js +17 -17
- package/dist/es2019/pm-plugins/drag-and-drop/plugin.js +6 -6
- package/dist/es2019/pm-plugins/keymap.js +5 -8
- package/dist/es2019/pm-plugins/main.js +3 -5
- package/dist/es2019/pm-plugins/sticky-headers/plugin.js +1 -1
- package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +5 -5
- package/dist/es2019/pm-plugins/table-resizing/utils/colgroup.js +2 -2
- package/dist/es2019/pm-plugins/table-resizing/utils/consts.js +3 -1
- package/dist/es2019/pm-plugins/table-resizing/utils/index.js +1 -1
- package/dist/es2019/pm-plugins/table-resizing/utils/misc.js +2 -2
- package/dist/es2019/pm-plugins/table-resizing/utils/resize-column.js +3 -2
- package/dist/es2019/pm-plugins/table-resizing/utils/resize-state.js +12 -13
- package/dist/es2019/pm-plugins/table-resizing/utils/scale-table.js +13 -13
- package/dist/es2019/pm-plugins/table-width.js +6 -2
- package/dist/es2019/toolbar.js +15 -15
- package/dist/es2019/transforms/column-width.js +5 -5
- package/dist/es2019/transforms/delete-columns.js +2 -2
- package/dist/es2019/ui/ColumnResizeWidget/index.js +0 -1
- package/dist/es2019/ui/FloatingContextualMenu/ContextualMenu.js +9 -12
- package/dist/es2019/ui/FloatingContextualMenu/index.js +2 -4
- package/dist/es2019/ui/FloatingDragMenu/DragMenu.js +2 -2
- package/dist/es2019/ui/FloatingDragMenu/index.js +5 -5
- package/dist/es2019/ui/FloatingInsertButton/index.js +5 -6
- package/dist/es2019/utils/create.js +2 -5
- package/dist/es2019/utils/drag-menu.js +4 -4
- package/dist/es2019/utils/guidelines.js +3 -2
- package/dist/es2019/utils/snapping.js +12 -1
- package/dist/esm/commands/column-resize.js +3 -3
- package/dist/esm/commands/delete.js +2 -2
- package/dist/esm/commands/insert.js +15 -15
- package/dist/esm/commands-with-analytics.js +7 -7
- package/dist/esm/event-handlers.js +2 -2
- package/dist/esm/nodeviews/TableComponent.js +45 -58
- package/dist/esm/nodeviews/TableContainer.js +6 -6
- package/dist/esm/nodeviews/TableResizer.js +14 -14
- package/dist/esm/nodeviews/table.js +9 -9
- package/dist/esm/plugin.js +58 -56
- package/dist/esm/pm-plugins/drag-and-drop/plugin.js +13 -13
- package/dist/esm/pm-plugins/keymap.js +6 -8
- package/dist/esm/pm-plugins/main.js +4 -6
- package/dist/esm/pm-plugins/sticky-headers/plugin.js +2 -3
- package/dist/esm/pm-plugins/table-resizing/event-handlers.js +12 -12
- package/dist/esm/pm-plugins/table-resizing/utils/colgroup.js +2 -2
- package/dist/esm/pm-plugins/table-resizing/utils/consts.js +3 -1
- package/dist/esm/pm-plugins/table-resizing/utils/index.js +1 -1
- package/dist/esm/pm-plugins/table-resizing/utils/misc.js +2 -2
- package/dist/esm/pm-plugins/table-resizing/utils/resize-column.js +4 -3
- package/dist/esm/pm-plugins/table-resizing/utils/resize-state.js +13 -14
- package/dist/esm/pm-plugins/table-resizing/utils/scale-table.js +13 -13
- package/dist/esm/pm-plugins/table-width.js +6 -2
- package/dist/esm/toolbar.js +21 -21
- package/dist/esm/transforms/column-width.js +5 -5
- package/dist/esm/transforms/delete-columns.js +2 -2
- package/dist/esm/ui/ColumnResizeWidget/index.js +0 -1
- package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +53 -55
- package/dist/esm/ui/FloatingContextualMenu/index.js +2 -4
- package/dist/esm/ui/FloatingDragMenu/DragMenu.js +2 -2
- package/dist/esm/ui/FloatingDragMenu/index.js +6 -6
- package/dist/esm/ui/FloatingInsertButton/index.js +6 -7
- package/dist/esm/utils/create.js +2 -5
- package/dist/esm/utils/drag-menu.js +4 -4
- package/dist/esm/utils/guidelines.js +5 -2
- package/dist/esm/utils/snapping.js +14 -1
- 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 +7 -7
- package/dist/types/commands-with-analytics.d.ts +3 -3
- package/dist/types/event-handlers.d.ts +1 -1
- package/dist/types/nodeviews/TableComponent.d.ts +2 -3
- package/dist/types/nodeviews/TableContainer.d.ts +4 -4
- package/dist/types/nodeviews/TableResizer.d.ts +2 -2
- package/dist/types/nodeviews/table.d.ts +1 -1
- package/dist/types/nodeviews/types.d.ts +1 -0
- package/dist/types/plugin.d.ts +1 -0
- package/dist/types/pm-plugins/drag-and-drop/plugin.d.ts +1 -2
- package/dist/types/pm-plugins/keymap.d.ts +2 -2
- package/dist/types/pm-plugins/main.d.ts +1 -1
- package/dist/types/pm-plugins/sticky-headers/plugin.d.ts +2 -3
- package/dist/types/pm-plugins/table-resizing/utils/colgroup.d.ts +1 -1
- package/dist/types/pm-plugins/table-resizing/utils/consts.d.ts +1 -0
- package/dist/types/pm-plugins/table-resizing/utils/index.d.ts +1 -1
- package/dist/types/pm-plugins/table-resizing/utils/misc.d.ts +1 -1
- package/dist/types/pm-plugins/table-resizing/utils/resize-column.d.ts +2 -1
- package/dist/types/pm-plugins/table-resizing/utils/resize-state.d.ts +4 -4
- package/dist/types/pm-plugins/table-resizing/utils/scale-table.d.ts +4 -4
- package/dist/types/pm-plugins/table-width.d.ts +1 -2
- 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/types.d.ts +1 -0
- package/dist/types/ui/ColumnResizeWidget/index.d.ts +2 -2
- package/dist/types/ui/FloatingContextualMenu/index.d.ts +1 -1
- package/dist/types/ui/FloatingDragMenu/DragMenu.d.ts +2 -2
- package/dist/types/ui/FloatingDragMenu/index.d.ts +2 -3
- package/dist/types/ui/FloatingInsertButton/index.d.ts +1 -2
- package/dist/types/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.d.ts +2 -2
- package/dist/types/ui/TableFloatingColumnControls/ColumnDropTargets/index.d.ts +2 -2
- package/dist/types/ui/TableFloatingColumnControls/index.d.ts +2 -2
- package/dist/types/utils/create.d.ts +1 -2
- package/dist/types/utils/drag-menu.d.ts +2 -2
- package/dist/types/utils/guidelines.d.ts +1 -0
- package/dist/types/utils/snapping.d.ts +2 -0
- 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 +7 -7
- package/dist/types-ts4.5/commands-with-analytics.d.ts +3 -3
- package/dist/types-ts4.5/event-handlers.d.ts +1 -1
- package/dist/types-ts4.5/nodeviews/TableComponent.d.ts +2 -3
- package/dist/types-ts4.5/nodeviews/TableContainer.d.ts +4 -4
- package/dist/types-ts4.5/nodeviews/TableResizer.d.ts +2 -2
- package/dist/types-ts4.5/nodeviews/table.d.ts +1 -1
- package/dist/types-ts4.5/nodeviews/types.d.ts +1 -0
- package/dist/types-ts4.5/plugin.d.ts +1 -0
- package/dist/types-ts4.5/pm-plugins/drag-and-drop/plugin.d.ts +1 -2
- package/dist/types-ts4.5/pm-plugins/keymap.d.ts +2 -2
- package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/sticky-headers/plugin.d.ts +2 -3
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/colgroup.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/consts.d.ts +1 -0
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/index.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/misc.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/resize-column.d.ts +2 -1
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/resize-state.d.ts +4 -4
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/scale-table.d.ts +4 -4
- package/dist/types-ts4.5/pm-plugins/table-width.d.ts +1 -2
- 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/types.d.ts +1 -0
- package/dist/types-ts4.5/ui/ColumnResizeWidget/index.d.ts +2 -2
- package/dist/types-ts4.5/ui/FloatingContextualMenu/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/FloatingDragMenu/DragMenu.d.ts +2 -2
- package/dist/types-ts4.5/ui/FloatingDragMenu/index.d.ts +2 -3
- package/dist/types-ts4.5/ui/FloatingInsertButton/index.d.ts +1 -2
- package/dist/types-ts4.5/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.d.ts +2 -2
- package/dist/types-ts4.5/ui/TableFloatingColumnControls/ColumnDropTargets/index.d.ts +2 -2
- package/dist/types-ts4.5/ui/TableFloatingColumnControls/index.d.ts +2 -2
- package/dist/types-ts4.5/utils/create.d.ts +1 -2
- package/dist/types-ts4.5/utils/drag-menu.d.ts +2 -2
- package/dist/types-ts4.5/utils/guidelines.d.ts +1 -0
- package/dist/types-ts4.5/utils/snapping.d.ts +2 -0
- package/package.json +2 -2
- package/src/commands/column-resize.ts +4 -3
- package/src/commands/delete.ts +2 -2
- package/src/commands/insert.ts +15 -27
- package/src/commands-with-analytics.ts +6 -9
- package/src/event-handlers.ts +2 -2
- package/src/nodeviews/TableComponent.tsx +31 -46
- package/src/nodeviews/TableContainer.tsx +16 -7
- package/src/nodeviews/TableResizer.tsx +44 -24
- package/src/nodeviews/table.tsx +6 -5
- package/src/nodeviews/types.ts +1 -0
- package/src/plugin.tsx +12 -28
- package/src/pm-plugins/drag-and-drop/plugin.ts +10 -15
- package/src/pm-plugins/keymap.ts +6 -13
- package/src/pm-plugins/main.ts +3 -3
- package/src/pm-plugins/sticky-headers/plugin.ts +2 -11
- package/src/pm-plugins/table-resizing/event-handlers.ts +6 -4
- package/src/pm-plugins/table-resizing/utils/colgroup.ts +2 -2
- package/src/pm-plugins/table-resizing/utils/consts.ts +2 -0
- package/src/pm-plugins/table-resizing/utils/index.ts +1 -1
- package/src/pm-plugins/table-resizing/utils/misc.ts +2 -2
- package/src/pm-plugins/table-resizing/utils/resize-column.ts +5 -2
- package/src/pm-plugins/table-resizing/utils/resize-state.ts +18 -13
- package/src/pm-plugins/table-resizing/utils/scale-table.ts +14 -14
- package/src/pm-plugins/table-width.ts +4 -6
- package/src/toolbar.tsx +16 -19
- package/src/transforms/column-width.ts +7 -6
- package/src/transforms/delete-columns.ts +2 -2
- package/src/types.ts +1 -0
- package/src/ui/ColumnResizeWidget/index.tsx +2 -4
- package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +11 -16
- package/src/ui/FloatingContextualMenu/index.tsx +0 -2
- package/src/ui/FloatingDragMenu/DragMenu.tsx +3 -3
- package/src/ui/FloatingDragMenu/index.tsx +4 -8
- package/src/ui/FloatingInsertButton/index.tsx +11 -22
- package/src/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.tsx +2 -2
- package/src/ui/TableFloatingColumnControls/ColumnDropTargets/index.tsx +2 -2
- package/src/ui/TableFloatingColumnControls/index.tsx +2 -2
- package/src/utils/create.ts +2 -5
- package/src/utils/drag-menu.ts +8 -13
- package/src/utils/guidelines.ts +12 -1
- package/src/utils/snapping.ts +36 -0
|
@@ -9,6 +9,7 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
9
9
|
var _ui = require("@atlaskit/editor-common/ui");
|
|
10
10
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
11
11
|
var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
|
|
12
|
+
var _pluginFactory = require("../../pm-plugins/plugin-factory");
|
|
12
13
|
var _consts = require("../consts");
|
|
13
14
|
var _DragMenu = _interopRequireDefault(require("./DragMenu"));
|
|
14
15
|
var FloatingDragMenu = function FloatingDragMenu(_ref) {
|
|
@@ -24,8 +25,7 @@ var FloatingDragMenu = function FloatingDragMenu(_ref) {
|
|
|
24
25
|
getEditorContainerWidth = _ref.getEditorContainerWidth,
|
|
25
26
|
editorAnalyticsAPI = _ref.editorAnalyticsAPI,
|
|
26
27
|
stickyHeaders = _ref.stickyHeaders,
|
|
27
|
-
pluginConfig = _ref.pluginConfig
|
|
28
|
-
getEditorFeatureFlags = _ref.getEditorFeatureFlags;
|
|
28
|
+
pluginConfig = _ref.pluginConfig;
|
|
29
29
|
if (!isOpen || !targetCellPosition || editorView.state.doc.nodeSize <= targetCellPosition) {
|
|
30
30
|
return null;
|
|
31
31
|
}
|
|
@@ -35,9 +35,9 @@ var FloatingDragMenu = function FloatingDragMenu(_ref) {
|
|
|
35
35
|
if (!targetHandleRef || !(editorView.state.selection instanceof _cellSelection.CellSelection)) {
|
|
36
36
|
return null;
|
|
37
37
|
}
|
|
38
|
-
var
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
var _getPluginState = (0, _pluginFactory.getPluginState)(editorView.state),
|
|
39
|
+
_getPluginState$isTab = _getPluginState.isTableScalingEnabled,
|
|
40
|
+
isTableScalingEnabled = _getPluginState$isTab === void 0 ? false : _getPluginState$isTab;
|
|
41
41
|
return /*#__PURE__*/_react.default.createElement(_ui.Popup, {
|
|
42
42
|
alignX: direction === 'row' ? 'right' : undefined,
|
|
43
43
|
alignY: direction === 'row' ? 'start' : undefined,
|
|
@@ -71,7 +71,7 @@ var FloatingDragMenu = function FloatingDragMenu(_ref) {
|
|
|
71
71
|
mountPoint: mountPoint,
|
|
72
72
|
boundariesElement: boundariesElement,
|
|
73
73
|
scrollableElement: scrollableElement,
|
|
74
|
-
|
|
74
|
+
isTableScalingEnabled: isTableScalingEnabled
|
|
75
75
|
}));
|
|
76
76
|
};
|
|
77
77
|
FloatingDragMenu.displayName = 'FloatingDragMenu';
|
|
@@ -25,6 +25,7 @@ var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
|
|
|
25
25
|
var _tableMap = require("@atlaskit/editor-tables/table-map");
|
|
26
26
|
var _utils3 = require("@atlaskit/editor-tables/utils");
|
|
27
27
|
var _commandsWithAnalytics = require("../../commands-with-analytics");
|
|
28
|
+
var _pluginFactory = require("../../pm-plugins/plugin-factory");
|
|
28
29
|
var _types = require("../../types");
|
|
29
30
|
var _utils4 = require("../../utils");
|
|
30
31
|
var _getPopupOptions = _interopRequireDefault(require("./getPopupOptions"));
|
|
@@ -195,17 +196,15 @@ var FloatingInsertButton = exports.FloatingInsertButton = /*#__PURE__*/function
|
|
|
195
196
|
var _this$props4 = this.props,
|
|
196
197
|
editorView = _this$props4.editorView,
|
|
197
198
|
insertColumnButtonIndex = _this$props4.insertColumnButtonIndex,
|
|
198
|
-
editorAnalyticsAPI = _this$props4.editorAnalyticsAPI
|
|
199
|
-
getEditorContainerWidth = _this$props4.getEditorContainerWidth;
|
|
199
|
+
editorAnalyticsAPI = _this$props4.editorAnalyticsAPI;
|
|
200
200
|
if (typeof insertColumnButtonIndex !== 'undefined') {
|
|
201
|
-
var _this$props$getEditor, _this$props5;
|
|
202
201
|
event.preventDefault();
|
|
203
|
-
var
|
|
204
|
-
|
|
205
|
-
|
|
202
|
+
var _getPluginState = (0, _pluginFactory.getPluginState)(editorView.state),
|
|
203
|
+
_getPluginState$isTab = _getPluginState.isTableScalingEnabled,
|
|
204
|
+
isTableScalingEnabled = _getPluginState$isTab === void 0 ? false : _getPluginState$isTab;
|
|
206
205
|
var state = editorView.state,
|
|
207
206
|
dispatch = editorView.dispatch;
|
|
208
|
-
(0, _commandsWithAnalytics.insertColumnWithAnalytics)(
|
|
207
|
+
(0, _commandsWithAnalytics.insertColumnWithAnalytics)(editorAnalyticsAPI, isTableScalingEnabled)(_analytics.INPUT_METHOD.BUTTON, insertColumnButtonIndex)(state, dispatch, editorView);
|
|
209
208
|
}
|
|
210
209
|
}
|
|
211
210
|
}]);
|
package/dist/cjs/utils/create.js
CHANGED
|
@@ -10,12 +10,9 @@ var _utils = require("@atlaskit/editor-tables/utils");
|
|
|
10
10
|
var _utils2 = require("../pm-plugins/table-resizing/utils");
|
|
11
11
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
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
|
-
var createTableWithWidth = exports.createTableWithWidth = function createTableWithWidth(
|
|
13
|
+
var createTableWithWidth = exports.createTableWithWidth = function createTableWithWidth(isTableScalingEnabled, isFullWidthModeEnabled, createTableProps) {
|
|
14
14
|
return function (schema) {
|
|
15
|
-
|
|
16
|
-
_ref$tablePreserveWid = _ref.tablePreserveWidth,
|
|
17
|
-
tablePreserveWidth = _ref$tablePreserveWid === void 0 ? false : _ref$tablePreserveWid;
|
|
18
|
-
if (tablePreserveWidth && isFullWidthModeEnabled) {
|
|
15
|
+
if (isTableScalingEnabled && isFullWidthModeEnabled) {
|
|
19
16
|
return (0, _utils.createTable)(_objectSpread({
|
|
20
17
|
schema: schema,
|
|
21
18
|
tableWidth: _utils2.TABLE_MAX_WIDTH
|
|
@@ -70,7 +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
|
|
73
|
+
var isTableScalingEnabled = arguments.length > 11 && arguments[11] !== undefined ? arguments[11] : false;
|
|
74
74
|
var addOptions = direction === 'row' ? [{
|
|
75
75
|
label: 'above',
|
|
76
76
|
offset: 0,
|
|
@@ -155,7 +155,7 @@ var getDragMenuConfig = exports.getDragMenuConfig = function getDragMenuConfig(d
|
|
|
155
155
|
moveCursorToInsertedRow: true
|
|
156
156
|
})(state, dispatch);
|
|
157
157
|
} else {
|
|
158
|
-
(0, _commandsWithAnalytics.insertColumnWithAnalytics)(
|
|
158
|
+
(0, _commandsWithAnalytics.insertColumnWithAnalytics)(editorAnalyticsAPI, isTableScalingEnabled)(_analytics.INPUT_METHOD.TABLE_CONTEXT_MENU, (index !== null && index !== void 0 ? index : 0) + offset)(state, dispatch, editorView);
|
|
159
159
|
}
|
|
160
160
|
return true;
|
|
161
161
|
},
|
|
@@ -168,7 +168,7 @@ var getDragMenuConfig = exports.getDragMenuConfig = function getDragMenuConfig(d
|
|
|
168
168
|
onClick: function onClick(state, dispatch) {
|
|
169
169
|
var selectionRect = (0, _toolbar.getClosestSelectionRect)(state);
|
|
170
170
|
if (selectionRect) {
|
|
171
|
-
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, isTableScalingEnabled);
|
|
172
172
|
if (newResizeState) {
|
|
173
173
|
(0, _commandsWithAnalytics.distributeColumnsWidthsWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.TABLE_CONTEXT_MENU, newResizeState)(state, dispatch);
|
|
174
174
|
return true;
|
|
@@ -194,7 +194,7 @@ var getDragMenuConfig = exports.getDragMenuConfig = function getDragMenuConfig(d
|
|
|
194
194
|
if (direction === 'row') {
|
|
195
195
|
(0, _commandsWithAnalytics.deleteRowsWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.TABLE_CONTEXT_MENU, selectionRect !== null && selectionRect !== void 0 ? selectionRect : defaultSelectionRect, !!isHeaderRowRequired)(state, dispatch);
|
|
196
196
|
} else {
|
|
197
|
-
(0, _commandsWithAnalytics.deleteColumnsWithAnalytics)(editorAnalyticsAPI,
|
|
197
|
+
(0, _commandsWithAnalytics.deleteColumnsWithAnalytics)(editorAnalyticsAPI, isTableScalingEnabled)(_analytics.INPUT_METHOD.TABLE_CONTEXT_MENU, selectionRect !== null && selectionRect !== void 0 ? selectionRect : defaultSelectionRect)(state, dispatch, editorView);
|
|
198
198
|
}
|
|
199
199
|
return true;
|
|
200
200
|
},
|
|
@@ -4,10 +4,13 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.defaultGuidelines = void 0;
|
|
7
|
+
exports.defaultGuidelinesForPreserveTable = exports.defaultGuidelines = void 0;
|
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
9
|
var _guideline = require("@atlaskit/editor-common/guideline");
|
|
10
10
|
var _snapping = require("./snapping");
|
|
11
11
|
// NOTE: We have to take 1 pixel off every length due to the fact that the tbody is 1px smaller then the table container.
|
|
12
12
|
// If we don't do this then the guidelines will not align correctly to the edge of the table
|
|
13
|
-
var defaultGuidelines = exports.defaultGuidelines = (0, _guideline.createFixedGuidelinesFromLengths)([0].concat((0, _toConsumableArray2.default)((0, _snapping.calculateDefaultSnappings)(-1))));
|
|
13
|
+
var defaultGuidelines = exports.defaultGuidelines = (0, _guideline.createFixedGuidelinesFromLengths)([0].concat((0, _toConsumableArray2.default)((0, _snapping.calculateDefaultSnappings)(-1))));
|
|
14
|
+
var defaultGuidelinesForPreserveTable = exports.defaultGuidelinesForPreserveTable = function defaultGuidelinesForPreserveTable(editorContainerWidth) {
|
|
15
|
+
return (0, _guideline.createFixedGuidelinesFromLengths)([0].concat((0, _toConsumableArray2.default)((0, _snapping.calculateDefaultTablePreserveSnappings)(-1, editorContainerWidth))));
|
|
16
|
+
};
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.findClosestSnap = exports.defaultSnappingWidths = exports.calculateDefaultSnappings = void 0;
|
|
7
|
+
exports.findClosestSnap = exports.defaultTablePreserveSnappingWidths = exports.defaultSnappingWidths = exports.calculateDefaultTablePreserveSnappings = exports.calculateDefaultSnappings = void 0;
|
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
9
|
var _guideline = require("@atlaskit/editor-common/guideline");
|
|
10
10
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
@@ -18,8 +18,21 @@ var calculateDefaultSnappings = exports.calculateDefaultSnappings = function cal
|
|
|
18
18
|
var lengthOffset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
19
19
|
return [].concat((0, _toConsumableArray2.default)(calculateSubSnappingWidths(numberOfLanesInDefaultLayoutWidth, _editorSharedStyles.akEditorDefaultLayoutWidth + lengthOffset)), [_editorSharedStyles.akEditorDefaultLayoutWidth + lengthOffset, _editorSharedStyles.akEditorCalculatedWideLayoutWidth + lengthOffset, _editorSharedStyles.akEditorFullWidthLayoutWidth + lengthOffset]);
|
|
20
20
|
};
|
|
21
|
+
|
|
22
|
+
// FF TablePreserve for calculateDefaultSnappings
|
|
23
|
+
var calculateDefaultTablePreserveSnappings = exports.calculateDefaultTablePreserveSnappings = function calculateDefaultTablePreserveSnappings() {
|
|
24
|
+
var lengthOffset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
25
|
+
var editorContainerWith = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _editorSharedStyles.akEditorFullWidthLayoutWidth;
|
|
26
|
+
var dynamicFullWidthLine = editorContainerWith - _editorSharedStyles.akEditorGutterPadding * 2 >= _editorSharedStyles.akEditorFullWidthLayoutWidth ? _editorSharedStyles.akEditorFullWidthLayoutWidth : editorContainerWith - _editorSharedStyles.akEditorGutterPadding * 2 - _editorSharedStyles.akEditorMediaResizeHandlerPaddingWide;
|
|
27
|
+
return [].concat((0, _toConsumableArray2.default)(calculateSubSnappingWidths(numberOfLanesInDefaultLayoutWidth, _editorSharedStyles.akEditorDefaultLayoutWidth + lengthOffset)), [_editorSharedStyles.akEditorDefaultLayoutWidth + lengthOffset, _editorSharedStyles.akEditorCalculatedWideLayoutWidth + lengthOffset, dynamicFullWidthLine - lengthOffset]);
|
|
28
|
+
};
|
|
21
29
|
var defaultSnappingWidths = exports.defaultSnappingWidths = calculateDefaultSnappings();
|
|
22
30
|
|
|
31
|
+
// FF TablePreserve for defaultSnappingWidths
|
|
32
|
+
var defaultTablePreserveSnappingWidths = exports.defaultTablePreserveSnappingWidths = function defaultTablePreserveSnappingWidths(editorContainerWidth) {
|
|
33
|
+
return editorContainerWidth - _editorSharedStyles.akEditorGutterPadding * 2 > _editorSharedStyles.akEditorFullWidthLayoutWidth ? calculateDefaultSnappings() : calculateDefaultTablePreserveSnappings(0, editorContainerWidth);
|
|
34
|
+
};
|
|
35
|
+
|
|
23
36
|
/**
|
|
24
37
|
* Returns keys of guidelines that are closest to the table and withthin the snapGap
|
|
25
38
|
*/
|
|
@@ -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,
|
|
124
|
+
export const changeColumnWidthByStep = (stepSize, getEditorContainerWidth, isTableScalingEnabled = false) => (state, dispatch, view) => {
|
|
125
125
|
let customTr = state.tr;
|
|
126
126
|
const fakeDispatch = tr => {
|
|
127
127
|
customTr = tr;
|
|
@@ -171,14 +171,14 @@ export const changeColumnWidthByStep = (stepSize, getEditorContainerWidth, table
|
|
|
171
171
|
tableRef: dom,
|
|
172
172
|
start: tableStartPosition,
|
|
173
173
|
domAtPos,
|
|
174
|
-
|
|
174
|
+
isTableScalingEnabled
|
|
175
175
|
});
|
|
176
176
|
updateControls()(state);
|
|
177
177
|
const selectionRect = getSelectionRect(state.selection);
|
|
178
178
|
const selectedColumns = selectionRect ? getSelectedColumnIndexes(selectionRect) : [];
|
|
179
179
|
// only selected (or selected - 1) columns should be distributed
|
|
180
180
|
const resizingSelectedColumns = selectedColumns.indexOf(colIndex) > -1 || selectedColumns.indexOf(colIndex + 1) > -1;
|
|
181
|
-
const newResizeState = resizeColumn(initialResizeState, colIndex, stepSize, dom, resizingSelectedColumns ? selectedColumns : undefined,
|
|
181
|
+
const newResizeState = resizeColumn(initialResizeState, colIndex, stepSize, dom, originalTable, resizingSelectedColumns ? selectedColumns : undefined, isTableScalingEnabled);
|
|
182
182
|
customTr = updateColumnWidths(newResizeState, originalTable, tableStartPosition)(customTr);
|
|
183
183
|
if (dispatch) {
|
|
184
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,
|
|
4
|
-
const tr = deleteColumns(rect, getAllowAddColumnCustomStep(state), view,
|
|
3
|
+
export const deleteColumnsCommand = (rect, isTableScalingEnabled = false) => (state, dispatch, view) => {
|
|
4
|
+
const tr = deleteColumns(rect, getAllowAddColumnCustomStep(state), view, isTableScalingEnabled)(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(
|
|
23
|
+
export function addColumnAt(isTableScalingEnabled = 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, tablePreserveWidth = false)
|
|
|
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(
|
|
35
|
+
updatedTr = rescaleColumns(isTableScalingEnabled)(table, view)(updatedTr);
|
|
36
36
|
}
|
|
37
37
|
if (getBooleanFF('platform.editor.table.analytics-plugin-moved-event') && view) {
|
|
38
38
|
updatedTr = updateRowOrColumnMovedTransform({
|
|
@@ -49,33 +49,33 @@ export function addColumnAt(getEditorContainerWidth, tablePreserveWidth = false)
|
|
|
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 = (
|
|
52
|
+
export const addColumnBefore = (isTableScalingEnabled = 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(
|
|
59
|
+
dispatch(addColumnAt(isTableScalingEnabled)(rect.left, getAllowAddColumnCustomStep(state), view)(state.tr));
|
|
60
60
|
}
|
|
61
61
|
return true;
|
|
62
62
|
};
|
|
63
63
|
|
|
64
64
|
// :: (EditorState, dispatch: ?(tr: Transaction)) → bool
|
|
65
65
|
// Command to add a column after the column with the selection.
|
|
66
|
-
export const addColumnAfter =
|
|
66
|
+
export const addColumnAfter = isTableScalingEnabled => (state, dispatch, view) => {
|
|
67
67
|
const table = findTable(state.selection);
|
|
68
68
|
if (!table) {
|
|
69
69
|
return false;
|
|
70
70
|
}
|
|
71
71
|
if (dispatch) {
|
|
72
72
|
let rect = selectedRect(state);
|
|
73
|
-
dispatch(addColumnAt(
|
|
73
|
+
dispatch(addColumnAt(isTableScalingEnabled)(rect.right, getAllowAddColumnCustomStep(state), view)(state.tr));
|
|
74
74
|
}
|
|
75
75
|
return true;
|
|
76
76
|
};
|
|
77
|
-
export const insertColumn = (
|
|
78
|
-
let tr = addColumnAt(
|
|
77
|
+
export const insertColumn = (isTableScalingEnabled = false) => column => (state, dispatch, view) => {
|
|
78
|
+
let tr = addColumnAt(isTableScalingEnabled)(column, getAllowAddColumnCustomStep(state), view)(state.tr);
|
|
79
79
|
const table = findTable(tr.selection);
|
|
80
80
|
if (!table) {
|
|
81
81
|
return false;
|
|
@@ -122,18 +122,18 @@ export const insertRow = (row, moveCursorToTheNewRow) => (state, dispatch) => {
|
|
|
122
122
|
}
|
|
123
123
|
return true;
|
|
124
124
|
};
|
|
125
|
-
export const createTable = (
|
|
126
|
-
const table = createTableWithWidth(
|
|
125
|
+
export const createTable = (isTableScalingEnabled, isFullWidthModeEnabled) => (state, dispatch) => {
|
|
126
|
+
const table = createTableWithWidth(isTableScalingEnabled, isFullWidthModeEnabled)(state.schema);
|
|
127
127
|
if (dispatch) {
|
|
128
128
|
dispatch(safeInsert(table)(state.tr).scrollIntoView());
|
|
129
129
|
}
|
|
130
130
|
return true;
|
|
131
131
|
};
|
|
132
|
-
export const insertTableWithSize = (isFullWidthModeEnabled,
|
|
132
|
+
export const insertTableWithSize = (isFullWidthModeEnabled, isTableScalingEnabled, editorAnalyticsAPI) => (rowsCount, colsCount, inputMethod) => {
|
|
133
133
|
return ({
|
|
134
134
|
tr
|
|
135
135
|
}) => {
|
|
136
|
-
const tableNode = createTableWithWidth(
|
|
136
|
+
const tableNode = createTableWithWidth(isTableScalingEnabled, isFullWidthModeEnabled, {
|
|
137
137
|
rowsCount: rowsCount,
|
|
138
138
|
colsCount: colsCount
|
|
139
139
|
})(tr.doc.type.schema);
|
|
@@ -168,7 +168,7 @@ export const insertRowWithAnalytics = editorAnalyticsAPI => (inputMethod, option
|
|
|
168
168
|
eventType: EVENT_TYPE.TRACK
|
|
169
169
|
};
|
|
170
170
|
})(editorAnalyticsAPI)(insertRow(options.index, options.moveCursorToInsertedRow));
|
|
171
|
-
export const changeColumnWidthByStepWithAnalytics = editorAnalyticsAPI => (stepSize, getEditorContainerWidth,
|
|
171
|
+
export const changeColumnWidthByStepWithAnalytics = editorAnalyticsAPI => (stepSize, getEditorContainerWidth, isTableScalingEnabled, inputMethod) => withEditorAnalyticsAPI(state => {
|
|
172
172
|
const {
|
|
173
173
|
table,
|
|
174
174
|
totalRowCount,
|
|
@@ -193,8 +193,8 @@ export const changeColumnWidthByStepWithAnalytics = editorAnalyticsAPI => (stepS
|
|
|
193
193
|
totalColumnCount
|
|
194
194
|
}
|
|
195
195
|
};
|
|
196
|
-
})(editorAnalyticsAPI)(changeColumnWidthByStep(stepSize, getEditorContainerWidth,
|
|
197
|
-
export const insertColumnWithAnalytics = (
|
|
196
|
+
})(editorAnalyticsAPI)(changeColumnWidthByStep(stepSize, getEditorContainerWidth, isTableScalingEnabled));
|
|
197
|
+
export const insertColumnWithAnalytics = (editorAnalyticsAPI, isTableScalingEnabled = false) => (inputMethod, position) => withEditorAnalyticsAPI(state => {
|
|
198
198
|
const {
|
|
199
199
|
totalRowCount,
|
|
200
200
|
totalColumnCount
|
|
@@ -211,7 +211,7 @@ export const insertColumnWithAnalytics = (getEditorContainerWidth, editorAnalyti
|
|
|
211
211
|
},
|
|
212
212
|
eventType: EVENT_TYPE.TRACK
|
|
213
213
|
};
|
|
214
|
-
})(editorAnalyticsAPI)(insertColumn(
|
|
214
|
+
})(editorAnalyticsAPI)(insertColumn(isTableScalingEnabled)(position));
|
|
215
215
|
export const deleteRowsWithAnalytics = editorAnalyticsAPI => (inputMethod, rect, isHeaderRowRequired) => withEditorAnalyticsAPI(({
|
|
216
216
|
selection
|
|
217
217
|
}) => {
|
|
@@ -238,7 +238,7 @@ export const deleteRowsWithAnalytics = editorAnalyticsAPI => (inputMethod, rect,
|
|
|
238
238
|
}
|
|
239
239
|
return true;
|
|
240
240
|
});
|
|
241
|
-
export const deleteColumnsWithAnalytics = (editorAnalyticsAPI,
|
|
241
|
+
export const deleteColumnsWithAnalytics = (editorAnalyticsAPI, isTableScalingEnabled = false) => (inputMethod, rect) => withEditorAnalyticsAPI(({
|
|
242
242
|
selection
|
|
243
243
|
}) => {
|
|
244
244
|
const {
|
|
@@ -258,7 +258,7 @@ export const deleteColumnsWithAnalytics = (editorAnalyticsAPI, tablePreserveWidt
|
|
|
258
258
|
},
|
|
259
259
|
eventType: EVENT_TYPE.TRACK
|
|
260
260
|
};
|
|
261
|
-
})(editorAnalyticsAPI)(deleteColumnsCommand(rect,
|
|
261
|
+
})(editorAnalyticsAPI)(deleteColumnsCommand(rect, isTableScalingEnabled));
|
|
262
262
|
export const deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut = editorAnalyticsAPI => (state, dispatch) => {
|
|
263
263
|
const {
|
|
264
264
|
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, isTableScalingEnabled = 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,
|
|
397
|
+
tr = deleteColumns(rect, getAllowAddColumnCustomStep(oldState), editorView, isTableScalingEnabled)(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,
|
|
9
|
+
import { browser, 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';
|
|
@@ -18,6 +18,7 @@ import { findStickyHeaderForTable, pluginKey as stickyHeadersPluginKey } from '.
|
|
|
18
18
|
import { META_KEYS } from '../pm-plugins/table-analytics';
|
|
19
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
|
+
import { TABLE_EDITOR_MARGIN } from '../pm-plugins/table-resizing/utils/consts';
|
|
21
22
|
import { updateControls } from '../pm-plugins/table-resizing/utils/dom';
|
|
22
23
|
import { TableCssClassName as ClassName, ShadowEvent } from '../types';
|
|
23
24
|
import { tableOverflowShadowWidth, tableOverflowShadowWidthWide } from '../ui/consts';
|
|
@@ -161,7 +162,7 @@ class TableComponent extends React.Component {
|
|
|
161
162
|
getPos,
|
|
162
163
|
containerWidth,
|
|
163
164
|
options,
|
|
164
|
-
|
|
165
|
+
isTableScalingEnabled
|
|
165
166
|
} = this.props;
|
|
166
167
|
const node = getNode();
|
|
167
168
|
const {
|
|
@@ -177,9 +178,6 @@ class TableComponent extends React.Component {
|
|
|
177
178
|
width
|
|
178
179
|
} = containerWidth;
|
|
179
180
|
this.scaleTableDebounced.cancel();
|
|
180
|
-
const {
|
|
181
|
-
tablePreserveWidth = false
|
|
182
|
-
} = getEditorFeatureFlags();
|
|
183
181
|
const tr = scaleTable(this.table, {
|
|
184
182
|
...scaleOptions,
|
|
185
183
|
node,
|
|
@@ -188,7 +186,7 @@ class TableComponent extends React.Component {
|
|
|
188
186
|
containerWidth: width,
|
|
189
187
|
previousContainerWidth: this.containerWidth.width || width,
|
|
190
188
|
...options
|
|
191
|
-
}, domAtPos,
|
|
189
|
+
}, domAtPos, isTableScalingEnabled)(state.tr);
|
|
192
190
|
dispatch(tr);
|
|
193
191
|
});
|
|
194
192
|
_defineProperty(this, "setTimerToSendInitialOverflowCaptured", isOverflowing => {
|
|
@@ -313,8 +311,12 @@ class TableComponent extends React.Component {
|
|
|
313
311
|
options,
|
|
314
312
|
isDragAndDropEnabled,
|
|
315
313
|
getNode,
|
|
316
|
-
getEditorFeatureFlags
|
|
314
|
+
getEditorFeatureFlags,
|
|
315
|
+
isTableScalingEnabled
|
|
317
316
|
} = this.props;
|
|
317
|
+
if (isTableScalingEnabled) {
|
|
318
|
+
this.handleColgroupUpdates(true);
|
|
319
|
+
}
|
|
318
320
|
if (allowColumnResizing && this.wrapper && !isIE11) {
|
|
319
321
|
this.wrapper.addEventListener('scroll', this.handleScrollDebounced, {
|
|
320
322
|
passive: true
|
|
@@ -392,24 +394,22 @@ class TableComponent extends React.Component {
|
|
|
392
394
|
clearTimeout(this.initialOverflowCaptureTimerId);
|
|
393
395
|
}
|
|
394
396
|
}
|
|
395
|
-
handleColgroupUpdates() {
|
|
397
|
+
handleColgroupUpdates(force = false) {
|
|
396
398
|
var _this$containerWidth;
|
|
397
399
|
const {
|
|
398
400
|
getNode,
|
|
399
401
|
containerWidth,
|
|
400
402
|
isResizing,
|
|
401
403
|
view,
|
|
402
|
-
getPos
|
|
403
|
-
tableRef
|
|
404
|
+
getPos
|
|
404
405
|
} = this.props;
|
|
405
|
-
if (!
|
|
406
|
+
if (!this.table) {
|
|
406
407
|
return;
|
|
407
408
|
}
|
|
408
|
-
const TABLE_MARGIN = 76;
|
|
409
409
|
|
|
410
410
|
// Remove any widths styles after resizing preview is completed
|
|
411
|
-
|
|
412
|
-
const tableRenderWidth = containerWidth.width -
|
|
411
|
+
this.table.style.width = '';
|
|
412
|
+
const tableRenderWidth = containerWidth.width - TABLE_EDITOR_MARGIN;
|
|
413
413
|
const tableNode = getNode();
|
|
414
414
|
const start = getPos() || 0;
|
|
415
415
|
const depth = view.state.doc.resolve(start).depth;
|
|
@@ -421,17 +421,12 @@ class TableComponent extends React.Component {
|
|
|
421
421
|
const {
|
|
422
422
|
width: tableNodeWidth
|
|
423
423
|
} = tableNode.attrs;
|
|
424
|
-
const tableColumnWidths = calcTableColumnWidths(tableNode);
|
|
425
424
|
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
425
|
const {
|
|
431
426
|
width: containerWidthValue
|
|
432
427
|
} = containerWidth;
|
|
433
428
|
const isWidthChanged = ((_this$containerWidth = this.containerWidth) === null || _this$containerWidth === void 0 ? void 0 : _this$containerWidth.width) !== containerWidthValue;
|
|
434
|
-
if (shouldTableScale && !isResizing &&
|
|
429
|
+
if (force || shouldTableScale && !isResizing && isWidthChanged) {
|
|
435
430
|
const resizeState = getResizeState({
|
|
436
431
|
minWidth: COLUMN_MIN_WIDTH,
|
|
437
432
|
maxSize: tableRenderWidth,
|
|
@@ -439,14 +434,11 @@ class TableComponent extends React.Component {
|
|
|
439
434
|
tableRef: this.table,
|
|
440
435
|
start,
|
|
441
436
|
domAtPos: view.domAtPos,
|
|
442
|
-
|
|
443
|
-
});
|
|
444
|
-
requestAnimationFrame(() => {
|
|
445
|
-
updateColgroup(resizeState, this.table, true);
|
|
437
|
+
isTableScalingEnabled: true
|
|
446
438
|
});
|
|
447
|
-
this.
|
|
448
|
-
this.containerWidth = containerWidth;
|
|
439
|
+
updateColgroup(resizeState, this.table, tableNode, true);
|
|
449
440
|
}
|
|
441
|
+
this.containerWidth = containerWidth;
|
|
450
442
|
}
|
|
451
443
|
componentDidUpdate(_, prevState) {
|
|
452
444
|
var _this$wrapper;
|
|
@@ -457,16 +449,13 @@ class TableComponent extends React.Component {
|
|
|
457
449
|
allowColumnResizing,
|
|
458
450
|
isResizing,
|
|
459
451
|
options,
|
|
460
|
-
|
|
452
|
+
isTableScalingEnabled
|
|
461
453
|
} = this.props;
|
|
462
454
|
const {
|
|
463
455
|
isInDanger
|
|
464
456
|
} = getPluginState(view.state);
|
|
465
|
-
const {
|
|
466
|
-
tablePreserveWidth = false
|
|
467
|
-
} = getEditorFeatureFlags();
|
|
468
457
|
const table = findTable(view.state.selection);
|
|
469
|
-
if (
|
|
458
|
+
if (isTableScalingEnabled) {
|
|
470
459
|
this.handleColgroupUpdates();
|
|
471
460
|
}
|
|
472
461
|
if (isInDanger && !table) {
|
|
@@ -505,7 +494,7 @@ class TableComponent extends React.Component {
|
|
|
505
494
|
} = this.props;
|
|
506
495
|
const shouldRecreateResizeCols = !(options !== null && options !== void 0 && options.isTableResizingEnabled) || !isResizing || tablesHaveDifferentNoOfColumns(currentTable, previousTable) && isResizing;
|
|
507
496
|
if (shouldRecreateResizeCols) {
|
|
508
|
-
insertColgroupFromNode(this.table, currentTable,
|
|
497
|
+
insertColgroupFromNode(this.table, currentTable, isTableScalingEnabled);
|
|
509
498
|
}
|
|
510
499
|
updateControls()(view.state);
|
|
511
500
|
}
|
|
@@ -551,7 +540,8 @@ class TableComponent extends React.Component {
|
|
|
551
540
|
getPos,
|
|
552
541
|
pluginInjectionApi,
|
|
553
542
|
isDragAndDropEnabled,
|
|
554
|
-
getEditorFeatureFlags
|
|
543
|
+
getEditorFeatureFlags,
|
|
544
|
+
isTableScalingEnabled
|
|
555
545
|
} = this.props;
|
|
556
546
|
const {
|
|
557
547
|
showBeforeShadow,
|
|
@@ -635,8 +625,7 @@ class TableComponent extends React.Component {
|
|
|
635
625
|
const isNested = isTableNested(view.state, tablePos);
|
|
636
626
|
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;
|
|
637
627
|
const {
|
|
638
|
-
stickyScrollbar
|
|
639
|
-
tablePreserveWidth
|
|
628
|
+
stickyScrollbar
|
|
640
629
|
} = getEditorFeatureFlags();
|
|
641
630
|
return /*#__PURE__*/React.createElement(TableContainer, {
|
|
642
631
|
className: classnames(ClassName.TABLE_CONTAINER, {
|
|
@@ -655,7 +644,7 @@ class TableComponent extends React.Component {
|
|
|
655
644
|
pluginInjectionApi: pluginInjectionApi,
|
|
656
645
|
isTableResizingEnabled: options === null || options === void 0 ? void 0 : options.isTableResizingEnabled,
|
|
657
646
|
isResizing: isResizing,
|
|
658
|
-
|
|
647
|
+
isTableScalingEnabled: isTableScalingEnabled
|
|
659
648
|
}, /*#__PURE__*/React.createElement("div", {
|
|
660
649
|
className: ClassName.TABLE_STICKY_SENTINEL_TOP,
|
|
661
650
|
"data-testid": "sticky-sentinel-top"
|
|
@@ -2,7 +2,7 @@ import React, { forwardRef, useCallback, useRef } from 'react';
|
|
|
2
2
|
import classNames from 'classnames';
|
|
3
3
|
import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
|
|
4
4
|
import { calcTableWidth } from '@atlaskit/editor-common/styles';
|
|
5
|
-
import { akEditorDefaultLayoutWidth, akEditorMobileBreakoutPoint } from '@atlaskit/editor-shared-styles';
|
|
5
|
+
import { akEditorDefaultLayoutWidth, akEditorGutterPadding, akEditorMediaResizeHandlerPaddingWide, akEditorMobileBreakoutPoint } from '@atlaskit/editor-shared-styles';
|
|
6
6
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
7
7
|
import { TABLE_MAX_WIDTH } from '../pm-plugins/table-resizing/utils';
|
|
8
8
|
import { TableCssClassName as ClassName } from '../types';
|
|
@@ -42,7 +42,7 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
|
|
|
42
42
|
tableRef,
|
|
43
43
|
isResizing,
|
|
44
44
|
pluginInjectionApi,
|
|
45
|
-
|
|
45
|
+
isTableScalingEnabled
|
|
46
46
|
}) => {
|
|
47
47
|
const containerRef = useRef(null);
|
|
48
48
|
const tableWidthRef = useRef(akEditorDefaultLayoutWidth);
|
|
@@ -107,7 +107,7 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
|
|
|
107
107
|
}, [pluginInjectionApi]);
|
|
108
108
|
const tableWidth = getTableContainerWidth(node);
|
|
109
109
|
// 76 is currently an accepted padding value considering the spacing for resizer handle
|
|
110
|
-
const responsiveContainerWidth = containerWidth -
|
|
110
|
+
const responsiveContainerWidth = isTableScalingEnabled ? containerWidth - akEditorGutterPadding * 2 - akEditorMediaResizeHandlerPaddingWide / 2 : containerWidth - akEditorGutterPadding * 2 - akEditorMediaResizeHandlerPaddingWide;
|
|
111
111
|
const width = Math.min(tableWidth, responsiveContainerWidth);
|
|
112
112
|
if (!isResizing) {
|
|
113
113
|
tableWidthRef.current = width;
|
|
@@ -125,7 +125,7 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
|
|
|
125
125
|
displayGuideline,
|
|
126
126
|
attachAnalyticsEvent,
|
|
127
127
|
displayGapCursor,
|
|
128
|
-
|
|
128
|
+
isTableScalingEnabled
|
|
129
129
|
};
|
|
130
130
|
if (getBooleanFF('platform.editor.resizing-table-height-improvement')) {
|
|
131
131
|
tableResizerProps = {
|
|
@@ -166,7 +166,7 @@ export const TableContainer = ({
|
|
|
166
166
|
isNested,
|
|
167
167
|
isResizing,
|
|
168
168
|
pluginInjectionApi,
|
|
169
|
-
|
|
169
|
+
isTableScalingEnabled
|
|
170
170
|
}) => {
|
|
171
171
|
if (isTableResizingEnabled && !isNested) {
|
|
172
172
|
return /*#__PURE__*/React.createElement(ResizableTableContainer, {
|
|
@@ -178,7 +178,7 @@ export const TableContainer = ({
|
|
|
178
178
|
tableRef: tableRef,
|
|
179
179
|
isResizing: isResizing,
|
|
180
180
|
pluginInjectionApi: pluginInjectionApi,
|
|
181
|
-
|
|
181
|
+
isTableScalingEnabled: isTableScalingEnabled
|
|
182
182
|
}, children);
|
|
183
183
|
}
|
|
184
184
|
const tableWidth = isBreakoutEnabled ? calcTableWidth(node.attrs.layout, editorWidth) : 'inherit';
|