@atlaskit/editor-plugin-table 8.4.5 → 8.4.7
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/OverflowShadowsObserver.js +1 -2
- package/dist/cjs/nodeviews/TableCell.js +6 -9
- package/dist/cjs/nodeviews/TableComponent.js +46 -41
- package/dist/cjs/nodeviews/TableRow.js +15 -18
- package/dist/cjs/nodeviews/TableStickyScrollbar.js +1 -2
- package/dist/cjs/nodeviews/table.js +17 -14
- package/dist/cjs/pm-plugins/plugin-key.js +3 -0
- package/dist/cjs/pm-plugins/table-resizing/plugin.js +1 -2
- package/dist/cjs/types/index.js +1 -1
- package/dist/cjs/ui/FloatingContextualMenu/ContextualMenu.js +26 -29
- package/dist/cjs/ui/FloatingDeleteButton/index.js +11 -14
- package/dist/cjs/ui/FloatingInsertButton/InsertButton.js +1 -2
- package/dist/cjs/ui/FloatingInsertButton/index.js +7 -10
- package/dist/cjs/ui/TableFloatingControls/CornerControls/ClassicCornerControls.js +9 -12
- package/dist/cjs/ui/TableFloatingControls/NumberColumn/index.js +11 -15
- package/dist/cjs/ui/TableFloatingControls/RowControls/ClassicControls.js +6 -9
- package/dist/cjs/ui/common-styles.js +2 -0
- package/dist/cjs/ui/consts.js +3 -0
- package/dist/es2019/index.js +3 -0
- package/dist/es2019/nodeviews/TableComponent.js +17 -7
- package/dist/es2019/nodeviews/table.js +7 -2
- package/dist/es2019/pm-plugins/commands/index.js +3 -0
- package/dist/es2019/pm-plugins/plugin-key.js +3 -0
- package/dist/es2019/types/index.js +3 -0
- package/dist/es2019/ui/common-styles.js +3 -0
- package/dist/es2019/ui/consts.js +3 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/nodeviews/OverflowShadowsObserver.js +1 -2
- package/dist/esm/nodeviews/TableCell.js +6 -9
- package/dist/esm/nodeviews/TableComponent.js +46 -41
- package/dist/esm/nodeviews/TableRow.js +15 -18
- package/dist/esm/nodeviews/TableStickyScrollbar.js +1 -2
- package/dist/esm/nodeviews/table.js +17 -14
- package/dist/esm/pm-plugins/commands/index.js +3 -0
- package/dist/esm/pm-plugins/plugin-key.js +3 -0
- package/dist/esm/pm-plugins/table-resizing/plugin.js +1 -2
- package/dist/esm/types/index.js +3 -0
- package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +26 -29
- package/dist/esm/ui/FloatingDeleteButton/index.js +11 -14
- package/dist/esm/ui/FloatingInsertButton/InsertButton.js +1 -2
- package/dist/esm/ui/FloatingInsertButton/index.js +7 -10
- package/dist/esm/ui/TableFloatingControls/CornerControls/ClassicCornerControls.js +9 -12
- package/dist/esm/ui/TableFloatingControls/NumberColumn/index.js +11 -15
- package/dist/esm/ui/TableFloatingControls/RowControls/ClassicControls.js +6 -9
- package/dist/esm/ui/common-styles.js +3 -0
- package/dist/esm/ui/consts.js +3 -0
- package/dist/types/types/index.d.ts +3 -0
- package/dist/types-ts4.5/types/index.d.ts +3 -0
- package/package.json +7 -4
- package/src/index.ts +3 -0
- package/src/nodeviews/TableComponent.tsx +24 -4
- package/src/nodeviews/table.tsx +11 -2
- package/src/pm-plugins/commands/index.ts +3 -0
- package/src/pm-plugins/plugin-key.ts +3 -0
- package/src/types/index.ts +3 -0
- package/src/ui/common-styles.ts +3 -0
- package/src/ui/consts.ts +3 -0
package/dist/es2019/index.js
CHANGED
|
@@ -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
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/* eslint-disable @atlaskit/editor/no-re-export */
|
|
2
|
+
// Entry file in package.json
|
|
3
|
+
|
|
1
4
|
export { hoverColumns, hoverRows, hoverTable, hoverCell, hoverMergedCells, clearHoverSelection, showResizeHandleLine, hideResizeHandleLine, setTableHovered } from './hover';
|
|
2
5
|
export { insertColumn, insertRow, createTable } from './insert';
|
|
3
6
|
export { getNextLayout, toggleContextualMenu, toggleHeaderColumn, toggleHeaderRow, toggleNumberColumn, toggleTableLayout } from './toggle';
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/* eslint-disable @atlaskit/editor/no-re-export */
|
|
2
|
+
// Entry file in package.json
|
|
3
|
+
|
|
1
4
|
import { tableCellSelector, tableHeaderSelector, tablePrefixSelector } from '@atlaskit/adf-schema';
|
|
2
5
|
import { TableSharedCssClassName } from '@atlaskit/editor-common/styles';
|
|
3
6
|
export const RESIZE_HANDLE_AREA_DECORATION_GAP = 30;
|
package/dist/es2019/ui/consts.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/* eslint-disable @atlaskit/editor/no-re-export */
|
|
2
|
+
// Entry file in package.json
|
|
3
|
+
|
|
1
4
|
import { tableCellBorderWidth, tableMarginTop } from '@atlaskit/editor-common/styles';
|
|
2
5
|
import { akEditorTableBorder, akEditorTableBorderSelected, akEditorTableCellBlanketDeleted, akEditorTableCellBlanketSelected, akEditorTableHeaderCellBackground, akEditorTableToolbar, akEditorTableToolbarSize, akEditorUnitZIndex, akRichMediaResizeZIndex } from '@atlaskit/editor-shared-styles';
|
|
3
6
|
import { B200, N0, N20, N200, N20A, N300, R300, R400, R75 } from '@atlaskit/theme/colors';
|
package/dist/esm/index.js
CHANGED
|
@@ -93,7 +93,7 @@ export var OverflowShadowsObserver = /*#__PURE__*/function () {
|
|
|
93
93
|
this.wrapper = wrapper;
|
|
94
94
|
this.init();
|
|
95
95
|
}
|
|
96
|
-
_createClass(OverflowShadowsObserver, [{
|
|
96
|
+
return _createClass(OverflowShadowsObserver, [{
|
|
97
97
|
key: "updateStickyShadowsHeightIfChanged",
|
|
98
98
|
value: function updateStickyShadowsHeightIfChanged() {
|
|
99
99
|
if (!this.isSticky) {
|
|
@@ -122,5 +122,4 @@ export var OverflowShadowsObserver = /*#__PURE__*/function () {
|
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
}]);
|
|
125
|
-
return OverflowShadowsObserver;
|
|
126
125
|
}();
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
2
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
3
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
|
-
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
5
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
6
4
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
7
5
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
6
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
8
7
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
9
|
-
function
|
|
8
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
10
9
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
11
10
|
import { getCellAttrs, getCellDomAttrs } from '@atlaskit/adf-schema';
|
|
12
11
|
import { ACTION_SUBJECT, EVENT_TYPE, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
|
|
@@ -37,12 +36,10 @@ function delayUntilIdle(cb) {
|
|
|
37
36
|
}
|
|
38
37
|
var cssVariablePattern = /^VAR\(--.*\)$/;
|
|
39
38
|
var TableCell = /*#__PURE__*/function (_TableNodeView) {
|
|
40
|
-
_inherits(TableCell, _TableNodeView);
|
|
41
|
-
var _super = _createSuper(TableCell);
|
|
42
39
|
function TableCell(node, view, getPos, eventDispatcher, editorAnalyticsAPI) {
|
|
43
40
|
var _this;
|
|
44
41
|
_classCallCheck(this, TableCell);
|
|
45
|
-
_this =
|
|
42
|
+
_this = _callSuper(this, TableCell, [node, view, getPos, eventDispatcher]);
|
|
46
43
|
|
|
47
44
|
// CONFCLOUD-78239: Previously we had a bug which tried to invert the heading colour of a table
|
|
48
45
|
// Obviously design tokens can't be inverted and so it would result in `VAR(--DS-BACKGROUND-ACCENT-GRAY-SUBTLEST, #F4F5F7)`
|
|
@@ -54,7 +51,7 @@ var TableCell = /*#__PURE__*/function (_TableNodeView) {
|
|
|
54
51
|
// This is a workaround to fix those cases on the fly. Note it is super specific on purpose
|
|
55
52
|
// so that it just fixes the heading token (other tokens should be unaffected)
|
|
56
53
|
// At some point in the future
|
|
57
|
-
_defineProperty(
|
|
54
|
+
_defineProperty(_this, "destroy", function () {
|
|
58
55
|
if (_this.delayHandle && typeof window !== 'undefined') {
|
|
59
56
|
var _window, _window$cancelIdleCal, _window2, _window2$cancelAnimat;
|
|
60
57
|
// eslint-disable-next-line compat/compat
|
|
@@ -82,7 +79,8 @@ var TableCell = /*#__PURE__*/function (_TableNodeView) {
|
|
|
82
79
|
}
|
|
83
80
|
return _this;
|
|
84
81
|
}
|
|
85
|
-
|
|
82
|
+
_inherits(TableCell, _TableNodeView);
|
|
83
|
+
return _createClass(TableCell, [{
|
|
86
84
|
key: "update",
|
|
87
85
|
value: function update(node) {
|
|
88
86
|
var didUpdate = this.updateNodeView(node);
|
|
@@ -140,6 +138,5 @@ var TableCell = /*#__PURE__*/function (_TableNodeView) {
|
|
|
140
138
|
return false;
|
|
141
139
|
}
|
|
142
140
|
}]);
|
|
143
|
-
return TableCell;
|
|
144
141
|
}(TableNodeView);
|
|
145
142
|
export { TableCell as default };
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
2
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
3
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
|
-
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
5
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
6
4
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
7
5
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
6
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
8
7
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
9
8
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
10
9
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
11
10
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
12
11
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
13
12
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _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; }
|
|
14
|
-
function
|
|
13
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
15
14
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
16
15
|
import React from 'react';
|
|
17
16
|
import classnames from 'classnames';
|
|
@@ -63,30 +62,27 @@ var isOverflowAnalyticsEnabled = false;
|
|
|
63
62
|
var NESTED_TABLE_IN_NESTED_PARENT_WIDTH_DIFF_MIN_THRESHOLD = 2;
|
|
64
63
|
var NESTED_TABLE_IN_NESTED_PARENT_WIDTH_DIFF_MAX_THRESHOLD = 20;
|
|
65
64
|
var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
66
|
-
_inherits(TableComponent, _React$Component);
|
|
67
|
-
var _super = _createSuper(TableComponent);
|
|
68
65
|
function TableComponent(props) {
|
|
69
|
-
var _defineProperty2;
|
|
70
66
|
var _this;
|
|
71
67
|
_classCallCheck(this, TableComponent);
|
|
72
|
-
_this =
|
|
73
|
-
_defineProperty(
|
|
68
|
+
_this = _callSuper(this, TableComponent, [props]);
|
|
69
|
+
_defineProperty(_this, "state", _defineProperty(_defineProperty(_defineProperty(_defineProperty({
|
|
74
70
|
scroll: 0,
|
|
75
71
|
parentWidth: undefined
|
|
76
|
-
},
|
|
77
|
-
_defineProperty(
|
|
72
|
+
}, ShadowEvent.SHOW_BEFORE_SHADOW, false), ShadowEvent.SHOW_AFTER_SHADOW, false), "tableWrapperWidth", undefined), "tableWrapperHeight", undefined));
|
|
73
|
+
_defineProperty(_this, "handleMouseOut", function (event) {
|
|
78
74
|
if (!isTableInFocus(_this.props.view)) {
|
|
79
75
|
return false;
|
|
80
76
|
}
|
|
81
77
|
return handleMouseOut(_this.props.view, event);
|
|
82
78
|
});
|
|
83
|
-
_defineProperty(
|
|
79
|
+
_defineProperty(_this, "handleMouseOver", function (event) {
|
|
84
80
|
if (!isTableInFocus(_this.props.view)) {
|
|
85
81
|
return false;
|
|
86
82
|
}
|
|
87
83
|
return withCellTracking(handleMouseOver)(_this.props.view, event);
|
|
88
84
|
});
|
|
89
|
-
_defineProperty(
|
|
85
|
+
_defineProperty(_this, "handleMouseEnter", function () {
|
|
90
86
|
var node = _this.props.getNode();
|
|
91
87
|
var pos = _this.props.getPos();
|
|
92
88
|
var tr = _this.props.view.state.tr;
|
|
@@ -94,13 +90,13 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
94
90
|
tr.setMeta('mouseEnterTable', [tableId, node, pos]);
|
|
95
91
|
_this.props.view.dispatch(tr);
|
|
96
92
|
});
|
|
97
|
-
_defineProperty(
|
|
93
|
+
_defineProperty(_this, "updateShadowState", function (shadowKey, value) {
|
|
98
94
|
if (_this.state[shadowKey] === value) {
|
|
99
95
|
return;
|
|
100
96
|
}
|
|
101
97
|
_this.setState(_defineProperty({}, shadowKey, value));
|
|
102
98
|
});
|
|
103
|
-
_defineProperty(
|
|
99
|
+
_defineProperty(_this, "createShadowSentinels", function (table) {
|
|
104
100
|
if (table) {
|
|
105
101
|
var shadowSentinelLeft = document.createElement('span');
|
|
106
102
|
shadowSentinelLeft.className = ClassName.TABLE_SHADOW_SENTINEL_LEFT;
|
|
@@ -110,7 +106,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
110
106
|
table.prepend(shadowSentinelRight);
|
|
111
107
|
}
|
|
112
108
|
});
|
|
113
|
-
_defineProperty(
|
|
109
|
+
_defineProperty(_this, "onStickyState", function (state) {
|
|
114
110
|
var pos = _this.props.getPos();
|
|
115
111
|
if (!isValidPosition(pos, _this.props.view.state)) {
|
|
116
112
|
return;
|
|
@@ -125,8 +121,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
125
121
|
}
|
|
126
122
|
}
|
|
127
123
|
});
|
|
128
|
-
_defineProperty(
|
|
129
|
-
_defineProperty(
|
|
124
|
+
_defineProperty(_this, "prevTableState", null);
|
|
125
|
+
_defineProperty(_this, "handleScroll", function (event) {
|
|
130
126
|
if (!_this.wrapper || event.target !== _this.wrapper) {
|
|
131
127
|
return;
|
|
132
128
|
}
|
|
@@ -144,7 +140,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
144
140
|
}
|
|
145
141
|
_this.setState(_defineProperty({}, ShadowEvent.SHOW_BEFORE_SHADOW, _this.wrapper.scrollLeft !== 0));
|
|
146
142
|
});
|
|
147
|
-
_defineProperty(
|
|
143
|
+
_defineProperty(_this, "handleTableResizing", function () {
|
|
148
144
|
var _this$props = _this.props,
|
|
149
145
|
getNode = _this$props.getNode,
|
|
150
146
|
containerWidth = _this$props.containerWidth,
|
|
@@ -207,7 +203,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
207
203
|
_this.layoutSize = layoutSize;
|
|
208
204
|
});
|
|
209
205
|
// Function gets called when table is nested.
|
|
210
|
-
_defineProperty(
|
|
206
|
+
_defineProperty(_this, "scaleTable", function (scaleOptions) {
|
|
211
207
|
var isUserTriggered = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
212
208
|
var _this$props2 = _this.props,
|
|
213
209
|
view = _this$props2.view,
|
|
@@ -240,7 +236,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
240
236
|
}
|
|
241
237
|
dispatch(tr);
|
|
242
238
|
});
|
|
243
|
-
_defineProperty(
|
|
239
|
+
_defineProperty(_this, "setTimerToSendInitialOverflowCaptured", function (isOverflowing) {
|
|
244
240
|
var _this$state;
|
|
245
241
|
var _this$props3 = _this.props,
|
|
246
242
|
dispatchAnalyticsEvent = _this$props3.dispatchAnalyticsEvent,
|
|
@@ -264,7 +260,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
264
260
|
_this.isInitialOverflowSent = true;
|
|
265
261
|
}, initialOverflowCaptureTimeroutDelay);
|
|
266
262
|
});
|
|
267
|
-
_defineProperty(
|
|
263
|
+
_defineProperty(_this, "handleAutoSize", function () {
|
|
268
264
|
if (_this.table) {
|
|
269
265
|
var _this$props4 = _this.props,
|
|
270
266
|
view = _this$props4.view,
|
|
@@ -281,7 +277,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
281
277
|
});
|
|
282
278
|
}
|
|
283
279
|
});
|
|
284
|
-
_defineProperty(
|
|
280
|
+
_defineProperty(_this, "handleWindowResize", function () {
|
|
285
281
|
var _this$props5 = _this.props,
|
|
286
282
|
getNode = _this$props5.getNode,
|
|
287
283
|
containerWidth = _this$props5.containerWidth;
|
|
@@ -295,7 +291,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
295
291
|
parentWidth: parentWidth
|
|
296
292
|
});
|
|
297
293
|
});
|
|
298
|
-
_defineProperty(
|
|
294
|
+
_defineProperty(_this, "getParentNodeWidth", function () {
|
|
299
295
|
var _this$props6 = _this.props,
|
|
300
296
|
getPos = _this$props6.getPos,
|
|
301
297
|
containerWidth = _this$props6.containerWidth,
|
|
@@ -308,25 +304,28 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
308
304
|
var parentNodeWith = getParentNodeWidth(pos, state, containerWidth, options && options.isFullWidthModeEnabled);
|
|
309
305
|
return parentNodeWith;
|
|
310
306
|
});
|
|
311
|
-
_defineProperty(
|
|
307
|
+
_defineProperty(_this, "updateParentWidth", function (width) {
|
|
312
308
|
_this.setState({
|
|
313
309
|
parentWidth: width
|
|
314
310
|
});
|
|
315
311
|
});
|
|
316
|
-
_defineProperty(
|
|
312
|
+
_defineProperty(_this, "tableNodeLayoutSize", function (node, containerWidth, options) {
|
|
317
313
|
return getLayoutSize(node.attrs.layout, containerWidth || _this.props.containerWidth.width, options || _this.props.options || {});
|
|
318
314
|
});
|
|
319
|
-
_defineProperty(
|
|
320
|
-
_defineProperty(
|
|
321
|
-
_defineProperty(
|
|
322
|
-
_defineProperty(
|
|
323
|
-
_defineProperty(
|
|
315
|
+
_defineProperty(_this, "scaleTableDebounced", rafSchedule(_this.scaleTable));
|
|
316
|
+
_defineProperty(_this, "handleTableResizingDebounced", rafSchedule(_this.handleTableResizing));
|
|
317
|
+
_defineProperty(_this, "handleScrollDebounced", rafSchedule(_this.handleScroll));
|
|
318
|
+
_defineProperty(_this, "handleAutoSizeDebounced", rafSchedule(_this.handleAutoSize));
|
|
319
|
+
_defineProperty(_this, "handleWindowResizeDebounced", rafSchedule(_this.handleWindowResize));
|
|
324
320
|
var _options = props.options,
|
|
325
321
|
_containerWidth = props.containerWidth,
|
|
326
322
|
_getNode = props.getNode;
|
|
327
323
|
_this.node = _getNode();
|
|
328
324
|
_this.containerWidth = _containerWidth;
|
|
329
325
|
_this.isInitialOverflowSent = false;
|
|
326
|
+
if (!_this.updateColGroupFromFullWidthChange) {
|
|
327
|
+
_this.updateColGroupFromFullWidthChange = (_options === null || _options === void 0 ? void 0 : _options.isFullWidthModeEnabled) && !(_options !== null && _options !== void 0 && _options.wasFullWidthModeEnabled);
|
|
328
|
+
}
|
|
330
329
|
|
|
331
330
|
// store table size using previous full-width mode so can detect if it has changed.
|
|
332
331
|
var isFullWidthModeEnabled = _options ? _options.wasFullWidthModeEnabled : false;
|
|
@@ -368,7 +367,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
368
367
|
}
|
|
369
368
|
return _this;
|
|
370
369
|
}
|
|
371
|
-
|
|
370
|
+
_inherits(TableComponent, _React$Component);
|
|
371
|
+
return _createClass(TableComponent, [{
|
|
372
372
|
key: "componentDidMount",
|
|
373
373
|
value: function componentDidMount() {
|
|
374
374
|
var _this$table,
|
|
@@ -515,7 +515,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
515
515
|
}, {
|
|
516
516
|
key: "handleColgroupUpdates",
|
|
517
517
|
value: function handleColgroupUpdates() {
|
|
518
|
-
var
|
|
518
|
+
var _this$containerWidth,
|
|
519
|
+
_this3 = this;
|
|
519
520
|
var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
520
521
|
var _this$props10 = this.props,
|
|
521
522
|
getNode = _this$props10.getNode,
|
|
@@ -548,16 +549,19 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
548
549
|
var isTableSquashed = tableRenderWidth < tableNodeWidth;
|
|
549
550
|
var isNumberColumnChanged = tableNode.attrs.isNumberColumnEnabled !== this.node.attrs.isNumberColumnEnabled;
|
|
550
551
|
var isNumberOfColumnsChanged = tablesHaveDifferentNoOfColumns(tableNode, this.node);
|
|
552
|
+
var containerWidthValue = containerWidth.width,
|
|
553
|
+
containerLineLength = containerWidth.lineLength;
|
|
554
|
+
var isLineLengthChanged = ((_this$containerWidth = this.containerWidth) === null || _this$containerWidth === void 0 ? void 0 : _this$containerWidth.lineLength) !== containerLineLength;
|
|
555
|
+
var isFullWidthModeAndLineLengthChanged = this.updateColGroupFromFullWidthChange && isLineLengthChanged && fg('platform_editor_table_overflow_in_full_width_fix');
|
|
551
556
|
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;
|
|
557
|
+
if (force || maybeScale || isFullWidthModeAndLineLengthChanged) {
|
|
558
|
+
var _this$containerWidth2, _this$props$options, _this$props$options2, _this$props$options3;
|
|
559
|
+
var isWidthChanged = ((_this$containerWidth2 = this.containerWidth) === null || _this$containerWidth2 === void 0 ? void 0 : _this$containerWidth2.width) !== containerWidthValue;
|
|
556
560
|
var wasTableResized = hasTableBeenResized(this.node);
|
|
557
561
|
var isTableResized = hasTableBeenResized(tableNode);
|
|
558
562
|
var isColumnsDistributed = wasTableResized && !isTableResized;
|
|
559
563
|
var isTableDisplayModeChanged = this.node.attrs.displayMode !== tableNode.attrs.displayMode;
|
|
560
|
-
var shouldUpdateColgroup = isWidthChanged || isColumnsDistributed || isTableResizedFullWidth || isTableWidthChanged || isTableDisplayModeChanged || isNumberColumnChanged || isNumberOfColumnsChanged;
|
|
564
|
+
var shouldUpdateColgroup = isWidthChanged || isColumnsDistributed || isTableResizedFullWidth || isTableWidthChanged || isTableDisplayModeChanged || isNumberColumnChanged || isNumberOfColumnsChanged || isFullWidthModeAndLineLengthChanged;
|
|
561
565
|
var _getEditorFeatureFlag3 = getEditorFeatureFlags(),
|
|
562
566
|
_getEditorFeatureFlag4 = _getEditorFeatureFlag3.tableWithFixedColumnWidthsOption,
|
|
563
567
|
tableWithFixedColumnWidthsOption = _getEditorFeatureFlag4 === void 0 ? false : _getEditorFeatureFlag4;
|
|
@@ -604,6 +608,9 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
604
608
|
});
|
|
605
609
|
}
|
|
606
610
|
}
|
|
611
|
+
if (isFullWidthModeAndLineLengthChanged) {
|
|
612
|
+
this.updateColGroupFromFullWidthChange = false;
|
|
613
|
+
}
|
|
607
614
|
this.tableNodeWidth = tableNodeWidth;
|
|
608
615
|
this.wasResizing = isResizing;
|
|
609
616
|
this.containerWidth = containerWidth;
|
|
@@ -742,8 +749,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
742
749
|
var _this5 = this,
|
|
743
750
|
_this$state$stickyHea2,
|
|
744
751
|
_this$state$stickyHea3,
|
|
745
|
-
_this$props$options10
|
|
746
|
-
_classnames;
|
|
752
|
+
_this$props$options10;
|
|
747
753
|
var _this$props12 = this.props,
|
|
748
754
|
view = _this$props12.view,
|
|
749
755
|
getNode = _this$props12.getNode,
|
|
@@ -867,7 +873,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
867
873
|
return /*#__PURE__*/React.createElement(TableContainer
|
|
868
874
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
869
875
|
, {
|
|
870
|
-
className: classnames(ClassName.TABLE_CONTAINER, (
|
|
876
|
+
className: classnames(ClassName.TABLE_CONTAINER, _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, ClassName.WITH_CONTROLS, allowControls && tableActive), ClassName.TABLE_STICKY, this.state.stickyHeader && hasHeaderRow), ClassName.HOVERED_DELETE_BUTTON, isInDanger), ClassName.TABLE_SELECTED, isTableSelected(view.state.selection))),
|
|
871
877
|
editorView: view,
|
|
872
878
|
getPos: getPos,
|
|
873
879
|
node: node,
|
|
@@ -987,7 +993,6 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
987
993
|
}));
|
|
988
994
|
}
|
|
989
995
|
}]);
|
|
990
|
-
return TableComponent;
|
|
991
996
|
}(React.Component);
|
|
992
997
|
_defineProperty(TableComponent, "displayName", 'TableComponent');
|
|
993
998
|
export default injectIntl(TableComponent);
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
-
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
4
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
3
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
4
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
5
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
7
6
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
|
-
function
|
|
7
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
9
8
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
10
9
|
import debounce from 'lodash/debounce';
|
|
11
10
|
import throttle from 'lodash/throttle';
|
|
@@ -27,17 +26,15 @@ var HEADER_ROW_SCROLL_THROTTLE_TIMEOUT = 200;
|
|
|
27
26
|
// if too short it would trigger too many dom updates.
|
|
28
27
|
var HEADER_ROW_SCROLL_RESET_DEBOUNCE_TIMEOUT = 400;
|
|
29
28
|
var TableRow = /*#__PURE__*/function (_TableNodeView) {
|
|
30
|
-
_inherits(TableRow, _TableNodeView);
|
|
31
|
-
var _super = _createSuper(TableRow);
|
|
32
29
|
function TableRow(node, view, getPos, eventDispatcher) {
|
|
33
30
|
var _this;
|
|
34
31
|
_classCallCheck(this, TableRow);
|
|
35
|
-
_this =
|
|
36
|
-
_defineProperty(
|
|
37
|
-
_defineProperty(
|
|
38
|
-
_defineProperty(
|
|
39
|
-
_defineProperty(
|
|
40
|
-
_defineProperty(
|
|
32
|
+
_this = _callSuper(this, TableRow, [node, view, getPos, eventDispatcher]);
|
|
33
|
+
_defineProperty(_this, "colControlsOffset", 0);
|
|
34
|
+
_defineProperty(_this, "focused", false);
|
|
35
|
+
_defineProperty(_this, "topPosEditorElement", 0);
|
|
36
|
+
_defineProperty(_this, "sentinels", {});
|
|
37
|
+
_defineProperty(_this, "sentinelData", {
|
|
41
38
|
top: {
|
|
42
39
|
isIntersecting: false,
|
|
43
40
|
boundingClientRect: null,
|
|
@@ -49,19 +46,19 @@ var TableRow = /*#__PURE__*/function (_TableNodeView) {
|
|
|
49
46
|
rootBounds: null
|
|
50
47
|
}
|
|
51
48
|
});
|
|
52
|
-
_defineProperty(
|
|
53
|
-
_defineProperty(
|
|
54
|
-
_defineProperty(
|
|
49
|
+
_defineProperty(_this, "listening", false);
|
|
50
|
+
_defineProperty(_this, "padding", 0);
|
|
51
|
+
_defineProperty(_this, "top", 0);
|
|
55
52
|
/**
|
|
56
53
|
* Methods
|
|
57
54
|
*/
|
|
58
|
-
_defineProperty(
|
|
55
|
+
_defineProperty(_this, "headerRowMouseScrollEnd", debounce(function () {
|
|
59
56
|
_this.dom.classList.remove('no-pointer-events');
|
|
60
57
|
}, HEADER_ROW_SCROLL_RESET_DEBOUNCE_TIMEOUT));
|
|
61
58
|
// When the header is sticky, the header row is set to position: fixed
|
|
62
59
|
// This prevents mouse wheel scrolling on the scroll-parent div when user's mouse is hovering the header row.
|
|
63
60
|
// This fix sets pointer-events: none on the header row briefly to avoid this behaviour
|
|
64
|
-
_defineProperty(
|
|
61
|
+
_defineProperty(_this, "headerRowMouseScroll", throttle(function () {
|
|
65
62
|
if (_this.isSticky) {
|
|
66
63
|
_this.dom.classList.add('no-pointer-events');
|
|
67
64
|
_this.headerRowMouseScrollEnd();
|
|
@@ -84,7 +81,8 @@ var TableRow = /*#__PURE__*/function (_TableNodeView) {
|
|
|
84
81
|
/**
|
|
85
82
|
* Variables
|
|
86
83
|
*/
|
|
87
|
-
|
|
84
|
+
_inherits(TableRow, _TableNodeView);
|
|
85
|
+
return _createClass(TableRow, [{
|
|
88
86
|
key: "update",
|
|
89
87
|
value:
|
|
90
88
|
/**
|
|
@@ -577,6 +575,5 @@ var TableRow = /*#__PURE__*/function (_TableNodeView) {
|
|
|
577
575
|
}
|
|
578
576
|
}
|
|
579
577
|
}]);
|
|
580
|
-
return TableRow;
|
|
581
578
|
}(TableNodeView);
|
|
582
579
|
export { TableRow as default };
|
|
@@ -25,7 +25,7 @@ export var TableStickyScrollbar = /*#__PURE__*/function () {
|
|
|
25
25
|
this.init();
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
_createClass(TableStickyScrollbar, [{
|
|
28
|
+
return _createClass(TableStickyScrollbar, [{
|
|
29
29
|
key: "dispose",
|
|
30
30
|
value: function dispose() {
|
|
31
31
|
if (this.stickyScrollbarContainerElement) {
|
|
@@ -142,5 +142,4 @@ export var TableStickyScrollbar = /*#__PURE__*/function () {
|
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
144
|
}]);
|
|
145
|
-
return TableStickyScrollbar;
|
|
146
145
|
}();
|