@atlaskit/editor-plugin-table 16.1.5 → 16.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 16.1.7
4
+
5
+ ### Patch Changes
6
+
7
+ - [`acd81a73a9a20`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/acd81a73a9a20) -
8
+ [ux] EDITOR-4259 Set table ref when table is rendered
9
+ - Updated dependencies
10
+
11
+ ## 16.1.6
12
+
13
+ ### Patch Changes
14
+
15
+ - [`8c24728c97456`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/8c24728c97456) -
16
+ EDITOR-3638 Exclude zero intersection entries when scroll is detected
17
+ - Updated dependencies
18
+
3
19
  ## 16.1.5
4
20
 
5
21
  ### Patch Changes
@@ -926,6 +926,12 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
926
926
  if (tableElement !== _this5.table) {
927
927
  _this5.table = tableElement;
928
928
  _this5.observeTable(_this5.table);
929
+
930
+ // // Update tableRef in plugin state when table is properly mounted
931
+ // // At this point, both table and wrapper are in DOM with correct parent-child relationship
932
+ if (_this5.table && _this5.props.view && (0, _expValEquals.expValEquals)('platform_editor_table_update_table_ref', 'isEnabled', true)) {
933
+ (0, _commands.setTableRef)(_this5.table)(_this5.props.view.state, _this5.props.view.dispatch);
934
+ }
929
935
  }
930
936
  }
931
937
  }
@@ -285,7 +285,7 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
285
285
  */
286
286
  entries.forEach(function (entry) {
287
287
  var tableWrapper = _this3.dom.closest(".".concat(_types.TableCssClassName.TABLE_NODE_WRAPPER));
288
- 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))) {
289
289
  if (entry.isIntersecting) {
290
290
  tableWrapper.classList.add(_types.TableCssClassName.TABLE_NODE_WRAPPER_NO_OVERFLOW);
291
291
  _this3.dom.classList.add(_types.TableCssClassName.NATIVE_STICKY);
@@ -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
  };
@@ -13,7 +13,7 @@ import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
13
13
  import { isTableSelected } from '@atlaskit/editor-tables/utils';
14
14
  import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';
15
15
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
16
- import { autoSizeTable, clearHoverSelection } from '../pm-plugins/commands';
16
+ import { autoSizeTable, clearHoverSelection, setTableRef } from '../pm-plugins/commands';
17
17
  import { autoScrollerFactory } from '../pm-plugins/drag-and-drop/utils/autoscrollers';
18
18
  import { pluginKey as stickyHeadersPluginKey } from '../pm-plugins/sticky-headers/plugin-key';
19
19
  import { findStickyHeaderForTable } from '../pm-plugins/sticky-headers/util';
@@ -891,6 +891,12 @@ class TableComponent extends React.Component {
891
891
  if (tableElement !== this.table) {
892
892
  this.table = tableElement;
893
893
  this.observeTable(this.table);
894
+
895
+ // // Update tableRef in plugin state when table is properly mounted
896
+ // // At this point, both table and wrapper are in DOM with correct parent-child relationship
897
+ if (this.table && this.props.view && expValEquals('platform_editor_table_update_table_ref', 'isEnabled', true)) {
898
+ setTableRef(this.table)(this.props.view.state, this.props.view.dispatch);
899
+ }
894
900
  }
895
901
  }
896
902
  }
@@ -14,7 +14,7 @@ import { getPluginState } from '../pm-plugins/plugin-factory';
14
14
  import { pluginKey as tablePluginKey } from '../pm-plugins/plugin-key';
15
15
  import { updateStickyState } from '../pm-plugins/sticky-headers/commands';
16
16
  import { syncStickyRowToTable, updateStickyMargins as updateTableMargin } from '../pm-plugins/table-resizing/utils/dom';
17
- import { getTop, getTree } from '../pm-plugins/utils/dom';
17
+ import { areAllRectsZero, getTop, getTree } from '../pm-plugins/utils/dom';
18
18
  import { supportedHeaderRow } from '../pm-plugins/utils/nodes';
19
19
  import { TableCssClassName as ClassName, TableCssClassName } from '../types';
20
20
  import { stickyHeaderBorderBottomWidth, stickyRowOffsetTop, tableControlsSpacing, tableScrollbarOffset } from '../ui/consts';
@@ -259,7 +259,7 @@ export default class TableRowNativeStickyWithFallback extends TableNodeView {
259
259
  */
260
260
  entries.forEach(entry => {
261
261
  const tableWrapper = this.dom.closest(`.${ClassName.TABLE_NODE_WRAPPER}`);
262
- 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))) {
263
263
  if (entry.isIntersecting) {
264
264
  tableWrapper.classList.add(ClassName.TABLE_NODE_WRAPPER_NO_OVERFLOW);
265
265
  this.dom.classList.add(ClassName.NATIVE_STICKY);
@@ -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
  };
@@ -26,7 +26,7 @@ import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
26
26
  import { isTableSelected } from '@atlaskit/editor-tables/utils';
27
27
  import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';
28
28
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
29
- import { autoSizeTable, clearHoverSelection } from '../pm-plugins/commands';
29
+ import { autoSizeTable, clearHoverSelection, setTableRef } from '../pm-plugins/commands';
30
30
  import { autoScrollerFactory } from '../pm-plugins/drag-and-drop/utils/autoscrollers';
31
31
  import { pluginKey as stickyHeadersPluginKey } from '../pm-plugins/sticky-headers/plugin-key';
32
32
  import { findStickyHeaderForTable } from '../pm-plugins/sticky-headers/util';
@@ -920,6 +920,12 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
920
920
  if (tableElement !== _this5.table) {
921
921
  _this5.table = tableElement;
922
922
  _this5.observeTable(_this5.table);
923
+
924
+ // // Update tableRef in plugin state when table is properly mounted
925
+ // // At this point, both table and wrapper are in DOM with correct parent-child relationship
926
+ if (_this5.table && _this5.props.view && expValEquals('platform_editor_table_update_table_ref', 'isEnabled', true)) {
927
+ setTableRef(_this5.table)(_this5.props.view.state, _this5.props.view.dispatch);
928
+ }
923
929
  }
924
930
  }
925
931
  }
@@ -21,7 +21,7 @@ import { getPluginState } from '../pm-plugins/plugin-factory';
21
21
  import { pluginKey as tablePluginKey } from '../pm-plugins/plugin-key';
22
22
  import { updateStickyState } from '../pm-plugins/sticky-headers/commands';
23
23
  import { syncStickyRowToTable, updateStickyMargins as updateTableMargin } from '../pm-plugins/table-resizing/utils/dom';
24
- import { getTop, getTree } from '../pm-plugins/utils/dom';
24
+ import { areAllRectsZero, getTop, getTree } from '../pm-plugins/utils/dom';
25
25
  import { supportedHeaderRow } from '../pm-plugins/utils/nodes';
26
26
  import { TableCssClassName as ClassName, TableCssClassName } from '../types';
27
27
  import { stickyHeaderBorderBottomWidth, stickyRowOffsetTop, tableControlsSpacing, tableScrollbarOffset } from '../ui/consts';
@@ -278,7 +278,7 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_ref) {
278
278
  */
279
279
  entries.forEach(function (entry) {
280
280
  var tableWrapper = _this3.dom.closest(".".concat(ClassName.TABLE_NODE_WRAPPER));
281
- 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))) {
282
282
  if (entry.isIntersecting) {
283
283
  tableWrapper.classList.add(ClassName.TABLE_NODE_WRAPPER_NO_OVERFLOW);
284
284
  _this3.dom.classList.add(ClassName.NATIVE_STICKY);
@@ -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
  };
@@ -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;
@@ -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.5",
3
+ "version": "16.1.7",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -57,7 +57,7 @@
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.8.0",
60
+ "@atlaskit/tmp-editor-statsig": "^16.10.0",
61
61
  "@atlaskit/toggle": "^15.2.0",
62
62
  "@atlaskit/tokens": "^9.1.0",
63
63
  "@atlaskit/tooltip": "^20.12.0",