@atlaskit/editor-plugin-table 24.4.23 → 24.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 24.4.24
4
+
5
+ ### Patch Changes
6
+
7
+ - [`b91c14d4dbad7`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b91c14d4dbad7) -
8
+ Editor; Ensure only the first table row can become a sticky header when the rounded table patch is
9
+ enabled
10
+
11
+ Renderer; Patch table body elements to have rounded corners when overridden by consumers
12
+
13
+ - Updated dependencies
14
+
3
15
  ## 24.4.23
4
16
 
5
17
  ### Patch Changes
@@ -111,13 +111,16 @@ var TableRow = exports.default = /*#__PURE__*/function (_TableNodeView) {
111
111
  var $pos = view.state.doc.resolve(pos);
112
112
  _this.isInNestedTable = (0, _nesting.getParentOfTypeCount)(view.state.schema.nodes.table)($pos) > 1;
113
113
  // Resolve rowIndex only when the flag is on — otherwise it's unused
114
- if ((0, _expValEquals.expValEquals)('platform_editor_fix_sticky_header_row', 'isEnabled', true)) {
114
+ if ((0, _expValEquals.expValEquals)('platform_editor_fix_sticky_header_row', 'isEnabled', true) && !(0, _expValEquals.expValEquals)('platform_editor_table_q4_patch_5', 'isEnabled', true)) {
115
115
  rowIndex = $pos.index();
116
116
  }
117
117
  }
118
118
  } catch (_unused) {
119
119
  // Intentionally swallowed — getPos can return stale positions during AI streaming
120
120
  }
121
+ if ((0, _expValEquals.expValEquals)('platform_editor_table_q4_patch_5', 'isEnabled', true)) {
122
+ rowIndex = (0, _nodes.getTableRowIndex)(view, getPos);
123
+ }
121
124
  _this.isHeaderRow = (0, _nodes.supportedHeaderRow)(node, rowIndex);
122
125
  if (_this.isHeaderRow) {
123
126
  _this.dom.setAttribute('data-vc-nvs', 'true');
@@ -175,6 +178,9 @@ var TableRow = exports.default = /*#__PURE__*/function (_TableNodeView) {
175
178
  // Intentionally swallowed — getPos can return stale positions during AI streaming
176
179
  }
177
180
  }
181
+ if ((0, _expValEquals.expValEquals)('platform_editor_table_q4_patch_5', 'isEnabled', true)) {
182
+ rowIndex = (0, _nodes.getTableRowIndex)(this.view, this.getPos);
183
+ }
178
184
  var newNodeIsHeaderRow = (0, _nodes.supportedHeaderRow)(node, rowIndex);
179
185
  if (this.isHeaderRow !== newNodeIsHeaderRow) {
180
186
  return false; // re-create nodeview
@@ -109,7 +109,12 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
109
109
  _this.disableNativeSticky = false;
110
110
  }
111
111
  });
112
- _this.isHeaderRow = (0, _nodes.supportedHeaderRow)(node);
112
+ if ((0, _expValEquals.expValEquals)('platform_editor_table_q4_patch_5', 'isEnabled', true)) {
113
+ var rowIndex = (0, _nodes.getTableRowIndex)(view, getPos);
114
+ _this.isHeaderRow = (0, _nodes.supportedHeaderRow)(node, rowIndex);
115
+ } else {
116
+ _this.isHeaderRow = (0, _nodes.supportedHeaderRow)(node);
117
+ }
113
118
  if (_this.isHeaderRow && (0, _expValEquals.expValEquals)('platform_editor_table_q4_patch_4', 'isEnabled', true)) {
114
119
  _this.isSingleRowTable = _this.checkIsSingleRowTable();
115
120
  }
@@ -203,7 +208,9 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
203
208
  // see if we're changing into a header row or
204
209
  // changing away from one
205
210
  var rowIndex = 0;
206
- if ((0, _expValEquals.expValEquals)('platform_editor_fix_sticky_header_row', 'isEnabled', true)) {
211
+ if ((0, _expValEquals.expValEquals)('platform_editor_table_q4_patch_5', 'isEnabled', true)) {
212
+ rowIndex = (0, _nodes.getTableRowIndex)(this.view, this.getPos);
213
+ } else if ((0, _expValEquals.expValEquals)('platform_editor_fix_sticky_header_row', 'isEnabled', true)) {
207
214
  try {
208
215
  var pos = this.getPos();
209
216
  if (pos) {
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.tablesHaveDifferentNoOfRows = exports.tablesHaveDifferentNoOfColumns = exports.tablesHaveDifferentColumnWidths = exports.supportedHeaderRow = exports.isTableNestedUnderBodiedSyncBlock = exports.isTableNestedInMoreThanOneNode = exports.isTableNested = exports.isIsolating = exports.getTableWidth = exports.containsHeaderRow = exports.containsHeaderColumn = exports.checkIfNumberColumnEnabled = exports.checkIfHeaderRowEnabled = exports.checkIfHeaderColumnEnabled = void 0;
7
+ exports.tablesHaveDifferentNoOfRows = exports.tablesHaveDifferentNoOfColumns = exports.tablesHaveDifferentColumnWidths = exports.supportedHeaderRow = exports.isTableNestedUnderBodiedSyncBlock = exports.isTableNestedInMoreThanOneNode = exports.isTableNested = exports.isIsolating = exports.getTableWidth = exports.getTableRowIndex = exports.containsHeaderRow = exports.containsHeaderColumn = exports.checkIfNumberColumnEnabled = exports.checkIfHeaderRowEnabled = exports.checkIfHeaderColumnEnabled = void 0;
8
8
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
9
  var _utils = require("@atlaskit/editor-common/utils");
10
10
  var _tableMap = require("@atlaskit/editor-tables/table-map");
@@ -142,9 +142,18 @@ var anyChildCellMergedAcrossColumn = function anyChildCellMergedAcrossColumn(nod
142
142
  return colspan > 1;
143
143
  });
144
144
  };
145
+ var getTableRowIndex = exports.getTableRowIndex = function getTableRowIndex(view, getPos) {
146
+ try {
147
+ var pos = getPos();
148
+ return pos === undefined ? 0 : view.state.doc.resolve(pos).index();
149
+ } catch (_unused2) {
150
+ return 0;
151
+ }
152
+ };
145
153
 
146
154
  /**
147
155
  * Check if a given node is a header row with this definition:
156
+ * - the row is the first row when platform_editor_table_q4_patch_5 is enabled
148
157
  * - all children are tableHeader cells
149
158
  * - no table cells have been merged with other table row cells (rowspan > 1)
150
159
  * - no table cells have been merged with other table column cells (colspan > 1),
@@ -158,6 +167,9 @@ var anyChildCellMergedAcrossColumn = function anyChildCellMergedAcrossColumn(nod
158
167
  */
159
168
  var supportedHeaderRow = exports.supportedHeaderRow = function supportedHeaderRow(node) {
160
169
  var rowIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
170
+ if ((0, _expValEquals.expValEquals)('platform_editor_table_q4_patch_5', 'isEnabled', true) && rowIndex !== 0) {
171
+ return false;
172
+ }
161
173
  var allHeaders = (0, _utils.mapChildren)(node, function (child) {
162
174
  return child.type.name === 'tableHeader';
163
175
  }).every(Boolean);
@@ -12,7 +12,7 @@ import { pluginKey as tablePluginKey } from '../pm-plugins/plugin-key';
12
12
  import { updateStickyState } from '../pm-plugins/sticky-headers/commands';
13
13
  import { clearStickyCornerMaskPositions, syncStickyRowToTable, updateStickyMargins as updateTableMargin } from '../pm-plugins/table-resizing/utils/dom';
14
14
  import { getTop, getTree } from '../pm-plugins/utils/dom';
15
- import { supportedHeaderRow } from '../pm-plugins/utils/nodes';
15
+ import { getTableRowIndex, supportedHeaderRow } from '../pm-plugins/utils/nodes';
16
16
  import { TableCssClassName as ClassName, TableCssClassName } from '../types';
17
17
  import { stickyHeaderBorderBottomWidth, stickyRowOffsetTop, tableControlsSpacing, tableScrollbarOffset } from '../ui/consts';
18
18
  import TableNodeView from './TableNodeViewBase';
@@ -96,13 +96,16 @@ export default class TableRow extends TableNodeView {
96
96
  const $pos = view.state.doc.resolve(pos);
97
97
  this.isInNestedTable = getParentOfTypeCount(view.state.schema.nodes.table)($pos) > 1;
98
98
  // Resolve rowIndex only when the flag is on — otherwise it's unused
99
- if (expValEquals('platform_editor_fix_sticky_header_row', 'isEnabled', true)) {
99
+ if (expValEquals('platform_editor_fix_sticky_header_row', 'isEnabled', true) && !expValEquals('platform_editor_table_q4_patch_5', 'isEnabled', true)) {
100
100
  rowIndex = $pos.index();
101
101
  }
102
102
  }
103
103
  } catch {
104
104
  // Intentionally swallowed — getPos can return stale positions during AI streaming
105
105
  }
106
+ if (expValEquals('platform_editor_table_q4_patch_5', 'isEnabled', true)) {
107
+ rowIndex = getTableRowIndex(view, getPos);
108
+ }
106
109
  this.isHeaderRow = supportedHeaderRow(node, rowIndex);
107
110
  if (this.isHeaderRow) {
108
111
  this.dom.setAttribute('data-vc-nvs', 'true');
@@ -155,6 +158,9 @@ export default class TableRow extends TableNodeView {
155
158
  // Intentionally swallowed — getPos can return stale positions during AI streaming
156
159
  }
157
160
  }
161
+ if (expValEquals('platform_editor_table_q4_patch_5', 'isEnabled', true)) {
162
+ rowIndex = getTableRowIndex(this.view, this.getPos);
163
+ }
158
164
  const newNodeIsHeaderRow = supportedHeaderRow(node, rowIndex);
159
165
  if (this.isHeaderRow !== newNodeIsHeaderRow) {
160
166
  return false; // re-create nodeview
@@ -15,7 +15,7 @@ import { pluginKey as tablePluginKey } from '../pm-plugins/plugin-key';
15
15
  import { updateStickyState } from '../pm-plugins/sticky-headers/commands';
16
16
  import { clearStickyCornerMaskPositions, syncStickyRowToTable, updateStickyMargins as updateTableMargin } from '../pm-plugins/table-resizing/utils/dom';
17
17
  import { areAllRectsZero, getTop, getTree } from '../pm-plugins/utils/dom';
18
- import { supportedHeaderRow } from '../pm-plugins/utils/nodes';
18
+ import { getTableRowIndex, 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';
21
21
  import TableNodeView from './TableNodeViewBase';
@@ -93,7 +93,12 @@ export default class TableRowNativeStickyWithFallback extends TableNodeView {
93
93
  this.disableNativeSticky = false;
94
94
  }
95
95
  });
96
- this.isHeaderRow = supportedHeaderRow(node);
96
+ if (expValEquals('platform_editor_table_q4_patch_5', 'isEnabled', true)) {
97
+ const rowIndex = getTableRowIndex(view, getPos);
98
+ this.isHeaderRow = supportedHeaderRow(node, rowIndex);
99
+ } else {
100
+ this.isHeaderRow = supportedHeaderRow(node);
101
+ }
97
102
  if (this.isHeaderRow && expValEquals('platform_editor_table_q4_patch_4', 'isEnabled', true)) {
98
103
  this.isSingleRowTable = this.checkIsSingleRowTable();
99
104
  }
@@ -184,7 +189,9 @@ export default class TableRowNativeStickyWithFallback extends TableNodeView {
184
189
  // see if we're changing into a header row or
185
190
  // changing away from one
186
191
  let rowIndex = 0;
187
- if (expValEquals('platform_editor_fix_sticky_header_row', 'isEnabled', true)) {
192
+ if (expValEquals('platform_editor_table_q4_patch_5', 'isEnabled', true)) {
193
+ rowIndex = getTableRowIndex(this.view, this.getPos);
194
+ } else if (expValEquals('platform_editor_fix_sticky_header_row', 'isEnabled', true)) {
188
195
  try {
189
196
  const pos = this.getPos();
190
197
  if (pos) {
@@ -110,9 +110,18 @@ export const isTableNestedUnderBodiedSyncBlock = (state, tablePos) => {
110
110
  };
111
111
  const anyChildCellMergedAcrossRow = node => mapChildren(node, child => child.attrs.rowspan || 0).some(rowspan => rowspan > 1);
112
112
  const anyChildCellMergedAcrossColumn = node => mapChildren(node, child => child.attrs.colspan || 0).some(colspan => colspan > 1);
113
+ export const getTableRowIndex = (view, getPos) => {
114
+ try {
115
+ const pos = getPos();
116
+ return pos === undefined ? 0 : view.state.doc.resolve(pos).index();
117
+ } catch {
118
+ return 0;
119
+ }
120
+ };
113
121
 
114
122
  /**
115
123
  * Check if a given node is a header row with this definition:
124
+ * - the row is the first row when platform_editor_table_q4_patch_5 is enabled
116
125
  * - all children are tableHeader cells
117
126
  * - no table cells have been merged with other table row cells (rowspan > 1)
118
127
  * - no table cells have been merged with other table column cells (colspan > 1),
@@ -125,6 +134,9 @@ const anyChildCellMergedAcrossColumn = node => mapChildren(node, child => child.
125
134
  * @returns boolean if it meets definition
126
135
  */
127
136
  export const supportedHeaderRow = (node, rowIndex = 0) => {
137
+ if (expValEquals('platform_editor_table_q4_patch_5', 'isEnabled', true) && rowIndex !== 0) {
138
+ return false;
139
+ }
128
140
  const allHeaders = mapChildren(node, child => child.type.name === 'tableHeader').every(Boolean);
129
141
  if (expValEquals('platform_editor_fix_sticky_header_malfunction', 'isEnabled', true)) {
130
142
  const someMergedAcrossRow = anyChildCellMergedAcrossRow(node);
@@ -19,7 +19,7 @@ import { pluginKey as tablePluginKey } from '../pm-plugins/plugin-key';
19
19
  import { updateStickyState } from '../pm-plugins/sticky-headers/commands';
20
20
  import { clearStickyCornerMaskPositions, syncStickyRowToTable, updateStickyMargins as updateTableMargin } from '../pm-plugins/table-resizing/utils/dom';
21
21
  import { getTop, getTree } from '../pm-plugins/utils/dom';
22
- import { supportedHeaderRow } from '../pm-plugins/utils/nodes';
22
+ import { getTableRowIndex, supportedHeaderRow } from '../pm-plugins/utils/nodes';
23
23
  import { TableCssClassName as ClassName, TableCssClassName } from '../types';
24
24
  import { stickyHeaderBorderBottomWidth, stickyRowOffsetTop, tableControlsSpacing, tableScrollbarOffset } from '../ui/consts';
25
25
  import TableNodeView from './TableNodeViewBase';
@@ -104,13 +104,16 @@ var TableRow = /*#__PURE__*/function (_TableNodeView) {
104
104
  var $pos = view.state.doc.resolve(pos);
105
105
  _this.isInNestedTable = getParentOfTypeCount(view.state.schema.nodes.table)($pos) > 1;
106
106
  // Resolve rowIndex only when the flag is on — otherwise it's unused
107
- if (expValEquals('platform_editor_fix_sticky_header_row', 'isEnabled', true)) {
107
+ if (expValEquals('platform_editor_fix_sticky_header_row', 'isEnabled', true) && !expValEquals('platform_editor_table_q4_patch_5', 'isEnabled', true)) {
108
108
  rowIndex = $pos.index();
109
109
  }
110
110
  }
111
111
  } catch (_unused) {
112
112
  // Intentionally swallowed — getPos can return stale positions during AI streaming
113
113
  }
114
+ if (expValEquals('platform_editor_table_q4_patch_5', 'isEnabled', true)) {
115
+ rowIndex = getTableRowIndex(view, getPos);
116
+ }
114
117
  _this.isHeaderRow = supportedHeaderRow(node, rowIndex);
115
118
  if (_this.isHeaderRow) {
116
119
  _this.dom.setAttribute('data-vc-nvs', 'true');
@@ -168,6 +171,9 @@ var TableRow = /*#__PURE__*/function (_TableNodeView) {
168
171
  // Intentionally swallowed — getPos can return stale positions during AI streaming
169
172
  }
170
173
  }
174
+ if (expValEquals('platform_editor_table_q4_patch_5', 'isEnabled', true)) {
175
+ rowIndex = getTableRowIndex(this.view, this.getPos);
176
+ }
171
177
  var newNodeIsHeaderRow = supportedHeaderRow(node, rowIndex);
172
178
  if (this.isHeaderRow !== newNodeIsHeaderRow) {
173
179
  return false; // re-create nodeview
@@ -22,7 +22,7 @@ import { pluginKey as tablePluginKey } from '../pm-plugins/plugin-key';
22
22
  import { updateStickyState } from '../pm-plugins/sticky-headers/commands';
23
23
  import { clearStickyCornerMaskPositions, syncStickyRowToTable, updateStickyMargins as updateTableMargin } from '../pm-plugins/table-resizing/utils/dom';
24
24
  import { areAllRectsZero, getTop, getTree } from '../pm-plugins/utils/dom';
25
- import { supportedHeaderRow } from '../pm-plugins/utils/nodes';
25
+ import { getTableRowIndex, 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';
28
28
  import TableNodeView from './TableNodeViewBase';
@@ -102,7 +102,12 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_TableNodeView) {
102
102
  _this.disableNativeSticky = false;
103
103
  }
104
104
  });
105
- _this.isHeaderRow = supportedHeaderRow(node);
105
+ if (expValEquals('platform_editor_table_q4_patch_5', 'isEnabled', true)) {
106
+ var rowIndex = getTableRowIndex(view, getPos);
107
+ _this.isHeaderRow = supportedHeaderRow(node, rowIndex);
108
+ } else {
109
+ _this.isHeaderRow = supportedHeaderRow(node);
110
+ }
106
111
  if (_this.isHeaderRow && expValEquals('platform_editor_table_q4_patch_4', 'isEnabled', true)) {
107
112
  _this.isSingleRowTable = _this.checkIsSingleRowTable();
108
113
  }
@@ -196,7 +201,9 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_TableNodeView) {
196
201
  // see if we're changing into a header row or
197
202
  // changing away from one
198
203
  var rowIndex = 0;
199
- if (expValEquals('platform_editor_fix_sticky_header_row', 'isEnabled', true)) {
204
+ if (expValEquals('platform_editor_table_q4_patch_5', 'isEnabled', true)) {
205
+ rowIndex = getTableRowIndex(this.view, this.getPos);
206
+ } else if (expValEquals('platform_editor_fix_sticky_header_row', 'isEnabled', true)) {
200
207
  try {
201
208
  var pos = this.getPos();
202
209
  if (pos) {
@@ -135,9 +135,18 @@ var anyChildCellMergedAcrossColumn = function anyChildCellMergedAcrossColumn(nod
135
135
  return colspan > 1;
136
136
  });
137
137
  };
138
+ export var getTableRowIndex = function getTableRowIndex(view, getPos) {
139
+ try {
140
+ var pos = getPos();
141
+ return pos === undefined ? 0 : view.state.doc.resolve(pos).index();
142
+ } catch (_unused2) {
143
+ return 0;
144
+ }
145
+ };
138
146
 
139
147
  /**
140
148
  * Check if a given node is a header row with this definition:
149
+ * - the row is the first row when platform_editor_table_q4_patch_5 is enabled
141
150
  * - all children are tableHeader cells
142
151
  * - no table cells have been merged with other table row cells (rowspan > 1)
143
152
  * - no table cells have been merged with other table column cells (colspan > 1),
@@ -151,6 +160,9 @@ var anyChildCellMergedAcrossColumn = function anyChildCellMergedAcrossColumn(nod
151
160
  */
152
161
  export var supportedHeaderRow = function supportedHeaderRow(node) {
153
162
  var rowIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
163
+ if (expValEquals('platform_editor_table_q4_patch_5', 'isEnabled', true) && rowIndex !== 0) {
164
+ return false;
165
+ }
154
166
  var allHeaders = mapChildren(node, function (child) {
155
167
  return child.type.name === 'tableHeader';
156
168
  }).every(Boolean);
@@ -1,5 +1,6 @@
1
1
  import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
2
2
  import type { EditorState, Selection } from '@atlaskit/editor-prosemirror/state';
3
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
3
4
  export declare const isIsolating: (node: PmNode) => boolean;
4
5
  export declare const containsHeaderColumn: (table: PmNode) => boolean;
5
6
  export declare const containsHeaderRow: (table: PmNode) => boolean;
@@ -17,8 +18,10 @@ export declare const isTableNestedInMoreThanOneNode: (state: EditorState, tableP
17
18
  * Used to prefer DOM-measured wrapper width over getParentNodeWidth() for stable scaling.
18
19
  */
19
20
  export declare const isTableNestedUnderBodiedSyncBlock: (state: EditorState, tablePos: number) => boolean;
21
+ export declare const getTableRowIndex: (view: EditorView, getPos: () => number | undefined) => number;
20
22
  /**
21
23
  * Check if a given node is a header row with this definition:
24
+ * - the row is the first row when platform_editor_table_q4_patch_5 is enabled
22
25
  * - all children are tableHeader cells
23
26
  * - no table cells have been merged with other table row cells (rowspan > 1)
24
27
  * - no table cells have been merged with other table column cells (colspan > 1),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "24.4.23",
3
+ "version": "24.4.24",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -52,7 +52,7 @@
52
52
  "@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^3.0.0",
53
53
  "@atlaskit/pragmatic-drag-and-drop-hitbox": "^2.0.0",
54
54
  "@atlaskit/primitives": "^22.2.0",
55
- "@atlaskit/tmp-editor-statsig": "^135.0.0",
55
+ "@atlaskit/tmp-editor-statsig": "^135.2.0",
56
56
  "@atlaskit/toggle": "^17.1.0",
57
57
  "@atlaskit/tokens": "^16.3.0",
58
58
  "@atlaskit/tooltip": "^23.2.0",
@@ -67,7 +67,7 @@
67
67
  "uuid": "^3.1.0"
68
68
  },
69
69
  "peerDependencies": {
70
- "@atlaskit/editor-common": "^116.41.0",
70
+ "@atlaskit/editor-common": "^116.42.0",
71
71
  "react": "^18.2.0",
72
72
  "react-dom": "^18.2.0",
73
73
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"