@atlaskit/editor-plugin-table 3.0.5 → 3.1.1

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 (64) hide show
  1. package/CHANGELOG.md +16 -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 +112 -47
  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/common-styles.js +1 -1
  12. package/dist/cjs/plugins/table/ui/consts.js +3 -1
  13. package/dist/cjs/plugins/table/ui/ui-styles.js +1 -1
  14. package/dist/es2019/plugins/table/commands/insert.js +5 -0
  15. package/dist/es2019/plugins/table/commands/toggle.js +11 -1
  16. package/dist/es2019/plugins/table/index.js +12 -0
  17. package/dist/es2019/plugins/table/nodeviews/TableComponent.js +73 -4
  18. package/dist/es2019/plugins/table/nodeviews/TableResizer.js +5 -0
  19. package/dist/es2019/plugins/table/pm-plugins/table-analytics.js +74 -0
  20. package/dist/es2019/plugins/table/pm-plugins/table-resizing/commands.js +5 -0
  21. package/dist/es2019/plugins/table/pm-plugins/table-resizing/event-handlers.js +9 -1
  22. package/dist/es2019/plugins/table/transforms/delete-columns.js +5 -0
  23. package/dist/es2019/plugins/table/ui/common-styles.js +4 -1
  24. package/dist/es2019/plugins/table/ui/consts.js +1 -0
  25. package/dist/es2019/plugins/table/ui/ui-styles.js +7 -5
  26. package/dist/esm/plugins/table/commands/insert.js +5 -0
  27. package/dist/esm/plugins/table/commands/toggle.js +11 -1
  28. package/dist/esm/plugins/table/index.js +37 -26
  29. package/dist/esm/plugins/table/nodeviews/TableComponent.js +114 -49
  30. package/dist/esm/plugins/table/nodeviews/TableResizer.js +5 -0
  31. package/dist/esm/plugins/table/pm-plugins/table-analytics.js +75 -0
  32. package/dist/esm/plugins/table/pm-plugins/table-resizing/commands.js +5 -0
  33. package/dist/esm/plugins/table/pm-plugins/table-resizing/event-handlers.js +9 -1
  34. package/dist/esm/plugins/table/transforms/delete-columns.js +5 -0
  35. package/dist/esm/plugins/table/ui/common-styles.js +2 -2
  36. package/dist/esm/plugins/table/ui/consts.js +1 -0
  37. package/dist/esm/plugins/table/ui/ui-styles.js +2 -2
  38. package/dist/types/plugins/table/commands/insert.d.ts +3 -4
  39. package/dist/types/plugins/table/commands/toggle.d.ts +2 -2
  40. package/dist/types/plugins/table/nodeviews/TableComponent.d.ts +4 -1
  41. package/dist/types/plugins/table/pm-plugins/table-analytics.d.ts +23 -0
  42. package/dist/types/plugins/table/pm-plugins/table-resizing/commands.d.ts +4 -4
  43. package/dist/types/plugins/table/transforms/delete-columns.d.ts +2 -2
  44. package/dist/types/plugins/table/ui/consts.d.ts +1 -0
  45. package/dist/types-ts4.5/plugins/table/commands/insert.d.ts +3 -4
  46. package/dist/types-ts4.5/plugins/table/commands/toggle.d.ts +2 -2
  47. package/dist/types-ts4.5/plugins/table/nodeviews/TableComponent.d.ts +4 -1
  48. package/dist/types-ts4.5/plugins/table/pm-plugins/table-analytics.d.ts +23 -0
  49. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/commands.d.ts +4 -4
  50. package/dist/types-ts4.5/plugins/table/transforms/delete-columns.d.ts +2 -2
  51. package/dist/types-ts4.5/plugins/table/ui/consts.d.ts +1 -0
  52. package/package.json +8 -2
  53. package/src/plugins/table/commands/insert.ts +12 -4
  54. package/src/plugins/table/commands/toggle.ts +17 -4
  55. package/src/plugins/table/index.tsx +17 -1
  56. package/src/plugins/table/nodeviews/TableComponent.tsx +110 -4
  57. package/src/plugins/table/nodeviews/TableResizer.tsx +6 -0
  58. package/src/plugins/table/pm-plugins/table-analytics.ts +102 -0
  59. package/src/plugins/table/pm-plugins/table-resizing/commands.ts +10 -4
  60. package/src/plugins/table/pm-plugins/table-resizing/event-handlers.ts +10 -0
  61. package/src/plugins/table/transforms/delete-columns.ts +12 -4
  62. package/src/plugins/table/ui/common-styles.ts +4 -0
  63. package/src/plugins/table/ui/consts.ts +1 -0
  64. package/src/plugins/table/ui/ui-styles.ts +28 -5
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 3.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`05b9c2db1dc`](https://bitbucket.org/atlassian/atlassian-frontend/commits/05b9c2db1dc) - [ux] Increase visibility of table scroll shadows
8
+
9
+ ## 3.1.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [`20d1964ba9d`](https://bitbucket.org/atlassian/atlassian-frontend/commits/20d1964ba9d) - Adds a new table-analytics plugin to collect payload information and dispatch a new tableOverflowChanged event
14
+
15
+ ### Patch Changes
16
+
17
+ - Updated dependencies
18
+
3
19
  ## 3.0.5
4
20
 
5
21
  ### Patch Changes
@@ -7,10 +7,12 @@ exports.addColumnAfter = void 0;
7
7
  exports.addColumnAt = addColumnAt;
8
8
  exports.insertRow = exports.insertColumn = exports.createTable = exports.addColumnBefore = void 0;
9
9
  var _steps = require("@atlaskit/adf-schema/steps");
10
+ var _analytics = require("@atlaskit/editor-common/analytics");
10
11
  var _state = require("@atlaskit/editor-prosemirror/state");
11
12
  var _utils = require("@atlaskit/editor-prosemirror/utils");
12
13
  var _tableMap = require("@atlaskit/editor-tables/table-map");
13
14
  var _utils2 = require("@atlaskit/editor-tables/utils");
15
+ var _tableAnalytics = require("../pm-plugins/table-analytics");
14
16
  var _columnWidth = require("../transforms/column-width");
15
17
  var _utils3 = require("../utils");
16
18
  var _getAllowAddColumnCustomStep = require("../utils/get-allow-add-column-custom-step");
@@ -43,6 +45,9 @@ function addColumnAt(getEditorContainerWidth) {
43
45
  // [ED-8288] Update colwidths manually to avoid multiple dispatch in TableComponent
44
46
  updatedTr = (0, _columnWidth.rescaleColumns)(getEditorContainerWidth)(table, view)(updatedTr);
45
47
  }
48
+ updatedTr.setMeta(_tableAnalytics.META_KEYS.OVERFLOW_TRIGGER, {
49
+ name: _analytics.TABLE_OVERFLOW_CHANGE_TRIGGER.ADDED_COLUMN
50
+ });
46
51
  return updatedTr;
47
52
  };
48
53
  };
@@ -6,8 +6,10 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.toggleTableLayout = exports.toggleNumberColumn = exports.toggleHeaderRow = exports.toggleHeaderColumn = exports.toggleContextualMenu = exports.getNextLayout = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
+ var _analytics = require("@atlaskit/editor-common/analytics");
9
10
  var _utils = require("@atlaskit/editor-tables/utils");
10
11
  var _pluginFactory = require("../pm-plugins/plugin-factory");
12
+ var _tableAnalytics = require("../pm-plugins/table-analytics");
11
13
  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; }
12
14
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } //#region Imports
13
15
  //#endregion
@@ -58,10 +60,15 @@ var toggleNumberColumn = function toggleNumberColumn(state, dispatch) {
58
60
  var _ref = (0, _utils.findTable)(state.selection),
59
61
  node = _ref.node,
60
62
  pos = _ref.pos;
63
+ var isNumberedColumnEnabled = node.attrs.isNumberColumnEnabled;
61
64
  tr.setNodeMarkup(pos, state.schema.nodes.table, _objectSpread(_objectSpread({}, node.attrs), {}, {
62
- isNumberColumnEnabled: !node.attrs.isNumberColumnEnabled
65
+ isNumberColumnEnabled: !isNumberedColumnEnabled
63
66
  }));
64
67
  tr.setMeta('scrollIntoView', false);
68
+ var tableOverflowChangeTriggerName = isNumberedColumnEnabled ? _analytics.TABLE_OVERFLOW_CHANGE_TRIGGER.DISABLED_NUMBERED_COLUMN : _analytics.TABLE_OVERFLOW_CHANGE_TRIGGER.ENABLED_NUMBERED_COLUMN;
69
+ tr.setMeta(_tableAnalytics.META_KEYS.OVERFLOW_TRIGGER, {
70
+ name: tableOverflowChangeTriggerName
71
+ });
65
72
  if (dispatch) {
66
73
  dispatch(tr);
67
74
  }
@@ -83,6 +90,9 @@ var toggleTableLayout = function toggleTableLayout(state, dispatch) {
83
90
  tr.setNodeMarkup(table.pos, state.schema.nodes.table, _objectSpread(_objectSpread({}, table.node.attrs), {}, {
84
91
  layout: layout
85
92
  }));
93
+ tr.setMeta(_tableAnalytics.META_KEYS.OVERFLOW_TRIGGER, {
94
+ name: _analytics.TABLE_OVERFLOW_CHANGE_TRIGGER.RESIZED
95
+ });
86
96
  return tr.setMeta('scrollIntoView', false);
87
97
  })(state, dispatch);
88
98
  };
@@ -17,6 +17,7 @@ var _utils = require("@atlaskit/editor-common/utils");
17
17
  var _withPluginState = require("@atlaskit/editor-common/with-plugin-state");
18
18
  var _pmPlugins = require("@atlaskit/editor-tables/pm-plugins");
19
19
  var _utils2 = require("@atlaskit/editor-tables/utils");
20
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
20
21
  var _createPluginConfig = require("./create-plugin-config");
21
22
  var _plugin = require("./pm-plugins/decorations/plugin");
22
23
  var _keymap = require("./pm-plugins/keymap");
@@ -24,6 +25,7 @@ var _main = require("./pm-plugins/main");
24
25
  var _pluginKey = require("./pm-plugins/plugin-key");
25
26
  var _safariDeleteCompositionTextIssueWorkaround = require("./pm-plugins/safari-delete-composition-text-issue-workaround");
26
27
  var _stickyHeaders = require("./pm-plugins/sticky-headers");
28
+ var _tableAnalytics = require("./pm-plugins/table-analytics");
27
29
  var _tableLocalId = require("./pm-plugins/table-local-id");
28
30
  var _tableResizing = require("./pm-plugins/table-resizing");
29
31
  var _tableSelectionKeymap = require("./pm-plugins/table-selection-keymap");
@@ -188,6 +190,14 @@ var tablesPlugin = function tablesPlugin(_ref) {
188
190
  dispatch = _ref9.dispatch;
189
191
  return options !== null && options !== void 0 && options.tableResizingEnabled ? (0, _tableWidth.createPlugin)(dispatch, dispatchAnalyticsEvent, (_options$fullWidthEna = options === null || options === void 0 ? void 0 : options.fullWidthEnabled) !== null && _options$fullWidthEna !== void 0 ? _options$fullWidthEna : false) : undefined;
190
192
  }
193
+ }, {
194
+ name: 'tableAnalyticsPlugin',
195
+ plugin: function plugin(_ref10) {
196
+ var _options$tableResizin;
197
+ var dispatch = _ref10.dispatch,
198
+ dispatchAnalyticsEvent = _ref10.dispatchAnalyticsEvent;
199
+ return (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.overflow-state-analytics') ? (0, _tableAnalytics.createPlugin)(dispatch, dispatchAnalyticsEvent, (_options$tableResizin = options === null || options === void 0 ? void 0 : options.tableResizingEnabled) !== null && _options$tableResizin !== void 0 ? _options$tableResizin : false) : undefined;
200
+ }
191
201
  }, {
192
202
  name: 'tableGetEditorViewReferencePlugin',
193
203
  plugin: function plugin() {
@@ -216,45 +226,46 @@ var tablesPlugin = function tablesPlugin(_ref) {
216
226
  }
217
227
  return plugins;
218
228
  },
219
- contentComponent: function contentComponent(_ref10) {
220
- var editorView = _ref10.editorView,
221
- popupsMountPoint = _ref10.popupsMountPoint,
222
- popupsBoundariesElement = _ref10.popupsBoundariesElement,
223
- popupsScrollableElement = _ref10.popupsScrollableElement,
224
- dispatchAnalyticsEvent = _ref10.dispatchAnalyticsEvent;
229
+ contentComponent: function contentComponent(_ref11) {
230
+ var editorView = _ref11.editorView,
231
+ popupsMountPoint = _ref11.popupsMountPoint,
232
+ popupsBoundariesElement = _ref11.popupsBoundariesElement,
233
+ popupsScrollableElement = _ref11.popupsScrollableElement,
234
+ dispatchAnalyticsEvent = _ref11.dispatchAnalyticsEvent;
225
235
  return /*#__PURE__*/_react.default.createElement(_errorBoundary.ErrorBoundary, {
226
236
  component: _analytics.ACTION_SUBJECT.TABLES_PLUGIN,
227
237
  dispatchAnalyticsEvent: dispatchAnalyticsEvent,
228
238
  fallbackComponent: null
229
239
  }, /*#__PURE__*/_react.default.createElement(_withPluginState.WithPluginState, {
230
240
  plugins: {
241
+ tableAnalyticsPluginState: _tableAnalytics.pluginKey,
231
242
  tablePluginState: _pluginKey.pluginKey,
232
243
  tableWidthPluginState: _tableWidth.pluginKey,
233
244
  tableResizingPluginState: _tableResizing.pluginKey,
234
245
  stickyHeadersState: _stickyHeaders.pluginKey
235
246
  },
236
- render: function render(_ref11) {
237
- var resizingPluginState = _ref11.tableResizingPluginState,
238
- stickyHeadersState = _ref11.stickyHeadersState,
239
- tablePluginState = _ref11.tablePluginState,
240
- tableWidthPluginState = _ref11.tableWidthPluginState;
247
+ render: function render(_ref12) {
248
+ var resizingPluginState = _ref12.tableResizingPluginState,
249
+ stickyHeadersState = _ref12.stickyHeadersState,
250
+ tablePluginState = _ref12.tablePluginState,
251
+ tableWidthPluginState = _ref12.tableWidthPluginState;
241
252
  var state = editorView.state;
242
253
  var isColumnResizing = resizingPluginState === null || resizingPluginState === void 0 ? void 0 : resizingPluginState.dragging;
243
254
  var isTableResizing = tableWidthPluginState === null || tableWidthPluginState === void 0 ? void 0 : tableWidthPluginState.resizing;
244
255
  var isResizing = isColumnResizing || isTableResizing;
245
- var _ref12 = tablePluginState,
246
- tableNode = _ref12.tableNode,
247
- tablePos = _ref12.tablePos,
248
- targetCellPosition = _ref12.targetCellPosition,
249
- isContextualMenuOpen = _ref12.isContextualMenuOpen,
250
- layout = _ref12.layout,
251
- tableRef = _ref12.tableRef,
252
- pluginConfig = _ref12.pluginConfig,
253
- insertColumnButtonIndex = _ref12.insertColumnButtonIndex,
254
- insertRowButtonIndex = _ref12.insertRowButtonIndex,
255
- isHeaderColumnEnabled = _ref12.isHeaderColumnEnabled,
256
- isHeaderRowEnabled = _ref12.isHeaderRowEnabled,
257
- tableWrapperTarget = _ref12.tableWrapperTarget;
256
+ var _ref13 = tablePluginState,
257
+ tableNode = _ref13.tableNode,
258
+ tablePos = _ref13.tablePos,
259
+ targetCellPosition = _ref13.targetCellPosition,
260
+ isContextualMenuOpen = _ref13.isContextualMenuOpen,
261
+ layout = _ref13.layout,
262
+ tableRef = _ref13.tableRef,
263
+ pluginConfig = _ref13.pluginConfig,
264
+ insertColumnButtonIndex = _ref13.insertColumnButtonIndex,
265
+ insertRowButtonIndex = _ref13.insertRowButtonIndex,
266
+ isHeaderColumnEnabled = _ref13.isHeaderColumnEnabled,
267
+ isHeaderRowEnabled = _ref13.isHeaderRowEnabled,
268
+ tableWrapperTarget = _ref13.tableWrapperTarget;
258
269
  var allowControls = pluginConfig.allowControls;
259
270
  var stickyHeader = stickyHeadersState ? (0, _stickyHeaders.findStickyHeaderForTable)(stickyHeadersState, tablePos) : undefined;
260
271
  var LayoutContent = options && !options.tableResizingEnabled && (0, _utils3.isLayoutSupported)(state) && options.breakoutEnabled ? /*#__PURE__*/_react.default.createElement(_LayoutButton.default, {
@@ -320,8 +331,8 @@ var tablesPlugin = function tablesPlugin(_ref) {
320
331
  }));
321
332
  },
322
333
  pluginsOptions: {
323
- quickInsert: function quickInsert(_ref13) {
324
- var formatMessage = _ref13.formatMessage;
334
+ quickInsert: function quickInsert(_ref14) {
335
+ var formatMessage = _ref14.formatMessage;
325
336
  return [{
326
337
  id: 'table',
327
338
  title: formatMessage(_messages.toolbarInsertBlockMessages.table),
@@ -16,6 +16,8 @@ var _react = _interopRequireDefault(require("react"));
16
16
  var _classnames2 = _interopRequireDefault(require("classnames"));
17
17
  var _memoizeOne = _interopRequireDefault(require("memoize-one"));
18
18
  var _rafSchd = _interopRequireDefault(require("raf-schd"));
19
+ var _analytics = require("@atlaskit/editor-common/analytics");
20
+ var _eventDispatcher = require("@atlaskit/editor-common/event-dispatcher");
19
21
  var _nodeWidth = require("@atlaskit/editor-common/node-width");
20
22
  var _styles = require("@atlaskit/editor-common/styles");
21
23
  var _utils = require("@atlaskit/editor-common/utils");
@@ -25,6 +27,7 @@ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
25
27
  var _commands = require("../commands");
26
28
  var _pluginFactory = require("../pm-plugins/plugin-factory");
27
29
  var _stickyHeaders = require("../pm-plugins/sticky-headers");
30
+ var _tableAnalytics = require("../pm-plugins/table-analytics");
28
31
  var _utils3 = require("../pm-plugins/table-resizing/utils");
29
32
  var _colgroup = require("../pm-plugins/table-resizing/utils/colgroup");
30
33
  var _dom = require("../pm-plugins/table-resizing/utils/dom");
@@ -39,6 +42,10 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
39
42
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
40
43
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
41
44
  var isIE11 = _utils.browser.ie_version === 11;
45
+ // When table is inserted via paste, keyboard shortcut or quickInsert,
46
+ // componentDidUpdate is called multiple times. The isOverflowing value is correct only on the last update.
47
+ // To make sure we capture the last update, we use setTimeout.
48
+ var initialOverflowCaptureTimeroutDelay = 300;
42
49
  var TableComponent = /*#__PURE__*/function (_React$Component) {
43
50
  (0, _inherits2.default)(TableComponent, _React$Component);
44
51
  var _super = _createSuper(TableComponent);
@@ -176,13 +183,40 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
176
183
  }, options), domAtPos)(state.tr);
177
184
  dispatch(tr);
178
185
  });
186
+ (0, _defineProperty3.default)((0, _assertThisInitialized2.default)(_this), "setTimerToSendInitialOverflowCaptured", function (isOverflowing) {
187
+ var _this$state;
188
+ var _this$props3 = _this.props,
189
+ eventDispatcher = _this$props3.eventDispatcher,
190
+ containerWidth = _this$props3.containerWidth,
191
+ options = _this$props3.options;
192
+ var dispatch = (0, _eventDispatcher.createDispatch)(eventDispatcher);
193
+ var parentWidth = ((_this$state = _this.state) === null || _this$state === void 0 ? void 0 : _this$state.parentWidth) || 0;
194
+ _this.initialOverflowCaptureTimerId = setTimeout(function () {
195
+ dispatch(_utils.analyticsEventKey, {
196
+ payload: {
197
+ action: _analytics.TABLE_ACTION.INITIAL_OVERFLOW_CAPTURED,
198
+ actionSubject: _analytics.ACTION_SUBJECT.TABLE,
199
+ actionSubjectId: null,
200
+ eventType: _analytics.EVENT_TYPE.TRACK,
201
+ attributes: {
202
+ editorWidth: containerWidth.width || 0,
203
+ isOverflowing: isOverflowing,
204
+ tableResizingEnabled: (options === null || options === void 0 ? void 0 : options.isTableResizingEnabled) || false,
205
+ width: _this.node.attrs.width || 0,
206
+ parentWidth: parentWidth
207
+ }
208
+ }
209
+ });
210
+ _this.isInitialOverflowSent = true;
211
+ }, initialOverflowCaptureTimeroutDelay);
212
+ });
179
213
  (0, _defineProperty3.default)((0, _assertThisInitialized2.default)(_this), "handleAutoSize", function () {
180
214
  if (_this.table) {
181
- var _this$props3 = _this.props,
182
- view = _this$props3.view,
183
- getNode = _this$props3.getNode,
184
- getPos = _this$props3.getPos,
185
- containerWidth = _this$props3.containerWidth;
215
+ var _this$props4 = _this.props,
216
+ view = _this$props4.view,
217
+ getNode = _this$props4.getNode,
218
+ getPos = _this$props4.getPos,
219
+ containerWidth = _this$props4.containerWidth;
186
220
  var _node = getNode();
187
221
  var pos = getPos();
188
222
  if (!(0, _utils.isValidPosition)(pos, view.state)) {
@@ -195,9 +229,9 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
195
229
  });
196
230
  (0, _defineProperty3.default)((0, _assertThisInitialized2.default)(_this), "handleWindowResize", function () {
197
231
  var _node$attrs, _node$attrs2;
198
- var _this$props4 = _this.props,
199
- getNode = _this$props4.getNode,
200
- containerWidth = _this$props4.containerWidth;
232
+ var _this$props5 = _this.props,
233
+ getNode = _this$props5.getNode,
234
+ containerWidth = _this$props5.containerWidth;
201
235
  var node = getNode();
202
236
  var prevNode = _this.node;
203
237
  var layoutSize = _this.tableNodeLayoutSize(node);
@@ -213,11 +247,11 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
213
247
  });
214
248
  });
215
249
  (0, _defineProperty3.default)((0, _assertThisInitialized2.default)(_this), "getParentNodeWidth", function () {
216
- var _this$props5 = _this.props,
217
- getPos = _this$props5.getPos,
218
- containerWidth = _this$props5.containerWidth,
219
- options = _this$props5.options,
220
- state = _this$props5.view.state;
250
+ var _this$props6 = _this.props,
251
+ getPos = _this$props6.getPos,
252
+ containerWidth = _this$props6.containerWidth,
253
+ options = _this$props6.options,
254
+ state = _this$props6.view.state;
221
255
  var pos = getPos();
222
256
  if (!(0, _utils.isValidPosition)(pos, state)) {
223
257
  return;
@@ -243,6 +277,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
243
277
  _getNode = props.getNode;
244
278
  _this.node = _getNode();
245
279
  _this.containerWidth = _containerWidth;
280
+ _this.isInitialOverflowSent = false;
246
281
 
247
282
  // store table size using previous full-width mode so can detect if it has changed
248
283
  var isFullWidthModeEnabled = _options ? _options.wasFullWidthModeEnabled : false;
@@ -264,10 +299,10 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
264
299
  (0, _createClass2.default)(TableComponent, [{
265
300
  key: "componentDidMount",
266
301
  value: function componentDidMount() {
267
- var _this$props6 = this.props,
268
- allowColumnResizing = _this$props6.allowColumnResizing,
269
- eventDispatcher = _this$props6.eventDispatcher,
270
- options = _this$props6.options;
302
+ var _this$props7 = this.props,
303
+ allowColumnResizing = _this$props7.allowColumnResizing,
304
+ eventDispatcher = _this$props7.eventDispatcher,
305
+ options = _this$props7.options;
271
306
  if (allowColumnResizing && this.wrapper && !isIE11) {
272
307
  this.wrapper.addEventListener('scroll', this.handleScrollDebounced);
273
308
  }
@@ -286,14 +321,18 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
286
321
  this.onStickyState(currentStickyState);
287
322
  }
288
323
  eventDispatcher.on(_stickyHeaders.pluginKey.key, this.onStickyState);
324
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.overflow-state-analytics')) {
325
+ var initialIsOveflowing = this.state[_types.ShadowEvent.SHOW_BEFORE_SHADOW] || this.state[_types.ShadowEvent.SHOW_AFTER_SHADOW];
326
+ this.setTimerToSendInitialOverflowCaptured(initialIsOveflowing);
327
+ }
289
328
  }
290
329
  }, {
291
330
  key: "componentWillUnmount",
292
331
  value: function componentWillUnmount() {
293
- var _this$props7 = this.props,
294
- allowColumnResizing = _this$props7.allowColumnResizing,
295
- eventDispatcher = _this$props7.eventDispatcher,
296
- options = _this$props7.options;
332
+ var _this$props8 = this.props,
333
+ allowColumnResizing = _this$props8.allowColumnResizing,
334
+ eventDispatcher = _this$props8.eventDispatcher,
335
+ options = _this$props8.options;
297
336
  if (this.wrapper && !isIE11) {
298
337
  this.wrapper.removeEventListener('scroll', this.handleScrollDebounced);
299
338
  }
@@ -311,18 +350,21 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
311
350
  this.overflowShadowsObserver.dispose();
312
351
  }
313
352
  eventDispatcher.off(_stickyHeaders.pluginKey.key, this.onStickyState);
353
+ if (this.initialOverflowCaptureTimerId) {
354
+ clearTimeout(this.initialOverflowCaptureTimerId);
355
+ }
314
356
  }
315
357
  }, {
316
358
  key: "componentDidUpdate",
317
- value: function componentDidUpdate() {
359
+ value: function componentDidUpdate(_, prevState) {
318
360
  var _this$wrapper;
319
- var _this$props8 = this.props,
320
- view = _this$props8.view,
321
- getNode = _this$props8.getNode,
322
- isMediaFullscreen = _this$props8.isMediaFullscreen,
323
- allowColumnResizing = _this$props8.allowColumnResizing,
324
- isResizing = _this$props8.isResizing,
325
- options = _this$props8.options;
361
+ var _this$props9 = this.props,
362
+ view = _this$props9.view,
363
+ getNode = _this$props9.getNode,
364
+ isMediaFullscreen = _this$props9.isMediaFullscreen,
365
+ allowColumnResizing = _this$props9.allowColumnResizing,
366
+ isResizing = _this$props9.isResizing,
367
+ options = _this$props9.options;
326
368
  var _getPluginState = (0, _pluginFactory.getPluginState)(view.state),
327
369
  isInDanger = _getPluginState.isInDanger;
328
370
  var table = (0, _utils2.findTable)(view.state.selection);
@@ -357,29 +399,52 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
357
399
  }
358
400
  this.handleTableResizingDebounced();
359
401
  }
402
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.overflow-state-analytics')) {
403
+ var newIsOverflowing = this.state[_types.ShadowEvent.SHOW_BEFORE_SHADOW] || this.state[_types.ShadowEvent.SHOW_AFTER_SHADOW];
404
+ var prevIsOverflowing = prevState[_types.ShadowEvent.SHOW_BEFORE_SHADOW] || prevState[_types.ShadowEvent.SHOW_AFTER_SHADOW];
405
+ if (this.initialOverflowCaptureTimerId) {
406
+ clearTimeout(this.initialOverflowCaptureTimerId);
407
+ }
408
+ if (!this.isInitialOverflowSent) {
409
+ this.setTimerToSendInitialOverflowCaptured(newIsOverflowing);
410
+ }
411
+ if (this.isInitialOverflowSent && prevIsOverflowing !== newIsOverflowing) {
412
+ var _this$state2;
413
+ var _this$props$view = this.props.view,
414
+ dispatch = _this$props$view.dispatch,
415
+ tr = _this$props$view.state.tr;
416
+ dispatch(tr.setMeta(_tableAnalytics.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
+ }
360
425
  }
361
426
  }, {
362
427
  key: "render",
363
428
  value: function render() {
364
429
  var _classnames,
365
430
  _this2 = this;
366
- var _this$props9 = this.props,
367
- view = _this$props9.view,
368
- getNode = _this$props9.getNode,
369
- isResizing = _this$props9.isResizing,
370
- _this$props9$allowCon = _this$props9.allowControls,
371
- allowControls = _this$props9$allowCon === void 0 ? true : _this$props9$allowCon,
372
- isHeaderRowEnabled = _this$props9.isHeaderRowEnabled,
373
- ordering = _this$props9.ordering,
374
- isHeaderColumnEnabled = _this$props9.isHeaderColumnEnabled,
375
- tableActive = _this$props9.tableActive,
376
- containerWidth = _this$props9.containerWidth,
377
- options = _this$props9.options,
378
- getPos = _this$props9.getPos,
379
- pluginInjectionApi = _this$props9.pluginInjectionApi;
380
- var _this$state = this.state,
381
- showBeforeShadow = _this$state.showBeforeShadow,
382
- showAfterShadow = _this$state.showAfterShadow;
431
+ var _this$props10 = this.props,
432
+ view = _this$props10.view,
433
+ getNode = _this$props10.getNode,
434
+ isResizing = _this$props10.isResizing,
435
+ _this$props10$allowCo = _this$props10.allowControls,
436
+ allowControls = _this$props10$allowCo === void 0 ? true : _this$props10$allowCo,
437
+ isHeaderRowEnabled = _this$props10.isHeaderRowEnabled,
438
+ ordering = _this$props10.ordering,
439
+ isHeaderColumnEnabled = _this$props10.isHeaderColumnEnabled,
440
+ tableActive = _this$props10.tableActive,
441
+ containerWidth = _this$props10.containerWidth,
442
+ options = _this$props10.options,
443
+ getPos = _this$props10.getPos,
444
+ pluginInjectionApi = _this$props10.pluginInjectionApi;
445
+ var _this$state3 = this.state,
446
+ showBeforeShadow = _this$state3.showBeforeShadow,
447
+ showAfterShadow = _this$state3.showAfterShadow;
383
448
  var node = getNode();
384
449
  // doesn't work well with WithPluginState
385
450
  var _getPluginState2 = (0, _pluginFactory.getPluginState)(view.state),
@@ -471,7 +536,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
471
536
  }), this.state.stickyHeader && /*#__PURE__*/_react.default.createElement("div", {
472
537
  style: {
473
538
  position: 'absolute',
474
- right: (0, _platformFeatureFlags.getBooleanFF)('platform.editor.custom-table-width') ? "".concat(_consts.tableOverflowShadowWidth, "px") : '-2px'
539
+ right: (0, _platformFeatureFlags.getBooleanFF)('platform.editor.custom-table-width') ? "".concat((0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.increase-shadow-visibility_lh89r') ? _consts.tableOverflowShadowWidthWide : _consts.tableOverflowShadowWidth, "px") : '-2px'
475
540
  }
476
541
  }, /*#__PURE__*/_react.default.createElement("div", {
477
542
  className: "".concat(_types.TableCssClassName.TABLE_RIGHT_SHADOW, " ").concat(_types.TableCssClassName.TABLE_STICKY_SHADOW),
@@ -11,15 +11,17 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
11
11
  var _react = _interopRequireWildcard(require("react"));
12
12
  var _rafSchd = _interopRequireDefault(require("raf-schd"));
13
13
  var _reactIntlNext = require("react-intl-next");
14
+ var _analytics = require("@atlaskit/editor-common/analytics");
14
15
  var _guideline = require("@atlaskit/editor-common/guideline");
15
16
  var _resizer = require("@atlaskit/editor-common/resizer");
16
17
  var _utils = require("@atlaskit/editor-tables/utils");
17
18
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
18
19
  var _pluginFactory = require("../pm-plugins/plugin-factory");
20
+ var _tableAnalytics = require("../pm-plugins/table-analytics");
19
21
  var _utils2 = require("../pm-plugins/table-resizing/utils");
20
22
  var _tableWidth = require("../pm-plugins/table-width");
21
23
  var _consts = require("../ui/consts");
22
- var _analytics = require("../utils/analytics");
24
+ var _analytics2 = require("../utils/analytics");
23
25
  var _guidelines = require("../utils/guidelines");
24
26
  var _snapping = require("../utils/snapping");
25
27
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
@@ -108,7 +110,7 @@ var TableResizer = function TableResizer(_ref) {
108
110
  var handleHeightSize = getResizerHandleHeight(tableRef);
109
111
  var _getPluginState = (0, _pluginFactory.getPluginState)(editorView.state),
110
112
  isInDanger = _getPluginState.isInDanger;
111
- var _useMeasureFramerate = (0, _analytics.useMeasureFramerate)(),
113
+ var _useMeasureFramerate = (0, _analytics2.useMeasureFramerate)(),
112
114
  startMeasure = _useMeasureFramerate.startMeasure,
113
115
  endMeasure = _useMeasureFramerate.endMeasure,
114
116
  countFrames = _useMeasureFramerate.countFrames;
@@ -145,6 +147,9 @@ var TableResizer = function TableResizer(_ref) {
145
147
  resizing: true
146
148
  });
147
149
  displayGapCursor(false);
150
+ tr.setMeta(_tableAnalytics.META_KEYS.OVERFLOW_TRIGGER, {
151
+ name: _analytics.TABLE_OVERFLOW_CHANGE_TRIGGER.RESIZED
152
+ });
148
153
  dispatch(tr);
149
154
  var visibleGuidelines = getVisibleGuidelines(_guidelines.defaultGuidelines, containerWidth);
150
155
  setSnappingEnabled(displayGuideline(visibleGuidelines));
@@ -188,7 +193,7 @@ var TableResizer = function TableResizer(_ref) {
188
193
  });
189
194
  var frameRateSamples = endMeasure();
190
195
  if (frameRateSamples.length > 0) {
191
- var resizeFrameRatePayloads = (0, _analytics.generateResizeFrameRatePayloads)({
196
+ var resizeFrameRatePayloads = (0, _analytics2.generateResizeFrameRatePayloads)({
192
197
  docSize: state.doc.nodeSize,
193
198
  frameRateSamples: frameRateSamples,
194
199
  originalNode: node
@@ -211,7 +216,7 @@ var TableResizer = function TableResizer(_ref) {
211
216
  parentWidth: newWidth
212
217
  }, editorView.domAtPos.bind(editorView))(tr);
213
218
  var scaledNode = tr.doc.nodeAt(pos);
214
- (_attachAnalyticsEvent2 = attachAnalyticsEvent((0, _analytics.generateResizedPayload)({
219
+ (_attachAnalyticsEvent2 = attachAnalyticsEvent((0, _analytics2.generateResizedPayload)({
215
220
  originalNode: node,
216
221
  resizedNode: scaledNode
217
222
  }))) === null || _attachAnalyticsEvent2 === void 0 ? void 0 : _attachAnalyticsEvent2(tr);
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.pluginKey = exports.createPlugin = exports.META_KEYS = void 0;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
+ var _analytics = require("@atlaskit/editor-common/analytics");
10
+ var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
11
+ var _state = require("@atlaskit/editor-prosemirror/state");
12
+ 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; }
13
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } /**
14
+ * A plugin is created for collecting payload data for tableOverflowChanged analytics event
15
+ */
16
+ var pluginKey = new _state.PluginKey('tableAnalyticsPlugin');
17
+ exports.pluginKey = pluginKey;
18
+ var META_KEYS = {
19
+ OVERFLOW_TRIGGER: 'tableOverflowTrigger',
20
+ OVERFLOW_STATE_CHANGED: 'tableOverflowStateChanged'
21
+ };
22
+ exports.META_KEYS = META_KEYS;
23
+ var createPlugin = function createPlugin(dispatch, dispatchAnalyticsEvent, tableResizingEnabled) {
24
+ return new _safePlugin.SafePlugin({
25
+ key: pluginKey,
26
+ state: {
27
+ init: function init() {
28
+ return {
29
+ lastTrigger: undefined
30
+ };
31
+ },
32
+ apply: function apply(tr, pluginState) {
33
+ var meta = tr.getMeta(META_KEYS.OVERFLOW_TRIGGER);
34
+ var newState = _objectSpread({}, pluginState);
35
+ if (meta) {
36
+ newState.lastTrigger = _objectSpread({}, meta);
37
+ dispatch(pluginKey, newState);
38
+ return newState;
39
+ }
40
+ return pluginState;
41
+ }
42
+ },
43
+ appendTransaction: function appendTransaction(transactions, oldState, newState) {
44
+ var _newPluginState$lastT;
45
+ var newPluginState = pluginKey.getState(newState);
46
+ var hasAnalyticsBeenDispatched = false;
47
+ var lastTriggerName = (newPluginState === null || newPluginState === void 0 ? void 0 : (_newPluginState$lastT = newPluginState.lastTrigger) === null || _newPluginState$lastT === void 0 ? void 0 : _newPluginState$lastT.name) ||
48
+ // NOTE: We assume that we know and can correctly differentiate
49
+ // between all triggers of table overflow state change.
50
+ // The only trigger we can't identify is viewport width change.
51
+ // However, since there is still a chance that there are other triggers we didn't think of,
52
+ // all these unknown triggers and viwport width change trigger are captured as EXTERNAL.
53
+ _analytics.TABLE_OVERFLOW_CHANGE_TRIGGER.EXTERNAL;
54
+ transactions.forEach(function (tr) {
55
+ var payload = tr.getMeta(META_KEYS.OVERFLOW_STATE_CHANGED);
56
+ if (payload) {
57
+ dispatchAnalyticsEvent({
58
+ action: _analytics.TABLE_ACTION.OVERFLOW_CHANGED,
59
+ actionSubject: _analytics.ACTION_SUBJECT.TABLE,
60
+ actionSubjectId: null,
61
+ eventType: _analytics.EVENT_TYPE.TRACK,
62
+ attributes: {
63
+ editorWidth: payload.editorWidth,
64
+ parentWidth: payload.parentWidth,
65
+ isOverflowing: payload.isOverflowing,
66
+ wasOverflowing: payload.wasOverflowing,
67
+ width: payload.width,
68
+ tableResizingEnabled: tableResizingEnabled,
69
+ trigger: lastTriggerName
70
+ }
71
+ });
72
+ hasAnalyticsBeenDispatched = true;
73
+ }
74
+ });
75
+ if (hasAnalyticsBeenDispatched) {
76
+ var tr = newState.tr;
77
+ return tr.setMeta(META_KEYS.OVERFLOW_TRIGGER, {});
78
+ }
79
+ return undefined;
80
+ }
81
+ });
82
+ };
83
+ exports.createPlugin = createPlugin;
@@ -4,8 +4,10 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.stopResizing = exports.setResizeHandlePos = exports.setLastClick = exports.setDragging = exports.evenColumns = exports.distributeColumnsWidths = void 0;
7
+ var _analytics = require("@atlaskit/editor-common/analytics");
7
8
  var _utils = require("@atlaskit/editor-tables/utils");
8
9
  var _transforms = require("../../transforms");
10
+ var _tableAnalytics = require("../table-analytics");
9
11
  var _pluginFactory = require("./plugin-factory");
10
12
  var _utils2 = require("./utils");
11
13
  var evenColumns = function evenColumns(_ref) {
@@ -43,6 +45,9 @@ var distributeColumnsWidths = function distributeColumnsWidths(newResizeState, t
43
45
  return function (state, dispatch) {
44
46
  if (dispatch) {
45
47
  var _tr = (0, _transforms.updateColumnWidths)(newResizeState, table.node, table.start)(state.tr);
48
+ _tr.setMeta(_tableAnalytics.META_KEYS.OVERFLOW_TRIGGER, {
49
+ name: _analytics.TABLE_OVERFLOW_CHANGE_TRIGGER.DISTRIBUTED_COLUMNS
50
+ });
46
51
  stopResizing(_tr)(state, dispatch);
47
52
  }
48
53
  return true;
@@ -14,6 +14,7 @@ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
14
14
  var _misc = require("../../commands/misc");
15
15
  var _transforms = require("../../transforms");
16
16
  var _utils2 = require("../../utils");
17
+ var _tableAnalytics = require("../table-analytics");
17
18
  var _commands = require("./commands");
18
19
  var _pluginFactory = require("./plugin-factory");
19
20
  var _utils3 = require("./utils");
@@ -26,6 +27,13 @@ var handleMouseDown = function handleMouseDown(view, event, localResizeHandlePos
26
27
  return false;
27
28
  }
28
29
  event.preventDefault();
30
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.overflow-state-analytics')) {
31
+ var tr = view.state.tr;
32
+ tr.setMeta(_tableAnalytics.META_KEYS.OVERFLOW_TRIGGER, {
33
+ name: _analytics.TABLE_OVERFLOW_CHANGE_TRIGGER.RESIZED_COLUMN
34
+ });
35
+ dispatch(tr);
36
+ }
29
37
  var mouseDownTime = event.timeStamp;
30
38
  var cell = state.doc.nodeAt(localResizeHandlePos);
31
39
  var $cell = state.doc.resolve(localResizeHandlePos);