@atlaskit/editor-plugin-table 16.1.1 → 16.1.2

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,13 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 16.1.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`66dcfa397e97d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/66dcfa397e97d) -
8
+ [ux] EDITOR-4197 Fix cell option menu for table header cells in table header column
9
+ - Updated dependencies
10
+
3
11
  ## 16.1.1
4
12
 
5
13
  ### Patch Changes
@@ -14,6 +14,7 @@ var _styles = require("@atlaskit/editor-common/styles");
14
14
  var _state = require("@atlaskit/editor-prosemirror/state");
15
15
  var _view = require("@atlaskit/editor-prosemirror/view");
16
16
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
17
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
17
18
  // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid
18
19
  var ObjHash = /*#__PURE__*/function () {
19
20
  function ObjHash() {
@@ -39,13 +40,20 @@ var getNodeAnchor = function getNodeAnchor(node) {
39
40
  };
40
41
  var createTableAnchorDecorations = function createTableAnchorDecorations(state) {
41
42
  var decs = [];
43
+ var headerRowId;
42
44
  state.doc.nodesBetween(0, state.doc.content.size, function (node, pos, parent, index) {
45
+ var _parent$attrs;
43
46
  var isTableHeader = node.type.name === 'tableHeader';
44
47
  var isTableRow = node.type.name === 'tableRow';
45
48
  var isParentTableRow = (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'tableRow';
46
-
49
+ var isParentTableHeaderRow = (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'tableRow' && headerRowId && (parent === null || parent === void 0 || (_parent$attrs = parent.attrs) === null || _parent$attrs === void 0 ? void 0 : _parent$attrs.localId) === headerRowId;
50
+ var shouldAddDecorationToHeader = (0, _expValEquals.expValEquals)('platform_editor_table_sticky_header_patch_9', 'isEnabled', true) ? isParentTableHeaderRow && isTableHeader : isTableHeader;
51
+ var isFirstRow = isTableRow && index === 0;
52
+ if (isFirstRow) {
53
+ headerRowId = node.attrs.localId;
54
+ }
47
55
  // only apply to header cells and the first row of a table, for performance reasons
48
- if (isTableRow && index === 0 || isTableHeader) {
56
+ if (isFirstRow || shouldAddDecorationToHeader) {
49
57
  var anchorName = getNodeAnchor(node);
50
58
  var shouldAddAnchorNameInDecoration = !(0, _styles.isCSSAttrAnchorSupported)() && (0, _styles.isCSSAnchorSupported)() && (0, _platformFeatureFlags.fg)('platform_editor_table_sticky_header_patch_8');
51
59
  var attributes = {
@@ -58,7 +66,7 @@ var createTableAnchorDecorations = function createTableAnchorDecorations(state)
58
66
  }
59
67
 
60
68
  // only decend if there is a possible table row or table header node after the current node, for performance reasons
61
- return !(isTableHeader || isParentTableRow);
69
+ return (0, _expValEquals.expValEquals)('platform_editor_table_sticky_header_patch_9', 'isEnabled', true) ? !(isTableHeader || isParentTableHeaderRow) : !(isTableHeader || isParentTableRow);
62
70
  });
63
71
  return _view.DecorationSet.create(state.doc, decs);
64
72
  };
@@ -119,18 +119,34 @@ var FloatingContextualButtonInner = /*#__PURE__*/_react.default.memo(function (p
119
119
  if (colAnchorName === '') {
120
120
  colAnchorName = targetCellRef === null || targetCellRef === void 0 ? void 0 : targetCellRef.dataset.nodeAnchor;
121
121
  }
122
- return (0, _react2.jsx)("div", {
123
- css: anchorStyles,
124
- style: {
125
- // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
126
- top: "calc(".concat(BUTTON_OFFSET, "px + anchor(").concat(rowAnchorName, " top))"),
127
- right: "calc(".concat(BUTTON_OFFSET, "px + anchor(").concat(colAnchorName, " right))"),
128
- // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
129
- positionAnchor: colAnchorName
130
- } // need to do this because CSSProperties doesn't have positionAnchor property even though it's a valid CSS property
131
- ,
132
- "data-testid": "table-cell-options-anchor-wrapper"
133
- }, button);
122
+ if (!(0, _expValEquals.expValEquals)('platform_editor_table_sticky_header_patch_9', 'isEnabled', true)) {
123
+ return (0, _react2.jsx)("div", {
124
+ css: anchorStyles,
125
+ style: {
126
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
127
+ top: "calc(".concat(BUTTON_OFFSET, "px + anchor(").concat(rowAnchorName, " top))"),
128
+ right: "calc(".concat(BUTTON_OFFSET, "px + anchor(").concat(colAnchorName, " right))"),
129
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
130
+ positionAnchor: colAnchorName
131
+ } // need to do this because CSSProperties doesn't have positionAnchor property even though it's a valid CSS property
132
+ ,
133
+ "data-testid": "table-cell-options-anchor-wrapper"
134
+ }, button);
135
+ }
136
+ if (rowAnchorName && colAnchorName) {
137
+ return (0, _react2.jsx)("div", {
138
+ css: anchorStyles,
139
+ style: {
140
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
141
+ top: "calc(".concat(BUTTON_OFFSET, "px + anchor(").concat(rowAnchorName, " top))"),
142
+ right: "calc(".concat(BUTTON_OFFSET, "px + anchor(").concat(colAnchorName, " right))"),
143
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
144
+ positionAnchor: colAnchorName
145
+ } // need to do this because CSSProperties doesn't have positionAnchor property even though it's a valid CSS property
146
+ ,
147
+ "data-testid": "table-cell-options-anchor-wrapper"
148
+ }, button);
149
+ }
134
150
  }
135
151
  if (stickyHeader && parentSticky && tableWrapper) {
136
152
  return (0, _react2.jsx)(_FixedButton.default, {
@@ -6,6 +6,7 @@ import { isCSSAnchorSupported, isCSSAttrAnchorSupported } from '@atlaskit/editor
6
6
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
7
7
  import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
8
8
  import { fg } from '@atlaskit/platform-feature-flags';
9
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
9
10
  class ObjHash {
10
11
  static getForNode(node) {
11
12
  if (this.cache.has(node)) {
@@ -24,13 +25,20 @@ const getNodeAnchor = node => {
24
25
  };
25
26
  const createTableAnchorDecorations = state => {
26
27
  const decs = [];
28
+ let headerRowId;
27
29
  state.doc.nodesBetween(0, state.doc.content.size, (node, pos, parent, index) => {
30
+ var _parent$attrs;
28
31
  const isTableHeader = node.type.name === 'tableHeader';
29
32
  const isTableRow = node.type.name === 'tableRow';
30
33
  const isParentTableRow = (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'tableRow';
31
-
34
+ const isParentTableHeaderRow = (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'tableRow' && headerRowId && (parent === null || parent === void 0 ? void 0 : (_parent$attrs = parent.attrs) === null || _parent$attrs === void 0 ? void 0 : _parent$attrs.localId) === headerRowId;
35
+ const shouldAddDecorationToHeader = expValEquals('platform_editor_table_sticky_header_patch_9', 'isEnabled', true) ? isParentTableHeaderRow && isTableHeader : isTableHeader;
36
+ const isFirstRow = isTableRow && index === 0;
37
+ if (isFirstRow) {
38
+ headerRowId = node.attrs.localId;
39
+ }
32
40
  // only apply to header cells and the first row of a table, for performance reasons
33
- if (isTableRow && index === 0 || isTableHeader) {
41
+ if (isFirstRow || shouldAddDecorationToHeader) {
34
42
  const anchorName = getNodeAnchor(node);
35
43
  const shouldAddAnchorNameInDecoration = !isCSSAttrAnchorSupported() && isCSSAnchorSupported() && fg('platform_editor_table_sticky_header_patch_8');
36
44
  const attributes = {
@@ -43,7 +51,7 @@ const createTableAnchorDecorations = state => {
43
51
  }
44
52
 
45
53
  // only decend if there is a possible table row or table header node after the current node, for performance reasons
46
- return !(isTableHeader || isParentTableRow);
54
+ return expValEquals('platform_editor_table_sticky_header_patch_9', 'isEnabled', true) ? !(isTableHeader || isParentTableHeaderRow) : !(isTableHeader || isParentTableRow);
47
55
  });
48
56
  return DecorationSet.create(state.doc, decs);
49
57
  };
@@ -117,18 +117,34 @@ const FloatingContextualButtonInner = /*#__PURE__*/React.memo(props => {
117
117
  if (colAnchorName === '') {
118
118
  colAnchorName = targetCellRef === null || targetCellRef === void 0 ? void 0 : targetCellRef.dataset.nodeAnchor;
119
119
  }
120
- return jsx("div", {
121
- css: anchorStyles,
122
- style: {
123
- // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
124
- top: `calc(${BUTTON_OFFSET}px + anchor(${rowAnchorName} top))`,
125
- right: `calc(${BUTTON_OFFSET}px + anchor(${colAnchorName} right))`,
126
- // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
127
- positionAnchor: colAnchorName
128
- } // need to do this because CSSProperties doesn't have positionAnchor property even though it's a valid CSS property
129
- ,
130
- "data-testid": "table-cell-options-anchor-wrapper"
131
- }, button);
120
+ if (!expValEquals('platform_editor_table_sticky_header_patch_9', 'isEnabled', true)) {
121
+ return jsx("div", {
122
+ css: anchorStyles,
123
+ style: {
124
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
125
+ top: `calc(${BUTTON_OFFSET}px + anchor(${rowAnchorName} top))`,
126
+ right: `calc(${BUTTON_OFFSET}px + anchor(${colAnchorName} right))`,
127
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
128
+ positionAnchor: colAnchorName
129
+ } // need to do this because CSSProperties doesn't have positionAnchor property even though it's a valid CSS property
130
+ ,
131
+ "data-testid": "table-cell-options-anchor-wrapper"
132
+ }, button);
133
+ }
134
+ if (rowAnchorName && colAnchorName) {
135
+ return jsx("div", {
136
+ css: anchorStyles,
137
+ style: {
138
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
139
+ top: `calc(${BUTTON_OFFSET}px + anchor(${rowAnchorName} top))`,
140
+ right: `calc(${BUTTON_OFFSET}px + anchor(${colAnchorName} right))`,
141
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
142
+ positionAnchor: colAnchorName
143
+ } // need to do this because CSSProperties doesn't have positionAnchor property even though it's a valid CSS property
144
+ ,
145
+ "data-testid": "table-cell-options-anchor-wrapper"
146
+ }, button);
147
+ }
132
148
  }
133
149
  if (stickyHeader && parentSticky && tableWrapper) {
134
150
  return jsx(FixedButton, {
@@ -8,6 +8,7 @@ import { isCSSAnchorSupported, isCSSAttrAnchorSupported } from '@atlaskit/editor
8
8
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
9
9
  import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
10
10
  import { fg } from '@atlaskit/platform-feature-flags';
11
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
11
12
  var ObjHash = /*#__PURE__*/function () {
12
13
  function ObjHash() {
13
14
  _classCallCheck(this, ObjHash);
@@ -32,13 +33,20 @@ var getNodeAnchor = function getNodeAnchor(node) {
32
33
  };
33
34
  var createTableAnchorDecorations = function createTableAnchorDecorations(state) {
34
35
  var decs = [];
36
+ var headerRowId;
35
37
  state.doc.nodesBetween(0, state.doc.content.size, function (node, pos, parent, index) {
38
+ var _parent$attrs;
36
39
  var isTableHeader = node.type.name === 'tableHeader';
37
40
  var isTableRow = node.type.name === 'tableRow';
38
41
  var isParentTableRow = (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'tableRow';
39
-
42
+ var isParentTableHeaderRow = (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'tableRow' && headerRowId && (parent === null || parent === void 0 || (_parent$attrs = parent.attrs) === null || _parent$attrs === void 0 ? void 0 : _parent$attrs.localId) === headerRowId;
43
+ var shouldAddDecorationToHeader = expValEquals('platform_editor_table_sticky_header_patch_9', 'isEnabled', true) ? isParentTableHeaderRow && isTableHeader : isTableHeader;
44
+ var isFirstRow = isTableRow && index === 0;
45
+ if (isFirstRow) {
46
+ headerRowId = node.attrs.localId;
47
+ }
40
48
  // only apply to header cells and the first row of a table, for performance reasons
41
- if (isTableRow && index === 0 || isTableHeader) {
49
+ if (isFirstRow || shouldAddDecorationToHeader) {
42
50
  var anchorName = getNodeAnchor(node);
43
51
  var shouldAddAnchorNameInDecoration = !isCSSAttrAnchorSupported() && isCSSAnchorSupported() && fg('platform_editor_table_sticky_header_patch_8');
44
52
  var attributes = {
@@ -51,7 +59,7 @@ var createTableAnchorDecorations = function createTableAnchorDecorations(state)
51
59
  }
52
60
 
53
61
  // only decend if there is a possible table row or table header node after the current node, for performance reasons
54
- return !(isTableHeader || isParentTableRow);
62
+ return expValEquals('platform_editor_table_sticky_header_patch_9', 'isEnabled', true) ? !(isTableHeader || isParentTableHeaderRow) : !(isTableHeader || isParentTableRow);
55
63
  });
56
64
  return DecorationSet.create(state.doc, decs);
57
65
  };
@@ -109,18 +109,34 @@ var FloatingContextualButtonInner = /*#__PURE__*/React.memo(function (props) {
109
109
  if (colAnchorName === '') {
110
110
  colAnchorName = targetCellRef === null || targetCellRef === void 0 ? void 0 : targetCellRef.dataset.nodeAnchor;
111
111
  }
112
- return jsx("div", {
113
- css: anchorStyles,
114
- style: {
115
- // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
116
- top: "calc(".concat(BUTTON_OFFSET, "px + anchor(").concat(rowAnchorName, " top))"),
117
- right: "calc(".concat(BUTTON_OFFSET, "px + anchor(").concat(colAnchorName, " right))"),
118
- // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
119
- positionAnchor: colAnchorName
120
- } // need to do this because CSSProperties doesn't have positionAnchor property even though it's a valid CSS property
121
- ,
122
- "data-testid": "table-cell-options-anchor-wrapper"
123
- }, button);
112
+ if (!expValEquals('platform_editor_table_sticky_header_patch_9', 'isEnabled', true)) {
113
+ return jsx("div", {
114
+ css: anchorStyles,
115
+ style: {
116
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
117
+ top: "calc(".concat(BUTTON_OFFSET, "px + anchor(").concat(rowAnchorName, " top))"),
118
+ right: "calc(".concat(BUTTON_OFFSET, "px + anchor(").concat(colAnchorName, " right))"),
119
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
120
+ positionAnchor: colAnchorName
121
+ } // need to do this because CSSProperties doesn't have positionAnchor property even though it's a valid CSS property
122
+ ,
123
+ "data-testid": "table-cell-options-anchor-wrapper"
124
+ }, button);
125
+ }
126
+ if (rowAnchorName && colAnchorName) {
127
+ return jsx("div", {
128
+ css: anchorStyles,
129
+ style: {
130
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
131
+ top: "calc(".concat(BUTTON_OFFSET, "px + anchor(").concat(rowAnchorName, " top))"),
132
+ right: "calc(".concat(BUTTON_OFFSET, "px + anchor(").concat(colAnchorName, " right))"),
133
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
134
+ positionAnchor: colAnchorName
135
+ } // need to do this because CSSProperties doesn't have positionAnchor property even though it's a valid CSS property
136
+ ,
137
+ "data-testid": "table-cell-options-anchor-wrapper"
138
+ }, button);
139
+ }
124
140
  }
125
141
  if (stickyHeader && parentSticky && tableWrapper) {
126
142
  return jsx(FixedButton, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "16.1.1",
3
+ "version": "16.1.2",
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.3.0",
60
+ "@atlaskit/tmp-editor-statsig": "^16.4.0",
61
61
  "@atlaskit/toggle": "^15.2.0",
62
62
  "@atlaskit/tokens": "^9.0.0",
63
63
  "@atlaskit/tooltip": "^20.11.0",