@atlaskit/editor-plugin-table 3.0.5 → 3.1.0

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.
Files changed (50) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/cjs/plugins/table/commands/insert.js +5 -0
  3. package/dist/cjs/plugins/table/commands/toggle.js +11 -1
  4. package/dist/cjs/plugins/table/index.js +37 -26
  5. package/dist/cjs/plugins/table/nodeviews/TableComponent.js +111 -46
  6. package/dist/cjs/plugins/table/nodeviews/TableResizer.js +9 -4
  7. package/dist/cjs/plugins/table/pm-plugins/table-analytics.js +83 -0
  8. package/dist/cjs/plugins/table/pm-plugins/table-resizing/commands.js +5 -0
  9. package/dist/cjs/plugins/table/pm-plugins/table-resizing/event-handlers.js +8 -0
  10. package/dist/cjs/plugins/table/transforms/delete-columns.js +5 -0
  11. package/dist/es2019/plugins/table/commands/insert.js +5 -0
  12. package/dist/es2019/plugins/table/commands/toggle.js +11 -1
  13. package/dist/es2019/plugins/table/index.js +12 -0
  14. package/dist/es2019/plugins/table/nodeviews/TableComponent.js +71 -2
  15. package/dist/es2019/plugins/table/nodeviews/TableResizer.js +5 -0
  16. package/dist/es2019/plugins/table/pm-plugins/table-analytics.js +74 -0
  17. package/dist/es2019/plugins/table/pm-plugins/table-resizing/commands.js +5 -0
  18. package/dist/es2019/plugins/table/pm-plugins/table-resizing/event-handlers.js +9 -1
  19. package/dist/es2019/plugins/table/transforms/delete-columns.js +5 -0
  20. package/dist/esm/plugins/table/commands/insert.js +5 -0
  21. package/dist/esm/plugins/table/commands/toggle.js +11 -1
  22. package/dist/esm/plugins/table/index.js +37 -26
  23. package/dist/esm/plugins/table/nodeviews/TableComponent.js +112 -47
  24. package/dist/esm/plugins/table/nodeviews/TableResizer.js +5 -0
  25. package/dist/esm/plugins/table/pm-plugins/table-analytics.js +75 -0
  26. package/dist/esm/plugins/table/pm-plugins/table-resizing/commands.js +5 -0
  27. package/dist/esm/plugins/table/pm-plugins/table-resizing/event-handlers.js +9 -1
  28. package/dist/esm/plugins/table/transforms/delete-columns.js +5 -0
  29. package/dist/types/plugins/table/commands/insert.d.ts +3 -4
  30. package/dist/types/plugins/table/commands/toggle.d.ts +2 -2
  31. package/dist/types/plugins/table/nodeviews/TableComponent.d.ts +4 -1
  32. package/dist/types/plugins/table/pm-plugins/table-analytics.d.ts +23 -0
  33. package/dist/types/plugins/table/pm-plugins/table-resizing/commands.d.ts +4 -4
  34. package/dist/types/plugins/table/transforms/delete-columns.d.ts +2 -2
  35. package/dist/types-ts4.5/plugins/table/commands/insert.d.ts +3 -4
  36. package/dist/types-ts4.5/plugins/table/commands/toggle.d.ts +2 -2
  37. package/dist/types-ts4.5/plugins/table/nodeviews/TableComponent.d.ts +4 -1
  38. package/dist/types-ts4.5/plugins/table/pm-plugins/table-analytics.d.ts +23 -0
  39. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/commands.d.ts +4 -4
  40. package/dist/types-ts4.5/plugins/table/transforms/delete-columns.d.ts +2 -2
  41. package/package.json +5 -2
  42. package/src/plugins/table/commands/insert.ts +12 -4
  43. package/src/plugins/table/commands/toggle.ts +17 -4
  44. package/src/plugins/table/index.tsx +17 -1
  45. package/src/plugins/table/nodeviews/TableComponent.tsx +99 -2
  46. package/src/plugins/table/nodeviews/TableResizer.tsx +6 -0
  47. package/src/plugins/table/pm-plugins/table-analytics.ts +102 -0
  48. package/src/plugins/table/pm-plugins/table-resizing/commands.ts +10 -4
  49. package/src/plugins/table/pm-plugins/table-resizing/event-handlers.ts +10 -0
  50. package/src/plugins/table/transforms/delete-columns.ts +12 -4
@@ -1,9 +1,11 @@
1
1
  // #region Imports
2
2
  import { AddColumnStep } from '@atlaskit/adf-schema/steps';
3
+ import { TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
3
4
  import { Selection } from '@atlaskit/editor-prosemirror/state';
4
5
  import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
5
6
  import { TableMap } from '@atlaskit/editor-tables/table-map';
6
7
  import { addColumnAt as addColumnAtPMUtils, addRowAt, createTable as createTableNode, findTable, selectedRect } from '@atlaskit/editor-tables/utils';
8
+ import { META_KEYS } from '../pm-plugins/table-analytics';
7
9
  import { rescaleColumns } from '../transforms/column-width';
8
10
  import { checkIfHeaderRowEnabled, copyPreviousRow } from '../utils';
9
11
  import { getAllowAddColumnCustomStep } from '../utils/get-allow-add-column-custom-step';
@@ -33,6 +35,9 @@ export function addColumnAt(getEditorContainerWidth) {
33
35
  // [ED-8288] Update colwidths manually to avoid multiple dispatch in TableComponent
34
36
  updatedTr = rescaleColumns(getEditorContainerWidth)(table, view)(updatedTr);
35
37
  }
38
+ updatedTr.setMeta(META_KEYS.OVERFLOW_TRIGGER, {
39
+ name: TABLE_OVERFLOW_CHANGE_TRIGGER.ADDED_COLUMN
40
+ });
36
41
  return updatedTr;
37
42
  };
38
43
  };
@@ -1,7 +1,9 @@
1
1
  //#region Imports
2
2
 
3
+ import { TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
3
4
  import { findTable, toggleHeader } from '@atlaskit/editor-tables/utils';
4
5
  import { createCommand } from '../pm-plugins/plugin-factory';
6
+ import { META_KEYS } from '../pm-plugins/table-analytics';
5
7
  //#endregion
6
8
 
7
9
  // #region Utils
@@ -38,11 +40,16 @@ export const toggleNumberColumn = (state, dispatch) => {
38
40
  node,
39
41
  pos
40
42
  } = findTable(state.selection);
43
+ const isNumberedColumnEnabled = node.attrs.isNumberColumnEnabled;
41
44
  tr.setNodeMarkup(pos, state.schema.nodes.table, {
42
45
  ...node.attrs,
43
- isNumberColumnEnabled: !node.attrs.isNumberColumnEnabled
46
+ isNumberColumnEnabled: !isNumberedColumnEnabled
44
47
  });
45
48
  tr.setMeta('scrollIntoView', false);
49
+ const tableOverflowChangeTriggerName = isNumberedColumnEnabled ? TABLE_OVERFLOW_CHANGE_TRIGGER.DISABLED_NUMBERED_COLUMN : TABLE_OVERFLOW_CHANGE_TRIGGER.ENABLED_NUMBERED_COLUMN;
50
+ tr.setMeta(META_KEYS.OVERFLOW_TRIGGER, {
51
+ name: tableOverflowChangeTriggerName
52
+ });
46
53
  if (dispatch) {
47
54
  dispatch(tr);
48
55
  }
@@ -64,6 +71,9 @@ export const toggleTableLayout = (state, dispatch) => {
64
71
  ...table.node.attrs,
65
72
  layout
66
73
  });
74
+ tr.setMeta(META_KEYS.OVERFLOW_TRIGGER, {
75
+ name: TABLE_OVERFLOW_CHANGE_TRIGGER.RESIZED
76
+ });
67
77
  return tr.setMeta('scrollIntoView', false);
68
78
  })(state, dispatch);
69
79
  };
@@ -10,6 +10,7 @@ import { browser } from '@atlaskit/editor-common/utils';
10
10
  import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
11
11
  import { tableEditing } from '@atlaskit/editor-tables/pm-plugins';
12
12
  import { createTable } from '@atlaskit/editor-tables/utils';
13
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
13
14
  import { pluginConfig } from './create-plugin-config';
14
15
  import { createPlugin as createDecorationsPlugin } from './pm-plugins/decorations/plugin';
15
16
  import { keymapPlugin } from './pm-plugins/keymap';
@@ -17,6 +18,7 @@ import { createPlugin } from './pm-plugins/main';
17
18
  import { pluginKey } from './pm-plugins/plugin-key';
18
19
  import { createPlugin as createTableSafariDeleteCompositionTextIssueWorkaroundPlugin } from './pm-plugins/safari-delete-composition-text-issue-workaround';
19
20
  import { createPlugin as createStickyHeadersPlugin, findStickyHeaderForTable, pluginKey as stickyHeadersPluginKey } from './pm-plugins/sticky-headers';
21
+ import { createPlugin as createTableAnalyticsPlugin, pluginKey as tableAnalyticsPluginKey } from './pm-plugins/table-analytics';
20
22
  import { createPlugin as createTableLocalIdPlugin } from './pm-plugins/table-local-id';
21
23
  import { createPlugin as createFlexiResizingPlugin, pluginKey as tableResizingPluginKey } from './pm-plugins/table-resizing';
22
24
  import { tableSelectionKeymapPlugin } from './pm-plugins/table-selection-keymap';
@@ -174,6 +176,15 @@ const tablesPlugin = ({
174
176
  var _options$fullWidthEna;
175
177
  return options !== null && options !== void 0 && options.tableResizingEnabled ? createTableWidthPlugin(dispatch, dispatchAnalyticsEvent, (_options$fullWidthEna = options === null || options === void 0 ? void 0 : options.fullWidthEnabled) !== null && _options$fullWidthEna !== void 0 ? _options$fullWidthEna : false) : undefined;
176
178
  }
179
+ }, {
180
+ name: 'tableAnalyticsPlugin',
181
+ plugin: ({
182
+ dispatch,
183
+ dispatchAnalyticsEvent
184
+ }) => {
185
+ var _options$tableResizin;
186
+ return getBooleanFF('platform.editor.table.overflow-state-analytics') ? createTableAnalyticsPlugin(dispatch, dispatchAnalyticsEvent, (_options$tableResizin = options === null || options === void 0 ? void 0 : options.tableResizingEnabled) !== null && _options$tableResizin !== void 0 ? _options$tableResizin : false) : undefined;
187
+ }
177
188
  }, {
178
189
  name: 'tableGetEditorViewReferencePlugin',
179
190
  plugin: () => {
@@ -215,6 +226,7 @@ const tablesPlugin = ({
215
226
  fallbackComponent: null
216
227
  }, /*#__PURE__*/React.createElement(WithPluginState, {
217
228
  plugins: {
229
+ tableAnalyticsPluginState: tableAnalyticsPluginKey,
218
230
  tablePluginState: pluginKey,
219
231
  tableWidthPluginState: tableWidthPluginKey,
220
232
  tableResizingPluginState: tableResizingPluginKey,
@@ -3,15 +3,18 @@ import React from 'react';
3
3
  import classnames from 'classnames';
4
4
  import memoizeOne from 'memoize-one';
5
5
  import rafSchedule from 'raf-schd';
6
+ import { ACTION_SUBJECT, EVENT_TYPE, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
7
+ import { createDispatch } from '@atlaskit/editor-common/event-dispatcher';
6
8
  import { getParentNodeWidth } from '@atlaskit/editor-common/node-width';
7
9
  import { tableMarginSides } from '@atlaskit/editor-common/styles';
8
- import { browser, isValidPosition } from '@atlaskit/editor-common/utils';
10
+ import { analyticsEventKey, browser, isValidPosition } from '@atlaskit/editor-common/utils';
9
11
  import { akEditorTableToolbarSize as tableToolbarSize } from '@atlaskit/editor-shared-styles';
10
12
  import { findTable, isTableSelected } from '@atlaskit/editor-tables/utils';
11
13
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
12
14
  import { autoSizeTable, clearHoverSelection } from '../commands';
13
15
  import { getPluginState } from '../pm-plugins/plugin-factory';
14
16
  import { findStickyHeaderForTable, pluginKey as stickyHeadersPluginKey } from '../pm-plugins/sticky-headers';
17
+ import { META_KEYS } from '../pm-plugins/table-analytics';
15
18
  import { getLayoutSize, insertColgroupFromNode as recreateResizeColsByNode, scaleTable } from '../pm-plugins/table-resizing/utils';
16
19
  import { hasTableBeenResized } from '../pm-plugins/table-resizing/utils/colgroup';
17
20
  import { updateControls } from '../pm-plugins/table-resizing/utils/dom';
@@ -22,6 +25,10 @@ import { containsHeaderRow, isTableNested, tablesHaveDifferentColumnWidths, tabl
22
25
  import { OverflowShadowsObserver } from './OverflowShadowsObserver';
23
26
  import { TableContainer } from './TableContainer';
24
27
  const isIE11 = browser.ie_version === 11;
28
+ // When table is inserted via paste, keyboard shortcut or quickInsert,
29
+ // componentDidUpdate is called multiple times. The isOverflowing value is correct only on the last update.
30
+ // To make sure we capture the last update, we use setTimeout.
31
+ const initialOverflowCaptureTimeroutDelay = 300;
25
32
  class TableComponent extends React.Component {
26
33
  constructor(props) {
27
34
  super(props);
@@ -168,6 +175,34 @@ class TableComponent extends React.Component {
168
175
  }, domAtPos)(state.tr);
169
176
  dispatch(tr);
170
177
  });
178
+ _defineProperty(this, "setTimerToSendInitialOverflowCaptured", isOverflowing => {
179
+ var _this$state;
180
+ const {
181
+ eventDispatcher,
182
+ containerWidth,
183
+ options
184
+ } = this.props;
185
+ const dispatch = createDispatch(eventDispatcher);
186
+ const parentWidth = ((_this$state = this.state) === null || _this$state === void 0 ? void 0 : _this$state.parentWidth) || 0;
187
+ this.initialOverflowCaptureTimerId = setTimeout(() => {
188
+ dispatch(analyticsEventKey, {
189
+ payload: {
190
+ action: TABLE_ACTION.INITIAL_OVERFLOW_CAPTURED,
191
+ actionSubject: ACTION_SUBJECT.TABLE,
192
+ actionSubjectId: null,
193
+ eventType: EVENT_TYPE.TRACK,
194
+ attributes: {
195
+ editorWidth: containerWidth.width || 0,
196
+ isOverflowing,
197
+ tableResizingEnabled: (options === null || options === void 0 ? void 0 : options.isTableResizingEnabled) || false,
198
+ width: this.node.attrs.width || 0,
199
+ parentWidth
200
+ }
201
+ }
202
+ });
203
+ this.isInitialOverflowSent = true;
204
+ }, initialOverflowCaptureTimeroutDelay);
205
+ });
171
206
  _defineProperty(this, "handleAutoSize", () => {
172
207
  if (this.table) {
173
208
  const {
@@ -240,6 +275,7 @@ class TableComponent extends React.Component {
240
275
  } = props;
241
276
  this.node = _getNode();
242
277
  this.containerWidth = _containerWidth;
278
+ this.isInitialOverflowSent = false;
243
279
 
244
280
  // store table size using previous full-width mode so can detect if it has changed
245
281
  const isFullWidthModeEnabled = _options ? _options.wasFullWidthModeEnabled : false;
@@ -281,6 +317,10 @@ class TableComponent extends React.Component {
281
317
  this.onStickyState(currentStickyState);
282
318
  }
283
319
  eventDispatcher.on(stickyHeadersPluginKey.key, this.onStickyState);
320
+ if (getBooleanFF('platform.editor.table.overflow-state-analytics')) {
321
+ const initialIsOveflowing = this.state[ShadowEvent.SHOW_BEFORE_SHADOW] || this.state[ShadowEvent.SHOW_AFTER_SHADOW];
322
+ this.setTimerToSendInitialOverflowCaptured(initialIsOveflowing);
323
+ }
284
324
  }
285
325
  componentWillUnmount() {
286
326
  const {
@@ -305,8 +345,11 @@ class TableComponent extends React.Component {
305
345
  this.overflowShadowsObserver.dispose();
306
346
  }
307
347
  eventDispatcher.off(stickyHeadersPluginKey.key, this.onStickyState);
348
+ if (this.initialOverflowCaptureTimerId) {
349
+ clearTimeout(this.initialOverflowCaptureTimerId);
350
+ }
308
351
  }
309
- componentDidUpdate() {
352
+ componentDidUpdate(_, prevState) {
310
353
  var _this$wrapper;
311
354
  const {
312
355
  view,
@@ -353,6 +396,32 @@ class TableComponent extends React.Component {
353
396
  }
354
397
  this.handleTableResizingDebounced();
355
398
  }
399
+ if (getBooleanFF('platform.editor.table.overflow-state-analytics')) {
400
+ const newIsOverflowing = this.state[ShadowEvent.SHOW_BEFORE_SHADOW] || this.state[ShadowEvent.SHOW_AFTER_SHADOW];
401
+ const prevIsOverflowing = prevState[ShadowEvent.SHOW_BEFORE_SHADOW] || prevState[ShadowEvent.SHOW_AFTER_SHADOW];
402
+ if (this.initialOverflowCaptureTimerId) {
403
+ clearTimeout(this.initialOverflowCaptureTimerId);
404
+ }
405
+ if (!this.isInitialOverflowSent) {
406
+ this.setTimerToSendInitialOverflowCaptured(newIsOverflowing);
407
+ }
408
+ if (this.isInitialOverflowSent && prevIsOverflowing !== newIsOverflowing) {
409
+ var _this$state2;
410
+ const {
411
+ dispatch,
412
+ state: {
413
+ tr
414
+ }
415
+ } = this.props.view;
416
+ dispatch(tr.setMeta(META_KEYS.OVERFLOW_STATE_CHANGED, {
417
+ isOverflowing: newIsOverflowing,
418
+ wasOverflowing: prevIsOverflowing,
419
+ editorWidth: this.props.containerWidth.width || 0,
420
+ width: this.node.attrs.width || 0,
421
+ parentWidth: ((_this$state2 = this.state) === null || _this$state2 === void 0 ? void 0 : _this$state2.parentWidth) || 0
422
+ }));
423
+ }
424
+ }
356
425
  }
357
426
  render() {
358
427
  const {
@@ -1,11 +1,13 @@
1
1
  import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
2
2
  import rafSchd from 'raf-schd';
3
3
  import { defineMessages, useIntl } from 'react-intl-next';
4
+ import { TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
4
5
  import { getGuidelinesWithHighlights } from '@atlaskit/editor-common/guideline';
5
6
  import { ResizerNext } from '@atlaskit/editor-common/resizer';
6
7
  import { findTable } from '@atlaskit/editor-tables/utils';
7
8
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
8
9
  import { getPluginState } from '../pm-plugins/plugin-factory';
10
+ import { META_KEYS } from '../pm-plugins/table-analytics';
9
11
  import { COLUMN_MIN_WIDTH, getColgroupChildrenLength, previewScaleTable, scaleTable } from '../pm-plugins/table-resizing/utils';
10
12
  import { pluginKey as tableWidthPluginKey } from '../pm-plugins/table-width';
11
13
  import { TABLE_HIGHLIGHT_GAP, TABLE_HIGHLIGHT_TOLERANCE, TABLE_SNAP_GAP } from '../ui/consts';
@@ -135,6 +137,9 @@ export const TableResizer = ({
135
137
  resizing: true
136
138
  });
137
139
  displayGapCursor(false);
140
+ tr.setMeta(META_KEYS.OVERFLOW_TRIGGER, {
141
+ name: TABLE_OVERFLOW_CHANGE_TRIGGER.RESIZED
142
+ });
138
143
  dispatch(tr);
139
144
  const visibleGuidelines = getVisibleGuidelines(defaultGuidelines, containerWidth);
140
145
  setSnappingEnabled(displayGuideline(visibleGuidelines));
@@ -0,0 +1,74 @@
1
+ /**
2
+ * A plugin is created for collecting payload data for tableOverflowChanged analytics event
3
+ */
4
+ import { ACTION_SUBJECT, EVENT_TYPE, TABLE_ACTION, TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
5
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
6
+ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
7
+ export const pluginKey = new PluginKey('tableAnalyticsPlugin');
8
+ export const META_KEYS = {
9
+ OVERFLOW_TRIGGER: 'tableOverflowTrigger',
10
+ OVERFLOW_STATE_CHANGED: 'tableOverflowStateChanged'
11
+ };
12
+ const createPlugin = (dispatch, dispatchAnalyticsEvent, tableResizingEnabled) => new SafePlugin({
13
+ key: pluginKey,
14
+ state: {
15
+ init() {
16
+ return {
17
+ lastTrigger: undefined
18
+ };
19
+ },
20
+ apply(tr, pluginState) {
21
+ const meta = tr.getMeta(META_KEYS.OVERFLOW_TRIGGER);
22
+ const newState = {
23
+ ...pluginState
24
+ };
25
+ if (meta) {
26
+ newState.lastTrigger = {
27
+ ...meta
28
+ };
29
+ dispatch(pluginKey, newState);
30
+ return newState;
31
+ }
32
+ return pluginState;
33
+ }
34
+ },
35
+ appendTransaction: (transactions, oldState, newState) => {
36
+ var _newPluginState$lastT;
37
+ const newPluginState = pluginKey.getState(newState);
38
+ let hasAnalyticsBeenDispatched = false;
39
+ let lastTriggerName = (newPluginState === null || newPluginState === void 0 ? void 0 : (_newPluginState$lastT = newPluginState.lastTrigger) === null || _newPluginState$lastT === void 0 ? void 0 : _newPluginState$lastT.name) ||
40
+ // NOTE: We assume that we know and can correctly differentiate
41
+ // between all triggers of table overflow state change.
42
+ // The only trigger we can't identify is viewport width change.
43
+ // However, since there is still a chance that there are other triggers we didn't think of,
44
+ // all these unknown triggers and viwport width change trigger are captured as EXTERNAL.
45
+ TABLE_OVERFLOW_CHANGE_TRIGGER.EXTERNAL;
46
+ transactions.forEach(tr => {
47
+ const payload = tr.getMeta(META_KEYS.OVERFLOW_STATE_CHANGED);
48
+ if (payload) {
49
+ dispatchAnalyticsEvent({
50
+ action: TABLE_ACTION.OVERFLOW_CHANGED,
51
+ actionSubject: ACTION_SUBJECT.TABLE,
52
+ actionSubjectId: null,
53
+ eventType: EVENT_TYPE.TRACK,
54
+ attributes: {
55
+ editorWidth: payload.editorWidth,
56
+ parentWidth: payload.parentWidth,
57
+ isOverflowing: payload.isOverflowing,
58
+ wasOverflowing: payload.wasOverflowing,
59
+ width: payload.width,
60
+ tableResizingEnabled,
61
+ trigger: lastTriggerName
62
+ }
63
+ });
64
+ hasAnalyticsBeenDispatched = true;
65
+ }
66
+ });
67
+ if (hasAnalyticsBeenDispatched) {
68
+ const tr = newState.tr;
69
+ return tr.setMeta(META_KEYS.OVERFLOW_TRIGGER, {});
70
+ }
71
+ return undefined;
72
+ }
73
+ });
74
+ export { createPlugin };
@@ -1,5 +1,7 @@
1
+ import { TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
1
2
  import { isTableSelected } from '@atlaskit/editor-tables/utils';
2
3
  import { updateColumnWidths } from '../../transforms';
4
+ import { META_KEYS } from '../table-analytics';
3
5
  import { createCommand, getPluginState } from './plugin-factory';
4
6
  import { evenAllColumnsWidths, isClickNear } from './utils';
5
7
  export const evenColumns = ({
@@ -33,6 +35,9 @@ export const evenColumns = ({
33
35
  export const distributeColumnsWidths = (newResizeState, table) => (state, dispatch) => {
34
36
  if (dispatch) {
35
37
  const tr = updateColumnWidths(newResizeState, table.node, table.start)(state.tr);
38
+ tr.setMeta(META_KEYS.OVERFLOW_TRIGGER, {
39
+ name: TABLE_OVERFLOW_CHANGE_TRIGGER.DISTRIBUTED_COLUMNS
40
+ });
36
41
  stopResizing(tr)(state, dispatch);
37
42
  }
38
43
  return true;
@@ -1,4 +1,4 @@
1
- import { ACTION_SUBJECT, EVENT_TYPE, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
1
+ import { ACTION_SUBJECT, EVENT_TYPE, TABLE_ACTION, TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
2
2
  import { getParentNodeWidth } from '@atlaskit/editor-common/node-width';
3
3
  import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
4
4
  import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
@@ -8,6 +8,7 @@ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
8
8
  import { updateResizeHandleDecorations } from '../../commands/misc';
9
9
  import { updateColumnWidths } from '../../transforms';
10
10
  import { getSelectedColumnIndexes, updateResizeHandles } from '../../utils';
11
+ import { META_KEYS } from '../table-analytics';
11
12
  import { evenColumns, setDragging, stopResizing } from './commands';
12
13
  import { getPluginState } from './plugin-factory';
13
14
  import { currentColWidth, getLayoutSize, getResizeState, pointsAtCell, resizeColumn, updateControls } from './utils';
@@ -22,6 +23,13 @@ export const handleMouseDown = (view, event, localResizeHandlePos, getEditorCont
22
23
  return false;
23
24
  }
24
25
  event.preventDefault();
26
+ if (getBooleanFF('platform.editor.table.overflow-state-analytics')) {
27
+ const tr = view.state.tr;
28
+ tr.setMeta(META_KEYS.OVERFLOW_TRIGGER, {
29
+ name: TABLE_OVERFLOW_CHANGE_TRIGGER.RESIZED_COLUMN
30
+ });
31
+ dispatch(tr);
32
+ }
25
33
  const mouseDownTime = event.timeStamp;
26
34
  const cell = state.doc.nodeAt(localResizeHandlePos);
27
35
  const $cell = state.doc.resolve(localResizeHandlePos);
@@ -1,7 +1,9 @@
1
1
  import { AddColumnStep } from '@atlaskit/adf-schema/steps';
2
+ import { TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
2
3
  import { Selection } from '@atlaskit/editor-prosemirror/state';
3
4
  import { TableMap } from '@atlaskit/editor-tables/table-map';
4
5
  import { findTable } from '@atlaskit/editor-tables/utils';
6
+ import { META_KEYS } from '../pm-plugins/table-analytics';
5
7
  import { splitCellsInColumns } from './split';
6
8
  const deleteColumnsCustomStep = rect => tr => {
7
9
  const table = findTable(tr.selection);
@@ -190,6 +192,9 @@ function fixRowSpans(table) {
190
192
  return table.type.createChecked(table.attrs, rows, table.marks);
191
193
  }
192
194
  export const deleteColumns = (rect, allowAddColumnCustomStep = false) => tr => {
195
+ tr.setMeta(META_KEYS.OVERFLOW_TRIGGER, {
196
+ name: TABLE_OVERFLOW_CHANGE_TRIGGER.DELETED_COLUMN
197
+ });
193
198
  if (allowAddColumnCustomStep) {
194
199
  return deleteColumnsCustomStep(rect)(tr);
195
200
  }
@@ -1,9 +1,11 @@
1
1
  // #region Imports
2
2
  import { AddColumnStep } from '@atlaskit/adf-schema/steps';
3
+ import { TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
3
4
  import { Selection } from '@atlaskit/editor-prosemirror/state';
4
5
  import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
5
6
  import { TableMap } from '@atlaskit/editor-tables/table-map';
6
7
  import { addColumnAt as addColumnAtPMUtils, addRowAt, createTable as createTableNode, findTable, selectedRect } from '@atlaskit/editor-tables/utils';
8
+ import { META_KEYS } from '../pm-plugins/table-analytics';
7
9
  import { rescaleColumns } from '../transforms/column-width';
8
10
  import { checkIfHeaderRowEnabled, copyPreviousRow } from '../utils';
9
11
  import { getAllowAddColumnCustomStep } from '../utils/get-allow-add-column-custom-step';
@@ -35,6 +37,9 @@ export function addColumnAt(getEditorContainerWidth) {
35
37
  // [ED-8288] Update colwidths manually to avoid multiple dispatch in TableComponent
36
38
  updatedTr = rescaleColumns(getEditorContainerWidth)(table, view)(updatedTr);
37
39
  }
40
+ updatedTr.setMeta(META_KEYS.OVERFLOW_TRIGGER, {
41
+ name: TABLE_OVERFLOW_CHANGE_TRIGGER.ADDED_COLUMN
42
+ });
38
43
  return updatedTr;
39
44
  };
40
45
  };
@@ -3,8 +3,10 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
3
3
  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) { _defineProperty(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; }
4
4
  //#region Imports
5
5
 
6
+ import { TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
6
7
  import { findTable, toggleHeader } from '@atlaskit/editor-tables/utils';
7
8
  import { createCommand } from '../pm-plugins/plugin-factory';
9
+ import { META_KEYS } from '../pm-plugins/table-analytics';
8
10
  //#endregion
9
11
 
10
12
  // #region Utils
@@ -50,10 +52,15 @@ export var toggleNumberColumn = function toggleNumberColumn(state, dispatch) {
50
52
  var _ref = findTable(state.selection),
51
53
  node = _ref.node,
52
54
  pos = _ref.pos;
55
+ var isNumberedColumnEnabled = node.attrs.isNumberColumnEnabled;
53
56
  tr.setNodeMarkup(pos, state.schema.nodes.table, _objectSpread(_objectSpread({}, node.attrs), {}, {
54
- isNumberColumnEnabled: !node.attrs.isNumberColumnEnabled
57
+ isNumberColumnEnabled: !isNumberedColumnEnabled
55
58
  }));
56
59
  tr.setMeta('scrollIntoView', false);
60
+ var tableOverflowChangeTriggerName = isNumberedColumnEnabled ? TABLE_OVERFLOW_CHANGE_TRIGGER.DISABLED_NUMBERED_COLUMN : TABLE_OVERFLOW_CHANGE_TRIGGER.ENABLED_NUMBERED_COLUMN;
61
+ tr.setMeta(META_KEYS.OVERFLOW_TRIGGER, {
62
+ name: tableOverflowChangeTriggerName
63
+ });
57
64
  if (dispatch) {
58
65
  dispatch(tr);
59
66
  }
@@ -74,6 +81,9 @@ export var toggleTableLayout = function toggleTableLayout(state, dispatch) {
74
81
  tr.setNodeMarkup(table.pos, state.schema.nodes.table, _objectSpread(_objectSpread({}, table.node.attrs), {}, {
75
82
  layout: layout
76
83
  }));
84
+ tr.setMeta(META_KEYS.OVERFLOW_TRIGGER, {
85
+ name: TABLE_OVERFLOW_CHANGE_TRIGGER.RESIZED
86
+ });
77
87
  return tr.setMeta('scrollIntoView', false);
78
88
  })(state, dispatch);
79
89
  };
@@ -10,6 +10,7 @@ import { browser } from '@atlaskit/editor-common/utils';
10
10
  import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
11
11
  import { tableEditing } from '@atlaskit/editor-tables/pm-plugins';
12
12
  import { createTable } from '@atlaskit/editor-tables/utils';
13
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
13
14
  import { pluginConfig } from './create-plugin-config';
14
15
  import { createPlugin as createDecorationsPlugin } from './pm-plugins/decorations/plugin';
15
16
  import { keymapPlugin } from './pm-plugins/keymap';
@@ -17,6 +18,7 @@ import { createPlugin } from './pm-plugins/main';
17
18
  import { pluginKey } from './pm-plugins/plugin-key';
18
19
  import { createPlugin as createTableSafariDeleteCompositionTextIssueWorkaroundPlugin } from './pm-plugins/safari-delete-composition-text-issue-workaround';
19
20
  import { createPlugin as createStickyHeadersPlugin, findStickyHeaderForTable, pluginKey as stickyHeadersPluginKey } from './pm-plugins/sticky-headers';
21
+ import { createPlugin as createTableAnalyticsPlugin, pluginKey as tableAnalyticsPluginKey } from './pm-plugins/table-analytics';
20
22
  import { createPlugin as createTableLocalIdPlugin } from './pm-plugins/table-local-id';
21
23
  import { createPlugin as createFlexiResizingPlugin, pluginKey as tableResizingPluginKey } from './pm-plugins/table-resizing';
22
24
  import { tableSelectionKeymapPlugin } from './pm-plugins/table-selection-keymap';
@@ -182,6 +184,14 @@ var tablesPlugin = function tablesPlugin(_ref) {
182
184
  dispatch = _ref9.dispatch;
183
185
  return options !== null && options !== void 0 && options.tableResizingEnabled ? createTableWidthPlugin(dispatch, dispatchAnalyticsEvent, (_options$fullWidthEna = options === null || options === void 0 ? void 0 : options.fullWidthEnabled) !== null && _options$fullWidthEna !== void 0 ? _options$fullWidthEna : false) : undefined;
184
186
  }
187
+ }, {
188
+ name: 'tableAnalyticsPlugin',
189
+ plugin: function plugin(_ref10) {
190
+ var _options$tableResizin;
191
+ var dispatch = _ref10.dispatch,
192
+ dispatchAnalyticsEvent = _ref10.dispatchAnalyticsEvent;
193
+ return getBooleanFF('platform.editor.table.overflow-state-analytics') ? createTableAnalyticsPlugin(dispatch, dispatchAnalyticsEvent, (_options$tableResizin = options === null || options === void 0 ? void 0 : options.tableResizingEnabled) !== null && _options$tableResizin !== void 0 ? _options$tableResizin : false) : undefined;
194
+ }
185
195
  }, {
186
196
  name: 'tableGetEditorViewReferencePlugin',
187
197
  plugin: function plugin() {
@@ -210,45 +220,46 @@ var tablesPlugin = function tablesPlugin(_ref) {
210
220
  }
211
221
  return plugins;
212
222
  },
213
- contentComponent: function contentComponent(_ref10) {
214
- var editorView = _ref10.editorView,
215
- popupsMountPoint = _ref10.popupsMountPoint,
216
- popupsBoundariesElement = _ref10.popupsBoundariesElement,
217
- popupsScrollableElement = _ref10.popupsScrollableElement,
218
- dispatchAnalyticsEvent = _ref10.dispatchAnalyticsEvent;
223
+ contentComponent: function contentComponent(_ref11) {
224
+ var editorView = _ref11.editorView,
225
+ popupsMountPoint = _ref11.popupsMountPoint,
226
+ popupsBoundariesElement = _ref11.popupsBoundariesElement,
227
+ popupsScrollableElement = _ref11.popupsScrollableElement,
228
+ dispatchAnalyticsEvent = _ref11.dispatchAnalyticsEvent;
219
229
  return /*#__PURE__*/React.createElement(ErrorBoundary, {
220
230
  component: ACTION_SUBJECT.TABLES_PLUGIN,
221
231
  dispatchAnalyticsEvent: dispatchAnalyticsEvent,
222
232
  fallbackComponent: null
223
233
  }, /*#__PURE__*/React.createElement(WithPluginState, {
224
234
  plugins: {
235
+ tableAnalyticsPluginState: tableAnalyticsPluginKey,
225
236
  tablePluginState: pluginKey,
226
237
  tableWidthPluginState: tableWidthPluginKey,
227
238
  tableResizingPluginState: tableResizingPluginKey,
228
239
  stickyHeadersState: stickyHeadersPluginKey
229
240
  },
230
- render: function render(_ref11) {
231
- var resizingPluginState = _ref11.tableResizingPluginState,
232
- stickyHeadersState = _ref11.stickyHeadersState,
233
- tablePluginState = _ref11.tablePluginState,
234
- tableWidthPluginState = _ref11.tableWidthPluginState;
241
+ render: function render(_ref12) {
242
+ var resizingPluginState = _ref12.tableResizingPluginState,
243
+ stickyHeadersState = _ref12.stickyHeadersState,
244
+ tablePluginState = _ref12.tablePluginState,
245
+ tableWidthPluginState = _ref12.tableWidthPluginState;
235
246
  var state = editorView.state;
236
247
  var isColumnResizing = resizingPluginState === null || resizingPluginState === void 0 ? void 0 : resizingPluginState.dragging;
237
248
  var isTableResizing = tableWidthPluginState === null || tableWidthPluginState === void 0 ? void 0 : tableWidthPluginState.resizing;
238
249
  var isResizing = isColumnResizing || isTableResizing;
239
- var _ref12 = tablePluginState,
240
- tableNode = _ref12.tableNode,
241
- tablePos = _ref12.tablePos,
242
- targetCellPosition = _ref12.targetCellPosition,
243
- isContextualMenuOpen = _ref12.isContextualMenuOpen,
244
- layout = _ref12.layout,
245
- tableRef = _ref12.tableRef,
246
- pluginConfig = _ref12.pluginConfig,
247
- insertColumnButtonIndex = _ref12.insertColumnButtonIndex,
248
- insertRowButtonIndex = _ref12.insertRowButtonIndex,
249
- isHeaderColumnEnabled = _ref12.isHeaderColumnEnabled,
250
- isHeaderRowEnabled = _ref12.isHeaderRowEnabled,
251
- tableWrapperTarget = _ref12.tableWrapperTarget;
250
+ var _ref13 = tablePluginState,
251
+ tableNode = _ref13.tableNode,
252
+ tablePos = _ref13.tablePos,
253
+ targetCellPosition = _ref13.targetCellPosition,
254
+ isContextualMenuOpen = _ref13.isContextualMenuOpen,
255
+ layout = _ref13.layout,
256
+ tableRef = _ref13.tableRef,
257
+ pluginConfig = _ref13.pluginConfig,
258
+ insertColumnButtonIndex = _ref13.insertColumnButtonIndex,
259
+ insertRowButtonIndex = _ref13.insertRowButtonIndex,
260
+ isHeaderColumnEnabled = _ref13.isHeaderColumnEnabled,
261
+ isHeaderRowEnabled = _ref13.isHeaderRowEnabled,
262
+ tableWrapperTarget = _ref13.tableWrapperTarget;
252
263
  var allowControls = pluginConfig.allowControls;
253
264
  var stickyHeader = stickyHeadersState ? findStickyHeaderForTable(stickyHeadersState, tablePos) : undefined;
254
265
  var LayoutContent = options && !options.tableResizingEnabled && isLayoutSupported(state) && options.breakoutEnabled ? /*#__PURE__*/React.createElement(LayoutButton, {
@@ -314,8 +325,8 @@ var tablesPlugin = function tablesPlugin(_ref) {
314
325
  }));
315
326
  },
316
327
  pluginsOptions: {
317
- quickInsert: function quickInsert(_ref13) {
318
- var formatMessage = _ref13.formatMessage;
328
+ quickInsert: function quickInsert(_ref14) {
329
+ var formatMessage = _ref14.formatMessage;
319
330
  return [{
320
331
  id: 'table',
321
332
  title: formatMessage(messages.table),