@atlaskit/editor-plugin-table 15.3.11 → 15.3.13

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,22 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 15.3.13
4
+
5
+ ### Patch Changes
6
+
7
+ - [`ca454ed251e1e`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ca454ed251e1e) -
8
+ Add table height analytics
9
+ - Updated dependencies
10
+
11
+ ## 15.3.12
12
+
13
+ ### Patch Changes
14
+
15
+ - [`c094becfaeeaa`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/c094becfaeeaa) -
16
+ EDITOR-2476 Introduce new utility method to check if nested tables is supported in the schema to
17
+ facilitate removal of gate `platform_editor_use_nested_table_pm_nodes`
18
+ - Updated dependencies
19
+
3
20
  ## 15.3.11
4
21
 
5
22
  ### Patch Changes
@@ -234,16 +234,16 @@ var insertTableWithSize = exports.insertTableWithSize = function insertTableWith
234
234
  /**
235
235
  * Unified command to insert a new table into the editor.
236
236
  *
237
- * @param {Object} options - Configuration options for table insertion.
237
+ * @param {object} options - Configuration options for table insertion.
238
238
  * @param {boolean} [options.isTableScalingEnabled=false] - Flag to enable table scaling.
239
239
  * @param {boolean} [options.isTableAlignmentEnabled=false] - Flag to enable table alignment.
240
240
  * @param {boolean} [options.isFullWidthModeEnabled=false] - Flag to enable full-width mode for the table.
241
241
  * @param {boolean} [options.isCommentEditor=false] - Flag to indicate if the editor is in comment mode.
242
242
  * @param {boolean} [options.isChromelessEditor=false] - Flag to indicate if the editor is chromeless.
243
243
  * @param {boolean} [options.isTableResizingEnabled=false] - Flag to enable table resizing.
244
- * @param {Object} [options.createTableProps={}] - Additional properties for table creation, including table size.
245
- * @param {Object} api - PluginInjectinoApi object for content insertion commands.
246
- * @param {Object} analyticsPayload - Payload for analytics tracking.
244
+ * @param {object} [options.createTableProps={}] - Additional properties for table creation, including table size.
245
+ * @param {object} api - PluginInjectinoApi object for content insertion commands.
246
+ * @param {object} analyticsPayload - Payload for analytics tracking.
247
247
  *
248
248
  * @returns {Function} A function that takes a transaction and inserts a table.
249
249
  */
@@ -270,7 +270,7 @@ var insertTableWithNestingSupport = exports.insertTableWithNestingSupport = func
270
270
  // If the cursor is inside a table
271
271
  var insertAt;
272
272
  var isNestedTable = false;
273
- if ((0, _utils.hasParentNodeOfType)(schema.nodes.table)(tr.selection) && (0, _platformFeatureFlags.fg)('platform_editor_use_nested_table_pm_nodes')) {
273
+ if ((0, _utils.hasParentNodeOfType)(schema.nodes.table)(tr.selection) && (0, _nesting.isNestedTablesSupported)(schema) && (0, _platformFeatureFlags.fg)('platform_editor_use_nested_table_pm_nodes')) {
274
274
  // If the experiment is disabled, or we're trying to nest deeper than one level, we insert the table after the top table
275
275
  if ((0, _experiments.editorExperiment)('nested-tables-in-tables', false, {
276
276
  exposure: true
@@ -9,6 +9,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
9
9
  var _analytics = require("@atlaskit/editor-common/analytics");
10
10
  var _browser = require("@atlaskit/editor-common/browser");
11
11
  var _coreUtils = require("@atlaskit/editor-common/core-utils");
12
+ var _nesting = require("@atlaskit/editor-common/nesting");
12
13
  var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
13
14
  var _transforms = require("@atlaskit/editor-common/transforms");
14
15
  var _utils = require("@atlaskit/editor-common/utils");
@@ -245,7 +246,7 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatchAnalytic
245
246
  slice = (0, _misc.transformSliceToFixDarkModeDefaultBackgroundColor)(slice, schema);
246
247
  }
247
248
  slice = (0, _transforms.transformSliceToRemoveOpenNestedExpand)(slice, schema);
248
- if ((0, _platformFeatureFlags.fg)('platform_editor_use_nested_table_pm_nodes')) {
249
+ if ((0, _nesting.isNestedTablesSupported)(schema) && (0, _platformFeatureFlags.fg)('platform_editor_use_nested_table_pm_nodes')) {
249
250
  slice = (0, _paste.transformSliceToRemoveNestedTables)(slice, schema, editorState.selection);
250
251
  }
251
252
  return slice;
@@ -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.generateResizedPayload = exports.generateResizeFrameRatePayloads = void 0;
7
+ exports.getHeightInfoPayload = exports.generateResizedPayload = exports.generateResizeFrameRatePayloads = void 0;
8
8
  exports.getSelectedCellInfo = getSelectedCellInfo;
9
9
  exports.getSelectedTableInfo = getSelectedTableInfo;
10
10
  exports.withEditorAnalyticsAPI = exports.useMeasureFramerate = exports.reduceResizeFrameRateSamples = exports.getWidthInfoPayload = void 0;
@@ -256,4 +256,51 @@ var getWidthInfoPayload = exports.getWidthInfoPayload = function getWidthInfoPay
256
256
  },
257
257
  eventType: _analytics.EVENT_TYPE.OPERATIONAL
258
258
  };
259
+ };
260
+ var getHeightInfoPayload = exports.getHeightInfoPayload = function getHeightInfoPayload(editorView) {
261
+ var tablesInfo = [];
262
+ var editorPopupScrollParent = editorView.dom.closest('.fabric-editor-popup-scroll-parent');
263
+
264
+ // don't send the event if the editor scroll parent is not available
265
+ if (!editorPopupScrollParent) {
266
+ return undefined;
267
+ }
268
+ var editorScrollParentClientHeight = editorPopupScrollParent.clientHeight;
269
+ var isEditorScrollable = editorPopupScrollParent.scrollHeight > editorScrollParentClientHeight;
270
+ editorView.state.doc.nodesBetween(0, editorView.state.doc.content.size, function (node, pos, parent) {
271
+ if (!tableContainerNodes.has(node.type.name)) {
272
+ return false;
273
+ }
274
+ if (node.type.name === 'table') {
275
+ var _domAtPos$node2;
276
+ var domAtPos = editorView.domAtPos(pos + 1);
277
+ var table = (_domAtPos$node2 = domAtPos.node) === null || _domAtPos$node2 === void 0 ? void 0 : _domAtPos$node2.parentElement;
278
+ var isNestedTable = (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'tableCell' || (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'tableHeader';
279
+ if (table instanceof HTMLTableElement) {
280
+ tablesInfo.push({
281
+ isNestedTable: isNestedTable,
282
+ tableHeight: table.scrollHeight
283
+ });
284
+ }
285
+ }
286
+ });
287
+
288
+ // only send the event if there are tables on the page
289
+ if (tablesInfo.length === 0) {
290
+ return undefined;
291
+ }
292
+ var maxTableHeight = Math.max.apply(Math, (0, _toConsumableArray2.default)(tablesInfo.map(function (table) {
293
+ return table.tableHeight;
294
+ })));
295
+ return {
296
+ action: _analytics.TABLE_ACTION.TABLE_EDITOR_HEIGHT_INFO,
297
+ actionSubject: _analytics.ACTION_SUBJECT.TABLE,
298
+ attributes: {
299
+ editorScrollParentClientHeight: editorScrollParentClientHeight,
300
+ isEditorScrollable: isEditorScrollable,
301
+ maxTableToEditorHeightRatio: maxTableHeight / editorScrollParentClientHeight,
302
+ tableHeightInfo: tablesInfo
303
+ },
304
+ eventType: _analytics.EVENT_TYPE.OPERATIONAL
305
+ };
259
306
  };
@@ -15,6 +15,8 @@ var _tableMap = require("@atlaskit/editor-tables/table-map");
15
15
  var _utils2 = require("@atlaskit/editor-tables/utils");
16
16
  var _types = require("../../types");
17
17
  var _ColumnResizeWidget = require("../../ui/ColumnResizeWidget");
18
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
19
+
18
20
  // @ts-ignore -- ReadonlyTransaction is a local declaration and will cause a TS2305 error in CCFE typecheck
19
21
 
20
22
  var filterDecorationByKey = function filterDecorationByKey(key, decorationSet) {
@@ -268,6 +270,7 @@ var createResizeHandleDecoration = exports.createResizeHandleDecoration = functi
268
270
  return emptyResult;
269
271
  }
270
272
  var createResizerHandleDecoration = function createResizerHandleDecoration(cellColumnPositioning, columnIndex, rowIndex, cellPos, cellNode) {
273
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
271
274
  var decorationRenderKey = (0, _v.default)();
272
275
  var position = cellPos + cellNode.nodeSize - 1;
273
276
  return _view.Decoration.widget(position, function () {
@@ -28,7 +28,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
28
28
  * This plugin allows sorting of table nodes in the Editor without modifying the underlying ProseMirror document.
29
29
  * Instead of making changes to the ProseMirror document, the plugin sorts the table rows in the DOM. This allows the sorting to be
30
30
  * visible to the user without affecting the document's content.
31
- */
31
+ */ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
32
32
  var createPlugin = exports.createPlugin = function createPlugin(api, nodeViewPortalProviderAPI) {
33
33
  return new _safePlugin.SafePlugin({
34
34
  state: {
@@ -111,6 +111,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api, nodeViewPor
111
111
  var map = _tableMap.TableMap.get(tableNode);
112
112
  var hasMergedCells = new Set(map.map).size !== map.map.length;
113
113
  map.mapByRow[0].forEach(function (cell, index) {
114
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
114
115
  var decorationRenderKey = (0, _v.default)();
115
116
  decs.push(_view.Decoration.widget(cell + pos + 2, function () {
116
117
  var _sort$tableId;
@@ -430,10 +430,18 @@ var tablePlugin = function tablePlugin(_ref) {
430
430
  var requestIdleCallbackFn = function requestIdleCallbackFn() {
431
431
  var _api$width$sharedStat2;
432
432
  var editorWidth = api === null || api === void 0 || (_api$width$sharedStat2 = api.width.sharedState.currentState()) === null || _api$width$sharedStat2 === void 0 ? void 0 : _api$width$sharedStat2.width;
433
- if (editorWidth && editorViewRef.current) {
434
- var payload = (0, _analytics2.getWidthInfoPayload)(editorViewRef.current, editorWidth);
435
- if (payload) {
436
- dispatchAnalyticsEvent(payload);
433
+ if (editorViewRef.current) {
434
+ if (editorWidth) {
435
+ var payload = (0, _analytics2.getWidthInfoPayload)(editorViewRef.current, editorWidth);
436
+ if (payload) {
437
+ dispatchAnalyticsEvent(payload);
438
+ }
439
+ }
440
+ if ((0, _platformFeatureFlags.fg)('platform_editor_table_height_analytics_event')) {
441
+ var payloadHeight = (0, _analytics2.getHeightInfoPayload)(editorViewRef.current);
442
+ if (payloadHeight) {
443
+ dispatchAnalyticsEvent(payloadHeight);
444
+ }
437
445
  }
438
446
  }
439
447
  };
@@ -488,7 +488,7 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(getE
488
488
  onBlur: (0, _commands.clearHoverSelection)()
489
489
  }]
490
490
  };
491
- var isNestedTable = (0, _platformFeatureFlags.fg)('platform_editor_use_nested_table_pm_nodes') && (0, _nesting.isSelectionTableNestedInTable)(state);
491
+ var isNestedTable = (0, _nesting.isNestedTablesSupported)(state.schema) && (0, _platformFeatureFlags.fg)('platform_editor_use_nested_table_pm_nodes') && (0, _nesting.isSelectionTableNestedInTable)(state);
492
492
  var hoverTableProps = function hoverTableProps(isInDanger, isSelected) {
493
493
  return {
494
494
  onMouseEnter: (0, _commands.hoverTable)(isInDanger, isSelected),
@@ -1,7 +1,7 @@
1
1
  // #region Imports
2
2
  import { AddColumnStep } from '@atlaskit/custom-steps';
3
3
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
4
- import { getParentOfTypeCount, getPositionAfterTopParentNodeOfType } from '@atlaskit/editor-common/nesting';
4
+ import { getParentOfTypeCount, getPositionAfterTopParentNodeOfType, isNestedTablesSupported } from '@atlaskit/editor-common/nesting';
5
5
  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';
@@ -198,16 +198,16 @@ export const insertTableWithSize = (isFullWidthModeEnabled, isTableScalingEnable
198
198
  /**
199
199
  * Unified command to insert a new table into the editor.
200
200
  *
201
- * @param {Object} options - Configuration options for table insertion.
201
+ * @param {object} options - Configuration options for table insertion.
202
202
  * @param {boolean} [options.isTableScalingEnabled=false] - Flag to enable table scaling.
203
203
  * @param {boolean} [options.isTableAlignmentEnabled=false] - Flag to enable table alignment.
204
204
  * @param {boolean} [options.isFullWidthModeEnabled=false] - Flag to enable full-width mode for the table.
205
205
  * @param {boolean} [options.isCommentEditor=false] - Flag to indicate if the editor is in comment mode.
206
206
  * @param {boolean} [options.isChromelessEditor=false] - Flag to indicate if the editor is chromeless.
207
207
  * @param {boolean} [options.isTableResizingEnabled=false] - Flag to enable table resizing.
208
- * @param {Object} [options.createTableProps={}] - Additional properties for table creation, including table size.
209
- * @param {Object} api - PluginInjectinoApi object for content insertion commands.
210
- * @param {Object} analyticsPayload - Payload for analytics tracking.
208
+ * @param {object} [options.createTableProps={}] - Additional properties for table creation, including table size.
209
+ * @param {object} api - PluginInjectinoApi object for content insertion commands.
210
+ * @param {object} analyticsPayload - Payload for analytics tracking.
211
211
  *
212
212
  * @returns {Function} A function that takes a transaction and inserts a table.
213
213
  */
@@ -230,7 +230,7 @@ export const insertTableWithNestingSupport = ({
230
230
  // If the cursor is inside a table
231
231
  let insertAt;
232
232
  let isNestedTable = false;
233
- if (hasParentNodeOfType(schema.nodes.table)(tr.selection) && fg('platform_editor_use_nested_table_pm_nodes')) {
233
+ if (hasParentNodeOfType(schema.nodes.table)(tr.selection) && isNestedTablesSupported(schema) && fg('platform_editor_use_nested_table_pm_nodes')) {
234
234
  // If the experiment is disabled, or we're trying to nest deeper than one level, we insert the table after the top table
235
235
  if (editorExperiment('nested-tables-in-tables', false, {
236
236
  exposure: true
@@ -1,6 +1,7 @@
1
1
  import { ACTION, ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
2
  import { browser as browserLegacy, getBrowserInfo } from '@atlaskit/editor-common/browser';
3
3
  import { insideTable } from '@atlaskit/editor-common/core-utils';
4
+ import { isNestedTablesSupported } from '@atlaskit/editor-common/nesting';
4
5
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
5
6
  import { transformSliceToRemoveOpenBodiedExtension, transformSliceToRemoveOpenExpand, transformSliceToRemoveOpenLayoutNodes, transformSliceToRemoveOpenMultiBodiedExtension, transformSliceToRemoveOpenNestedExpand } from '@atlaskit/editor-common/transforms';
6
7
  import { closestElement } from '@atlaskit/editor-common/utils';
@@ -237,7 +238,7 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
237
238
  slice = transformSliceToFixDarkModeDefaultBackgroundColor(slice, schema);
238
239
  }
239
240
  slice = transformSliceToRemoveOpenNestedExpand(slice, schema);
240
- if (fg('platform_editor_use_nested_table_pm_nodes')) {
241
+ if (isNestedTablesSupported(schema) && fg('platform_editor_use_nested_table_pm_nodes')) {
241
242
  slice = transformSliceToRemoveNestedTables(slice, schema, editorState.selection);
242
243
  }
243
244
  return slice;
@@ -227,4 +227,49 @@ export const getWidthInfoPayload = (editorView, editorWidth) => {
227
227
  },
228
228
  eventType: EVENT_TYPE.OPERATIONAL
229
229
  };
230
+ };
231
+ export const getHeightInfoPayload = editorView => {
232
+ const tablesInfo = [];
233
+ const editorPopupScrollParent = editorView.dom.closest('.fabric-editor-popup-scroll-parent');
234
+
235
+ // don't send the event if the editor scroll parent is not available
236
+ if (!editorPopupScrollParent) {
237
+ return undefined;
238
+ }
239
+ const editorScrollParentClientHeight = editorPopupScrollParent.clientHeight;
240
+ const isEditorScrollable = editorPopupScrollParent.scrollHeight > editorScrollParentClientHeight;
241
+ editorView.state.doc.nodesBetween(0, editorView.state.doc.content.size, (node, pos, parent) => {
242
+ if (!tableContainerNodes.has(node.type.name)) {
243
+ return false;
244
+ }
245
+ if (node.type.name === 'table') {
246
+ var _domAtPos$node2;
247
+ const domAtPos = editorView.domAtPos(pos + 1);
248
+ const table = (_domAtPos$node2 = domAtPos.node) === null || _domAtPos$node2 === void 0 ? void 0 : _domAtPos$node2.parentElement;
249
+ const isNestedTable = (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'tableCell' || (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'tableHeader';
250
+ if (table instanceof HTMLTableElement) {
251
+ tablesInfo.push({
252
+ isNestedTable: isNestedTable,
253
+ tableHeight: table.scrollHeight
254
+ });
255
+ }
256
+ }
257
+ });
258
+
259
+ // only send the event if there are tables on the page
260
+ if (tablesInfo.length === 0) {
261
+ return undefined;
262
+ }
263
+ const maxTableHeight = Math.max(...tablesInfo.map(table => table.tableHeight));
264
+ return {
265
+ action: TABLE_ACTION.TABLE_EDITOR_HEIGHT_INFO,
266
+ actionSubject: ACTION_SUBJECT.TABLE,
267
+ attributes: {
268
+ editorScrollParentClientHeight,
269
+ isEditorScrollable,
270
+ maxTableToEditorHeightRatio: maxTableHeight / editorScrollParentClientHeight,
271
+ tableHeightInfo: tablesInfo
272
+ },
273
+ eventType: EVENT_TYPE.OPERATIONAL
274
+ };
230
275
  };
@@ -1,5 +1,6 @@
1
1
  import { createElement } from 'react';
2
2
  import { RawIntlProvider } from 'react-intl-next';
3
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
3
4
  import uuid from 'uuid/v4';
4
5
  import { nonNullable } from '@atlaskit/editor-common/utils';
5
6
 
@@ -238,6 +239,7 @@ export const createResizeHandleDecoration = (tr, rowIndexTarget, columnEndIndexT
238
239
  return emptyResult;
239
240
  }
240
241
  const createResizerHandleDecoration = (cellColumnPositioning, columnIndex, rowIndex, cellPos, cellNode) => {
242
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
241
243
  const decorationRenderKey = uuid();
242
244
  const position = cellPos + cellNode.nodeSize - 1;
243
245
  return Decoration.widget(position, () => {
@@ -6,6 +6,7 @@
6
6
 
7
7
  import { createElement } from 'react';
8
8
  import { RawIntlProvider } from 'react-intl-next';
9
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
9
10
  import uuid from 'uuid/v4';
10
11
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
11
12
  import { SortOrder } from '@atlaskit/editor-common/types';
@@ -84,6 +85,7 @@ export const createPlugin = (api, nodeViewPortalProviderAPI) => {
84
85
  const map = TableMap.get(tableNode);
85
86
  const hasMergedCells = new Set(map.map).size !== map.map.length;
86
87
  map.mapByRow[0].forEach((cell, index) => {
88
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
87
89
  const decorationRenderKey = uuid();
88
90
  decs.push(Decoration.widget(cell + pos + 2, () => {
89
91
  var _sort$tableId;
@@ -36,7 +36,7 @@ import { tableSelectionKeymapPlugin } from './pm-plugins/table-selection-keymap'
36
36
  import { createPlugin as createSizeSelectorPlugin, pluginKey as sizeSelectorPluginKey } from './pm-plugins/table-size-selector';
37
37
  import { createPlugin as createTableWidthPlugin, pluginKey as tableWidthPluginKey } from './pm-plugins/table-width';
38
38
  import { createPlugin as createTableWidthInCommentFixPlugin } from './pm-plugins/table-width-in-comment-fix';
39
- import { getWidthInfoPayload } from './pm-plugins/utils/analytics';
39
+ import { getHeightInfoPayload, getWidthInfoPayload } from './pm-plugins/utils/analytics';
40
40
  import { createTableWithWidth } from './pm-plugins/utils/create';
41
41
  import { createPlugin as createViewModeSortPlugin } from './pm-plugins/view-mode-sort';
42
42
  import { ContentComponent } from './ui/ContentComponent';
@@ -419,10 +419,18 @@ const tablePlugin = ({
419
419
  const requestIdleCallbackFn = () => {
420
420
  var _api$width$sharedStat2;
421
421
  const editorWidth = api === null || api === void 0 ? void 0 : (_api$width$sharedStat2 = api.width.sharedState.currentState()) === null || _api$width$sharedStat2 === void 0 ? void 0 : _api$width$sharedStat2.width;
422
- if (editorWidth && editorViewRef.current) {
423
- const payload = getWidthInfoPayload(editorViewRef.current, editorWidth);
424
- if (payload) {
425
- dispatchAnalyticsEvent(payload);
422
+ if (editorViewRef.current) {
423
+ if (editorWidth) {
424
+ const payload = getWidthInfoPayload(editorViewRef.current, editorWidth);
425
+ if (payload) {
426
+ dispatchAnalyticsEvent(payload);
427
+ }
428
+ }
429
+ if (fg('platform_editor_table_height_analytics_event')) {
430
+ const payloadHeight = getHeightInfoPayload(editorViewRef.current);
431
+ if (payloadHeight) {
432
+ dispatchAnalyticsEvent(payloadHeight);
433
+ }
426
434
  }
427
435
  }
428
436
  };
@@ -10,7 +10,7 @@ import { CHANGE_ALIGNMENT_REASON, INPUT_METHOD } from '@atlaskit/editor-common/a
10
10
  import { DropdownMenuExtensionItems } from '@atlaskit/editor-common/floating-toolbar';
11
11
  import { addColumnAfter, addRowAfter, backspace, tooltip } from '@atlaskit/editor-common/keymaps';
12
12
  import commonMessages, { tableMessages as messages } from '@atlaskit/editor-common/messages';
13
- import { isSelectionTableNestedInTable } from '@atlaskit/editor-common/nesting';
13
+ import { isNestedTablesSupported, isSelectionTableNestedInTable } from '@atlaskit/editor-common/nesting';
14
14
  import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
15
15
  import { areToolbarFlagsEnabled } from '@atlaskit/editor-common/toolbar-flag-check';
16
16
  import { DEFAULT_BORDER_COLOR, cellBackgroundColorPalette } from '@atlaskit/editor-common/ui-color';
@@ -460,7 +460,7 @@ export const getToolbarConfig = (getEditorContainerWidth, api, editorAnalyticsAP
460
460
  onBlur: clearHoverSelection()
461
461
  }]
462
462
  };
463
- const isNestedTable = fg('platform_editor_use_nested_table_pm_nodes') && isSelectionTableNestedInTable(state);
463
+ const isNestedTable = isNestedTablesSupported(state.schema) && fg('platform_editor_use_nested_table_pm_nodes') && isSelectionTableNestedInTable(state);
464
464
  const hoverTableProps = (isInDanger, isSelected) => ({
465
465
  onMouseEnter: hoverTable(isInDanger, isSelected),
466
466
  onMouseLeave: clearHoverSelection(),
@@ -4,7 +4,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
4
4
  // #region Imports
5
5
  import { AddColumnStep } from '@atlaskit/custom-steps';
6
6
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
7
- import { getParentOfTypeCount, getPositionAfterTopParentNodeOfType } from '@atlaskit/editor-common/nesting';
7
+ import { getParentOfTypeCount, getPositionAfterTopParentNodeOfType, isNestedTablesSupported } from '@atlaskit/editor-common/nesting';
8
8
  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';
@@ -226,16 +226,16 @@ export var insertTableWithSize = function insertTableWithSize(isFullWidthModeEna
226
226
  /**
227
227
  * Unified command to insert a new table into the editor.
228
228
  *
229
- * @param {Object} options - Configuration options for table insertion.
229
+ * @param {object} options - Configuration options for table insertion.
230
230
  * @param {boolean} [options.isTableScalingEnabled=false] - Flag to enable table scaling.
231
231
  * @param {boolean} [options.isTableAlignmentEnabled=false] - Flag to enable table alignment.
232
232
  * @param {boolean} [options.isFullWidthModeEnabled=false] - Flag to enable full-width mode for the table.
233
233
  * @param {boolean} [options.isCommentEditor=false] - Flag to indicate if the editor is in comment mode.
234
234
  * @param {boolean} [options.isChromelessEditor=false] - Flag to indicate if the editor is chromeless.
235
235
  * @param {boolean} [options.isTableResizingEnabled=false] - Flag to enable table resizing.
236
- * @param {Object} [options.createTableProps={}] - Additional properties for table creation, including table size.
237
- * @param {Object} api - PluginInjectinoApi object for content insertion commands.
238
- * @param {Object} analyticsPayload - Payload for analytics tracking.
236
+ * @param {object} [options.createTableProps={}] - Additional properties for table creation, including table size.
237
+ * @param {object} api - PluginInjectinoApi object for content insertion commands.
238
+ * @param {object} analyticsPayload - Payload for analytics tracking.
239
239
  *
240
240
  * @returns {Function} A function that takes a transaction and inserts a table.
241
241
  */
@@ -262,7 +262,7 @@ export var insertTableWithNestingSupport = function insertTableWithNestingSuppor
262
262
  // If the cursor is inside a table
263
263
  var insertAt;
264
264
  var isNestedTable = false;
265
- if (hasParentNodeOfType(schema.nodes.table)(tr.selection) && fg('platform_editor_use_nested_table_pm_nodes')) {
265
+ if (hasParentNodeOfType(schema.nodes.table)(tr.selection) && isNestedTablesSupported(schema) && fg('platform_editor_use_nested_table_pm_nodes')) {
266
266
  // If the experiment is disabled, or we're trying to nest deeper than one level, we insert the table after the top table
267
267
  if (editorExperiment('nested-tables-in-tables', false, {
268
268
  exposure: true
@@ -4,6 +4,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
4
4
  import { ACTION, ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
5
5
  import { browser as browserLegacy, getBrowserInfo } from '@atlaskit/editor-common/browser';
6
6
  import { insideTable } from '@atlaskit/editor-common/core-utils';
7
+ import { isNestedTablesSupported } from '@atlaskit/editor-common/nesting';
7
8
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
8
9
  import { transformSliceToRemoveOpenBodiedExtension, transformSliceToRemoveOpenExpand, transformSliceToRemoveOpenLayoutNodes, transformSliceToRemoveOpenMultiBodiedExtension, transformSliceToRemoveOpenNestedExpand } from '@atlaskit/editor-common/transforms';
9
10
  import { closestElement } from '@atlaskit/editor-common/utils';
@@ -238,7 +239,7 @@ export var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch
238
239
  slice = transformSliceToFixDarkModeDefaultBackgroundColor(slice, schema);
239
240
  }
240
241
  slice = transformSliceToRemoveOpenNestedExpand(slice, schema);
241
- if (fg('platform_editor_use_nested_table_pm_nodes')) {
242
+ if (isNestedTablesSupported(schema) && fg('platform_editor_use_nested_table_pm_nodes')) {
242
243
  slice = transformSliceToRemoveNestedTables(slice, schema, editorState.selection);
243
244
  }
244
245
  return slice;
@@ -246,4 +246,51 @@ export var getWidthInfoPayload = function getWidthInfoPayload(editorView, editor
246
246
  },
247
247
  eventType: EVENT_TYPE.OPERATIONAL
248
248
  };
249
+ };
250
+ export var getHeightInfoPayload = function getHeightInfoPayload(editorView) {
251
+ var tablesInfo = [];
252
+ var editorPopupScrollParent = editorView.dom.closest('.fabric-editor-popup-scroll-parent');
253
+
254
+ // don't send the event if the editor scroll parent is not available
255
+ if (!editorPopupScrollParent) {
256
+ return undefined;
257
+ }
258
+ var editorScrollParentClientHeight = editorPopupScrollParent.clientHeight;
259
+ var isEditorScrollable = editorPopupScrollParent.scrollHeight > editorScrollParentClientHeight;
260
+ editorView.state.doc.nodesBetween(0, editorView.state.doc.content.size, function (node, pos, parent) {
261
+ if (!tableContainerNodes.has(node.type.name)) {
262
+ return false;
263
+ }
264
+ if (node.type.name === 'table') {
265
+ var _domAtPos$node2;
266
+ var domAtPos = editorView.domAtPos(pos + 1);
267
+ var table = (_domAtPos$node2 = domAtPos.node) === null || _domAtPos$node2 === void 0 ? void 0 : _domAtPos$node2.parentElement;
268
+ var isNestedTable = (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'tableCell' || (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'tableHeader';
269
+ if (table instanceof HTMLTableElement) {
270
+ tablesInfo.push({
271
+ isNestedTable: isNestedTable,
272
+ tableHeight: table.scrollHeight
273
+ });
274
+ }
275
+ }
276
+ });
277
+
278
+ // only send the event if there are tables on the page
279
+ if (tablesInfo.length === 0) {
280
+ return undefined;
281
+ }
282
+ var maxTableHeight = Math.max.apply(Math, _toConsumableArray(tablesInfo.map(function (table) {
283
+ return table.tableHeight;
284
+ })));
285
+ return {
286
+ action: TABLE_ACTION.TABLE_EDITOR_HEIGHT_INFO,
287
+ actionSubject: ACTION_SUBJECT.TABLE,
288
+ attributes: {
289
+ editorScrollParentClientHeight: editorScrollParentClientHeight,
290
+ isEditorScrollable: isEditorScrollable,
291
+ maxTableToEditorHeightRatio: maxTableHeight / editorScrollParentClientHeight,
292
+ tableHeightInfo: tablesInfo
293
+ },
294
+ eventType: EVENT_TYPE.OPERATIONAL
295
+ };
249
296
  };
@@ -1,6 +1,7 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
2
  import { createElement } from 'react';
3
3
  import { RawIntlProvider } from 'react-intl-next';
4
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
4
5
  import uuid from 'uuid/v4';
5
6
  import { nonNullable } from '@atlaskit/editor-common/utils';
6
7
 
@@ -262,6 +263,7 @@ export var createResizeHandleDecoration = function createResizeHandleDecoration(
262
263
  return emptyResult;
263
264
  }
264
265
  var createResizerHandleDecoration = function createResizerHandleDecoration(cellColumnPositioning, columnIndex, rowIndex, cellPos, cellNode) {
266
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
265
267
  var decorationRenderKey = uuid();
266
268
  var position = cellPos + cellNode.nodeSize - 1;
267
269
  return Decoration.widget(position, function () {
@@ -14,6 +14,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
14
14
 
15
15
  import { createElement } from 'react';
16
16
  import { RawIntlProvider } from 'react-intl-next';
17
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
17
18
  import uuid from 'uuid/v4';
18
19
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
19
20
  import { SortOrder } from '@atlaskit/editor-common/types';
@@ -106,6 +107,7 @@ export var createPlugin = function createPlugin(api, nodeViewPortalProviderAPI)
106
107
  var map = TableMap.get(tableNode);
107
108
  var hasMergedCells = new Set(map.map).size !== map.map.length;
108
109
  map.mapByRow[0].forEach(function (cell, index) {
110
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
109
111
  var decorationRenderKey = uuid();
110
112
  decs.push(Decoration.widget(cell + pos + 2, function () {
111
113
  var _sort$tableId;
@@ -39,7 +39,7 @@ import { tableSelectionKeymapPlugin } from './pm-plugins/table-selection-keymap'
39
39
  import { createPlugin as createSizeSelectorPlugin, pluginKey as sizeSelectorPluginKey } from './pm-plugins/table-size-selector';
40
40
  import { createPlugin as createTableWidthPlugin, pluginKey as tableWidthPluginKey } from './pm-plugins/table-width';
41
41
  import { createPlugin as createTableWidthInCommentFixPlugin } from './pm-plugins/table-width-in-comment-fix';
42
- import { getWidthInfoPayload } from './pm-plugins/utils/analytics';
42
+ import { getHeightInfoPayload, getWidthInfoPayload } from './pm-plugins/utils/analytics';
43
43
  import { createTableWithWidth } from './pm-plugins/utils/create';
44
44
  import { createPlugin as createViewModeSortPlugin } from './pm-plugins/view-mode-sort';
45
45
  import { ContentComponent } from './ui/ContentComponent';
@@ -421,10 +421,18 @@ var tablePlugin = function tablePlugin(_ref) {
421
421
  var requestIdleCallbackFn = function requestIdleCallbackFn() {
422
422
  var _api$width$sharedStat2;
423
423
  var editorWidth = api === null || api === void 0 || (_api$width$sharedStat2 = api.width.sharedState.currentState()) === null || _api$width$sharedStat2 === void 0 ? void 0 : _api$width$sharedStat2.width;
424
- if (editorWidth && editorViewRef.current) {
425
- var payload = getWidthInfoPayload(editorViewRef.current, editorWidth);
426
- if (payload) {
427
- dispatchAnalyticsEvent(payload);
424
+ if (editorViewRef.current) {
425
+ if (editorWidth) {
426
+ var payload = getWidthInfoPayload(editorViewRef.current, editorWidth);
427
+ if (payload) {
428
+ dispatchAnalyticsEvent(payload);
429
+ }
430
+ }
431
+ if (fg('platform_editor_table_height_analytics_event')) {
432
+ var payloadHeight = getHeightInfoPayload(editorViewRef.current);
433
+ if (payloadHeight) {
434
+ dispatchAnalyticsEvent(payloadHeight);
435
+ }
428
436
  }
429
437
  }
430
438
  };
@@ -14,7 +14,7 @@ import { CHANGE_ALIGNMENT_REASON, INPUT_METHOD } from '@atlaskit/editor-common/a
14
14
  import { DropdownMenuExtensionItems } from '@atlaskit/editor-common/floating-toolbar';
15
15
  import { addColumnAfter, addRowAfter, backspace, tooltip } from '@atlaskit/editor-common/keymaps';
16
16
  import commonMessages, { tableMessages as messages } from '@atlaskit/editor-common/messages';
17
- import { isSelectionTableNestedInTable } from '@atlaskit/editor-common/nesting';
17
+ import { isNestedTablesSupported, isSelectionTableNestedInTable } from '@atlaskit/editor-common/nesting';
18
18
  import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
19
19
  import { areToolbarFlagsEnabled } from '@atlaskit/editor-common/toolbar-flag-check';
20
20
  import { DEFAULT_BORDER_COLOR, cellBackgroundColorPalette } from '@atlaskit/editor-common/ui-color';
@@ -481,7 +481,7 @@ export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth,
481
481
  onBlur: clearHoverSelection()
482
482
  }]
483
483
  };
484
- var isNestedTable = fg('platform_editor_use_nested_table_pm_nodes') && isSelectionTableNestedInTable(state);
484
+ var isNestedTable = isNestedTablesSupported(state.schema) && fg('platform_editor_use_nested_table_pm_nodes') && isSelectionTableNestedInTable(state);
485
485
  var hoverTableProps = function hoverTableProps(isInDanger, isSelected) {
486
486
  return {
487
487
  onMouseEnter: hoverTable(isInDanger, isSelected),
@@ -36,16 +36,16 @@ export declare const insertTableWithSize: (isFullWidthModeEnabled?: boolean, isT
36
36
  /**
37
37
  * Unified command to insert a new table into the editor.
38
38
  *
39
- * @param {Object} options - Configuration options for table insertion.
39
+ * @param {object} options - Configuration options for table insertion.
40
40
  * @param {boolean} [options.isTableScalingEnabled=false] - Flag to enable table scaling.
41
41
  * @param {boolean} [options.isTableAlignmentEnabled=false] - Flag to enable table alignment.
42
42
  * @param {boolean} [options.isFullWidthModeEnabled=false] - Flag to enable full-width mode for the table.
43
43
  * @param {boolean} [options.isCommentEditor=false] - Flag to indicate if the editor is in comment mode.
44
44
  * @param {boolean} [options.isChromelessEditor=false] - Flag to indicate if the editor is chromeless.
45
45
  * @param {boolean} [options.isTableResizingEnabled=false] - Flag to enable table resizing.
46
- * @param {Object} [options.createTableProps={}] - Additional properties for table creation, including table size.
47
- * @param {Object} api - PluginInjectinoApi object for content insertion commands.
48
- * @param {Object} analyticsPayload - Payload for analytics tracking.
46
+ * @param {object} [options.createTableProps={}] - Additional properties for table creation, including table size.
47
+ * @param {object} api - PluginInjectinoApi object for content insertion commands.
48
+ * @param {object} analyticsPayload - Payload for analytics tracking.
49
49
  *
50
50
  * @returns {Function} A function that takes a transaction and inserts a table.
51
51
  */
@@ -45,4 +45,5 @@ export declare const useMeasureFramerate: (config?: UseMeasureFramerateConfig) =
45
45
  countFrames: () => void;
46
46
  };
47
47
  export declare const getWidthInfoPayload: (editorView: EditorView, editorWidth: number) => TableEventPayload | undefined;
48
+ export declare const getHeightInfoPayload: (editorView: EditorView) => TableEventPayload | undefined;
48
49
  export {};
@@ -36,16 +36,16 @@ export declare const insertTableWithSize: (isFullWidthModeEnabled?: boolean, isT
36
36
  /**
37
37
  * Unified command to insert a new table into the editor.
38
38
  *
39
- * @param {Object} options - Configuration options for table insertion.
39
+ * @param {object} options - Configuration options for table insertion.
40
40
  * @param {boolean} [options.isTableScalingEnabled=false] - Flag to enable table scaling.
41
41
  * @param {boolean} [options.isTableAlignmentEnabled=false] - Flag to enable table alignment.
42
42
  * @param {boolean} [options.isFullWidthModeEnabled=false] - Flag to enable full-width mode for the table.
43
43
  * @param {boolean} [options.isCommentEditor=false] - Flag to indicate if the editor is in comment mode.
44
44
  * @param {boolean} [options.isChromelessEditor=false] - Flag to indicate if the editor is chromeless.
45
45
  * @param {boolean} [options.isTableResizingEnabled=false] - Flag to enable table resizing.
46
- * @param {Object} [options.createTableProps={}] - Additional properties for table creation, including table size.
47
- * @param {Object} api - PluginInjectinoApi object for content insertion commands.
48
- * @param {Object} analyticsPayload - Payload for analytics tracking.
46
+ * @param {object} [options.createTableProps={}] - Additional properties for table creation, including table size.
47
+ * @param {object} api - PluginInjectinoApi object for content insertion commands.
48
+ * @param {object} analyticsPayload - Payload for analytics tracking.
49
49
  *
50
50
  * @returns {Function} A function that takes a transaction and inserts a table.
51
51
  */
@@ -45,4 +45,5 @@ export declare const useMeasureFramerate: (config?: UseMeasureFramerateConfig) =
45
45
  countFrames: () => void;
46
46
  };
47
47
  export declare const getWidthInfoPayload: (editorView: EditorView, editorWidth: number) => TableEventPayload | undefined;
48
+ export declare const getHeightInfoPayload: (editorView: EditorView) => TableEventPayload | undefined;
48
49
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "15.3.11",
3
+ "version": "15.3.13",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -59,7 +59,7 @@
59
59
  "@atlaskit/primitives": "^16.1.0",
60
60
  "@atlaskit/react-ufo": "^4.14.0",
61
61
  "@atlaskit/theme": "^21.0.0",
62
- "@atlaskit/tmp-editor-statsig": "^13.30.0",
62
+ "@atlaskit/tmp-editor-statsig": "^13.31.0",
63
63
  "@atlaskit/toggle": "^15.1.0",
64
64
  "@atlaskit/tokens": "^7.1.0",
65
65
  "@atlaskit/tooltip": "^20.7.0",
@@ -72,7 +72,7 @@
72
72
  "uuid": "^3.1.0"
73
73
  },
74
74
  "peerDependencies": {
75
- "@atlaskit/editor-common": "^110.23.0",
75
+ "@atlaskit/editor-common": "^110.24.0",
76
76
  "react": "^18.2.0",
77
77
  "react-dom": "^18.2.0",
78
78
  "react-intl-next": "npm:react-intl@^5.18.1"
@@ -147,6 +147,12 @@
147
147
  },
148
148
  "platform_editor_table_width_refactor": {
149
149
  "type": "boolean"
150
+ },
151
+ "platform_editor_table_height_analytics": {
152
+ "type": "boolean"
153
+ },
154
+ "platform_editor_table_height_analytics_event": {
155
+ "type": "boolean"
150
156
  }
151
157
  }
152
158
  }