@atlaskit/editor-plugin-table 15.4.21 → 15.4.22
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 +10 -0
- package/dist/cjs/nodeviews/{TableComponentNext.js → TableComponent.js} +3 -3
- package/dist/cjs/nodeviews/TableComponentWithSharedState.js +2 -9
- package/dist/cjs/nodeviews/toDOM.js +1 -32
- package/dist/cjs/pm-plugins/table-resizing/utils/consts.js +0 -1
- package/dist/cjs/ui/common-styles.js +7 -14
- package/dist/es2019/nodeviews/{TableComponentNext.js → TableComponent.js} +3 -3
- package/dist/es2019/nodeviews/TableComponentWithSharedState.js +1 -6
- package/dist/es2019/nodeviews/toDOM.js +1 -32
- package/dist/es2019/pm-plugins/table-resizing/utils/consts.js +0 -1
- package/dist/es2019/ui/common-styles.js +39 -52
- package/dist/esm/nodeviews/{TableComponentNext.js → TableComponent.js} +3 -3
- package/dist/esm/nodeviews/TableComponentWithSharedState.js +1 -8
- package/dist/esm/nodeviews/toDOM.js +1 -32
- package/dist/esm/pm-plugins/table-resizing/utils/consts.js +0 -1
- package/dist/esm/ui/common-styles.js +8 -15
- package/dist/types/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.d.ts +1 -1
- package/dist/types/ui/icons/DragHandleDisabledIcon.d.ts +1 -1
- package/dist/types-ts4.5/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.d.ts +1 -1
- package/dist/types-ts4.5/ui/icons/DragHandleDisabledIcon.d.ts +1 -1
- package/package.json +9 -4
- package/dist/cjs/nodeviews/TableComponentLegacy.js +0 -1141
- package/dist/es2019/nodeviews/TableComponentLegacy.js +0 -1114
- package/dist/esm/nodeviews/TableComponentLegacy.js +0 -1135
- package/dist/types/nodeviews/TableComponentLegacy.d.ts +0 -47
- package/dist/types/nodeviews/TableComponentNext.d.ts +0 -47
- /package/dist/{types-ts4.5/nodeviews/TableComponentNext.d.ts → types/nodeviews/TableComponent.d.ts} +0 -0
- /package/dist/types-ts4.5/nodeviews/{TableComponentLegacy.d.ts → TableComponent.d.ts} +0 -0
|
@@ -1,1141 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
10
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
11
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
12
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
13
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
14
|
-
var _defineProperty3 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
15
|
-
var _react = _interopRequireDefault(require("react"));
|
|
16
|
-
var _classnames2 = _interopRequireDefault(require("classnames"));
|
|
17
|
-
var _memoizeOne = _interopRequireDefault(require("memoize-one"));
|
|
18
|
-
var _rafSchd = _interopRequireDefault(require("raf-schd"));
|
|
19
|
-
var _reactIntlNext = require("react-intl-next");
|
|
20
|
-
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
21
|
-
var _browser = require("@atlaskit/editor-common/browser");
|
|
22
|
-
var _collab = require("@atlaskit/editor-common/collab");
|
|
23
|
-
var _nesting = require("@atlaskit/editor-common/nesting");
|
|
24
|
-
var _nodeVisibility = require("@atlaskit/editor-common/node-visibility");
|
|
25
|
-
var _nodeWidth = require("@atlaskit/editor-common/node-width");
|
|
26
|
-
var _styles = require("@atlaskit/editor-common/styles");
|
|
27
|
-
var _utils = require("@atlaskit/editor-common/utils");
|
|
28
|
-
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
29
|
-
var _utils2 = require("@atlaskit/editor-tables/utils");
|
|
30
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
31
|
-
var _combine = require("@atlaskit/pragmatic-drag-and-drop/combine");
|
|
32
|
-
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
33
|
-
var _commands = require("../pm-plugins/commands");
|
|
34
|
-
var _autoscrollers = require("../pm-plugins/drag-and-drop/utils/autoscrollers");
|
|
35
|
-
var _pluginKey = require("../pm-plugins/sticky-headers/plugin-key");
|
|
36
|
-
var _util = require("../pm-plugins/sticky-headers/util");
|
|
37
|
-
var _tableAnalytics = require("../pm-plugins/table-analytics");
|
|
38
|
-
var _colgroup = require("../pm-plugins/table-resizing/utils/colgroup");
|
|
39
|
-
var _consts = require("../pm-plugins/table-resizing/utils/consts");
|
|
40
|
-
var _dom = require("../pm-plugins/table-resizing/utils/dom");
|
|
41
|
-
var _misc = require("../pm-plugins/table-resizing/utils/misc");
|
|
42
|
-
var _resizeState = require("../pm-plugins/table-resizing/utils/resize-state");
|
|
43
|
-
var _scaleTable = require("../pm-plugins/table-resizing/utils/scale-table");
|
|
44
|
-
var _nodes = require("../pm-plugins/utils/nodes");
|
|
45
|
-
var _table = require("../pm-plugins/utils/table");
|
|
46
|
-
var _types = require("../types");
|
|
47
|
-
var _eventHandlers = require("../ui/event-handlers");
|
|
48
|
-
var _TableFloatingColumnControls = _interopRequireDefault(require("../ui/TableFloatingColumnControls"));
|
|
49
|
-
var _TableFloatingControls = _interopRequireDefault(require("../ui/TableFloatingControls"));
|
|
50
|
-
var _ExternalDropTargets = require("./ExternalDropTargets");
|
|
51
|
-
var _OverflowShadowsObserver = require("./OverflowShadowsObserver");
|
|
52
|
-
var _TableContainer = require("./TableContainer");
|
|
53
|
-
var _TableStickyScrollbar = require("./TableStickyScrollbar");
|
|
54
|
-
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; } } }; }
|
|
55
|
-
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; } }
|
|
56
|
-
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; }
|
|
57
|
-
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; }
|
|
58
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty3.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
59
|
-
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
|
|
60
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } // Ignored via go/ees005
|
|
61
|
-
// eslint-disable-next-line import/no-named-as-default
|
|
62
|
-
// When table is inserted via paste, keyboard shortcut or quickInsert,
|
|
63
|
-
// componentDidUpdate is called multiple times. The isOverflowing value is correct only on the last update.
|
|
64
|
-
// To make sure we capture the last update, we use setTimeout.
|
|
65
|
-
var initialOverflowCaptureTimeroutDelay = 300;
|
|
66
|
-
|
|
67
|
-
// This is a hard switch for controlling whether the overflow analytics should be dispatched. There has been 6months of data
|
|
68
|
-
// already collected which we could use but have not. This has been disabled rather then removed entirely in the event that
|
|
69
|
-
// the current collected data becomes stale and we want to start collecting fresh data again in future.
|
|
70
|
-
// PLEASE NOTE: that the current way this alaytics has been configured WILL cause reflows to occur. This is why the has been disabled.
|
|
71
|
-
var isOverflowAnalyticsEnabled = false;
|
|
72
|
-
|
|
73
|
-
// Prevent unnecessary parentWidth updates when table is nested inside of a node that is nested itself.
|
|
74
|
-
var NESTED_TABLE_IN_NESTED_PARENT_WIDTH_DIFF_MIN_THRESHOLD = 2;
|
|
75
|
-
var NESTED_TABLE_IN_NESTED_PARENT_WIDTH_DIFF_MAX_THRESHOLD = 20;
|
|
76
|
-
// Ignored via go/ees005
|
|
77
|
-
// eslint-disable-next-line @repo/internal/deprecations/deprecation-ticket-required
|
|
78
|
-
// @deprecated Please use TableComponentNext instead
|
|
79
|
-
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
80
|
-
var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
81
|
-
function TableComponent(props) {
|
|
82
|
-
var _this;
|
|
83
|
-
(0, _classCallCheck2.default)(this, TableComponent);
|
|
84
|
-
_this = _callSuper(this, TableComponent, [props]);
|
|
85
|
-
(0, _defineProperty3.default)(_this, "state", (0, _defineProperty3.default)((0, _defineProperty3.default)((0, _defineProperty3.default)((0, _defineProperty3.default)((0, _defineProperty3.default)({
|
|
86
|
-
scroll: 0,
|
|
87
|
-
parentWidth: undefined
|
|
88
|
-
}, _types.ShadowEvent.SHOW_BEFORE_SHADOW, false), _types.ShadowEvent.SHOW_AFTER_SHADOW, false), "tableWrapperWidth", undefined), "tableWrapperHeight", undefined), "windowResized", false));
|
|
89
|
-
(0, _defineProperty3.default)(_this, "handleMouseOut", function (event) {
|
|
90
|
-
if (!(0, _eventHandlers.isTableInFocus)(_this.props.view)) {
|
|
91
|
-
return false;
|
|
92
|
-
}
|
|
93
|
-
return (0, _eventHandlers.handleMouseOut)(_this.props.view, event);
|
|
94
|
-
});
|
|
95
|
-
(0, _defineProperty3.default)(_this, "handleMouseOver", function (event) {
|
|
96
|
-
if (!(0, _eventHandlers.isTableInFocus)(_this.props.view)) {
|
|
97
|
-
return false;
|
|
98
|
-
}
|
|
99
|
-
return (0, _eventHandlers.withCellTracking)(_eventHandlers.handleMouseOver)(_this.props.view, event);
|
|
100
|
-
});
|
|
101
|
-
(0, _defineProperty3.default)(_this, "handleMouseEnter", function () {
|
|
102
|
-
var node = _this.props.getNode();
|
|
103
|
-
var pos = _this.props.getPos();
|
|
104
|
-
var tr = _this.props.view.state.tr;
|
|
105
|
-
var tableId = node.attrs.localId;
|
|
106
|
-
tr.setMeta('mouseEnterTable', [tableId, node, pos]);
|
|
107
|
-
_this.props.view.dispatch(tr);
|
|
108
|
-
});
|
|
109
|
-
(0, _defineProperty3.default)(_this, "updateShadowState", function (shadowKey, value) {
|
|
110
|
-
if (_this.state[shadowKey] === value) {
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
_this.setState((0, _defineProperty3.default)({}, shadowKey, value));
|
|
114
|
-
});
|
|
115
|
-
(0, _defineProperty3.default)(_this, "createShadowSentinels", function (table) {
|
|
116
|
-
if (table) {
|
|
117
|
-
var shadowSentinelLeft = document.createElement('span');
|
|
118
|
-
shadowSentinelLeft.className = _types.TableCssClassName.TABLE_SHADOW_SENTINEL_LEFT;
|
|
119
|
-
var shadowSentinelRight = document.createElement('span');
|
|
120
|
-
shadowSentinelRight.className = _types.TableCssClassName.TABLE_SHADOW_SENTINEL_RIGHT;
|
|
121
|
-
table.prepend(shadowSentinelLeft);
|
|
122
|
-
table.prepend(shadowSentinelRight);
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
(0, _defineProperty3.default)(_this, "onStickyState", function (state) {
|
|
126
|
-
var pos = _this.props.getPos();
|
|
127
|
-
if (!(0, _utils.isValidPosition)(pos, _this.props.view.state)) {
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
var stickyHeader = (0, _util.findStickyHeaderForTable)(state, pos);
|
|
131
|
-
if (stickyHeader !== _this.state.stickyHeader) {
|
|
132
|
-
_this.setState({
|
|
133
|
-
stickyHeader: stickyHeader
|
|
134
|
-
});
|
|
135
|
-
if (_this.overflowShadowsObserver) {
|
|
136
|
-
_this.overflowShadowsObserver.updateStickyShadows();
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
// Ignored via go/ees005
|
|
141
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
142
|
-
(0, _defineProperty3.default)(_this, "prevTableState", null);
|
|
143
|
-
(0, _defineProperty3.default)(_this, "handleScroll", function (event) {
|
|
144
|
-
if (!_this.wrapper || event.target !== _this.wrapper) {
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
if (_this.stickyScrollbar) {
|
|
148
|
-
_this.stickyScrollbar.scrollLeft(_this.wrapper.scrollLeft);
|
|
149
|
-
}
|
|
150
|
-
if (_this.table) {
|
|
151
|
-
// sync sticky header row to table scroll
|
|
152
|
-
var headers = _this.table.querySelectorAll('tr[data-header-row]');
|
|
153
|
-
for (var i = 0; i < headers.length; i++) {
|
|
154
|
-
// Ignored via go/ees005
|
|
155
|
-
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
156
|
-
var header = headers[i];
|
|
157
|
-
header.scrollLeft = _this.wrapper.scrollLeft;
|
|
158
|
-
header.style.marginRight = '2px';
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
_this.setState((0, _defineProperty3.default)({}, _types.ShadowEvent.SHOW_BEFORE_SHADOW, _this.wrapper.scrollLeft !== 0));
|
|
162
|
-
});
|
|
163
|
-
(0, _defineProperty3.default)(_this, "handleTableResizing", function () {
|
|
164
|
-
var _this$props = _this.props,
|
|
165
|
-
getNode = _this$props.getNode,
|
|
166
|
-
containerWidth = _this$props.containerWidth,
|
|
167
|
-
options = _this$props.options,
|
|
168
|
-
allowTableResizing = _this$props.allowTableResizing;
|
|
169
|
-
// Ignored via go/ees005
|
|
170
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
171
|
-
var prevNode = _this.node;
|
|
172
|
-
var node = getNode();
|
|
173
|
-
var prevAttrs = prevNode.attrs;
|
|
174
|
-
var isNested = (0, _nodes.isTableNested)(_this.props.view.state, _this.props.getPos());
|
|
175
|
-
var parentWidth = _this.getParentNodeWidth();
|
|
176
|
-
if (isNested && (0, _nodes.isTableNestedInMoreThanOneNode)(_this.props.view.state, _this.props.getPos())) {
|
|
177
|
-
var resizeObsWrapperWidth = _this.wrapperWidth || 0;
|
|
178
|
-
var wrapperWidthDiffBetweenRerenders = Math.abs(resizeObsWrapperWidth - (_this.state.parentWidth || 0));
|
|
179
|
-
var isOusideOfThreshold = wrapperWidthDiffBetweenRerenders <= NESTED_TABLE_IN_NESTED_PARENT_WIDTH_DIFF_MIN_THRESHOLD || wrapperWidthDiffBetweenRerenders > NESTED_TABLE_IN_NESTED_PARENT_WIDTH_DIFF_MAX_THRESHOLD;
|
|
180
|
-
// 1. Check isOusideOfThreshold is added to prevent undersired state update.
|
|
181
|
-
// When table is nested in the extenstion and the table column is being resized,
|
|
182
|
-
// space available within extension can change and cause undesirable state update.
|
|
183
|
-
// MIN_THRESNESTED_TABLE_IN_NESTED_PARENT_WIDTH_DIFF_MIN_THRESHOLDHOLD value is required
|
|
184
|
-
// as the resizeObsWrapperWidth can differ between page reloads by 2px.
|
|
185
|
-
|
|
186
|
-
// 2. Check resizeObsWrapperWidth > 1 is added to prevent parentWidth update when table unmounts.
|
|
187
|
-
// When a is nested table in a nested expand and the expand collabses, the table unmounts and
|
|
188
|
-
// resizeObsWrapperWidth becomes 1.
|
|
189
|
-
parentWidth = isOusideOfThreshold && resizeObsWrapperWidth > 1 ? resizeObsWrapperWidth : _this.state.parentWidth;
|
|
190
|
-
}
|
|
191
|
-
var parentWidthChanged = parentWidth && parentWidth !== _this.state.parentWidth;
|
|
192
|
-
var layoutSize = _this.tableNodeLayoutSize(node, containerWidth.width, options);
|
|
193
|
-
var hasNumberedColumnChanged = prevAttrs.isNumberColumnEnabled !== node.attrs.isNumberColumnEnabled;
|
|
194
|
-
var noOfColumnsChanged = (0, _nodes.tablesHaveDifferentNoOfColumns)(node, prevNode);
|
|
195
|
-
if (
|
|
196
|
-
// We need to react if our parent changes
|
|
197
|
-
// Scales the cols widths relative to the new parent width.
|
|
198
|
-
parentWidthChanged ||
|
|
199
|
-
// Enabling / disabling this feature reduces or adds size to the table.
|
|
200
|
-
hasNumberedColumnChanged ||
|
|
201
|
-
// This last check is also to cater for dynamic text sizing changing the 'default' layout width
|
|
202
|
-
// Usually happens on window resize.
|
|
203
|
-
layoutSize !== _this.layoutSize || noOfColumnsChanged) {
|
|
204
|
-
var shouldScaleTable = (!allowTableResizing || allowTableResizing && isNested) && !hasNumberedColumnChanged && !noOfColumnsChanged;
|
|
205
|
-
|
|
206
|
-
// If column has been inserted/deleted avoid multi dispatch
|
|
207
|
-
if (shouldScaleTable) {
|
|
208
|
-
_this.scaleTable({
|
|
209
|
-
parentWidth: parentWidth
|
|
210
|
-
}, hasNumberedColumnChanged);
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
// only when table resizing is enabled and toggle numbered column to run scaleTable
|
|
214
|
-
if (allowTableResizing && hasNumberedColumnChanged) {
|
|
215
|
-
if (!(0, _colgroup.hasTableBeenResized)(prevNode)) {
|
|
216
|
-
_this.scaleTable({
|
|
217
|
-
parentWidth: node.attrs.width
|
|
218
|
-
}, true);
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
_this.updateParentWidth(parentWidth);
|
|
222
|
-
}
|
|
223
|
-
_this.node = node;
|
|
224
|
-
_this.containerWidth = containerWidth;
|
|
225
|
-
_this.layoutSize = layoutSize;
|
|
226
|
-
});
|
|
227
|
-
// Function gets called when table is nested.
|
|
228
|
-
(0, _defineProperty3.default)(_this, "scaleTable", function (scaleOptions) {
|
|
229
|
-
var isUserTriggered = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
230
|
-
var _this$props2 = _this.props,
|
|
231
|
-
view = _this$props2.view,
|
|
232
|
-
getNode = _this$props2.getNode,
|
|
233
|
-
getPos = _this$props2.getPos,
|
|
234
|
-
containerWidth = _this$props2.containerWidth,
|
|
235
|
-
options = _this$props2.options;
|
|
236
|
-
var node = getNode();
|
|
237
|
-
var state = view.state,
|
|
238
|
-
dispatch = view.dispatch;
|
|
239
|
-
var pos = getPos();
|
|
240
|
-
if (typeof pos !== 'number' || !(0, _utils.isValidPosition)(pos, state)) {
|
|
241
|
-
return;
|
|
242
|
-
}
|
|
243
|
-
var domAtPos = view.domAtPos.bind(view);
|
|
244
|
-
var width = containerWidth.width;
|
|
245
|
-
_this.scaleTableDebounced.cancel();
|
|
246
|
-
var tr = (0, _scaleTable.scaleTable)(_this.table, _objectSpread(_objectSpread({}, scaleOptions), {}, {
|
|
247
|
-
node: node,
|
|
248
|
-
prevNode: _this.node || node,
|
|
249
|
-
start: pos + 1,
|
|
250
|
-
containerWidth: width,
|
|
251
|
-
// Ignored via go/ees005
|
|
252
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
253
|
-
previousContainerWidth: _this.containerWidth.width || width
|
|
254
|
-
}, options), domAtPos, _this.props.pluginInjectionApi, false,
|
|
255
|
-
// isTableScalingEnabled doesn't change the behavior of nested tables
|
|
256
|
-
false // shouldUseIncreasedScalingPercent set to false for nested tables
|
|
257
|
-
)(state.tr);
|
|
258
|
-
if (!isUserTriggered) {
|
|
259
|
-
(0, _collab.tintDirtyTransaction)(tr);
|
|
260
|
-
// Avoid adding this transaction separately to the history as these are automatic updates
|
|
261
|
-
// as a consequence of another action
|
|
262
|
-
tr.setMeta('addToHistory', false);
|
|
263
|
-
}
|
|
264
|
-
dispatch(tr);
|
|
265
|
-
});
|
|
266
|
-
(0, _defineProperty3.default)(_this, "setTimerToSendInitialOverflowCaptured", function (isOverflowing) {
|
|
267
|
-
var _this$state;
|
|
268
|
-
var _this$props3 = _this.props,
|
|
269
|
-
dispatchAnalyticsEvent = _this$props3.dispatchAnalyticsEvent,
|
|
270
|
-
containerWidth = _this$props3.containerWidth,
|
|
271
|
-
allowTableResizing = _this$props3.allowTableResizing;
|
|
272
|
-
var parentWidth = ((_this$state = _this.state) === null || _this$state === void 0 ? void 0 : _this$state.parentWidth) || 0;
|
|
273
|
-
_this.initialOverflowCaptureTimerId = setTimeout(function () {
|
|
274
|
-
dispatchAnalyticsEvent({
|
|
275
|
-
action: _analytics.TABLE_ACTION.INITIAL_OVERFLOW_CAPTURED,
|
|
276
|
-
actionSubject: _analytics.ACTION_SUBJECT.TABLE,
|
|
277
|
-
actionSubjectId: null,
|
|
278
|
-
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
279
|
-
attributes: {
|
|
280
|
-
editorWidth: containerWidth.width || 0,
|
|
281
|
-
isOverflowing: isOverflowing,
|
|
282
|
-
tableResizingEnabled: allowTableResizing || false,
|
|
283
|
-
width: _this.node.attrs.width || 0,
|
|
284
|
-
parentWidth: parentWidth
|
|
285
|
-
}
|
|
286
|
-
});
|
|
287
|
-
_this.isInitialOverflowSent = true;
|
|
288
|
-
}, initialOverflowCaptureTimeroutDelay);
|
|
289
|
-
});
|
|
290
|
-
(0, _defineProperty3.default)(_this, "handleAutoSize", function () {
|
|
291
|
-
if (_this.table) {
|
|
292
|
-
var _this$props4 = _this.props,
|
|
293
|
-
view = _this$props4.view,
|
|
294
|
-
getNode = _this$props4.getNode,
|
|
295
|
-
getPos = _this$props4.getPos,
|
|
296
|
-
containerWidth = _this$props4.containerWidth;
|
|
297
|
-
var node = getNode();
|
|
298
|
-
var pos = getPos();
|
|
299
|
-
if (!(0, _utils.isValidPosition)(pos, view.state)) {
|
|
300
|
-
return;
|
|
301
|
-
}
|
|
302
|
-
(0, _commands.autoSizeTable)(view, node, _this.table, pos, {
|
|
303
|
-
containerWidth: containerWidth.width
|
|
304
|
-
});
|
|
305
|
-
}
|
|
306
|
-
});
|
|
307
|
-
(0, _defineProperty3.default)(_this, "handleWindowResize", function () {
|
|
308
|
-
var _this$props5 = _this.props,
|
|
309
|
-
getNode = _this$props5.getNode,
|
|
310
|
-
containerWidth = _this$props5.containerWidth;
|
|
311
|
-
var node = getNode();
|
|
312
|
-
var layoutSize = _this.tableNodeLayoutSize(node);
|
|
313
|
-
if (containerWidth.width > layoutSize) {
|
|
314
|
-
return;
|
|
315
|
-
}
|
|
316
|
-
var parentWidth = _this.getParentNodeWidth();
|
|
317
|
-
_this.scaleTableDebounced({
|
|
318
|
-
parentWidth: parentWidth
|
|
319
|
-
});
|
|
320
|
-
});
|
|
321
|
-
// This is a new handler for window resize events that sets the windowResized state immediately
|
|
322
|
-
// This is needed to update colgroup on window resize, to enforce the table scaling
|
|
323
|
-
(0, _defineProperty3.default)(_this, "handleWindowResizeNew", function () {
|
|
324
|
-
// Set resizing to true immediately
|
|
325
|
-
if (!_this.state.windowResized) {
|
|
326
|
-
_this.setState({
|
|
327
|
-
windowResized: true
|
|
328
|
-
});
|
|
329
|
-
}
|
|
330
|
-
});
|
|
331
|
-
(0, _defineProperty3.default)(_this, "getParentNodeWidth", function () {
|
|
332
|
-
var _this$props6 = _this.props,
|
|
333
|
-
getPos = _this$props6.getPos,
|
|
334
|
-
containerWidth = _this$props6.containerWidth,
|
|
335
|
-
options = _this$props6.options,
|
|
336
|
-
state = _this$props6.view.state;
|
|
337
|
-
var pos = getPos();
|
|
338
|
-
if (!(0, _utils.isValidPosition)(pos, state)) {
|
|
339
|
-
return;
|
|
340
|
-
}
|
|
341
|
-
var parentNodeWith = (0, _nodeWidth.getParentNodeWidth)(pos, state, containerWidth, options && options.isFullWidthModeEnabled);
|
|
342
|
-
return parentNodeWith;
|
|
343
|
-
});
|
|
344
|
-
(0, _defineProperty3.default)(_this, "updateParentWidth", function (width) {
|
|
345
|
-
_this.setState({
|
|
346
|
-
parentWidth: width
|
|
347
|
-
});
|
|
348
|
-
});
|
|
349
|
-
(0, _defineProperty3.default)(_this, "tableNodeLayoutSize", function (node, containerWidth, options) {
|
|
350
|
-
return (0, _misc.getLayoutSize)(node.attrs.layout, containerWidth || _this.props.containerWidth.width, options || _this.props.options || {});
|
|
351
|
-
});
|
|
352
|
-
(0, _defineProperty3.default)(_this, "shouldUpdateColgroup", function (params) {
|
|
353
|
-
var _this$props$options, _this$props$options2;
|
|
354
|
-
var isWindowResized = params.isWindowResized,
|
|
355
|
-
isWidthChanged = params.isWidthChanged,
|
|
356
|
-
isTableWidthChanged = params.isTableWidthChanged,
|
|
357
|
-
isColumnsDistributed = params.isColumnsDistributed,
|
|
358
|
-
isTableResizedFullWidth = params.isTableResizedFullWidth,
|
|
359
|
-
isTableDisplayModeChanged = params.isTableDisplayModeChanged,
|
|
360
|
-
isNumberColumnChanged = params.isNumberColumnChanged,
|
|
361
|
-
isNumberOfColumnsChanged = params.isNumberOfColumnsChanged,
|
|
362
|
-
isFullWidthModeAndLineLengthChanged = params.isFullWidthModeAndLineLengthChanged;
|
|
363
|
-
var isFullPageEditor = !((_this$props$options = _this.props.options) !== null && _this$props$options !== void 0 && _this$props$options.isCommentEditor) && !((_this$props$options2 = _this.props.options) !== null && _this$props$options2 !== void 0 && _this$props$options2.isChromelessEditor);
|
|
364
|
-
if (isFullPageEditor) {
|
|
365
|
-
return !!isWindowResized || isColumnsDistributed || !!isTableResizedFullWidth || isTableDisplayModeChanged || isNumberColumnChanged || isNumberOfColumnsChanged || !!isFullWidthModeAndLineLengthChanged;
|
|
366
|
-
}
|
|
367
|
-
return isWidthChanged || isTableWidthChanged || isColumnsDistributed || !!isTableResizedFullWidth || isTableDisplayModeChanged || isNumberColumnChanged || isNumberOfColumnsChanged || !!isFullWidthModeAndLineLengthChanged;
|
|
368
|
-
});
|
|
369
|
-
(0, _defineProperty3.default)(_this, "scaleTableDebounced", (0, _rafSchd.default)(_this.scaleTable));
|
|
370
|
-
(0, _defineProperty3.default)(_this, "handleTableResizingDebounced", (0, _rafSchd.default)(_this.handleTableResizing));
|
|
371
|
-
(0, _defineProperty3.default)(_this, "handleScrollDebounced", (0, _rafSchd.default)(_this.handleScroll));
|
|
372
|
-
(0, _defineProperty3.default)(_this, "handleAutoSizeDebounced", (0, _rafSchd.default)(_this.handleAutoSize));
|
|
373
|
-
(0, _defineProperty3.default)(_this, "handleWindowResizeDebounced", (0, _rafSchd.default)(_this.handleWindowResize));
|
|
374
|
-
(0, _defineProperty3.default)(_this, "handleWindowResizeNewDebounced", (0, _rafSchd.default)(_this.handleWindowResizeNew));
|
|
375
|
-
(0, _defineProperty3.default)(_this, "updateShadowStateDebounced", (0, _rafSchd.default)(_this.updateShadowState));
|
|
376
|
-
var _options = props.options,
|
|
377
|
-
_containerWidth = props.containerWidth,
|
|
378
|
-
_getNode = props.getNode;
|
|
379
|
-
_this.node = _getNode();
|
|
380
|
-
_this.containerWidth = _containerWidth;
|
|
381
|
-
var tablePos = props.getPos();
|
|
382
|
-
_this.isNestedInTable = tablePos ? (0, _nesting.getParentOfTypeCount)(props.view.state.schema.nodes.table)(props.view.state.doc.resolve(tablePos)) > 0 : false;
|
|
383
|
-
_this.isInitialOverflowSent = false;
|
|
384
|
-
if (!_this.updateColGroupFromFullWidthChange) {
|
|
385
|
-
_this.updateColGroupFromFullWidthChange = (_options === null || _options === void 0 ? void 0 : _options.isFullWidthModeEnabled) && !(_options !== null && _options !== void 0 && _options.wasFullWidthModeEnabled);
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
// store table size using previous full-width mode so can detect if it has changed.
|
|
389
|
-
var isFullWidthModeEnabled = _options ? _options.wasFullWidthModeEnabled : false;
|
|
390
|
-
_this.layoutSize = _this.tableNodeLayoutSize(_this.node, _containerWidth.width, {
|
|
391
|
-
isFullWidthModeEnabled: isFullWidthModeEnabled
|
|
392
|
-
});
|
|
393
|
-
_this.resizeObserver = new ResizeObserver(function (entries) {
|
|
394
|
-
var _iterator = _createForOfIteratorHelper(entries),
|
|
395
|
-
_step;
|
|
396
|
-
try {
|
|
397
|
-
var _loop = function _loop() {
|
|
398
|
-
var entry = _step.value;
|
|
399
|
-
_this.setState(function (prev) {
|
|
400
|
-
var _entry$contentRect, _entry$contentRect2;
|
|
401
|
-
return (prev === null || prev === void 0 ? void 0 : prev.tableWrapperWidth) === ((_entry$contentRect = entry.contentRect) === null || _entry$contentRect === void 0 ? void 0 : _entry$contentRect.width) && (prev === null || prev === void 0 ? void 0 : prev.tableWrapperHeight) === ((_entry$contentRect2 = entry.contentRect) === null || _entry$contentRect2 === void 0 ? void 0 : _entry$contentRect2.height) ? prev : _objectSpread(_objectSpread({}, prev), {}, {
|
|
402
|
-
tableWrapperWidth: entry.contentRect.width,
|
|
403
|
-
tableWrapperHeight: entry.contentRect.height
|
|
404
|
-
});
|
|
405
|
-
});
|
|
406
|
-
};
|
|
407
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
408
|
-
_loop();
|
|
409
|
-
}
|
|
410
|
-
} catch (err) {
|
|
411
|
-
_iterator.e(err);
|
|
412
|
-
} finally {
|
|
413
|
-
_iterator.f();
|
|
414
|
-
}
|
|
415
|
-
});
|
|
416
|
-
|
|
417
|
-
// Disable inline table editing and resizing controls in Firefox
|
|
418
|
-
// https://github.com/ProseMirror/prosemirror/issues/432
|
|
419
|
-
if ('execCommand' in document) {
|
|
420
|
-
['enableObjectResizing', 'enableInlineTableEditing'].forEach(function (cmd) {
|
|
421
|
-
if (document.queryCommandSupported(cmd)) {
|
|
422
|
-
document.execCommand(cmd, false, 'false');
|
|
423
|
-
}
|
|
424
|
-
});
|
|
425
|
-
}
|
|
426
|
-
return _this;
|
|
427
|
-
}
|
|
428
|
-
(0, _inherits2.default)(TableComponent, _React$Component);
|
|
429
|
-
return (0, _createClass2.default)(TableComponent, [{
|
|
430
|
-
key: "componentDidMount",
|
|
431
|
-
value: function componentDidMount() {
|
|
432
|
-
var _this2 = this;
|
|
433
|
-
var _nodeVisibilityManage = (0, _nodeVisibility.nodeVisibilityManager)(this.props.view.dom),
|
|
434
|
-
observe = _nodeVisibilityManage.observe;
|
|
435
|
-
if (this.table) {
|
|
436
|
-
this.nodeVisibilityObserverCleanupFn = observe({
|
|
437
|
-
element: this.table,
|
|
438
|
-
onFirstVisible: function onFirstVisible() {
|
|
439
|
-
_this2.initialiseEventListenersAfterMount();
|
|
440
|
-
// force width calculation - missed resize event under firefox when
|
|
441
|
-
// table is nested within bodied extension
|
|
442
|
-
if (_this2.wrapper) {
|
|
443
|
-
var _this2$wrapper;
|
|
444
|
-
_this2.wrapperWidth = (_this2$wrapper = _this2.wrapper) === null || _this2$wrapper === void 0 ? void 0 : _this2$wrapper.clientWidth;
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
});
|
|
448
|
-
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
449
|
-
window.addEventListener('resize', this.handleWindowResizeNewDebounced);
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
}, {
|
|
453
|
-
key: "initialiseEventListenersAfterMount",
|
|
454
|
-
value: function initialiseEventListenersAfterMount() {
|
|
455
|
-
var _this$table,
|
|
456
|
-
_this$table2,
|
|
457
|
-
_this$table3,
|
|
458
|
-
_this3 = this;
|
|
459
|
-
var _this$props7 = this.props,
|
|
460
|
-
allowColumnResizing = _this$props7.allowColumnResizing,
|
|
461
|
-
allowTableResizing = _this$props7.allowTableResizing,
|
|
462
|
-
eventDispatcher = _this$props7.eventDispatcher,
|
|
463
|
-
isDragAndDropEnabled = _this$props7.isDragAndDropEnabled,
|
|
464
|
-
getNode = _this$props7.getNode;
|
|
465
|
-
var browser = (0, _expValEquals.expValEquals)('platform_editor_hydratable_ui', 'isEnabled', true) ? (0, _browser.getBrowserInfo)() : _browser.browser;
|
|
466
|
-
var isIE11 = browser.ie_version === 11;
|
|
467
|
-
|
|
468
|
-
// Ignored via go/ees005
|
|
469
|
-
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
470
|
-
this === null || this === void 0 || (_this$table = this.table) === null || _this$table === void 0 || _this$table.addEventListener('mouseenter', this.handleMouseEnter);
|
|
471
|
-
|
|
472
|
-
// Ignored via go/ees005
|
|
473
|
-
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
474
|
-
this === null || this === void 0 || (_this$table2 = this.table) === null || _this$table2 === void 0 || _this$table2.addEventListener('mouseout', this.handleMouseOut);
|
|
475
|
-
|
|
476
|
-
// Ignored via go/ees005
|
|
477
|
-
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
478
|
-
this === null || this === void 0 || (_this$table3 = this.table) === null || _this$table3 === void 0 || _this$table3.addEventListener('mouseover', this.handleMouseOver);
|
|
479
|
-
if (this.wrapper) {
|
|
480
|
-
this.wrapperReisizeObserver = new ResizeObserver(function (entries) {
|
|
481
|
-
var _iterator2 = _createForOfIteratorHelper(entries),
|
|
482
|
-
_step2;
|
|
483
|
-
try {
|
|
484
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
485
|
-
var _entry$contentRect3;
|
|
486
|
-
var entry = _step2.value;
|
|
487
|
-
_this3.wrapperWidth = (_entry$contentRect3 = entry.contentRect) === null || _entry$contentRect3 === void 0 ? void 0 : _entry$contentRect3.width;
|
|
488
|
-
}
|
|
489
|
-
} catch (err) {
|
|
490
|
-
_iterator2.e(err);
|
|
491
|
-
} finally {
|
|
492
|
-
_iterator2.f();
|
|
493
|
-
}
|
|
494
|
-
});
|
|
495
|
-
this.wrapperReisizeObserver.observe(this.wrapper);
|
|
496
|
-
}
|
|
497
|
-
if (allowColumnResizing && this.wrapper && !isIE11) {
|
|
498
|
-
// Ignored via go/ees005
|
|
499
|
-
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
500
|
-
this.wrapper.addEventListener('scroll', this.handleScrollDebounced, {
|
|
501
|
-
passive: true
|
|
502
|
-
});
|
|
503
|
-
if (this.table && !this.isNestedInTable) {
|
|
504
|
-
this.stickyScrollbar = new _TableStickyScrollbar.TableStickyScrollbar(this.wrapper, this.props.view);
|
|
505
|
-
}
|
|
506
|
-
if (isDragAndDropEnabled) {
|
|
507
|
-
this.dragAndDropCleanupFn = _combine.combine.apply(void 0, (0, _toConsumableArray2.default)((0, _autoscrollers.autoScrollerFactory)({
|
|
508
|
-
tableWrapper: this.wrapper,
|
|
509
|
-
getNode: getNode
|
|
510
|
-
})));
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
if (allowColumnResizing) {
|
|
514
|
-
/**
|
|
515
|
-
* We no longer use `containerWidth` as a variable to determine an update for table resizing (avoids unnecessary updates).
|
|
516
|
-
* Instead we use the resize event to only trigger updates when necessary.
|
|
517
|
-
*/
|
|
518
|
-
if (!allowTableResizing) {
|
|
519
|
-
// Ignored via go/ees005
|
|
520
|
-
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
521
|
-
window.addEventListener('resize', this.handleWindowResizeDebounced);
|
|
522
|
-
}
|
|
523
|
-
this.handleTableResizingDebounced();
|
|
524
|
-
}
|
|
525
|
-
var currentStickyState = _pluginKey.pluginKey.getState(this.props.view.state);
|
|
526
|
-
if (currentStickyState) {
|
|
527
|
-
this.onStickyState(currentStickyState);
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
// Ignored via go/ees005
|
|
531
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
532
|
-
eventDispatcher.on(_pluginKey.pluginKey.key, this.onStickyState);
|
|
533
|
-
if (isOverflowAnalyticsEnabled) {
|
|
534
|
-
var initialIsOveflowing = this.state[_types.ShadowEvent.SHOW_BEFORE_SHADOW] || this.state[_types.ShadowEvent.SHOW_AFTER_SHADOW];
|
|
535
|
-
this.setTimerToSendInitialOverflowCaptured(initialIsOveflowing);
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
}, {
|
|
539
|
-
key: "componentWillUnmount",
|
|
540
|
-
value: function componentWillUnmount() {
|
|
541
|
-
var _this$resizeObserver, _this$wrapperReisizeO, _this$table4, _this$table5, _this$table6;
|
|
542
|
-
var _this$props8 = this.props,
|
|
543
|
-
allowColumnResizing = _this$props8.allowColumnResizing,
|
|
544
|
-
allowTableResizing = _this$props8.allowTableResizing,
|
|
545
|
-
eventDispatcher = _this$props8.eventDispatcher,
|
|
546
|
-
isDragAndDropEnabled = _this$props8.isDragAndDropEnabled,
|
|
547
|
-
view = _this$props8.view,
|
|
548
|
-
isInDanger = _this$props8.isInDanger;
|
|
549
|
-
var browser = (0, _expValEquals.expValEquals)('platform_editor_hydratable_ui', 'isEnabled', true) ? (0, _browser.getBrowserInfo)() : _browser.browser;
|
|
550
|
-
var isIE11 = browser.ie_version === 11;
|
|
551
|
-
if (this.wrapper && !isIE11) {
|
|
552
|
-
// Ignored via go/ees005
|
|
553
|
-
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
554
|
-
this.wrapper.removeEventListener('scroll', this.handleScrollDebounced);
|
|
555
|
-
}
|
|
556
|
-
if (isDragAndDropEnabled && this.dragAndDropCleanupFn) {
|
|
557
|
-
this.dragAndDropCleanupFn();
|
|
558
|
-
}
|
|
559
|
-
if (this.nodeVisibilityObserverCleanupFn) {
|
|
560
|
-
this.nodeVisibilityObserverCleanupFn();
|
|
561
|
-
}
|
|
562
|
-
(_this$resizeObserver = this.resizeObserver) === null || _this$resizeObserver === void 0 || _this$resizeObserver.disconnect();
|
|
563
|
-
(_this$wrapperReisizeO = this.wrapperReisizeObserver) === null || _this$wrapperReisizeO === void 0 || _this$wrapperReisizeO.disconnect();
|
|
564
|
-
if (this.stickyScrollbar) {
|
|
565
|
-
this.stickyScrollbar.dispose();
|
|
566
|
-
}
|
|
567
|
-
this.handleScrollDebounced.cancel();
|
|
568
|
-
this.scaleTableDebounced.cancel();
|
|
569
|
-
this.handleTableResizingDebounced.cancel();
|
|
570
|
-
this.handleAutoSizeDebounced.cancel();
|
|
571
|
-
if (!allowTableResizing) {
|
|
572
|
-
this.handleWindowResizeDebounced.cancel();
|
|
573
|
-
}
|
|
574
|
-
this.handleWindowResizeNewDebounced.cancel();
|
|
575
|
-
if (isInDanger) {
|
|
576
|
-
(0, _commands.clearHoverSelection)()(view.state, view.dispatch);
|
|
577
|
-
}
|
|
578
|
-
if (!allowTableResizing && allowColumnResizing) {
|
|
579
|
-
// Ignored via go/ees005
|
|
580
|
-
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
581
|
-
window.removeEventListener('resize', this.handleWindowResizeDebounced);
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
585
|
-
window.removeEventListener('resize', this.handleWindowResizeNewDebounced);
|
|
586
|
-
|
|
587
|
-
// Ignored via go/ees005
|
|
588
|
-
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
589
|
-
this === null || this === void 0 || (_this$table4 = this.table) === null || _this$table4 === void 0 || _this$table4.removeEventListener('mouseenter', this.handleMouseEnter);
|
|
590
|
-
|
|
591
|
-
// Ignored via go/ees005
|
|
592
|
-
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
593
|
-
this === null || this === void 0 || (_this$table5 = this.table) === null || _this$table5 === void 0 || _this$table5.removeEventListener('mouseout', this.handleMouseOut);
|
|
594
|
-
|
|
595
|
-
// Ignored via go/ees005
|
|
596
|
-
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
597
|
-
this === null || this === void 0 || (_this$table6 = this.table) === null || _this$table6 === void 0 || _this$table6.removeEventListener('mouseover', this.handleMouseOver);
|
|
598
|
-
if (this.overflowShadowsObserver) {
|
|
599
|
-
this.overflowShadowsObserver.dispose();
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
// Ignored via go/ees005
|
|
603
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
604
|
-
eventDispatcher.off(_pluginKey.pluginKey.key, this.onStickyState);
|
|
605
|
-
if (this.initialOverflowCaptureTimerId) {
|
|
606
|
-
clearTimeout(this.initialOverflowCaptureTimerId);
|
|
607
|
-
}
|
|
608
|
-
}
|
|
609
|
-
}, {
|
|
610
|
-
key: "removeInlineTableWidth",
|
|
611
|
-
value:
|
|
612
|
-
// Should be called only when table node width is reset to undefined in Comment Editor
|
|
613
|
-
// Maybe replaced by handleColgroupUpdates as we implement new table's support in Comment Editor.
|
|
614
|
-
function removeInlineTableWidth() {
|
|
615
|
-
var _this$props9 = this.props,
|
|
616
|
-
isResizing = _this$props9.isResizing,
|
|
617
|
-
getNode = _this$props9.getNode,
|
|
618
|
-
view = _this$props9.view,
|
|
619
|
-
getPos = _this$props9.getPos;
|
|
620
|
-
if (!this.table) {
|
|
621
|
-
return;
|
|
622
|
-
}
|
|
623
|
-
var tableNode = getNode();
|
|
624
|
-
var newTableWidth = tableNode.attrs.width;
|
|
625
|
-
var start = getPos() || 0;
|
|
626
|
-
var depth = view.state.doc.resolve(start).depth;
|
|
627
|
-
if (depth !== 0) {
|
|
628
|
-
return;
|
|
629
|
-
}
|
|
630
|
-
if (!isResizing && newTableWidth === null) {
|
|
631
|
-
this.table.style.width = '';
|
|
632
|
-
}
|
|
633
|
-
}
|
|
634
|
-
}, {
|
|
635
|
-
key: "handleColgroupUpdates",
|
|
636
|
-
value: function handleColgroupUpdates() {
|
|
637
|
-
var _this$containerWidth,
|
|
638
|
-
_this4 = this;
|
|
639
|
-
var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
640
|
-
var _this$props0 = this.props,
|
|
641
|
-
getNode = _this$props0.getNode,
|
|
642
|
-
containerWidth = _this$props0.containerWidth,
|
|
643
|
-
isResizing = _this$props0.isResizing,
|
|
644
|
-
view = _this$props0.view,
|
|
645
|
-
getPos = _this$props0.getPos,
|
|
646
|
-
getEditorFeatureFlags = _this$props0.getEditorFeatureFlags,
|
|
647
|
-
options = _this$props0.options;
|
|
648
|
-
if (!this.table) {
|
|
649
|
-
return;
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
// Remove any widths styles after resizing preview is completed
|
|
653
|
-
this.table.style.width = '';
|
|
654
|
-
var tableNode = getNode();
|
|
655
|
-
var start = getPos() || 0;
|
|
656
|
-
var depth = view.state.doc.resolve(start).depth;
|
|
657
|
-
if (depth !== 0) {
|
|
658
|
-
return;
|
|
659
|
-
}
|
|
660
|
-
var tableNodeWidth = (0, _nodeWidth.getTableContainerWidth)(tableNode);
|
|
661
|
-
var isTableResizedFullWidth = tableNodeWidth === 1800 && this.wasResizing && !isResizing;
|
|
662
|
-
|
|
663
|
-
// Needed for undo / redo
|
|
664
|
-
var isTableWidthChanged = tableNodeWidth !== this.tableNodeWidth;
|
|
665
|
-
var tableRenderWidth = options !== null && options !== void 0 && options.isCommentEditor ? containerWidth.width - (_consts.TABLE_OFFSET_IN_COMMENT_EDITOR + 1) // should be the same as this.table.parentElement?.clientWidth - 1, subtract 1 to avoid overflow
|
|
666
|
-
: containerWidth.width - _consts.TABLE_EDITOR_MARGIN;
|
|
667
|
-
tableNodeWidth = options !== null && options !== void 0 && options.isCommentEditor && !tableNode.attrs.width ? tableRenderWidth : tableNodeWidth;
|
|
668
|
-
var isTableSquashed = tableRenderWidth < tableNodeWidth;
|
|
669
|
-
var isNumberColumnChanged = tableNode.attrs.isNumberColumnEnabled !== this.node.attrs.isNumberColumnEnabled;
|
|
670
|
-
var isNumberOfColumnsChanged = (0, _nodes.tablesHaveDifferentNoOfColumns)(tableNode, this.node);
|
|
671
|
-
var containerWidthValue = containerWidth.width,
|
|
672
|
-
containerLineLength = containerWidth.lineLength;
|
|
673
|
-
var isLineLengthChanged = ((_this$containerWidth = this.containerWidth) === null || _this$containerWidth === void 0 ? void 0 : _this$containerWidth.lineLength) !== containerLineLength;
|
|
674
|
-
var isFullWidthModeAndLineLengthChanged = this.updateColGroupFromFullWidthChange && isLineLengthChanged;
|
|
675
|
-
var maybeScale = isTableSquashed || isTableWidthChanged || isTableResizedFullWidth && !(options !== null && options !== void 0 && options.isCommentEditor) || isNumberColumnChanged || isNumberOfColumnsChanged || this.state.windowResized;
|
|
676
|
-
if (force || maybeScale || isFullWidthModeAndLineLengthChanged) {
|
|
677
|
-
var _this$containerWidth2, _this$props$options3, _this$props$options4, _this$props$options5;
|
|
678
|
-
var isWidthChanged = ((_this$containerWidth2 = this.containerWidth) === null || _this$containerWidth2 === void 0 ? void 0 : _this$containerWidth2.width) !== containerWidthValue;
|
|
679
|
-
var wasTableResized = (0, _colgroup.hasTableBeenResized)(this.node);
|
|
680
|
-
var isTableResized = (0, _colgroup.hasTableBeenResized)(tableNode);
|
|
681
|
-
var isColumnsDistributed = wasTableResized && !isTableResized;
|
|
682
|
-
var isTableDisplayModeChanged = this.node.attrs.displayMode !== tableNode.attrs.displayMode;
|
|
683
|
-
var shouldUpdateColgroup = this.shouldUpdateColgroup({
|
|
684
|
-
isWindowResized: this.state.windowResized,
|
|
685
|
-
isWidthChanged: isWidthChanged,
|
|
686
|
-
isTableWidthChanged: isTableWidthChanged,
|
|
687
|
-
isColumnsDistributed: isColumnsDistributed,
|
|
688
|
-
isTableResizedFullWidth: isTableResizedFullWidth,
|
|
689
|
-
isTableDisplayModeChanged: isTableDisplayModeChanged,
|
|
690
|
-
isNumberColumnChanged: isNumberColumnChanged,
|
|
691
|
-
isNumberOfColumnsChanged: isNumberOfColumnsChanged,
|
|
692
|
-
isFullWidthModeAndLineLengthChanged: isFullWidthModeAndLineLengthChanged,
|
|
693
|
-
isTableResized: isTableResized
|
|
694
|
-
});
|
|
695
|
-
var _getEditorFeatureFlag = getEditorFeatureFlags(),
|
|
696
|
-
_getEditorFeatureFlag2 = _getEditorFeatureFlag.tableWithFixedColumnWidthsOption,
|
|
697
|
-
tableWithFixedColumnWidthsOption = _getEditorFeatureFlag2 === void 0 ? false : _getEditorFeatureFlag2;
|
|
698
|
-
var isTableScalingWithFixedColumnWidthsOptionEnabled = !!((_this$props$options3 = this.props.options) !== null && _this$props$options3 !== void 0 && _this$props$options3.isTableScalingEnabled) && tableWithFixedColumnWidthsOption;
|
|
699
|
-
var shouldUseIncreasedScalingPercent = isTableScalingWithFixedColumnWidthsOptionEnabled || !!((_this$props$options4 = this.props.options) !== null && _this$props$options4 !== void 0 && _this$props$options4.isTableScalingEnabled) && !!((_this$props$options5 = this.props.options) !== null && _this$props$options5 !== void 0 && _this$props$options5.isCommentEditor);
|
|
700
|
-
if (force || !isResizing && shouldUpdateColgroup) {
|
|
701
|
-
var _this$props$options6, _this$props$options7, _this$props$options8, _this$props$options9;
|
|
702
|
-
var resizeState = (0, _resizeState.getResizeState)({
|
|
703
|
-
minWidth: _consts.COLUMN_MIN_WIDTH,
|
|
704
|
-
// When numbered column enabled, we need to subtract the width of the numbered column
|
|
705
|
-
maxSize: tableNode.attrs.isNumberColumnEnabled ? tableRenderWidth - _editorSharedStyles.akEditorTableNumberColumnWidth : tableRenderWidth,
|
|
706
|
-
table: tableNode,
|
|
707
|
-
tableRef: this.table,
|
|
708
|
-
start: start,
|
|
709
|
-
domAtPos: view.domAtPos.bind(view),
|
|
710
|
-
isTableScalingEnabled: true,
|
|
711
|
-
shouldUseIncreasedScalingPercent: shouldUseIncreasedScalingPercent,
|
|
712
|
-
isCommentEditor: !!((_this$props$options6 = this.props.options) !== null && _this$props$options6 !== void 0 && _this$props$options6.isCommentEditor)
|
|
713
|
-
});
|
|
714
|
-
var shouldScaleOnColgroupUpdate = false;
|
|
715
|
-
if ((_this$props$options7 = this.props.options) !== null && _this$props$options7 !== void 0 && _this$props$options7.isTableScalingEnabled && !tableWithFixedColumnWidthsOption) {
|
|
716
|
-
shouldScaleOnColgroupUpdate = true;
|
|
717
|
-
}
|
|
718
|
-
if (isTableScalingWithFixedColumnWidthsOptionEnabled && tableNode.attrs.displayMode !== 'fixed') {
|
|
719
|
-
shouldScaleOnColgroupUpdate = true;
|
|
720
|
-
}
|
|
721
|
-
if ((_this$props$options8 = this.props.options) !== null && _this$props$options8 !== void 0 && _this$props$options8.isTableScalingEnabled && (_this$props$options9 = this.props.options) !== null && _this$props$options9 !== void 0 && _this$props$options9.isCommentEditor) {
|
|
722
|
-
shouldScaleOnColgroupUpdate = true;
|
|
723
|
-
}
|
|
724
|
-
var scalePercent = 1;
|
|
725
|
-
requestAnimationFrame(function () {
|
|
726
|
-
var _this4$props$options, _this4$props$options2;
|
|
727
|
-
// Scaling percent has to be calculated inside requestAnimationFrame, otherwise
|
|
728
|
-
// renderWidth calculated as `tableRef?.parentElement?.clientWidth`
|
|
729
|
-
// inside of getTableScalingPercent returns 0.
|
|
730
|
-
if (!((_this4$props$options = _this4.props.options) !== null && _this4$props$options !== void 0 && _this4$props$options.isCommentEditor) || (_this4$props$options2 = _this4.props.options) !== null && _this4$props$options2 !== void 0 && _this4$props$options2.isCommentEditor && tableNode.attrs.width) {
|
|
731
|
-
scalePercent = (0, _misc.getTableScalingPercent)(tableNode,
|
|
732
|
-
// Ignored via go/ees005
|
|
733
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
734
|
-
_this4.table, shouldUseIncreasedScalingPercent);
|
|
735
|
-
} else {
|
|
736
|
-
// Ignored via go/ees005
|
|
737
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
738
|
-
scalePercent = (0, _misc.getScalingPercentForTableWithoutWidth)(tableNode, _this4.table);
|
|
739
|
-
}
|
|
740
|
-
|
|
741
|
-
// Request animation frame required for Firefox
|
|
742
|
-
(0, _resizeState.updateColgroup)(resizeState,
|
|
743
|
-
// Ignored via go/ees005
|
|
744
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
745
|
-
_this4.table, tableNode, shouldScaleOnColgroupUpdate, scalePercent);
|
|
746
|
-
});
|
|
747
|
-
}
|
|
748
|
-
}
|
|
749
|
-
if (isFullWidthModeAndLineLengthChanged) {
|
|
750
|
-
this.updateColGroupFromFullWidthChange = false;
|
|
751
|
-
}
|
|
752
|
-
this.tableNodeWidth = tableNodeWidth;
|
|
753
|
-
this.wasResizing = isResizing;
|
|
754
|
-
this.containerWidth = containerWidth;
|
|
755
|
-
}
|
|
756
|
-
|
|
757
|
-
// Ignored via go/ees005
|
|
758
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
759
|
-
}, {
|
|
760
|
-
key: "componentDidUpdate",
|
|
761
|
-
value: function componentDidUpdate(_, prevState) {
|
|
762
|
-
var _this$props$options0,
|
|
763
|
-
_this$props$options1,
|
|
764
|
-
_this$wrapper,
|
|
765
|
-
_this5 = this;
|
|
766
|
-
var _this$props1 = this.props,
|
|
767
|
-
getNode = _this$props1.getNode,
|
|
768
|
-
isMediaFullscreen = _this$props1.isMediaFullscreen,
|
|
769
|
-
allowColumnResizing = _this$props1.allowColumnResizing,
|
|
770
|
-
allowTableResizing = _this$props1.allowTableResizing,
|
|
771
|
-
isResizing = _this$props1.isResizing,
|
|
772
|
-
options = _this$props1.options,
|
|
773
|
-
isTableScalingEnabled = _this$props1.isTableScalingEnabled,
|
|
774
|
-
getPos = _this$props1.getPos,
|
|
775
|
-
getEditorFeatureFlags = _this$props1.getEditorFeatureFlags;
|
|
776
|
-
var shouldScale = false;
|
|
777
|
-
var shouldHandleColgroupUpdates = false;
|
|
778
|
-
var _getEditorFeatureFlag3 = getEditorFeatureFlags(),
|
|
779
|
-
_getEditorFeatureFlag4 = _getEditorFeatureFlag3.tableWithFixedColumnWidthsOption,
|
|
780
|
-
tableWithFixedColumnWidthsOption = _getEditorFeatureFlag4 === void 0 ? false : _getEditorFeatureFlag4;
|
|
781
|
-
if (isTableScalingEnabled && !tableWithFixedColumnWidthsOption) {
|
|
782
|
-
shouldScale = true;
|
|
783
|
-
shouldHandleColgroupUpdates = true;
|
|
784
|
-
}
|
|
785
|
-
var isTableScalingWithFixedColumnWidthsOptionEnabled = !!isTableScalingEnabled && tableWithFixedColumnWidthsOption;
|
|
786
|
-
var shouldUseIncreasedScalingPercent = isTableScalingWithFixedColumnWidthsOptionEnabled || !!isTableScalingEnabled && !!((_this$props$options0 = this.props.options) !== null && _this$props$options0 !== void 0 && _this$props$options0.isCommentEditor);
|
|
787
|
-
if (isTableScalingWithFixedColumnWidthsOptionEnabled && getNode().attrs.displayMode !== 'fixed') {
|
|
788
|
-
shouldScale = true;
|
|
789
|
-
shouldHandleColgroupUpdates = true;
|
|
790
|
-
}
|
|
791
|
-
if (!(0, _platformFeatureFlags.fg)('platform_editor_table_width_refactor')) {
|
|
792
|
-
if (this.state.windowResized) {
|
|
793
|
-
shouldHandleColgroupUpdates = true;
|
|
794
|
-
}
|
|
795
|
-
}
|
|
796
|
-
if (shouldHandleColgroupUpdates) {
|
|
797
|
-
this.handleColgroupUpdates();
|
|
798
|
-
}
|
|
799
|
-
if ((_this$props$options1 = this.props.options) !== null && _this$props$options1 !== void 0 && _this$props$options1.isCommentEditor && allowTableResizing && !(options !== null && options !== void 0 && options.isTableScalingEnabled)) {
|
|
800
|
-
this.removeInlineTableWidth();
|
|
801
|
-
}
|
|
802
|
-
if ((_this$wrapper = this.wrapper) !== null && _this$wrapper !== void 0 && _this$wrapper.parentElement && this.table && !this.overflowShadowsObserver) {
|
|
803
|
-
// isDragAndDropEnabled will be false when the editorViewMode is 'live' and so the fix below is never triggered
|
|
804
|
-
// but the shadow observer must run async so its initial state is correct.
|
|
805
|
-
if (this.props.isDragAndDropEnabled) {
|
|
806
|
-
// requestAnimationFrame is used here to fix a race condition issue
|
|
807
|
-
// that happens when a table is nested in expand and expand's width is
|
|
808
|
-
// changed via breakout button
|
|
809
|
-
window.requestAnimationFrame(function () {
|
|
810
|
-
_this5.overflowShadowsObserver = new _OverflowShadowsObserver.OverflowShadowsObserver(_this5.updateShadowStateDebounced,
|
|
811
|
-
// Ignored via go/ees005
|
|
812
|
-
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
813
|
-
_this5.table, _this5.wrapper);
|
|
814
|
-
});
|
|
815
|
-
} else {
|
|
816
|
-
this.overflowShadowsObserver = new _OverflowShadowsObserver.OverflowShadowsObserver(this.updateShadowState, this.table, this.wrapper);
|
|
817
|
-
}
|
|
818
|
-
}
|
|
819
|
-
if (this.overflowShadowsObserver) {
|
|
820
|
-
var _this$state$stickyHea;
|
|
821
|
-
this.overflowShadowsObserver.observeShadowSentinels((_this$state$stickyHea = this.state.stickyHeader) === null || _this$state$stickyHea === void 0 ? void 0 : _this$state$stickyHea.sticky);
|
|
822
|
-
}
|
|
823
|
-
var currentTable = getNode();
|
|
824
|
-
var previousTable = this.node;
|
|
825
|
-
var isNoOfColumnsChanged = (0, _nodes.tablesHaveDifferentNoOfColumns)(currentTable, previousTable);
|
|
826
|
-
var isNoOfRowsChanged = (0, _nodes.tablesHaveDifferentNoOfRows)(currentTable, previousTable);
|
|
827
|
-
if (isNoOfColumnsChanged || isNoOfRowsChanged) {
|
|
828
|
-
var _this$props$pluginInj;
|
|
829
|
-
(_this$props$pluginInj = this.props.pluginInjectionApi) === null || _this$props$pluginInj === void 0 || (_this$props$pluginInj = _this$props$pluginInj.accessibilityUtils) === null || _this$props$pluginInj === void 0 || _this$props$pluginInj.actions.ariaNotify((0, _table.getAssistiveMessage)(previousTable, currentTable, this.props.intl), {
|
|
830
|
-
priority: 'important'
|
|
831
|
-
});
|
|
832
|
-
}
|
|
833
|
-
if (currentTable.attrs.__autoSize) {
|
|
834
|
-
// Wait for next tick to handle auto sizing, gives the browser time to do layout calc etc.
|
|
835
|
-
this.handleAutoSizeDebounced();
|
|
836
|
-
}
|
|
837
|
-
// re-drawing will cause media component get unmounted that will exit fullscreen mode if media is in fullscreen mode
|
|
838
|
-
// see https://product-fabric.atlassian.net/browse/MEX-1290
|
|
839
|
-
else if (allowColumnResizing && this.table && !isMediaFullscreen) {
|
|
840
|
-
// If col widths (e.g. via collab) or number of columns (e.g. delete a column) have changed,
|
|
841
|
-
// re-draw colgroup.
|
|
842
|
-
if ((0, _nodes.tablesHaveDifferentColumnWidths)(currentTable, previousTable) || isNoOfColumnsChanged) {
|
|
843
|
-
var view = this.props.view;
|
|
844
|
-
var shouldRecreateResizeCols = !allowTableResizing || !isResizing || isNoOfColumnsChanged && isResizing;
|
|
845
|
-
if (shouldRecreateResizeCols) {
|
|
846
|
-
var start = getPos() || 0;
|
|
847
|
-
var depth = view.state.doc.resolve(start).depth;
|
|
848
|
-
shouldScale = depth === 0 && shouldScale;
|
|
849
|
-
(0, _colgroup.insertColgroupFromNode)(this.table, currentTable, shouldScale, undefined, shouldUseIncreasedScalingPercent, options === null || options === void 0 ? void 0 : options.isCommentEditor);
|
|
850
|
-
}
|
|
851
|
-
(0, _dom.updateControls)()(view.state);
|
|
852
|
-
}
|
|
853
|
-
this.handleTableResizingDebounced();
|
|
854
|
-
}
|
|
855
|
-
if (isOverflowAnalyticsEnabled) {
|
|
856
|
-
var newIsOverflowing = this.state[_types.ShadowEvent.SHOW_BEFORE_SHADOW] || this.state[_types.ShadowEvent.SHOW_AFTER_SHADOW];
|
|
857
|
-
var prevIsOverflowing = prevState[_types.ShadowEvent.SHOW_BEFORE_SHADOW] || prevState[_types.ShadowEvent.SHOW_AFTER_SHADOW];
|
|
858
|
-
if (this.initialOverflowCaptureTimerId) {
|
|
859
|
-
clearTimeout(this.initialOverflowCaptureTimerId);
|
|
860
|
-
}
|
|
861
|
-
if (!this.isInitialOverflowSent) {
|
|
862
|
-
this.setTimerToSendInitialOverflowCaptured(newIsOverflowing);
|
|
863
|
-
}
|
|
864
|
-
if (this.isInitialOverflowSent && prevIsOverflowing !== newIsOverflowing) {
|
|
865
|
-
var _this$state2;
|
|
866
|
-
var _this$props$view = this.props.view,
|
|
867
|
-
dispatch = _this$props$view.dispatch,
|
|
868
|
-
tr = _this$props$view.state.tr;
|
|
869
|
-
dispatch(tr.setMeta(_tableAnalytics.META_KEYS.OVERFLOW_STATE_CHANGED, {
|
|
870
|
-
isOverflowing: newIsOverflowing,
|
|
871
|
-
wasOverflowing: prevIsOverflowing,
|
|
872
|
-
editorWidth: this.props.containerWidth.width || 0,
|
|
873
|
-
width: this.node.attrs.width || 0,
|
|
874
|
-
parentWidth: ((_this$state2 = this.state) === null || _this$state2 === void 0 ? void 0 : _this$state2.parentWidth) || 0
|
|
875
|
-
}));
|
|
876
|
-
}
|
|
877
|
-
}
|
|
878
|
-
}
|
|
879
|
-
}, {
|
|
880
|
-
key: "observeTable",
|
|
881
|
-
value: function observeTable(table) {
|
|
882
|
-
if (table) {
|
|
883
|
-
var _this$resizeObserver2;
|
|
884
|
-
(_this$resizeObserver2 = this.resizeObserver) === null || _this$resizeObserver2 === void 0 || _this$resizeObserver2.observe(table);
|
|
885
|
-
}
|
|
886
|
-
}
|
|
887
|
-
}, {
|
|
888
|
-
key: "render",
|
|
889
|
-
value: function render() {
|
|
890
|
-
var _this6 = this,
|
|
891
|
-
_this$props$options10;
|
|
892
|
-
var _this$props10 = this.props,
|
|
893
|
-
view = _this$props10.view,
|
|
894
|
-
getNode = _this$props10.getNode,
|
|
895
|
-
isResizing = _this$props10.isResizing,
|
|
896
|
-
_this$props10$allowCo = _this$props10.allowControls,
|
|
897
|
-
allowControls = _this$props10$allowCo === void 0 ? true : _this$props10$allowCo,
|
|
898
|
-
isHeaderRowEnabled = _this$props10.isHeaderRowEnabled,
|
|
899
|
-
ordering = _this$props10.ordering,
|
|
900
|
-
isHeaderColumnEnabled = _this$props10.isHeaderColumnEnabled,
|
|
901
|
-
tableActive = _this$props10.tableActive,
|
|
902
|
-
containerWidth = _this$props10.containerWidth,
|
|
903
|
-
options = _this$props10.options,
|
|
904
|
-
getPos = _this$props10.getPos,
|
|
905
|
-
pluginInjectionApi = _this$props10.pluginInjectionApi,
|
|
906
|
-
isDragAndDropEnabled = _this$props10.isDragAndDropEnabled,
|
|
907
|
-
getEditorFeatureFlags = _this$props10.getEditorFeatureFlags,
|
|
908
|
-
isTableScalingEnabled = _this$props10.isTableScalingEnabled,
|
|
909
|
-
allowTableResizing = _this$props10.allowTableResizing,
|
|
910
|
-
allowTableAlignment = _this$props10.allowTableAlignment,
|
|
911
|
-
selection = _this$props10.selection,
|
|
912
|
-
isInDanger = _this$props10.isInDanger,
|
|
913
|
-
hoveredRows = _this$props10.hoveredRows,
|
|
914
|
-
hoveredCell = _this$props10.hoveredCell,
|
|
915
|
-
isTableHovered = _this$props10.isTableHovered,
|
|
916
|
-
isWholeTableInDanger = _this$props10.isWholeTableInDanger;
|
|
917
|
-
var _this$state3 = this.state,
|
|
918
|
-
showBeforeShadow = _this$state3.showBeforeShadow,
|
|
919
|
-
showAfterShadow = _this$state3.showAfterShadow;
|
|
920
|
-
var node = getNode();
|
|
921
|
-
var tableRef = this.table || undefined;
|
|
922
|
-
var headerRow = tableRef ? tableRef.querySelector('tr[data-header-row]') : undefined;
|
|
923
|
-
var hasHeaderRow = (0, _nodes.containsHeaderRow)(node);
|
|
924
|
-
var rowControls = /*#__PURE__*/_react.default.createElement(_TableFloatingControls.default, {
|
|
925
|
-
editorView: view,
|
|
926
|
-
tableRef: tableRef,
|
|
927
|
-
tableNode: node,
|
|
928
|
-
tableActive: tableActive,
|
|
929
|
-
hoveredRows: hoveredRows,
|
|
930
|
-
hoveredCell: hoveredCell,
|
|
931
|
-
isTableHovered: isTableHovered,
|
|
932
|
-
isInDanger: isInDanger,
|
|
933
|
-
isResizing: isResizing,
|
|
934
|
-
isNumberColumnEnabled: node.attrs.isNumberColumnEnabled,
|
|
935
|
-
isHeaderRowEnabled: isHeaderRowEnabled,
|
|
936
|
-
isDragAndDropEnabled: isDragAndDropEnabled,
|
|
937
|
-
ordering: ordering,
|
|
938
|
-
isHeaderColumnEnabled: isHeaderColumnEnabled,
|
|
939
|
-
hasHeaderRow: hasHeaderRow
|
|
940
|
-
// pass `selection` and `tableHeight` to control re-render
|
|
941
|
-
,
|
|
942
|
-
selection: view.state.selection,
|
|
943
|
-
headerRowHeight: headerRow ? headerRow.offsetHeight : undefined,
|
|
944
|
-
stickyHeader: !this.props.limitedMode ? this.state.stickyHeader : undefined,
|
|
945
|
-
tableWrapperWidth: this.state.tableWrapperWidth,
|
|
946
|
-
api: pluginInjectionApi,
|
|
947
|
-
isChromelessEditor: options === null || options === void 0 ? void 0 : options.isChromelessEditor
|
|
948
|
-
});
|
|
949
|
-
var tableContainerWidth = (0, _nodeWidth.getTableContainerWidth)(node);
|
|
950
|
-
var colControls = isDragAndDropEnabled ? /*#__PURE__*/_react.default.createElement(_TableFloatingColumnControls.default, {
|
|
951
|
-
editorView: view,
|
|
952
|
-
tableRef: tableRef,
|
|
953
|
-
getNode: getNode,
|
|
954
|
-
tableActive: tableActive,
|
|
955
|
-
isInDanger: isInDanger,
|
|
956
|
-
hoveredRows: hoveredRows,
|
|
957
|
-
hoveredCell: hoveredCell,
|
|
958
|
-
isTableHovered: isTableHovered,
|
|
959
|
-
isResizing: isResizing,
|
|
960
|
-
ordering: ordering,
|
|
961
|
-
hasHeaderRow: hasHeaderRow
|
|
962
|
-
// pass `selection` to control re-render
|
|
963
|
-
,
|
|
964
|
-
selection: view.state.selection,
|
|
965
|
-
headerRowHeight: headerRow ? headerRow.offsetHeight : undefined,
|
|
966
|
-
stickyHeader: !this.props.limitedMode ? this.state.stickyHeader : undefined,
|
|
967
|
-
getEditorFeatureFlags: getEditorFeatureFlags,
|
|
968
|
-
tableContainerWidth: tableContainerWidth,
|
|
969
|
-
isNumberColumnEnabled: node.attrs.isNumberColumnEnabled,
|
|
970
|
-
getScrollOffset: function getScrollOffset() {
|
|
971
|
-
var _this6$wrapper;
|
|
972
|
-
return ((_this6$wrapper = _this6.wrapper) === null || _this6$wrapper === void 0 ? void 0 : _this6$wrapper.scrollLeft) || 0;
|
|
973
|
-
},
|
|
974
|
-
tableWrapperHeight: this.state.tableWrapperHeight,
|
|
975
|
-
api: pluginInjectionApi,
|
|
976
|
-
isChromelessEditor: options === null || options === void 0 ? void 0 : options.isChromelessEditor
|
|
977
|
-
}) : null;
|
|
978
|
-
var shadowPadding = allowControls && tableActive ? -_editorSharedStyles.akEditorTableToolbarSize : _styles.tableMarginSides;
|
|
979
|
-
var shadowStyle = (0, _memoizeOne.default)(function (visible) {
|
|
980
|
-
return {
|
|
981
|
-
visibility: visible ? 'visible' : 'hidden'
|
|
982
|
-
};
|
|
983
|
-
});
|
|
984
|
-
|
|
985
|
-
/**
|
|
986
|
-
* ED-19838
|
|
987
|
-
* There is a getPos issue coming from this code. We need to apply this workaround for now and apply a patch
|
|
988
|
-
* before CR6 lands in production
|
|
989
|
-
*/
|
|
990
|
-
var tablePos;
|
|
991
|
-
try {
|
|
992
|
-
tablePos = getPos ? getPos() : undefined;
|
|
993
|
-
} catch (_unused) {
|
|
994
|
-
tablePos = undefined;
|
|
995
|
-
}
|
|
996
|
-
var isNested = (0, _nodes.isTableNested)(view.state, tablePos);
|
|
997
|
-
var topShadowPadding = isDragAndDropEnabled ? 0 : shadowPadding;
|
|
998
|
-
var topOffset = 0;
|
|
999
|
-
var topStickyShadowPosition = !this.props.limitedMode && this.state.stickyHeader && topOffset + this.state.stickyHeader.padding + topShadowPadding + 2;
|
|
1000
|
-
var _getEditorFeatureFlag5 = getEditorFeatureFlags(),
|
|
1001
|
-
_getEditorFeatureFlag6 = _getEditorFeatureFlag5.tableWithFixedColumnWidthsOption,
|
|
1002
|
-
tableWithFixedColumnWidthsOption = _getEditorFeatureFlag6 === void 0 ? false : _getEditorFeatureFlag6;
|
|
1003
|
-
var shouldUseIncreasedScalingPercent = !!isTableScalingEnabled && (tableWithFixedColumnWidthsOption || !!((_this$props$options10 = this.props.options) !== null && _this$props$options10 !== void 0 && _this$props$options10.isCommentEditor));
|
|
1004
|
-
return /*#__PURE__*/_react.default.createElement(_TableContainer.TableContainer
|
|
1005
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
1006
|
-
, {
|
|
1007
|
-
className: (0, _classnames2.default)(_types.TableCssClassName.TABLE_CONTAINER, (0, _defineProperty3.default)((0, _defineProperty3.default)((0, _defineProperty3.default)((0, _defineProperty3.default)((0, _defineProperty3.default)({}, _types.TableCssClassName.WITH_CONTROLS, allowControls && tableActive), _types.TableCssClassName.TABLE_STICKY, !this.props.limitedMode && this.state.stickyHeader && hasHeaderRow), _types.TableCssClassName.HOVERED_DELETE_BUTTON, isInDanger), _types.TableCssClassName.TABLE_SELECTED, (0, _utils2.isTableSelected)(selection !== null && selection !== void 0 ? selection : view.state.selection)), _types.TableCssClassName.NESTED_TABLE_WITH_CONTROLS, tableActive && allowControls && this.isNestedInTable)),
|
|
1008
|
-
editorView: view,
|
|
1009
|
-
getPos: getPos,
|
|
1010
|
-
node: node
|
|
1011
|
-
// Ignored via go/ees005
|
|
1012
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
1013
|
-
,
|
|
1014
|
-
tableRef: tableRef,
|
|
1015
|
-
containerWidth: containerWidth,
|
|
1016
|
-
isNested: isNested,
|
|
1017
|
-
pluginInjectionApi: pluginInjectionApi,
|
|
1018
|
-
tableWrapperHeight: this.state.tableWrapperHeight,
|
|
1019
|
-
isTableResizingEnabled: allowTableResizing,
|
|
1020
|
-
isResizing: isResizing,
|
|
1021
|
-
isTableScalingEnabled: isTableScalingEnabled,
|
|
1022
|
-
isTableWithFixedColumnWidthsOptionEnabled: tableWithFixedColumnWidthsOption,
|
|
1023
|
-
isWholeTableInDanger: isWholeTableInDanger,
|
|
1024
|
-
isTableAlignmentEnabled: allowTableAlignment,
|
|
1025
|
-
shouldUseIncreasedScalingPercent: shouldUseIncreasedScalingPercent,
|
|
1026
|
-
isCommentEditor: options === null || options === void 0 ? void 0 : options.isCommentEditor,
|
|
1027
|
-
isChromelessEditor: options === null || options === void 0 ? void 0 : options.isChromelessEditor
|
|
1028
|
-
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
1029
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
1030
|
-
className: _types.TableCssClassName.TABLE_STICKY_SENTINEL_TOP,
|
|
1031
|
-
"data-testid": "sticky-sentinel-top"
|
|
1032
|
-
}), !this.isNestedInTable && /*#__PURE__*/_react.default.createElement("div", {
|
|
1033
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
1034
|
-
className: _types.TableCssClassName.TABLE_STICKY_SCROLLBAR_SENTINEL_TOP,
|
|
1035
|
-
"data-testid": "sticky-scrollbar-sentinel-top"
|
|
1036
|
-
}), allowControls && rowControls, isDragAndDropEnabled && /*#__PURE__*/_react.default.createElement(_ExternalDropTargets.ExternalDropTargets, {
|
|
1037
|
-
editorView: view,
|
|
1038
|
-
node: node,
|
|
1039
|
-
getScrollOffset: function getScrollOffset() {
|
|
1040
|
-
var _this6$wrapper2;
|
|
1041
|
-
return ((_this6$wrapper2 = _this6.wrapper) === null || _this6$wrapper2 === void 0 ? void 0 : _this6$wrapper2.scrollLeft) || 0;
|
|
1042
|
-
},
|
|
1043
|
-
getTableWrapperWidth: function getTableWrapperWidth() {
|
|
1044
|
-
var _this6$wrapper3;
|
|
1045
|
-
return ((_this6$wrapper3 = _this6.wrapper) === null || _this6$wrapper3 === void 0 ? void 0 : _this6$wrapper3.clientWidth) || 760;
|
|
1046
|
-
}
|
|
1047
|
-
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
1048
|
-
contentEditable: false
|
|
1049
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
1050
|
-
,
|
|
1051
|
-
style: shadowStyle(showBeforeShadow)
|
|
1052
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
1053
|
-
,
|
|
1054
|
-
className: options !== null && options !== void 0 && options.isChromelessEditor && !isDragAndDropEnabled ? _types.TableCssClassName.TABLE_LEFT_SHADOW + ' ' + _types.TableCssClassName.TABLE_CHROMELESS : _types.TableCssClassName.TABLE_LEFT_SHADOW
|
|
1055
|
-
}), this.state.stickyHeader && /*#__PURE__*/_react.default.createElement("div", {
|
|
1056
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
1057
|
-
className: "".concat(_types.TableCssClassName.TABLE_LEFT_SHADOW, " ").concat(_types.TableCssClassName.TABLE_STICKY_SHADOW),
|
|
1058
|
-
style: {
|
|
1059
|
-
visibility: showBeforeShadow && hasHeaderRow ? 'visible' : 'hidden',
|
|
1060
|
-
top: "".concat(topStickyShadowPosition, "px"),
|
|
1061
|
-
paddingBottom: "".concat(isDragAndDropEnabled && "var(--ds-space-025, 2px)")
|
|
1062
|
-
}
|
|
1063
|
-
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
1064
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
1065
|
-
className: (0, _classnames2.default)(_types.TableCssClassName.TABLE_NODE_WRAPPER),
|
|
1066
|
-
ref: function ref(elem) {
|
|
1067
|
-
_this6.wrapper = elem;
|
|
1068
|
-
if (elem) {
|
|
1069
|
-
_this6.props.contentDOM(elem);
|
|
1070
|
-
var tableElement = elem.querySelector('table');
|
|
1071
|
-
if (tableElement !== _this6.table) {
|
|
1072
|
-
_this6.table = tableElement;
|
|
1073
|
-
_this6.createShadowSentinels(_this6.table);
|
|
1074
|
-
_this6.observeTable(_this6.table);
|
|
1075
|
-
}
|
|
1076
|
-
}
|
|
1077
|
-
}
|
|
1078
|
-
}, allowControls && colControls), !this.isNestedInTable ? /*#__PURE__*/_react.default.createElement("div", {
|
|
1079
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
1080
|
-
className: _types.TableCssClassName.TABLE_STICKY_SCROLLBAR_CONTAINER,
|
|
1081
|
-
"data-vc-nvs": "true",
|
|
1082
|
-
style: {
|
|
1083
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
1084
|
-
height: "var(--ds-space-250, 20px)",
|
|
1085
|
-
// MAX_BROWSER_SCROLLBAR_HEIGHT
|
|
1086
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
1087
|
-
display: 'none',
|
|
1088
|
-
// prevent unwanted scroll during table resize without removing scrollbar container from the dom
|
|
1089
|
-
width: isResizing ? "var(--ds-space-0, 0px)" : '100%'
|
|
1090
|
-
}
|
|
1091
|
-
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
1092
|
-
style: {
|
|
1093
|
-
width: tableRef === null || tableRef === void 0 ? void 0 : tableRef.clientWidth,
|
|
1094
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
1095
|
-
height: '100%'
|
|
1096
|
-
},
|
|
1097
|
-
"data-vc-nvs": "true"
|
|
1098
|
-
})) : /*#__PURE__*/_react.default.createElement("div", {
|
|
1099
|
-
style: {
|
|
1100
|
-
width: tableRef === null || tableRef === void 0 ? void 0 : tableRef.clientWidth,
|
|
1101
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
1102
|
-
height: '100%'
|
|
1103
|
-
},
|
|
1104
|
-
"data-vc-nvs": "true"
|
|
1105
|
-
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
1106
|
-
contentEditable: false
|
|
1107
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
1108
|
-
,
|
|
1109
|
-
style: shadowStyle(showAfterShadow)
|
|
1110
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
1111
|
-
,
|
|
1112
|
-
className: options !== null && options !== void 0 && options.isChromelessEditor && !isDragAndDropEnabled ? _types.TableCssClassName.TABLE_RIGHT_SHADOW + ' ' + _types.TableCssClassName.TABLE_CHROMELESS : _types.TableCssClassName.TABLE_RIGHT_SHADOW
|
|
1113
|
-
}), this.state.stickyHeader && /*#__PURE__*/_react.default.createElement("div", {
|
|
1114
|
-
style: {
|
|
1115
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
1116
|
-
position: 'absolute',
|
|
1117
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
1118
|
-
right: "var(--ds-space-400, 32px)" // tableOverflowShadowWidthWide
|
|
1119
|
-
}
|
|
1120
|
-
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
1121
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
1122
|
-
className: "".concat(_types.TableCssClassName.TABLE_RIGHT_SHADOW, " ").concat(_types.TableCssClassName.TABLE_STICKY_SHADOW),
|
|
1123
|
-
style: {
|
|
1124
|
-
visibility: showAfterShadow && hasHeaderRow ? 'visible' : 'hidden',
|
|
1125
|
-
top: "".concat(topStickyShadowPosition, "px"),
|
|
1126
|
-
paddingBottom: "".concat(isDragAndDropEnabled && "var(--ds-space-025, 2px)")
|
|
1127
|
-
}
|
|
1128
|
-
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
1129
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
1130
|
-
className: _types.TableCssClassName.TABLE_STICKY_SENTINEL_BOTTOM,
|
|
1131
|
-
"data-testid": "sticky-sentinel-bottom"
|
|
1132
|
-
}), !this.isNestedInTable && /*#__PURE__*/_react.default.createElement("div", {
|
|
1133
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
1134
|
-
className: _types.TableCssClassName.TABLE_STICKY_SCROLLBAR_SENTINEL_BOTTOM,
|
|
1135
|
-
"data-testid": "sticky-scrollbar-sentinel-bottom"
|
|
1136
|
-
}));
|
|
1137
|
-
}
|
|
1138
|
-
}]);
|
|
1139
|
-
}(_react.default.Component);
|
|
1140
|
-
(0, _defineProperty3.default)(TableComponent, "displayName", 'TableComponent');
|
|
1141
|
-
var _default = exports.default = (0, _reactIntlNext.injectIntl)(TableComponent);
|