@atlaskit/editor-plugin-table 17.3.21 → 17.3.23

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,19 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 17.3.23
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 17.3.22
10
+
11
+ ### Patch Changes
12
+
13
+ - [`a040c03082274`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/a040c03082274) -
14
+ [ux] EDITOR-507 Clean up main nested tables experiment `platform_editor_nested_tables`
15
+ - Updated dependencies
16
+
3
17
  ## 17.3.21
4
18
 
5
19
  ### Patch Changes
@@ -15,7 +15,6 @@ var _state = require("@atlaskit/editor-prosemirror/state");
15
15
  var _utils = require("@atlaskit/editor-prosemirror/utils");
16
16
  var _tableMap = require("@atlaskit/editor-tables/table-map");
17
17
  var _utils2 = require("@atlaskit/editor-tables/utils");
18
- var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
19
18
  var _commands = require("../analytics/commands");
20
19
  var _tableAnalytics = require("../table-analytics");
21
20
  var _columnWidth = require("../transforms/column-width");
@@ -274,10 +273,8 @@ var insertTableWithNestingSupport = exports.insertTableWithNestingSupport = func
274
273
  var insertAt;
275
274
  var isNestedTable = false;
276
275
  if ((0, _utils.hasParentNodeOfType)(schema.nodes.table)(tr.selection) && (0, _nesting.isNestedTablesSupported)(schema)) {
277
- // If the experiment is disabled, or we're trying to nest deeper than one level, we insert the table after the top table
278
- if ((0, _experiments.editorExperiment)('nested-tables-in-tables', false, {
279
- exposure: true
280
- }) || (0, _nesting.getParentOfTypeCount)(schema.nodes.table)(tr.selection.$from) > 1) {
276
+ // If trying to nest deeper than one level, we insert the table after the top table
277
+ if ((0, _nesting.getParentOfTypeCount)(schema.nodes.table)(tr.selection.$from) > 1) {
281
278
  var positionAfterTopTable = (0, _nesting.getPositionAfterTopParentNodeOfType)(schema.nodes.table)(tr.selection.$from);
282
279
  if (!positionAfterTopTable) {
283
280
  return tr;
@@ -58,7 +58,7 @@ var createTableAnchorDecorations = function createTableAnchorDecorations(state)
58
58
  var shouldAddAnchorNameInDecoration = !(0, _styles.isCSSAttrAnchorSupported)() && (0, _styles.isCSSAnchorSupported)() && (0, _platformFeatureFlags.fg)('platform_editor_table_sticky_header_patch_8');
59
59
  var attributes = {
60
60
  'data-node-anchor': anchorName,
61
- 'style': "anchor-name: ".concat(anchorName, ";")
61
+ style: "anchor-name: ".concat(anchorName, ";")
62
62
  };
63
63
  decs.push(_view.Decoration.node(pos, pos + node.nodeSize, shouldAddAnchorNameInDecoration ? attributes : {
64
64
  'data-node-anchor': anchorName
@@ -14,7 +14,6 @@ var _model = require("@atlaskit/editor-prosemirror/model");
14
14
  var _utils2 = require("@atlaskit/editor-prosemirror/utils");
15
15
  var _editorTables = require("@atlaskit/editor-tables");
16
16
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
17
- var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
18
17
  var _pluginFactory = require("../plugin-factory");
19
18
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
20
19
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -75,17 +74,16 @@ var removeTableFromLastChild = exports.removeTableFromLastChild = function remov
75
74
  return i === fragment.childCount - 1 ? unwrapContentFromTable(node) : node;
76
75
  };
77
76
  var transformSliceToRemoveNestedTables = exports.transformSliceToRemoveNestedTables = function transformSliceToRemoveNestedTables(slice, schema, selection) {
78
- var isNestingAllowed = (0, _experiments.editorExperiment)('nested-tables-in-tables', true);
79
77
  var _schema$nodes2 = schema.nodes,
80
78
  table = _schema$nodes2.table,
81
79
  tableCell = _schema$nodes2.tableCell,
82
80
  tableHeader = _schema$nodes2.tableHeader;
83
81
  var openEnd = slice.openEnd;
84
82
  var newFragment = (0, _utils.flatmap)(slice.content, function (node, i, fragment) {
85
- var _slice$content$firstC;
86
- // if pasted content is a node that supports nesting a table
87
- // such as layoutSection or expand allow 1 level by default
88
- var allowedTableNesting = 1;
83
+ var _slice$content$firstC, _slice$content$lastCh;
84
+ // We allow default nesting of 2 to support
85
+ // two levels of nesting in nodes that support table nesting already such as layoutSection and expands
86
+ var allowedTableNesting = 2;
89
87
  var isCellSelection = selection instanceof _editorTables.CellSelection;
90
88
  var isPasteInTable = (0, _utils2.hasParentNodeOfType)([table, tableCell, tableHeader])(selection);
91
89
  var isPasteInNestedTable = (0, _nesting.getParentOfTypeCount)(schema.nodes.table)(selection.$from) > 1;
@@ -93,55 +91,42 @@ var transformSliceToRemoveNestedTables = exports.transformSliceToRemoveNestedTab
93
91
 
94
92
  // Pasted content only contains a table and no other content
95
93
  var isCellPaste = isPasteInTable && slice.content.childCount === 1 && ((_slice$content$firstC = slice.content.firstChild) === null || _slice$content$firstC === void 0 ? void 0 : _slice$content$firstC.type) === table && (!isPasteFullTableInsideEmptyCellEnabled || slice.openStart !== 0 && slice.openEnd !== 0);
96
- if (isNestingAllowed) {
97
- var _slice$content$lastCh;
98
- // if nesting is allowed we bump up the default nesting allowance to 2 to support
99
- // two levels of nesting in nodes that support table nesting already such as layoutSection and expands
100
- allowedTableNesting = 2;
101
94
 
102
- // however if pasted content is a table, allow just one level
103
- if (node.type === schema.nodes.table) {
104
- allowedTableNesting = 1;
105
-
106
- // if paste is inside a table, allow no further nesting
107
- if (isPasteInTable) {
108
- allowedTableNesting = 0;
109
- }
110
-
111
- // unless we are pasting inside a nested table, then bounce back to 1 level
112
- // because editor-plugin-paste will lift the table to the parent table (just below it)
113
- if (isPasteInNestedTable) {
114
- allowedTableNesting = 1;
115
- }
95
+ // however if pasted content is a table, allow just one level
96
+ if (node.type === schema.nodes.table) {
97
+ allowedTableNesting = 1;
116
98
 
117
- // paste of table cells into a table cell - content is spread across multiple cells
118
- // by editor-tables so needs to be treated a little differently
119
- if (isCellPaste || isCellSelection) {
120
- allowedTableNesting = 1;
121
- if (isPasteInNestedTable) {
122
- allowedTableNesting = 0;
123
- }
124
- }
99
+ // if paste is inside a table, allow no further nesting
100
+ if (isPasteInTable) {
101
+ allowedTableNesting = 0;
125
102
  }
126
103
 
127
- // Prevent invalid openEnd after pasting tables with a selection that ends inside a nested table cell.
128
- // If the slice ends with a selection that ends inside a nested table, and we paste inside a table we
129
- // need to adjust the openEnd because it is no longer correct. If we don't, Prosemirror fires an exception
130
- // because it iterates to a non-existent depth and the transform will not be applied
131
- if (slice.openEnd >= 7 &&
132
- // depth of a nested table cell
133
- slice.content.childCount > 1 && ((_slice$content$lastCh = slice.content.lastChild) === null || _slice$content$lastCh === void 0 ? void 0 : _slice$content$lastCh.type) === table && isPasteInTable) {
134
- // re-point the slice's openEnd to non-nested table cell depth
135
- openEnd = 4;
104
+ // unless we are pasting inside a nested table, then bounce back to 1 level
105
+ // because editor-plugin-paste will lift the table to the parent table (just below it)
106
+ if (isPasteInNestedTable) {
107
+ allowedTableNesting = 1;
136
108
  }
137
- } else {
138
- // for layouts and expands, we start with 1 level of nesting as set above
139
109
 
140
- // if pasted content is a table, don't allow further nesting
141
- if (node.type === schema.nodes.table) {
142
- allowedTableNesting = 0;
110
+ // paste of table cells into a table cell - content is spread across multiple cells
111
+ // by editor-tables so needs to be treated a little differently
112
+ if (isCellPaste || isCellSelection) {
113
+ allowedTableNesting = 1;
114
+ if (isPasteInNestedTable) {
115
+ allowedTableNesting = 0;
116
+ }
143
117
  }
144
118
  }
119
+
120
+ // Prevent invalid openEnd after pasting tables with a selection that ends inside a nested table cell.
121
+ // If the slice ends with a selection that ends inside a nested table, and we paste inside a table we
122
+ // need to adjust the openEnd because it is no longer correct. If we don't, Prosemirror fires an exception
123
+ // because it iterates to a non-existent depth and the transform will not be applied
124
+ if (slice.openEnd >= 7 &&
125
+ // depth of a nested table cell
126
+ slice.content.childCount > 1 && ((_slice$content$lastCh = slice.content.lastChild) === null || _slice$content$lastCh === void 0 ? void 0 : _slice$content$lastCh.type) === table && isPasteInTable) {
127
+ // re-point the slice's openEnd to non-nested table cell depth
128
+ openEnd = 4;
129
+ }
145
130
  if (isCellSelection && !isCellPaste) {
146
131
  // if pasting into a cell selection, we need to flatten the parent table as well
147
132
  return _unwrapNestedTables(_model.Fragment.fromArray([node]), schema, allowedTableNesting);
@@ -574,10 +574,8 @@ var tablePlugin = function tablePlugin(_ref) {
574
574
  var tr = state.tr;
575
575
  // If the cursor is inside a table
576
576
  if ((0, _utils.hasParentNodeOfType)(state.schema.nodes.table)(state.selection) && options !== null && options !== void 0 && (_options$tableOptions6 = options.tableOptions) !== null && _options$tableOptions6 !== void 0 && _options$tableOptions6.allowNestedTables) {
577
- // If the experiment is disabled, or we're trying to nest deeper than one level, we insert the table after the top table
578
- if ((0, _experiments.editorExperiment)('nested-tables-in-tables', false, {
579
- exposure: true
580
- }) || (0, _nesting.getParentOfTypeCount)(state.schema.nodes.table)(state.selection.$from) > 1) {
577
+ // If trying to nest deeper than one level, we insert the table after the top table
578
+ if ((0, _nesting.getParentOfTypeCount)(state.schema.nodes.table)(state.selection.$from) > 1) {
581
579
  // Nesting is too deep insert table after the top parent table
582
580
  var positionAfterTopTable = (0, _nesting.getPositionAfterTopParentNodeOfType)(state.schema.nodes.table)(state.selection.$from);
583
581
  tr = (0, _utils.safeInsert)(tableNode, positionAfterTopTable)(tr);
@@ -91,9 +91,8 @@ var RowControlsComponent = /*#__PURE__*/function (_Component) {
91
91
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
92
92
  top: thisRowSticky ? "3px" : undefined,
93
93
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
94
- paddingTop: thisRowSticky
95
- // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
96
- ? "".concat(_consts.tableControlsSpacing - 2, "px") : undefined
94
+ paddingTop: thisRowSticky ? // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
95
+ "".concat(_consts.tableControlsSpacing - 2, "px") : undefined
97
96
  }
98
97
  }, /*#__PURE__*/_react.default.createElement("button", {
99
98
  "aria-label": formatMessage(_messages.tableMessages.rowControl),
@@ -6,7 +6,6 @@ import { Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
6
6
  import { hasParentNodeOfType, safeInsert } from '@atlaskit/editor-prosemirror/utils';
7
7
  import { TableMap } from '@atlaskit/editor-tables/table-map';
8
8
  import { addColumnAt as addColumnAtPMUtils, addRowAt, findTable, selectedRect } from '@atlaskit/editor-tables/utils';
9
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
10
9
  import { updateRowOrColumnMovedTransform } from '../analytics/commands';
11
10
  import { META_KEYS } from '../table-analytics';
12
11
  import { rescaleColumns } from '../transforms/column-width';
@@ -233,10 +232,8 @@ export const insertTableWithNestingSupport = ({
233
232
  let insertAt;
234
233
  let isNestedTable = false;
235
234
  if (hasParentNodeOfType(schema.nodes.table)(tr.selection) && isNestedTablesSupported(schema)) {
236
- // If the experiment is disabled, or we're trying to nest deeper than one level, we insert the table after the top table
237
- if (editorExperiment('nested-tables-in-tables', false, {
238
- exposure: true
239
- }) || getParentOfTypeCount(schema.nodes.table)(tr.selection.$from) > 1) {
235
+ // If trying to nest deeper than one level, we insert the table after the top table
236
+ if (getParentOfTypeCount(schema.nodes.table)(tr.selection.$from) > 1) {
240
237
  const positionAfterTopTable = getPositionAfterTopParentNodeOfType(schema.nodes.table)(tr.selection.$from);
241
238
  if (!positionAfterTopTable) {
242
239
  return tr;
@@ -43,7 +43,7 @@ const createTableAnchorDecorations = state => {
43
43
  const shouldAddAnchorNameInDecoration = !isCSSAttrAnchorSupported() && isCSSAnchorSupported() && fg('platform_editor_table_sticky_header_patch_8');
44
44
  const attributes = {
45
45
  'data-node-anchor': anchorName,
46
- 'style': `anchor-name: ${anchorName};`
46
+ style: `anchor-name: ${anchorName};`
47
47
  };
48
48
  decs.push(Decoration.node(pos, pos + node.nodeSize, shouldAddAnchorNameInDecoration ? attributes : {
49
49
  'data-node-anchor': anchorName
@@ -4,7 +4,6 @@ import { Slice, Fragment } from '@atlaskit/editor-prosemirror/model';
4
4
  import { flatten, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
5
5
  import { CellSelection } from '@atlaskit/editor-tables';
6
6
  import { fg } from '@atlaskit/platform-feature-flags';
7
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
8
7
  import { getPluginState } from '../plugin-factory';
9
8
 
10
9
  // lifts up the content of each cell, returning an array of nodes
@@ -64,7 +63,6 @@ export const removeTableFromLastChild = (node, i, fragment) => {
64
63
  return i === fragment.childCount - 1 ? unwrapContentFromTable(node) : node;
65
64
  };
66
65
  export const transformSliceToRemoveNestedTables = (slice, schema, selection) => {
67
- const isNestingAllowed = editorExperiment('nested-tables-in-tables', true);
68
66
  const {
69
67
  table,
70
68
  tableCell,
@@ -72,10 +70,10 @@ export const transformSliceToRemoveNestedTables = (slice, schema, selection) =>
72
70
  } = schema.nodes;
73
71
  let openEnd = slice.openEnd;
74
72
  const newFragment = flatmap(slice.content, (node, i, fragment) => {
75
- var _slice$content$firstC;
76
- // if pasted content is a node that supports nesting a table
77
- // such as layoutSection or expand allow 1 level by default
78
- let allowedTableNesting = 1;
73
+ var _slice$content$firstC, _slice$content$lastCh;
74
+ // We allow default nesting of 2 to support
75
+ // two levels of nesting in nodes that support table nesting already such as layoutSection and expands
76
+ let allowedTableNesting = 2;
79
77
  const isCellSelection = selection instanceof CellSelection;
80
78
  const isPasteInTable = hasParentNodeOfType([table, tableCell, tableHeader])(selection);
81
79
  const isPasteInNestedTable = getParentOfTypeCount(schema.nodes.table)(selection.$from) > 1;
@@ -83,55 +81,42 @@ export const transformSliceToRemoveNestedTables = (slice, schema, selection) =>
83
81
 
84
82
  // Pasted content only contains a table and no other content
85
83
  const isCellPaste = isPasteInTable && slice.content.childCount === 1 && ((_slice$content$firstC = slice.content.firstChild) === null || _slice$content$firstC === void 0 ? void 0 : _slice$content$firstC.type) === table && (!isPasteFullTableInsideEmptyCellEnabled || slice.openStart !== 0 && slice.openEnd !== 0);
86
- if (isNestingAllowed) {
87
- var _slice$content$lastCh;
88
- // if nesting is allowed we bump up the default nesting allowance to 2 to support
89
- // two levels of nesting in nodes that support table nesting already such as layoutSection and expands
90
- allowedTableNesting = 2;
91
84
 
92
- // however if pasted content is a table, allow just one level
93
- if (node.type === schema.nodes.table) {
94
- allowedTableNesting = 1;
95
-
96
- // if paste is inside a table, allow no further nesting
97
- if (isPasteInTable) {
98
- allowedTableNesting = 0;
99
- }
100
-
101
- // unless we are pasting inside a nested table, then bounce back to 1 level
102
- // because editor-plugin-paste will lift the table to the parent table (just below it)
103
- if (isPasteInNestedTable) {
104
- allowedTableNesting = 1;
105
- }
85
+ // however if pasted content is a table, allow just one level
86
+ if (node.type === schema.nodes.table) {
87
+ allowedTableNesting = 1;
106
88
 
107
- // paste of table cells into a table cell - content is spread across multiple cells
108
- // by editor-tables so needs to be treated a little differently
109
- if (isCellPaste || isCellSelection) {
110
- allowedTableNesting = 1;
111
- if (isPasteInNestedTable) {
112
- allowedTableNesting = 0;
113
- }
114
- }
89
+ // if paste is inside a table, allow no further nesting
90
+ if (isPasteInTable) {
91
+ allowedTableNesting = 0;
115
92
  }
116
93
 
117
- // Prevent invalid openEnd after pasting tables with a selection that ends inside a nested table cell.
118
- // If the slice ends with a selection that ends inside a nested table, and we paste inside a table we
119
- // need to adjust the openEnd because it is no longer correct. If we don't, Prosemirror fires an exception
120
- // because it iterates to a non-existent depth and the transform will not be applied
121
- if (slice.openEnd >= 7 &&
122
- // depth of a nested table cell
123
- slice.content.childCount > 1 && ((_slice$content$lastCh = slice.content.lastChild) === null || _slice$content$lastCh === void 0 ? void 0 : _slice$content$lastCh.type) === table && isPasteInTable) {
124
- // re-point the slice's openEnd to non-nested table cell depth
125
- openEnd = 4;
94
+ // unless we are pasting inside a nested table, then bounce back to 1 level
95
+ // because editor-plugin-paste will lift the table to the parent table (just below it)
96
+ if (isPasteInNestedTable) {
97
+ allowedTableNesting = 1;
126
98
  }
127
- } else {
128
- // for layouts and expands, we start with 1 level of nesting as set above
129
99
 
130
- // if pasted content is a table, don't allow further nesting
131
- if (node.type === schema.nodes.table) {
132
- allowedTableNesting = 0;
100
+ // paste of table cells into a table cell - content is spread across multiple cells
101
+ // by editor-tables so needs to be treated a little differently
102
+ if (isCellPaste || isCellSelection) {
103
+ allowedTableNesting = 1;
104
+ if (isPasteInNestedTable) {
105
+ allowedTableNesting = 0;
106
+ }
133
107
  }
134
108
  }
109
+
110
+ // Prevent invalid openEnd after pasting tables with a selection that ends inside a nested table cell.
111
+ // If the slice ends with a selection that ends inside a nested table, and we paste inside a table we
112
+ // need to adjust the openEnd because it is no longer correct. If we don't, Prosemirror fires an exception
113
+ // because it iterates to a non-existent depth and the transform will not be applied
114
+ if (slice.openEnd >= 7 &&
115
+ // depth of a nested table cell
116
+ slice.content.childCount > 1 && ((_slice$content$lastCh = slice.content.lastChild) === null || _slice$content$lastCh === void 0 ? void 0 : _slice$content$lastCh.type) === table && isPasteInTable) {
117
+ // re-point the slice's openEnd to non-nested table cell depth
118
+ openEnd = 4;
119
+ }
135
120
  if (isCellSelection && !isCellPaste) {
136
121
  // if pasting into a cell selection, we need to flatten the parent table as well
137
122
  return unwrapNestedTables(Fragment.fromArray([node]), schema, allowedTableNesting);
@@ -560,10 +560,8 @@ const tablePlugin = ({
560
560
  } = state;
561
561
  // If the cursor is inside a table
562
562
  if (hasParentNodeOfType(state.schema.nodes.table)(state.selection) && options !== null && options !== void 0 && (_options$tableOptions6 = options.tableOptions) !== null && _options$tableOptions6 !== void 0 && _options$tableOptions6.allowNestedTables) {
563
- // If the experiment is disabled, or we're trying to nest deeper than one level, we insert the table after the top table
564
- if (editorExperiment('nested-tables-in-tables', false, {
565
- exposure: true
566
- }) || getParentOfTypeCount(state.schema.nodes.table)(state.selection.$from) > 1) {
563
+ // If trying to nest deeper than one level, we insert the table after the top table
564
+ if (getParentOfTypeCount(state.schema.nodes.table)(state.selection.$from) > 1) {
567
565
  // Nesting is too deep insert table after the top parent table
568
566
  const positionAfterTopTable = getPositionAfterTopParentNodeOfType(state.schema.nodes.table)(state.selection.$from);
569
567
  tr = safeInsert(tableNode, positionAfterTopTable)(tr);
@@ -72,9 +72,9 @@ class RowControlsComponent extends Component {
72
72
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
73
73
  top: thisRowSticky ? `3px` : undefined,
74
74
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
75
- paddingTop: thisRowSticky
75
+ paddingTop: thisRowSticky ?
76
76
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
77
- ? `${tableControlsSpacing - 2}px` : undefined
77
+ `${tableControlsSpacing - 2}px` : undefined
78
78
  }
79
79
  }, /*#__PURE__*/React.createElement("button", {
80
80
  "aria-label": formatMessage(messages.rowControl),
@@ -9,7 +9,6 @@ import { Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
9
9
  import { hasParentNodeOfType, safeInsert } from '@atlaskit/editor-prosemirror/utils';
10
10
  import { TableMap } from '@atlaskit/editor-tables/table-map';
11
11
  import { addColumnAt as addColumnAtPMUtils, addRowAt, findTable, selectedRect } from '@atlaskit/editor-tables/utils';
12
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
13
12
  import { updateRowOrColumnMovedTransform } from '../analytics/commands';
14
13
  import { META_KEYS } from '../table-analytics';
15
14
  import { rescaleColumns } from '../transforms/column-width';
@@ -266,10 +265,8 @@ export var insertTableWithNestingSupport = function insertTableWithNestingSuppor
266
265
  var insertAt;
267
266
  var isNestedTable = false;
268
267
  if (hasParentNodeOfType(schema.nodes.table)(tr.selection) && isNestedTablesSupported(schema)) {
269
- // If the experiment is disabled, or we're trying to nest deeper than one level, we insert the table after the top table
270
- if (editorExperiment('nested-tables-in-tables', false, {
271
- exposure: true
272
- }) || getParentOfTypeCount(schema.nodes.table)(tr.selection.$from) > 1) {
268
+ // If trying to nest deeper than one level, we insert the table after the top table
269
+ if (getParentOfTypeCount(schema.nodes.table)(tr.selection.$from) > 1) {
273
270
  var positionAfterTopTable = getPositionAfterTopParentNodeOfType(schema.nodes.table)(tr.selection.$from);
274
271
  if (!positionAfterTopTable) {
275
272
  return tr;
@@ -51,7 +51,7 @@ var createTableAnchorDecorations = function createTableAnchorDecorations(state)
51
51
  var shouldAddAnchorNameInDecoration = !isCSSAttrAnchorSupported() && isCSSAnchorSupported() && fg('platform_editor_table_sticky_header_patch_8');
52
52
  var attributes = {
53
53
  'data-node-anchor': anchorName,
54
- 'style': "anchor-name: ".concat(anchorName, ";")
54
+ style: "anchor-name: ".concat(anchorName, ";")
55
55
  };
56
56
  decs.push(Decoration.node(pos, pos + node.nodeSize, shouldAddAnchorNameInDecoration ? attributes : {
57
57
  'data-node-anchor': anchorName
@@ -8,7 +8,6 @@ import { Slice, Fragment } from '@atlaskit/editor-prosemirror/model';
8
8
  import { flatten, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
9
9
  import { CellSelection } from '@atlaskit/editor-tables';
10
10
  import { fg } from '@atlaskit/platform-feature-flags';
11
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
12
11
  import { getPluginState } from '../plugin-factory';
13
12
 
14
13
  // lifts up the content of each cell, returning an array of nodes
@@ -68,17 +67,16 @@ export var removeTableFromLastChild = function removeTableFromLastChild(node, i,
68
67
  return i === fragment.childCount - 1 ? unwrapContentFromTable(node) : node;
69
68
  };
70
69
  export var transformSliceToRemoveNestedTables = function transformSliceToRemoveNestedTables(slice, schema, selection) {
71
- var isNestingAllowed = editorExperiment('nested-tables-in-tables', true);
72
70
  var _schema$nodes2 = schema.nodes,
73
71
  table = _schema$nodes2.table,
74
72
  tableCell = _schema$nodes2.tableCell,
75
73
  tableHeader = _schema$nodes2.tableHeader;
76
74
  var openEnd = slice.openEnd;
77
75
  var newFragment = flatmap(slice.content, function (node, i, fragment) {
78
- var _slice$content$firstC;
79
- // if pasted content is a node that supports nesting a table
80
- // such as layoutSection or expand allow 1 level by default
81
- var allowedTableNesting = 1;
76
+ var _slice$content$firstC, _slice$content$lastCh;
77
+ // We allow default nesting of 2 to support
78
+ // two levels of nesting in nodes that support table nesting already such as layoutSection and expands
79
+ var allowedTableNesting = 2;
82
80
  var isCellSelection = selection instanceof CellSelection;
83
81
  var isPasteInTable = hasParentNodeOfType([table, tableCell, tableHeader])(selection);
84
82
  var isPasteInNestedTable = getParentOfTypeCount(schema.nodes.table)(selection.$from) > 1;
@@ -86,55 +84,42 @@ export var transformSliceToRemoveNestedTables = function transformSliceToRemoveN
86
84
 
87
85
  // Pasted content only contains a table and no other content
88
86
  var isCellPaste = isPasteInTable && slice.content.childCount === 1 && ((_slice$content$firstC = slice.content.firstChild) === null || _slice$content$firstC === void 0 ? void 0 : _slice$content$firstC.type) === table && (!isPasteFullTableInsideEmptyCellEnabled || slice.openStart !== 0 && slice.openEnd !== 0);
89
- if (isNestingAllowed) {
90
- var _slice$content$lastCh;
91
- // if nesting is allowed we bump up the default nesting allowance to 2 to support
92
- // two levels of nesting in nodes that support table nesting already such as layoutSection and expands
93
- allowedTableNesting = 2;
94
87
 
95
- // however if pasted content is a table, allow just one level
96
- if (node.type === schema.nodes.table) {
97
- allowedTableNesting = 1;
98
-
99
- // if paste is inside a table, allow no further nesting
100
- if (isPasteInTable) {
101
- allowedTableNesting = 0;
102
- }
103
-
104
- // unless we are pasting inside a nested table, then bounce back to 1 level
105
- // because editor-plugin-paste will lift the table to the parent table (just below it)
106
- if (isPasteInNestedTable) {
107
- allowedTableNesting = 1;
108
- }
88
+ // however if pasted content is a table, allow just one level
89
+ if (node.type === schema.nodes.table) {
90
+ allowedTableNesting = 1;
109
91
 
110
- // paste of table cells into a table cell - content is spread across multiple cells
111
- // by editor-tables so needs to be treated a little differently
112
- if (isCellPaste || isCellSelection) {
113
- allowedTableNesting = 1;
114
- if (isPasteInNestedTable) {
115
- allowedTableNesting = 0;
116
- }
117
- }
92
+ // if paste is inside a table, allow no further nesting
93
+ if (isPasteInTable) {
94
+ allowedTableNesting = 0;
118
95
  }
119
96
 
120
- // Prevent invalid openEnd after pasting tables with a selection that ends inside a nested table cell.
121
- // If the slice ends with a selection that ends inside a nested table, and we paste inside a table we
122
- // need to adjust the openEnd because it is no longer correct. If we don't, Prosemirror fires an exception
123
- // because it iterates to a non-existent depth and the transform will not be applied
124
- if (slice.openEnd >= 7 &&
125
- // depth of a nested table cell
126
- slice.content.childCount > 1 && ((_slice$content$lastCh = slice.content.lastChild) === null || _slice$content$lastCh === void 0 ? void 0 : _slice$content$lastCh.type) === table && isPasteInTable) {
127
- // re-point the slice's openEnd to non-nested table cell depth
128
- openEnd = 4;
97
+ // unless we are pasting inside a nested table, then bounce back to 1 level
98
+ // because editor-plugin-paste will lift the table to the parent table (just below it)
99
+ if (isPasteInNestedTable) {
100
+ allowedTableNesting = 1;
129
101
  }
130
- } else {
131
- // for layouts and expands, we start with 1 level of nesting as set above
132
102
 
133
- // if pasted content is a table, don't allow further nesting
134
- if (node.type === schema.nodes.table) {
135
- allowedTableNesting = 0;
103
+ // paste of table cells into a table cell - content is spread across multiple cells
104
+ // by editor-tables so needs to be treated a little differently
105
+ if (isCellPaste || isCellSelection) {
106
+ allowedTableNesting = 1;
107
+ if (isPasteInNestedTable) {
108
+ allowedTableNesting = 0;
109
+ }
136
110
  }
137
111
  }
112
+
113
+ // Prevent invalid openEnd after pasting tables with a selection that ends inside a nested table cell.
114
+ // If the slice ends with a selection that ends inside a nested table, and we paste inside a table we
115
+ // need to adjust the openEnd because it is no longer correct. If we don't, Prosemirror fires an exception
116
+ // because it iterates to a non-existent depth and the transform will not be applied
117
+ if (slice.openEnd >= 7 &&
118
+ // depth of a nested table cell
119
+ slice.content.childCount > 1 && ((_slice$content$lastCh = slice.content.lastChild) === null || _slice$content$lastCh === void 0 ? void 0 : _slice$content$lastCh.type) === table && isPasteInTable) {
120
+ // re-point the slice's openEnd to non-nested table cell depth
121
+ openEnd = 4;
122
+ }
138
123
  if (isCellSelection && !isCellPaste) {
139
124
  // if pasting into a cell selection, we need to flatten the parent table as well
140
125
  return _unwrapNestedTables(Fragment.fromArray([node]), schema, allowedTableNesting);
@@ -565,10 +565,8 @@ var tablePlugin = function tablePlugin(_ref) {
565
565
  var tr = state.tr;
566
566
  // If the cursor is inside a table
567
567
  if (hasParentNodeOfType(state.schema.nodes.table)(state.selection) && options !== null && options !== void 0 && (_options$tableOptions6 = options.tableOptions) !== null && _options$tableOptions6 !== void 0 && _options$tableOptions6.allowNestedTables) {
568
- // If the experiment is disabled, or we're trying to nest deeper than one level, we insert the table after the top table
569
- if (editorExperiment('nested-tables-in-tables', false, {
570
- exposure: true
571
- }) || getParentOfTypeCount(state.schema.nodes.table)(state.selection.$from) > 1) {
568
+ // If trying to nest deeper than one level, we insert the table after the top table
569
+ if (getParentOfTypeCount(state.schema.nodes.table)(state.selection.$from) > 1) {
572
570
  // Nesting is too deep insert table after the top parent table
573
571
  var positionAfterTopTable = getPositionAfterTopParentNodeOfType(state.schema.nodes.table)(state.selection.$from);
574
572
  tr = safeInsert(tableNode, positionAfterTopTable)(tr);
@@ -82,9 +82,8 @@ var RowControlsComponent = /*#__PURE__*/function (_Component) {
82
82
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
83
83
  top: thisRowSticky ? "3px" : undefined,
84
84
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
85
- paddingTop: thisRowSticky
86
- // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
87
- ? "".concat(tableControlsSpacing - 2, "px") : undefined
85
+ paddingTop: thisRowSticky ? // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
86
+ "".concat(tableControlsSpacing - 2, "px") : undefined
88
87
  }
89
88
  }, /*#__PURE__*/React.createElement("button", {
90
89
  "aria-label": formatMessage(messages.rowControl),
@@ -27,7 +27,7 @@ export interface TablePluginOptions {
27
27
  * @deprecated {@link https://hello.atlassian.net/browse/ENGHEALTH-49683 Internal documentation for deprecation (no external access)}
28
28
  * Deprecating this prop to enable drag and drop in tables by default.
29
29
  * See {@link https://hello.atlassian.net/wiki/spaces/EDITOR/pages/6312469305/Deprecating+legacy+table+controls} for rollout plan
30
- **/
30
+ **/
31
31
  dragAndDropEnabled?: boolean;
32
32
  fullWidthEnabled?: boolean;
33
33
  getEditorFeatureFlags?: GetEditorFeatureFlags;
@@ -37,7 +37,7 @@ export interface TablePluginOptions {
37
37
  * @deprecated {@link https://hello.atlassian.net/browse/ENGHEALTH-49683 Internal documentation for deprecation (no external access)}
38
38
  * Deprecating this prop to enable table scaling by default
39
39
  * See {@link https://hello.atlassian.net/wiki/spaces/EDITOR/pages/6312469305/Deprecating+legacy+table+controls} for rollout plan
40
- **/
40
+ **/
41
41
  isTableScalingEnabled?: boolean;
42
42
  maxWidthEnabled?: boolean;
43
43
  tableOptions: PluginConfig;
@@ -27,7 +27,7 @@ export interface TablePluginOptions {
27
27
  * @deprecated {@link https://hello.atlassian.net/browse/ENGHEALTH-49683 Internal documentation for deprecation (no external access)}
28
28
  * Deprecating this prop to enable drag and drop in tables by default.
29
29
  * See {@link https://hello.atlassian.net/wiki/spaces/EDITOR/pages/6312469305/Deprecating+legacy+table+controls} for rollout plan
30
- **/
30
+ **/
31
31
  dragAndDropEnabled?: boolean;
32
32
  fullWidthEnabled?: boolean;
33
33
  getEditorFeatureFlags?: GetEditorFeatureFlags;
@@ -37,7 +37,7 @@ export interface TablePluginOptions {
37
37
  * @deprecated {@link https://hello.atlassian.net/browse/ENGHEALTH-49683 Internal documentation for deprecation (no external access)}
38
38
  * Deprecating this prop to enable table scaling by default
39
39
  * See {@link https://hello.atlassian.net/wiki/spaces/EDITOR/pages/6312469305/Deprecating+legacy+table+controls} for rollout plan
40
- **/
40
+ **/
41
41
  isTableScalingEnabled?: boolean;
42
42
  maxWidthEnabled?: boolean;
43
43
  tableOptions: PluginConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "17.3.21",
3
+ "version": "17.3.23",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -37,7 +37,7 @@
37
37
  "@atlaskit/editor-plugin-batch-attribute-updates": "^7.0.0",
38
38
  "@atlaskit/editor-plugin-content-insertion": "^7.0.0",
39
39
  "@atlaskit/editor-plugin-editor-viewmode": "^9.0.0",
40
- "@atlaskit/editor-plugin-extension": "10.1.3",
40
+ "@atlaskit/editor-plugin-extension": "10.1.5",
41
41
  "@atlaskit/editor-plugin-guideline": "^7.0.0",
42
42
  "@atlaskit/editor-plugin-interaction": "^14.0.0",
43
43
  "@atlaskit/editor-plugin-limited-mode": "^4.0.0",
@@ -57,7 +57,7 @@
57
57
  "@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.1.0",
58
58
  "@atlaskit/primitives": "^18.0.0",
59
59
  "@atlaskit/theme": "^21.0.0",
60
- "@atlaskit/tmp-editor-statsig": "^27.1.0",
60
+ "@atlaskit/tmp-editor-statsig": "^29.0.0",
61
61
  "@atlaskit/toggle": "^15.2.0",
62
62
  "@atlaskit/tokens": "^11.0.0",
63
63
  "@atlaskit/tooltip": "^20.14.0",