@atlaskit/editor-plugin-table 16.1.4 → 16.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 16.1.6
4
+
5
+ ### Patch Changes
6
+
7
+ - [`8c24728c97456`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/8c24728c97456) -
8
+ EDITOR-3638 Exclude zero intersection entries when scroll is detected
9
+ - Updated dependencies
10
+
11
+ ## 16.1.5
12
+
13
+ ### Patch Changes
14
+
15
+ - [`38de936c97015`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/38de936c97015) -
16
+ EDITOR-3707 Fire UI event when native/ legacy sticky headers are enabled
17
+ - Updated dependencies
18
+
3
19
  ## 16.1.4
4
20
 
5
21
  ### Patch Changes
@@ -13,6 +13,7 @@ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits
13
13
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
14
14
  var _debounce = _interopRequireDefault(require("lodash/debounce"));
15
15
  var _throttle = _interopRequireDefault(require("lodash/throttle"));
16
+ var _analytics = require("@atlaskit/editor-common/analytics");
16
17
  var _nesting = require("@atlaskit/editor-common/nesting");
17
18
  var _nodeVisibility = require("@atlaskit/editor-common/node-visibility");
18
19
  var _styles = require("@atlaskit/editor-common/styles");
@@ -112,6 +113,7 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
112
113
  var _getPluginState = (0, _pluginFactory.getPluginState)(view.state),
113
114
  pluginConfig = _getPluginState.pluginConfig;
114
115
  _this.isStickyHeaderEnabled = !!pluginConfig.stickyHeaders;
116
+ _this.api = api;
115
117
  if (api !== null && api !== void 0 && (_api$limitedMode = api.limitedMode) !== null && _api$limitedMode !== void 0 && (_api$limitedMode = _api$limitedMode.sharedState.currentState()) !== null && _api$limitedMode !== void 0 && (_api$limitedMode = _api$limitedMode.limitedModePluginKey.getState(view.state)) !== null && _api$limitedMode !== void 0 && _api$limitedMode.documentSizeBreachesThreshold) {
116
118
  _this.isStickyHeaderEnabled = false;
117
119
  // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
@@ -283,7 +285,7 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
283
285
  */
284
286
  entries.forEach(function (entry) {
285
287
  var tableWrapper = _this3.dom.closest(".".concat(_types.TableCssClassName.TABLE_NODE_WRAPPER));
286
- if (tableWrapper && tableWrapper instanceof HTMLElement) {
288
+ if (tableWrapper && tableWrapper instanceof HTMLElement && (!(0, _dom2.areAllRectsZero)(entry) && (0, _expValEquals.expValEquals)('platform_editor_table_sticky_header_patch_10', 'isEnabled', true) || !(0, _expValEquals.expValEquals)('platform_editor_table_sticky_header_patch_10', 'isEnabled', true))) {
287
289
  if (entry.isIntersecting) {
288
290
  tableWrapper.classList.add(_types.TableCssClassName.TABLE_NODE_WRAPPER_NO_OVERFLOW);
289
291
  _this3.dom.classList.add(_types.TableCssClassName.NATIVE_STICKY);
@@ -403,6 +405,18 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
403
405
  _this4.isNativeSticky = false;
404
406
  }
405
407
  _this4.refreshLegacyStickyState();
408
+ if ((0, _expValEquals.expValEquals)('platform_editor_table_sticky_header_patch_9', 'isEnabled', true)) {
409
+ var _this4$api;
410
+ (_this4$api = _this4.api) === null || _this4$api === void 0 || (_this4$api = _this4$api.analytics) === null || _this4$api === void 0 || (_this4$api = _this4$api.actions) === null || _this4$api === void 0 || _this4$api.fireAnalyticsEvent({
411
+ action: _analytics.TABLE_ACTION.STICKY_HEADER_METHOD_TOGGLED,
412
+ actionSubject: _analytics.ACTION_SUBJECT.TABLE,
413
+ actionSubjectId: _analytics.ACTION_SUBJECT_ID.TABLE_STICKY_HEADER,
414
+ eventType: _analytics.EVENT_TYPE.UI,
415
+ attributes: {
416
+ nativeStickyHeaderEnabled: entry.isIntersecting
417
+ }
418
+ });
419
+ }
406
420
  });
407
421
  }, options);
408
422
  }
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.isTableControlsButton = exports.isTableContainerOrWrapper = exports.isRowControlsButton = exports.isResizeHandleDecoration = exports.isInsertRowButton = exports.isDragRowFloatingInsertDot = exports.isDragCornerButton = exports.isDragColumnFloatingInsertDot = exports.isCornerButton = exports.isColumnControlsDecorations = exports.isCell = exports.hasResizeHandler = exports.getTree = exports.getTop = exports.getMousePositionVerticalRelativeByElement = exports.getMousePositionHorizontalRelativeByElement = exports.getColumnOrRowIndex = exports.findNearestCellIndexToPoint = void 0;
6
+ exports.isTableControlsButton = exports.isTableContainerOrWrapper = exports.isRowControlsButton = exports.isResizeHandleDecoration = exports.isInsertRowButton = exports.isDragRowFloatingInsertDot = exports.isDragCornerButton = exports.isDragColumnFloatingInsertDot = exports.isCornerButton = exports.isColumnControlsDecorations = exports.isCell = exports.hasResizeHandler = exports.getTree = exports.getTop = exports.getMousePositionVerticalRelativeByElement = exports.getMousePositionHorizontalRelativeByElement = exports.getColumnOrRowIndex = exports.findNearestCellIndexToPoint = exports.areAllRectsZero = void 0;
7
7
  var _utils = require("@atlaskit/editor-common/utils");
8
8
  var _types = require("../../types");
9
9
  var isCell = exports.isCell = function isCell(node) {
@@ -202,4 +202,10 @@ var findNearestCellIndexToPoint = exports.findNearestCellIndexToPoint = function
202
202
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
203
203
  col: cell.cellIndex
204
204
  };
205
+ };
206
+ var areAllRectsZero = exports.areAllRectsZero = function areAllRectsZero(entry) {
207
+ var rects = [entry.boundingClientRect, entry.rootBounds, entry.intersectionRect];
208
+ return rects.every(function (rect) {
209
+ return rect && rect.width === 0 && rect.height === 0 && rect.top === 0 && rect.left === 0 && rect.bottom === 0 && rect.right === 0 && rect.x === 0 && rect.y === 0;
210
+ });
205
211
  };
@@ -1,6 +1,7 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import debounce from 'lodash/debounce';
3
3
  import throttle from 'lodash/throttle';
4
+ import { ACTION_SUBJECT_ID, ACTION_SUBJECT, EVENT_TYPE, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
4
5
  import { getParentOfTypeCount } from '@atlaskit/editor-common/nesting';
5
6
  import { nodeVisibilityManager } from '@atlaskit/editor-common/node-visibility';
6
7
  import { tableMarginTop } from '@atlaskit/editor-common/styles';
@@ -13,7 +14,7 @@ import { getPluginState } from '../pm-plugins/plugin-factory';
13
14
  import { pluginKey as tablePluginKey } from '../pm-plugins/plugin-key';
14
15
  import { updateStickyState } from '../pm-plugins/sticky-headers/commands';
15
16
  import { syncStickyRowToTable, updateStickyMargins as updateTableMargin } from '../pm-plugins/table-resizing/utils/dom';
16
- import { getTop, getTree } from '../pm-plugins/utils/dom';
17
+ import { areAllRectsZero, getTop, getTree } from '../pm-plugins/utils/dom';
17
18
  import { supportedHeaderRow } from '../pm-plugins/utils/nodes';
18
19
  import { TableCssClassName as ClassName, TableCssClassName } from '../types';
19
20
  import { stickyHeaderBorderBottomWidth, stickyRowOffsetTop, tableControlsSpacing, tableScrollbarOffset } from '../ui/consts';
@@ -97,6 +98,7 @@ export default class TableRowNativeStickyWithFallback extends TableNodeView {
97
98
  pluginConfig
98
99
  } = getPluginState(view.state);
99
100
  this.isStickyHeaderEnabled = !!pluginConfig.stickyHeaders;
101
+ this.api = api;
100
102
  if (api !== null && api !== void 0 && (_api$limitedMode = api.limitedMode) !== null && _api$limitedMode !== void 0 && (_api$limitedMode$shar = _api$limitedMode.sharedState.currentState()) !== null && _api$limitedMode$shar !== void 0 && (_api$limitedMode$shar2 = _api$limitedMode$shar.limitedModePluginKey.getState(view.state)) !== null && _api$limitedMode$shar2 !== void 0 && _api$limitedMode$shar2.documentSizeBreachesThreshold) {
101
103
  this.isStickyHeaderEnabled = false;
102
104
  // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
@@ -257,7 +259,7 @@ export default class TableRowNativeStickyWithFallback extends TableNodeView {
257
259
  */
258
260
  entries.forEach(entry => {
259
261
  const tableWrapper = this.dom.closest(`.${ClassName.TABLE_NODE_WRAPPER}`);
260
- if (tableWrapper && tableWrapper instanceof HTMLElement) {
262
+ if (tableWrapper && tableWrapper instanceof HTMLElement && (!areAllRectsZero(entry) && expValEquals('platform_editor_table_sticky_header_patch_10', 'isEnabled', true) || !expValEquals('platform_editor_table_sticky_header_patch_10', 'isEnabled', true))) {
261
263
  if (entry.isIntersecting) {
262
264
  tableWrapper.classList.add(ClassName.TABLE_NODE_WRAPPER_NO_OVERFLOW);
263
265
  this.dom.classList.add(ClassName.NATIVE_STICKY);
@@ -372,6 +374,18 @@ export default class TableRowNativeStickyWithFallback extends TableNodeView {
372
374
  this.isNativeSticky = false;
373
375
  }
374
376
  this.refreshLegacyStickyState();
377
+ if (expValEquals('platform_editor_table_sticky_header_patch_9', 'isEnabled', true)) {
378
+ var _this$api, _this$api$analytics, _this$api$analytics$a;
379
+ (_this$api = this.api) === null || _this$api === void 0 ? void 0 : (_this$api$analytics = _this$api.analytics) === null || _this$api$analytics === void 0 ? void 0 : (_this$api$analytics$a = _this$api$analytics.actions) === null || _this$api$analytics$a === void 0 ? void 0 : _this$api$analytics$a.fireAnalyticsEvent({
380
+ action: TABLE_ACTION.STICKY_HEADER_METHOD_TOGGLED,
381
+ actionSubject: ACTION_SUBJECT.TABLE,
382
+ actionSubjectId: ACTION_SUBJECT_ID.TABLE_STICKY_HEADER,
383
+ eventType: EVENT_TYPE.UI,
384
+ attributes: {
385
+ nativeStickyHeaderEnabled: entry.isIntersecting
386
+ }
387
+ });
388
+ }
375
389
  });
376
390
  }, options);
377
391
  }
@@ -173,4 +173,8 @@ export const findNearestCellIndexToPoint = (x, y) => {
173
173
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
174
174
  col: cell.cellIndex
175
175
  };
176
+ };
177
+ export const areAllRectsZero = entry => {
178
+ const rects = [entry.boundingClientRect, entry.rootBounds, entry.intersectionRect];
179
+ return rects.every(rect => rect && rect.width === 0 && rect.height === 0 && rect.top === 0 && rect.left === 0 && rect.bottom === 0 && rect.right === 0 && rect.x === 0 && rect.y === 0);
176
180
  };
@@ -8,6 +8,7 @@ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstruct
8
8
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
9
9
  import debounce from 'lodash/debounce';
10
10
  import throttle from 'lodash/throttle';
11
+ import { ACTION_SUBJECT_ID, ACTION_SUBJECT, EVENT_TYPE, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
11
12
  import { getParentOfTypeCount } from '@atlaskit/editor-common/nesting';
12
13
  import { nodeVisibilityManager } from '@atlaskit/editor-common/node-visibility';
13
14
  import { tableMarginTop } from '@atlaskit/editor-common/styles';
@@ -20,7 +21,7 @@ import { getPluginState } from '../pm-plugins/plugin-factory';
20
21
  import { pluginKey as tablePluginKey } from '../pm-plugins/plugin-key';
21
22
  import { updateStickyState } from '../pm-plugins/sticky-headers/commands';
22
23
  import { syncStickyRowToTable, updateStickyMargins as updateTableMargin } from '../pm-plugins/table-resizing/utils/dom';
23
- import { getTop, getTree } from '../pm-plugins/utils/dom';
24
+ import { areAllRectsZero, getTop, getTree } from '../pm-plugins/utils/dom';
24
25
  import { supportedHeaderRow } from '../pm-plugins/utils/nodes';
25
26
  import { TableCssClassName as ClassName, TableCssClassName } from '../types';
26
27
  import { stickyHeaderBorderBottomWidth, stickyRowOffsetTop, tableControlsSpacing, tableScrollbarOffset } from '../ui/consts';
@@ -105,6 +106,7 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_ref) {
105
106
  var _getPluginState = getPluginState(view.state),
106
107
  pluginConfig = _getPluginState.pluginConfig;
107
108
  _this.isStickyHeaderEnabled = !!pluginConfig.stickyHeaders;
109
+ _this.api = api;
108
110
  if (api !== null && api !== void 0 && (_api$limitedMode = api.limitedMode) !== null && _api$limitedMode !== void 0 && (_api$limitedMode = _api$limitedMode.sharedState.currentState()) !== null && _api$limitedMode !== void 0 && (_api$limitedMode = _api$limitedMode.limitedModePluginKey.getState(view.state)) !== null && _api$limitedMode !== void 0 && _api$limitedMode.documentSizeBreachesThreshold) {
109
111
  _this.isStickyHeaderEnabled = false;
110
112
  // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
@@ -276,7 +278,7 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_ref) {
276
278
  */
277
279
  entries.forEach(function (entry) {
278
280
  var tableWrapper = _this3.dom.closest(".".concat(ClassName.TABLE_NODE_WRAPPER));
279
- if (tableWrapper && tableWrapper instanceof HTMLElement) {
281
+ if (tableWrapper && tableWrapper instanceof HTMLElement && (!areAllRectsZero(entry) && expValEquals('platform_editor_table_sticky_header_patch_10', 'isEnabled', true) || !expValEquals('platform_editor_table_sticky_header_patch_10', 'isEnabled', true))) {
280
282
  if (entry.isIntersecting) {
281
283
  tableWrapper.classList.add(ClassName.TABLE_NODE_WRAPPER_NO_OVERFLOW);
282
284
  _this3.dom.classList.add(ClassName.NATIVE_STICKY);
@@ -396,6 +398,18 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_ref) {
396
398
  _this4.isNativeSticky = false;
397
399
  }
398
400
  _this4.refreshLegacyStickyState();
401
+ if (expValEquals('platform_editor_table_sticky_header_patch_9', 'isEnabled', true)) {
402
+ var _this4$api;
403
+ (_this4$api = _this4.api) === null || _this4$api === void 0 || (_this4$api = _this4$api.analytics) === null || _this4$api === void 0 || (_this4$api = _this4$api.actions) === null || _this4$api === void 0 || _this4$api.fireAnalyticsEvent({
404
+ action: TABLE_ACTION.STICKY_HEADER_METHOD_TOGGLED,
405
+ actionSubject: ACTION_SUBJECT.TABLE,
406
+ actionSubjectId: ACTION_SUBJECT_ID.TABLE_STICKY_HEADER,
407
+ eventType: EVENT_TYPE.UI,
408
+ attributes: {
409
+ nativeStickyHeaderEnabled: entry.isIntersecting
410
+ }
411
+ });
412
+ }
399
413
  });
400
414
  }, options);
401
415
  }
@@ -196,4 +196,10 @@ export var findNearestCellIndexToPoint = function findNearestCellIndexToPoint(x,
196
196
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
197
197
  col: cell.cellIndex
198
198
  };
199
+ };
200
+ export var areAllRectsZero = function areAllRectsZero(entry) {
201
+ var rects = [entry.boundingClientRect, entry.rootBounds, entry.intersectionRect];
202
+ return rects.every(function (rect) {
203
+ return rect && rect.width === 0 && rect.height === 0 && rect.top === 0 && rect.left === 0 && rect.bottom === 0 && rect.right === 0 && rect.x === 0 && rect.y === 0;
204
+ });
199
205
  };
@@ -28,6 +28,7 @@ export default class TableRowNativeStickyWithFallback extends TableNodeView<HTML
28
28
  private listening;
29
29
  private padding;
30
30
  private top;
31
+ private api?;
31
32
  /** Native sticky header variables */
32
33
  private overflowObserver?;
33
34
  private stickyStateObserver?;
@@ -36,3 +36,4 @@ export declare const findNearestCellIndexToPoint: (x: number, y: number) => {
36
36
  col: number;
37
37
  row: number;
38
38
  } | undefined;
39
+ export declare const areAllRectsZero: (entry: IntersectionObserverEntry) => boolean;
@@ -28,6 +28,7 @@ export default class TableRowNativeStickyWithFallback extends TableNodeView<HTML
28
28
  private listening;
29
29
  private padding;
30
30
  private top;
31
+ private api?;
31
32
  /** Native sticky header variables */
32
33
  private overflowObserver?;
33
34
  private stickyStateObserver?;
@@ -39,3 +39,4 @@ export declare const findNearestCellIndexToPoint: (x: number, y: number) => {
39
39
  col: number;
40
40
  row: number;
41
41
  } | undefined;
42
+ export declare const areAllRectsZero: (entry: IntersectionObserverEntry) => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "16.1.4",
3
+ "version": "16.1.6",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -48,7 +48,7 @@
48
48
  "@atlaskit/editor-prosemirror": "^7.2.0",
49
49
  "@atlaskit/editor-shared-styles": "^3.10.0",
50
50
  "@atlaskit/editor-tables": "^2.9.0",
51
- "@atlaskit/icon": "^29.3.0",
51
+ "@atlaskit/icon": "^29.4.0",
52
52
  "@atlaskit/insm": "^0.2.0",
53
53
  "@atlaskit/menu": "^8.4.0",
54
54
  "@atlaskit/platform-feature-flags": "^1.1.0",
@@ -57,10 +57,10 @@
57
57
  "@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.1.0",
58
58
  "@atlaskit/primitives": "^17.0.0",
59
59
  "@atlaskit/theme": "^21.0.0",
60
- "@atlaskit/tmp-editor-statsig": "^16.4.0",
60
+ "@atlaskit/tmp-editor-statsig": "^16.9.0",
61
61
  "@atlaskit/toggle": "^15.2.0",
62
62
  "@atlaskit/tokens": "^9.1.0",
63
- "@atlaskit/tooltip": "^20.11.0",
63
+ "@atlaskit/tooltip": "^20.12.0",
64
64
  "@babel/runtime": "^7.0.0",
65
65
  "@emotion/react": "^11.7.1",
66
66
  "classnames": "^2.2.5",
@@ -70,7 +70,7 @@
70
70
  "uuid": "^3.1.0"
71
71
  },
72
72
  "peerDependencies": {
73
- "@atlaskit/editor-common": "^111.2.0",
73
+ "@atlaskit/editor-common": "^111.6.0",
74
74
  "react": "^18.2.0",
75
75
  "react-dom": "^18.2.0",
76
76
  "react-intl-next": "npm:react-intl@^5.18.1"