@atlaskit/editor-plugin-table 7.25.14 → 7.25.16
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 +16 -0
- package/afm-cc/tsconfig.json +3 -0
- package/afm-jira/tsconfig.json +3 -0
- package/dist/cjs/nodeviews/TableComponent.js +18 -14
- package/dist/cjs/transforms/column-width.js +15 -2
- package/dist/es2019/nodeviews/TableComponent.js +12 -8
- package/dist/es2019/pm-plugins/table-resizing/utils/misc.js +1 -1
- package/dist/es2019/transforms/column-width.js +15 -2
- package/dist/esm/nodeviews/TableComponent.js +18 -14
- package/dist/esm/transforms/column-width.js +15 -2
- package/dist/types/plugin.d.ts +2 -0
- package/dist/types/transforms/column-width.d.ts +1 -1
- package/dist/types/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +5 -1
- package/dist/types/ui/TableFloatingControls/CornerControls/DragCornerControls.d.ts +10 -2
- package/dist/types/ui/TableFloatingControls/index.d.ts +5 -1
- package/dist/types-ts4.5/plugin.d.ts +2 -0
- package/dist/types-ts4.5/transforms/column-width.d.ts +1 -1
- package/dist/types-ts4.5/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +5 -0
- package/dist/types-ts4.5/ui/TableFloatingControls/CornerControls/DragCornerControls.d.ts +10 -0
- package/dist/types-ts4.5/ui/TableFloatingControls/index.d.ts +5 -0
- package/package.json +6 -2
- package/src/nodeviews/TableComponent.tsx +17 -14
- package/src/plugin.tsx +2 -0
- package/src/pm-plugins/table-resizing/utils/misc.ts +1 -1
- package/src/transforms/column-width.ts +13 -3
- package/tsconfig.app.json +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 7.25.16
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#135342](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/135342)
|
|
8
|
+
[`7310995594ece`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/7310995594ece) -
|
|
9
|
+
[ED-24636] Group Table Resizing Steps into a single custom step
|
|
10
|
+
|
|
11
|
+
## 7.25.15
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [`be687d5675114`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/be687d5675114) -
|
|
16
|
+
[ux] Fixes a bug where scaled table viewed on a narrow screen loses scaling.
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
|
|
3
19
|
## 7.25.14
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/afm-cc/tsconfig.json
CHANGED
package/afm-jira/tsconfig.json
CHANGED
|
@@ -548,7 +548,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
548
548
|
// When in comment editor, we need the scaling percent to be 40% while tableWithFixedColumnWidthsOption is not visible
|
|
549
549
|
!!((_this$props$options2 = this.props.options) !== null && _this$props$options2 !== void 0 && _this$props$options2.isTableScalingEnabled) && !!((_this$props$options3 = this.props.options) !== null && _this$props$options3 !== void 0 && _this$props$options3.isCommentEditor);
|
|
550
550
|
if (force || !isResizing && shouldUpdateColgroup) {
|
|
551
|
-
var _this$props$options4, _this$props$options5, _this$props$options6, _this$props$options7
|
|
551
|
+
var _this$props$options4, _this$props$options5, _this$props$options6, _this$props$options7;
|
|
552
552
|
var resizeState = (0, _utils4.getResizeState)({
|
|
553
553
|
minWidth: _utils4.COLUMN_MIN_WIDTH,
|
|
554
554
|
maxSize: tableRenderWidth,
|
|
@@ -571,14 +571,18 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
571
571
|
shouldScaleOnColgroupUpdate = true;
|
|
572
572
|
}
|
|
573
573
|
var scalePercent = 1;
|
|
574
|
-
if (!((_this$props$options8 = this.props.options) !== null && _this$props$options8 !== void 0 && _this$props$options8.isCommentEditor) || (_this$props$options9 = this.props.options) !== null && _this$props$options9 !== void 0 && _this$props$options9.isCommentEditor && tableNode.attrs.width) {
|
|
575
|
-
scalePercent = (0, _misc.getTableScalingPercent)(tableNode, this.table, shouldUseIncreasedScalingPercent);
|
|
576
|
-
} else {
|
|
577
|
-
scalePercent = (0, _misc.getScalingPercentForTableWithoutWidth)(tableNode, this.table);
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
// Request animation frame required for Firefox
|
|
581
574
|
requestAnimationFrame(function () {
|
|
575
|
+
var _this2$props$options, _this2$props$options2;
|
|
576
|
+
// Scaling percent has to be calculated inside requestAnimationFrame, otherwise
|
|
577
|
+
// renderWidth calculated as `tableRef?.parentElement?.clientWidth`
|
|
578
|
+
// inside of getTableScalingPercent returns 0.
|
|
579
|
+
if (!((_this2$props$options = _this2.props.options) !== null && _this2$props$options !== void 0 && _this2$props$options.isCommentEditor) || (_this2$props$options2 = _this2.props.options) !== null && _this2$props$options2 !== void 0 && _this2$props$options2.isCommentEditor && tableNode.attrs.width) {
|
|
580
|
+
scalePercent = (0, _misc.getTableScalingPercent)(tableNode, _this2.table, shouldUseIncreasedScalingPercent);
|
|
581
|
+
} else {
|
|
582
|
+
scalePercent = (0, _misc.getScalingPercentForTableWithoutWidth)(tableNode, _this2.table);
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
// Request animation frame required for Firefox
|
|
582
586
|
(0, _utils4.updateColgroup)(resizeState, _this2.table, tableNode, shouldScaleOnColgroupUpdate, scalePercent);
|
|
583
587
|
});
|
|
584
588
|
}
|
|
@@ -590,8 +594,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
590
594
|
}, {
|
|
591
595
|
key: "componentDidUpdate",
|
|
592
596
|
value: function componentDidUpdate(_, prevState) {
|
|
593
|
-
var _this$props$
|
|
594
|
-
_this$props$
|
|
597
|
+
var _this$props$options8,
|
|
598
|
+
_this$props$options9,
|
|
595
599
|
_this$wrapper,
|
|
596
600
|
_this3 = this;
|
|
597
601
|
var _this$props11 = this.props,
|
|
@@ -620,7 +624,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
620
624
|
shouldHandleColgroupUpdates = true;
|
|
621
625
|
}
|
|
622
626
|
var isTableScalingWithFixedColumnWidthsOptionEnabled = !!isTableScalingEnabled && tableWithFixedColumnWidthsOption;
|
|
623
|
-
var shouldUseIncreasedScalingPercent = isTableScalingWithFixedColumnWidthsOptionEnabled && (0, _platformFeatureFlags.fg)('platform.editor.table.use-increased-scaling-percent') || !!isTableScalingEnabled && !!((_this$props$
|
|
627
|
+
var shouldUseIncreasedScalingPercent = isTableScalingWithFixedColumnWidthsOptionEnabled && (0, _platformFeatureFlags.fg)('platform.editor.table.use-increased-scaling-percent') || !!isTableScalingEnabled && !!((_this$props$options8 = this.props.options) !== null && _this$props$options8 !== void 0 && _this$props$options8.isCommentEditor);
|
|
624
628
|
if (isTableScalingWithFixedColumnWidthsOptionEnabled && getNode().attrs.displayMode !== 'fixed') {
|
|
625
629
|
shouldScale = true;
|
|
626
630
|
shouldHandleColgroupUpdates = true;
|
|
@@ -631,7 +635,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
631
635
|
if (isInDanger && !table) {
|
|
632
636
|
(0, _commands.clearHoverSelection)()(view.state, view.dispatch);
|
|
633
637
|
}
|
|
634
|
-
if ((_this$props$
|
|
638
|
+
if ((_this$props$options9 = this.props.options) !== null && _this$props$options9 !== void 0 && _this$props$options9.isCommentEditor && options !== null && options !== void 0 && options.isTableResizingEnabled) {
|
|
635
639
|
this.removeInlineTableWidth();
|
|
636
640
|
}
|
|
637
641
|
if ((_this$wrapper = this.wrapper) !== null && _this$wrapper !== void 0 && _this$wrapper.parentElement && this.table && !this.overflowShadowsObserver) {
|
|
@@ -718,7 +722,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
718
722
|
key: "render",
|
|
719
723
|
value: function render() {
|
|
720
724
|
var _this4 = this,
|
|
721
|
-
_this$props$
|
|
725
|
+
_this$props$options10,
|
|
722
726
|
_classnames;
|
|
723
727
|
var _this$props12 = this.props,
|
|
724
728
|
view = _this$props12.view,
|
|
@@ -837,7 +841,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
837
841
|
stickyScrollbar = _getEditorFeatureFlag8.stickyScrollbar,
|
|
838
842
|
_getEditorFeatureFlag9 = _getEditorFeatureFlag8.tableWithFixedColumnWidthsOption,
|
|
839
843
|
tableWithFixedColumnWidthsOption = _getEditorFeatureFlag9 === void 0 ? false : _getEditorFeatureFlag9;
|
|
840
|
-
var shouldUseIncreasedScalingPercent = !!isTableScalingEnabled && (tableWithFixedColumnWidthsOption && (0, _platformFeatureFlags.fg)('platform.editor.table.use-increased-scaling-percent') || !!((_this$props$
|
|
844
|
+
var shouldUseIncreasedScalingPercent = !!isTableScalingEnabled && (tableWithFixedColumnWidthsOption && (0, _platformFeatureFlags.fg)('platform.editor.table.use-increased-scaling-percent') || !!((_this$props$options10 = this.props.options) !== null && _this$props$options10 !== void 0 && _this$props$options10.isCommentEditor));
|
|
841
845
|
return /*#__PURE__*/_react.default.createElement(_TableContainer.TableContainer
|
|
842
846
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
843
847
|
, {
|
|
@@ -9,6 +9,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
9
9
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
10
10
|
var _transform = require("@atlaskit/editor-prosemirror/transform");
|
|
11
11
|
var _tableMap = require("@atlaskit/editor-tables/table-map");
|
|
12
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
12
13
|
var _utils = require("../pm-plugins/table-resizing/utils");
|
|
13
14
|
var _colgroup = require("../pm-plugins/table-resizing/utils/colgroup");
|
|
14
15
|
var _resizeState = require("../pm-plugins/table-resizing/utils/resize-state");
|
|
@@ -22,10 +23,11 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
22
23
|
* @param start
|
|
23
24
|
* @returns
|
|
24
25
|
*/
|
|
25
|
-
var updateColumnWidths = exports.updateColumnWidths = function updateColumnWidths(resizeState, table, start,
|
|
26
|
+
var updateColumnWidths = exports.updateColumnWidths = function updateColumnWidths(resizeState, table, start, api) {
|
|
26
27
|
return function (tr) {
|
|
27
28
|
var map = _tableMap.TableMap.get(table);
|
|
28
29
|
var updatedCellsAttrs = {};
|
|
30
|
+
var steps = [];
|
|
29
31
|
|
|
30
32
|
// calculating new attributes for each cell
|
|
31
33
|
for (var columnIndex = 0; columnIndex < map.width; columnIndex++) {
|
|
@@ -75,12 +77,23 @@ var updateColumnWidths = exports.updateColumnWidths = function updateColumnWidth
|
|
|
75
77
|
var cell = table.nodeAt(pos);
|
|
76
78
|
if (!seen[pos] && cell) {
|
|
77
79
|
if (updatedCellsAttrs[pos]) {
|
|
78
|
-
|
|
80
|
+
steps.push(new _transform.AttrStep(pos + start, 'colwidth', updatedCellsAttrs[pos].colwidth));
|
|
79
81
|
}
|
|
80
82
|
seen[pos] = true;
|
|
81
83
|
}
|
|
82
84
|
}
|
|
83
85
|
}
|
|
86
|
+
if (api !== null && api !== void 0 && api.batchAttributeUpdates && (0, _platformFeatureFlags.fg)('platform_editor_batch_steps_table')) {
|
|
87
|
+
var batchStep = api.batchAttributeUpdates.actions.batchSteps({
|
|
88
|
+
steps: steps,
|
|
89
|
+
doc: tr.doc
|
|
90
|
+
});
|
|
91
|
+
tr.step(batchStep);
|
|
92
|
+
} else {
|
|
93
|
+
steps.forEach(function (s) {
|
|
94
|
+
tr.step(s);
|
|
95
|
+
});
|
|
96
|
+
}
|
|
84
97
|
return tr;
|
|
85
98
|
};
|
|
86
99
|
};
|
|
@@ -529,7 +529,7 @@ class TableComponent extends React.Component {
|
|
|
529
529
|
// When in comment editor, we need the scaling percent to be 40% while tableWithFixedColumnWidthsOption is not visible
|
|
530
530
|
!!((_this$props$options2 = this.props.options) !== null && _this$props$options2 !== void 0 && _this$props$options2.isTableScalingEnabled) && !!((_this$props$options3 = this.props.options) !== null && _this$props$options3 !== void 0 && _this$props$options3.isCommentEditor);
|
|
531
531
|
if (force || !isResizing && shouldUpdateColgroup) {
|
|
532
|
-
var _this$props$options4, _this$props$options5, _this$props$options6, _this$props$options7
|
|
532
|
+
var _this$props$options4, _this$props$options5, _this$props$options6, _this$props$options7;
|
|
533
533
|
const resizeState = getResizeState({
|
|
534
534
|
minWidth: COLUMN_MIN_WIDTH,
|
|
535
535
|
maxSize: tableRenderWidth,
|
|
@@ -552,14 +552,18 @@ class TableComponent extends React.Component {
|
|
|
552
552
|
shouldScaleOnColgroupUpdate = true;
|
|
553
553
|
}
|
|
554
554
|
let scalePercent = 1;
|
|
555
|
-
if (!((_this$props$options8 = this.props.options) !== null && _this$props$options8 !== void 0 && _this$props$options8.isCommentEditor) || (_this$props$options9 = this.props.options) !== null && _this$props$options9 !== void 0 && _this$props$options9.isCommentEditor && tableNode.attrs.width) {
|
|
556
|
-
scalePercent = getTableScalingPercent(tableNode, this.table, shouldUseIncreasedScalingPercent);
|
|
557
|
-
} else {
|
|
558
|
-
scalePercent = getScalingPercentForTableWithoutWidth(tableNode, this.table);
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
// Request animation frame required for Firefox
|
|
562
555
|
requestAnimationFrame(() => {
|
|
556
|
+
var _this$props$options8, _this$props$options9;
|
|
557
|
+
// Scaling percent has to be calculated inside requestAnimationFrame, otherwise
|
|
558
|
+
// renderWidth calculated as `tableRef?.parentElement?.clientWidth`
|
|
559
|
+
// inside of getTableScalingPercent returns 0.
|
|
560
|
+
if (!((_this$props$options8 = this.props.options) !== null && _this$props$options8 !== void 0 && _this$props$options8.isCommentEditor) || (_this$props$options9 = this.props.options) !== null && _this$props$options9 !== void 0 && _this$props$options9.isCommentEditor && tableNode.attrs.width) {
|
|
561
|
+
scalePercent = getTableScalingPercent(tableNode, this.table, shouldUseIncreasedScalingPercent);
|
|
562
|
+
} else {
|
|
563
|
+
scalePercent = getScalingPercentForTableWithoutWidth(tableNode, this.table);
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
// Request animation frame required for Firefox
|
|
563
567
|
updateColgroup(resizeState, this.table, tableNode, shouldScaleOnColgroupUpdate, scalePercent);
|
|
564
568
|
});
|
|
565
569
|
}
|
|
@@ -82,7 +82,7 @@ export const getTableScalingPercent = (table, tableRef, shouldUseIncreasedScalin
|
|
|
82
82
|
var _tableRef$parentEleme;
|
|
83
83
|
const maxScalingPercent = shouldUseIncreasedScalingPercent ? MAX_SCALING_PERCENT_TABLES_WITH_FIXED_COLUMN_WIDTHS_OPTION : MAX_SCALING_PERCENT;
|
|
84
84
|
const tableWidth = getTableContainerElementWidth(table);
|
|
85
|
-
|
|
85
|
+
const renderWidth = (tableRef === null || tableRef === void 0 ? void 0 : (_tableRef$parentEleme = tableRef.parentElement) === null || _tableRef$parentEleme === void 0 ? void 0 : _tableRef$parentEleme.clientWidth) || tableWidth;
|
|
86
86
|
// minus 1 here to avoid any 1px scroll in Firefox
|
|
87
87
|
let scalePercent = (renderWidth - 1) / tableWidth;
|
|
88
88
|
scalePercent = Math.max(scalePercent, 1 - maxScalingPercent);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
2
2
|
import { AttrStep } from '@atlaskit/editor-prosemirror/transform';
|
|
3
3
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
4
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
5
|
import { getTableContainerElementWidth, getTableElementWidth, hasTableBeenResized } from '../pm-plugins/table-resizing/utils';
|
|
5
6
|
import { isMinCellWidthTable } from '../pm-plugins/table-resizing/utils/colgroup';
|
|
6
7
|
import { getResizeState } from '../pm-plugins/table-resizing/utils/resize-state';
|
|
@@ -12,9 +13,10 @@ import { scaleTableTo } from '../pm-plugins/table-resizing/utils/scale-table';
|
|
|
12
13
|
* @param start
|
|
13
14
|
* @returns
|
|
14
15
|
*/
|
|
15
|
-
export const updateColumnWidths = (resizeState, table, start,
|
|
16
|
+
export const updateColumnWidths = (resizeState, table, start, api) => tr => {
|
|
16
17
|
const map = TableMap.get(table);
|
|
17
18
|
const updatedCellsAttrs = {};
|
|
19
|
+
const steps = [];
|
|
18
20
|
|
|
19
21
|
// calculating new attributes for each cell
|
|
20
22
|
for (let columnIndex = 0; columnIndex < map.width; columnIndex++) {
|
|
@@ -67,12 +69,23 @@ export const updateColumnWidths = (resizeState, table, start, _api) => tr => {
|
|
|
67
69
|
const cell = table.nodeAt(pos);
|
|
68
70
|
if (!seen[pos] && cell) {
|
|
69
71
|
if (updatedCellsAttrs[pos]) {
|
|
70
|
-
|
|
72
|
+
steps.push(new AttrStep(pos + start, 'colwidth', updatedCellsAttrs[pos].colwidth));
|
|
71
73
|
}
|
|
72
74
|
seen[pos] = true;
|
|
73
75
|
}
|
|
74
76
|
}
|
|
75
77
|
}
|
|
78
|
+
if (api !== null && api !== void 0 && api.batchAttributeUpdates && fg('platform_editor_batch_steps_table')) {
|
|
79
|
+
const batchStep = api.batchAttributeUpdates.actions.batchSteps({
|
|
80
|
+
steps,
|
|
81
|
+
doc: tr.doc
|
|
82
|
+
});
|
|
83
|
+
tr.step(batchStep);
|
|
84
|
+
} else {
|
|
85
|
+
steps.forEach(s => {
|
|
86
|
+
tr.step(s);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
76
89
|
return tr;
|
|
77
90
|
};
|
|
78
91
|
|
|
@@ -541,7 +541,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
541
541
|
// When in comment editor, we need the scaling percent to be 40% while tableWithFixedColumnWidthsOption is not visible
|
|
542
542
|
!!((_this$props$options2 = this.props.options) !== null && _this$props$options2 !== void 0 && _this$props$options2.isTableScalingEnabled) && !!((_this$props$options3 = this.props.options) !== null && _this$props$options3 !== void 0 && _this$props$options3.isCommentEditor);
|
|
543
543
|
if (force || !isResizing && shouldUpdateColgroup) {
|
|
544
|
-
var _this$props$options4, _this$props$options5, _this$props$options6, _this$props$options7
|
|
544
|
+
var _this$props$options4, _this$props$options5, _this$props$options6, _this$props$options7;
|
|
545
545
|
var resizeState = getResizeState({
|
|
546
546
|
minWidth: COLUMN_MIN_WIDTH,
|
|
547
547
|
maxSize: tableRenderWidth,
|
|
@@ -564,14 +564,18 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
564
564
|
shouldScaleOnColgroupUpdate = true;
|
|
565
565
|
}
|
|
566
566
|
var scalePercent = 1;
|
|
567
|
-
if (!((_this$props$options8 = this.props.options) !== null && _this$props$options8 !== void 0 && _this$props$options8.isCommentEditor) || (_this$props$options9 = this.props.options) !== null && _this$props$options9 !== void 0 && _this$props$options9.isCommentEditor && tableNode.attrs.width) {
|
|
568
|
-
scalePercent = getTableScalingPercent(tableNode, this.table, shouldUseIncreasedScalingPercent);
|
|
569
|
-
} else {
|
|
570
|
-
scalePercent = getScalingPercentForTableWithoutWidth(tableNode, this.table);
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
// Request animation frame required for Firefox
|
|
574
567
|
requestAnimationFrame(function () {
|
|
568
|
+
var _this2$props$options, _this2$props$options2;
|
|
569
|
+
// Scaling percent has to be calculated inside requestAnimationFrame, otherwise
|
|
570
|
+
// renderWidth calculated as `tableRef?.parentElement?.clientWidth`
|
|
571
|
+
// inside of getTableScalingPercent returns 0.
|
|
572
|
+
if (!((_this2$props$options = _this2.props.options) !== null && _this2$props$options !== void 0 && _this2$props$options.isCommentEditor) || (_this2$props$options2 = _this2.props.options) !== null && _this2$props$options2 !== void 0 && _this2$props$options2.isCommentEditor && tableNode.attrs.width) {
|
|
573
|
+
scalePercent = getTableScalingPercent(tableNode, _this2.table, shouldUseIncreasedScalingPercent);
|
|
574
|
+
} else {
|
|
575
|
+
scalePercent = getScalingPercentForTableWithoutWidth(tableNode, _this2.table);
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
// Request animation frame required for Firefox
|
|
575
579
|
updateColgroup(resizeState, _this2.table, tableNode, shouldScaleOnColgroupUpdate, scalePercent);
|
|
576
580
|
});
|
|
577
581
|
}
|
|
@@ -583,8 +587,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
583
587
|
}, {
|
|
584
588
|
key: "componentDidUpdate",
|
|
585
589
|
value: function componentDidUpdate(_, prevState) {
|
|
586
|
-
var _this$props$
|
|
587
|
-
_this$props$
|
|
590
|
+
var _this$props$options8,
|
|
591
|
+
_this$props$options9,
|
|
588
592
|
_this$wrapper,
|
|
589
593
|
_this3 = this;
|
|
590
594
|
var _this$props11 = this.props,
|
|
@@ -613,7 +617,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
613
617
|
shouldHandleColgroupUpdates = true;
|
|
614
618
|
}
|
|
615
619
|
var isTableScalingWithFixedColumnWidthsOptionEnabled = !!isTableScalingEnabled && tableWithFixedColumnWidthsOption;
|
|
616
|
-
var shouldUseIncreasedScalingPercent = isTableScalingWithFixedColumnWidthsOptionEnabled && fg('platform.editor.table.use-increased-scaling-percent') || !!isTableScalingEnabled && !!((_this$props$
|
|
620
|
+
var shouldUseIncreasedScalingPercent = isTableScalingWithFixedColumnWidthsOptionEnabled && fg('platform.editor.table.use-increased-scaling-percent') || !!isTableScalingEnabled && !!((_this$props$options8 = this.props.options) !== null && _this$props$options8 !== void 0 && _this$props$options8.isCommentEditor);
|
|
617
621
|
if (isTableScalingWithFixedColumnWidthsOptionEnabled && getNode().attrs.displayMode !== 'fixed') {
|
|
618
622
|
shouldScale = true;
|
|
619
623
|
shouldHandleColgroupUpdates = true;
|
|
@@ -624,7 +628,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
624
628
|
if (isInDanger && !table) {
|
|
625
629
|
clearHoverSelection()(view.state, view.dispatch);
|
|
626
630
|
}
|
|
627
|
-
if ((_this$props$
|
|
631
|
+
if ((_this$props$options9 = this.props.options) !== null && _this$props$options9 !== void 0 && _this$props$options9.isCommentEditor && options !== null && options !== void 0 && options.isTableResizingEnabled) {
|
|
628
632
|
this.removeInlineTableWidth();
|
|
629
633
|
}
|
|
630
634
|
if ((_this$wrapper = this.wrapper) !== null && _this$wrapper !== void 0 && _this$wrapper.parentElement && this.table && !this.overflowShadowsObserver) {
|
|
@@ -711,7 +715,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
711
715
|
key: "render",
|
|
712
716
|
value: function render() {
|
|
713
717
|
var _this4 = this,
|
|
714
|
-
_this$props$
|
|
718
|
+
_this$props$options10,
|
|
715
719
|
_classnames;
|
|
716
720
|
var _this$props12 = this.props,
|
|
717
721
|
view = _this$props12.view,
|
|
@@ -830,7 +834,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
830
834
|
stickyScrollbar = _getEditorFeatureFlag8.stickyScrollbar,
|
|
831
835
|
_getEditorFeatureFlag9 = _getEditorFeatureFlag8.tableWithFixedColumnWidthsOption,
|
|
832
836
|
tableWithFixedColumnWidthsOption = _getEditorFeatureFlag9 === void 0 ? false : _getEditorFeatureFlag9;
|
|
833
|
-
var shouldUseIncreasedScalingPercent = !!isTableScalingEnabled && (tableWithFixedColumnWidthsOption && fg('platform.editor.table.use-increased-scaling-percent') || !!((_this$props$
|
|
837
|
+
var shouldUseIncreasedScalingPercent = !!isTableScalingEnabled && (tableWithFixedColumnWidthsOption && fg('platform.editor.table.use-increased-scaling-percent') || !!((_this$props$options10 = this.props.options) !== null && _this$props$options10 !== void 0 && _this$props$options10.isCommentEditor));
|
|
834
838
|
return /*#__PURE__*/React.createElement(TableContainer
|
|
835
839
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
836
840
|
, {
|
|
@@ -4,6 +4,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
4
4
|
import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
5
5
|
import { AttrStep } from '@atlaskit/editor-prosemirror/transform';
|
|
6
6
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
7
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
8
|
import { getTableContainerElementWidth, getTableElementWidth, hasTableBeenResized } from '../pm-plugins/table-resizing/utils';
|
|
8
9
|
import { isMinCellWidthTable } from '../pm-plugins/table-resizing/utils/colgroup';
|
|
9
10
|
import { getResizeState } from '../pm-plugins/table-resizing/utils/resize-state';
|
|
@@ -15,10 +16,11 @@ import { scaleTableTo } from '../pm-plugins/table-resizing/utils/scale-table';
|
|
|
15
16
|
* @param start
|
|
16
17
|
* @returns
|
|
17
18
|
*/
|
|
18
|
-
export var updateColumnWidths = function updateColumnWidths(resizeState, table, start,
|
|
19
|
+
export var updateColumnWidths = function updateColumnWidths(resizeState, table, start, api) {
|
|
19
20
|
return function (tr) {
|
|
20
21
|
var map = TableMap.get(table);
|
|
21
22
|
var updatedCellsAttrs = {};
|
|
23
|
+
var steps = [];
|
|
22
24
|
|
|
23
25
|
// calculating new attributes for each cell
|
|
24
26
|
for (var columnIndex = 0; columnIndex < map.width; columnIndex++) {
|
|
@@ -68,12 +70,23 @@ export var updateColumnWidths = function updateColumnWidths(resizeState, table,
|
|
|
68
70
|
var cell = table.nodeAt(pos);
|
|
69
71
|
if (!seen[pos] && cell) {
|
|
70
72
|
if (updatedCellsAttrs[pos]) {
|
|
71
|
-
|
|
73
|
+
steps.push(new AttrStep(pos + start, 'colwidth', updatedCellsAttrs[pos].colwidth));
|
|
72
74
|
}
|
|
73
75
|
seen[pos] = true;
|
|
74
76
|
}
|
|
75
77
|
}
|
|
76
78
|
}
|
|
79
|
+
if (api !== null && api !== void 0 && api.batchAttributeUpdates && fg('platform_editor_batch_steps_table')) {
|
|
80
|
+
var batchStep = api.batchAttributeUpdates.actions.batchSteps({
|
|
81
|
+
steps: steps,
|
|
82
|
+
doc: tr.doc
|
|
83
|
+
});
|
|
84
|
+
tr.step(batchStep);
|
|
85
|
+
} else {
|
|
86
|
+
steps.forEach(function (s) {
|
|
87
|
+
tr.step(s);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
77
90
|
return tr;
|
|
78
91
|
};
|
|
79
92
|
};
|
package/dist/types/plugin.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
|
3
3
|
import type { Command, EditorCommand, GetEditorFeatureFlags, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
4
4
|
import type { AccessibilityUtilsPlugin } from '@atlaskit/editor-plugin-accessibility-utils';
|
|
5
5
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
6
|
+
import type { BatchAttributeUpdatesPlugin } from '@atlaskit/editor-plugin-batch-attribute-updates';
|
|
6
7
|
import type { ContentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
|
|
7
8
|
import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmode';
|
|
8
9
|
import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
|
|
@@ -46,6 +47,7 @@ export type TablePlugin = NextEditorPlugin<'table', {
|
|
|
46
47
|
WidthPlugin,
|
|
47
48
|
GuidelinePlugin,
|
|
48
49
|
SelectionPlugin,
|
|
50
|
+
OptionalPlugin<BatchAttributeUpdatesPlugin>,
|
|
49
51
|
OptionalPlugin<AccessibilityUtilsPlugin>,
|
|
50
52
|
OptionalPlugin<MediaPlugin>,
|
|
51
53
|
OptionalPlugin<EditorViewModePlugin>,
|
|
@@ -11,7 +11,7 @@ import type { PluginInjectionAPI } from '../types';
|
|
|
11
11
|
* @param start
|
|
12
12
|
* @returns
|
|
13
13
|
*/
|
|
14
|
-
export declare const updateColumnWidths: (resizeState: ResizeState, table: PMNode, start: number,
|
|
14
|
+
export declare const updateColumnWidths: (resizeState: ResizeState, table: PMNode, start: number, api: PluginInjectionAPI | undefined | null) => (tr: Transaction) => Transaction;
|
|
15
15
|
/**
|
|
16
16
|
* This function is called when user inserts/deletes a column in a table to;
|
|
17
17
|
* - rescale all columns (if the table did not overflow before the insertion)
|
|
@@ -74,7 +74,11 @@ export declare const ColumnControls: ({ editorView, tableActive, tableRef, hover
|
|
|
74
74
|
displayGapCursor: (toggle: boolean) => import("@atlaskit/editor-common/types").EditorCommand;
|
|
75
75
|
};
|
|
76
76
|
sharedState: import("@atlaskit/editor-common/selection").SelectionSharedState;
|
|
77
|
-
}, import("@atlaskit/editor-plugin-selection/types").SelectionPluginOptions | undefined>, import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"
|
|
77
|
+
}, import("@atlaskit/editor-plugin-selection/types").SelectionPluginOptions | undefined>, import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"batchAttributeUpdates", {
|
|
78
|
+
actions: {
|
|
79
|
+
batchSteps: import("@atlaskit/editor-plugin-batch-attribute-updates").BatchStepsAction;
|
|
80
|
+
};
|
|
81
|
+
}, undefined>>, import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"accessibilityUtils", {
|
|
78
82
|
dependencies: [];
|
|
79
83
|
actions: {
|
|
80
84
|
ariaNotify: (message: string, ariaLiveElementAttributes?: import("@atlaskit/editor-plugin-accessibility-utils").AriaLiveElementAttributes | undefined) => void;
|
|
@@ -55,7 +55,11 @@ export declare const DragCornerControlsWithSelection: React.FC<import("react-int
|
|
|
55
55
|
displayGapCursor: (toggle: boolean) => import("@atlaskit/editor-common/types").EditorCommand;
|
|
56
56
|
};
|
|
57
57
|
sharedState: import("@atlaskit/editor-common/selection").SelectionSharedState;
|
|
58
|
-
}, import("@atlaskit/editor-plugin-selection/types").SelectionPluginOptions | undefined>, import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"
|
|
58
|
+
}, import("@atlaskit/editor-plugin-selection/types").SelectionPluginOptions | undefined>, import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"batchAttributeUpdates", {
|
|
59
|
+
actions: {
|
|
60
|
+
batchSteps: import("@atlaskit/editor-plugin-batch-attribute-updates").BatchStepsAction;
|
|
61
|
+
};
|
|
62
|
+
}, undefined>>, import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"accessibilityUtils", {
|
|
59
63
|
dependencies: [];
|
|
60
64
|
actions: {
|
|
61
65
|
ariaNotify: (message: string, ariaLiveElementAttributes?: import("@atlaskit/editor-plugin-accessibility-utils").AriaLiveElementAttributes | undefined) => void;
|
|
@@ -137,7 +141,11 @@ export declare const DragCornerControlsWithSelection: React.FC<import("react-int
|
|
|
137
141
|
displayGapCursor: (toggle: boolean) => import("@atlaskit/editor-common/types").EditorCommand;
|
|
138
142
|
};
|
|
139
143
|
sharedState: import("@atlaskit/editor-common/selection").SelectionSharedState;
|
|
140
|
-
}, import("@atlaskit/editor-plugin-selection/types").SelectionPluginOptions | undefined>, import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"
|
|
144
|
+
}, import("@atlaskit/editor-plugin-selection/types").SelectionPluginOptions | undefined>, import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"batchAttributeUpdates", {
|
|
145
|
+
actions: {
|
|
146
|
+
batchSteps: import("@atlaskit/editor-plugin-batch-attribute-updates").BatchStepsAction;
|
|
147
|
+
};
|
|
148
|
+
}, undefined>>, import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"accessibilityUtils", {
|
|
141
149
|
dependencies: [];
|
|
142
150
|
actions: {
|
|
143
151
|
ariaNotify: (message: string, ariaLiveElementAttributes?: import("@atlaskit/editor-plugin-accessibility-utils").AriaLiveElementAttributes | undefined) => void;
|
|
@@ -84,7 +84,11 @@ export declare const TableFloatingControls: ({ editorView, tableRef, tableNode,
|
|
|
84
84
|
displayGapCursor: (toggle: boolean) => import("@atlaskit/editor-common/types").EditorCommand;
|
|
85
85
|
};
|
|
86
86
|
sharedState: import("@atlaskit/editor-common/selection").SelectionSharedState;
|
|
87
|
-
}, import("@atlaskit/editor-plugin-selection/types").SelectionPluginOptions | undefined>, import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"
|
|
87
|
+
}, import("@atlaskit/editor-plugin-selection/types").SelectionPluginOptions | undefined>, import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"batchAttributeUpdates", {
|
|
88
|
+
actions: {
|
|
89
|
+
batchSteps: import("@atlaskit/editor-plugin-batch-attribute-updates").BatchStepsAction;
|
|
90
|
+
};
|
|
91
|
+
}, undefined>>, import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"accessibilityUtils", {
|
|
88
92
|
dependencies: [];
|
|
89
93
|
actions: {
|
|
90
94
|
ariaNotify: (message: string, ariaLiveElementAttributes?: import("@atlaskit/editor-plugin-accessibility-utils").AriaLiveElementAttributes | undefined) => void;
|
|
@@ -3,6 +3,7 @@ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
|
3
3
|
import type { Command, EditorCommand, GetEditorFeatureFlags, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
4
4
|
import type { AccessibilityUtilsPlugin } from '@atlaskit/editor-plugin-accessibility-utils';
|
|
5
5
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
6
|
+
import type { BatchAttributeUpdatesPlugin } from '@atlaskit/editor-plugin-batch-attribute-updates';
|
|
6
7
|
import type { ContentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
|
|
7
8
|
import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmode';
|
|
8
9
|
import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
|
|
@@ -46,6 +47,7 @@ export type TablePlugin = NextEditorPlugin<'table', {
|
|
|
46
47
|
WidthPlugin,
|
|
47
48
|
GuidelinePlugin,
|
|
48
49
|
SelectionPlugin,
|
|
50
|
+
OptionalPlugin<BatchAttributeUpdatesPlugin>,
|
|
49
51
|
OptionalPlugin<AccessibilityUtilsPlugin>,
|
|
50
52
|
OptionalPlugin<MediaPlugin>,
|
|
51
53
|
OptionalPlugin<EditorViewModePlugin>,
|
|
@@ -11,7 +11,7 @@ import type { PluginInjectionAPI } from '../types';
|
|
|
11
11
|
* @param start
|
|
12
12
|
* @returns
|
|
13
13
|
*/
|
|
14
|
-
export declare const updateColumnWidths: (resizeState: ResizeState, table: PMNode, start: number,
|
|
14
|
+
export declare const updateColumnWidths: (resizeState: ResizeState, table: PMNode, start: number, api: PluginInjectionAPI | undefined | null) => (tr: Transaction) => Transaction;
|
|
15
15
|
/**
|
|
16
16
|
* This function is called when user inserts/deletes a column in a table to;
|
|
17
17
|
* - rescale all columns (if the table did not overflow before the insertion)
|
|
@@ -88,6 +88,11 @@ export declare const ColumnControls: ({ editorView, tableActive, tableRef, hover
|
|
|
88
88
|
};
|
|
89
89
|
sharedState: import("@atlaskit/editor-common/selection").SelectionSharedState;
|
|
90
90
|
}, import("@atlaskit/editor-plugin-selection/types").SelectionPluginOptions | undefined>,
|
|
91
|
+
import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"batchAttributeUpdates", {
|
|
92
|
+
actions: {
|
|
93
|
+
batchSteps: import("@atlaskit/editor-plugin-batch-attribute-updates").BatchStepsAction;
|
|
94
|
+
};
|
|
95
|
+
}, undefined>>,
|
|
91
96
|
import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"accessibilityUtils", {
|
|
92
97
|
dependencies: [
|
|
93
98
|
];
|
|
@@ -69,6 +69,11 @@ export declare const DragCornerControlsWithSelection: React.FC<import("react-int
|
|
|
69
69
|
};
|
|
70
70
|
sharedState: import("@atlaskit/editor-common/selection").SelectionSharedState;
|
|
71
71
|
}, import("@atlaskit/editor-plugin-selection/types").SelectionPluginOptions | undefined>,
|
|
72
|
+
import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"batchAttributeUpdates", {
|
|
73
|
+
actions: {
|
|
74
|
+
batchSteps: import("@atlaskit/editor-plugin-batch-attribute-updates").BatchStepsAction;
|
|
75
|
+
};
|
|
76
|
+
}, undefined>>,
|
|
72
77
|
import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"accessibilityUtils", {
|
|
73
78
|
dependencies: [
|
|
74
79
|
];
|
|
@@ -171,6 +176,11 @@ export declare const DragCornerControlsWithSelection: React.FC<import("react-int
|
|
|
171
176
|
};
|
|
172
177
|
sharedState: import("@atlaskit/editor-common/selection").SelectionSharedState;
|
|
173
178
|
}, import("@atlaskit/editor-plugin-selection/types").SelectionPluginOptions | undefined>,
|
|
179
|
+
import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"batchAttributeUpdates", {
|
|
180
|
+
actions: {
|
|
181
|
+
batchSteps: import("@atlaskit/editor-plugin-batch-attribute-updates").BatchStepsAction;
|
|
182
|
+
};
|
|
183
|
+
}, undefined>>,
|
|
174
184
|
import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"accessibilityUtils", {
|
|
175
185
|
dependencies: [
|
|
176
186
|
];
|
|
@@ -98,6 +98,11 @@ export declare const TableFloatingControls: ({ editorView, tableRef, tableNode,
|
|
|
98
98
|
};
|
|
99
99
|
sharedState: import("@atlaskit/editor-common/selection").SelectionSharedState;
|
|
100
100
|
}, import("@atlaskit/editor-plugin-selection/types").SelectionPluginOptions | undefined>,
|
|
101
|
+
import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"batchAttributeUpdates", {
|
|
102
|
+
actions: {
|
|
103
|
+
batchSteps: import("@atlaskit/editor-plugin-batch-attribute-updates").BatchStepsAction;
|
|
104
|
+
};
|
|
105
|
+
}, undefined>>,
|
|
101
106
|
import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"accessibilityUtils", {
|
|
102
107
|
dependencies: [
|
|
103
108
|
];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "7.25.
|
|
3
|
+
"version": "7.25.16",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -31,10 +31,11 @@
|
|
|
31
31
|
"@atlaskit/adf-schema": "^40.9.0",
|
|
32
32
|
"@atlaskit/button": "^20.1.0",
|
|
33
33
|
"@atlaskit/custom-steps": "^0.7.0",
|
|
34
|
-
"@atlaskit/editor-common": "^88.
|
|
34
|
+
"@atlaskit/editor-common": "^88.5.0",
|
|
35
35
|
"@atlaskit/editor-palette": "1.6.0",
|
|
36
36
|
"@atlaskit/editor-plugin-accessibility-utils": "^1.2.0",
|
|
37
37
|
"@atlaskit/editor-plugin-analytics": "^1.8.0",
|
|
38
|
+
"@atlaskit/editor-plugin-batch-attribute-updates": "1.0.0",
|
|
38
39
|
"@atlaskit/editor-plugin-content-insertion": "^1.8.0",
|
|
39
40
|
"@atlaskit/editor-plugin-editor-viewmode": "^2.1.0",
|
|
40
41
|
"@atlaskit/editor-plugin-guideline": "^1.2.0",
|
|
@@ -111,6 +112,9 @@
|
|
|
111
112
|
"platform.editor.table.use-increased-scaling-percent": {
|
|
112
113
|
"type": "boolean"
|
|
113
114
|
},
|
|
115
|
+
"platform_editor_batch_steps_table": {
|
|
116
|
+
"type": "boolean"
|
|
117
|
+
},
|
|
114
118
|
"platform_editor_dark_mode_cell_header_color_fix": {
|
|
115
119
|
"type": "boolean"
|
|
116
120
|
},
|
|
@@ -483,21 +483,24 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
483
483
|
}
|
|
484
484
|
|
|
485
485
|
let scalePercent = 1;
|
|
486
|
-
if (
|
|
487
|
-
!this.props.options?.isCommentEditor ||
|
|
488
|
-
(this.props.options?.isCommentEditor && tableNode.attrs.width)
|
|
489
|
-
) {
|
|
490
|
-
scalePercent = getTableScalingPercent(
|
|
491
|
-
tableNode,
|
|
492
|
-
this.table!,
|
|
493
|
-
shouldUseIncreasedScalingPercent,
|
|
494
|
-
);
|
|
495
|
-
} else {
|
|
496
|
-
scalePercent = getScalingPercentForTableWithoutWidth(tableNode, this.table!);
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
// Request animation frame required for Firefox
|
|
500
486
|
requestAnimationFrame(() => {
|
|
487
|
+
// Scaling percent has to be calculated inside requestAnimationFrame, otherwise
|
|
488
|
+
// renderWidth calculated as `tableRef?.parentElement?.clientWidth`
|
|
489
|
+
// inside of getTableScalingPercent returns 0.
|
|
490
|
+
if (
|
|
491
|
+
!this.props.options?.isCommentEditor ||
|
|
492
|
+
(this.props.options?.isCommentEditor && tableNode.attrs.width)
|
|
493
|
+
) {
|
|
494
|
+
scalePercent = getTableScalingPercent(
|
|
495
|
+
tableNode,
|
|
496
|
+
this.table!,
|
|
497
|
+
shouldUseIncreasedScalingPercent,
|
|
498
|
+
);
|
|
499
|
+
} else {
|
|
500
|
+
scalePercent = getScalingPercentForTableWithoutWidth(tableNode, this.table!);
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
// Request animation frame required for Firefox
|
|
501
504
|
updateColgroup(
|
|
502
505
|
resizeState,
|
|
503
506
|
this.table!,
|
package/src/plugin.tsx
CHANGED
|
@@ -28,6 +28,7 @@ import { browser } from '@atlaskit/editor-common/utils';
|
|
|
28
28
|
import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
|
|
29
29
|
import type { AccessibilityUtilsPlugin } from '@atlaskit/editor-plugin-accessibility-utils';
|
|
30
30
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
31
|
+
import type { BatchAttributeUpdatesPlugin } from '@atlaskit/editor-plugin-batch-attribute-updates';
|
|
31
32
|
import type { ContentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
|
|
32
33
|
import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmode';
|
|
33
34
|
import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
|
|
@@ -136,6 +137,7 @@ export type TablePlugin = NextEditorPlugin<
|
|
|
136
137
|
WidthPlugin,
|
|
137
138
|
GuidelinePlugin,
|
|
138
139
|
SelectionPlugin,
|
|
140
|
+
OptionalPlugin<BatchAttributeUpdatesPlugin>,
|
|
139
141
|
OptionalPlugin<AccessibilityUtilsPlugin>,
|
|
140
142
|
OptionalPlugin<MediaPlugin>,
|
|
141
143
|
OptionalPlugin<EditorViewModePlugin>,
|
|
@@ -135,7 +135,7 @@ export const getTableScalingPercent = (
|
|
|
135
135
|
: MAX_SCALING_PERCENT;
|
|
136
136
|
|
|
137
137
|
const tableWidth = getTableContainerElementWidth(table);
|
|
138
|
-
|
|
138
|
+
const renderWidth = tableRef?.parentElement?.clientWidth || tableWidth;
|
|
139
139
|
// minus 1 here to avoid any 1px scroll in Firefox
|
|
140
140
|
let scalePercent = (renderWidth - 1) / tableWidth;
|
|
141
141
|
scalePercent = Math.max(scalePercent, 1 - maxScalingPercent);
|
|
@@ -6,6 +6,7 @@ import { AttrStep } from '@atlaskit/editor-prosemirror/transform';
|
|
|
6
6
|
import type { ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
|
|
7
7
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
8
8
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
9
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
10
|
|
|
10
11
|
import type { ResizeState } from '../pm-plugins/table-resizing/utils';
|
|
11
12
|
import {
|
|
@@ -30,12 +31,12 @@ export const updateColumnWidths =
|
|
|
30
31
|
resizeState: ResizeState,
|
|
31
32
|
table: PMNode,
|
|
32
33
|
start: number,
|
|
33
|
-
|
|
34
|
-
_api: PluginInjectionAPI | undefined | null,
|
|
34
|
+
api: PluginInjectionAPI | undefined | null,
|
|
35
35
|
) =>
|
|
36
36
|
(tr: Transaction): Transaction => {
|
|
37
37
|
const map = TableMap.get(table);
|
|
38
38
|
const updatedCellsAttrs: { [key: number]: CellAttributes } = {};
|
|
39
|
+
const steps: Array<AttrStep> = [];
|
|
39
40
|
|
|
40
41
|
// calculating new attributes for each cell
|
|
41
42
|
for (let columnIndex = 0; columnIndex < map.width; columnIndex++) {
|
|
@@ -89,13 +90,22 @@ export const updateColumnWidths =
|
|
|
89
90
|
const cell = table.nodeAt(pos);
|
|
90
91
|
if (!seen[pos] && cell) {
|
|
91
92
|
if (updatedCellsAttrs[pos]) {
|
|
92
|
-
|
|
93
|
+
steps.push(new AttrStep(pos + start, 'colwidth', updatedCellsAttrs[pos].colwidth));
|
|
93
94
|
}
|
|
94
95
|
seen[pos] = true;
|
|
95
96
|
}
|
|
96
97
|
}
|
|
97
98
|
}
|
|
98
99
|
|
|
100
|
+
if (api?.batchAttributeUpdates && fg('platform_editor_batch_steps_table')) {
|
|
101
|
+
const batchStep = api.batchAttributeUpdates.actions.batchSteps({ steps, doc: tr.doc });
|
|
102
|
+
tr.step(batchStep);
|
|
103
|
+
} else {
|
|
104
|
+
steps.forEach((s) => {
|
|
105
|
+
tr.step(s);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
99
109
|
return tr;
|
|
100
110
|
};
|
|
101
111
|
|
package/tsconfig.app.json
CHANGED