@atlaskit/editor-plugin-table 15.4.22 → 15.4.24

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.
Files changed (36) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/cjs/nodeviews/TableComponent.js +2 -1
  3. package/dist/cjs/nodeviews/table-node-views.js +3 -2
  4. package/dist/cjs/pm-plugins/main.js +2 -1
  5. package/dist/cjs/pm-plugins/utils/sticky-header.js +24 -0
  6. package/dist/cjs/ui/ContentComponent.js +2 -1
  7. package/dist/cjs/ui/FloatingContextualButton/index.js +5 -2
  8. package/dist/cjs/ui/TableFloatingColumnControls/index.js +4 -3
  9. package/dist/es2019/nodeviews/TableComponent.js +2 -1
  10. package/dist/es2019/nodeviews/table-node-views.js +3 -2
  11. package/dist/es2019/pm-plugins/main.js +2 -1
  12. package/dist/es2019/pm-plugins/utils/sticky-header.js +17 -0
  13. package/dist/es2019/ui/ContentComponent.js +2 -1
  14. package/dist/es2019/ui/FloatingContextualButton/index.js +5 -2
  15. package/dist/es2019/ui/TableFloatingColumnControls/index.js +4 -3
  16. package/dist/esm/nodeviews/TableComponent.js +2 -1
  17. package/dist/esm/nodeviews/table-node-views.js +3 -2
  18. package/dist/esm/pm-plugins/main.js +2 -1
  19. package/dist/esm/pm-plugins/utils/sticky-header.js +17 -0
  20. package/dist/esm/ui/ContentComponent.js +2 -1
  21. package/dist/esm/ui/FloatingContextualButton/index.js +5 -2
  22. package/dist/esm/ui/TableFloatingColumnControls/index.js +4 -3
  23. package/dist/types/nodeviews/table-node-views.d.ts +1 -0
  24. package/dist/types/pm-plugins/utils/sticky-header.d.ts +2 -0
  25. package/dist/types/ui/FloatingContextualButton/index.d.ts +1 -0
  26. package/dist/types/ui/TableFloatingColumnControls/index.d.ts +2 -1
  27. package/dist/types-ts4.5/nodeviews/table-node-views.d.ts +1 -0
  28. package/dist/types-ts4.5/pm-plugins/utils/sticky-header.d.ts +2 -0
  29. package/dist/types-ts4.5/ui/FloatingContextualButton/index.d.ts +1 -0
  30. package/dist/types-ts4.5/ui/TableFloatingColumnControls/index.d.ts +2 -1
  31. package/package.json +3 -3
  32. package/dist/cjs/pm-plugins/utils/anchor.js +0 -14
  33. package/dist/es2019/pm-plugins/utils/anchor.js +0 -7
  34. package/dist/esm/pm-plugins/utils/anchor.js +0 -7
  35. package/dist/types/pm-plugins/utils/anchor.d.ts +0 -1
  36. package/dist/types-ts4.5/pm-plugins/utils/anchor.d.ts +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 15.4.24
4
+
5
+ ### Patch Changes
6
+
7
+ - [`e51da6f828fe9`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e51da6f828fe9) -
8
+ Exclude Safari due to contenteditable in sticky positioned table header bug
9
+ - Updated dependencies
10
+
11
+ ## 15.4.23
12
+
13
+ ### Patch Changes
14
+
15
+ - [`21089bb0ca0d2`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/21089bb0ca0d2) -
16
+ Only enable new table sticky header if drag and drop flag enabled
17
+
3
18
  ## 15.4.22
4
19
 
5
20
  ### Patch Changes
@@ -857,7 +857,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
857
857
  },
858
858
  tableWrapperHeight: this.state.tableWrapperHeight,
859
859
  api: pluginInjectionApi,
860
- isChromelessEditor: options === null || options === void 0 ? void 0 : options.isChromelessEditor
860
+ isChromelessEditor: options === null || options === void 0 ? void 0 : options.isChromelessEditor,
861
+ isDragAndDropEnabled: isDragAndDropEnabled
861
862
  }) : null;
862
863
 
863
864
  /**
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.tableView = exports.tableRowView = exports.tableHeaderView = exports.tableCellView = void 0;
8
8
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
9
- var _anchor = require("../pm-plugins/utils/anchor");
9
+ var _stickyHeader = require("../pm-plugins/utils/sticky-header");
10
10
  var _table = require("./table");
11
11
  var _TableCell = _interopRequireDefault(require("./TableCell"));
12
12
  var _TableRow = _interopRequireDefault(require("./TableRow"));
@@ -32,7 +32,8 @@ var tableHeaderView = exports.tableHeaderView = function tableHeaderView(options
32
32
  };
33
33
  var tableRowView = exports.tableRowView = function tableRowView(options) {
34
34
  return function (node, view, getPos) {
35
- if ((0, _anchor.isAnchorSupported)() && (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) && (0, _expValEquals.expValEquals)('platform_editor_table_sticky_header_improvements', 'cohort', 'test_with_overflow')) {
35
+ var _options$isDragAndDro;
36
+ if ((0, _stickyHeader.isNativeStickySupported)((_options$isDragAndDro = options.isDragAndDropEnabled) !== null && _options$isDragAndDro !== void 0 ? _options$isDragAndDro : false) && (0, _expValEquals.expValEquals)('platform_editor_table_sticky_header_improvements', 'cohort', 'test_with_overflow')) {
36
37
  return new _TableRowNativeStickyWithFallback.default(node, view, getPos, options.eventDispatcher, options.pluginInjectionApi);
37
38
  } else {
38
39
  return new _TableRow.default(node, view, getPos, options.eventDispatcher, options.pluginInjectionApi);
@@ -76,7 +76,8 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatchAnalytic
76
76
  }),
77
77
  tableRow: (0, _tableNodeViews.tableRowView)({
78
78
  eventDispatcher: eventDispatcher,
79
- pluginInjectionApi: pluginInjectionApi
79
+ pluginInjectionApi: pluginInjectionApi,
80
+ isDragAndDropEnabled: dragAndDropEnabled
80
81
  }),
81
82
  tableCell: (0, _tableNodeViews.tableCellView)({
82
83
  eventDispatcher: eventDispatcher,
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.isNativeStickySupported = exports.isAnchorSupported = void 0;
8
+ var _memoizeOne = _interopRequireDefault(require("memoize-one"));
9
+ var _browser = require("@atlaskit/editor-common/browser");
10
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
11
+ var isAnchorSupported = exports.isAnchorSupported = (0, _memoizeOne.default)(function () {
12
+ if (window.CSS && window.CSS.supports) {
13
+ return window.CSS.supports('anchor-name: --anchor');
14
+ }
15
+ return false;
16
+ });
17
+ var isNativeStickySupported = exports.isNativeStickySupported = function isNativeStickySupported(isDragAndDropEnabled) {
18
+ var safariVersion = (0, _browser.getBrowserInfo)().safari_version;
19
+ var isBrowserSafari = !Number.isNaN(safariVersion);
20
+ return (
21
+ // Safari has a bug with position: sticky and content editable, so we don't support it
22
+ !isBrowserSafari && isAnchorSupported() && isDragAndDropEnabled && (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true)
23
+ );
24
+ };
@@ -112,7 +112,8 @@ var ContentComponentInternal = function ContentComponentInternal(_ref) {
112
112
  isContextualMenuOpen: isContextualMenuOpen,
113
113
  stickyHeader: stickyHeader,
114
114
  tableWrapper: tableWrapperTarget,
115
- isCellMenuOpenByKeyboard: isCellMenuOpenByKeyboard
115
+ isCellMenuOpenByKeyboard: isCellMenuOpenByKeyboard,
116
+ isDragAndDropEnabled: isDragAndDropEnabled
116
117
  }), allowControls && /*#__PURE__*/_react.default.createElement(_FloatingInsertButton.default, {
117
118
  tableNode: tableNode,
118
119
  tableRef: tableRef,
@@ -20,7 +20,7 @@ var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
20
20
  var _chevronDown = _interopRequireDefault(require("@atlaskit/icon/core/migration/chevron-down"));
21
21
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
22
22
  var _commands = require("../../pm-plugins/commands");
23
- var _anchor = require("../../pm-plugins/utils/anchor");
23
+ var _stickyHeader = require("../../pm-plugins/utils/sticky-header");
24
24
  var _types = require("../../types");
25
25
  var _FixedButton = _interopRequireDefault(require("./FixedButton"));
26
26
  var _styles = require("./styles");
@@ -51,6 +51,7 @@ var FloatingContextualButtonInner = /*#__PURE__*/_react.default.memo(function (p
51
51
  tableWrapper = props.tableWrapper,
52
52
  targetCellPosition = props.targetCellPosition,
53
53
  isCellMenuOpenByKeyboard = props.isCellMenuOpenByKeyboard,
54
+ isDragAndDropEnabled = props.isDragAndDropEnabled,
54
55
  formatMessage = props.intl.formatMessage; // : Props & WrappedComponentProps
55
56
 
56
57
  var handleClick = function handleClick() {
@@ -103,7 +104,7 @@ var FloatingContextualButtonInner = /*#__PURE__*/_react.default.memo(function (p
103
104
  }));
104
105
  var parentSticky = targetCellRef.parentElement && targetCellRef.parentElement.className.indexOf('sticky') > -1;
105
106
  var parentStickyNative = targetCellRef.parentElement && targetCellRef.parentElement.classList.contains(_types.TableCssClassName.NATIVE_STICKY);
106
- if ((0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) && (0, _expValEquals.expValEquals)('platform_editor_table_sticky_header_improvements', 'cohort', 'test_with_overflow') && (0, _anchor.isAnchorSupported)() && targetCellRef.nodeName === 'TH' && parentStickyNative) {
107
+ if (parentStickyNative && targetCellRef.nodeName === 'TH' && (0, _stickyHeader.isNativeStickySupported)(isDragAndDropEnabled !== null && isDragAndDropEnabled !== void 0 ? isDragAndDropEnabled : false) && (0, _expValEquals.expValEquals)('platform_editor_table_sticky_header_improvements', 'cohort', 'test_with_overflow')) {
107
108
  var _targetCellRef$datase, _targetCellRef$parent, _targetCellRef$parent2;
108
109
  var anchorName = (_targetCellRef$datase = targetCellRef.dataset.nodeAnchor) !== null && _targetCellRef$datase !== void 0 ? _targetCellRef$datase : '';
109
110
  var rowAnchorName = (_targetCellRef$parent = (_targetCellRef$parent2 = targetCellRef.parentElement) === null || _targetCellRef$parent2 === void 0 ? void 0 : _targetCellRef$parent2.dataset.nodeAnchor) !== null && _targetCellRef$parent !== void 0 ? _targetCellRef$parent : '';
@@ -116,6 +117,8 @@ var FloatingContextualButtonInner = /*#__PURE__*/_react.default.memo(function (p
116
117
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
117
118
  positionAnchor: anchorName
118
119
  } // need to do this because CSSProperties doesn't have positionAnchor property even though it's a valid CSS property
120
+ ,
121
+ "data-testid": "table-cell-options-anchor-wrapper"
119
122
  }, button);
120
123
  }
121
124
  if (stickyHeader && parentSticky && tableWrapper) {
@@ -10,10 +10,10 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
10
10
  var _react = _interopRequireWildcard(require("react"));
11
11
  var _adapter = require("@atlaskit/pragmatic-drag-and-drop/element/adapter");
12
12
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
13
- var _anchor = require("../../pm-plugins/utils/anchor");
14
13
  var _columnControls = require("../../pm-plugins/utils/column-controls");
15
14
  var _nodes = require("../../pm-plugins/utils/nodes");
16
15
  var _rowControls = require("../../pm-plugins/utils/row-controls");
16
+ var _stickyHeader = require("../../pm-plugins/utils/sticky-header");
17
17
  var _types = require("../../types");
18
18
  var _ColumnControls = require("./ColumnControls");
19
19
  var _ColumnDropTargets = require("./ColumnDropTargets");
@@ -35,7 +35,8 @@ var TableFloatingColumnControls = function TableFloatingColumnControls(_ref) {
35
35
  getScrollOffset = _ref.getScrollOffset,
36
36
  tableWrapperHeight = _ref.tableWrapperHeight,
37
37
  api = _ref.api,
38
- isChromelessEditor = _ref.isChromelessEditor;
38
+ isChromelessEditor = _ref.isChromelessEditor,
39
+ isDragAndDropEnabled = _ref.isDragAndDropEnabled;
39
40
  var _useState = (0, _react.useState)(false),
40
41
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
41
42
  isDragging = _useState2[0],
@@ -83,7 +84,7 @@ var TableFloatingColumnControls = function TableFloatingColumnControls(_ref) {
83
84
  containerRef === null || containerRef === void 0 || (_containerRef$current2 = containerRef.current) === null || _containerRef$current2 === void 0 || _containerRef$current2.style.removeProperty('top');
84
85
  }
85
86
  var anchorStyles = {};
86
- if ((0, _anchor.isAnchorSupported)() && (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) && (0, _expValEquals.expValEquals)('platform_editor_table_sticky_header_improvements', 'cohort', 'test_with_overflow')) {
87
+ if ((0, _stickyHeader.isNativeStickySupported)(isDragAndDropEnabled !== null && isDragAndDropEnabled !== void 0 ? isDragAndDropEnabled : false) && (0, _expValEquals.expValEquals)('platform_editor_table_sticky_header_improvements', 'cohort', 'test_with_overflow')) {
87
88
  var _tableRef$querySelect;
88
89
  // cast here is due to CSSProperties missing valid positionAnchor property
89
90
  anchorStyles = {
@@ -816,7 +816,8 @@ class TableComponent extends React.Component {
816
816
  },
817
817
  tableWrapperHeight: this.state.tableWrapperHeight,
818
818
  api: pluginInjectionApi,
819
- isChromelessEditor: options === null || options === void 0 ? void 0 : options.isChromelessEditor
819
+ isChromelessEditor: options === null || options === void 0 ? void 0 : options.isChromelessEditor,
820
+ isDragAndDropEnabled: isDragAndDropEnabled
820
821
  }) : null;
821
822
 
822
823
  /**
@@ -1,5 +1,5 @@
1
1
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
2
- import { isAnchorSupported } from '../pm-plugins/utils/anchor';
2
+ import { isNativeStickySupported } from '../pm-plugins/utils/sticky-header';
3
3
  // TODO: ED-23976 - Clean up
4
4
  import { createTableView } from './table';
5
5
  import TableCell from './TableCell';
@@ -24,7 +24,8 @@ export const tableHeaderView = options => {
24
24
  };
25
25
  export const tableRowView = options => {
26
26
  return (node, view, getPos) => {
27
- if (isAnchorSupported() && expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) && expValEquals('platform_editor_table_sticky_header_improvements', 'cohort', 'test_with_overflow')) {
27
+ var _options$isDragAndDro;
28
+ if (isNativeStickySupported((_options$isDragAndDro = options.isDragAndDropEnabled) !== null && _options$isDragAndDro !== void 0 ? _options$isDragAndDro : false) && expValEquals('platform_editor_table_sticky_header_improvements', 'cohort', 'test_with_overflow')) {
28
29
  return new TableRowNativeStickyWithFallback(node, view, getPos, options.eventDispatcher, options.pluginInjectionApi);
29
30
  } else {
30
31
  return new TableRow(node, view, getPos, options.eventDispatcher, options.pluginInjectionApi);
@@ -67,7 +67,8 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
67
67
  }),
68
68
  tableRow: tableRowView({
69
69
  eventDispatcher,
70
- pluginInjectionApi
70
+ pluginInjectionApi,
71
+ isDragAndDropEnabled: dragAndDropEnabled
71
72
  }),
72
73
  tableCell: tableCellView({
73
74
  eventDispatcher,
@@ -0,0 +1,17 @@
1
+ import memorizeOne from 'memoize-one';
2
+ import { getBrowserInfo } from '@atlaskit/editor-common/browser';
3
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
4
+ export const isAnchorSupported = memorizeOne(() => {
5
+ if (window.CSS && window.CSS.supports) {
6
+ return window.CSS.supports('anchor-name: --anchor');
7
+ }
8
+ return false;
9
+ });
10
+ export const isNativeStickySupported = isDragAndDropEnabled => {
11
+ const safariVersion = getBrowserInfo().safari_version;
12
+ const isBrowserSafari = !Number.isNaN(safariVersion);
13
+ return (
14
+ // Safari has a bug with position: sticky and content editable, so we don't support it
15
+ !isBrowserSafari && isAnchorSupported() && isDragAndDropEnabled && expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true)
16
+ );
17
+ };
@@ -107,7 +107,8 @@ const ContentComponentInternal = ({
107
107
  isContextualMenuOpen: isContextualMenuOpen,
108
108
  stickyHeader: stickyHeader,
109
109
  tableWrapper: tableWrapperTarget,
110
- isCellMenuOpenByKeyboard: isCellMenuOpenByKeyboard
110
+ isCellMenuOpenByKeyboard: isCellMenuOpenByKeyboard,
111
+ isDragAndDropEnabled: isDragAndDropEnabled
111
112
  }), allowControls && /*#__PURE__*/React.createElement(FloatingInsertButton, {
112
113
  tableNode: tableNode,
113
114
  tableRef: tableRef,
@@ -18,7 +18,7 @@ import { akEditorSmallZIndex } from '@atlaskit/editor-shared-styles';
18
18
  import ExpandIcon from '@atlaskit/icon/core/migration/chevron-down';
19
19
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
20
20
  import { toggleContextualMenu } from '../../pm-plugins/commands';
21
- import { isAnchorSupported } from '../../pm-plugins/utils/anchor';
21
+ import { isNativeStickySupported } from '../../pm-plugins/utils/sticky-header';
22
22
  import { TableCssClassName as ClassName } from '../../types';
23
23
 
24
24
  // Ignored via go/ees005
@@ -42,6 +42,7 @@ const FloatingContextualButtonInner = /*#__PURE__*/React.memo(props => {
42
42
  tableWrapper,
43
43
  targetCellPosition,
44
44
  isCellMenuOpenByKeyboard,
45
+ isDragAndDropEnabled,
45
46
  intl: {
46
47
  formatMessage
47
48
  }
@@ -101,7 +102,7 @@ const FloatingContextualButtonInner = /*#__PURE__*/React.memo(props => {
101
102
  }));
102
103
  const parentSticky = targetCellRef.parentElement && targetCellRef.parentElement.className.indexOf('sticky') > -1;
103
104
  const parentStickyNative = targetCellRef.parentElement && targetCellRef.parentElement.classList.contains(ClassName.NATIVE_STICKY);
104
- if (expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) && expValEquals('platform_editor_table_sticky_header_improvements', 'cohort', 'test_with_overflow') && isAnchorSupported() && targetCellRef.nodeName === 'TH' && parentStickyNative) {
105
+ if (parentStickyNative && targetCellRef.nodeName === 'TH' && isNativeStickySupported(isDragAndDropEnabled !== null && isDragAndDropEnabled !== void 0 ? isDragAndDropEnabled : false) && expValEquals('platform_editor_table_sticky_header_improvements', 'cohort', 'test_with_overflow')) {
105
106
  var _targetCellRef$datase, _targetCellRef$parent, _targetCellRef$parent2;
106
107
  const anchorName = (_targetCellRef$datase = targetCellRef.dataset.nodeAnchor) !== null && _targetCellRef$datase !== void 0 ? _targetCellRef$datase : '';
107
108
  const rowAnchorName = (_targetCellRef$parent = (_targetCellRef$parent2 = targetCellRef.parentElement) === null || _targetCellRef$parent2 === void 0 ? void 0 : _targetCellRef$parent2.dataset.nodeAnchor) !== null && _targetCellRef$parent !== void 0 ? _targetCellRef$parent : '';
@@ -114,6 +115,8 @@ const FloatingContextualButtonInner = /*#__PURE__*/React.memo(props => {
114
115
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
115
116
  positionAnchor: anchorName
116
117
  } // need to do this because CSSProperties doesn't have positionAnchor property even though it's a valid CSS property
118
+ ,
119
+ "data-testid": "table-cell-options-anchor-wrapper"
117
120
  }, button);
118
121
  }
119
122
  if (stickyHeader && parentSticky && tableWrapper) {
@@ -1,10 +1,10 @@
1
1
  import React, { useEffect, useMemo, useRef, useState } from 'react';
2
2
  import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
3
3
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
4
- import { isAnchorSupported } from '../../pm-plugins/utils/anchor';
5
4
  import { getColumnsWidths } from '../../pm-plugins/utils/column-controls';
6
5
  import { containsHeaderColumn } from '../../pm-plugins/utils/nodes';
7
6
  import { getRowHeights } from '../../pm-plugins/utils/row-controls';
7
+ import { isNativeStickySupported } from '../../pm-plugins/utils/sticky-header';
8
8
  import { TableCssClassName as ClassName } from '../../types';
9
9
  import { ColumnControls } from './ColumnControls';
10
10
  import { ColumnDropTargets } from './ColumnDropTargets';
@@ -25,7 +25,8 @@ const TableFloatingColumnControls = ({
25
25
  getScrollOffset,
26
26
  tableWrapperHeight,
27
27
  api,
28
- isChromelessEditor
28
+ isChromelessEditor,
29
+ isDragAndDropEnabled
29
30
  }) => {
30
31
  const [isDragging, setIsDragging] = useState(false);
31
32
  const containerRef = useRef(null);
@@ -73,7 +74,7 @@ const TableFloatingColumnControls = ({
73
74
  containerRef === null || containerRef === void 0 ? void 0 : (_containerRef$current2 = containerRef.current) === null || _containerRef$current2 === void 0 ? void 0 : _containerRef$current2.style.removeProperty('top');
74
75
  }
75
76
  let anchorStyles = {};
76
- if (isAnchorSupported() && expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) && expValEquals('platform_editor_table_sticky_header_improvements', 'cohort', 'test_with_overflow')) {
77
+ if (isNativeStickySupported(isDragAndDropEnabled !== null && isDragAndDropEnabled !== void 0 ? isDragAndDropEnabled : false) && expValEquals('platform_editor_table_sticky_header_improvements', 'cohort', 'test_with_overflow')) {
77
78
  var _tableRef$querySelect;
78
79
  // cast here is due to CSSProperties missing valid positionAnchor property
79
80
  anchorStyles = {
@@ -851,7 +851,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
851
851
  },
852
852
  tableWrapperHeight: this.state.tableWrapperHeight,
853
853
  api: pluginInjectionApi,
854
- isChromelessEditor: options === null || options === void 0 ? void 0 : options.isChromelessEditor
854
+ isChromelessEditor: options === null || options === void 0 ? void 0 : options.isChromelessEditor,
855
+ isDragAndDropEnabled: isDragAndDropEnabled
855
856
  }) : null;
856
857
 
857
858
  /**
@@ -1,5 +1,5 @@
1
1
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
2
- import { isAnchorSupported } from '../pm-plugins/utils/anchor';
2
+ import { isNativeStickySupported } from '../pm-plugins/utils/sticky-header';
3
3
  // TODO: ED-23976 - Clean up
4
4
  import { createTableView } from './table';
5
5
  import TableCell from './TableCell';
@@ -24,7 +24,8 @@ export var tableHeaderView = function tableHeaderView(options) {
24
24
  };
25
25
  export var tableRowView = function tableRowView(options) {
26
26
  return function (node, view, getPos) {
27
- if (isAnchorSupported() && expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) && expValEquals('platform_editor_table_sticky_header_improvements', 'cohort', 'test_with_overflow')) {
27
+ var _options$isDragAndDro;
28
+ if (isNativeStickySupported((_options$isDragAndDro = options.isDragAndDropEnabled) !== null && _options$isDragAndDro !== void 0 ? _options$isDragAndDro : false) && expValEquals('platform_editor_table_sticky_header_improvements', 'cohort', 'test_with_overflow')) {
28
29
  return new TableRowNativeStickyWithFallback(node, view, getPos, options.eventDispatcher, options.pluginInjectionApi);
29
30
  } else {
30
31
  return new TableRow(node, view, getPos, options.eventDispatcher, options.pluginInjectionApi);
@@ -69,7 +69,8 @@ export var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch
69
69
  }),
70
70
  tableRow: tableRowView({
71
71
  eventDispatcher: eventDispatcher,
72
- pluginInjectionApi: pluginInjectionApi
72
+ pluginInjectionApi: pluginInjectionApi,
73
+ isDragAndDropEnabled: dragAndDropEnabled
73
74
  }),
74
75
  tableCell: tableCellView({
75
76
  eventDispatcher: eventDispatcher,
@@ -0,0 +1,17 @@
1
+ import memorizeOne from 'memoize-one';
2
+ import { getBrowserInfo } from '@atlaskit/editor-common/browser';
3
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
4
+ export var isAnchorSupported = memorizeOne(function () {
5
+ if (window.CSS && window.CSS.supports) {
6
+ return window.CSS.supports('anchor-name: --anchor');
7
+ }
8
+ return false;
9
+ });
10
+ export var isNativeStickySupported = function isNativeStickySupported(isDragAndDropEnabled) {
11
+ var safariVersion = getBrowserInfo().safari_version;
12
+ var isBrowserSafari = !Number.isNaN(safariVersion);
13
+ return (
14
+ // Safari has a bug with position: sticky and content editable, so we don't support it
15
+ !isBrowserSafari && isAnchorSupported() && isDragAndDropEnabled && expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true)
16
+ );
17
+ };
@@ -104,7 +104,8 @@ var ContentComponentInternal = function ContentComponentInternal(_ref) {
104
104
  isContextualMenuOpen: isContextualMenuOpen,
105
105
  stickyHeader: stickyHeader,
106
106
  tableWrapper: tableWrapperTarget,
107
- isCellMenuOpenByKeyboard: isCellMenuOpenByKeyboard
107
+ isCellMenuOpenByKeyboard: isCellMenuOpenByKeyboard,
108
+ isDragAndDropEnabled: isDragAndDropEnabled
108
109
  }), allowControls && /*#__PURE__*/React.createElement(FloatingInsertButton, {
109
110
  tableNode: tableNode,
110
111
  tableRef: tableRef,
@@ -18,7 +18,7 @@ import { akEditorSmallZIndex } from '@atlaskit/editor-shared-styles';
18
18
  import ExpandIcon from '@atlaskit/icon/core/migration/chevron-down';
19
19
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
20
20
  import { toggleContextualMenu } from '../../pm-plugins/commands';
21
- import { isAnchorSupported } from '../../pm-plugins/utils/anchor';
21
+ import { isNativeStickySupported } from '../../pm-plugins/utils/sticky-header';
22
22
  import { TableCssClassName as ClassName } from '../../types';
23
23
 
24
24
  // Ignored via go/ees005
@@ -41,6 +41,7 @@ var FloatingContextualButtonInner = /*#__PURE__*/React.memo(function (props) {
41
41
  tableWrapper = props.tableWrapper,
42
42
  targetCellPosition = props.targetCellPosition,
43
43
  isCellMenuOpenByKeyboard = props.isCellMenuOpenByKeyboard,
44
+ isDragAndDropEnabled = props.isDragAndDropEnabled,
44
45
  formatMessage = props.intl.formatMessage; // : Props & WrappedComponentProps
45
46
 
46
47
  var handleClick = function handleClick() {
@@ -93,7 +94,7 @@ var FloatingContextualButtonInner = /*#__PURE__*/React.memo(function (props) {
93
94
  }));
94
95
  var parentSticky = targetCellRef.parentElement && targetCellRef.parentElement.className.indexOf('sticky') > -1;
95
96
  var parentStickyNative = targetCellRef.parentElement && targetCellRef.parentElement.classList.contains(ClassName.NATIVE_STICKY);
96
- if (expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) && expValEquals('platform_editor_table_sticky_header_improvements', 'cohort', 'test_with_overflow') && isAnchorSupported() && targetCellRef.nodeName === 'TH' && parentStickyNative) {
97
+ if (parentStickyNative && targetCellRef.nodeName === 'TH' && isNativeStickySupported(isDragAndDropEnabled !== null && isDragAndDropEnabled !== void 0 ? isDragAndDropEnabled : false) && expValEquals('platform_editor_table_sticky_header_improvements', 'cohort', 'test_with_overflow')) {
97
98
  var _targetCellRef$datase, _targetCellRef$parent, _targetCellRef$parent2;
98
99
  var anchorName = (_targetCellRef$datase = targetCellRef.dataset.nodeAnchor) !== null && _targetCellRef$datase !== void 0 ? _targetCellRef$datase : '';
99
100
  var rowAnchorName = (_targetCellRef$parent = (_targetCellRef$parent2 = targetCellRef.parentElement) === null || _targetCellRef$parent2 === void 0 ? void 0 : _targetCellRef$parent2.dataset.nodeAnchor) !== null && _targetCellRef$parent !== void 0 ? _targetCellRef$parent : '';
@@ -106,6 +107,8 @@ var FloatingContextualButtonInner = /*#__PURE__*/React.memo(function (props) {
106
107
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
107
108
  positionAnchor: anchorName
108
109
  } // need to do this because CSSProperties doesn't have positionAnchor property even though it's a valid CSS property
110
+ ,
111
+ "data-testid": "table-cell-options-anchor-wrapper"
109
112
  }, button);
110
113
  }
111
114
  if (stickyHeader && parentSticky && tableWrapper) {
@@ -2,10 +2,10 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
2
  import React, { useEffect, useMemo, useRef, useState } from 'react';
3
3
  import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
4
4
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
5
- import { isAnchorSupported } from '../../pm-plugins/utils/anchor';
6
5
  import { getColumnsWidths } from '../../pm-plugins/utils/column-controls';
7
6
  import { containsHeaderColumn } from '../../pm-plugins/utils/nodes';
8
7
  import { getRowHeights } from '../../pm-plugins/utils/row-controls';
8
+ import { isNativeStickySupported } from '../../pm-plugins/utils/sticky-header';
9
9
  import { TableCssClassName as ClassName } from '../../types';
10
10
  import { ColumnControls } from './ColumnControls';
11
11
  import { ColumnDropTargets } from './ColumnDropTargets';
@@ -26,7 +26,8 @@ var TableFloatingColumnControls = function TableFloatingColumnControls(_ref) {
26
26
  getScrollOffset = _ref.getScrollOffset,
27
27
  tableWrapperHeight = _ref.tableWrapperHeight,
28
28
  api = _ref.api,
29
- isChromelessEditor = _ref.isChromelessEditor;
29
+ isChromelessEditor = _ref.isChromelessEditor,
30
+ isDragAndDropEnabled = _ref.isDragAndDropEnabled;
30
31
  var _useState = useState(false),
31
32
  _useState2 = _slicedToArray(_useState, 2),
32
33
  isDragging = _useState2[0],
@@ -74,7 +75,7 @@ var TableFloatingColumnControls = function TableFloatingColumnControls(_ref) {
74
75
  containerRef === null || containerRef === void 0 || (_containerRef$current2 = containerRef.current) === null || _containerRef$current2 === void 0 || _containerRef$current2.style.removeProperty('top');
75
76
  }
76
77
  var anchorStyles = {};
77
- if (isAnchorSupported() && expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) && expValEquals('platform_editor_table_sticky_header_improvements', 'cohort', 'test_with_overflow')) {
78
+ if (isNativeStickySupported(isDragAndDropEnabled !== null && isDragAndDropEnabled !== void 0 ? isDragAndDropEnabled : false) && expValEquals('platform_editor_table_sticky_header_improvements', 'cohort', 'test_with_overflow')) {
78
79
  var _tableRef$querySelect;
79
80
  // cast here is due to CSSProperties missing valid positionAnchor property
80
81
  anchorStyles = {
@@ -21,6 +21,7 @@ type TableViewOptions = {
21
21
  export declare const tableView: (options: TableViewOptions) => (node: PMNode, view: EditorView, getPos: () => number | undefined) => import("prosemirror-view").NodeView;
22
22
  type TableCellViewOptions = {
23
23
  eventDispatcher: EventDispatcher;
24
+ isDragAndDropEnabled?: boolean;
24
25
  pluginInjectionApi?: PluginInjectionAPI;
25
26
  };
26
27
  export declare const tableCellView: (options: TableCellViewOptions) => (node: PMNode, view: EditorView, getPos: () => number | undefined) => TableCell;
@@ -0,0 +1,2 @@
1
+ export declare const isAnchorSupported: import("memoize-one").MemoizedFn<() => boolean>;
2
+ export declare const isNativeStickySupported: (isDragAndDropEnabled: boolean) => boolean;
@@ -9,6 +9,7 @@ export interface Props {
9
9
  editorView: EditorView;
10
10
  isCellMenuOpenByKeyboard?: boolean;
11
11
  isContextualMenuOpen?: boolean;
12
+ isDragAndDropEnabled?: boolean;
12
13
  isNumberColumnEnabled?: boolean;
13
14
  mountPoint?: HTMLElement;
14
15
  scrollableElement?: HTMLElement;
@@ -17,6 +17,7 @@ interface Props {
17
17
  hoveredCell?: CellHoverMeta;
18
18
  hoveredRows?: number[];
19
19
  isChromelessEditor?: boolean;
20
+ isDragAndDropEnabled?: boolean;
20
21
  isInDanger?: boolean;
21
22
  isNumberColumnEnabled?: boolean;
22
23
  isResizing?: boolean;
@@ -29,5 +30,5 @@ interface Props {
29
30
  tableRef?: HTMLTableElement;
30
31
  tableWrapperHeight?: number;
31
32
  }
32
- declare const TableFloatingColumnControls: ({ editorView, tableRef, getNode, tableActive, hasHeaderRow, hoveredCell, isResizing, stickyHeader, selection, isInDanger, isTableHovered, tableContainerWidth, isNumberColumnEnabled, getScrollOffset, tableWrapperHeight, api, isChromelessEditor, }: Props) => React.JSX.Element | null;
33
+ declare const TableFloatingColumnControls: ({ editorView, tableRef, getNode, tableActive, hasHeaderRow, hoveredCell, isResizing, stickyHeader, selection, isInDanger, isTableHovered, tableContainerWidth, isNumberColumnEnabled, getScrollOffset, tableWrapperHeight, api, isChromelessEditor, isDragAndDropEnabled, }: Props) => React.JSX.Element | null;
33
34
  export default TableFloatingColumnControls;
@@ -21,6 +21,7 @@ type TableViewOptions = {
21
21
  export declare const tableView: (options: TableViewOptions) => (node: PMNode, view: EditorView, getPos: () => number | undefined) => import("prosemirror-view").NodeView;
22
22
  type TableCellViewOptions = {
23
23
  eventDispatcher: EventDispatcher;
24
+ isDragAndDropEnabled?: boolean;
24
25
  pluginInjectionApi?: PluginInjectionAPI;
25
26
  };
26
27
  export declare const tableCellView: (options: TableCellViewOptions) => (node: PMNode, view: EditorView, getPos: () => number | undefined) => TableCell;
@@ -0,0 +1,2 @@
1
+ export declare const isAnchorSupported: import("memoize-one").MemoizedFn<() => boolean>;
2
+ export declare const isNativeStickySupported: (isDragAndDropEnabled: boolean) => boolean;
@@ -9,6 +9,7 @@ export interface Props {
9
9
  editorView: EditorView;
10
10
  isCellMenuOpenByKeyboard?: boolean;
11
11
  isContextualMenuOpen?: boolean;
12
+ isDragAndDropEnabled?: boolean;
12
13
  isNumberColumnEnabled?: boolean;
13
14
  mountPoint?: HTMLElement;
14
15
  scrollableElement?: HTMLElement;
@@ -17,6 +17,7 @@ interface Props {
17
17
  hoveredCell?: CellHoverMeta;
18
18
  hoveredRows?: number[];
19
19
  isChromelessEditor?: boolean;
20
+ isDragAndDropEnabled?: boolean;
20
21
  isInDanger?: boolean;
21
22
  isNumberColumnEnabled?: boolean;
22
23
  isResizing?: boolean;
@@ -29,5 +30,5 @@ interface Props {
29
30
  tableRef?: HTMLTableElement;
30
31
  tableWrapperHeight?: number;
31
32
  }
32
- declare const TableFloatingColumnControls: ({ editorView, tableRef, getNode, tableActive, hasHeaderRow, hoveredCell, isResizing, stickyHeader, selection, isInDanger, isTableHovered, tableContainerWidth, isNumberColumnEnabled, getScrollOffset, tableWrapperHeight, api, isChromelessEditor, }: Props) => React.JSX.Element | null;
33
+ declare const TableFloatingColumnControls: ({ editorView, tableRef, getNode, tableActive, hasHeaderRow, hoveredCell, isResizing, stickyHeader, selection, isInDanger, isTableHovered, tableContainerWidth, isNumberColumnEnabled, getScrollOffset, tableWrapperHeight, api, isChromelessEditor, isDragAndDropEnabled, }: Props) => React.JSX.Element | null;
33
34
  export default TableFloatingColumnControls;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "15.4.22",
3
+ "version": "15.4.24",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -29,7 +29,7 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@atlaskit/adf-schema": "^51.5.1",
32
- "@atlaskit/button": "^23.6.0",
32
+ "@atlaskit/button": "^23.7.0",
33
33
  "@atlaskit/custom-steps": "^0.16.0",
34
34
  "@atlaskit/editor-palette": "^2.1.0",
35
35
  "@atlaskit/editor-plugin-accessibility-utils": "^6.0.0",
@@ -58,7 +58,7 @@
58
58
  "@atlaskit/primitives": "^16.4.0",
59
59
  "@atlaskit/theme": "^21.0.0",
60
60
  "@atlaskit/tmp-editor-statsig": "^15.7.0",
61
- "@atlaskit/toggle": "^15.1.0",
61
+ "@atlaskit/toggle": "^15.2.0",
62
62
  "@atlaskit/tokens": "^8.4.0",
63
63
  "@atlaskit/tooltip": "^20.11.0",
64
64
  "@babel/runtime": "^7.0.0",
@@ -1,14 +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.isAnchorSupported = void 0;
8
- var _memoizeOne = _interopRequireDefault(require("memoize-one"));
9
- var isAnchorSupported = exports.isAnchorSupported = (0, _memoizeOne.default)(function () {
10
- if (window.CSS && window.CSS.supports) {
11
- return window.CSS.supports('anchor-name: --anchor');
12
- }
13
- return false;
14
- });
@@ -1,7 +0,0 @@
1
- import memorizeOne from 'memoize-one';
2
- export const isAnchorSupported = memorizeOne(() => {
3
- if (window.CSS && window.CSS.supports) {
4
- return window.CSS.supports('anchor-name: --anchor');
5
- }
6
- return false;
7
- });
@@ -1,7 +0,0 @@
1
- import memorizeOne from 'memoize-one';
2
- export var isAnchorSupported = memorizeOne(function () {
3
- if (window.CSS && window.CSS.supports) {
4
- return window.CSS.supports('anchor-name: --anchor');
5
- }
6
- return false;
7
- });
@@ -1 +0,0 @@
1
- export declare const isAnchorSupported: import("memoize-one").MemoizedFn<() => boolean>;
@@ -1 +0,0 @@
1
- export declare const isAnchorSupported: import("memoize-one").MemoizedFn<() => boolean>;