@atlaskit/editor-plugin-table 8.4.4 → 8.4.6
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/nodeviews/TableComponent.js +16 -6
- package/dist/cjs/nodeviews/table.js +7 -2
- package/dist/es2019/nodeviews/TableComponent.js +17 -7
- package/dist/es2019/nodeviews/table.js +7 -2
- package/dist/esm/nodeviews/TableComponent.js +16 -6
- package/dist/esm/nodeviews/table.js +7 -2
- package/package.json +8 -5
- package/src/nodeviews/TableComponent.tsx +24 -4
- package/src/nodeviews/table.tsx +11 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 8.4.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#176217](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/176217)
|
|
8
|
+
[`38f5a9c8db167`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/38f5a9c8db167) -
|
|
9
|
+
ED-25953 Fix table overflow when page changes from full page to full width
|
|
10
|
+
|
|
11
|
+
## 8.4.5
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
|
|
3
17
|
## 8.4.4
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -334,6 +334,9 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
334
334
|
_this.node = _getNode();
|
|
335
335
|
_this.containerWidth = _containerWidth;
|
|
336
336
|
_this.isInitialOverflowSent = false;
|
|
337
|
+
if (!_this.updateColGroupFromFullWidthChange) {
|
|
338
|
+
_this.updateColGroupFromFullWidthChange = (_options === null || _options === void 0 ? void 0 : _options.isFullWidthModeEnabled) && !(_options !== null && _options !== void 0 && _options.wasFullWidthModeEnabled);
|
|
339
|
+
}
|
|
337
340
|
|
|
338
341
|
// store table size using previous full-width mode so can detect if it has changed.
|
|
339
342
|
var isFullWidthModeEnabled = _options ? _options.wasFullWidthModeEnabled : false;
|
|
@@ -522,7 +525,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
522
525
|
}, {
|
|
523
526
|
key: "handleColgroupUpdates",
|
|
524
527
|
value: function handleColgroupUpdates() {
|
|
525
|
-
var
|
|
528
|
+
var _this$containerWidth,
|
|
529
|
+
_this3 = this;
|
|
526
530
|
var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
527
531
|
var _this$props10 = this.props,
|
|
528
532
|
getNode = _this$props10.getNode,
|
|
@@ -555,16 +559,19 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
555
559
|
var isTableSquashed = tableRenderWidth < tableNodeWidth;
|
|
556
560
|
var isNumberColumnChanged = tableNode.attrs.isNumberColumnEnabled !== this.node.attrs.isNumberColumnEnabled;
|
|
557
561
|
var isNumberOfColumnsChanged = (0, _utils5.tablesHaveDifferentNoOfColumns)(tableNode, this.node);
|
|
562
|
+
var containerWidthValue = containerWidth.width,
|
|
563
|
+
containerLineLength = containerWidth.lineLength;
|
|
564
|
+
var isLineLengthChanged = ((_this$containerWidth = this.containerWidth) === null || _this$containerWidth === void 0 ? void 0 : _this$containerWidth.lineLength) !== containerLineLength;
|
|
565
|
+
var isFullWidthModeAndLineLengthChanged = this.updateColGroupFromFullWidthChange && isLineLengthChanged && (0, _platformFeatureFlags.fg)('platform_editor_table_overflow_in_full_width_fix');
|
|
558
566
|
var maybeScale = isTableSquashed || isTableWidthChanged || isTableResizedFullWidth && !(options !== null && options !== void 0 && options.isCommentEditor) || isNumberColumnChanged || isNumberOfColumnsChanged;
|
|
559
|
-
if (force || maybeScale) {
|
|
560
|
-
var _this$
|
|
561
|
-
var
|
|
562
|
-
var isWidthChanged = ((_this$containerWidth = this.containerWidth) === null || _this$containerWidth === void 0 ? void 0 : _this$containerWidth.width) !== containerWidthValue;
|
|
567
|
+
if (force || maybeScale || isFullWidthModeAndLineLengthChanged) {
|
|
568
|
+
var _this$containerWidth2, _this$props$options, _this$props$options2, _this$props$options3;
|
|
569
|
+
var isWidthChanged = ((_this$containerWidth2 = this.containerWidth) === null || _this$containerWidth2 === void 0 ? void 0 : _this$containerWidth2.width) !== containerWidthValue;
|
|
563
570
|
var wasTableResized = (0, _colgroup.hasTableBeenResized)(this.node);
|
|
564
571
|
var isTableResized = (0, _colgroup.hasTableBeenResized)(tableNode);
|
|
565
572
|
var isColumnsDistributed = wasTableResized && !isTableResized;
|
|
566
573
|
var isTableDisplayModeChanged = this.node.attrs.displayMode !== tableNode.attrs.displayMode;
|
|
567
|
-
var shouldUpdateColgroup = isWidthChanged || isColumnsDistributed || isTableResizedFullWidth || isTableWidthChanged || isTableDisplayModeChanged || isNumberColumnChanged || isNumberOfColumnsChanged;
|
|
574
|
+
var shouldUpdateColgroup = isWidthChanged || isColumnsDistributed || isTableResizedFullWidth || isTableWidthChanged || isTableDisplayModeChanged || isNumberColumnChanged || isNumberOfColumnsChanged || isFullWidthModeAndLineLengthChanged;
|
|
568
575
|
var _getEditorFeatureFlag3 = getEditorFeatureFlags(),
|
|
569
576
|
_getEditorFeatureFlag4 = _getEditorFeatureFlag3.tableWithFixedColumnWidthsOption,
|
|
570
577
|
tableWithFixedColumnWidthsOption = _getEditorFeatureFlag4 === void 0 ? false : _getEditorFeatureFlag4;
|
|
@@ -611,6 +618,9 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
611
618
|
});
|
|
612
619
|
}
|
|
613
620
|
}
|
|
621
|
+
if (isFullWidthModeAndLineLengthChanged) {
|
|
622
|
+
this.updateColGroupFromFullWidthChange = false;
|
|
623
|
+
}
|
|
614
624
|
this.tableNodeWidth = tableNodeWidth;
|
|
615
625
|
this.wasResizing = isResizing;
|
|
616
626
|
this.containerWidth = containerWidth;
|
|
@@ -22,6 +22,7 @@ var _withPluginState = require("@atlaskit/editor-common/with-plugin-state");
|
|
|
22
22
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
23
23
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
24
24
|
var _tableMap = require("@atlaskit/editor-tables/table-map");
|
|
25
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
25
26
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
26
27
|
var _createPluginConfig = require("../pm-plugins/create-plugin-config");
|
|
27
28
|
var _dragAndDrop = require("../pm-plugins/drag-and-drop");
|
|
@@ -297,12 +298,16 @@ var TableView = exports.default = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
297
298
|
return TableView;
|
|
298
299
|
}(_reactNodeView.default);
|
|
299
300
|
var createTableView = exports.createTableView = function createTableView(node, view, getPos, portalProviderAPI, eventDispatcher, getEditorContainerWidth, getEditorFeatureFlags, dispatchAnalyticsEvent, pluginInjectionApi, isCommentEditor, isChromelessEditor) {
|
|
301
|
+
var _pluginInjectionApi$t;
|
|
300
302
|
var _getPluginState2 = (0, _pluginFactory.getPluginState)(view.state),
|
|
301
303
|
pluginConfig = _getPluginState2.pluginConfig,
|
|
302
304
|
isFullWidthModeEnabled = _getPluginState2.isFullWidthModeEnabled,
|
|
303
305
|
wasFullWidthModeEnabled = _getPluginState2.wasFullWidthModeEnabled,
|
|
304
306
|
isDragAndDropEnabled = _getPluginState2.isDragAndDropEnabled,
|
|
305
307
|
isTableScalingEnabled = _getPluginState2.isTableScalingEnabled;
|
|
308
|
+
|
|
309
|
+
// Use shared state for isFullWidthModeEnabled and wasFullWidthModeEnabled for most up-to-date values
|
|
310
|
+
var tableState = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$t = pluginInjectionApi.table) === null || _pluginInjectionApi$t === void 0 ? void 0 : _pluginInjectionApi$t.sharedState.currentState();
|
|
306
311
|
var _getPluginConfig = (0, _createPluginConfig.pluginConfig)(pluginConfig),
|
|
307
312
|
allowColumnResizing = _getPluginConfig.allowColumnResizing,
|
|
308
313
|
allowControls = _getPluginConfig.allowControls,
|
|
@@ -319,8 +324,8 @@ var createTableView = exports.createTableView = function createTableView(node, v
|
|
|
319
324
|
eventDispatcher: eventDispatcher,
|
|
320
325
|
getPos: getPos,
|
|
321
326
|
options: {
|
|
322
|
-
isFullWidthModeEnabled: isFullWidthModeEnabled,
|
|
323
|
-
wasFullWidthModeEnabled: wasFullWidthModeEnabled,
|
|
327
|
+
isFullWidthModeEnabled: (0, _platformFeatureFlags.fg)('platform_editor_table_overflow_in_full_width_fix') ? tableState === null || tableState === void 0 ? void 0 : tableState.isFullWidthModeEnabled : isFullWidthModeEnabled,
|
|
328
|
+
wasFullWidthModeEnabled: (0, _platformFeatureFlags.fg)('platform_editor_table_overflow_in_full_width_fix') ? tableState === null || tableState === void 0 ? void 0 : tableState.wasFullWidthModeEnabled : wasFullWidthModeEnabled,
|
|
324
329
|
isDragAndDropEnabled: isDragAndDropEnabled,
|
|
325
330
|
isTableScalingEnabled: isTableScalingEnabled,
|
|
326
331
|
// same as options.isTableScalingEnabled
|
|
@@ -329,6 +329,9 @@ class TableComponent extends React.Component {
|
|
|
329
329
|
this.node = _getNode();
|
|
330
330
|
this.containerWidth = _containerWidth;
|
|
331
331
|
this.isInitialOverflowSent = false;
|
|
332
|
+
if (!this.updateColGroupFromFullWidthChange) {
|
|
333
|
+
this.updateColGroupFromFullWidthChange = (_options === null || _options === void 0 ? void 0 : _options.isFullWidthModeEnabled) && !(_options !== null && _options !== void 0 && _options.wasFullWidthModeEnabled);
|
|
334
|
+
}
|
|
332
335
|
|
|
333
336
|
// store table size using previous full-width mode so can detect if it has changed.
|
|
334
337
|
const isFullWidthModeEnabled = _options ? _options.wasFullWidthModeEnabled : false;
|
|
@@ -487,6 +490,7 @@ class TableComponent extends React.Component {
|
|
|
487
490
|
}
|
|
488
491
|
}
|
|
489
492
|
handleColgroupUpdates(force = false) {
|
|
493
|
+
var _this$containerWidth;
|
|
490
494
|
const {
|
|
491
495
|
getNode,
|
|
492
496
|
containerWidth,
|
|
@@ -519,18 +523,21 @@ class TableComponent extends React.Component {
|
|
|
519
523
|
const isTableSquashed = tableRenderWidth < tableNodeWidth;
|
|
520
524
|
const isNumberColumnChanged = tableNode.attrs.isNumberColumnEnabled !== this.node.attrs.isNumberColumnEnabled;
|
|
521
525
|
const isNumberOfColumnsChanged = tablesHaveDifferentNoOfColumns(tableNode, this.node);
|
|
526
|
+
const {
|
|
527
|
+
width: containerWidthValue,
|
|
528
|
+
lineLength: containerLineLength
|
|
529
|
+
} = containerWidth;
|
|
530
|
+
const isLineLengthChanged = ((_this$containerWidth = this.containerWidth) === null || _this$containerWidth === void 0 ? void 0 : _this$containerWidth.lineLength) !== containerLineLength;
|
|
531
|
+
const isFullWidthModeAndLineLengthChanged = this.updateColGroupFromFullWidthChange && isLineLengthChanged && fg('platform_editor_table_overflow_in_full_width_fix');
|
|
522
532
|
const maybeScale = isTableSquashed || isTableWidthChanged || isTableResizedFullWidth && !(options !== null && options !== void 0 && options.isCommentEditor) || isNumberColumnChanged || isNumberOfColumnsChanged;
|
|
523
|
-
if (force || maybeScale) {
|
|
524
|
-
var _this$
|
|
525
|
-
const
|
|
526
|
-
width: containerWidthValue
|
|
527
|
-
} = containerWidth;
|
|
528
|
-
const isWidthChanged = ((_this$containerWidth = this.containerWidth) === null || _this$containerWidth === void 0 ? void 0 : _this$containerWidth.width) !== containerWidthValue;
|
|
533
|
+
if (force || maybeScale || isFullWidthModeAndLineLengthChanged) {
|
|
534
|
+
var _this$containerWidth2, _this$props$options, _this$props$options2, _this$props$options3;
|
|
535
|
+
const isWidthChanged = ((_this$containerWidth2 = this.containerWidth) === null || _this$containerWidth2 === void 0 ? void 0 : _this$containerWidth2.width) !== containerWidthValue;
|
|
529
536
|
const wasTableResized = hasTableBeenResized(this.node);
|
|
530
537
|
const isTableResized = hasTableBeenResized(tableNode);
|
|
531
538
|
const isColumnsDistributed = wasTableResized && !isTableResized;
|
|
532
539
|
const isTableDisplayModeChanged = this.node.attrs.displayMode !== tableNode.attrs.displayMode;
|
|
533
|
-
const shouldUpdateColgroup = isWidthChanged || isColumnsDistributed || isTableResizedFullWidth || isTableWidthChanged || isTableDisplayModeChanged || isNumberColumnChanged || isNumberOfColumnsChanged;
|
|
540
|
+
const shouldUpdateColgroup = isWidthChanged || isColumnsDistributed || isTableResizedFullWidth || isTableWidthChanged || isTableDisplayModeChanged || isNumberColumnChanged || isNumberOfColumnsChanged || isFullWidthModeAndLineLengthChanged;
|
|
534
541
|
const {
|
|
535
542
|
tableWithFixedColumnWidthsOption = false
|
|
536
543
|
} = getEditorFeatureFlags();
|
|
@@ -577,6 +584,9 @@ class TableComponent extends React.Component {
|
|
|
577
584
|
});
|
|
578
585
|
}
|
|
579
586
|
}
|
|
587
|
+
if (isFullWidthModeAndLineLengthChanged) {
|
|
588
|
+
this.updateColGroupFromFullWidthChange = false;
|
|
589
|
+
}
|
|
580
590
|
this.tableNodeWidth = tableNodeWidth;
|
|
581
591
|
this.wasResizing = isResizing;
|
|
582
592
|
this.containerWidth = containerWidth;
|
|
@@ -6,6 +6,7 @@ import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
|
|
|
6
6
|
import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
|
|
7
7
|
import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
|
|
8
8
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
9
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
10
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
10
11
|
import { pluginConfig as getPluginConfig } from '../pm-plugins/create-plugin-config';
|
|
11
12
|
import { pluginKey as tableDragAndDropPluginKey } from '../pm-plugins/drag-and-drop';
|
|
@@ -262,6 +263,7 @@ export default class TableView extends ReactNodeView {
|
|
|
262
263
|
}
|
|
263
264
|
}
|
|
264
265
|
export const createTableView = (node, view, getPos, portalProviderAPI, eventDispatcher, getEditorContainerWidth, getEditorFeatureFlags, dispatchAnalyticsEvent, pluginInjectionApi, isCommentEditor, isChromelessEditor) => {
|
|
266
|
+
var _pluginInjectionApi$t;
|
|
265
267
|
const {
|
|
266
268
|
pluginConfig,
|
|
267
269
|
isFullWidthModeEnabled,
|
|
@@ -269,6 +271,9 @@ export const createTableView = (node, view, getPos, portalProviderAPI, eventDisp
|
|
|
269
271
|
isDragAndDropEnabled,
|
|
270
272
|
isTableScalingEnabled // same as options.isTableScalingEnabled
|
|
271
273
|
} = getPluginState(view.state);
|
|
274
|
+
|
|
275
|
+
// Use shared state for isFullWidthModeEnabled and wasFullWidthModeEnabled for most up-to-date values
|
|
276
|
+
const tableState = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$t = pluginInjectionApi.table) === null || _pluginInjectionApi$t === void 0 ? void 0 : _pluginInjectionApi$t.sharedState.currentState();
|
|
272
277
|
const {
|
|
273
278
|
allowColumnResizing,
|
|
274
279
|
allowControls,
|
|
@@ -286,8 +291,8 @@ export const createTableView = (node, view, getPos, portalProviderAPI, eventDisp
|
|
|
286
291
|
eventDispatcher,
|
|
287
292
|
getPos: getPos,
|
|
288
293
|
options: {
|
|
289
|
-
isFullWidthModeEnabled,
|
|
290
|
-
wasFullWidthModeEnabled,
|
|
294
|
+
isFullWidthModeEnabled: fg('platform_editor_table_overflow_in_full_width_fix') ? tableState === null || tableState === void 0 ? void 0 : tableState.isFullWidthModeEnabled : isFullWidthModeEnabled,
|
|
295
|
+
wasFullWidthModeEnabled: fg('platform_editor_table_overflow_in_full_width_fix') ? tableState === null || tableState === void 0 ? void 0 : tableState.wasFullWidthModeEnabled : wasFullWidthModeEnabled,
|
|
291
296
|
isDragAndDropEnabled,
|
|
292
297
|
isTableScalingEnabled,
|
|
293
298
|
// same as options.isTableScalingEnabled
|
|
@@ -327,6 +327,9 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
327
327
|
_this.node = _getNode();
|
|
328
328
|
_this.containerWidth = _containerWidth;
|
|
329
329
|
_this.isInitialOverflowSent = false;
|
|
330
|
+
if (!_this.updateColGroupFromFullWidthChange) {
|
|
331
|
+
_this.updateColGroupFromFullWidthChange = (_options === null || _options === void 0 ? void 0 : _options.isFullWidthModeEnabled) && !(_options !== null && _options !== void 0 && _options.wasFullWidthModeEnabled);
|
|
332
|
+
}
|
|
330
333
|
|
|
331
334
|
// store table size using previous full-width mode so can detect if it has changed.
|
|
332
335
|
var isFullWidthModeEnabled = _options ? _options.wasFullWidthModeEnabled : false;
|
|
@@ -515,7 +518,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
515
518
|
}, {
|
|
516
519
|
key: "handleColgroupUpdates",
|
|
517
520
|
value: function handleColgroupUpdates() {
|
|
518
|
-
var
|
|
521
|
+
var _this$containerWidth,
|
|
522
|
+
_this3 = this;
|
|
519
523
|
var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
520
524
|
var _this$props10 = this.props,
|
|
521
525
|
getNode = _this$props10.getNode,
|
|
@@ -548,16 +552,19 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
548
552
|
var isTableSquashed = tableRenderWidth < tableNodeWidth;
|
|
549
553
|
var isNumberColumnChanged = tableNode.attrs.isNumberColumnEnabled !== this.node.attrs.isNumberColumnEnabled;
|
|
550
554
|
var isNumberOfColumnsChanged = tablesHaveDifferentNoOfColumns(tableNode, this.node);
|
|
555
|
+
var containerWidthValue = containerWidth.width,
|
|
556
|
+
containerLineLength = containerWidth.lineLength;
|
|
557
|
+
var isLineLengthChanged = ((_this$containerWidth = this.containerWidth) === null || _this$containerWidth === void 0 ? void 0 : _this$containerWidth.lineLength) !== containerLineLength;
|
|
558
|
+
var isFullWidthModeAndLineLengthChanged = this.updateColGroupFromFullWidthChange && isLineLengthChanged && fg('platform_editor_table_overflow_in_full_width_fix');
|
|
551
559
|
var maybeScale = isTableSquashed || isTableWidthChanged || isTableResizedFullWidth && !(options !== null && options !== void 0 && options.isCommentEditor) || isNumberColumnChanged || isNumberOfColumnsChanged;
|
|
552
|
-
if (force || maybeScale) {
|
|
553
|
-
var _this$
|
|
554
|
-
var
|
|
555
|
-
var isWidthChanged = ((_this$containerWidth = this.containerWidth) === null || _this$containerWidth === void 0 ? void 0 : _this$containerWidth.width) !== containerWidthValue;
|
|
560
|
+
if (force || maybeScale || isFullWidthModeAndLineLengthChanged) {
|
|
561
|
+
var _this$containerWidth2, _this$props$options, _this$props$options2, _this$props$options3;
|
|
562
|
+
var isWidthChanged = ((_this$containerWidth2 = this.containerWidth) === null || _this$containerWidth2 === void 0 ? void 0 : _this$containerWidth2.width) !== containerWidthValue;
|
|
556
563
|
var wasTableResized = hasTableBeenResized(this.node);
|
|
557
564
|
var isTableResized = hasTableBeenResized(tableNode);
|
|
558
565
|
var isColumnsDistributed = wasTableResized && !isTableResized;
|
|
559
566
|
var isTableDisplayModeChanged = this.node.attrs.displayMode !== tableNode.attrs.displayMode;
|
|
560
|
-
var shouldUpdateColgroup = isWidthChanged || isColumnsDistributed || isTableResizedFullWidth || isTableWidthChanged || isTableDisplayModeChanged || isNumberColumnChanged || isNumberOfColumnsChanged;
|
|
567
|
+
var shouldUpdateColgroup = isWidthChanged || isColumnsDistributed || isTableResizedFullWidth || isTableWidthChanged || isTableDisplayModeChanged || isNumberColumnChanged || isNumberOfColumnsChanged || isFullWidthModeAndLineLengthChanged;
|
|
561
568
|
var _getEditorFeatureFlag3 = getEditorFeatureFlags(),
|
|
562
569
|
_getEditorFeatureFlag4 = _getEditorFeatureFlag3.tableWithFixedColumnWidthsOption,
|
|
563
570
|
tableWithFixedColumnWidthsOption = _getEditorFeatureFlag4 === void 0 ? false : _getEditorFeatureFlag4;
|
|
@@ -604,6 +611,9 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
604
611
|
});
|
|
605
612
|
}
|
|
606
613
|
}
|
|
614
|
+
if (isFullWidthModeAndLineLengthChanged) {
|
|
615
|
+
this.updateColGroupFromFullWidthChange = false;
|
|
616
|
+
}
|
|
607
617
|
this.tableNodeWidth = tableNodeWidth;
|
|
608
618
|
this.wasResizing = isResizing;
|
|
609
619
|
this.containerWidth = containerWidth;
|
|
@@ -17,6 +17,7 @@ import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
|
|
|
17
17
|
import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
|
|
18
18
|
import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
|
|
19
19
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
20
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
20
21
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
21
22
|
import { pluginConfig as getPluginConfig } from '../pm-plugins/create-plugin-config';
|
|
22
23
|
import { pluginKey as tableDragAndDropPluginKey } from '../pm-plugins/drag-and-drop';
|
|
@@ -291,12 +292,16 @@ var TableView = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
291
292
|
}(ReactNodeView);
|
|
292
293
|
export { TableView as default };
|
|
293
294
|
export var createTableView = function createTableView(node, view, getPos, portalProviderAPI, eventDispatcher, getEditorContainerWidth, getEditorFeatureFlags, dispatchAnalyticsEvent, pluginInjectionApi, isCommentEditor, isChromelessEditor) {
|
|
295
|
+
var _pluginInjectionApi$t;
|
|
294
296
|
var _getPluginState2 = getPluginState(view.state),
|
|
295
297
|
pluginConfig = _getPluginState2.pluginConfig,
|
|
296
298
|
isFullWidthModeEnabled = _getPluginState2.isFullWidthModeEnabled,
|
|
297
299
|
wasFullWidthModeEnabled = _getPluginState2.wasFullWidthModeEnabled,
|
|
298
300
|
isDragAndDropEnabled = _getPluginState2.isDragAndDropEnabled,
|
|
299
301
|
isTableScalingEnabled = _getPluginState2.isTableScalingEnabled;
|
|
302
|
+
|
|
303
|
+
// Use shared state for isFullWidthModeEnabled and wasFullWidthModeEnabled for most up-to-date values
|
|
304
|
+
var tableState = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$t = pluginInjectionApi.table) === null || _pluginInjectionApi$t === void 0 ? void 0 : _pluginInjectionApi$t.sharedState.currentState();
|
|
300
305
|
var _getPluginConfig = getPluginConfig(pluginConfig),
|
|
301
306
|
allowColumnResizing = _getPluginConfig.allowColumnResizing,
|
|
302
307
|
allowControls = _getPluginConfig.allowControls,
|
|
@@ -313,8 +318,8 @@ export var createTableView = function createTableView(node, view, getPos, portal
|
|
|
313
318
|
eventDispatcher: eventDispatcher,
|
|
314
319
|
getPos: getPos,
|
|
315
320
|
options: {
|
|
316
|
-
isFullWidthModeEnabled: isFullWidthModeEnabled,
|
|
317
|
-
wasFullWidthModeEnabled: wasFullWidthModeEnabled,
|
|
321
|
+
isFullWidthModeEnabled: fg('platform_editor_table_overflow_in_full_width_fix') ? tableState === null || tableState === void 0 ? void 0 : tableState.isFullWidthModeEnabled : isFullWidthModeEnabled,
|
|
322
|
+
wasFullWidthModeEnabled: fg('platform_editor_table_overflow_in_full_width_fix') ? tableState === null || tableState === void 0 ? void 0 : tableState.wasFullWidthModeEnabled : wasFullWidthModeEnabled,
|
|
318
323
|
isDragAndDropEnabled: isDragAndDropEnabled,
|
|
319
324
|
isTableScalingEnabled: isTableScalingEnabled,
|
|
320
325
|
// same as options.isTableScalingEnabled
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "8.4.
|
|
3
|
+
"version": "8.4.6",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"@atlaskit/adf-schema": "^46.1.0",
|
|
31
31
|
"@atlaskit/button": "^20.3.0",
|
|
32
32
|
"@atlaskit/custom-steps": "^0.9.0",
|
|
33
|
-
"@atlaskit/editor-common": "^96.
|
|
33
|
+
"@atlaskit/editor-common": "^96.4.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",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@atlaskit/editor-plugin-content-insertion": "^1.11.0",
|
|
39
39
|
"@atlaskit/editor-plugin-editor-viewmode": "^2.1.0",
|
|
40
40
|
"@atlaskit/editor-plugin-guideline": "^1.2.0",
|
|
41
|
-
"@atlaskit/editor-plugin-selection": "^1.
|
|
41
|
+
"@atlaskit/editor-plugin-selection": "^1.6.0",
|
|
42
42
|
"@atlaskit/editor-plugin-width": "^1.3.0",
|
|
43
43
|
"@atlaskit/editor-prosemirror": "6.2.1",
|
|
44
44
|
"@atlaskit/editor-shared-styles": "^3.2.0",
|
|
@@ -51,10 +51,10 @@
|
|
|
51
51
|
"@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.0.0",
|
|
52
52
|
"@atlaskit/primitives": "^13.3.0",
|
|
53
53
|
"@atlaskit/theme": "^14.0.0",
|
|
54
|
-
"@atlaskit/tmp-editor-statsig": "^2.
|
|
54
|
+
"@atlaskit/tmp-editor-statsig": "^2.25.0",
|
|
55
55
|
"@atlaskit/toggle": "^13.4.0",
|
|
56
56
|
"@atlaskit/tokens": "^2.4.0",
|
|
57
|
-
"@atlaskit/tooltip": "^
|
|
57
|
+
"@atlaskit/tooltip": "^19.0.0",
|
|
58
58
|
"@babel/runtime": "^7.0.0",
|
|
59
59
|
"@emotion/react": "^11.7.1",
|
|
60
60
|
"classnames": "^2.2.5",
|
|
@@ -137,6 +137,9 @@
|
|
|
137
137
|
},
|
|
138
138
|
"platform_editor_ed_25642": {
|
|
139
139
|
"type": "boolean"
|
|
140
|
+
},
|
|
141
|
+
"platform_editor_table_overflow_in_full_width_fix": {
|
|
142
|
+
"type": "boolean"
|
|
140
143
|
}
|
|
141
144
|
}
|
|
142
145
|
}
|
|
@@ -173,6 +173,8 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
173
173
|
private wrapperWidth?: number;
|
|
174
174
|
private wrapperReisizeObserver?: ResizeObserver;
|
|
175
175
|
|
|
176
|
+
private updateColGroupFromFullWidthChange?: boolean;
|
|
177
|
+
|
|
176
178
|
private dragAndDropCleanupFn?: CleanupFn;
|
|
177
179
|
|
|
178
180
|
constructor(props: ComponentProps) {
|
|
@@ -180,8 +182,14 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
180
182
|
const { options, containerWidth, getNode } = props;
|
|
181
183
|
this.node = getNode();
|
|
182
184
|
this.containerWidth = containerWidth;
|
|
185
|
+
|
|
183
186
|
this.isInitialOverflowSent = false;
|
|
184
187
|
|
|
188
|
+
if (!this.updateColGroupFromFullWidthChange) {
|
|
189
|
+
this.updateColGroupFromFullWidthChange =
|
|
190
|
+
options?.isFullWidthModeEnabled && !options?.wasFullWidthModeEnabled;
|
|
191
|
+
}
|
|
192
|
+
|
|
185
193
|
// store table size using previous full-width mode so can detect if it has changed.
|
|
186
194
|
const isFullWidthModeEnabled = options ? options.wasFullWidthModeEnabled : false;
|
|
187
195
|
this.layoutSize = this.tableNodeLayoutSize(this.node, containerWidth.width, {
|
|
@@ -429,6 +437,14 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
429
437
|
tableNode.attrs.isNumberColumnEnabled !== this.node.attrs.isNumberColumnEnabled;
|
|
430
438
|
const isNumberOfColumnsChanged = tablesHaveDifferentNoOfColumns(tableNode, this.node);
|
|
431
439
|
|
|
440
|
+
const { width: containerWidthValue, lineLength: containerLineLength } = containerWidth;
|
|
441
|
+
const isLineLengthChanged = this.containerWidth?.lineLength !== containerLineLength;
|
|
442
|
+
|
|
443
|
+
const isFullWidthModeAndLineLengthChanged =
|
|
444
|
+
this.updateColGroupFromFullWidthChange &&
|
|
445
|
+
isLineLengthChanged &&
|
|
446
|
+
fg('platform_editor_table_overflow_in_full_width_fix');
|
|
447
|
+
|
|
432
448
|
const maybeScale =
|
|
433
449
|
isTableSquashed ||
|
|
434
450
|
isTableWidthChanged ||
|
|
@@ -436,14 +452,12 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
436
452
|
isNumberColumnChanged ||
|
|
437
453
|
isNumberOfColumnsChanged;
|
|
438
454
|
|
|
439
|
-
if (force || maybeScale) {
|
|
440
|
-
const { width: containerWidthValue } = containerWidth;
|
|
455
|
+
if (force || maybeScale || isFullWidthModeAndLineLengthChanged) {
|
|
441
456
|
const isWidthChanged = this.containerWidth?.width !== containerWidthValue;
|
|
442
457
|
const wasTableResized = hasTableBeenResized(this.node);
|
|
443
458
|
const isTableResized = hasTableBeenResized(tableNode);
|
|
444
459
|
const isColumnsDistributed = wasTableResized && !isTableResized;
|
|
445
460
|
const isTableDisplayModeChanged = this.node.attrs.displayMode !== tableNode.attrs.displayMode;
|
|
446
|
-
|
|
447
461
|
const shouldUpdateColgroup =
|
|
448
462
|
isWidthChanged ||
|
|
449
463
|
isColumnsDistributed ||
|
|
@@ -451,7 +465,8 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
451
465
|
isTableWidthChanged ||
|
|
452
466
|
isTableDisplayModeChanged ||
|
|
453
467
|
isNumberColumnChanged ||
|
|
454
|
-
isNumberOfColumnsChanged
|
|
468
|
+
isNumberOfColumnsChanged ||
|
|
469
|
+
isFullWidthModeAndLineLengthChanged;
|
|
455
470
|
|
|
456
471
|
const { tableWithFixedColumnWidthsOption = false } = getEditorFeatureFlags();
|
|
457
472
|
|
|
@@ -523,6 +538,11 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
523
538
|
});
|
|
524
539
|
}
|
|
525
540
|
}
|
|
541
|
+
|
|
542
|
+
if (isFullWidthModeAndLineLengthChanged) {
|
|
543
|
+
this.updateColGroupFromFullWidthChange = false;
|
|
544
|
+
}
|
|
545
|
+
|
|
526
546
|
this.tableNodeWidth = tableNodeWidth;
|
|
527
547
|
this.wasResizing = isResizing;
|
|
528
548
|
this.containerWidth = containerWidth;
|
package/src/nodeviews/table.tsx
CHANGED
|
@@ -19,6 +19,7 @@ import type { EditorState, PluginKey } from '@atlaskit/editor-prosemirror/state'
|
|
|
19
19
|
import type { EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
|
|
20
20
|
import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
|
|
21
21
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
22
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
22
23
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
23
24
|
|
|
24
25
|
import { pluginConfig as getPluginConfig } from '../pm-plugins/create-plugin-config';
|
|
@@ -382,6 +383,10 @@ export const createTableView = (
|
|
|
382
383
|
isDragAndDropEnabled,
|
|
383
384
|
isTableScalingEnabled, // same as options.isTableScalingEnabled
|
|
384
385
|
} = getPluginState(view.state);
|
|
386
|
+
|
|
387
|
+
// Use shared state for isFullWidthModeEnabled and wasFullWidthModeEnabled for most up-to-date values
|
|
388
|
+
const tableState = pluginInjectionApi?.table?.sharedState.currentState();
|
|
389
|
+
|
|
385
390
|
const { allowColumnResizing, allowControls, allowTableResizing, allowTableAlignment } =
|
|
386
391
|
getPluginConfig(pluginConfig);
|
|
387
392
|
|
|
@@ -396,8 +401,12 @@ export const createTableView = (
|
|
|
396
401
|
eventDispatcher,
|
|
397
402
|
getPos: getPos as getPosHandlerNode,
|
|
398
403
|
options: {
|
|
399
|
-
isFullWidthModeEnabled
|
|
400
|
-
|
|
404
|
+
isFullWidthModeEnabled: fg('platform_editor_table_overflow_in_full_width_fix')
|
|
405
|
+
? tableState?.isFullWidthModeEnabled
|
|
406
|
+
: isFullWidthModeEnabled,
|
|
407
|
+
wasFullWidthModeEnabled: fg('platform_editor_table_overflow_in_full_width_fix')
|
|
408
|
+
? tableState?.wasFullWidthModeEnabled
|
|
409
|
+
: wasFullWidthModeEnabled,
|
|
401
410
|
isDragAndDropEnabled,
|
|
402
411
|
isTableScalingEnabled, // same as options.isTableScalingEnabled
|
|
403
412
|
isCommentEditor,
|