@atlaskit/editor-plugin-table 7.6.14 → 7.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/cjs/commands/misc.js +0 -2
- package/dist/cjs/nodeviews/OverflowShadowsObserver.js +1 -3
- package/dist/cjs/nodeviews/TableComponent.js +3 -18
- package/dist/cjs/nodeviews/TableContainer.js +6 -25
- package/dist/cjs/nodeviews/TableResizer.js +2 -2
- package/dist/cjs/nodeviews/table.js +0 -2
- package/dist/cjs/plugin.js +3 -20
- package/dist/cjs/pm-plugins/main.js +1 -2
- package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +12 -21
- package/dist/cjs/pm-plugins/table-resizing/utils/colgroup.js +32 -57
- package/dist/cjs/pm-plugins/table-resizing/utils/misc.js +1 -2
- package/dist/cjs/pm-plugins/table-resizing/utils/resize-column.js +29 -4
- package/dist/cjs/pm-plugins/table-resizing/utils/resize-logic.js +19 -0
- package/dist/cjs/pm-plugins/table-resizing/utils/resize-state.js +16 -28
- package/dist/cjs/pm-plugins/table-resizing/utils/scale-table.js +2 -12
- package/dist/cjs/reducer.js +0 -2
- package/dist/cjs/transforms/column-width.js +3 -5
- package/dist/cjs/types.js +0 -1
- package/dist/cjs/ui/ColumnResizeWidget/index.js +5 -1
- package/dist/cjs/ui/common-styles.js +5 -12
- package/dist/cjs/ui/ui-styles.js +7 -12
- package/dist/cjs/utils/index.js +0 -6
- package/dist/cjs/utils/nodes.js +5 -18
- package/dist/es2019/commands/misc.js +0 -2
- package/dist/es2019/nodeviews/OverflowShadowsObserver.js +1 -3
- package/dist/es2019/nodeviews/TableComponent.js +3 -18
- package/dist/es2019/nodeviews/TableContainer.js +6 -24
- package/dist/es2019/nodeviews/TableResizer.js +2 -2
- package/dist/es2019/nodeviews/table.js +0 -2
- package/dist/es2019/plugin.js +5 -24
- package/dist/es2019/pm-plugins/main.js +1 -2
- package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +13 -22
- package/dist/es2019/pm-plugins/table-resizing/utils/colgroup.js +30 -53
- package/dist/es2019/pm-plugins/table-resizing/utils/misc.js +1 -2
- package/dist/es2019/pm-plugins/table-resizing/utils/resize-column.js +28 -4
- package/dist/es2019/pm-plugins/table-resizing/utils/resize-logic.js +20 -0
- package/dist/es2019/pm-plugins/table-resizing/utils/resize-state.js +14 -24
- package/dist/es2019/pm-plugins/table-resizing/utils/scale-table.js +2 -12
- package/dist/es2019/reducer.js +0 -5
- package/dist/es2019/transforms/column-width.js +3 -5
- package/dist/es2019/types.js +0 -1
- package/dist/es2019/ui/ColumnResizeWidget/index.js +5 -1
- package/dist/es2019/ui/common-styles.js +15 -46
- package/dist/es2019/ui/ui-styles.js +34 -41
- package/dist/es2019/utils/index.js +1 -1
- package/dist/es2019/utils/nodes.js +0 -15
- package/dist/esm/commands/misc.js +0 -2
- package/dist/esm/nodeviews/OverflowShadowsObserver.js +1 -3
- package/dist/esm/nodeviews/TableComponent.js +3 -18
- package/dist/esm/nodeviews/TableContainer.js +6 -25
- package/dist/esm/nodeviews/TableResizer.js +2 -2
- package/dist/esm/nodeviews/table.js +0 -2
- package/dist/esm/plugin.js +5 -22
- package/dist/esm/pm-plugins/main.js +1 -2
- package/dist/esm/pm-plugins/table-resizing/event-handlers.js +13 -22
- package/dist/esm/pm-plugins/table-resizing/utils/colgroup.js +32 -57
- package/dist/esm/pm-plugins/table-resizing/utils/misc.js +1 -2
- package/dist/esm/pm-plugins/table-resizing/utils/resize-column.js +30 -4
- package/dist/esm/pm-plugins/table-resizing/utils/resize-logic.js +18 -0
- package/dist/esm/pm-plugins/table-resizing/utils/resize-state.js +16 -28
- package/dist/esm/pm-plugins/table-resizing/utils/scale-table.js +2 -12
- package/dist/esm/reducer.js +0 -2
- package/dist/esm/transforms/column-width.js +3 -5
- package/dist/esm/types.js +0 -1
- package/dist/esm/ui/ColumnResizeWidget/index.js +5 -1
- package/dist/esm/ui/common-styles.js +6 -13
- package/dist/esm/ui/ui-styles.js +7 -12
- package/dist/esm/utils/index.js +1 -1
- package/dist/esm/utils/nodes.js +0 -13
- package/dist/types/nodeviews/TableContainer.d.ts +1 -2
- package/dist/types/nodeviews/types.d.ts +0 -1
- package/dist/types/plugin.d.ts +0 -1
- package/dist/types/pm-plugins/main.d.ts +1 -1
- package/dist/types/pm-plugins/table-resizing/utils/resize-logic.d.ts +4 -0
- package/dist/types/pm-plugins/table-resizing/utils/scale-table.d.ts +0 -1
- package/dist/types/types.d.ts +0 -9
- package/dist/types/ui/FloatingContextualButton/index.d.ts +0 -2
- package/dist/types/utils/index.d.ts +1 -1
- package/dist/types/utils/nodes.d.ts +0 -1
- package/dist/types-ts4.5/nodeviews/TableContainer.d.ts +1 -2
- package/dist/types-ts4.5/nodeviews/types.d.ts +0 -1
- package/dist/types-ts4.5/plugin.d.ts +0 -1
- package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/resize-logic.d.ts +4 -0
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/scale-table.d.ts +0 -1
- package/dist/types-ts4.5/types.d.ts +0 -9
- package/dist/types-ts4.5/ui/FloatingContextualButton/index.d.ts +0 -2
- package/dist/types-ts4.5/utils/index.d.ts +1 -1
- package/dist/types-ts4.5/utils/nodes.d.ts +0 -1
- package/package.json +7 -10
- package/src/commands/misc.ts +0 -2
- package/src/nodeviews/OverflowShadowsObserver.ts +1 -6
- package/src/nodeviews/TableComponent.tsx +2 -25
- package/src/nodeviews/TableContainer.tsx +7 -34
- package/src/nodeviews/TableResizer.tsx +2 -8
- package/src/nodeviews/table.tsx +0 -2
- package/src/nodeviews/types.ts +0 -1
- package/src/plugin.tsx +4 -43
- package/src/pm-plugins/main.ts +0 -2
- package/src/pm-plugins/table-resizing/event-handlers.ts +13 -37
- package/src/pm-plugins/table-resizing/utils/colgroup.ts +40 -61
- package/src/pm-plugins/table-resizing/utils/misc.ts +4 -6
- package/src/pm-plugins/table-resizing/utils/resize-column.ts +52 -9
- package/src/pm-plugins/table-resizing/utils/resize-logic.ts +25 -0
- package/src/pm-plugins/table-resizing/utils/resize-state.ts +18 -29
- package/src/pm-plugins/table-resizing/utils/scale-table.ts +2 -13
- package/src/reducer.ts +0 -3
- package/src/transforms/column-width.ts +2 -10
- package/src/types.ts +0 -8
- package/src/ui/ColumnResizeWidget/index.tsx +10 -1
- package/src/ui/FloatingContextualButton/index.tsx +0 -2
- package/src/ui/common-styles.ts +15 -53
- package/src/ui/ui-styles.ts +34 -47
- package/src/utils/index.ts +0 -1
- package/src/utils/nodes.ts +0 -23
- package/dist/cjs/ui/LayoutButton/index.js +0 -206
- package/dist/es2019/ui/LayoutButton/index.js +0 -168
- package/dist/esm/ui/LayoutButton/index.js +0 -196
- package/dist/types/ui/LayoutButton/index.d.ts +0 -21
- package/dist/types-ts4.5/ui/LayoutButton/index.d.ts +0 -21
- package/src/ui/LayoutButton/index.tsx +0 -217
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 7.7.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#90896](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/90896) [`ee5dc6f04816`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/ee5dc6f04816) - Add new column resize functionality behind LD ff platform.editor.table.colum-resizing-improvements
|
|
8
|
+
- [#91106](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/91106) [`b6ffa30186b9`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/b6ffa30186b9) - Bump ADF-schema package to version 35.0.0
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 7.7.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- [#86368](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/86368) [`d07ec8d13230`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/d07ec8d13230) - [ux] Remove the custom table width platform flag and remove Layout/Breakout button
|
|
16
|
+
|
|
3
17
|
## 7.6.14
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -38,7 +38,6 @@ var setTableRef = exports.setTableRef = function setTableRef(ref) {
|
|
|
38
38
|
var tableNode = ref && foundTable ? foundTable.node : undefined;
|
|
39
39
|
var tablePos = ref && foundTable ? foundTable.pos : undefined;
|
|
40
40
|
var tableWrapperTarget = (0, _utils.closestElement)(tableRef, ".".concat(_types.TableCssClassName.TABLE_NODE_WRAPPER)) || undefined;
|
|
41
|
-
var layout = tableNode ? tableNode.attrs.layout : undefined;
|
|
42
41
|
var _getPluginState = (0, _pluginFactory.getPluginState)(state),
|
|
43
42
|
isDragAndDropEnabled = _getPluginState.isDragAndDropEnabled;
|
|
44
43
|
return {
|
|
@@ -48,7 +47,6 @@ var setTableRef = exports.setTableRef = function setTableRef(ref) {
|
|
|
48
47
|
tableNode: tableNode,
|
|
49
48
|
tablePos: tablePos,
|
|
50
49
|
tableWrapperTarget: tableWrapperTarget,
|
|
51
|
-
layout: layout || 'default',
|
|
52
50
|
isNumberColumnEnabled: (0, _nodes.checkIfNumberColumnEnabled)(state.selection),
|
|
53
51
|
isHeaderRowEnabled: (0, _nodes.checkIfHeaderRowEnabled)(state.selection),
|
|
54
52
|
isHeaderColumnEnabled: (0, _nodes.checkIfHeaderColumnEnabled)(state.selection),
|
|
@@ -9,9 +9,7 @@ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/cl
|
|
|
9
9
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
11
|
var _rafSchd = _interopRequireDefault(require("raf-schd"));
|
|
12
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
13
12
|
var _types = require("../types");
|
|
14
|
-
var _consts = require("../ui/consts");
|
|
15
13
|
var _updateOverflowShadows = require("./update-overflow-shadows");
|
|
16
14
|
var OverflowShadowsObserver = exports.OverflowShadowsObserver = /*#__PURE__*/function () {
|
|
17
15
|
// updateShadowState is a method to update shadow key
|
|
@@ -43,7 +41,7 @@ var OverflowShadowsObserver = exports.OverflowShadowsObserver = /*#__PURE__*/fun
|
|
|
43
41
|
}, {
|
|
44
42
|
threshold: [0, 1],
|
|
45
43
|
root: _this.wrapper,
|
|
46
|
-
rootMargin:
|
|
44
|
+
rootMargin: '0px'
|
|
47
45
|
});
|
|
48
46
|
return;
|
|
49
47
|
}
|
|
@@ -135,16 +135,12 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
135
135
|
var node = getNode();
|
|
136
136
|
var prevAttrs = prevNode.attrs;
|
|
137
137
|
var isNested = (0, _utils5.isTableNested)(_this.props.view.state, _this.props.getPos());
|
|
138
|
-
// We only consider a layout change valid if it's done outside of an autoSize.
|
|
139
|
-
var layoutChanged = prevAttrs.layout !== node.attrs.layout && prevAttrs.__autoSize === node.attrs.__autoSize;
|
|
140
138
|
var parentWidth = _this.getParentNodeWidth();
|
|
141
139
|
var parentWidthChanged = parentWidth && parentWidth !== _this.state.parentWidth;
|
|
142
140
|
var layoutSize = _this.tableNodeLayoutSize(node, containerWidth.width, options);
|
|
143
141
|
var hasNumberedColumnChanged = prevAttrs.isNumberColumnEnabled !== node.attrs.isNumberColumnEnabled;
|
|
144
142
|
var noOfColumnsChanged = (0, _utils5.tablesHaveDifferentNoOfColumns)(node, prevNode);
|
|
145
143
|
if (
|
|
146
|
-
// Breakout mode/layout changed
|
|
147
|
-
layoutChanged ||
|
|
148
144
|
// We need to react if our parent changes
|
|
149
145
|
// Scales the cols widths relative to the new parent width.
|
|
150
146
|
parentWidthChanged ||
|
|
@@ -158,8 +154,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
158
154
|
// If column has been inserted/deleted avoid multi dispatch
|
|
159
155
|
if (shouldScaleTable) {
|
|
160
156
|
_this.scaleTable({
|
|
161
|
-
parentWidth: parentWidth
|
|
162
|
-
layoutChanged: layoutChanged
|
|
157
|
+
parentWidth: parentWidth
|
|
163
158
|
});
|
|
164
159
|
}
|
|
165
160
|
|
|
@@ -167,8 +162,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
167
162
|
if (options !== null && options !== void 0 && options.isTableResizingEnabled && hasNumberedColumnChanged) {
|
|
168
163
|
if (!(0, _colgroup.hasTableBeenResized)(prevNode)) {
|
|
169
164
|
_this.scaleTable({
|
|
170
|
-
parentWidth: node.attrs.width
|
|
171
|
-
layoutChanged: layoutChanged
|
|
165
|
+
parentWidth: node.attrs.width
|
|
172
166
|
});
|
|
173
167
|
}
|
|
174
168
|
}
|
|
@@ -246,21 +240,16 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
246
240
|
}
|
|
247
241
|
});
|
|
248
242
|
(0, _defineProperty3.default)((0, _assertThisInitialized2.default)(_this), "handleWindowResize", function () {
|
|
249
|
-
var _node$attrs, _node$attrs2;
|
|
250
243
|
var _this$props5 = _this.props,
|
|
251
244
|
getNode = _this$props5.getNode,
|
|
252
245
|
containerWidth = _this$props5.containerWidth;
|
|
253
246
|
var node = getNode();
|
|
254
|
-
var prevNode = _this.node;
|
|
255
247
|
var layoutSize = _this.tableNodeLayoutSize(node);
|
|
256
|
-
var prevAttrs = prevNode === null || prevNode === void 0 ? void 0 : prevNode.attrs;
|
|
257
|
-
var layoutChanged = (prevAttrs === null || prevAttrs === void 0 ? void 0 : prevAttrs.layout) !== (node === null || node === void 0 || (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.layout) && (prevAttrs === null || prevAttrs === void 0 ? void 0 : prevAttrs.__autoSize) === (node === null || node === void 0 || (_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.__autoSize);
|
|
258
248
|
if (containerWidth.width > layoutSize) {
|
|
259
249
|
return;
|
|
260
250
|
}
|
|
261
251
|
var parentWidth = _this.getParentNodeWidth();
|
|
262
252
|
_this.scaleTableDebounced({
|
|
263
|
-
layoutChanged: layoutChanged,
|
|
264
253
|
parentWidth: parentWidth
|
|
265
254
|
});
|
|
266
255
|
});
|
|
@@ -713,7 +702,6 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
713
702
|
node: node,
|
|
714
703
|
tableRef: tableRef,
|
|
715
704
|
containerWidth: containerWidth,
|
|
716
|
-
isBreakoutEnabled: options === null || options === void 0 ? void 0 : options.isBreakoutEnabled,
|
|
717
705
|
isNested: isNested,
|
|
718
706
|
pluginInjectionApi: pluginInjectionApi,
|
|
719
707
|
tableWrapperHeight: this.state.tableWrapperHeight,
|
|
@@ -784,10 +772,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
784
772
|
}), this.state.stickyHeader && /*#__PURE__*/_react.default.createElement("div", {
|
|
785
773
|
style: {
|
|
786
774
|
position: 'absolute',
|
|
787
|
-
right:
|
|
788
|
-
:
|
|
789
|
-
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
|
|
790
|
-
'22px'
|
|
775
|
+
right: "var(--ds-space-400, 32px)" // tableOverflowShadowWidthWide
|
|
791
776
|
}
|
|
792
777
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
793
778
|
className: "".concat(_types.TableCssClassName.TABLE_RIGHT_SHADOW, " ").concat(_types.TableCssClassName.TABLE_STICKY_SHADOW),
|
|
@@ -12,9 +12,7 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
12
12
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
13
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
14
14
|
var _nodeWidth = require("@atlaskit/editor-common/node-width");
|
|
15
|
-
var _styles = require("@atlaskit/editor-common/styles");
|
|
16
15
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
17
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
18
16
|
var _utils = require("../pm-plugins/table-resizing/utils");
|
|
19
17
|
var _types = require("../types");
|
|
20
18
|
var _TableResizer = require("./TableResizer");
|
|
@@ -22,16 +20,6 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
|
|
|
22
20
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
23
21
|
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; }
|
|
24
22
|
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; }
|
|
25
|
-
var getMarginLeft = function getMarginLeft(lineLength, tableWidth) {
|
|
26
|
-
var marginLeft;
|
|
27
|
-
if (tableWidth !== 'inherit' && lineLength) {
|
|
28
|
-
var containerWidth = tableWidth;
|
|
29
|
-
if (containerWidth) {
|
|
30
|
-
marginLeft = (lineLength - containerWidth) / 2;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return marginLeft;
|
|
34
|
-
};
|
|
35
23
|
var InnerContainer = exports.InnerContainer = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
36
24
|
var className = _ref.className,
|
|
37
25
|
style = _ref.style,
|
|
@@ -144,12 +132,10 @@ var ResizableTableContainer = exports.ResizableTableContainer = /*#__PURE__*/_re
|
|
|
144
132
|
isWholeTableInDanger: isWholeTableInDanger,
|
|
145
133
|
pluginInjectionApi: pluginInjectionApi
|
|
146
134
|
};
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
});
|
|
152
|
-
}
|
|
135
|
+
tableResizerProps = _objectSpread(_objectSpread({}, tableResizerProps), {}, {
|
|
136
|
+
onResizeStart: onResizeStart,
|
|
137
|
+
onResizeStop: onResizeStop
|
|
138
|
+
});
|
|
153
139
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
154
140
|
style: {
|
|
155
141
|
display: 'flex',
|
|
@@ -174,11 +160,8 @@ var TableContainer = exports.TableContainer = function TableContainer(_ref3) {
|
|
|
174
160
|
var children = _ref3.children,
|
|
175
161
|
node = _ref3.node,
|
|
176
162
|
className = _ref3.className,
|
|
177
|
-
|
|
178
|
-
lineLength = _ref3$containerWidth.lineLength,
|
|
179
|
-
editorWidth = _ref3$containerWidth.width,
|
|
163
|
+
editorWidth = _ref3.containerWidth.width,
|
|
180
164
|
isTableResizingEnabled = _ref3.isTableResizingEnabled,
|
|
181
|
-
isBreakoutEnabled = _ref3.isBreakoutEnabled,
|
|
182
165
|
editorView = _ref3.editorView,
|
|
183
166
|
getPos = _ref3.getPos,
|
|
184
167
|
tableRef = _ref3.tableRef,
|
|
@@ -203,15 +186,13 @@ var TableContainer = exports.TableContainer = function TableContainer(_ref3) {
|
|
|
203
186
|
isWholeTableInDanger: isWholeTableInDanger
|
|
204
187
|
}, children);
|
|
205
188
|
}
|
|
206
|
-
var tableWidth = isBreakoutEnabled ? (0, _styles.calcTableWidth)(node.attrs.layout, editorWidth) : 'inherit';
|
|
207
189
|
return /*#__PURE__*/_react.default.createElement(InnerContainer, {
|
|
208
190
|
node: node,
|
|
209
191
|
className: (0, _classnames.default)(className, {
|
|
210
192
|
'less-padding': editorWidth < _editorSharedStyles.akEditorMobileBreakoutPoint && !isNested
|
|
211
193
|
}),
|
|
212
194
|
style: {
|
|
213
|
-
width:
|
|
214
|
-
marginLeft: getMarginLeft(lineLength, tableWidth)
|
|
195
|
+
width: 'inherit'
|
|
215
196
|
}
|
|
216
197
|
}, children);
|
|
217
198
|
};
|
|
@@ -170,7 +170,7 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
|
|
|
170
170
|
dispatch(tr);
|
|
171
171
|
var visibleGuidelines = getVisibleGuidelines(isTableScalingEnabled ? (0, _guidelines.defaultGuidelinesForPreserveTable)(containerWidth) : _guidelines.defaultGuidelines, containerWidth);
|
|
172
172
|
setSnappingEnabled(displayGuideline(visibleGuidelines));
|
|
173
|
-
if (
|
|
173
|
+
if (onResizeStart) {
|
|
174
174
|
onResizeStart();
|
|
175
175
|
}
|
|
176
176
|
}, [startMeasure, editorView, displayGapCursor, isTableScalingEnabled, containerWidth, displayGuideline, onResizeStart]);
|
|
@@ -274,7 +274,7 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
|
|
|
274
274
|
displayGuideline([]);
|
|
275
275
|
updateWidth(newWidth);
|
|
276
276
|
scheduleResize.cancel();
|
|
277
|
-
if (
|
|
277
|
+
if (onResizeStop) {
|
|
278
278
|
onResizeStop();
|
|
279
279
|
}
|
|
280
280
|
return newWidth;
|
|
@@ -279,7 +279,6 @@ var TableView = exports.default = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
279
279
|
var createTableView = exports.createTableView = function createTableView(node, view, getPos, portalProviderAPI, eventDispatcher, getEditorContainerWidth, getEditorFeatureFlags, dispatchAnalyticsEvent, pluginInjectionApi) {
|
|
280
280
|
var _getPluginState2 = (0, _pluginFactory.getPluginState)(view.state),
|
|
281
281
|
pluginConfig = _getPluginState2.pluginConfig,
|
|
282
|
-
isBreakoutEnabled = _getPluginState2.isBreakoutEnabled,
|
|
283
282
|
isFullWidthModeEnabled = _getPluginState2.isFullWidthModeEnabled,
|
|
284
283
|
wasFullWidthModeEnabled = _getPluginState2.wasFullWidthModeEnabled,
|
|
285
284
|
isTableResizingEnabled = _getPluginState2.isTableResizingEnabled,
|
|
@@ -298,7 +297,6 @@ var createTableView = exports.createTableView = function createTableView(node, v
|
|
|
298
297
|
eventDispatcher: eventDispatcher,
|
|
299
298
|
getPos: getPos,
|
|
300
299
|
options: {
|
|
301
|
-
isBreakoutEnabled: isBreakoutEnabled,
|
|
302
300
|
isFullWidthModeEnabled: isFullWidthModeEnabled,
|
|
303
301
|
wasFullWidthModeEnabled: wasFullWidthModeEnabled,
|
|
304
302
|
isTableResizingEnabled: isTableResizingEnabled,
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -40,7 +40,6 @@ var _FloatingContextualMenu = _interopRequireDefault(require("./ui/FloatingConte
|
|
|
40
40
|
var _FloatingDeleteButton = _interopRequireDefault(require("./ui/FloatingDeleteButton"));
|
|
41
41
|
var _FloatingDragMenu = _interopRequireDefault(require("./ui/FloatingDragMenu"));
|
|
42
42
|
var _FloatingInsertButton = _interopRequireDefault(require("./ui/FloatingInsertButton"));
|
|
43
|
-
var _LayoutButton = _interopRequireDefault(require("./ui/LayoutButton"));
|
|
44
43
|
var _utils2 = require("./utils");
|
|
45
44
|
var defaultGetEditorFeatureFlags = function defaultGetEditorFeatureFlags() {
|
|
46
45
|
return {};
|
|
@@ -117,10 +116,9 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
117
116
|
insertTableWithSize: (0, _insert.insertTableWithSize)(options === null || options === void 0 ? void 0 : options.fullWidthEnabled, options === null || options === void 0 ? void 0 : options.isTableScalingEnabled, api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)
|
|
118
117
|
},
|
|
119
118
|
nodes: function nodes() {
|
|
120
|
-
var tableNode = options !== null && options !== void 0 && options.tableResizingEnabled ? _adfSchema.tableWithCustomWidth : _adfSchema.table;
|
|
121
119
|
return [{
|
|
122
120
|
name: 'table',
|
|
123
|
-
node:
|
|
121
|
+
node: _adfSchema.table
|
|
124
122
|
}, {
|
|
125
123
|
name: 'tableHeader',
|
|
126
124
|
node: _adfSchema.tableHeader
|
|
@@ -145,12 +143,11 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
145
143
|
fullWidthEnabled = _ref3.fullWidthEnabled,
|
|
146
144
|
wasFullWidthEnabled = _ref3.wasFullWidthEnabled,
|
|
147
145
|
tableResizingEnabled = _ref3.tableResizingEnabled,
|
|
148
|
-
breakoutEnabled = _ref3.breakoutEnabled,
|
|
149
146
|
tableOptions = _ref3.tableOptions,
|
|
150
147
|
getEditorFeatureFlags = _ref3.getEditorFeatureFlags,
|
|
151
148
|
dragAndDropEnabled = _ref3.dragAndDropEnabled,
|
|
152
149
|
isTableScalingEnabled = _ref3.isTableScalingEnabled;
|
|
153
|
-
return (0, _main.createPlugin)(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, (0, _createPluginConfig.pluginConfig)(tableOptions), defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, getIntl,
|
|
150
|
+
return (0, _main.createPlugin)(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, (0, _createPluginConfig.pluginConfig)(tableOptions), defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, getIntl, tableResizingEnabled, fullWidthEnabled, wasFullWidthEnabled, dragAndDropEnabled, editorAnalyticsAPI, api, isTableScalingEnabled);
|
|
154
151
|
}
|
|
155
152
|
}, {
|
|
156
153
|
name: 'tablePMColResizing',
|
|
@@ -312,7 +309,6 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
312
309
|
tablePluginState = _ref17.tablePluginState,
|
|
313
310
|
tableWidthPluginState = _ref17.tableWidthPluginState,
|
|
314
311
|
dragAndDropState = _ref17.dragAndDropState;
|
|
315
|
-
var state = editorView.state;
|
|
316
312
|
var isColumnResizing = resizingPluginState === null || resizingPluginState === void 0 ? void 0 : resizingPluginState.dragging;
|
|
317
313
|
var isTableResizing = tableWidthPluginState === null || tableWidthPluginState === void 0 ? void 0 : tableWidthPluginState.resizing;
|
|
318
314
|
var isResizing = isColumnResizing || isTableResizing;
|
|
@@ -321,7 +317,6 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
321
317
|
tablePos = _ref18.tablePos,
|
|
322
318
|
targetCellPosition = _ref18.targetCellPosition,
|
|
323
319
|
isContextualMenuOpen = _ref18.isContextualMenuOpen,
|
|
324
|
-
layout = _ref18.layout,
|
|
325
320
|
tableRef = _ref18.tableRef,
|
|
326
321
|
pluginConfig = _ref18.pluginConfig,
|
|
327
322
|
insertColumnButtonIndex = _ref18.insertColumnButtonIndex,
|
|
@@ -332,17 +327,6 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
332
327
|
tableWrapperTarget = _ref18.tableWrapperTarget;
|
|
333
328
|
var allowControls = pluginConfig.allowControls;
|
|
334
329
|
var stickyHeader = stickyHeadersState ? (0, _stickyHeaders.findStickyHeaderForTable)(stickyHeadersState, tablePos) : undefined;
|
|
335
|
-
var LayoutContent = options && !options.tableResizingEnabled && (0, _utils2.isLayoutSupported)(state) && options.breakoutEnabled ? /*#__PURE__*/_react.default.createElement(_LayoutButton.default, {
|
|
336
|
-
editorView: editorView,
|
|
337
|
-
mountPoint: popupsMountPoint,
|
|
338
|
-
boundariesElement: popupsBoundariesElement,
|
|
339
|
-
scrollableElement: popupsScrollableElement,
|
|
340
|
-
targetRef: tableWrapperTarget,
|
|
341
|
-
layout: layout,
|
|
342
|
-
isResizing: !!resizingPluginState && !!resizingPluginState.dragging,
|
|
343
|
-
stickyHeader: stickyHeader,
|
|
344
|
-
editorAnalyticsAPI: editorAnalyticsAPI
|
|
345
|
-
}) : null;
|
|
346
330
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, targetCellPosition && tableRef && !isResizing && options && options.allowContextualMenu && /*#__PURE__*/_react.default.createElement(_FloatingContextualButton.default, {
|
|
347
331
|
isNumberColumnEnabled: tableNode && tableNode.attrs.isNumberColumnEnabled,
|
|
348
332
|
editorView: editorView,
|
|
@@ -352,7 +336,6 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
352
336
|
scrollableElement: popupsScrollableElement,
|
|
353
337
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
354
338
|
isContextualMenuOpen: isContextualMenuOpen,
|
|
355
|
-
layout: layout,
|
|
356
339
|
stickyHeader: stickyHeader,
|
|
357
340
|
tableWrapper: tableWrapperTarget
|
|
358
341
|
}), allowControls && /*#__PURE__*/_react.default.createElement(_FloatingInsertButton.default, {
|
|
@@ -405,7 +388,7 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
405
388
|
stickyHeaders: stickyHeader,
|
|
406
389
|
isNumberColumnEnabled: tableNode && tableNode.attrs.isNumberColumnEnabled,
|
|
407
390
|
editorAnalyticsAPI: editorAnalyticsAPI
|
|
408
|
-
})
|
|
391
|
+
}));
|
|
409
392
|
}
|
|
410
393
|
}));
|
|
411
394
|
},
|
|
@@ -32,7 +32,7 @@ var _pluginFactory = require("./plugin-factory");
|
|
|
32
32
|
var _pluginKey = require("./plugin-key");
|
|
33
33
|
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; }
|
|
34
34
|
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; }
|
|
35
|
-
var createPlugin = exports.createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig, getEditorContainerWidth, getEditorFeatureFlags, getIntl,
|
|
35
|
+
var createPlugin = exports.createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig, getEditorContainerWidth, getEditorFeatureFlags, getIntl, tableResizingEnabled, fullWidthModeEnabled, previousFullWidthModeEnabled, dragAndDropEnabled, editorAnalyticsAPI, pluginInjectionApi, isTableScalingEnabled) {
|
|
36
36
|
var _accessibilityUtils;
|
|
37
37
|
var state = (0, _pluginFactory.createPluginState)(dispatch, _objectSpread(_objectSpread(_objectSpread({
|
|
38
38
|
pluginConfig: pluginConfig,
|
|
@@ -40,7 +40,6 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatchAnalytic
|
|
|
40
40
|
insertColumnButtonIndex: undefined,
|
|
41
41
|
insertRowButtonIndex: undefined,
|
|
42
42
|
isFullWidthModeEnabled: fullWidthModeEnabled,
|
|
43
|
-
isBreakoutEnabled: breakoutEnabled,
|
|
44
43
|
wasFullWidthModeEnabled: previousFullWidthModeEnabled,
|
|
45
44
|
isTableResizingEnabled: tableResizingEnabled,
|
|
46
45
|
isHeaderRowEnabled: !!pluginConfig.allowHeaderRow,
|
|
@@ -5,9 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.handleMouseDown = void 0;
|
|
7
7
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
8
|
-
var _nodeWidth = require("@atlaskit/editor-common/node-width");
|
|
9
8
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
10
|
-
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
11
9
|
var _tableMap = require("@atlaskit/editor-tables/table-map");
|
|
12
10
|
var _utils = require("@atlaskit/editor-tables/utils");
|
|
13
11
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
@@ -50,25 +48,13 @@ var handleMouseDown = exports.handleMouseDown = function handleMouseDown(view, e
|
|
|
50
48
|
if (dom && dom.nodeName !== 'TABLE') {
|
|
51
49
|
dom = dom.closest('table');
|
|
52
50
|
}
|
|
53
|
-
var maxSize
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if (originalTable.attrs.isNumberColumnEnabled) {
|
|
61
|
-
maxSize -= _editorSharedStyles.akEditorTableNumberColumnWidth;
|
|
62
|
-
}
|
|
63
|
-
} else {
|
|
64
|
-
maxSize = (0, _utils3.getTableMaxWidth)({
|
|
65
|
-
table: originalTable,
|
|
66
|
-
tableStart: start,
|
|
67
|
-
state: state,
|
|
68
|
-
layout: originalTable.attrs.layout,
|
|
69
|
-
getEditorContainerWidth: getEditorContainerWidth
|
|
70
|
-
});
|
|
71
|
-
}
|
|
51
|
+
var maxSize = (0, _utils3.getTableMaxWidth)({
|
|
52
|
+
table: originalTable,
|
|
53
|
+
tableStart: start,
|
|
54
|
+
state: state,
|
|
55
|
+
layout: originalTable.attrs.layout,
|
|
56
|
+
getEditorContainerWidth: getEditorContainerWidth
|
|
57
|
+
});
|
|
72
58
|
var shouldScale = tableDepth === 0 && isTableScalingEnabled;
|
|
73
59
|
var resizeState = (0, _utils3.getResizeState)({
|
|
74
60
|
minWidth: _styles.tableCellMinWidth,
|
|
@@ -155,6 +141,11 @@ var handleMouseDown = exports.handleMouseDown = function handleMouseDown(view, e
|
|
|
155
141
|
var newResizeState = (0, _utils3.resizeColumn)(resizeState, colIndex, clientX - startX, dom, originalTable, resizingSelectedColumns ? selectedColumns : undefined, _shouldScale);
|
|
156
142
|
var resizedDelta = clientX - startX;
|
|
157
143
|
tr = (0, _transforms.updateColumnWidths)(newResizeState, table, start)(tr);
|
|
144
|
+
|
|
145
|
+
// console.log('debug newResizeState=', newResizeState);
|
|
146
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.colum-resizing-improvements')) {
|
|
147
|
+
tr.setNodeAttribute(tablePos, 'width', newResizeState.tableWidth);
|
|
148
|
+
}
|
|
158
149
|
if (colIndex === map.width - 1) {
|
|
159
150
|
var mouseUpTime = event.timeStamp;
|
|
160
151
|
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
|
|
@@ -10,7 +10,6 @@ var _styles = require("@atlaskit/editor-common/styles");
|
|
|
10
10
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
11
11
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
12
12
|
var _tableMap = require("@atlaskit/editor-tables/table-map");
|
|
13
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
14
13
|
var _misc = require("./misc");
|
|
15
14
|
/**
|
|
16
15
|
* This ensures the combined width of the columns (and tbody) of table is always smaller or equal
|
|
@@ -23,66 +22,42 @@ var getColWidthFix = exports.getColWidthFix = function getColWidthFix(colwidth,
|
|
|
23
22
|
};
|
|
24
23
|
var generateColgroup = exports.generateColgroup = function generateColgroup(table, tableRef) {
|
|
25
24
|
var cols = [];
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
var scalePercent = (0, _misc.getTableScalingPercent)(table, tableRef);
|
|
35
|
-
cell.attrs.colwidth.slice(0, colspan).forEach(function (width) {
|
|
36
|
-
var fixedColWidth = getColWidthFix(width, map.width);
|
|
37
|
-
var scaledWidth = fixedColWidth * scalePercent;
|
|
38
|
-
var finalWidth = Math.max(scaledWidth, _styles.tableCellMinWidth);
|
|
39
|
-
cols.push(['col', {
|
|
40
|
-
style: "width: ".concat(finalWidth, "px;")
|
|
41
|
-
}]);
|
|
42
|
-
});
|
|
43
|
-
} else {
|
|
44
|
-
cell.attrs.colwidth.slice(0, colspan).forEach(function (width) {
|
|
45
|
-
cols.push(['col', {
|
|
46
|
-
style: "width: ".concat(getColWidthFix(width ? Math.max(width, _styles.tableCellMinWidth) : _styles.tableCellMinWidth, map.width), "px;")
|
|
47
|
-
}]);
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
} else {
|
|
51
|
-
// When we have merged cells on the first row (firstChild),
|
|
52
|
-
// We want to ensure we're creating the appropriate amount of
|
|
53
|
-
// cols the table still has.
|
|
54
|
-
cols.push.apply(cols, (0, _toConsumableArray2.default)(Array.from({
|
|
55
|
-
length: colspan
|
|
56
|
-
}, function (_) {
|
|
57
|
-
return ['col', {
|
|
58
|
-
style: "width: ".concat(_styles.tableCellMinWidth, "px;")
|
|
59
|
-
}];
|
|
60
|
-
})));
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
} else {
|
|
64
|
-
table.content.firstChild.content.forEach(function (cell) {
|
|
65
|
-
var colspan = cell.attrs.colspan || 1;
|
|
66
|
-
if (Array.isArray(cell.attrs.colwidth)) {
|
|
67
|
-
// We slice here to guard against our colwidth array having more entries
|
|
68
|
-
// Than the we actually span. We'll patch the document at a later point.
|
|
25
|
+
var map = _tableMap.TableMap.get(table);
|
|
26
|
+
table.content.firstChild.content.forEach(function (cell) {
|
|
27
|
+
var colspan = cell.attrs.colspan || 1;
|
|
28
|
+
if (Array.isArray(cell.attrs.colwidth)) {
|
|
29
|
+
// We slice here to guard against our colwidth array having more entries
|
|
30
|
+
// Than the we actually span. We'll patch the document at a later point.
|
|
31
|
+
if (tableRef) {
|
|
32
|
+
var scalePercent = (0, _misc.getTableScalingPercent)(table, tableRef);
|
|
69
33
|
cell.attrs.colwidth.slice(0, colspan).forEach(function (width) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
34
|
+
var fixedColWidth = getColWidthFix(width, map.width);
|
|
35
|
+
var scaledWidth = fixedColWidth * scalePercent;
|
|
36
|
+
var finalWidth = Math.max(scaledWidth, _styles.tableCellMinWidth);
|
|
37
|
+
cols.push(['col', {
|
|
38
|
+
style: "width: ".concat(finalWidth, "px;")
|
|
39
|
+
}]);
|
|
73
40
|
});
|
|
74
41
|
} else {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}, function (_) {
|
|
81
|
-
return ['col', {}];
|
|
82
|
-
})));
|
|
42
|
+
cell.attrs.colwidth.slice(0, colspan).forEach(function (width) {
|
|
43
|
+
cols.push(['col', {
|
|
44
|
+
style: "width: ".concat(getColWidthFix(width ? Math.max(width, _styles.tableCellMinWidth) : _styles.tableCellMinWidth, map.width), "px;")
|
|
45
|
+
}]);
|
|
46
|
+
});
|
|
83
47
|
}
|
|
84
|
-
}
|
|
85
|
-
|
|
48
|
+
} else {
|
|
49
|
+
// When we have merged cells on the first row (firstChild),
|
|
50
|
+
// We want to ensure we're creating the appropriate amount of
|
|
51
|
+
// cols the table still has.
|
|
52
|
+
cols.push.apply(cols, (0, _toConsumableArray2.default)(Array.from({
|
|
53
|
+
length: colspan
|
|
54
|
+
}, function (_) {
|
|
55
|
+
return ['col', {
|
|
56
|
+
style: "width: ".concat(_styles.tableCellMinWidth, "px;")
|
|
57
|
+
}];
|
|
58
|
+
})));
|
|
59
|
+
}
|
|
60
|
+
});
|
|
86
61
|
return cols;
|
|
87
62
|
};
|
|
88
63
|
var insertColgroupFromNode = exports.insertColgroupFromNode = function insertColgroupFromNode(tableRef, table) {
|
|
@@ -14,7 +14,6 @@ var _styles = require("@atlaskit/editor-common/styles");
|
|
|
14
14
|
var _ui = require("@atlaskit/editor-common/ui");
|
|
15
15
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
16
16
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
17
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
18
17
|
var _colgroup = require("./colgroup");
|
|
19
18
|
var _consts = require("./consts");
|
|
20
19
|
// Translates named layouts in number values.
|
|
@@ -77,7 +76,7 @@ var getTableMaxWidth = exports.getTableMaxWidth = function getTableMaxWidth(_ref
|
|
|
77
76
|
getEditorContainerWidth = _ref2.getEditorContainerWidth;
|
|
78
77
|
var containerWidth = getEditorContainerWidth();
|
|
79
78
|
var parentWidth = (0, _nodeWidth.getParentNodeWidth)(tableStart, state, containerWidth);
|
|
80
|
-
var maxWidth =
|
|
79
|
+
var maxWidth = parentWidth || table.attrs.width || getLayoutSize(layout, containerWidth.width, {});
|
|
81
80
|
if (table.attrs.isNumberColumnEnabled) {
|
|
82
81
|
maxWidth -= _editorSharedStyles.akEditorTableNumberColumnWidth;
|
|
83
82
|
}
|
|
@@ -1,23 +1,48 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.resizeColumn = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
10
|
+
var _types = require("../../../types");
|
|
7
11
|
var _misc = require("./misc");
|
|
8
12
|
var _resizeLogic = require("./resize-logic");
|
|
9
13
|
var _resizeState = require("./resize-state");
|
|
10
|
-
|
|
11
|
-
|
|
14
|
+
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; }
|
|
15
|
+
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; } // Resize a given column by an amount from the current state
|
|
12
16
|
var resizeColumn = exports.resizeColumn = function resizeColumn(resizeState, colIndex, amount, tableRef, tableNode, selectedColumns) {
|
|
13
17
|
var isTableScalingEnabled = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
|
|
14
18
|
var scalePercent = 1;
|
|
15
|
-
var resizeAmount = amount;
|
|
19
|
+
var resizeAmount = (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.colum-resizing-improvements') ? amount * 2 : amount;
|
|
16
20
|
if (isTableScalingEnabled) {
|
|
17
21
|
scalePercent = (0, _misc.getTableScalingPercent)(tableNode, tableRef);
|
|
18
22
|
resizeAmount = amount / scalePercent;
|
|
19
23
|
}
|
|
20
|
-
var newState = resizeAmount > 0 ? (0, _resizeLogic.growColumn)(resizeState, colIndex, resizeAmount, selectedColumns) : resizeAmount < 0 ? (0, _resizeLogic.shrinkColumn)(resizeState, colIndex, resizeAmount, selectedColumns) : resizeState;
|
|
24
|
+
var newState = (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.colum-resizing-improvements') ? (0, _resizeLogic.updateAffectedColumn)(resizeState, colIndex, resizeAmount) : resizeAmount > 0 ? (0, _resizeLogic.growColumn)(resizeState, colIndex, resizeAmount, selectedColumns) : resizeAmount < 0 ? (0, _resizeLogic.shrinkColumn)(resizeState, colIndex, resizeAmount, selectedColumns) : resizeState;
|
|
21
25
|
(0, _resizeState.updateColgroup)(newState, tableRef, tableNode, isTableScalingEnabled);
|
|
26
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.colum-resizing-improvements')) {
|
|
27
|
+
// use the difference in width from affected column to update overall table width
|
|
28
|
+
var delta = newState.cols[colIndex].width - resizeState.cols[colIndex].width;
|
|
29
|
+
updateTable(delta, tableRef, tableNode);
|
|
30
|
+
return _objectSpread(_objectSpread({}, newState), {}, {
|
|
31
|
+
tableWidth: resizeState.tableWidth + delta
|
|
32
|
+
});
|
|
33
|
+
}
|
|
22
34
|
return newState;
|
|
35
|
+
};
|
|
36
|
+
var updateTable = function updateTable(resizeAmount, tableRef, tableNode
|
|
37
|
+
// isTableScalingEnabled: boolean,
|
|
38
|
+
) {
|
|
39
|
+
var currentWidth = (0, _misc.getTableContainerElementWidth)(tableNode);
|
|
40
|
+
var resizingContainer = tableRef.closest(".".concat(_types.TableCssClassName.TABLE_RESIZER_CONTAINER));
|
|
41
|
+
var resizingItem = resizingContainer === null || resizingContainer === void 0 ? void 0 : resizingContainer.querySelector('.resizer-item');
|
|
42
|
+
if (resizingContainer && resizingItem) {
|
|
43
|
+
var newWidth = "".concat(currentWidth + resizeAmount, "px");
|
|
44
|
+
tableRef.style.width = newWidth;
|
|
45
|
+
resizingContainer.style.width = newWidth;
|
|
46
|
+
resizingItem.style.width = newWidth;
|
|
47
|
+
}
|
|
23
48
|
};
|
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.growColumn = void 0;
|
|
8
8
|
exports.reduceSpace = reduceSpace;
|
|
9
9
|
exports.shrinkColumn = void 0;
|
|
10
|
+
exports.updateAffectedColumn = updateAffectedColumn;
|
|
10
11
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
12
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
12
13
|
var _columnState = require("./column-state");
|
|
@@ -224,4 +225,22 @@ function getCandidates(state, destIdx, amount) {
|
|
|
224
225
|
|
|
225
226
|
// only consider rows after the selected column in the direction of resize
|
|
226
227
|
return amount < 0 ? candidates.slice(0, destIdx) : candidates.slice(destIdx + 1);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Update the given column based on resizeAmount, maintaining all other columns
|
|
232
|
+
*/
|
|
233
|
+
function updateAffectedColumn(resizeState, colIndex, resizeAmount) {
|
|
234
|
+
var updatedCols = resizeState.cols.map(function (col, index) {
|
|
235
|
+
if (index === colIndex) {
|
|
236
|
+
var newWidth = Math.max(col.width + resizeAmount, col.minWidth);
|
|
237
|
+
return _objectSpread(_objectSpread({}, col), {}, {
|
|
238
|
+
width: newWidth
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
return col;
|
|
242
|
+
});
|
|
243
|
+
return _objectSpread(_objectSpread({}, resizeState), {}, {
|
|
244
|
+
cols: updatedCols
|
|
245
|
+
});
|
|
227
246
|
}
|