@atlaskit/editor-plugin-table 7.29.9 → 7.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/dist/cjs/nodeviews/TableComponent.js +63 -23
- package/dist/cjs/plugin.js +22 -2
- package/dist/cjs/toDOM.js +3 -2
- package/dist/cjs/utils/index.js +6 -0
- package/dist/cjs/utils/nodes.js +5 -1
- package/dist/es2019/nodeviews/TableComponent.js +31 -3
- package/dist/es2019/plugin.js +23 -3
- package/dist/es2019/toDOM.js +4 -3
- package/dist/es2019/utils/index.js +1 -1
- package/dist/es2019/utils/nodes.js +3 -0
- package/dist/esm/nodeviews/TableComponent.js +64 -24
- package/dist/esm/plugin.js +23 -3
- package/dist/esm/toDOM.js +4 -3
- package/dist/esm/utils/index.js +1 -1
- package/dist/esm/utils/nodes.js +4 -0
- package/dist/types/toDOM.d.ts +3 -2
- package/dist/types/utils/index.d.ts +1 -1
- package/dist/types/utils/nodes.d.ts +1 -0
- package/dist/types-ts4.5/toDOM.d.ts +3 -2
- package/dist/types-ts4.5/utils/index.d.ts +1 -1
- package/dist/types-ts4.5/utils/nodes.d.ts +1 -0
- package/package.json +11 -5
- package/src/nodeviews/TableComponent.tsx +50 -1
- package/src/plugin.tsx +40 -15
- package/src/toDOM.ts +8 -5
- package/src/utils/index.ts +1 -0
- package/src/utils/nodes.ts +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 7.30.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#159340](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/159340)
|
|
8
|
+
[`aa03078fd0c80`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/aa03078fd0c80) -
|
|
9
|
+
[ux] [ED-25398] This change is enabling nested tables behind a feature gate.
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`9546839a5b527`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/9546839a5b527) -
|
|
14
|
+
[ux] Fix comically wide table columns widths when table nested inside a nested node.
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
|
|
17
|
+
## 7.29.10
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- [#159176](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/159176)
|
|
22
|
+
[`8f1d77592a9dc`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/8f1d77592a9dc) -
|
|
23
|
+
Bump adf-schema to 44.2.0
|
|
24
|
+
- Updated dependencies
|
|
25
|
+
|
|
3
26
|
## 7.29.9
|
|
4
27
|
|
|
5
28
|
### Patch Changes
|
|
@@ -65,6 +65,10 @@ var initialOverflowCaptureTimeroutDelay = 300;
|
|
|
65
65
|
// the current collected data becomes stale and we want to start collecting fresh data again in future.
|
|
66
66
|
// PLEASE NOTE: that the current way this alaytics has been configured WILL cause reflows to occur. This is why the has been disabled.
|
|
67
67
|
var isOverflowAnalyticsEnabled = false;
|
|
68
|
+
|
|
69
|
+
// Prevent unnecessary parentWidth updates when table is nested inside of a node that is nested itself.
|
|
70
|
+
var NESTED_TABLE_IN_NESTED_PARENT_WIDTH_DIFF_MIN_THRESHOLD = 2;
|
|
71
|
+
var NESTED_TABLE_IN_NESTED_PARENT_WIDTH_DIFF_MAX_THRESHOLD = 20;
|
|
68
72
|
var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
69
73
|
(0, _inherits2.default)(TableComponent, _React$Component);
|
|
70
74
|
var _super = _createSuper(TableComponent);
|
|
@@ -157,6 +161,21 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
157
161
|
var prevAttrs = prevNode.attrs;
|
|
158
162
|
var isNested = (0, _utils5.isTableNested)(_this.props.view.state, _this.props.getPos());
|
|
159
163
|
var parentWidth = _this.getParentNodeWidth();
|
|
164
|
+
if (isNested && (0, _utils5.isTableNestedInMoreThanOneNode)(_this.props.view.state, _this.props.getPos()) && (0, _platformFeatureFlags.fg)('platform_editor_nested_table_in_nested_parent_fix')) {
|
|
165
|
+
var resizeObsWrapperWidth = _this.wrapperWidth || 0;
|
|
166
|
+
var wrapperWidthDiffBetweenRerenders = Math.abs(resizeObsWrapperWidth - (_this.state.parentWidth || 0));
|
|
167
|
+
var isOusideOfThreshold = wrapperWidthDiffBetweenRerenders <= NESTED_TABLE_IN_NESTED_PARENT_WIDTH_DIFF_MIN_THRESHOLD || wrapperWidthDiffBetweenRerenders > NESTED_TABLE_IN_NESTED_PARENT_WIDTH_DIFF_MAX_THRESHOLD;
|
|
168
|
+
// 1. Check isOusideOfThreshold is added to prevent undersired state update.
|
|
169
|
+
// When table is nested in the extenstion and the table column is being resized,
|
|
170
|
+
// space available within extension can change and cause undesirable state update.
|
|
171
|
+
// MIN_THRESNESTED_TABLE_IN_NESTED_PARENT_WIDTH_DIFF_MIN_THRESHOLDHOLD value is required
|
|
172
|
+
// as the resizeObsWrapperWidth can differ between page reloads by 2px.
|
|
173
|
+
|
|
174
|
+
// 2. Check resizeObsWrapperWidth > 1 is added to prevent parentWidth update when table unmounts.
|
|
175
|
+
// When a is nested table in a nested expand and the expand collabses, the table unmounts and
|
|
176
|
+
// resizeObsWrapperWidth becomes 1.
|
|
177
|
+
parentWidth = isOusideOfThreshold && resizeObsWrapperWidth > 1 ? resizeObsWrapperWidth : _this.state.parentWidth;
|
|
178
|
+
}
|
|
160
179
|
var parentWidthChanged = parentWidth && parentWidth !== _this.state.parentWidth;
|
|
161
180
|
var layoutSize = _this.tableNodeLayoutSize(node, containerWidth.width, options);
|
|
162
181
|
var hasNumberedColumnChanged = prevAttrs.isNumberColumnEnabled !== node.attrs.isNumberColumnEnabled;
|
|
@@ -358,7 +377,10 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
358
377
|
(0, _createClass2.default)(TableComponent, [{
|
|
359
378
|
key: "componentDidMount",
|
|
360
379
|
value: function componentDidMount() {
|
|
361
|
-
var _this$table,
|
|
380
|
+
var _this$table,
|
|
381
|
+
_this$table2,
|
|
382
|
+
_this$table3,
|
|
383
|
+
_this2 = this;
|
|
362
384
|
var _this$props7 = this.props,
|
|
363
385
|
allowColumnResizing = _this$props7.allowColumnResizing,
|
|
364
386
|
eventDispatcher = _this$props7.eventDispatcher,
|
|
@@ -379,6 +401,23 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
379
401
|
if (isTableScalingEnabled && tableWithFixedColumnWidthsOption && getNode().attrs.displayMode !== 'fixed') {
|
|
380
402
|
this.handleColgroupUpdates(true);
|
|
381
403
|
}
|
|
404
|
+
if (this.wrapper && (0, _platformFeatureFlags.fg)('platform_editor_nested_table_in_nested_parent_fix')) {
|
|
405
|
+
this.wrapperReisizeObserver = new ResizeObserver(function (entries) {
|
|
406
|
+
var _iterator2 = _createForOfIteratorHelper(entries),
|
|
407
|
+
_step2;
|
|
408
|
+
try {
|
|
409
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
410
|
+
var entry = _step2.value;
|
|
411
|
+
_this2.wrapperWidth = entry.contentRect.width;
|
|
412
|
+
}
|
|
413
|
+
} catch (err) {
|
|
414
|
+
_iterator2.e(err);
|
|
415
|
+
} finally {
|
|
416
|
+
_iterator2.f();
|
|
417
|
+
}
|
|
418
|
+
});
|
|
419
|
+
this.wrapperReisizeObserver.observe(this.wrapper);
|
|
420
|
+
}
|
|
382
421
|
if (allowColumnResizing && this.wrapper && !isIE11) {
|
|
383
422
|
this.wrapper.addEventListener('scroll', this.handleScrollDebounced, {
|
|
384
423
|
passive: true
|
|
@@ -416,7 +455,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
416
455
|
}, {
|
|
417
456
|
key: "componentWillUnmount",
|
|
418
457
|
value: function componentWillUnmount() {
|
|
419
|
-
var _this$resizeObserver, _this$table4, _this$table5, _this$table6;
|
|
458
|
+
var _this$resizeObserver, _this$wrapperReisizeO, _this$table4, _this$table5, _this$table6;
|
|
420
459
|
var _this$props8 = this.props,
|
|
421
460
|
allowColumnResizing = _this$props8.allowColumnResizing,
|
|
422
461
|
eventDispatcher = _this$props8.eventDispatcher,
|
|
@@ -429,6 +468,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
429
468
|
this.dragAndDropCleanupFn();
|
|
430
469
|
}
|
|
431
470
|
(_this$resizeObserver = this.resizeObserver) === null || _this$resizeObserver === void 0 || _this$resizeObserver.disconnect();
|
|
471
|
+
(_this$wrapperReisizeO = this.wrapperReisizeObserver) === null || _this$wrapperReisizeO === void 0 || _this$wrapperReisizeO.disconnect();
|
|
432
472
|
if (this.stickyScrollbar) {
|
|
433
473
|
this.stickyScrollbar.dispose();
|
|
434
474
|
}
|
|
@@ -481,7 +521,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
481
521
|
}, {
|
|
482
522
|
key: "handleColgroupUpdates",
|
|
483
523
|
value: function handleColgroupUpdates() {
|
|
484
|
-
var
|
|
524
|
+
var _this3 = this;
|
|
485
525
|
var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
486
526
|
var _this$props10 = this.props,
|
|
487
527
|
getNode = _this$props10.getNode,
|
|
@@ -555,18 +595,18 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
555
595
|
}
|
|
556
596
|
var scalePercent = 1;
|
|
557
597
|
requestAnimationFrame(function () {
|
|
558
|
-
var
|
|
598
|
+
var _this3$props$options, _this3$props$options2;
|
|
559
599
|
// Scaling percent has to be calculated inside requestAnimationFrame, otherwise
|
|
560
600
|
// renderWidth calculated as `tableRef?.parentElement?.clientWidth`
|
|
561
601
|
// inside of getTableScalingPercent returns 0.
|
|
562
|
-
if (!((
|
|
563
|
-
scalePercent = (0, _misc.getTableScalingPercent)(tableNode,
|
|
602
|
+
if (!((_this3$props$options = _this3.props.options) !== null && _this3$props$options !== void 0 && _this3$props$options.isCommentEditor) || (_this3$props$options2 = _this3.props.options) !== null && _this3$props$options2 !== void 0 && _this3$props$options2.isCommentEditor && tableNode.attrs.width) {
|
|
603
|
+
scalePercent = (0, _misc.getTableScalingPercent)(tableNode, _this3.table, shouldUseIncreasedScalingPercent);
|
|
564
604
|
} else {
|
|
565
|
-
scalePercent = (0, _misc.getScalingPercentForTableWithoutWidth)(tableNode,
|
|
605
|
+
scalePercent = (0, _misc.getScalingPercentForTableWithoutWidth)(tableNode, _this3.table);
|
|
566
606
|
}
|
|
567
607
|
|
|
568
608
|
// Request animation frame required for Firefox
|
|
569
|
-
(0, _utils4.updateColgroup)(resizeState,
|
|
609
|
+
(0, _utils4.updateColgroup)(resizeState, _this3.table, tableNode, shouldScaleOnColgroupUpdate, scalePercent);
|
|
570
610
|
});
|
|
571
611
|
}
|
|
572
612
|
}
|
|
@@ -580,7 +620,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
580
620
|
var _this$props$options8,
|
|
581
621
|
_this$props$options9,
|
|
582
622
|
_this$wrapper,
|
|
583
|
-
|
|
623
|
+
_this4 = this;
|
|
584
624
|
var _this$props11 = this.props,
|
|
585
625
|
view = _this$props11.view,
|
|
586
626
|
getNode = _this$props11.getNode,
|
|
@@ -627,7 +667,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
627
667
|
// that happens when a table is nested in expand and expand's width is
|
|
628
668
|
// changed via breakout button
|
|
629
669
|
window.requestAnimationFrame(function () {
|
|
630
|
-
|
|
670
|
+
_this4.overflowShadowsObserver = new _OverflowShadowsObserver.OverflowShadowsObserver(_this4.updateShadowState, _this4.table, _this4.wrapper);
|
|
631
671
|
});
|
|
632
672
|
} else {
|
|
633
673
|
this.overflowShadowsObserver = new _OverflowShadowsObserver.OverflowShadowsObserver(this.updateShadowState, this.table, this.wrapper);
|
|
@@ -704,7 +744,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
704
744
|
}, {
|
|
705
745
|
key: "render",
|
|
706
746
|
value: function render() {
|
|
707
|
-
var
|
|
747
|
+
var _this5 = this,
|
|
708
748
|
_this$state$stickyHea2,
|
|
709
749
|
_this$state$stickyHea3,
|
|
710
750
|
_this$props$options10,
|
|
@@ -795,8 +835,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
795
835
|
tableContainerWidth: tableContainerWidth,
|
|
796
836
|
isNumberColumnEnabled: node.attrs.isNumberColumnEnabled,
|
|
797
837
|
getScrollOffset: function getScrollOffset() {
|
|
798
|
-
var
|
|
799
|
-
return ((
|
|
838
|
+
var _this5$wrapper;
|
|
839
|
+
return ((_this5$wrapper = _this5.wrapper) === null || _this5$wrapper === void 0 ? void 0 : _this5$wrapper.scrollLeft) || 0;
|
|
800
840
|
},
|
|
801
841
|
tableWrapperHeight: this.state.tableWrapperHeight,
|
|
802
842
|
api: pluginInjectionApi,
|
|
@@ -861,12 +901,12 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
861
901
|
editorView: view,
|
|
862
902
|
node: node,
|
|
863
903
|
getScrollOffset: function getScrollOffset() {
|
|
864
|
-
var
|
|
865
|
-
return ((
|
|
904
|
+
var _this5$wrapper2;
|
|
905
|
+
return ((_this5$wrapper2 = _this5.wrapper) === null || _this5$wrapper2 === void 0 ? void 0 : _this5$wrapper2.scrollLeft) || 0;
|
|
866
906
|
},
|
|
867
907
|
getTableWrapperWidth: function getTableWrapperWidth() {
|
|
868
|
-
var
|
|
869
|
-
return ((
|
|
908
|
+
var _this5$wrapper3;
|
|
909
|
+
return ((_this5$wrapper3 = _this5.wrapper) === null || _this5$wrapper3 === void 0 ? void 0 : _this5$wrapper3.clientWidth) || 760;
|
|
870
910
|
}
|
|
871
911
|
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
872
912
|
contentEditable: false
|
|
@@ -888,14 +928,14 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
888
928
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
889
929
|
className: (0, _classnames2.default)(_types.TableCssClassName.TABLE_NODE_WRAPPER),
|
|
890
930
|
ref: function ref(elem) {
|
|
891
|
-
|
|
931
|
+
_this5.wrapper = elem;
|
|
892
932
|
if (elem) {
|
|
893
|
-
|
|
933
|
+
_this5.props.contentDOM(elem);
|
|
894
934
|
var tableElement = elem.querySelector('table');
|
|
895
|
-
if (tableElement !==
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
935
|
+
if (tableElement !== _this5.table) {
|
|
936
|
+
_this5.table = tableElement;
|
|
937
|
+
_this5.createShadowSentinels(_this5.table);
|
|
938
|
+
_this5.observeTable(_this5.table);
|
|
899
939
|
}
|
|
900
940
|
}
|
|
901
941
|
}
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -18,6 +18,7 @@ var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
|
18
18
|
var _withPluginState = require("@atlaskit/editor-common/with-plugin-state");
|
|
19
19
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
20
20
|
var _pmPlugins = require("@atlaskit/editor-tables/pm-plugins");
|
|
21
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
21
22
|
var _insert = require("./commands/insert");
|
|
22
23
|
var _createPluginConfig = require("./create-plugin-config");
|
|
23
24
|
var _plugin = require("./pm-plugins/analytics/plugin");
|
|
@@ -143,12 +144,31 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
143
144
|
nodes: function nodes() {
|
|
144
145
|
var _pluginConfig = (0, _createPluginConfig.pluginConfig)(options === null || options === void 0 ? void 0 : options.tableOptions),
|
|
145
146
|
allowColumnResizing = _pluginConfig.allowColumnResizing;
|
|
146
|
-
|
|
147
|
+
var isNestingSupported = (0, _platformFeatureFlags.fg)('platform_editor_use_nested_table_pm_nodes');
|
|
148
|
+
return isNestingSupported ? [{
|
|
147
149
|
name: 'table',
|
|
148
150
|
node: (0, _toDOM.tableNodeSpecWithFixedToDOM)({
|
|
149
151
|
allowColumnResizing: Boolean(allowColumnResizing),
|
|
150
152
|
tableResizingEnabled: Boolean(options === null || options === void 0 ? void 0 : options.tableResizingEnabled),
|
|
151
|
-
getEditorContainerWidth: defaultGetEditorContainerWidth
|
|
153
|
+
getEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
154
|
+
isNestingSupported: isNestingSupported
|
|
155
|
+
})
|
|
156
|
+
}, {
|
|
157
|
+
name: 'tableHeader',
|
|
158
|
+
node: _adfSchema.tableHeaderWithNestedTable
|
|
159
|
+
}, {
|
|
160
|
+
name: 'tableRow',
|
|
161
|
+
node: _adfSchema.tableRowWithNestedTable
|
|
162
|
+
}, {
|
|
163
|
+
name: 'tableCell',
|
|
164
|
+
node: _adfSchema.tableCellWithNestedTable
|
|
165
|
+
}] : [{
|
|
166
|
+
name: 'table',
|
|
167
|
+
node: (0, _toDOM.tableNodeSpecWithFixedToDOM)({
|
|
168
|
+
allowColumnResizing: Boolean(allowColumnResizing),
|
|
169
|
+
tableResizingEnabled: Boolean(options === null || options === void 0 ? void 0 : options.tableResizingEnabled),
|
|
170
|
+
getEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
171
|
+
isNestingSupported: isNestingSupported
|
|
152
172
|
})
|
|
153
173
|
}, {
|
|
154
174
|
name: 'tableHeader',
|
package/dist/cjs/toDOM.js
CHANGED
|
@@ -20,10 +20,11 @@ var _consts = require("./pm-plugins/table-resizing/utils/consts");
|
|
|
20
20
|
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; }
|
|
21
21
|
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; }
|
|
22
22
|
var tableNodeSpecWithFixedToDOM = exports.tableNodeSpecWithFixedToDOM = function tableNodeSpecWithFixedToDOM(config) {
|
|
23
|
+
var tableNode = config.isNestingSupported ? _adfSchema.tableWithNestedTable : _adfSchema.table;
|
|
23
24
|
if ((0, _experiments.editorExperiment)('platform_editor_exp_lazy_node_views', false)) {
|
|
24
|
-
return
|
|
25
|
+
return tableNode;
|
|
25
26
|
}
|
|
26
|
-
return _objectSpread(_objectSpread({},
|
|
27
|
+
return _objectSpread(_objectSpread({}, tableNode), {}, {
|
|
27
28
|
toDOM: function toDOM(node) {
|
|
28
29
|
var gutterPadding = (0, _editorSharedStyles.akEditorGutterPaddingDynamic)() * 2;
|
|
29
30
|
var editorWidthFromGetter = (0, _platformFeatureFlags.fg)('platform_editor_breakout_use_css') ? undefined : Math.min(config.getEditorContainerWidth().width - gutterPadding, node.attrs.width);
|
package/dist/cjs/utils/index.js
CHANGED
|
@@ -291,6 +291,12 @@ Object.defineProperty(exports, "isTableNested", {
|
|
|
291
291
|
return _nodes.isTableNested;
|
|
292
292
|
}
|
|
293
293
|
});
|
|
294
|
+
Object.defineProperty(exports, "isTableNestedInMoreThanOneNode", {
|
|
295
|
+
enumerable: true,
|
|
296
|
+
get: function get() {
|
|
297
|
+
return _nodes.isTableNestedInMoreThanOneNode;
|
|
298
|
+
}
|
|
299
|
+
});
|
|
294
300
|
Object.defineProperty(exports, "tablesHaveDifferentColumnWidths", {
|
|
295
301
|
enumerable: true,
|
|
296
302
|
get: function get() {
|
package/dist/cjs/utils/nodes.js
CHANGED
|
@@ -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.tablesHaveDifferentNoOfRows = exports.tablesHaveDifferentNoOfColumns = exports.tablesHaveDifferentColumnWidths = exports.supportedHeaderRow = exports.isTableNested = exports.isIsolating = exports.getTableWidth = exports.containsHeaderRow = exports.containsHeaderColumn = exports.checkIfNumberColumnEnabled = exports.checkIfHeaderRowEnabled = exports.checkIfHeaderColumnEnabled = void 0;
|
|
7
|
+
exports.tablesHaveDifferentNoOfRows = exports.tablesHaveDifferentNoOfColumns = exports.tablesHaveDifferentColumnWidths = exports.supportedHeaderRow = exports.isTableNestedInMoreThanOneNode = exports.isTableNested = exports.isIsolating = exports.getTableWidth = exports.containsHeaderRow = exports.containsHeaderColumn = exports.checkIfNumberColumnEnabled = exports.checkIfHeaderRowEnabled = exports.checkIfHeaderColumnEnabled = void 0;
|
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
9
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
10
10
|
var _tableMap = require("@atlaskit/editor-tables/table-map");
|
|
@@ -106,6 +106,10 @@ var isTableNested = exports.isTableNested = function isTableNested(state) {
|
|
|
106
106
|
var nodeTypes = state.schema.nodes;
|
|
107
107
|
return parent.type === nodeTypes.layoutColumn || parent.type === nodeTypes.expand || parent.type === nodeTypes.bodiedExtension || parent.type === nodeTypes.extensionFrame;
|
|
108
108
|
};
|
|
109
|
+
var isTableNestedInMoreThanOneNode = exports.isTableNestedInMoreThanOneNode = function isTableNestedInMoreThanOneNode(state) {
|
|
110
|
+
var tablePos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
111
|
+
return state.doc.resolve(tablePos).depth > 2;
|
|
112
|
+
};
|
|
109
113
|
var anyChildCellMergedAcrossRow = function anyChildCellMergedAcrossRow(node) {
|
|
110
114
|
return (0, _utils.mapChildren)(node, function (child) {
|
|
111
115
|
return child.attrs.rowspan || 0;
|
|
@@ -28,7 +28,7 @@ import { getScalingPercentForTableWithoutWidth, getTableScalingPercent } from '.
|
|
|
28
28
|
import { TableCssClassName as ClassName, ShadowEvent } from '../types';
|
|
29
29
|
import TableFloatingColumnControls from '../ui/TableFloatingColumnControls';
|
|
30
30
|
import TableFloatingControls from '../ui/TableFloatingControls';
|
|
31
|
-
import { containsHeaderRow, getAssistiveMessage, isTableNested, tablesHaveDifferentColumnWidths, tablesHaveDifferentNoOfColumns, tablesHaveDifferentNoOfRows } from '../utils';
|
|
31
|
+
import { containsHeaderRow, getAssistiveMessage, isTableNested, isTableNestedInMoreThanOneNode, tablesHaveDifferentColumnWidths, tablesHaveDifferentNoOfColumns, tablesHaveDifferentNoOfRows } from '../utils';
|
|
32
32
|
import { ExternalDropTargets } from './ExternalDropTargets';
|
|
33
33
|
import { OverflowShadowsObserver } from './OverflowShadowsObserver';
|
|
34
34
|
import { TableContainer } from './TableContainer';
|
|
@@ -44,6 +44,10 @@ const initialOverflowCaptureTimeroutDelay = 300;
|
|
|
44
44
|
// the current collected data becomes stale and we want to start collecting fresh data again in future.
|
|
45
45
|
// PLEASE NOTE: that the current way this alaytics has been configured WILL cause reflows to occur. This is why the has been disabled.
|
|
46
46
|
const isOverflowAnalyticsEnabled = false;
|
|
47
|
+
|
|
48
|
+
// Prevent unnecessary parentWidth updates when table is nested inside of a node that is nested itself.
|
|
49
|
+
const NESTED_TABLE_IN_NESTED_PARENT_WIDTH_DIFF_MIN_THRESHOLD = 2;
|
|
50
|
+
const NESTED_TABLE_IN_NESTED_PARENT_WIDTH_DIFF_MAX_THRESHOLD = 20;
|
|
47
51
|
class TableComponent extends React.Component {
|
|
48
52
|
constructor(props) {
|
|
49
53
|
super(props);
|
|
@@ -139,7 +143,22 @@ class TableComponent extends React.Component {
|
|
|
139
143
|
const node = getNode();
|
|
140
144
|
const prevAttrs = prevNode.attrs;
|
|
141
145
|
const isNested = isTableNested(this.props.view.state, this.props.getPos());
|
|
142
|
-
|
|
146
|
+
let parentWidth = this.getParentNodeWidth();
|
|
147
|
+
if (isNested && isTableNestedInMoreThanOneNode(this.props.view.state, this.props.getPos()) && fg('platform_editor_nested_table_in_nested_parent_fix')) {
|
|
148
|
+
const resizeObsWrapperWidth = this.wrapperWidth || 0;
|
|
149
|
+
const wrapperWidthDiffBetweenRerenders = Math.abs(resizeObsWrapperWidth - (this.state.parentWidth || 0));
|
|
150
|
+
const isOusideOfThreshold = wrapperWidthDiffBetweenRerenders <= NESTED_TABLE_IN_NESTED_PARENT_WIDTH_DIFF_MIN_THRESHOLD || wrapperWidthDiffBetweenRerenders > NESTED_TABLE_IN_NESTED_PARENT_WIDTH_DIFF_MAX_THRESHOLD;
|
|
151
|
+
// 1. Check isOusideOfThreshold is added to prevent undersired state update.
|
|
152
|
+
// When table is nested in the extenstion and the table column is being resized,
|
|
153
|
+
// space available within extension can change and cause undesirable state update.
|
|
154
|
+
// MIN_THRESNESTED_TABLE_IN_NESTED_PARENT_WIDTH_DIFF_MIN_THRESHOLDHOLD value is required
|
|
155
|
+
// as the resizeObsWrapperWidth can differ between page reloads by 2px.
|
|
156
|
+
|
|
157
|
+
// 2. Check resizeObsWrapperWidth > 1 is added to prevent parentWidth update when table unmounts.
|
|
158
|
+
// When a is nested table in a nested expand and the expand collabses, the table unmounts and
|
|
159
|
+
// resizeObsWrapperWidth becomes 1.
|
|
160
|
+
parentWidth = isOusideOfThreshold && resizeObsWrapperWidth > 1 ? resizeObsWrapperWidth : this.state.parentWidth;
|
|
161
|
+
}
|
|
143
162
|
const parentWidthChanged = parentWidth && parentWidth !== this.state.parentWidth;
|
|
144
163
|
const layoutSize = this.tableNodeLayoutSize(node, containerWidth.width, options);
|
|
145
164
|
const hasNumberedColumnChanged = prevAttrs.isNumberColumnEnabled !== node.attrs.isNumberColumnEnabled;
|
|
@@ -361,6 +380,14 @@ class TableComponent extends React.Component {
|
|
|
361
380
|
if (isTableScalingEnabled && tableWithFixedColumnWidthsOption && getNode().attrs.displayMode !== 'fixed') {
|
|
362
381
|
this.handleColgroupUpdates(true);
|
|
363
382
|
}
|
|
383
|
+
if (this.wrapper && fg('platform_editor_nested_table_in_nested_parent_fix')) {
|
|
384
|
+
this.wrapperReisizeObserver = new ResizeObserver(entries => {
|
|
385
|
+
for (const entry of entries) {
|
|
386
|
+
this.wrapperWidth = entry.contentRect.width;
|
|
387
|
+
}
|
|
388
|
+
});
|
|
389
|
+
this.wrapperReisizeObserver.observe(this.wrapper);
|
|
390
|
+
}
|
|
364
391
|
if (allowColumnResizing && this.wrapper && !isIE11) {
|
|
365
392
|
this.wrapper.addEventListener('scroll', this.handleScrollDebounced, {
|
|
366
393
|
passive: true
|
|
@@ -396,7 +423,7 @@ class TableComponent extends React.Component {
|
|
|
396
423
|
}
|
|
397
424
|
}
|
|
398
425
|
componentWillUnmount() {
|
|
399
|
-
var _this$resizeObserver, _this$table4, _this$table5, _this$table6;
|
|
426
|
+
var _this$resizeObserver, _this$wrapperReisizeO, _this$table4, _this$table5, _this$table6;
|
|
400
427
|
const {
|
|
401
428
|
allowColumnResizing,
|
|
402
429
|
eventDispatcher,
|
|
@@ -410,6 +437,7 @@ class TableComponent extends React.Component {
|
|
|
410
437
|
this.dragAndDropCleanupFn();
|
|
411
438
|
}
|
|
412
439
|
(_this$resizeObserver = this.resizeObserver) === null || _this$resizeObserver === void 0 ? void 0 : _this$resizeObserver.disconnect();
|
|
440
|
+
(_this$wrapperReisizeO = this.wrapperReisizeObserver) === null || _this$wrapperReisizeO === void 0 ? void 0 : _this$wrapperReisizeO.disconnect();
|
|
413
441
|
if (this.stickyScrollbar) {
|
|
414
442
|
this.stickyScrollbar.dispose();
|
|
415
443
|
}
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { tableCell, tableHeader, tableRow } from '@atlaskit/adf-schema';
|
|
2
|
+
import { tableCell, tableCellWithNestedTable, tableHeader, tableHeaderWithNestedTable, tableRow, tableRowWithNestedTable } from '@atlaskit/adf-schema';
|
|
3
3
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
|
|
4
4
|
import { browser } from '@atlaskit/editor-common/browser';
|
|
5
5
|
import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
|
|
@@ -10,6 +10,7 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
|
10
10
|
import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
|
|
11
11
|
import { akEditorFloatingPanelZIndex } from '@atlaskit/editor-shared-styles';
|
|
12
12
|
import { tableEditing } from '@atlaskit/editor-tables/pm-plugins';
|
|
13
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
13
14
|
import { insertTableWithSize } from './commands/insert';
|
|
14
15
|
import { pluginConfig } from './create-plugin-config';
|
|
15
16
|
import { createPlugin as createTableAnalyticsPlugin } from './pm-plugins/analytics/plugin';
|
|
@@ -133,12 +134,31 @@ const tablesPlugin = ({
|
|
|
133
134
|
const {
|
|
134
135
|
allowColumnResizing
|
|
135
136
|
} = pluginConfig(options === null || options === void 0 ? void 0 : options.tableOptions);
|
|
136
|
-
|
|
137
|
+
const isNestingSupported = fg('platform_editor_use_nested_table_pm_nodes');
|
|
138
|
+
return isNestingSupported ? [{
|
|
137
139
|
name: 'table',
|
|
138
140
|
node: tableNodeSpecWithFixedToDOM({
|
|
139
141
|
allowColumnResizing: Boolean(allowColumnResizing),
|
|
140
142
|
tableResizingEnabled: Boolean(options === null || options === void 0 ? void 0 : options.tableResizingEnabled),
|
|
141
|
-
getEditorContainerWidth: defaultGetEditorContainerWidth
|
|
143
|
+
getEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
144
|
+
isNestingSupported
|
|
145
|
+
})
|
|
146
|
+
}, {
|
|
147
|
+
name: 'tableHeader',
|
|
148
|
+
node: tableHeaderWithNestedTable
|
|
149
|
+
}, {
|
|
150
|
+
name: 'tableRow',
|
|
151
|
+
node: tableRowWithNestedTable
|
|
152
|
+
}, {
|
|
153
|
+
name: 'tableCell',
|
|
154
|
+
node: tableCellWithNestedTable
|
|
155
|
+
}] : [{
|
|
156
|
+
name: 'table',
|
|
157
|
+
node: tableNodeSpecWithFixedToDOM({
|
|
158
|
+
allowColumnResizing: Boolean(allowColumnResizing),
|
|
159
|
+
tableResizingEnabled: Boolean(options === null || options === void 0 ? void 0 : options.tableResizingEnabled),
|
|
160
|
+
getEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
161
|
+
isNestingSupported
|
|
142
162
|
})
|
|
143
163
|
}, {
|
|
144
164
|
name: 'tableHeader',
|
package/dist/es2019/toDOM.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import kebabCase from 'lodash/kebabCase';
|
|
2
|
-
import { table } from '@atlaskit/adf-schema';
|
|
2
|
+
import { table, tableWithNestedTable } from '@atlaskit/adf-schema';
|
|
3
3
|
import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
|
|
4
4
|
import { akEditorGutterPaddingDynamic } from '@atlaskit/editor-shared-styles';
|
|
5
5
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
@@ -8,11 +8,12 @@ import { getAlignmentStyle } from './nodeviews/table-container-styles';
|
|
|
8
8
|
import { generateColgroup, getResizerMinWidth } from './pm-plugins/table-resizing/utils/colgroup';
|
|
9
9
|
import { TABLE_MAX_WIDTH } from './pm-plugins/table-resizing/utils/consts';
|
|
10
10
|
export const tableNodeSpecWithFixedToDOM = config => {
|
|
11
|
+
const tableNode = config.isNestingSupported ? tableWithNestedTable : table;
|
|
11
12
|
if (editorExperiment('platform_editor_exp_lazy_node_views', false)) {
|
|
12
|
-
return
|
|
13
|
+
return tableNode;
|
|
13
14
|
}
|
|
14
15
|
return {
|
|
15
|
-
...
|
|
16
|
+
...tableNode,
|
|
16
17
|
toDOM: node => {
|
|
17
18
|
const gutterPadding = akEditorGutterPaddingDynamic() * 2;
|
|
18
19
|
const editorWidthFromGetter = fg('platform_editor_breakout_use_css') ? undefined : Math.min(config.getEditorContainerWidth().width - gutterPadding, node.attrs.width);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { getSelectedColumnIndexes, getSelectedRowIndexes } from './selection';
|
|
2
2
|
export { findControlsHoverDecoration, createControlsHoverDecoration, createCellHoverDecoration, updateDecorations, createColumnInsertLine, createColumnLineResize, createRowInsertLine } from './decoration';
|
|
3
|
-
export { containsHeaderColumn, containsHeaderRow, checkIfHeaderColumnEnabled, checkIfHeaderRowEnabled, checkIfNumberColumnEnabled, getTableWidth, tablesHaveDifferentColumnWidths, tablesHaveDifferentNoOfColumns, tablesHaveDifferentNoOfRows, isTableNested } from './nodes';
|
|
3
|
+
export { containsHeaderColumn, containsHeaderRow, checkIfHeaderColumnEnabled, checkIfHeaderRowEnabled, checkIfNumberColumnEnabled, getTableWidth, tablesHaveDifferentColumnWidths, tablesHaveDifferentNoOfColumns, tablesHaveDifferentNoOfRows, isTableNested, isTableNestedInMoreThanOneNode } from './nodes';
|
|
4
4
|
export { transformSliceToRemoveOpenTable, transformSliceToCorrectEmptyTableCells, transformSliceToFixHardBreakProblemOnCopyFromCell } from './paste';
|
|
5
5
|
export { isCell, isCornerButton, isInsertRowButton, isColumnControlsDecorations, isTableControlsButton, isTableContainerOrWrapper, isRowControlsButton, isDragColumnFloatingInsertDot, isDragRowFloatingInsertDot, isDragCornerButton, getColumnOrRowIndex, getMousePositionHorizontalRelativeByElement, getMousePositionVerticalRelativeByElement, isResizeHandleDecoration, hasResizeHandler, findNearestCellIndexToPoint } from './dom';
|
|
6
6
|
export { convertHTMLCellIndexToColumnIndex, getColumnsWidths, getColumnDeleteButtonParams, getColumnIndexMappedToColumnIndexInFirstRow } from './column-controls';
|
|
@@ -87,6 +87,9 @@ export const isTableNested = (state, tablePos = 0) => {
|
|
|
87
87
|
const nodeTypes = state.schema.nodes;
|
|
88
88
|
return parent.type === nodeTypes.layoutColumn || parent.type === nodeTypes.expand || parent.type === nodeTypes.bodiedExtension || parent.type === nodeTypes.extensionFrame;
|
|
89
89
|
};
|
|
90
|
+
export const isTableNestedInMoreThanOneNode = (state, tablePos = 0) => {
|
|
91
|
+
return state.doc.resolve(tablePos).depth > 2;
|
|
92
|
+
};
|
|
90
93
|
const anyChildCellMergedAcrossRow = node => mapChildren(node, child => child.attrs.rowspan || 0).some(rowspan => rowspan > 1);
|
|
91
94
|
|
|
92
95
|
/**
|
|
@@ -42,7 +42,7 @@ import { getScalingPercentForTableWithoutWidth, getTableScalingPercent } from '.
|
|
|
42
42
|
import { TableCssClassName as ClassName, ShadowEvent } from '../types';
|
|
43
43
|
import TableFloatingColumnControls from '../ui/TableFloatingColumnControls';
|
|
44
44
|
import TableFloatingControls from '../ui/TableFloatingControls';
|
|
45
|
-
import { containsHeaderRow, getAssistiveMessage, isTableNested, tablesHaveDifferentColumnWidths, tablesHaveDifferentNoOfColumns, tablesHaveDifferentNoOfRows } from '../utils';
|
|
45
|
+
import { containsHeaderRow, getAssistiveMessage, isTableNested, isTableNestedInMoreThanOneNode, tablesHaveDifferentColumnWidths, tablesHaveDifferentNoOfColumns, tablesHaveDifferentNoOfRows } from '../utils';
|
|
46
46
|
import { ExternalDropTargets } from './ExternalDropTargets';
|
|
47
47
|
import { OverflowShadowsObserver } from './OverflowShadowsObserver';
|
|
48
48
|
import { TableContainer } from './TableContainer';
|
|
@@ -58,6 +58,10 @@ var initialOverflowCaptureTimeroutDelay = 300;
|
|
|
58
58
|
// the current collected data becomes stale and we want to start collecting fresh data again in future.
|
|
59
59
|
// PLEASE NOTE: that the current way this alaytics has been configured WILL cause reflows to occur. This is why the has been disabled.
|
|
60
60
|
var isOverflowAnalyticsEnabled = false;
|
|
61
|
+
|
|
62
|
+
// Prevent unnecessary parentWidth updates when table is nested inside of a node that is nested itself.
|
|
63
|
+
var NESTED_TABLE_IN_NESTED_PARENT_WIDTH_DIFF_MIN_THRESHOLD = 2;
|
|
64
|
+
var NESTED_TABLE_IN_NESTED_PARENT_WIDTH_DIFF_MAX_THRESHOLD = 20;
|
|
61
65
|
var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
62
66
|
_inherits(TableComponent, _React$Component);
|
|
63
67
|
var _super = _createSuper(TableComponent);
|
|
@@ -150,6 +154,21 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
150
154
|
var prevAttrs = prevNode.attrs;
|
|
151
155
|
var isNested = isTableNested(_this.props.view.state, _this.props.getPos());
|
|
152
156
|
var parentWidth = _this.getParentNodeWidth();
|
|
157
|
+
if (isNested && isTableNestedInMoreThanOneNode(_this.props.view.state, _this.props.getPos()) && fg('platform_editor_nested_table_in_nested_parent_fix')) {
|
|
158
|
+
var resizeObsWrapperWidth = _this.wrapperWidth || 0;
|
|
159
|
+
var wrapperWidthDiffBetweenRerenders = Math.abs(resizeObsWrapperWidth - (_this.state.parentWidth || 0));
|
|
160
|
+
var isOusideOfThreshold = wrapperWidthDiffBetweenRerenders <= NESTED_TABLE_IN_NESTED_PARENT_WIDTH_DIFF_MIN_THRESHOLD || wrapperWidthDiffBetweenRerenders > NESTED_TABLE_IN_NESTED_PARENT_WIDTH_DIFF_MAX_THRESHOLD;
|
|
161
|
+
// 1. Check isOusideOfThreshold is added to prevent undersired state update.
|
|
162
|
+
// When table is nested in the extenstion and the table column is being resized,
|
|
163
|
+
// space available within extension can change and cause undesirable state update.
|
|
164
|
+
// MIN_THRESNESTED_TABLE_IN_NESTED_PARENT_WIDTH_DIFF_MIN_THRESHOLDHOLD value is required
|
|
165
|
+
// as the resizeObsWrapperWidth can differ between page reloads by 2px.
|
|
166
|
+
|
|
167
|
+
// 2. Check resizeObsWrapperWidth > 1 is added to prevent parentWidth update when table unmounts.
|
|
168
|
+
// When a is nested table in a nested expand and the expand collabses, the table unmounts and
|
|
169
|
+
// resizeObsWrapperWidth becomes 1.
|
|
170
|
+
parentWidth = isOusideOfThreshold && resizeObsWrapperWidth > 1 ? resizeObsWrapperWidth : _this.state.parentWidth;
|
|
171
|
+
}
|
|
153
172
|
var parentWidthChanged = parentWidth && parentWidth !== _this.state.parentWidth;
|
|
154
173
|
var layoutSize = _this.tableNodeLayoutSize(node, containerWidth.width, options);
|
|
155
174
|
var hasNumberedColumnChanged = prevAttrs.isNumberColumnEnabled !== node.attrs.isNumberColumnEnabled;
|
|
@@ -351,7 +370,10 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
351
370
|
_createClass(TableComponent, [{
|
|
352
371
|
key: "componentDidMount",
|
|
353
372
|
value: function componentDidMount() {
|
|
354
|
-
var _this$table,
|
|
373
|
+
var _this$table,
|
|
374
|
+
_this$table2,
|
|
375
|
+
_this$table3,
|
|
376
|
+
_this2 = this;
|
|
355
377
|
var _this$props7 = this.props,
|
|
356
378
|
allowColumnResizing = _this$props7.allowColumnResizing,
|
|
357
379
|
eventDispatcher = _this$props7.eventDispatcher,
|
|
@@ -372,6 +394,23 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
372
394
|
if (isTableScalingEnabled && tableWithFixedColumnWidthsOption && getNode().attrs.displayMode !== 'fixed') {
|
|
373
395
|
this.handleColgroupUpdates(true);
|
|
374
396
|
}
|
|
397
|
+
if (this.wrapper && fg('platform_editor_nested_table_in_nested_parent_fix')) {
|
|
398
|
+
this.wrapperReisizeObserver = new ResizeObserver(function (entries) {
|
|
399
|
+
var _iterator2 = _createForOfIteratorHelper(entries),
|
|
400
|
+
_step2;
|
|
401
|
+
try {
|
|
402
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
403
|
+
var entry = _step2.value;
|
|
404
|
+
_this2.wrapperWidth = entry.contentRect.width;
|
|
405
|
+
}
|
|
406
|
+
} catch (err) {
|
|
407
|
+
_iterator2.e(err);
|
|
408
|
+
} finally {
|
|
409
|
+
_iterator2.f();
|
|
410
|
+
}
|
|
411
|
+
});
|
|
412
|
+
this.wrapperReisizeObserver.observe(this.wrapper);
|
|
413
|
+
}
|
|
375
414
|
if (allowColumnResizing && this.wrapper && !isIE11) {
|
|
376
415
|
this.wrapper.addEventListener('scroll', this.handleScrollDebounced, {
|
|
377
416
|
passive: true
|
|
@@ -409,7 +448,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
409
448
|
}, {
|
|
410
449
|
key: "componentWillUnmount",
|
|
411
450
|
value: function componentWillUnmount() {
|
|
412
|
-
var _this$resizeObserver, _this$table4, _this$table5, _this$table6;
|
|
451
|
+
var _this$resizeObserver, _this$wrapperReisizeO, _this$table4, _this$table5, _this$table6;
|
|
413
452
|
var _this$props8 = this.props,
|
|
414
453
|
allowColumnResizing = _this$props8.allowColumnResizing,
|
|
415
454
|
eventDispatcher = _this$props8.eventDispatcher,
|
|
@@ -422,6 +461,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
422
461
|
this.dragAndDropCleanupFn();
|
|
423
462
|
}
|
|
424
463
|
(_this$resizeObserver = this.resizeObserver) === null || _this$resizeObserver === void 0 || _this$resizeObserver.disconnect();
|
|
464
|
+
(_this$wrapperReisizeO = this.wrapperReisizeObserver) === null || _this$wrapperReisizeO === void 0 || _this$wrapperReisizeO.disconnect();
|
|
425
465
|
if (this.stickyScrollbar) {
|
|
426
466
|
this.stickyScrollbar.dispose();
|
|
427
467
|
}
|
|
@@ -474,7 +514,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
474
514
|
}, {
|
|
475
515
|
key: "handleColgroupUpdates",
|
|
476
516
|
value: function handleColgroupUpdates() {
|
|
477
|
-
var
|
|
517
|
+
var _this3 = this;
|
|
478
518
|
var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
479
519
|
var _this$props10 = this.props,
|
|
480
520
|
getNode = _this$props10.getNode,
|
|
@@ -548,18 +588,18 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
548
588
|
}
|
|
549
589
|
var scalePercent = 1;
|
|
550
590
|
requestAnimationFrame(function () {
|
|
551
|
-
var
|
|
591
|
+
var _this3$props$options, _this3$props$options2;
|
|
552
592
|
// Scaling percent has to be calculated inside requestAnimationFrame, otherwise
|
|
553
593
|
// renderWidth calculated as `tableRef?.parentElement?.clientWidth`
|
|
554
594
|
// inside of getTableScalingPercent returns 0.
|
|
555
|
-
if (!((
|
|
556
|
-
scalePercent = getTableScalingPercent(tableNode,
|
|
595
|
+
if (!((_this3$props$options = _this3.props.options) !== null && _this3$props$options !== void 0 && _this3$props$options.isCommentEditor) || (_this3$props$options2 = _this3.props.options) !== null && _this3$props$options2 !== void 0 && _this3$props$options2.isCommentEditor && tableNode.attrs.width) {
|
|
596
|
+
scalePercent = getTableScalingPercent(tableNode, _this3.table, shouldUseIncreasedScalingPercent);
|
|
557
597
|
} else {
|
|
558
|
-
scalePercent = getScalingPercentForTableWithoutWidth(tableNode,
|
|
598
|
+
scalePercent = getScalingPercentForTableWithoutWidth(tableNode, _this3.table);
|
|
559
599
|
}
|
|
560
600
|
|
|
561
601
|
// Request animation frame required for Firefox
|
|
562
|
-
updateColgroup(resizeState,
|
|
602
|
+
updateColgroup(resizeState, _this3.table, tableNode, shouldScaleOnColgroupUpdate, scalePercent);
|
|
563
603
|
});
|
|
564
604
|
}
|
|
565
605
|
}
|
|
@@ -573,7 +613,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
573
613
|
var _this$props$options8,
|
|
574
614
|
_this$props$options9,
|
|
575
615
|
_this$wrapper,
|
|
576
|
-
|
|
616
|
+
_this4 = this;
|
|
577
617
|
var _this$props11 = this.props,
|
|
578
618
|
view = _this$props11.view,
|
|
579
619
|
getNode = _this$props11.getNode,
|
|
@@ -620,7 +660,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
620
660
|
// that happens when a table is nested in expand and expand's width is
|
|
621
661
|
// changed via breakout button
|
|
622
662
|
window.requestAnimationFrame(function () {
|
|
623
|
-
|
|
663
|
+
_this4.overflowShadowsObserver = new OverflowShadowsObserver(_this4.updateShadowState, _this4.table, _this4.wrapper);
|
|
624
664
|
});
|
|
625
665
|
} else {
|
|
626
666
|
this.overflowShadowsObserver = new OverflowShadowsObserver(this.updateShadowState, this.table, this.wrapper);
|
|
@@ -697,7 +737,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
697
737
|
}, {
|
|
698
738
|
key: "render",
|
|
699
739
|
value: function render() {
|
|
700
|
-
var
|
|
740
|
+
var _this5 = this,
|
|
701
741
|
_this$state$stickyHea2,
|
|
702
742
|
_this$state$stickyHea3,
|
|
703
743
|
_this$props$options10,
|
|
@@ -788,8 +828,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
788
828
|
tableContainerWidth: tableContainerWidth,
|
|
789
829
|
isNumberColumnEnabled: node.attrs.isNumberColumnEnabled,
|
|
790
830
|
getScrollOffset: function getScrollOffset() {
|
|
791
|
-
var
|
|
792
|
-
return ((
|
|
831
|
+
var _this5$wrapper;
|
|
832
|
+
return ((_this5$wrapper = _this5.wrapper) === null || _this5$wrapper === void 0 ? void 0 : _this5$wrapper.scrollLeft) || 0;
|
|
793
833
|
},
|
|
794
834
|
tableWrapperHeight: this.state.tableWrapperHeight,
|
|
795
835
|
api: pluginInjectionApi,
|
|
@@ -854,12 +894,12 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
854
894
|
editorView: view,
|
|
855
895
|
node: node,
|
|
856
896
|
getScrollOffset: function getScrollOffset() {
|
|
857
|
-
var
|
|
858
|
-
return ((
|
|
897
|
+
var _this5$wrapper2;
|
|
898
|
+
return ((_this5$wrapper2 = _this5.wrapper) === null || _this5$wrapper2 === void 0 ? void 0 : _this5$wrapper2.scrollLeft) || 0;
|
|
859
899
|
},
|
|
860
900
|
getTableWrapperWidth: function getTableWrapperWidth() {
|
|
861
|
-
var
|
|
862
|
-
return ((
|
|
901
|
+
var _this5$wrapper3;
|
|
902
|
+
return ((_this5$wrapper3 = _this5.wrapper) === null || _this5$wrapper3 === void 0 ? void 0 : _this5$wrapper3.clientWidth) || 760;
|
|
863
903
|
}
|
|
864
904
|
}), /*#__PURE__*/React.createElement("div", {
|
|
865
905
|
contentEditable: false
|
|
@@ -881,14 +921,14 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
881
921
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
882
922
|
className: classnames(ClassName.TABLE_NODE_WRAPPER),
|
|
883
923
|
ref: function ref(elem) {
|
|
884
|
-
|
|
924
|
+
_this5.wrapper = elem;
|
|
885
925
|
if (elem) {
|
|
886
|
-
|
|
926
|
+
_this5.props.contentDOM(elem);
|
|
887
927
|
var tableElement = elem.querySelector('table');
|
|
888
|
-
if (tableElement !==
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
928
|
+
if (tableElement !== _this5.table) {
|
|
929
|
+
_this5.table = tableElement;
|
|
930
|
+
_this5.createShadowSentinels(_this5.table);
|
|
931
|
+
_this5.observeTable(_this5.table);
|
|
892
932
|
}
|
|
893
933
|
}
|
|
894
934
|
}
|
package/dist/esm/plugin.js
CHANGED
|
@@ -2,7 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
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; }
|
|
3
3
|
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) { _defineProperty(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; }
|
|
4
4
|
import React from 'react';
|
|
5
|
-
import { tableCell, tableHeader, tableRow } from '@atlaskit/adf-schema';
|
|
5
|
+
import { tableCell, tableCellWithNestedTable, tableHeader, tableHeaderWithNestedTable, tableRow, tableRowWithNestedTable } from '@atlaskit/adf-schema';
|
|
6
6
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
|
|
7
7
|
import { browser } from '@atlaskit/editor-common/browser';
|
|
8
8
|
import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
|
|
@@ -13,6 +13,7 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
|
13
13
|
import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
|
|
14
14
|
import { akEditorFloatingPanelZIndex } from '@atlaskit/editor-shared-styles';
|
|
15
15
|
import { tableEditing } from '@atlaskit/editor-tables/pm-plugins';
|
|
16
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
16
17
|
import { insertTableWithSize } from './commands/insert';
|
|
17
18
|
import { pluginConfig } from './create-plugin-config';
|
|
18
19
|
import { createPlugin as createTableAnalyticsPlugin } from './pm-plugins/analytics/plugin';
|
|
@@ -136,12 +137,31 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
136
137
|
nodes: function nodes() {
|
|
137
138
|
var _pluginConfig = pluginConfig(options === null || options === void 0 ? void 0 : options.tableOptions),
|
|
138
139
|
allowColumnResizing = _pluginConfig.allowColumnResizing;
|
|
139
|
-
|
|
140
|
+
var isNestingSupported = fg('platform_editor_use_nested_table_pm_nodes');
|
|
141
|
+
return isNestingSupported ? [{
|
|
140
142
|
name: 'table',
|
|
141
143
|
node: tableNodeSpecWithFixedToDOM({
|
|
142
144
|
allowColumnResizing: Boolean(allowColumnResizing),
|
|
143
145
|
tableResizingEnabled: Boolean(options === null || options === void 0 ? void 0 : options.tableResizingEnabled),
|
|
144
|
-
getEditorContainerWidth: defaultGetEditorContainerWidth
|
|
146
|
+
getEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
147
|
+
isNestingSupported: isNestingSupported
|
|
148
|
+
})
|
|
149
|
+
}, {
|
|
150
|
+
name: 'tableHeader',
|
|
151
|
+
node: tableHeaderWithNestedTable
|
|
152
|
+
}, {
|
|
153
|
+
name: 'tableRow',
|
|
154
|
+
node: tableRowWithNestedTable
|
|
155
|
+
}, {
|
|
156
|
+
name: 'tableCell',
|
|
157
|
+
node: tableCellWithNestedTable
|
|
158
|
+
}] : [{
|
|
159
|
+
name: 'table',
|
|
160
|
+
node: tableNodeSpecWithFixedToDOM({
|
|
161
|
+
allowColumnResizing: Boolean(allowColumnResizing),
|
|
162
|
+
tableResizingEnabled: Boolean(options === null || options === void 0 ? void 0 : options.tableResizingEnabled),
|
|
163
|
+
getEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
164
|
+
isNestingSupported: isNestingSupported
|
|
145
165
|
})
|
|
146
166
|
}, {
|
|
147
167
|
name: 'tableHeader',
|
package/dist/esm/toDOM.js
CHANGED
|
@@ -4,7 +4,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
4
4
|
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; }
|
|
5
5
|
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) { _defineProperty(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; }
|
|
6
6
|
import kebabCase from 'lodash/kebabCase';
|
|
7
|
-
import { table } from '@atlaskit/adf-schema';
|
|
7
|
+
import { table, tableWithNestedTable } from '@atlaskit/adf-schema';
|
|
8
8
|
import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
|
|
9
9
|
import { akEditorGutterPaddingDynamic } from '@atlaskit/editor-shared-styles';
|
|
10
10
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
@@ -13,10 +13,11 @@ import { getAlignmentStyle } from './nodeviews/table-container-styles';
|
|
|
13
13
|
import { generateColgroup, getResizerMinWidth } from './pm-plugins/table-resizing/utils/colgroup';
|
|
14
14
|
import { TABLE_MAX_WIDTH } from './pm-plugins/table-resizing/utils/consts';
|
|
15
15
|
export var tableNodeSpecWithFixedToDOM = function tableNodeSpecWithFixedToDOM(config) {
|
|
16
|
+
var tableNode = config.isNestingSupported ? tableWithNestedTable : table;
|
|
16
17
|
if (editorExperiment('platform_editor_exp_lazy_node_views', false)) {
|
|
17
|
-
return
|
|
18
|
+
return tableNode;
|
|
18
19
|
}
|
|
19
|
-
return _objectSpread(_objectSpread({},
|
|
20
|
+
return _objectSpread(_objectSpread({}, tableNode), {}, {
|
|
20
21
|
toDOM: function toDOM(node) {
|
|
21
22
|
var gutterPadding = akEditorGutterPaddingDynamic() * 2;
|
|
22
23
|
var editorWidthFromGetter = fg('platform_editor_breakout_use_css') ? undefined : Math.min(config.getEditorContainerWidth().width - gutterPadding, node.attrs.width);
|
package/dist/esm/utils/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { getSelectedColumnIndexes, getSelectedRowIndexes } from './selection';
|
|
2
2
|
export { findControlsHoverDecoration, createControlsHoverDecoration, createCellHoverDecoration, updateDecorations, createColumnInsertLine, createColumnLineResize, createRowInsertLine } from './decoration';
|
|
3
|
-
export { containsHeaderColumn, containsHeaderRow, checkIfHeaderColumnEnabled, checkIfHeaderRowEnabled, checkIfNumberColumnEnabled, getTableWidth, tablesHaveDifferentColumnWidths, tablesHaveDifferentNoOfColumns, tablesHaveDifferentNoOfRows, isTableNested } from './nodes';
|
|
3
|
+
export { containsHeaderColumn, containsHeaderRow, checkIfHeaderColumnEnabled, checkIfHeaderRowEnabled, checkIfNumberColumnEnabled, getTableWidth, tablesHaveDifferentColumnWidths, tablesHaveDifferentNoOfColumns, tablesHaveDifferentNoOfRows, isTableNested, isTableNestedInMoreThanOneNode } from './nodes';
|
|
4
4
|
export { transformSliceToRemoveOpenTable, transformSliceToCorrectEmptyTableCells, transformSliceToFixHardBreakProblemOnCopyFromCell } from './paste';
|
|
5
5
|
export { isCell, isCornerButton, isInsertRowButton, isColumnControlsDecorations, isTableControlsButton, isTableContainerOrWrapper, isRowControlsButton, isDragColumnFloatingInsertDot, isDragRowFloatingInsertDot, isDragCornerButton, getColumnOrRowIndex, getMousePositionHorizontalRelativeByElement, getMousePositionVerticalRelativeByElement, isResizeHandleDecoration, hasResizeHandler, findNearestCellIndexToPoint } from './dom';
|
|
6
6
|
export { convertHTMLCellIndexToColumnIndex, getColumnsWidths, getColumnDeleteButtonParams, getColumnIndexMappedToColumnIndexInFirstRow } from './column-controls';
|
package/dist/esm/utils/nodes.js
CHANGED
|
@@ -99,6 +99,10 @@ export var isTableNested = function isTableNested(state) {
|
|
|
99
99
|
var nodeTypes = state.schema.nodes;
|
|
100
100
|
return parent.type === nodeTypes.layoutColumn || parent.type === nodeTypes.expand || parent.type === nodeTypes.bodiedExtension || parent.type === nodeTypes.extensionFrame;
|
|
101
101
|
};
|
|
102
|
+
export var isTableNestedInMoreThanOneNode = function isTableNestedInMoreThanOneNode(state) {
|
|
103
|
+
var tablePos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
104
|
+
return state.doc.resolve(tablePos).depth > 2;
|
|
105
|
+
};
|
|
102
106
|
var anyChildCellMergedAcrossRow = function anyChildCellMergedAcrossRow(node) {
|
|
103
107
|
return mapChildren(node, function (child) {
|
|
104
108
|
return child.attrs.rowspan || 0;
|
package/dist/types/toDOM.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { table } from '@atlaskit/adf-schema';
|
|
2
1
|
import type { GetEditorContainerWidth } from '@atlaskit/editor-common/src/types';
|
|
2
|
+
import type { NodeSpec } from '@atlaskit/editor-prosemirror/model';
|
|
3
3
|
type Config = {
|
|
4
4
|
allowColumnResizing: boolean;
|
|
5
5
|
tableResizingEnabled: boolean;
|
|
6
6
|
getEditorContainerWidth: GetEditorContainerWidth;
|
|
7
|
+
isNestingSupported?: boolean;
|
|
7
8
|
};
|
|
8
|
-
export declare const tableNodeSpecWithFixedToDOM: (config: Config) =>
|
|
9
|
+
export declare const tableNodeSpecWithFixedToDOM: (config: Config) => NodeSpec;
|
|
9
10
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { getSelectedColumnIndexes, getSelectedRowIndexes } from './selection';
|
|
2
2
|
export { findControlsHoverDecoration, createControlsHoverDecoration, createCellHoverDecoration, updateDecorations, createColumnInsertLine, createColumnLineResize, createRowInsertLine, } from './decoration';
|
|
3
|
-
export { containsHeaderColumn, containsHeaderRow, checkIfHeaderColumnEnabled, checkIfHeaderRowEnabled, checkIfNumberColumnEnabled, getTableWidth, tablesHaveDifferentColumnWidths, tablesHaveDifferentNoOfColumns, tablesHaveDifferentNoOfRows, isTableNested, } from './nodes';
|
|
3
|
+
export { containsHeaderColumn, containsHeaderRow, checkIfHeaderColumnEnabled, checkIfHeaderRowEnabled, checkIfNumberColumnEnabled, getTableWidth, tablesHaveDifferentColumnWidths, tablesHaveDifferentNoOfColumns, tablesHaveDifferentNoOfRows, isTableNested, isTableNestedInMoreThanOneNode, } from './nodes';
|
|
4
4
|
export { transformSliceToRemoveOpenTable, transformSliceToCorrectEmptyTableCells, transformSliceToFixHardBreakProblemOnCopyFromCell, } from './paste';
|
|
5
5
|
export { isCell, isCornerButton, isInsertRowButton, isColumnControlsDecorations, isTableControlsButton, isTableContainerOrWrapper, isRowControlsButton, isDragColumnFloatingInsertDot, isDragRowFloatingInsertDot, isDragCornerButton, getColumnOrRowIndex, getMousePositionHorizontalRelativeByElement, getMousePositionVerticalRelativeByElement, isResizeHandleDecoration, hasResizeHandler, findNearestCellIndexToPoint, } from './dom';
|
|
6
6
|
export { convertHTMLCellIndexToColumnIndex, getColumnsWidths, getColumnDeleteButtonParams, getColumnIndexMappedToColumnIndexInFirstRow, } from './column-controls';
|
|
@@ -11,6 +11,7 @@ export declare const tablesHaveDifferentColumnWidths: (currentTable: PmNode, pre
|
|
|
11
11
|
export declare const tablesHaveDifferentNoOfColumns: (currentTable: PmNode, previousTable: PmNode) => boolean;
|
|
12
12
|
export declare const tablesHaveDifferentNoOfRows: (currentTable: PmNode, previousTable: PmNode) => boolean;
|
|
13
13
|
export declare const isTableNested: (state: EditorState, tablePos?: number) => boolean;
|
|
14
|
+
export declare const isTableNestedInMoreThanOneNode: (state: EditorState, tablePos?: number) => boolean;
|
|
14
15
|
/**
|
|
15
16
|
* Check if a given node is a header row with this definition:
|
|
16
17
|
* - all children are tableHeader cells
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { table } from '@atlaskit/adf-schema';
|
|
2
1
|
import type { GetEditorContainerWidth } from '@atlaskit/editor-common/src/types';
|
|
2
|
+
import type { NodeSpec } from '@atlaskit/editor-prosemirror/model';
|
|
3
3
|
type Config = {
|
|
4
4
|
allowColumnResizing: boolean;
|
|
5
5
|
tableResizingEnabled: boolean;
|
|
6
6
|
getEditorContainerWidth: GetEditorContainerWidth;
|
|
7
|
+
isNestingSupported?: boolean;
|
|
7
8
|
};
|
|
8
|
-
export declare const tableNodeSpecWithFixedToDOM: (config: Config) =>
|
|
9
|
+
export declare const tableNodeSpecWithFixedToDOM: (config: Config) => NodeSpec;
|
|
9
10
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { getSelectedColumnIndexes, getSelectedRowIndexes } from './selection';
|
|
2
2
|
export { findControlsHoverDecoration, createControlsHoverDecoration, createCellHoverDecoration, updateDecorations, createColumnInsertLine, createColumnLineResize, createRowInsertLine, } from './decoration';
|
|
3
|
-
export { containsHeaderColumn, containsHeaderRow, checkIfHeaderColumnEnabled, checkIfHeaderRowEnabled, checkIfNumberColumnEnabled, getTableWidth, tablesHaveDifferentColumnWidths, tablesHaveDifferentNoOfColumns, tablesHaveDifferentNoOfRows, isTableNested, } from './nodes';
|
|
3
|
+
export { containsHeaderColumn, containsHeaderRow, checkIfHeaderColumnEnabled, checkIfHeaderRowEnabled, checkIfNumberColumnEnabled, getTableWidth, tablesHaveDifferentColumnWidths, tablesHaveDifferentNoOfColumns, tablesHaveDifferentNoOfRows, isTableNested, isTableNestedInMoreThanOneNode, } from './nodes';
|
|
4
4
|
export { transformSliceToRemoveOpenTable, transformSliceToCorrectEmptyTableCells, transformSliceToFixHardBreakProblemOnCopyFromCell, } from './paste';
|
|
5
5
|
export { isCell, isCornerButton, isInsertRowButton, isColumnControlsDecorations, isTableControlsButton, isTableContainerOrWrapper, isRowControlsButton, isDragColumnFloatingInsertDot, isDragRowFloatingInsertDot, isDragCornerButton, getColumnOrRowIndex, getMousePositionHorizontalRelativeByElement, getMousePositionVerticalRelativeByElement, isResizeHandleDecoration, hasResizeHandler, findNearestCellIndexToPoint, } from './dom';
|
|
6
6
|
export { convertHTMLCellIndexToColumnIndex, getColumnsWidths, getColumnDeleteButtonParams, getColumnIndexMappedToColumnIndexInFirstRow, } from './column-controls';
|
|
@@ -11,6 +11,7 @@ export declare const tablesHaveDifferentColumnWidths: (currentTable: PmNode, pre
|
|
|
11
11
|
export declare const tablesHaveDifferentNoOfColumns: (currentTable: PmNode, previousTable: PmNode) => boolean;
|
|
12
12
|
export declare const tablesHaveDifferentNoOfRows: (currentTable: PmNode, previousTable: PmNode) => boolean;
|
|
13
13
|
export declare const isTableNested: (state: EditorState, tablePos?: number) => boolean;
|
|
14
|
+
export declare const isTableNestedInMoreThanOneNode: (state: EditorState, tablePos?: number) => boolean;
|
|
14
15
|
/**
|
|
15
16
|
* Check if a given node is a header row with this definition:
|
|
16
17
|
* - all children are tableHeader cells
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.30.0",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -27,14 +27,14 @@
|
|
|
27
27
|
"runReact18": true
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@atlaskit/adf-schema": "^
|
|
30
|
+
"@atlaskit/adf-schema": "^44.2.0",
|
|
31
31
|
"@atlaskit/button": "^20.3.0",
|
|
32
32
|
"@atlaskit/custom-steps": "^0.8.0",
|
|
33
|
-
"@atlaskit/editor-common": "^94.
|
|
33
|
+
"@atlaskit/editor-common": "^94.10.0",
|
|
34
34
|
"@atlaskit/editor-palette": "1.6.3",
|
|
35
35
|
"@atlaskit/editor-plugin-accessibility-utils": "^1.2.0",
|
|
36
36
|
"@atlaskit/editor-plugin-analytics": "^1.10.0",
|
|
37
|
-
"@atlaskit/editor-plugin-batch-attribute-updates": "1.1.
|
|
37
|
+
"@atlaskit/editor-plugin-batch-attribute-updates": "1.1.4",
|
|
38
38
|
"@atlaskit/editor-plugin-content-insertion": "^1.9.0",
|
|
39
39
|
"@atlaskit/editor-plugin-editor-viewmode": "^2.1.0",
|
|
40
40
|
"@atlaskit/editor-plugin-guideline": "^1.2.0",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.0.0",
|
|
52
52
|
"@atlaskit/primitives": "^13.0.0",
|
|
53
53
|
"@atlaskit/theme": "^14.0.0",
|
|
54
|
-
"@atlaskit/tmp-editor-statsig": "^2.
|
|
54
|
+
"@atlaskit/tmp-editor-statsig": "^2.11.0",
|
|
55
55
|
"@atlaskit/toggle": "^13.4.0",
|
|
56
56
|
"@atlaskit/tokens": "^2.0.0",
|
|
57
57
|
"@atlaskit/tooltip": "^18.8.0",
|
|
@@ -112,8 +112,14 @@
|
|
|
112
112
|
"platform_editor_breakout_use_css": {
|
|
113
113
|
"type": "boolean"
|
|
114
114
|
},
|
|
115
|
+
"platform_editor_nested_table_in_nested_parent_fix": {
|
|
116
|
+
"type": "boolean"
|
|
117
|
+
},
|
|
115
118
|
"platform-visual-refresh-icons": {
|
|
116
119
|
"type": "boolean"
|
|
120
|
+
},
|
|
121
|
+
"platform_editor_use_nested_table_pm_nodes": {
|
|
122
|
+
"type": "boolean"
|
|
117
123
|
}
|
|
118
124
|
}
|
|
119
125
|
}
|
|
@@ -70,6 +70,7 @@ import {
|
|
|
70
70
|
containsHeaderRow,
|
|
71
71
|
getAssistiveMessage,
|
|
72
72
|
isTableNested,
|
|
73
|
+
isTableNestedInMoreThanOneNode,
|
|
73
74
|
tablesHaveDifferentColumnWidths,
|
|
74
75
|
tablesHaveDifferentNoOfColumns,
|
|
75
76
|
tablesHaveDifferentNoOfRows,
|
|
@@ -93,6 +94,10 @@ const initialOverflowCaptureTimeroutDelay = 300;
|
|
|
93
94
|
// PLEASE NOTE: that the current way this alaytics has been configured WILL cause reflows to occur. This is why the has been disabled.
|
|
94
95
|
const isOverflowAnalyticsEnabled = false;
|
|
95
96
|
|
|
97
|
+
// Prevent unnecessary parentWidth updates when table is nested inside of a node that is nested itself.
|
|
98
|
+
const NESTED_TABLE_IN_NESTED_PARENT_WIDTH_DIFF_MIN_THRESHOLD = 2;
|
|
99
|
+
const NESTED_TABLE_IN_NESTED_PARENT_WIDTH_DIFF_MAX_THRESHOLD = 20;
|
|
100
|
+
|
|
96
101
|
interface ComponentProps {
|
|
97
102
|
view: EditorView;
|
|
98
103
|
getNode: () => PmNode;
|
|
@@ -162,6 +167,9 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
162
167
|
private initialOverflowCaptureTimerId?: ReturnType<typeof setTimeout>;
|
|
163
168
|
private resizeObserver?: ResizeObserver;
|
|
164
169
|
|
|
170
|
+
private wrapperWidth?: number;
|
|
171
|
+
private wrapperReisizeObserver?: ResizeObserver;
|
|
172
|
+
|
|
165
173
|
private dragAndDropCleanupFn?: CleanupFn;
|
|
166
174
|
|
|
167
175
|
constructor(props: ComponentProps) {
|
|
@@ -248,6 +256,16 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
248
256
|
this.handleColgroupUpdates(true);
|
|
249
257
|
}
|
|
250
258
|
|
|
259
|
+
if (this.wrapper && fg('platform_editor_nested_table_in_nested_parent_fix')) {
|
|
260
|
+
this.wrapperReisizeObserver = new ResizeObserver((entries) => {
|
|
261
|
+
for (const entry of entries) {
|
|
262
|
+
this.wrapperWidth = entry.contentRect.width;
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
this.wrapperReisizeObserver.observe(this.wrapper);
|
|
267
|
+
}
|
|
268
|
+
|
|
251
269
|
if (allowColumnResizing && this.wrapper && !isIE11) {
|
|
252
270
|
this.wrapper.addEventListener('scroll', this.handleScrollDebounced, {
|
|
253
271
|
passive: true,
|
|
@@ -305,6 +323,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
305
323
|
}
|
|
306
324
|
|
|
307
325
|
this.resizeObserver?.disconnect();
|
|
326
|
+
this.wrapperReisizeObserver?.disconnect();
|
|
308
327
|
|
|
309
328
|
if (this.stickyScrollbar) {
|
|
310
329
|
this.stickyScrollbar.dispose();
|
|
@@ -1025,7 +1044,37 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
1025
1044
|
|
|
1026
1045
|
const isNested = isTableNested(this.props.view.state, this.props.getPos());
|
|
1027
1046
|
|
|
1028
|
-
|
|
1047
|
+
let parentWidth = this.getParentNodeWidth();
|
|
1048
|
+
|
|
1049
|
+
if (
|
|
1050
|
+
isNested &&
|
|
1051
|
+
isTableNestedInMoreThanOneNode(this.props.view.state, this.props.getPos()) &&
|
|
1052
|
+
fg('platform_editor_nested_table_in_nested_parent_fix')
|
|
1053
|
+
) {
|
|
1054
|
+
const resizeObsWrapperWidth = this.wrapperWidth || 0;
|
|
1055
|
+
|
|
1056
|
+
const wrapperWidthDiffBetweenRerenders = Math.abs(
|
|
1057
|
+
resizeObsWrapperWidth - (this.state.parentWidth || 0),
|
|
1058
|
+
);
|
|
1059
|
+
const isOusideOfThreshold =
|
|
1060
|
+
wrapperWidthDiffBetweenRerenders <=
|
|
1061
|
+
NESTED_TABLE_IN_NESTED_PARENT_WIDTH_DIFF_MIN_THRESHOLD ||
|
|
1062
|
+
wrapperWidthDiffBetweenRerenders > NESTED_TABLE_IN_NESTED_PARENT_WIDTH_DIFF_MAX_THRESHOLD;
|
|
1063
|
+
// 1. Check isOusideOfThreshold is added to prevent undersired state update.
|
|
1064
|
+
// When table is nested in the extenstion and the table column is being resized,
|
|
1065
|
+
// space available within extension can change and cause undesirable state update.
|
|
1066
|
+
// MIN_THRESNESTED_TABLE_IN_NESTED_PARENT_WIDTH_DIFF_MIN_THRESHOLDHOLD value is required
|
|
1067
|
+
// as the resizeObsWrapperWidth can differ between page reloads by 2px.
|
|
1068
|
+
|
|
1069
|
+
// 2. Check resizeObsWrapperWidth > 1 is added to prevent parentWidth update when table unmounts.
|
|
1070
|
+
// When a is nested table in a nested expand and the expand collabses, the table unmounts and
|
|
1071
|
+
// resizeObsWrapperWidth becomes 1.
|
|
1072
|
+
parentWidth =
|
|
1073
|
+
isOusideOfThreshold && resizeObsWrapperWidth > 1
|
|
1074
|
+
? resizeObsWrapperWidth
|
|
1075
|
+
: this.state.parentWidth;
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1029
1078
|
const parentWidthChanged = parentWidth && parentWidth !== this.state.parentWidth;
|
|
1030
1079
|
|
|
1031
1080
|
const layoutSize = this.tableNodeLayoutSize(node, containerWidth.width, options);
|
package/src/plugin.tsx
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
tableCell,
|
|
5
|
+
tableCellWithNestedTable,
|
|
6
|
+
tableHeader,
|
|
7
|
+
tableHeaderWithNestedTable,
|
|
8
|
+
tableRow,
|
|
9
|
+
tableRowWithNestedTable,
|
|
10
|
+
} from '@atlaskit/adf-schema';
|
|
4
11
|
import type { AnalyticsEventPayload } from '@atlaskit/editor-common/analytics';
|
|
5
12
|
import {
|
|
6
13
|
ACTION,
|
|
@@ -39,6 +46,7 @@ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
|
39
46
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
40
47
|
import { akEditorFloatingPanelZIndex } from '@atlaskit/editor-shared-styles';
|
|
41
48
|
import { tableEditing } from '@atlaskit/editor-tables/pm-plugins';
|
|
49
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
42
50
|
|
|
43
51
|
import { insertTableWithSize } from './commands/insert';
|
|
44
52
|
import { pluginConfig } from './create-plugin-config';
|
|
@@ -258,20 +266,37 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
258
266
|
|
|
259
267
|
nodes() {
|
|
260
268
|
const { allowColumnResizing } = pluginConfig(options?.tableOptions);
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
269
|
+
const isNestingSupported = fg('platform_editor_use_nested_table_pm_nodes');
|
|
270
|
+
|
|
271
|
+
return isNestingSupported
|
|
272
|
+
? [
|
|
273
|
+
{
|
|
274
|
+
name: 'table',
|
|
275
|
+
node: tableNodeSpecWithFixedToDOM({
|
|
276
|
+
allowColumnResizing: Boolean(allowColumnResizing),
|
|
277
|
+
tableResizingEnabled: Boolean(options?.tableResizingEnabled),
|
|
278
|
+
getEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
279
|
+
isNestingSupported,
|
|
280
|
+
}),
|
|
281
|
+
},
|
|
282
|
+
{ name: 'tableHeader', node: tableHeaderWithNestedTable },
|
|
283
|
+
{ name: 'tableRow', node: tableRowWithNestedTable },
|
|
284
|
+
{ name: 'tableCell', node: tableCellWithNestedTable },
|
|
285
|
+
]
|
|
286
|
+
: [
|
|
287
|
+
{
|
|
288
|
+
name: 'table',
|
|
289
|
+
node: tableNodeSpecWithFixedToDOM({
|
|
290
|
+
allowColumnResizing: Boolean(allowColumnResizing),
|
|
291
|
+
tableResizingEnabled: Boolean(options?.tableResizingEnabled),
|
|
292
|
+
getEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
293
|
+
isNestingSupported,
|
|
294
|
+
}),
|
|
295
|
+
},
|
|
296
|
+
{ name: 'tableHeader', node: tableHeader },
|
|
297
|
+
{ name: 'tableRow', node: tableRow },
|
|
298
|
+
{ name: 'tableCell', node: tableCell },
|
|
299
|
+
];
|
|
275
300
|
},
|
|
276
301
|
|
|
277
302
|
pmPlugins() {
|
package/src/toDOM.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import kebabCase from 'lodash/kebabCase';
|
|
2
2
|
|
|
3
|
-
import { table } from '@atlaskit/adf-schema';
|
|
3
|
+
import { table, tableWithNestedTable } from '@atlaskit/adf-schema';
|
|
4
4
|
import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
|
|
5
5
|
import type { GetEditorContainerWidth } from '@atlaskit/editor-common/src/types';
|
|
6
|
-
import type { DOMOutputSpec, Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
6
|
+
import type { DOMOutputSpec, NodeSpec, Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
7
7
|
import { akEditorGutterPaddingDynamic } from '@atlaskit/editor-shared-styles';
|
|
8
8
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
9
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
@@ -16,14 +16,17 @@ type Config = {
|
|
|
16
16
|
allowColumnResizing: boolean;
|
|
17
17
|
tableResizingEnabled: boolean;
|
|
18
18
|
getEditorContainerWidth: GetEditorContainerWidth;
|
|
19
|
+
isNestingSupported?: boolean;
|
|
19
20
|
};
|
|
20
|
-
export const tableNodeSpecWithFixedToDOM = (config: Config):
|
|
21
|
+
export const tableNodeSpecWithFixedToDOM = (config: Config): NodeSpec => {
|
|
22
|
+
const tableNode = config.isNestingSupported ? tableWithNestedTable : table;
|
|
23
|
+
|
|
21
24
|
if (editorExperiment('platform_editor_exp_lazy_node_views', false)) {
|
|
22
|
-
return
|
|
25
|
+
return tableNode;
|
|
23
26
|
}
|
|
24
27
|
|
|
25
28
|
return {
|
|
26
|
-
...
|
|
29
|
+
...tableNode,
|
|
27
30
|
toDOM: (node: PMNode): DOMOutputSpec => {
|
|
28
31
|
const gutterPadding = akEditorGutterPaddingDynamic() * 2;
|
|
29
32
|
const editorWidthFromGetter = fg('platform_editor_breakout_use_css')
|
package/src/utils/index.ts
CHANGED
package/src/utils/nodes.ts
CHANGED
|
@@ -136,6 +136,10 @@ export const isTableNested = (state: EditorState, tablePos = 0): boolean => {
|
|
|
136
136
|
);
|
|
137
137
|
};
|
|
138
138
|
|
|
139
|
+
export const isTableNestedInMoreThanOneNode = (state: EditorState, tablePos = 0) => {
|
|
140
|
+
return state.doc.resolve(tablePos).depth > 2;
|
|
141
|
+
};
|
|
142
|
+
|
|
139
143
|
const anyChildCellMergedAcrossRow = (node: PmNode): boolean =>
|
|
140
144
|
mapChildren(node, (child) => child.attrs.rowspan || 0).some((rowspan) => rowspan > 1);
|
|
141
145
|
|