@atlaskit/editor-plugin-table 3.0.4 → 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 (54) hide show
  1. package/CHANGELOG.md +17 -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/cjs/plugins/table/ui/ui-styles.js +1 -1
  12. package/dist/es2019/plugins/table/commands/insert.js +5 -0
  13. package/dist/es2019/plugins/table/commands/toggle.js +11 -1
  14. package/dist/es2019/plugins/table/index.js +12 -0
  15. package/dist/es2019/plugins/table/nodeviews/TableComponent.js +71 -2
  16. package/dist/es2019/plugins/table/nodeviews/TableResizer.js +5 -0
  17. package/dist/es2019/plugins/table/pm-plugins/table-analytics.js +74 -0
  18. package/dist/es2019/plugins/table/pm-plugins/table-resizing/commands.js +5 -0
  19. package/dist/es2019/plugins/table/pm-plugins/table-resizing/event-handlers.js +9 -1
  20. package/dist/es2019/plugins/table/transforms/delete-columns.js +5 -0
  21. package/dist/es2019/plugins/table/ui/ui-styles.js +1 -1
  22. package/dist/esm/plugins/table/commands/insert.js +5 -0
  23. package/dist/esm/plugins/table/commands/toggle.js +11 -1
  24. package/dist/esm/plugins/table/index.js +37 -26
  25. package/dist/esm/plugins/table/nodeviews/TableComponent.js +112 -47
  26. package/dist/esm/plugins/table/nodeviews/TableResizer.js +5 -0
  27. package/dist/esm/plugins/table/pm-plugins/table-analytics.js +75 -0
  28. package/dist/esm/plugins/table/pm-plugins/table-resizing/commands.js +5 -0
  29. package/dist/esm/plugins/table/pm-plugins/table-resizing/event-handlers.js +9 -1
  30. package/dist/esm/plugins/table/transforms/delete-columns.js +5 -0
  31. package/dist/esm/plugins/table/ui/ui-styles.js +1 -1
  32. package/dist/types/plugins/table/commands/insert.d.ts +3 -4
  33. package/dist/types/plugins/table/commands/toggle.d.ts +2 -2
  34. package/dist/types/plugins/table/nodeviews/TableComponent.d.ts +4 -1
  35. package/dist/types/plugins/table/pm-plugins/table-analytics.d.ts +23 -0
  36. package/dist/types/plugins/table/pm-plugins/table-resizing/commands.d.ts +4 -4
  37. package/dist/types/plugins/table/transforms/delete-columns.d.ts +2 -2
  38. package/dist/types-ts4.5/plugins/table/commands/insert.d.ts +3 -4
  39. package/dist/types-ts4.5/plugins/table/commands/toggle.d.ts +2 -2
  40. package/dist/types-ts4.5/plugins/table/nodeviews/TableComponent.d.ts +4 -1
  41. package/dist/types-ts4.5/plugins/table/pm-plugins/table-analytics.d.ts +23 -0
  42. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/commands.d.ts +4 -4
  43. package/dist/types-ts4.5/plugins/table/transforms/delete-columns.d.ts +2 -2
  44. package/package.json +5 -2
  45. package/src/plugins/table/commands/insert.ts +12 -4
  46. package/src/plugins/table/commands/toggle.ts +17 -4
  47. package/src/plugins/table/index.tsx +17 -1
  48. package/src/plugins/table/nodeviews/TableComponent.tsx +99 -2
  49. package/src/plugins/table/nodeviews/TableResizer.tsx +6 -0
  50. package/src/plugins/table/pm-plugins/table-analytics.ts +102 -0
  51. package/src/plugins/table/pm-plugins/table-resizing/commands.ts +10 -4
  52. package/src/plugins/table/pm-plugins/table-resizing/event-handlers.ts +10 -0
  53. package/src/plugins/table/transforms/delete-columns.ts +12 -4
  54. package/src/plugins/table/ui/ui-styles.ts +1 -1
@@ -13,15 +13,18 @@ import React from 'react';
13
13
  import classnames from 'classnames';
14
14
  import memoizeOne from 'memoize-one';
15
15
  import rafSchedule from 'raf-schd';
16
+ import { ACTION_SUBJECT, EVENT_TYPE, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
17
+ import { createDispatch } from '@atlaskit/editor-common/event-dispatcher';
16
18
  import { getParentNodeWidth } from '@atlaskit/editor-common/node-width';
17
19
  import { tableMarginSides } from '@atlaskit/editor-common/styles';
18
- import { browser, isValidPosition } from '@atlaskit/editor-common/utils';
20
+ import { analyticsEventKey, browser, isValidPosition } from '@atlaskit/editor-common/utils';
19
21
  import { akEditorTableToolbarSize as tableToolbarSize } from '@atlaskit/editor-shared-styles';
20
22
  import { findTable, isTableSelected } from '@atlaskit/editor-tables/utils';
21
23
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
22
24
  import { autoSizeTable, clearHoverSelection } from '../commands';
23
25
  import { getPluginState } from '../pm-plugins/plugin-factory';
24
26
  import { findStickyHeaderForTable, pluginKey as stickyHeadersPluginKey } from '../pm-plugins/sticky-headers';
27
+ import { META_KEYS } from '../pm-plugins/table-analytics';
25
28
  import { getLayoutSize, insertColgroupFromNode as recreateResizeColsByNode, scaleTable } from '../pm-plugins/table-resizing/utils';
26
29
  import { hasTableBeenResized } from '../pm-plugins/table-resizing/utils/colgroup';
27
30
  import { updateControls } from '../pm-plugins/table-resizing/utils/dom';
@@ -32,6 +35,10 @@ import { containsHeaderRow, isTableNested, tablesHaveDifferentColumnWidths, tabl
32
35
  import { OverflowShadowsObserver } from './OverflowShadowsObserver';
33
36
  import { TableContainer } from './TableContainer';
34
37
  var isIE11 = browser.ie_version === 11;
38
+ // When table is inserted via paste, keyboard shortcut or quickInsert,
39
+ // componentDidUpdate is called multiple times. The isOverflowing value is correct only on the last update.
40
+ // To make sure we capture the last update, we use setTimeout.
41
+ var initialOverflowCaptureTimeroutDelay = 300;
35
42
  var TableComponent = /*#__PURE__*/function (_React$Component) {
36
43
  _inherits(TableComponent, _React$Component);
37
44
  var _super = _createSuper(TableComponent);
@@ -169,13 +176,40 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
169
176
  }, options), domAtPos)(state.tr);
170
177
  dispatch(tr);
171
178
  });
179
+ _defineProperty(_assertThisInitialized(_this), "setTimerToSendInitialOverflowCaptured", function (isOverflowing) {
180
+ var _this$state;
181
+ var _this$props3 = _this.props,
182
+ eventDispatcher = _this$props3.eventDispatcher,
183
+ containerWidth = _this$props3.containerWidth,
184
+ options = _this$props3.options;
185
+ var dispatch = createDispatch(eventDispatcher);
186
+ var parentWidth = ((_this$state = _this.state) === null || _this$state === void 0 ? void 0 : _this$state.parentWidth) || 0;
187
+ _this.initialOverflowCaptureTimerId = setTimeout(function () {
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: isOverflowing,
197
+ tableResizingEnabled: (options === null || options === void 0 ? void 0 : options.isTableResizingEnabled) || false,
198
+ width: _this.node.attrs.width || 0,
199
+ parentWidth: parentWidth
200
+ }
201
+ }
202
+ });
203
+ _this.isInitialOverflowSent = true;
204
+ }, initialOverflowCaptureTimeroutDelay);
205
+ });
172
206
  _defineProperty(_assertThisInitialized(_this), "handleAutoSize", function () {
173
207
  if (_this.table) {
174
- var _this$props3 = _this.props,
175
- view = _this$props3.view,
176
- getNode = _this$props3.getNode,
177
- getPos = _this$props3.getPos,
178
- containerWidth = _this$props3.containerWidth;
208
+ var _this$props4 = _this.props,
209
+ view = _this$props4.view,
210
+ getNode = _this$props4.getNode,
211
+ getPos = _this$props4.getPos,
212
+ containerWidth = _this$props4.containerWidth;
179
213
  var _node = getNode();
180
214
  var pos = getPos();
181
215
  if (!isValidPosition(pos, view.state)) {
@@ -188,9 +222,9 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
188
222
  });
189
223
  _defineProperty(_assertThisInitialized(_this), "handleWindowResize", function () {
190
224
  var _node$attrs, _node$attrs2;
191
- var _this$props4 = _this.props,
192
- getNode = _this$props4.getNode,
193
- containerWidth = _this$props4.containerWidth;
225
+ var _this$props5 = _this.props,
226
+ getNode = _this$props5.getNode,
227
+ containerWidth = _this$props5.containerWidth;
194
228
  var node = getNode();
195
229
  var prevNode = _this.node;
196
230
  var layoutSize = _this.tableNodeLayoutSize(node);
@@ -206,11 +240,11 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
206
240
  });
207
241
  });
208
242
  _defineProperty(_assertThisInitialized(_this), "getParentNodeWidth", function () {
209
- var _this$props5 = _this.props,
210
- getPos = _this$props5.getPos,
211
- containerWidth = _this$props5.containerWidth,
212
- options = _this$props5.options,
213
- state = _this$props5.view.state;
243
+ var _this$props6 = _this.props,
244
+ getPos = _this$props6.getPos,
245
+ containerWidth = _this$props6.containerWidth,
246
+ options = _this$props6.options,
247
+ state = _this$props6.view.state;
214
248
  var pos = getPos();
215
249
  if (!isValidPosition(pos, state)) {
216
250
  return;
@@ -236,6 +270,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
236
270
  _getNode = props.getNode;
237
271
  _this.node = _getNode();
238
272
  _this.containerWidth = _containerWidth;
273
+ _this.isInitialOverflowSent = false;
239
274
 
240
275
  // store table size using previous full-width mode so can detect if it has changed
241
276
  var isFullWidthModeEnabled = _options ? _options.wasFullWidthModeEnabled : false;
@@ -257,10 +292,10 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
257
292
  _createClass(TableComponent, [{
258
293
  key: "componentDidMount",
259
294
  value: function componentDidMount() {
260
- var _this$props6 = this.props,
261
- allowColumnResizing = _this$props6.allowColumnResizing,
262
- eventDispatcher = _this$props6.eventDispatcher,
263
- options = _this$props6.options;
295
+ var _this$props7 = this.props,
296
+ allowColumnResizing = _this$props7.allowColumnResizing,
297
+ eventDispatcher = _this$props7.eventDispatcher,
298
+ options = _this$props7.options;
264
299
  if (allowColumnResizing && this.wrapper && !isIE11) {
265
300
  this.wrapper.addEventListener('scroll', this.handleScrollDebounced);
266
301
  }
@@ -279,14 +314,18 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
279
314
  this.onStickyState(currentStickyState);
280
315
  }
281
316
  eventDispatcher.on(stickyHeadersPluginKey.key, this.onStickyState);
317
+ if (getBooleanFF('platform.editor.table.overflow-state-analytics')) {
318
+ var initialIsOveflowing = this.state[ShadowEvent.SHOW_BEFORE_SHADOW] || this.state[ShadowEvent.SHOW_AFTER_SHADOW];
319
+ this.setTimerToSendInitialOverflowCaptured(initialIsOveflowing);
320
+ }
282
321
  }
283
322
  }, {
284
323
  key: "componentWillUnmount",
285
324
  value: function componentWillUnmount() {
286
- var _this$props7 = this.props,
287
- allowColumnResizing = _this$props7.allowColumnResizing,
288
- eventDispatcher = _this$props7.eventDispatcher,
289
- options = _this$props7.options;
325
+ var _this$props8 = this.props,
326
+ allowColumnResizing = _this$props8.allowColumnResizing,
327
+ eventDispatcher = _this$props8.eventDispatcher,
328
+ options = _this$props8.options;
290
329
  if (this.wrapper && !isIE11) {
291
330
  this.wrapper.removeEventListener('scroll', this.handleScrollDebounced);
292
331
  }
@@ -304,18 +343,21 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
304
343
  this.overflowShadowsObserver.dispose();
305
344
  }
306
345
  eventDispatcher.off(stickyHeadersPluginKey.key, this.onStickyState);
346
+ if (this.initialOverflowCaptureTimerId) {
347
+ clearTimeout(this.initialOverflowCaptureTimerId);
348
+ }
307
349
  }
308
350
  }, {
309
351
  key: "componentDidUpdate",
310
- value: function componentDidUpdate() {
352
+ value: function componentDidUpdate(_, prevState) {
311
353
  var _this$wrapper;
312
- var _this$props8 = this.props,
313
- view = _this$props8.view,
314
- getNode = _this$props8.getNode,
315
- isMediaFullscreen = _this$props8.isMediaFullscreen,
316
- allowColumnResizing = _this$props8.allowColumnResizing,
317
- isResizing = _this$props8.isResizing,
318
- options = _this$props8.options;
354
+ var _this$props9 = this.props,
355
+ view = _this$props9.view,
356
+ getNode = _this$props9.getNode,
357
+ isMediaFullscreen = _this$props9.isMediaFullscreen,
358
+ allowColumnResizing = _this$props9.allowColumnResizing,
359
+ isResizing = _this$props9.isResizing,
360
+ options = _this$props9.options;
319
361
  var _getPluginState = getPluginState(view.state),
320
362
  isInDanger = _getPluginState.isInDanger;
321
363
  var table = findTable(view.state.selection);
@@ -350,29 +392,52 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
350
392
  }
351
393
  this.handleTableResizingDebounced();
352
394
  }
395
+ if (getBooleanFF('platform.editor.table.overflow-state-analytics')) {
396
+ var newIsOverflowing = this.state[ShadowEvent.SHOW_BEFORE_SHADOW] || this.state[ShadowEvent.SHOW_AFTER_SHADOW];
397
+ var prevIsOverflowing = prevState[ShadowEvent.SHOW_BEFORE_SHADOW] || prevState[ShadowEvent.SHOW_AFTER_SHADOW];
398
+ if (this.initialOverflowCaptureTimerId) {
399
+ clearTimeout(this.initialOverflowCaptureTimerId);
400
+ }
401
+ if (!this.isInitialOverflowSent) {
402
+ this.setTimerToSendInitialOverflowCaptured(newIsOverflowing);
403
+ }
404
+ if (this.isInitialOverflowSent && prevIsOverflowing !== newIsOverflowing) {
405
+ var _this$state2;
406
+ var _this$props$view = this.props.view,
407
+ dispatch = _this$props$view.dispatch,
408
+ tr = _this$props$view.state.tr;
409
+ dispatch(tr.setMeta(META_KEYS.OVERFLOW_STATE_CHANGED, {
410
+ isOverflowing: newIsOverflowing,
411
+ wasOverflowing: prevIsOverflowing,
412
+ editorWidth: this.props.containerWidth.width || 0,
413
+ width: this.node.attrs.width || 0,
414
+ parentWidth: ((_this$state2 = this.state) === null || _this$state2 === void 0 ? void 0 : _this$state2.parentWidth) || 0
415
+ }));
416
+ }
417
+ }
353
418
  }
354
419
  }, {
355
420
  key: "render",
356
421
  value: function render() {
357
422
  var _classnames,
358
423
  _this2 = this;
359
- var _this$props9 = this.props,
360
- view = _this$props9.view,
361
- getNode = _this$props9.getNode,
362
- isResizing = _this$props9.isResizing,
363
- _this$props9$allowCon = _this$props9.allowControls,
364
- allowControls = _this$props9$allowCon === void 0 ? true : _this$props9$allowCon,
365
- isHeaderRowEnabled = _this$props9.isHeaderRowEnabled,
366
- ordering = _this$props9.ordering,
367
- isHeaderColumnEnabled = _this$props9.isHeaderColumnEnabled,
368
- tableActive = _this$props9.tableActive,
369
- containerWidth = _this$props9.containerWidth,
370
- options = _this$props9.options,
371
- getPos = _this$props9.getPos,
372
- pluginInjectionApi = _this$props9.pluginInjectionApi;
373
- var _this$state = this.state,
374
- showBeforeShadow = _this$state.showBeforeShadow,
375
- showAfterShadow = _this$state.showAfterShadow;
424
+ var _this$props10 = this.props,
425
+ view = _this$props10.view,
426
+ getNode = _this$props10.getNode,
427
+ isResizing = _this$props10.isResizing,
428
+ _this$props10$allowCo = _this$props10.allowControls,
429
+ allowControls = _this$props10$allowCo === void 0 ? true : _this$props10$allowCo,
430
+ isHeaderRowEnabled = _this$props10.isHeaderRowEnabled,
431
+ ordering = _this$props10.ordering,
432
+ isHeaderColumnEnabled = _this$props10.isHeaderColumnEnabled,
433
+ tableActive = _this$props10.tableActive,
434
+ containerWidth = _this$props10.containerWidth,
435
+ options = _this$props10.options,
436
+ getPos = _this$props10.getPos,
437
+ pluginInjectionApi = _this$props10.pluginInjectionApi;
438
+ var _this$state3 = this.state,
439
+ showBeforeShadow = _this$state3.showBeforeShadow,
440
+ showAfterShadow = _this$state3.showAfterShadow;
376
441
  var node = getNode();
377
442
  // doesn't work well with WithPluginState
378
443
  var _getPluginState2 = getPluginState(view.state),
@@ -5,11 +5,13 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
5
5
  import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
6
6
  import rafSchd from 'raf-schd';
7
7
  import { defineMessages, useIntl } from 'react-intl-next';
8
+ import { TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
8
9
  import { getGuidelinesWithHighlights } from '@atlaskit/editor-common/guideline';
9
10
  import { ResizerNext } from '@atlaskit/editor-common/resizer';
10
11
  import { findTable } from '@atlaskit/editor-tables/utils';
11
12
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
12
13
  import { getPluginState } from '../pm-plugins/plugin-factory';
14
+ import { META_KEYS } from '../pm-plugins/table-analytics';
13
15
  import { COLUMN_MIN_WIDTH, getColgroupChildrenLength, previewScaleTable, scaleTable } from '../pm-plugins/table-resizing/utils';
14
16
  import { pluginKey as tableWidthPluginKey } from '../pm-plugins/table-width';
15
17
  import { TABLE_HIGHLIGHT_GAP, TABLE_HIGHLIGHT_TOLERANCE, TABLE_SNAP_GAP } from '../ui/consts';
@@ -135,6 +137,9 @@ export var TableResizer = function TableResizer(_ref) {
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
  var visibleGuidelines = getVisibleGuidelines(defaultGuidelines, containerWidth);
140
145
  setSnappingEnabled(displayGuideline(visibleGuidelines));
@@ -0,0 +1,75 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ 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; }
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
+ /**
5
+ * A plugin is created for collecting payload data for tableOverflowChanged analytics event
6
+ */
7
+ import { ACTION_SUBJECT, EVENT_TYPE, TABLE_ACTION, TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
8
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
9
+ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
10
+ export var pluginKey = new PluginKey('tableAnalyticsPlugin');
11
+ export var META_KEYS = {
12
+ OVERFLOW_TRIGGER: 'tableOverflowTrigger',
13
+ OVERFLOW_STATE_CHANGED: 'tableOverflowStateChanged'
14
+ };
15
+ var createPlugin = function createPlugin(dispatch, dispatchAnalyticsEvent, tableResizingEnabled) {
16
+ return new SafePlugin({
17
+ key: pluginKey,
18
+ state: {
19
+ init: function init() {
20
+ return {
21
+ lastTrigger: undefined
22
+ };
23
+ },
24
+ apply: function apply(tr, pluginState) {
25
+ var meta = tr.getMeta(META_KEYS.OVERFLOW_TRIGGER);
26
+ var newState = _objectSpread({}, pluginState);
27
+ if (meta) {
28
+ newState.lastTrigger = _objectSpread({}, meta);
29
+ dispatch(pluginKey, newState);
30
+ return newState;
31
+ }
32
+ return pluginState;
33
+ }
34
+ },
35
+ appendTransaction: function appendTransaction(transactions, oldState, newState) {
36
+ var _newPluginState$lastT;
37
+ var newPluginState = pluginKey.getState(newState);
38
+ var hasAnalyticsBeenDispatched = false;
39
+ var 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(function (tr) {
47
+ var 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: tableResizingEnabled,
61
+ trigger: lastTriggerName
62
+ }
63
+ });
64
+ hasAnalyticsBeenDispatched = true;
65
+ }
66
+ });
67
+ if (hasAnalyticsBeenDispatched) {
68
+ var tr = newState.tr;
69
+ return tr.setMeta(META_KEYS.OVERFLOW_TRIGGER, {});
70
+ }
71
+ return undefined;
72
+ }
73
+ });
74
+ };
75
+ 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 var evenColumns = function evenColumns(_ref) {
@@ -36,6 +38,9 @@ export var distributeColumnsWidths = function distributeColumnsWidths(newResizeS
36
38
  return function (state, dispatch) {
37
39
  if (dispatch) {
38
40
  var _tr = updateColumnWidths(newResizeState, table.node, table.start)(state.tr);
41
+ _tr.setMeta(META_KEYS.OVERFLOW_TRIGGER, {
42
+ name: TABLE_OVERFLOW_CHANGE_TRIGGER.DISTRIBUTED_COLUMNS
43
+ });
39
44
  stopResizing(_tr)(state, dispatch);
40
45
  }
41
46
  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';
@@ -20,6 +21,13 @@ export var handleMouseDown = function handleMouseDown(view, event, localResizeHa
20
21
  return false;
21
22
  }
22
23
  event.preventDefault();
24
+ if (getBooleanFF('platform.editor.table.overflow-state-analytics')) {
25
+ var tr = view.state.tr;
26
+ tr.setMeta(META_KEYS.OVERFLOW_TRIGGER, {
27
+ name: TABLE_OVERFLOW_CHANGE_TRIGGER.RESIZED_COLUMN
28
+ });
29
+ dispatch(tr);
30
+ }
23
31
  var mouseDownTime = event.timeStamp;
24
32
  var cell = state.doc.nodeAt(localResizeHandlePos);
25
33
  var $cell = state.doc.resolve(localResizeHandlePos);
@@ -3,9 +3,11 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  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; }
4
4
  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; }
5
5
  import { AddColumnStep } from '@atlaskit/adf-schema/steps';
6
+ import { TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
6
7
  import { Selection } from '@atlaskit/editor-prosemirror/state';
7
8
  import { TableMap } from '@atlaskit/editor-tables/table-map';
8
9
  import { findTable } from '@atlaskit/editor-tables/utils';
10
+ import { META_KEYS } from '../pm-plugins/table-analytics';
9
11
  import { splitCellsInColumns } from './split';
10
12
  var deleteColumnsCustomStep = function deleteColumnsCustomStep(rect) {
11
13
  return function (tr) {
@@ -203,6 +205,9 @@ function fixRowSpans(table) {
203
205
  export var deleteColumns = function deleteColumns(rect) {
204
206
  var allowAddColumnCustomStep = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
205
207
  return function (tr) {
208
+ tr.setMeta(META_KEYS.OVERFLOW_TRIGGER, {
209
+ name: TABLE_OVERFLOW_CHANGE_TRIGGER.DELETED_COLUMN
210
+ });
206
211
  if (allowAddColumnCustomStep) {
207
212
  return deleteColumnsCustomStep(rect)(tr);
208
213
  }
@@ -72,7 +72,7 @@ export var hoveredWarningCell = css(_templateObject21 || (_templateObject21 = _t
72
72
 
73
73
  // move the resize handle zone completely inside the table cell to avoid overflow
74
74
  var getLastColumnResizerOverrides = function getLastColumnResizerOverrides() {
75
- return getBooleanFF('platform.editor.custom-table-width') ? css(_templateObject22 || (_templateObject22 = _taggedTemplateLiteral(["\n tr\n th:last-child\n .", ",\n tr\n td:last-child\n .", " {\n background-color: transparent;\n position: absolute;\n width: ", "px;\n height: 100%;\n top: 0;\n right: 0;\n cursor: col-resize;\n z-index: ", ";\n }\n "])), ClassName.RESIZE_HANDLE_DECORATION, ClassName.RESIZE_HANDLE_DECORATION, resizeHandlerAreaWidth, resizeHandlerZIndex) : '';
75
+ return getBooleanFF('platform.editor.custom-table-width') ? css(_templateObject22 || (_templateObject22 = _taggedTemplateLiteral(["\n tr\n th:last-child\n .", ",\n tr\n td:last-child\n .", " {\n background-color: transparent;\n position: absolute;\n width: ", "px;\n height: 100%;\n top: 0;\n right: 0;\n cursor: col-resize;\n z-index: ", ";\n }\n "])), ClassName.RESIZE_HANDLE_DECORATION, ClassName.RESIZE_HANDLE_DECORATION, resizeHandlerAreaWidth / 2, resizeHandlerZIndex) : '';
76
76
  };
77
77
  export var resizeHandle = function resizeHandle(props) {
78
78
  return css(_templateObject23 || (_templateObject23 = _taggedTemplateLiteral(["\n .", " {\n .", " {\n background-color: transparent;\n position: absolute;\n width: ", "px;\n height: 100%;\n top: 0;\n right: -", "px;\n cursor: col-resize;\n z-index: ", ";\n }\n\n ", "\n\n td.", "::before {\n content: ' ';\n position: absolute;\n left: ", ";\n top: -1px;\n width: ", "px;\n height: calc(100% + 2px);\n background-color: ", ";\n z-index: ", ";\n }\n\n th.", "::before {\n content: ' ';\n left: ", ";\n position: absolute;\n width: ", "px;\n height: calc(100% + ", "px);\n background-color: ", ";\n z-index: ", ";\n top: -", "px;\n }\n\n td.", "::before {\n content: ' ';\n position: absolute;\n right: -1px;\n top: -1px;\n width: ", "px;\n height: calc(100% + 2px);\n background-color: ", ";\n z-index: ", ";\n }\n\n th.", "::before {\n content: ' ';\n right: -1px;\n position: absolute;\n width: ", "px;\n height: calc(100% + ", "px);\n background-color: ", ";\n z-index: ", ";\n top: -", "px;\n }\n\n table\n tr:first-of-type\n th.", "\n .", "::after,\n table\n tr:first-of-type\n td.", "\n .", "::after {\n top: -", "px;\n height: calc(100% + ", "px);\n }\n }\n"])), ClassName.TABLE_CONTAINER, ClassName.RESIZE_HANDLE_DECORATION, resizeHandlerAreaWidth, resizeHandlerAreaWidth / 2, resizeHandlerZIndex, getLastColumnResizerOverrides(), ClassName.WITH_RESIZE_LINE, "var(--ds-space-negative-025, -2px)", resizeLineWidth, tableBorderSelectedColor(props), columnControlsZIndex * 2, ClassName.WITH_RESIZE_LINE, "var(--ds-space-negative-025, -2px)", resizeLineWidth, tableToolbarSize + tableCellBorderWidth, tableBorderSelectedColor(props), columnControlsZIndex * 2, tableToolbarSize + tableCellBorderWidth, ClassName.WITH_RESIZE_LINE_LAST_COLUMN, resizeLineWidth, tableBorderSelectedColor(props), columnControlsZIndex * 2, ClassName.WITH_RESIZE_LINE_LAST_COLUMN, resizeLineWidth, tableToolbarSize + tableCellBorderWidth, tableBorderSelectedColor(props), columnControlsZIndex * 2, tableToolbarSize + tableCellBorderWidth, ClassName.WITH_RESIZE_LINE, ClassName.RESIZE_HANDLE_DECORATION, ClassName.WITH_RESIZE_LINE, ClassName.RESIZE_HANDLE_DECORATION, tableToolbarSize + tableCellBorderWidth, tableToolbarSize + tableCellBorderWidth);
@@ -1,7 +1,6 @@
1
- import { Command } from '@atlaskit/editor-common/types';
2
- import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
3
- import { Transaction } from '@atlaskit/editor-prosemirror/state';
4
- import { EditorView } from '@atlaskit/editor-prosemirror/view';
1
+ import type { Command, GetEditorContainerWidth } from '@atlaskit/editor-common/types';
2
+ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
3
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
5
4
  export declare function addColumnAt(getEditorContainerWidth: GetEditorContainerWidth): (column: number, allowAddColumnCustomStep: boolean | undefined, view: EditorView | undefined) => (tr: Transaction) => Transaction;
6
5
  export declare const addColumnBefore: (getEditorContainerWidth: GetEditorContainerWidth) => Command;
7
6
  export declare const addColumnAfter: (getEditorContainerWidth: GetEditorContainerWidth) => Command;
@@ -1,5 +1,5 @@
1
- import { TableLayout } from '@atlaskit/adf-schema';
2
- import { Command } from '@atlaskit/editor-common/types';
1
+ import type { TableLayout } from '@atlaskit/adf-schema';
2
+ import type { Command } from '@atlaskit/editor-common/types';
3
3
  /**
4
4
  * Table layout toggle logic
5
5
  * default -> wide -> full-width -> default
@@ -43,10 +43,12 @@ declare class TableComponent extends React.Component<ComponentProps, TableState>
43
43
  private containerWidth?;
44
44
  private layoutSize?;
45
45
  private overflowShadowsObserver?;
46
+ private isInitialOverflowSent;
47
+ private initialOverflowCaptureTimerId?;
46
48
  constructor(props: ComponentProps);
47
49
  componentDidMount(): void;
48
50
  componentWillUnmount(): void;
49
- componentDidUpdate(): void;
51
+ componentDidUpdate(_: any, prevState: TableState): void;
50
52
  private updateShadowState;
51
53
  private createShadowSentinels;
52
54
  onStickyState: (state: StickyPluginState) => void;
@@ -55,6 +57,7 @@ declare class TableComponent extends React.Component<ComponentProps, TableState>
55
57
  private handleScroll;
56
58
  private handleTableResizing;
57
59
  private scaleTable;
60
+ private setTimerToSendInitialOverflowCaptured;
58
61
  private handleAutoSize;
59
62
  private handleWindowResize;
60
63
  private getParentNodeWidth;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * A plugin is created for collecting payload data for tableOverflowChanged analytics event
3
+ */
4
+ import { TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
5
+ import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
6
+ import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
7
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
8
+ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
9
+ interface LastTrigger {
10
+ name: TABLE_OVERFLOW_CHANGE_TRIGGER;
11
+ }
12
+ type TableAnalyticsPluginState = {
13
+ lastTrigger: LastTrigger | undefined;
14
+ };
15
+ export declare const pluginKey: PluginKey<TableAnalyticsPluginState>;
16
+ export declare const META_KEYS: {
17
+ OVERFLOW_TRIGGER: string;
18
+ OVERFLOW_STATE_CHANGED: string;
19
+ };
20
+ declare const createPlugin: (dispatch: Dispatch, dispatchAnalyticsEvent: DispatchAnalyticsEvent, tableResizingEnabled: boolean) => SafePlugin<{
21
+ lastTrigger: undefined;
22
+ }>;
23
+ export { createPlugin };
@@ -1,8 +1,8 @@
1
1
  import type { Command } from '@atlaskit/editor-common/types';
2
- import { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
3
- import { Transaction } from '@atlaskit/editor-prosemirror/state';
4
- import { ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
5
- import { ResizeState } from './utils';
2
+ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
3
+ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
4
+ import type { ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
5
+ import type { ResizeState } from './utils';
6
6
  export declare const evenColumns: ({ resizeState, table, start, event, }: {
7
7
  resizeState: ResizeState;
8
8
  table: PMNode;
@@ -1,3 +1,3 @@
1
- import { Transaction } from '@atlaskit/editor-prosemirror/state';
2
- import { Rect } from '@atlaskit/editor-tables/table-map';
1
+ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
2
+ import type { Rect } from '@atlaskit/editor-tables/table-map';
3
3
  export declare const deleteColumns: (rect: Rect, allowAddColumnCustomStep?: boolean) => (tr: Transaction) => Transaction;
@@ -1,7 +1,6 @@
1
- import { Command } from '@atlaskit/editor-common/types';
2
- import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
3
- import { Transaction } from '@atlaskit/editor-prosemirror/state';
4
- import { EditorView } from '@atlaskit/editor-prosemirror/view';
1
+ import type { Command, GetEditorContainerWidth } from '@atlaskit/editor-common/types';
2
+ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
3
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
5
4
  export declare function addColumnAt(getEditorContainerWidth: GetEditorContainerWidth): (column: number, allowAddColumnCustomStep: boolean | undefined, view: EditorView | undefined) => (tr: Transaction) => Transaction;
6
5
  export declare const addColumnBefore: (getEditorContainerWidth: GetEditorContainerWidth) => Command;
7
6
  export declare const addColumnAfter: (getEditorContainerWidth: GetEditorContainerWidth) => Command;
@@ -1,5 +1,5 @@
1
- import { TableLayout } from '@atlaskit/adf-schema';
2
- import { Command } from '@atlaskit/editor-common/types';
1
+ import type { TableLayout } from '@atlaskit/adf-schema';
2
+ import type { Command } from '@atlaskit/editor-common/types';
3
3
  /**
4
4
  * Table layout toggle logic
5
5
  * default -> wide -> full-width -> default
@@ -43,10 +43,12 @@ declare class TableComponent extends React.Component<ComponentProps, TableState>
43
43
  private containerWidth?;
44
44
  private layoutSize?;
45
45
  private overflowShadowsObserver?;
46
+ private isInitialOverflowSent;
47
+ private initialOverflowCaptureTimerId?;
46
48
  constructor(props: ComponentProps);
47
49
  componentDidMount(): void;
48
50
  componentWillUnmount(): void;
49
- componentDidUpdate(): void;
51
+ componentDidUpdate(_: any, prevState: TableState): void;
50
52
  private updateShadowState;
51
53
  private createShadowSentinels;
52
54
  onStickyState: (state: StickyPluginState) => void;
@@ -55,6 +57,7 @@ declare class TableComponent extends React.Component<ComponentProps, TableState>
55
57
  private handleScroll;
56
58
  private handleTableResizing;
57
59
  private scaleTable;
60
+ private setTimerToSendInitialOverflowCaptured;
58
61
  private handleAutoSize;
59
62
  private handleWindowResize;
60
63
  private getParentNodeWidth;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * A plugin is created for collecting payload data for tableOverflowChanged analytics event
3
+ */
4
+ import { TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
5
+ import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
6
+ import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
7
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
8
+ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
9
+ interface LastTrigger {
10
+ name: TABLE_OVERFLOW_CHANGE_TRIGGER;
11
+ }
12
+ type TableAnalyticsPluginState = {
13
+ lastTrigger: LastTrigger | undefined;
14
+ };
15
+ export declare const pluginKey: PluginKey<TableAnalyticsPluginState>;
16
+ export declare const META_KEYS: {
17
+ OVERFLOW_TRIGGER: string;
18
+ OVERFLOW_STATE_CHANGED: string;
19
+ };
20
+ declare const createPlugin: (dispatch: Dispatch, dispatchAnalyticsEvent: DispatchAnalyticsEvent, tableResizingEnabled: boolean) => SafePlugin<{
21
+ lastTrigger: undefined;
22
+ }>;
23
+ export { createPlugin };
@@ -1,8 +1,8 @@
1
1
  import type { Command } from '@atlaskit/editor-common/types';
2
- import { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
3
- import { Transaction } from '@atlaskit/editor-prosemirror/state';
4
- import { ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
5
- import { ResizeState } from './utils';
2
+ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
3
+ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
4
+ import type { ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
5
+ import type { ResizeState } from './utils';
6
6
  export declare const evenColumns: ({ resizeState, table, start, event, }: {
7
7
  resizeState: ResizeState;
8
8
  table: PMNode;
@@ -1,3 +1,3 @@
1
- import { Transaction } from '@atlaskit/editor-prosemirror/state';
2
- import { Rect } from '@atlaskit/editor-tables/table-map';
1
+ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
2
+ import type { Rect } from '@atlaskit/editor-tables/table-map';
3
3
  export declare const deleteColumns: (rect: Rect, allowAddColumnCustomStep?: boolean) => (tr: Transaction) => Transaction;