@atlaskit/editor-plugin-table 5.4.6 → 5.4.7

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 (95) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/cjs/plugins/table/commands/insert.js +12 -2
  3. package/dist/cjs/plugins/table/commands/misc.js +49 -1
  4. package/dist/cjs/plugins/table/index.js +46 -35
  5. package/dist/cjs/plugins/table/nodeviews/TableComponent.js +12 -16
  6. package/dist/cjs/plugins/table/nodeviews/TableResizer.js +1 -1
  7. package/dist/cjs/plugins/table/nodeviews/table.js +3 -1
  8. package/dist/cjs/plugins/table/pm-plugins/analytics/actions.js +14 -0
  9. package/dist/cjs/plugins/table/pm-plugins/analytics/commands.js +45 -0
  10. package/dist/cjs/plugins/table/pm-plugins/analytics/plugin-factory.js +13 -0
  11. package/dist/cjs/plugins/table/pm-plugins/analytics/plugin-key.js +8 -0
  12. package/dist/cjs/plugins/table/pm-plugins/analytics/plugin.js +74 -0
  13. package/dist/cjs/plugins/table/pm-plugins/analytics/reducer.js +26 -0
  14. package/dist/cjs/plugins/table/pm-plugins/analytics/types.js +13 -0
  15. package/dist/cjs/plugins/table/pm-plugins/analytics/utils/moved-event.js +38 -0
  16. package/dist/cjs/plugins/table/pm-plugins/main.js +1 -1
  17. package/dist/cjs/plugins/table/pm-plugins/table-analytics.js +1 -1
  18. package/dist/es2019/plugins/table/commands/insert.js +12 -3
  19. package/dist/es2019/plugins/table/commands/misc.js +49 -0
  20. package/dist/es2019/plugins/table/index.js +14 -4
  21. package/dist/es2019/plugins/table/nodeviews/TableComponent.js +13 -17
  22. package/dist/es2019/plugins/table/nodeviews/TableResizer.js +1 -1
  23. package/dist/es2019/plugins/table/nodeviews/table.js +3 -1
  24. package/dist/es2019/plugins/table/pm-plugins/analytics/actions.js +8 -0
  25. package/dist/es2019/plugins/table/pm-plugins/analytics/commands.js +33 -0
  26. package/dist/es2019/plugins/table/pm-plugins/analytics/plugin-factory.js +8 -0
  27. package/dist/es2019/plugins/table/pm-plugins/analytics/plugin-key.js +2 -0
  28. package/dist/es2019/plugins/table/pm-plugins/analytics/plugin.js +72 -0
  29. package/dist/es2019/plugins/table/pm-plugins/analytics/reducer.js +21 -0
  30. package/dist/es2019/plugins/table/pm-plugins/analytics/types.js +7 -0
  31. package/dist/es2019/plugins/table/pm-plugins/analytics/utils/moved-event.js +30 -0
  32. package/dist/es2019/plugins/table/pm-plugins/main.js +1 -1
  33. package/dist/es2019/plugins/table/pm-plugins/table-analytics.js +1 -1
  34. package/dist/esm/plugins/table/commands/insert.js +12 -3
  35. package/dist/esm/plugins/table/commands/misc.js +48 -0
  36. package/dist/esm/plugins/table/index.js +43 -32
  37. package/dist/esm/plugins/table/nodeviews/TableComponent.js +13 -17
  38. package/dist/esm/plugins/table/nodeviews/TableResizer.js +1 -1
  39. package/dist/esm/plugins/table/nodeviews/table.js +3 -1
  40. package/dist/esm/plugins/table/pm-plugins/analytics/actions.js +8 -0
  41. package/dist/esm/plugins/table/pm-plugins/analytics/commands.js +39 -0
  42. package/dist/esm/plugins/table/pm-plugins/analytics/plugin-factory.js +8 -0
  43. package/dist/esm/plugins/table/pm-plugins/analytics/plugin-key.js +2 -0
  44. package/dist/esm/plugins/table/pm-plugins/analytics/plugin.js +68 -0
  45. package/dist/esm/plugins/table/pm-plugins/analytics/reducer.js +19 -0
  46. package/dist/esm/plugins/table/pm-plugins/analytics/types.js +7 -0
  47. package/dist/esm/plugins/table/pm-plugins/analytics/utils/moved-event.js +31 -0
  48. package/dist/esm/plugins/table/pm-plugins/main.js +1 -1
  49. package/dist/esm/plugins/table/pm-plugins/table-analytics.js +1 -1
  50. package/dist/types/plugins/table/commands/misc.d.ts +5 -1
  51. package/dist/types/plugins/table/nodeviews/TableComponent.d.ts +2 -0
  52. package/dist/types/plugins/table/nodeviews/table.d.ts +2 -1
  53. package/dist/types/plugins/table/nodeviews/types.d.ts +2 -0
  54. package/dist/types/plugins/table/pm-plugins/analytics/actions.d.ts +17 -0
  55. package/dist/types/plugins/table/pm-plugins/analytics/commands.d.ts +5 -0
  56. package/dist/types/plugins/table/pm-plugins/analytics/plugin-factory.d.ts +1 -0
  57. package/dist/types/plugins/table/pm-plugins/analytics/plugin-key.d.ts +3 -0
  58. package/dist/types/plugins/table/pm-plugins/analytics/plugin.d.ts +4 -0
  59. package/dist/types/plugins/table/pm-plugins/analytics/reducer.d.ts +3 -0
  60. package/dist/types/plugins/table/pm-plugins/analytics/types.d.ts +11 -0
  61. package/dist/types/plugins/table/pm-plugins/analytics/utils/moved-event.d.ts +6 -0
  62. package/dist/types-ts4.5/plugins/table/commands/misc.d.ts +5 -1
  63. package/dist/types-ts4.5/plugins/table/nodeviews/TableComponent.d.ts +2 -0
  64. package/dist/types-ts4.5/plugins/table/nodeviews/table.d.ts +2 -1
  65. package/dist/types-ts4.5/plugins/table/nodeviews/types.d.ts +2 -0
  66. package/dist/types-ts4.5/plugins/table/pm-plugins/analytics/actions.d.ts +17 -0
  67. package/dist/types-ts4.5/plugins/table/pm-plugins/analytics/commands.d.ts +5 -0
  68. package/dist/types-ts4.5/plugins/table/pm-plugins/analytics/plugin-factory.d.ts +1 -0
  69. package/dist/types-ts4.5/plugins/table/pm-plugins/analytics/plugin-key.d.ts +3 -0
  70. package/dist/types-ts4.5/plugins/table/pm-plugins/analytics/plugin.d.ts +4 -0
  71. package/dist/types-ts4.5/plugins/table/pm-plugins/analytics/reducer.d.ts +3 -0
  72. package/dist/types-ts4.5/plugins/table/pm-plugins/analytics/types.d.ts +11 -0
  73. package/dist/types-ts4.5/plugins/table/pm-plugins/analytics/utils/moved-event.d.ts +6 -0
  74. package/package.json +4 -1
  75. package/src/__tests__/unit/index-with-fake-timers.ts +1 -0
  76. package/src/__tests__/unit/nodeviews/table.ts +1 -0
  77. package/src/__tests__/unit/pm-plugins/analytics.ts +327 -0
  78. package/src/plugins/table/commands/insert.ts +23 -2
  79. package/src/plugins/table/commands/misc.ts +84 -1
  80. package/src/plugins/table/index.tsx +13 -6
  81. package/src/plugins/table/nodeviews/TableComponent.tsx +15 -22
  82. package/src/plugins/table/nodeviews/TableResizer.tsx +1 -2
  83. package/src/plugins/table/nodeviews/table.tsx +4 -0
  84. package/src/plugins/table/nodeviews/types.ts +2 -0
  85. package/src/plugins/table/pm-plugins/analytics/actions.ts +23 -0
  86. package/src/plugins/table/pm-plugins/analytics/commands.ts +53 -0
  87. package/src/plugins/table/pm-plugins/analytics/plugin-factory.ts +7 -0
  88. package/src/plugins/table/pm-plugins/analytics/plugin-key.ts +7 -0
  89. package/src/plugins/table/pm-plugins/analytics/plugin.ts +98 -0
  90. package/src/plugins/table/pm-plugins/analytics/reducer.ts +27 -0
  91. package/src/plugins/table/pm-plugins/analytics/types.ts +20 -0
  92. package/src/plugins/table/pm-plugins/analytics/utils/moved-event.ts +51 -0
  93. package/src/plugins/table/pm-plugins/main.ts +1 -0
  94. package/src/plugins/table/pm-plugins/table-analytics.ts +1 -1
  95. package/tsconfig.dev.json +3 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 5.4.7
4
+
5
+ ### Patch Changes
6
+
7
+ - [#56725](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/56725) [`4401801c484b`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/4401801c484b) - Add new rowOrColumnMoved event to table plugin, behind a feature flag
8
+
3
9
  ## 5.4.6
4
10
 
5
11
  ### Patch Changes
@@ -12,14 +12,14 @@ var _state = require("@atlaskit/editor-prosemirror/state");
12
12
  var _utils = require("@atlaskit/editor-prosemirror/utils");
13
13
  var _tableMap = require("@atlaskit/editor-tables/table-map");
14
14
  var _utils2 = require("@atlaskit/editor-tables/utils");
15
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
16
+ var _commands = require("../pm-plugins/analytics/commands");
15
17
  var _tableAnalytics = require("../pm-plugins/table-analytics");
16
18
  var _columnWidth = require("../transforms/column-width");
17
19
  var _utils3 = require("../utils");
18
20
  var _getAllowAddColumnCustomStep = require("../utils/get-allow-add-column-custom-step");
19
21
  // #region Imports
20
22
 
21
- // #endregion
22
-
23
23
  function addColumnAtCustomStep(column) {
24
24
  return function (tr) {
25
25
  var table = (0, _utils2.findTable)(tr.selection);
@@ -45,6 +45,11 @@ function addColumnAt(getEditorContainerWidth) {
45
45
  // [ED-8288] Update colwidths manually to avoid multiple dispatch in TableComponent
46
46
  updatedTr = (0, _columnWidth.rescaleColumns)(getEditorContainerWidth)(table, view)(updatedTr);
47
47
  }
48
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.analytics-plugin-moved-event') && view) {
49
+ updatedTr = (0, _commands.updateRowOrColumnMovedTransform)({
50
+ type: 'column'
51
+ }, 'addRowOrColumn')(view.state, updatedTr);
52
+ }
48
53
  updatedTr.setMeta(_tableAnalytics.META_KEYS.OVERFLOW_TRIGGER, {
49
54
  name: _analytics.TABLE_OVERFLOW_CHANGE_TRIGGER.ADDED_COLUMN
50
55
  });
@@ -128,6 +133,11 @@ var insertRow = exports.insertRow = function insertRow(row, moveCursorToTheNewRo
128
133
  } else {
129
134
  tr.setSelection(selection.map(tr.doc, tr.mapping));
130
135
  }
136
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.analytics-plugin-moved-event')) {
137
+ (0, _commands.updateRowOrColumnMovedTransform)({
138
+ type: 'row'
139
+ }, 'addRowOrColumn')(state, tr);
140
+ }
131
141
  dispatch(tr);
132
142
  }
133
143
  return true;
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.updateResizeHandleDecorations = exports.triggerUnlessTableHeader = exports.transformSliceToRemoveColumnsWidths = exports.transformSliceToAddTableHeaders = exports.transformSliceRemoveCellBackgroundColor = exports.showInsertRowButton = exports.showInsertColumnButton = exports.setTableRef = exports.setMultipleCellAttrs = exports.setEditorFocus = exports.setCellAttr = exports.selectRow = exports.selectColumn = exports.removeResizeHandleDecorations = exports.moveCursorBackward = exports.hideInsertColumnOrRowButton = exports.deleteTableIfSelected = exports.deleteTable = exports.convertFirstRowToHeader = exports.autoSizeTable = exports.addResizeHandleDecorations = exports.addBoldInEmptyHeaderCells = void 0;
7
+ exports.updateResizeHandleDecorations = exports.triggerUnlessTableHeader = exports.transformSliceToRemoveColumnsWidths = exports.transformSliceToAddTableHeaders = exports.transformSliceRemoveCellBackgroundColor = exports.showInsertRowButton = exports.showInsertColumnButton = exports.setTableRef = exports.setMultipleCellAttrs = exports.setEditorFocus = exports.setCellAttr = exports.selectRow = exports.selectColumn = exports.removeResizeHandleDecorations = exports.moveCursorBackward = exports.isInsideFirstCellOfRowOrColumn = exports.hideInsertColumnOrRowButton = exports.getTableSelectionType = exports.getTableElementMoveTypeBySlice = exports.deleteTableIfSelected = exports.deleteTable = exports.countCellsInSlice = exports.convertFirstRowToHeader = exports.autoSizeTable = exports.addResizeHandleDecorations = exports.addBoldInEmptyHeaderCells = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _utils = require("@atlaskit/editor-common/utils");
10
10
  var _state = require("@atlaskit/editor-prosemirror/state");
@@ -157,6 +157,54 @@ var transformSliceToRemoveColumnsWidths = exports.transformSliceToRemoveColumnsW
157
157
  return maybeCell;
158
158
  });
159
159
  };
160
+ var countCellsInSlice = exports.countCellsInSlice = function countCellsInSlice(slice, schema, type) {
161
+ var _schema$nodes4 = schema.nodes,
162
+ tableHeader = _schema$nodes4.tableHeader,
163
+ tableCell = _schema$nodes4.tableCell;
164
+ var count = 0;
165
+ if (!type) {
166
+ return count;
167
+ }
168
+ slice.content.descendants(function (maybeCell) {
169
+ if (maybeCell.type === tableCell || maybeCell.type === tableHeader) {
170
+ count += type === 'row' ? maybeCell.attrs.colspan : maybeCell.attrs.rowspan;
171
+ return false;
172
+ }
173
+ });
174
+ return count;
175
+ };
176
+ var getTableSelectionType = exports.getTableSelectionType = function getTableSelectionType(selection) {
177
+ if (selection instanceof _cellSelection.CellSelection) {
178
+ return selection.isRowSelection() ? 'row' : selection.isColSelection() ? 'column' : undefined;
179
+ }
180
+ };
181
+ var getTableElementMoveTypeBySlice = exports.getTableElementMoveTypeBySlice = function getTableElementMoveTypeBySlice(slice, state) {
182
+ if (!slice.content.firstChild) {
183
+ return;
184
+ }
185
+ var schema = state.schema;
186
+
187
+ // if the slice only contains one table row, assume it's a row
188
+ if (slice.content.childCount === 1 && slice.content.firstChild.type === schema.nodes.tableRow) {
189
+ return 'row';
190
+ }
191
+ var table = (0, _utils2.findTable)(state.tr.selection);
192
+ var map = _tableMap.TableMap.get(table.node);
193
+ var slicedMap = _tableMap.TableMap.get(slice.content.firstChild);
194
+ return map.width === slicedMap.width ? 'row' : map.height === slicedMap.height ? 'column' : undefined;
195
+ };
196
+ var isInsideFirstCellOfRowOrColumn = exports.isInsideFirstCellOfRowOrColumn = function isInsideFirstCellOfRowOrColumn(selection, type) {
197
+ var table = (0, _utils2.findTable)(selection);
198
+ if (!table || !type) {
199
+ return;
200
+ }
201
+ var map = _tableMap.TableMap.get(table.node);
202
+ var cell = (0, _utils2.selectionCell)(selection);
203
+ var index = map.map.findIndex(function (value) {
204
+ return value === cell.pos - 1;
205
+ });
206
+ return type === 'row' ? index % map.width === 0 : index < map.width;
207
+ };
160
208
  var deleteTable = exports.deleteTable = function deleteTable(state, dispatch) {
161
209
  if (dispatch) {
162
210
  dispatch((0, _utils2.removeTable)(state.tr));
@@ -19,11 +19,13 @@ var _pmPlugins = require("@atlaskit/editor-tables/pm-plugins");
19
19
  var _utils2 = require("@atlaskit/editor-tables/utils");
20
20
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
21
21
  var _createPluginConfig = require("./create-plugin-config");
22
- var _plugin = require("./pm-plugins/decorations/plugin");
22
+ var _plugin = require("./pm-plugins/analytics/plugin");
23
+ var _pluginKey = require("./pm-plugins/analytics/plugin-key");
24
+ var _plugin2 = require("./pm-plugins/decorations/plugin");
23
25
  var _dragAndDrop = require("./pm-plugins/drag-and-drop");
24
26
  var _keymap = require("./pm-plugins/keymap");
25
27
  var _main = require("./pm-plugins/main");
26
- var _pluginKey = require("./pm-plugins/plugin-key");
28
+ var _pluginKey2 = require("./pm-plugins/plugin-key");
27
29
  var _safariDeleteCompositionTextIssueWorkaround = require("./pm-plugins/safari-delete-composition-text-issue-workaround");
28
30
  var _stickyHeaders = require("./pm-plugins/sticky-headers");
29
31
  var _tableAnalytics = require("./pm-plugins/table-analytics");
@@ -134,7 +136,7 @@ var tablesPlugin = function tablesPlugin(_ref) {
134
136
  }, {
135
137
  name: 'tableEditing',
136
138
  plugin: function plugin() {
137
- return (0, _plugin.createPlugin)();
139
+ return (0, _plugin2.createPlugin)();
138
140
  }
139
141
  },
140
142
  // Needs to be lower priority than editor-tables.tableEditing
@@ -198,14 +200,23 @@ var tablesPlugin = function tablesPlugin(_ref) {
198
200
  dispatch = _ref10.dispatch;
199
201
  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;
200
202
  }
201
- }, {
202
- name: 'tableAnalyticsPlugin',
203
+ },
204
+ // TODO: should be deprecated and eventually replaced with 'tableAnalyticsPlugin'
205
+ {
206
+ name: 'tableOverflowAnalyticsPlugin',
203
207
  plugin: function plugin(_ref11) {
204
208
  var _options$tableResizin;
205
209
  var dispatch = _ref11.dispatch,
206
210
  dispatchAnalyticsEvent = _ref11.dispatchAnalyticsEvent;
207
211
  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;
208
212
  }
213
+ }, {
214
+ name: 'tableAnalyticsPlugin',
215
+ plugin: function plugin(_ref12) {
216
+ var dispatch = _ref12.dispatch,
217
+ dispatchAnalyticsEvent = _ref12.dispatchAnalyticsEvent;
218
+ return (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.analytics-plugin-moved-event') ? (0, _plugin.createPlugin)(dispatch, dispatchAnalyticsEvent) : undefined;
219
+ }
209
220
  }, {
210
221
  name: 'tableGetEditorViewReferencePlugin',
211
222
  plugin: function plugin() {
@@ -234,49 +245,49 @@ var tablesPlugin = function tablesPlugin(_ref) {
234
245
  }
235
246
  return plugins;
236
247
  },
237
- contentComponent: function contentComponent(_ref12) {
238
- var editorView = _ref12.editorView,
239
- popupsMountPoint = _ref12.popupsMountPoint,
240
- popupsBoundariesElement = _ref12.popupsBoundariesElement,
241
- popupsScrollableElement = _ref12.popupsScrollableElement,
242
- dispatchAnalyticsEvent = _ref12.dispatchAnalyticsEvent;
248
+ contentComponent: function contentComponent(_ref13) {
249
+ var editorView = _ref13.editorView,
250
+ popupsMountPoint = _ref13.popupsMountPoint,
251
+ popupsBoundariesElement = _ref13.popupsBoundariesElement,
252
+ popupsScrollableElement = _ref13.popupsScrollableElement,
253
+ dispatchAnalyticsEvent = _ref13.dispatchAnalyticsEvent;
243
254
  return /*#__PURE__*/_react.default.createElement(_errorBoundary.ErrorBoundary, {
244
255
  component: _analytics.ACTION_SUBJECT.TABLES_PLUGIN,
245
256
  dispatchAnalyticsEvent: dispatchAnalyticsEvent,
246
257
  fallbackComponent: null
247
258
  }, /*#__PURE__*/_react.default.createElement(_withPluginState.WithPluginState, {
248
259
  plugins: {
249
- tableAnalyticsPluginState: _tableAnalytics.pluginKey,
250
- tablePluginState: _pluginKey.pluginKey,
260
+ tableAnalyticsPluginState: _pluginKey.pluginKey,
261
+ tablePluginState: _pluginKey2.pluginKey,
251
262
  tableWidthPluginState: _tableWidth.pluginKey,
252
263
  tableResizingPluginState: _tableResizing.pluginKey,
253
264
  stickyHeadersState: _stickyHeaders.pluginKey,
254
265
  dragAndDropState: _dragAndDrop.pluginKey
255
266
  },
256
- render: function render(_ref13) {
257
- var resizingPluginState = _ref13.tableResizingPluginState,
258
- stickyHeadersState = _ref13.stickyHeadersState,
259
- tablePluginState = _ref13.tablePluginState,
260
- tableWidthPluginState = _ref13.tableWidthPluginState,
261
- dragAndDropState = _ref13.dragAndDropState;
267
+ render: function render(_ref14) {
268
+ var resizingPluginState = _ref14.tableResizingPluginState,
269
+ stickyHeadersState = _ref14.stickyHeadersState,
270
+ tablePluginState = _ref14.tablePluginState,
271
+ tableWidthPluginState = _ref14.tableWidthPluginState,
272
+ dragAndDropState = _ref14.dragAndDropState;
262
273
  var state = editorView.state;
263
274
  var isColumnResizing = resizingPluginState === null || resizingPluginState === void 0 ? void 0 : resizingPluginState.dragging;
264
275
  var isTableResizing = tableWidthPluginState === null || tableWidthPluginState === void 0 ? void 0 : tableWidthPluginState.resizing;
265
276
  var isResizing = isColumnResizing || isTableResizing;
266
- var _ref14 = tablePluginState,
267
- tableNode = _ref14.tableNode,
268
- tablePos = _ref14.tablePos,
269
- targetCellPosition = _ref14.targetCellPosition,
270
- isContextualMenuOpen = _ref14.isContextualMenuOpen,
271
- layout = _ref14.layout,
272
- tableRef = _ref14.tableRef,
273
- pluginConfig = _ref14.pluginConfig,
274
- insertColumnButtonIndex = _ref14.insertColumnButtonIndex,
275
- insertRowButtonIndex = _ref14.insertRowButtonIndex,
276
- isHeaderColumnEnabled = _ref14.isHeaderColumnEnabled,
277
- isHeaderRowEnabled = _ref14.isHeaderRowEnabled,
278
- isDragAndDropEnabled = _ref14.isDragAndDropEnabled,
279
- tableWrapperTarget = _ref14.tableWrapperTarget;
277
+ var _ref15 = tablePluginState,
278
+ tableNode = _ref15.tableNode,
279
+ tablePos = _ref15.tablePos,
280
+ targetCellPosition = _ref15.targetCellPosition,
281
+ isContextualMenuOpen = _ref15.isContextualMenuOpen,
282
+ layout = _ref15.layout,
283
+ tableRef = _ref15.tableRef,
284
+ pluginConfig = _ref15.pluginConfig,
285
+ insertColumnButtonIndex = _ref15.insertColumnButtonIndex,
286
+ insertRowButtonIndex = _ref15.insertRowButtonIndex,
287
+ isHeaderColumnEnabled = _ref15.isHeaderColumnEnabled,
288
+ isHeaderRowEnabled = _ref15.isHeaderRowEnabled,
289
+ isDragAndDropEnabled = _ref15.isDragAndDropEnabled,
290
+ tableWrapperTarget = _ref15.tableWrapperTarget;
280
291
  var allowControls = pluginConfig.allowControls;
281
292
  var stickyHeader = stickyHeadersState ? (0, _stickyHeaders.findStickyHeaderForTable)(stickyHeadersState, tablePos) : undefined;
282
293
  var LayoutContent = options && !options.tableResizingEnabled && (0, _utils3.isLayoutSupported)(state) && options.breakoutEnabled ? /*#__PURE__*/_react.default.createElement(_LayoutButton.default, {
@@ -354,8 +365,8 @@ var tablesPlugin = function tablesPlugin(_ref) {
354
365
  }));
355
366
  },
356
367
  pluginsOptions: {
357
- quickInsert: function quickInsert(_ref15) {
358
- var formatMessage = _ref15.formatMessage;
368
+ quickInsert: function quickInsert(_ref16) {
369
+ var formatMessage = _ref16.formatMessage;
359
370
  return [{
360
371
  id: 'table',
361
372
  title: formatMessage(_messages.toolbarInsertBlockMessages.table),
@@ -17,7 +17,6 @@ var _classnames2 = _interopRequireDefault(require("classnames"));
17
17
  var _memoizeOne = _interopRequireDefault(require("memoize-one"));
18
18
  var _rafSchd = _interopRequireDefault(require("raf-schd"));
19
19
  var _analytics = require("@atlaskit/editor-common/analytics");
20
- var _eventDispatcher = require("@atlaskit/editor-common/event-dispatcher");
21
20
  var _nodeWidth = require("@atlaskit/editor-common/node-width");
22
21
  var _styles = require("@atlaskit/editor-common/styles");
23
22
  var _utils = require("@atlaskit/editor-common/utils");
@@ -197,25 +196,22 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
197
196
  (0, _defineProperty3.default)((0, _assertThisInitialized2.default)(_this), "setTimerToSendInitialOverflowCaptured", function (isOverflowing) {
198
197
  var _this$state;
199
198
  var _this$props3 = _this.props,
200
- eventDispatcher = _this$props3.eventDispatcher,
199
+ dispatchAnalyticsEvent = _this$props3.dispatchAnalyticsEvent,
201
200
  containerWidth = _this$props3.containerWidth,
202
201
  options = _this$props3.options;
203
- var dispatch = (0, _eventDispatcher.createDispatch)(eventDispatcher);
204
202
  var parentWidth = ((_this$state = _this.state) === null || _this$state === void 0 ? void 0 : _this$state.parentWidth) || 0;
205
203
  _this.initialOverflowCaptureTimerId = setTimeout(function () {
206
- dispatch(_utils.analyticsEventKey, {
207
- payload: {
208
- action: _analytics.TABLE_ACTION.INITIAL_OVERFLOW_CAPTURED,
209
- actionSubject: _analytics.ACTION_SUBJECT.TABLE,
210
- actionSubjectId: null,
211
- eventType: _analytics.EVENT_TYPE.TRACK,
212
- attributes: {
213
- editorWidth: containerWidth.width || 0,
214
- isOverflowing: isOverflowing,
215
- tableResizingEnabled: (options === null || options === void 0 ? void 0 : options.isTableResizingEnabled) || false,
216
- width: _this.node.attrs.width || 0,
217
- parentWidth: parentWidth
218
- }
204
+ dispatchAnalyticsEvent({
205
+ action: _analytics.TABLE_ACTION.INITIAL_OVERFLOW_CAPTURED,
206
+ actionSubject: _analytics.ACTION_SUBJECT.TABLE,
207
+ actionSubjectId: null,
208
+ eventType: _analytics.EVENT_TYPE.TRACK,
209
+ attributes: {
210
+ editorWidth: containerWidth.width || 0,
211
+ isOverflowing: isOverflowing,
212
+ tableResizingEnabled: (options === null || options === void 0 ? void 0 : options.isTableResizingEnabled) || false,
213
+ width: _this.node.attrs.width || 0,
214
+ parentWidth: parentWidth
219
215
  }
220
216
  });
221
217
  _this.isInitialOverflowSent = true;
@@ -145,10 +145,10 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
145
145
  isResizing.current = true;
146
146
  var dispatch = editorView.dispatch,
147
147
  tr = editorView.state.tr;
148
+ displayGapCursor(false);
148
149
  tr.setMeta(_tableWidth.pluginKey, {
149
150
  resizing: true
150
151
  });
151
- displayGapCursor(false);
152
152
  tr.setMeta(_tableAnalytics.META_KEYS.OVERFLOW_TRIGGER, {
153
153
  name: _analytics.TABLE_OVERFLOW_CHANGE_TRIGGER.RESIZED
154
154
  });
@@ -184,6 +184,7 @@ var TableView = exports.default = /*#__PURE__*/function (_ReactNodeView) {
184
184
  containerWidth: containerWidth,
185
185
  contentDOM: forwardRef,
186
186
  getEditorFeatureFlags: props.getEditorFeatureFlags,
187
+ dispatchAnalyticsEvent: props.dispatchAnalyticsEvent,
187
188
  pluginInjectionApi: props.pluginInjectionApi
188
189
  });
189
190
  }
@@ -249,7 +250,7 @@ var TableView = exports.default = /*#__PURE__*/function (_ReactNodeView) {
249
250
  }]);
250
251
  return TableView;
251
252
  }(_reactNodeView.default);
252
- var createTableView = exports.createTableView = function createTableView(node, view, getPos, portalProviderAPI, eventDispatcher, getEditorContainerWidth, getEditorFeatureFlags, pluginInjectionApi) {
253
+ var createTableView = exports.createTableView = function createTableView(node, view, getPos, portalProviderAPI, eventDispatcher, getEditorContainerWidth, getEditorFeatureFlags, dispatchAnalyticsEvent, pluginInjectionApi) {
253
254
  var _getPluginState2 = (0, _pluginFactory.getPluginState)(view.state),
254
255
  pluginConfig = _getPluginState2.pluginConfig,
255
256
  isBreakoutEnabled = _getPluginState2.isBreakoutEnabled,
@@ -276,6 +277,7 @@ var createTableView = exports.createTableView = function createTableView(node, v
276
277
  },
277
278
  getEditorContainerWidth: getEditorContainerWidth,
278
279
  getEditorFeatureFlags: getEditorFeatureFlags,
280
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent,
279
281
  hasIntlContext: hasIntlContext,
280
282
  pluginInjectionApi: pluginInjectionApi
281
283
  }).init();
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.AnalyticPluginTypes = void 0;
7
+ var AnalyticPluginTypes = exports.AnalyticPluginTypes = /*#__PURE__*/function (AnalyticPluginTypes) {
8
+ AnalyticPluginTypes[AnalyticPluginTypes["UpdateOverflowTriggerNameAction"] = 0] = "UpdateOverflowTriggerNameAction";
9
+ AnalyticPluginTypes[AnalyticPluginTypes["UpdateRowOrColumnMovedAction"] = 1] = "UpdateRowOrColumnMovedAction";
10
+ AnalyticPluginTypes[AnalyticPluginTypes["RemoveRowOrColumnMovedAction"] = 2] = "RemoveRowOrColumnMovedAction";
11
+ AnalyticPluginTypes[AnalyticPluginTypes["RemoveOverFlowTriggerNameAction"] = 3] = "RemoveOverFlowTriggerNameAction";
12
+ AnalyticPluginTypes[AnalyticPluginTypes["UpdateRowOrColumnMovedAndOverflowTrigger"] = 4] = "UpdateRowOrColumnMovedAndOverflowTrigger";
13
+ return AnalyticPluginTypes;
14
+ }({});
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.updateRowOrColumnMovedTransform = exports.updateRowOrColumnMoved = exports.resetRowOrColumnMovedTransform = void 0;
7
+ var _actions = require("./actions");
8
+ var _pluginFactory = require("./plugin-factory");
9
+ var _pluginKey = require("./plugin-key");
10
+ var _movedEvent = require("./utils/moved-event");
11
+ var updateRowOrColumnMoved = exports.updateRowOrColumnMoved = function updateRowOrColumnMoved(nextState, nextAction) {
12
+ return (0, _pluginFactory.createCommand)(function (state) {
13
+ var _getPluginState = (0, _pluginFactory.getPluginState)(state),
14
+ rowOrColumnMoved = _getPluginState.rowOrColumnMoved;
15
+ var data = (0, _movedEvent.getMovedPayload)(nextState, nextAction, rowOrColumnMoved);
16
+ return {
17
+ type: _actions.AnalyticPluginTypes.UpdateRowOrColumnMovedAction,
18
+ data: data
19
+ };
20
+ }, function (tr) {
21
+ return tr.setMeta('addToHistory', false);
22
+ });
23
+ };
24
+
25
+ // --- transforms, prefer these over commands to avoid an extra 'dispatch'
26
+ var resetRowOrColumnMovedTransform = exports.resetRowOrColumnMovedTransform = function resetRowOrColumnMovedTransform() {
27
+ return function (tr) {
28
+ var payload = {
29
+ type: _actions.AnalyticPluginTypes.RemoveRowOrColumnMovedAction
30
+ };
31
+ return tr.setMeta(_pluginKey.pluginKey, payload);
32
+ };
33
+ };
34
+ var updateRowOrColumnMovedTransform = exports.updateRowOrColumnMovedTransform = function updateRowOrColumnMovedTransform(nextState, nextAction) {
35
+ return function (state, tr) {
36
+ var _getPluginState2 = (0, _pluginFactory.getPluginState)(state),
37
+ rowOrColumnMoved = _getPluginState2.rowOrColumnMoved;
38
+ var data = (0, _movedEvent.getMovedPayload)(nextState, nextAction, rowOrColumnMoved);
39
+ var payload = {
40
+ type: _actions.AnalyticPluginTypes.UpdateRowOrColumnMovedAction,
41
+ data: data
42
+ };
43
+ return tr.setMeta(_pluginKey.pluginKey, payload);
44
+ };
45
+ };
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getPluginState = exports.createPluginState = exports.createCommand = void 0;
7
+ var _utils = require("@atlaskit/editor-common/utils");
8
+ var _pluginKey = require("./plugin-key");
9
+ var _reducer = require("./reducer");
10
+ var _pluginFactory = (0, _utils.pluginFactory)(_pluginKey.pluginKey, _reducer.reducer),
11
+ createPluginState = exports.createPluginState = _pluginFactory.createPluginState,
12
+ createCommand = exports.createCommand = _pluginFactory.createCommand,
13
+ getPluginState = exports.getPluginState = _pluginFactory.getPluginState;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.pluginKey = void 0;
7
+ var _state = require("@atlaskit/editor-prosemirror/state");
8
+ var pluginKey = exports.pluginKey = new _state.PluginKey('tableAnalyticPlugin');
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createPlugin = void 0;
7
+ var _analytics = require("@atlaskit/editor-common/analytics");
8
+ var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
9
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
10
+ var _misc = require("../../commands/misc");
11
+ var _commands = require("./commands");
12
+ var _pluginFactory = require("./plugin-factory");
13
+ var _pluginKey = require("./plugin-key");
14
+ var _types = require("./types");
15
+ var createPlugin = exports.createPlugin = function createPlugin(dispatch, dispatchAnalyticsEvent) {
16
+ return new _safePlugin.SafePlugin({
17
+ key: _pluginKey.pluginKey,
18
+ state: (0, _pluginFactory.createPluginState)(dispatch, _types.defaultState),
19
+ appendTransaction: function appendTransaction(transactions, oldState, newState) {
20
+ var tr = transactions.find(function (tr) {
21
+ var _tr$getMeta;
22
+ return (_tr$getMeta = tr.getMeta(_pluginKey.pluginKey)) === null || _tr$getMeta === void 0 || (_tr$getMeta = _tr$getMeta.data) === null || _tr$getMeta === void 0 || (_tr$getMeta = _tr$getMeta.currentActions) === null || _tr$getMeta === void 0 ? void 0 : _tr$getMeta.includes('pasted');
23
+ });
24
+ if (tr) {
25
+ var _tr$getMeta2;
26
+ dispatchAnalyticsEvent({
27
+ action: _analytics.TABLE_ACTION.ROW_OR_COLUMN_MOVED,
28
+ actionSubject: _analytics.ACTION_SUBJECT.TABLE,
29
+ actionSubjectId: null,
30
+ eventType: _analytics.EVENT_TYPE.TRACK,
31
+ attributes: {
32
+ type: (_tr$getMeta2 = tr.getMeta(_pluginKey.pluginKey)) === null || _tr$getMeta2 === void 0 || (_tr$getMeta2 = _tr$getMeta2.data) === null || _tr$getMeta2 === void 0 ? void 0 : _tr$getMeta2.type
33
+ }
34
+ });
35
+ return (0, _commands.resetRowOrColumnMovedTransform)()(tr);
36
+ }
37
+ return undefined;
38
+ },
39
+ props: {
40
+ handlePaste: function handlePaste(_ref, event, slice) {
41
+ var state = _ref.state,
42
+ dispatch = _ref.dispatch;
43
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.analytics-plugin-moved-event')) {
44
+ var schema = state.schema;
45
+ var type = (0, _misc.getTableElementMoveTypeBySlice)(slice, state);
46
+
47
+ // if the selection wasn't in the first cell of a row or column, don't count it
48
+ if (!(0, _misc.isInsideFirstCellOfRowOrColumn)(state.selection, type)) {
49
+ return;
50
+ }
51
+ var count = (0, _misc.countCellsInSlice)(slice, schema, type);
52
+ (0, _commands.updateRowOrColumnMoved)({
53
+ numberOfCells: count,
54
+ type: type
55
+ }, 'pasted')(state, dispatch);
56
+ }
57
+ },
58
+ transformCopied: function transformCopied(slice, _ref2) {
59
+ var state = _ref2.state,
60
+ dispatch = _ref2.dispatch;
61
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.analytics-plugin-moved-event')) {
62
+ var schema = state.schema;
63
+ var type = (0, _misc.getTableSelectionType)(state.selection);
64
+ var count = (0, _misc.countCellsInSlice)(slice, schema, type);
65
+ (0, _commands.updateRowOrColumnMoved)({
66
+ numberOfCells: count,
67
+ type: type
68
+ }, 'copyOrCut')(state, dispatch);
69
+ }
70
+ return slice;
71
+ }
72
+ }
73
+ });
74
+ };
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.reducer = void 0;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
+ var _actions = require("./actions");
10
+ var _types = require("./types");
11
+ 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
+ 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; }
13
+ var reducer = exports.reducer = function reducer(state, action) {
14
+ switch (action.type) {
15
+ case _actions.AnalyticPluginTypes.UpdateRowOrColumnMovedAction:
16
+ return _objectSpread(_objectSpread({}, state), {}, {
17
+ rowOrColumnMoved: _objectSpread(_objectSpread({}, state.rowOrColumnMoved), action.data)
18
+ });
19
+ case _actions.AnalyticPluginTypes.RemoveRowOrColumnMovedAction:
20
+ return _objectSpread(_objectSpread({}, state), {}, {
21
+ rowOrColumnMoved: _types.defaultState.rowOrColumnMoved
22
+ });
23
+ default:
24
+ return state;
25
+ }
26
+ };
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.defaultState = void 0;
7
+ var defaultState = exports.defaultState = {
8
+ rowOrColumnMoved: {
9
+ type: undefined,
10
+ numberOfCells: undefined,
11
+ currentActions: []
12
+ }
13
+ };
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.getMovedPayload = void 0;
8
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
+ var _types = require("../types");
10
+ var getNextActionType = function getNextActionType(nextState, nextAction, prevState) {
11
+ if (nextAction === 'pasted') {
12
+ if (prevState && prevState.currentActions.includes('copyOrCut') && prevState.currentActions.includes('addRowOrColumn') && prevState.numberOfCells === nextState.numberOfCells && prevState.type === nextState.type) {
13
+ return 'pasted';
14
+ }
15
+ return 'none';
16
+ }
17
+ return nextAction;
18
+ };
19
+ var getMovedPayload = exports.getMovedPayload = function getMovedPayload(nextState, nextAction, prevState) {
20
+ var nextActionType = getNextActionType(nextState, nextAction, prevState);
21
+ if (nextActionType === 'none') {
22
+ return _types.defaultState.rowOrColumnMoved;
23
+ }
24
+
25
+ // a new workflow has started in the opposite axis (e.g. inserted a row, but copied a column) remove old state
26
+ if (prevState.type !== nextState.type) {
27
+ return {
28
+ currentActions: [nextActionType],
29
+ numberOfCells: nextState === null || nextState === void 0 ? void 0 : nextState.numberOfCells,
30
+ type: nextState.type
31
+ };
32
+ }
33
+ return {
34
+ currentActions: prevState.currentActions.includes(nextActionType) ? prevState.currentActions : [].concat((0, _toConsumableArray2.default)(prevState.currentActions), [nextActionType]),
35
+ numberOfCells: (nextState === null || nextState === void 0 ? void 0 : nextState.numberOfCells) || prevState.numberOfCells,
36
+ type: nextState === null || nextState === void 0 ? void 0 : nextState.type
37
+ };
38
+ };
@@ -232,7 +232,7 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatchAnalytic
232
232
  },
233
233
  nodeViews: {
234
234
  table: function table(node, view, getPos) {
235
- return (0, _table.createTableView)(node, view, getPos, portalProviderAPI, eventDispatcher, getEditorContainerWidth, getEditorFeatureFlags, pluginInjectionApi);
235
+ return (0, _table.createTableView)(node, view, getPos, portalProviderAPI, eventDispatcher, getEditorContainerWidth, getEditorFeatureFlags, dispatchAnalyticsEvent, pluginInjectionApi);
236
236
  },
237
237
  tableRow: function tableRow(node, view, getPos) {
238
238
  return new _TableRow.default(node, view, getPos, eventDispatcher);
@@ -13,7 +13,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
13
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
14
  * A plugin is created for collecting payload data for tableOverflowChanged analytics event
15
15
  */
16
- var pluginKey = exports.pluginKey = new _state.PluginKey('tableAnalyticsPlugin');
16
+ var pluginKey = exports.pluginKey = new _state.PluginKey('tableOverflowAnalyticsPlugin');
17
17
  var META_KEYS = exports.META_KEYS = {
18
18
  OVERFLOW_TRIGGER: 'tableOverflowTrigger',
19
19
  OVERFLOW_STATE_CHANGED: 'tableOverflowStateChanged'