@atlaskit/editor-plugin-table 9.5.9 → 9.5.10

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,16 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 9.5.10
4
+
5
+ ### Patch Changes
6
+
7
+ - [#116555](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/116555)
8
+ [`ee0cb1bc42e39`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/ee0cb1bc42e39) -
9
+ [ux] ED-26663 Bugfix for a regression introduced by nested tables - when nested table nodes are
10
+ enabled but the nested table experiment is disabled, copying table content inside a bodied
11
+ extension and pasting it in the table results in the content being pasted under the table and
12
+ wrapped in a table
13
+
3
14
  ## 9.5.9
4
15
 
5
16
  ### Patch Changes
@@ -193,11 +193,21 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatchAnalytic
193
193
  // This needs to go before `transformSliceToRemoveOpenTable`
194
194
  slice = (0, _transforms.transformSliceToRemoveOpenExpand)(slice, schema);
195
195
 
196
- /** If a partial paste of table, paste only table's content */
197
- slice = (0, _paste.transformSliceToRemoveOpenTable)(slice, schema);
196
+ // transformSliceToRemoveOpenTable() transforms based on the depth of the root node, assuming that the tables will be at the root
197
+ // Bodied extensions will contribute to the depth of the table selection so we need to remove them first
198
+ if ((0, _platformFeatureFlags.fg)('platform_editor_nested_tables_bodied_extension_fix')) {
199
+ /** If a partial paste of bodied extension, paste only text */
200
+ slice = (0, _transforms.transformSliceToRemoveOpenBodiedExtension)(slice, schema);
198
201
 
199
- /** If a partial paste of bodied extension, paste only text */
200
- slice = (0, _transforms.transformSliceToRemoveOpenBodiedExtension)(slice, schema);
202
+ /** If a partial paste of table, paste only table's content */
203
+ slice = (0, _paste.transformSliceToRemoveOpenTable)(slice, schema);
204
+ } else {
205
+ /** If a partial paste of table, paste only table's content */
206
+ slice = (0, _paste.transformSliceToRemoveOpenTable)(slice, schema);
207
+
208
+ /** If a partial paste of bodied extension, paste only text */
209
+ slice = (0, _transforms.transformSliceToRemoveOpenBodiedExtension)(slice, schema);
210
+ }
201
211
 
202
212
  /** If a partial paste of multi bodied extension, paste only children */
203
213
  slice = (0, _transforms.transformSliceToRemoveOpenMultiBodiedExtension)(slice, schema);
@@ -195,8 +195,8 @@ var containsNonTableBlockChildren = function containsNonTableBlockChildren(fragm
195
195
  var transformSliceToRemoveOpenTable = exports.transformSliceToRemoveOpenTable = function transformSliceToRemoveOpenTable(slice, schema) {
196
196
  var _slice$content$firstC4;
197
197
  if ((0, _platformFeatureFlags.fg)('platform_editor_nested_tables_paste_wrap_fix')) {
198
- // Case 1: A slice of a textblock selection inside a nested table
199
- // Prosemirror wraps nested textblock selections in their respective tables
198
+ // Case 1: A slice of a block selection inside a nested table
199
+ // Prosemirror wraps nested block selections in their respective tables
200
200
  // We are using `safeInsert` to paste nested tables, so we do not want to preserve this wrapping
201
201
 
202
202
  // slice starts and ends inside a nested table at the same depth
@@ -208,7 +208,7 @@ var transformSliceToRemoveOpenTable = exports.transformSliceToRemoveOpenTable =
208
208
  // if the slice is a single cell table and contains cells with single cell tables, descend into it until we find textblock children
209
209
  if (isFragmentSingleCellTable(slice.content, schema)) {
210
210
  var _slice$content$firstC2;
211
- (_slice$content$firstC2 = slice.content.firstChild) === null || _slice$content$firstC2 === void 0 || _slice$content$firstC2.descendants(function (node, _pos, parent) {
211
+ (_slice$content$firstC2 = slice.content.firstChild) === null || _slice$content$firstC2 === void 0 || _slice$content$firstC2.descendants(function (node) {
212
212
  if (isNodeSingleCellTable(node, schema)) {
213
213
  descendedDepth += tableDepthDecrement;
214
214
  } else if (node.type === schema.nodes.table) {
@@ -185,11 +185,21 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
185
185
  // This needs to go before `transformSliceToRemoveOpenTable`
186
186
  slice = transformSliceToRemoveOpenExpand(slice, schema);
187
187
 
188
- /** If a partial paste of table, paste only table's content */
189
- slice = transformSliceToRemoveOpenTable(slice, schema);
188
+ // transformSliceToRemoveOpenTable() transforms based on the depth of the root node, assuming that the tables will be at the root
189
+ // Bodied extensions will contribute to the depth of the table selection so we need to remove them first
190
+ if (fg('platform_editor_nested_tables_bodied_extension_fix')) {
191
+ /** If a partial paste of bodied extension, paste only text */
192
+ slice = transformSliceToRemoveOpenBodiedExtension(slice, schema);
190
193
 
191
- /** If a partial paste of bodied extension, paste only text */
192
- slice = transformSliceToRemoveOpenBodiedExtension(slice, schema);
194
+ /** If a partial paste of table, paste only table's content */
195
+ slice = transformSliceToRemoveOpenTable(slice, schema);
196
+ } else {
197
+ /** If a partial paste of table, paste only table's content */
198
+ slice = transformSliceToRemoveOpenTable(slice, schema);
199
+
200
+ /** If a partial paste of bodied extension, paste only text */
201
+ slice = transformSliceToRemoveOpenBodiedExtension(slice, schema);
202
+ }
193
203
 
194
204
  /** If a partial paste of multi bodied extension, paste only children */
195
205
  slice = transformSliceToRemoveOpenMultiBodiedExtension(slice, schema);
@@ -187,8 +187,8 @@ const containsNonTableBlockChildren = (fragment, schema) => {
187
187
  export const transformSliceToRemoveOpenTable = (slice, schema) => {
188
188
  var _slice$content$firstC8;
189
189
  if (fg('platform_editor_nested_tables_paste_wrap_fix')) {
190
- // Case 1: A slice of a textblock selection inside a nested table
191
- // Prosemirror wraps nested textblock selections in their respective tables
190
+ // Case 1: A slice of a block selection inside a nested table
191
+ // Prosemirror wraps nested block selections in their respective tables
192
192
  // We are using `safeInsert` to paste nested tables, so we do not want to preserve this wrapping
193
193
 
194
194
  // slice starts and ends inside a nested table at the same depth
@@ -200,7 +200,7 @@ export const transformSliceToRemoveOpenTable = (slice, schema) => {
200
200
  // if the slice is a single cell table and contains cells with single cell tables, descend into it until we find textblock children
201
201
  if (isFragmentSingleCellTable(slice.content, schema)) {
202
202
  var _slice$content$firstC2;
203
- (_slice$content$firstC2 = slice.content.firstChild) === null || _slice$content$firstC2 === void 0 ? void 0 : _slice$content$firstC2.descendants((node, _pos, parent) => {
203
+ (_slice$content$firstC2 = slice.content.firstChild) === null || _slice$content$firstC2 === void 0 ? void 0 : _slice$content$firstC2.descendants(node => {
204
204
  if (isNodeSingleCellTable(node, schema)) {
205
205
  descendedDepth += tableDepthDecrement;
206
206
  } else if (node.type === schema.nodes.table) {
@@ -186,11 +186,21 @@ export var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch
186
186
  // This needs to go before `transformSliceToRemoveOpenTable`
187
187
  slice = transformSliceToRemoveOpenExpand(slice, schema);
188
188
 
189
- /** If a partial paste of table, paste only table's content */
190
- slice = transformSliceToRemoveOpenTable(slice, schema);
189
+ // transformSliceToRemoveOpenTable() transforms based on the depth of the root node, assuming that the tables will be at the root
190
+ // Bodied extensions will contribute to the depth of the table selection so we need to remove them first
191
+ if (fg('platform_editor_nested_tables_bodied_extension_fix')) {
192
+ /** If a partial paste of bodied extension, paste only text */
193
+ slice = transformSliceToRemoveOpenBodiedExtension(slice, schema);
191
194
 
192
- /** If a partial paste of bodied extension, paste only text */
193
- slice = transformSliceToRemoveOpenBodiedExtension(slice, schema);
195
+ /** If a partial paste of table, paste only table's content */
196
+ slice = transformSliceToRemoveOpenTable(slice, schema);
197
+ } else {
198
+ /** If a partial paste of table, paste only table's content */
199
+ slice = transformSliceToRemoveOpenTable(slice, schema);
200
+
201
+ /** If a partial paste of bodied extension, paste only text */
202
+ slice = transformSliceToRemoveOpenBodiedExtension(slice, schema);
203
+ }
194
204
 
195
205
  /** If a partial paste of multi bodied extension, paste only children */
196
206
  slice = transformSliceToRemoveOpenMultiBodiedExtension(slice, schema);
@@ -188,8 +188,8 @@ var containsNonTableBlockChildren = function containsNonTableBlockChildren(fragm
188
188
  export var transformSliceToRemoveOpenTable = function transformSliceToRemoveOpenTable(slice, schema) {
189
189
  var _slice$content$firstC4;
190
190
  if (fg('platform_editor_nested_tables_paste_wrap_fix')) {
191
- // Case 1: A slice of a textblock selection inside a nested table
192
- // Prosemirror wraps nested textblock selections in their respective tables
191
+ // Case 1: A slice of a block selection inside a nested table
192
+ // Prosemirror wraps nested block selections in their respective tables
193
193
  // We are using `safeInsert` to paste nested tables, so we do not want to preserve this wrapping
194
194
 
195
195
  // slice starts and ends inside a nested table at the same depth
@@ -201,7 +201,7 @@ export var transformSliceToRemoveOpenTable = function transformSliceToRemoveOpen
201
201
  // if the slice is a single cell table and contains cells with single cell tables, descend into it until we find textblock children
202
202
  if (isFragmentSingleCellTable(slice.content, schema)) {
203
203
  var _slice$content$firstC2;
204
- (_slice$content$firstC2 = slice.content.firstChild) === null || _slice$content$firstC2 === void 0 || _slice$content$firstC2.descendants(function (node, _pos, parent) {
204
+ (_slice$content$firstC2 = slice.content.firstChild) === null || _slice$content$firstC2 === void 0 || _slice$content$firstC2.descendants(function (node) {
205
205
  if (isNodeSingleCellTable(node, schema)) {
206
206
  descendedDepth += tableDepthDecrement;
207
207
  } else if (node.type === schema.nodes.table) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "9.5.9",
3
+ "version": "9.5.10",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -164,6 +164,9 @@
164
164
  },
165
165
  "platform_editor_react18_stickyheaders_fix": {
166
166
  "type": "boolean"
167
+ },
168
+ "platform_editor_nested_tables_bodied_extension_fix": {
169
+ "type": "boolean"
167
170
  }
168
171
  }
169
172
  }
@@ -287,11 +287,21 @@ export const createPlugin = (
287
287
  // This needs to go before `transformSliceToRemoveOpenTable`
288
288
  slice = transformSliceToRemoveOpenExpand(slice, schema);
289
289
 
290
- /** If a partial paste of table, paste only table's content */
291
- slice = transformSliceToRemoveOpenTable(slice, schema);
292
-
293
- /** If a partial paste of bodied extension, paste only text */
294
- slice = transformSliceToRemoveOpenBodiedExtension(slice, schema);
290
+ // transformSliceToRemoveOpenTable() transforms based on the depth of the root node, assuming that the tables will be at the root
291
+ // Bodied extensions will contribute to the depth of the table selection so we need to remove them first
292
+ if (fg('platform_editor_nested_tables_bodied_extension_fix')) {
293
+ /** If a partial paste of bodied extension, paste only text */
294
+ slice = transformSliceToRemoveOpenBodiedExtension(slice, schema);
295
+
296
+ /** If a partial paste of table, paste only table's content */
297
+ slice = transformSliceToRemoveOpenTable(slice, schema);
298
+ } else {
299
+ /** If a partial paste of table, paste only table's content */
300
+ slice = transformSliceToRemoveOpenTable(slice, schema);
301
+
302
+ /** If a partial paste of bodied extension, paste only text */
303
+ slice = transformSliceToRemoveOpenBodiedExtension(slice, schema);
304
+ }
295
305
 
296
306
  /** If a partial paste of multi bodied extension, paste only children */
297
307
  slice = transformSliceToRemoveOpenMultiBodiedExtension(slice, schema);
@@ -244,8 +244,8 @@ const containsNonTableBlockChildren = (fragment: Fragment, schema: Schema): bool
244
244
 
245
245
  export const transformSliceToRemoveOpenTable = (slice: Slice, schema: Schema): Slice => {
246
246
  if (fg('platform_editor_nested_tables_paste_wrap_fix')) {
247
- // Case 1: A slice of a textblock selection inside a nested table
248
- // Prosemirror wraps nested textblock selections in their respective tables
247
+ // Case 1: A slice of a block selection inside a nested table
248
+ // Prosemirror wraps nested block selections in their respective tables
249
249
  // We are using `safeInsert` to paste nested tables, so we do not want to preserve this wrapping
250
250
 
251
251
  // slice starts and ends inside a nested table at the same depth
@@ -256,7 +256,7 @@ export const transformSliceToRemoveOpenTable = (slice: Slice, schema: Schema): S
256
256
 
257
257
  // if the slice is a single cell table and contains cells with single cell tables, descend into it until we find textblock children
258
258
  if (isFragmentSingleCellTable(slice.content, schema)) {
259
- slice.content.firstChild?.descendants((node, _pos, parent) => {
259
+ slice.content.firstChild?.descendants((node) => {
260
260
  if (isNodeSingleCellTable(node, schema)) {
261
261
  descendedDepth += tableDepthDecrement;
262
262
  } else if (node.type === schema.nodes.table) {