@atlaskit/editor-plugin-table 1.7.3 → 2.0.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 (40) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/cjs/plugins/table/index.js +11 -16
  3. package/dist/cjs/plugins/table/nodeviews/TableComponent.js +7 -3
  4. package/dist/cjs/plugins/table/nodeviews/TableContainer.js +23 -19
  5. package/dist/cjs/plugins/table/nodeviews/TableResizer.js +2 -1
  6. package/dist/cjs/plugins/table/nodeviews/table.js +5 -1
  7. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/scale-table.js +8 -1
  8. package/dist/cjs/version.json +1 -1
  9. package/dist/es2019/plugins/table/index.js +11 -16
  10. package/dist/es2019/plugins/table/nodeviews/TableComponent.js +7 -3
  11. package/dist/es2019/plugins/table/nodeviews/TableContainer.js +22 -18
  12. package/dist/es2019/plugins/table/nodeviews/TableResizer.js +3 -2
  13. package/dist/es2019/plugins/table/nodeviews/table.js +5 -1
  14. package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/scale-table.js +8 -1
  15. package/dist/es2019/version.json +1 -1
  16. package/dist/esm/plugins/table/index.js +11 -16
  17. package/dist/esm/plugins/table/nodeviews/TableComponent.js +7 -3
  18. package/dist/esm/plugins/table/nodeviews/TableContainer.js +23 -19
  19. package/dist/esm/plugins/table/nodeviews/TableResizer.js +3 -2
  20. package/dist/esm/plugins/table/nodeviews/table.js +5 -1
  21. package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/scale-table.js +8 -1
  22. package/dist/esm/version.json +1 -1
  23. package/dist/types/plugins/table/index.d.ts +0 -2
  24. package/dist/types/plugins/table/nodeviews/TableContainer.d.ts +5 -3
  25. package/dist/types/plugins/table/nodeviews/TableResizer.d.ts +2 -1
  26. package/dist/types-ts4.5/plugins/table/index.d.ts +0 -2
  27. package/dist/types-ts4.5/plugins/table/nodeviews/TableContainer.d.ts +5 -3
  28. package/dist/types-ts4.5/plugins/table/nodeviews/TableResizer.d.ts +2 -1
  29. package/package.json +5 -7
  30. package/report.api.md +0 -3
  31. package/src/__tests__/unit/analytics.ts +20 -10
  32. package/src/__tests__/unit/keymap.ts +14 -21
  33. package/src/__tests__/unit/pm-plugins/table-resizing/event-handlers.ts +12 -7
  34. package/src/plugins/table/index.tsx +12 -25
  35. package/src/plugins/table/nodeviews/TableComponent.tsx +10 -4
  36. package/src/plugins/table/nodeviews/TableContainer.tsx +28 -19
  37. package/src/plugins/table/nodeviews/TableResizer.tsx +3 -2
  38. package/src/plugins/table/nodeviews/table.tsx +6 -0
  39. package/src/plugins/table/pm-plugins/table-resizing/utils/scale-table.ts +10 -1
  40. package/tmp/api-report-tmp.d.ts +0 -107
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "1.7.3",
3
+ "version": "2.0.1",
4
4
  "sideEffects": false
5
5
  }
@@ -33,6 +33,7 @@ var defaultGetEditorFeatureFlags = function defaultGetEditorFeatureFlags() {
33
33
  return {};
34
34
  };
35
35
  var tablesPlugin = function tablesPlugin(options, api) {
36
+ var _api$dependencies$ana;
36
37
  var editorViewRef = {
37
38
  current: null
38
39
  };
@@ -43,6 +44,7 @@ var tablesPlugin = function tablesPlugin(options, api) {
43
44
  };
44
45
  return (_api$dependencies$wid = api === null || api === void 0 ? void 0 : api.dependencies.width.sharedState.currentState()) !== null && _api$dependencies$wid !== void 0 ? _api$dependencies$wid : defaultState;
45
46
  };
47
+ var editorAnalyticsAPI = api === null || api === void 0 ? void 0 : (_api$dependencies$ana = api.dependencies.analytics) === null || _api$dependencies$ana === void 0 ? void 0 : _api$dependencies$ana.actions;
46
48
  return {
47
49
  name: 'table',
48
50
  actions: {
@@ -84,19 +86,15 @@ var tablesPlugin = function tablesPlugin(options, api) {
84
86
  var plugins = [{
85
87
  name: 'table',
86
88
  plugin: function plugin(_ref) {
87
- var _api$dependencies$ana;
88
89
  var dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent,
89
90
  dispatch = _ref.dispatch,
90
91
  portalProviderAPI = _ref.portalProviderAPI,
91
92
  eventDispatcher = _ref.eventDispatcher;
92
- var _ref2 = options || {
93
- editorAnalyticsAPI: api === null || api === void 0 ? void 0 : (_api$dependencies$ana = api.dependencies.analytics) === null || _api$dependencies$ana === void 0 ? void 0 : _api$dependencies$ana.actions
94
- },
93
+ var _ref2 = options || {},
95
94
  fullWidthEnabled = _ref2.fullWidthEnabled,
96
95
  wasFullWidthEnabled = _ref2.wasFullWidthEnabled,
97
96
  breakoutEnabled = _ref2.breakoutEnabled,
98
97
  tableOptions = _ref2.tableOptions,
99
- editorAnalyticsAPI = _ref2.editorAnalyticsAPI,
100
98
  getEditorFeatureFlags = _ref2.getEditorFeatureFlags;
101
99
  return createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig(tableOptions), defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, breakoutEnabled, fullWidthEnabled, wasFullWidthEnabled, editorAnalyticsAPI);
102
100
  }
@@ -107,7 +105,6 @@ var tablesPlugin = function tablesPlugin(options, api) {
107
105
  var _ref4 = options || {},
108
106
  fullWidthEnabled = _ref4.fullWidthEnabled,
109
107
  tableOptions = _ref4.tableOptions,
110
- editorAnalyticsAPI = _ref4.editorAnalyticsAPI,
111
108
  getEditorFeatureFlags = _ref4.getEditorFeatureFlags;
112
109
  var _pluginConfig = pluginConfig(tableOptions),
113
110
  allowColumnResizing = _pluginConfig.allowColumnResizing;
@@ -126,7 +123,7 @@ var tablesPlugin = function tablesPlugin(options, api) {
126
123
  {
127
124
  name: 'tableKeymap',
128
125
  plugin: function plugin() {
129
- return keymapPlugin(defaultGetEditorContainerWidth, options === null || options === void 0 ? void 0 : options.editorAnalyticsAPI);
126
+ return keymapPlugin(defaultGetEditorContainerWidth, editorAnalyticsAPI);
130
127
  }
131
128
  }, {
132
129
  name: 'tableSelectionKeymap',
@@ -138,11 +135,10 @@ var tablesPlugin = function tablesPlugin(options, api) {
138
135
  plugin: function plugin() {
139
136
  return tableEditing({
140
137
  reportFixedTable: function reportFixedTable(_ref5) {
141
- var _options$editorAnalyt;
142
138
  var state = _ref5.state,
143
139
  tr = _ref5.tr,
144
140
  reason = _ref5.reason;
145
- options === null || options === void 0 ? void 0 : (_options$editorAnalyt = options.editorAnalyticsAPI) === null || _options$editorAnalyt === void 0 ? void 0 : _options$editorAnalyt.attachAnalyticsEvent({
141
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
146
142
  action: TABLE_ACTION.FIXED,
147
143
  actionSubject: ACTION_SUBJECT.TABLE,
148
144
  actionSubjectId: null,
@@ -249,7 +245,7 @@ var tablesPlugin = function tablesPlugin(options, api) {
249
245
  layout: layout,
250
246
  isResizing: !!resizingPluginState && !!resizingPluginState.dragging,
251
247
  stickyHeader: stickyHeader,
252
- editorAnalyticsAPI: options === null || options === void 0 ? void 0 : options.editorAnalyticsAPI
248
+ editorAnalyticsAPI: editorAnalyticsAPI
253
249
  }) : null;
254
250
  return /*#__PURE__*/React.createElement(React.Fragment, null, targetCellPosition && tableRef && !isDragging && options && options.allowContextualMenu && /*#__PURE__*/React.createElement(FloatingContextualButton, {
255
251
  isNumberColumnEnabled: tableNode && tableNode.attrs.isNumberColumnEnabled,
@@ -276,7 +272,7 @@ var tablesPlugin = function tablesPlugin(options, api) {
276
272
  scrollableElement: popupsScrollableElement,
277
273
  hasStickyHeaders: stickyHeader && stickyHeader.sticky,
278
274
  dispatchAnalyticsEvent: dispatchAnalyticsEvent,
279
- editorAnalyticsAPI: options === null || options === void 0 ? void 0 : options.editorAnalyticsAPI,
275
+ editorAnalyticsAPI: editorAnalyticsAPI,
280
276
  getEditorContainerWidth: defaultGetEditorContainerWidth
281
277
  }), /*#__PURE__*/React.createElement(FloatingContextualMenu, {
282
278
  editorView: editorView,
@@ -285,7 +281,7 @@ var tablesPlugin = function tablesPlugin(options, api) {
285
281
  targetCellPosition: targetCellPosition,
286
282
  isOpen: Boolean(isContextualMenuOpen),
287
283
  pluginConfig: pluginConfig,
288
- editorAnalyticsAPI: options === null || options === void 0 ? void 0 : options.editorAnalyticsAPI,
284
+ editorAnalyticsAPI: editorAnalyticsAPI,
289
285
  getEditorContainerWidth: defaultGetEditorContainerWidth,
290
286
  getEditorFeatureFlags: (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags
291
287
  }), allowControls && /*#__PURE__*/React.createElement(FloatingDeleteButton, {
@@ -297,7 +293,7 @@ var tablesPlugin = function tablesPlugin(options, api) {
297
293
  scrollableElement: popupsScrollableElement,
298
294
  stickyHeaders: stickyHeader,
299
295
  isNumberColumnEnabled: tableNode && tableNode.attrs.isNumberColumnEnabled,
300
- editorAnalyticsAPI: options === null || options === void 0 ? void 0 : options.editorAnalyticsAPI
296
+ editorAnalyticsAPI: editorAnalyticsAPI
301
297
  }), LayoutContent);
302
298
  }
303
299
  }));
@@ -316,11 +312,10 @@ var tablesPlugin = function tablesPlugin(options, api) {
316
312
  return /*#__PURE__*/React.createElement(IconTable, null);
317
313
  },
318
314
  action: function action(insert, state) {
319
- var _options$editorAnalyt2;
320
315
  var tr = insert(createTable({
321
316
  schema: state.schema
322
317
  }));
323
- options === null || options === void 0 ? void 0 : (_options$editorAnalyt2 = options.editorAnalyticsAPI) === null || _options$editorAnalyt2 === void 0 ? void 0 : _options$editorAnalyt2.attachAnalyticsEvent({
318
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
324
319
  action: ACTION.INSERTED,
325
320
  actionSubject: ACTION_SUBJECT.DOCUMENT,
326
321
  actionSubjectId: ACTION_SUBJECT_ID.TABLE,
@@ -333,7 +328,7 @@ var tablesPlugin = function tablesPlugin(options, api) {
333
328
  }
334
329
  }];
335
330
  },
336
- floatingToolbar: getToolbarConfig(defaultGetEditorContainerWidth, options === null || options === void 0 ? void 0 : options.editorAnalyticsAPI, (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags, function () {
331
+ floatingToolbar: getToolbarConfig(defaultGetEditorContainerWidth, editorAnalyticsAPI, (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags, function () {
337
332
  return editorViewRef.current;
338
333
  })(pluginConfig(options === null || options === void 0 ? void 0 : options.tableOptions))
339
334
  }
@@ -278,7 +278,9 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
278
278
  * We no longer use `containerWidth` as a variable to determine an update for table resizing (avoids unnecessary updates).
279
279
  * Instead we use the resize event to only trigger updates when necessary.
280
280
  */
281
- window.addEventListener('resize', this.handleWindowResizeDebounced);
281
+ if (!getBooleanFF('platform.editor.custom-table-width')) {
282
+ window.addEventListener('resize', this.handleWindowResizeDebounced);
283
+ }
282
284
  this.handleTableResizingDebounced();
283
285
  }
284
286
  var currentStickyState = stickyHeadersPluginKey.getState(this.props.view.state);
@@ -297,8 +299,10 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
297
299
  this.scaleTableDebounced.cancel();
298
300
  this.handleTableResizingDebounced.cancel();
299
301
  this.handleAutoSizeDebounced.cancel();
300
- this.handleWindowResizeDebounced.cancel();
301
- if (this.props.allowColumnResizing) {
302
+ if (!getBooleanFF('platform.editor.custom-table-width')) {
303
+ this.handleWindowResizeDebounced.cancel();
304
+ }
305
+ if (!getBooleanFF('platform.editor.custom-table-width') && this.props.allowColumnResizing) {
302
306
  window.removeEventListener('resize', this.handleWindowResizeDebounced);
303
307
  }
304
308
  if (this.overflowShadowsObserver) {
@@ -4,6 +4,7 @@ import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
4
4
  import { calcTableWidth } from '@atlaskit/editor-common/styles';
5
5
  import { TableCssClassName as ClassName } from '../types';
6
6
  import { TableResizer } from './TableResizer';
7
+ import { TABLE_MAX_WIDTH } from '../pm-plugins/table-resizing/utils';
7
8
  var getMarginLeft = function getMarginLeft(_ref) {
8
9
  var lineLength = _ref.lineLength,
9
10
  tableWidth = _ref.tableWidth;
@@ -17,17 +18,13 @@ var getMarginLeft = function getMarginLeft(_ref) {
17
18
  return marginLeft;
18
19
  };
19
20
  export var InnerContainer = /*#__PURE__*/forwardRef(function (_ref2, ref) {
20
- var marginLeft = _ref2.marginLeft,
21
- className = _ref2.className,
22
- width = _ref2.width,
21
+ var className = _ref2.className,
22
+ style = _ref2.style,
23
23
  node = _ref2.node,
24
24
  children = _ref2.children;
25
25
  return /*#__PURE__*/React.createElement("div", {
26
26
  ref: ref,
27
- style: {
28
- width: width,
29
- marginLeft: marginLeft
30
- },
27
+ style: style,
31
28
  className: className,
32
29
  "data-number-column": node.attrs.isNumberColumnEnabled,
33
30
  "data-layout": node.attrs.layout,
@@ -39,6 +36,7 @@ export var ResizableTableContainer = function ResizableTableContainer(_ref3) {
39
36
  className = _ref3.className,
40
37
  node = _ref3.node,
41
38
  lineLength = _ref3.lineLength,
39
+ containerWidth = _ref3.containerWidth,
42
40
  editorView = _ref3.editorView,
43
41
  getPos = _ref3.getPos,
44
42
  tableRef = _ref3.tableRef;
@@ -48,19 +46,24 @@ export var ResizableTableContainer = function ResizableTableContainer(_ref3) {
48
46
  if (!containerRef.current || !innerContainerRef.current) {
49
47
  return;
50
48
  }
51
- innerContainerRef.current.style.width = "".concat(width, "px");
52
49
  var marginLeft = getMarginLeft({
53
50
  lineLength: lineLength,
54
51
  tableWidth: width
55
52
  });
56
- containerRef.current.style.width = "".concat(width, "px");
57
- containerRef.current.style.marginLeft = "".concat(marginLeft, "px");
53
+ if (marginLeft) {
54
+ containerRef.current.style.marginLeft = "".concat(marginLeft, "px");
55
+ }
58
56
  }, [lineLength]);
59
- var width = getTableContainerWidth(node);
57
+ var tableWidth = getTableContainerWidth(node);
58
+
59
+ // 76 is currently an accepted padding value considering the spacing for resizer handle
60
+ var responsiveContainerWidth = containerWidth - 76;
61
+ var width = Math.min(tableWidth, responsiveContainerWidth);
60
62
  var marginLeft = getMarginLeft({
61
63
  lineLength: lineLength,
62
64
  tableWidth: width
63
65
  });
66
+ var maxResizerWidth = Math.min(responsiveContainerWidth, TABLE_MAX_WIDTH);
64
67
  return /*#__PURE__*/React.createElement("div", {
65
68
  style: {
66
69
  marginLeft: marginLeft,
@@ -70,6 +73,7 @@ export var ResizableTableContainer = function ResizableTableContainer(_ref3) {
70
73
  ref: containerRef
71
74
  }, /*#__PURE__*/React.createElement(TableResizer, {
72
75
  width: width,
76
+ maxWidth: maxResizerWidth,
73
77
  updateWidth: updateWidth,
74
78
  editorView: editorView,
75
79
  getPos: getPos,
@@ -78,9 +82,7 @@ export var ResizableTableContainer = function ResizableTableContainer(_ref3) {
78
82
  }, /*#__PURE__*/React.createElement(InnerContainer, {
79
83
  ref: innerContainerRef,
80
84
  className: className,
81
- node: node,
82
- width: width,
83
- marginLeft: 0
85
+ node: node
84
86
  }, children)));
85
87
  };
86
88
  export var TableContainer = function TableContainer(_ref4) {
@@ -110,10 +112,12 @@ export var TableContainer = function TableContainer(_ref4) {
110
112
  return /*#__PURE__*/React.createElement(InnerContainer, {
111
113
  node: node,
112
114
  className: className,
113
- width: tableWidth,
114
- marginLeft: getMarginLeft({
115
- lineLength: lineLength,
116
- tableWidth: tableWidth
117
- })
115
+ style: {
116
+ width: tableWidth,
117
+ marginLeft: getMarginLeft({
118
+ lineLength: lineLength,
119
+ tableWidth: tableWidth
120
+ })
121
+ }
118
122
  }, children);
119
123
  };
@@ -4,13 +4,14 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
4
4
  import React from 'react';
5
5
  import rafSchd from 'raf-schd';
6
6
  import { ResizerNext } from '@atlaskit/editor-common/resizer';
7
- import { scaleTable, previewScaleTable, getColgroupChildrenLength, COLUMN_MIN_WIDTH, TABLE_MAX_WIDTH } from '../pm-plugins/table-resizing/utils';
7
+ import { scaleTable, previewScaleTable, getColgroupChildrenLength, COLUMN_MIN_WIDTH } from '../pm-plugins/table-resizing/utils';
8
8
  var handles = {
9
9
  right: true
10
10
  };
11
11
  export var TableResizer = function TableResizer(_ref) {
12
12
  var children = _ref.children,
13
13
  width = _ref.width,
14
+ maxWidth = _ref.maxWidth,
14
15
  updateWidth = _ref.updateWidth,
15
16
  editorView = _ref.editorView,
16
17
  getPos = _ref.getPos,
@@ -63,6 +64,6 @@ export var TableResizer = function TableResizer(_ref) {
63
64
  },
64
65
  resizeRatio: 2,
65
66
  minWidth: minColumnWidth,
66
- maxWidth: TABLE_MAX_WIDTH
67
+ maxWidth: maxWidth
67
68
  }, children);
68
69
  };
@@ -21,13 +21,17 @@ import { pluginKey as tableResizingPluginKey } from '../pm-plugins/table-resizin
21
21
  import { generateColgroup } from '../pm-plugins/table-resizing/utils';
22
22
  import { TableMap } from '@atlaskit/editor-tables/table-map';
23
23
  import TableComponent from './TableComponent';
24
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
25
+ import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
24
26
  var tableAttributes = function tableAttributes(node) {
27
+ var style = getBooleanFF('platform.editor.custom-table-width') ? "width: ".concat(getTableContainerWidth(node), "px") : undefined;
25
28
  return {
26
29
  'data-number-column': node.attrs.isNumberColumnEnabled,
27
30
  'data-layout': node.attrs.layout,
28
31
  'data-autosize': node.attrs.__autoSize,
29
32
  'data-table-local-id': node.attrs.localId || '',
30
- 'data-table-width': node.attrs.width
33
+ 'data-table-width': node.attrs.width,
34
+ style: style
31
35
  };
32
36
  };
33
37
  var toDOM = function toDOM(node, props) {
@@ -3,6 +3,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
3
3
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
4
  import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
5
5
  import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
6
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
6
7
  import { getTableWidth } from '../../../utils';
7
8
  import { getLayoutSize } from '../utils/misc';
8
9
  import { reduceSpace } from '../utils/resize-logic';
@@ -101,7 +102,13 @@ export var previewScaleTable = function previewScaleTable(tableRef, options, dom
101
102
  var node = options.node,
102
103
  start = options.start,
103
104
  parentWidth = options.parentWidth;
104
- if (!tableRef || !hasTableBeenResized(node)) {
105
+ if (!tableRef) {
106
+ return;
107
+ }
108
+ if (getBooleanFF('platform.editor.custom-table-width') && parentWidth) {
109
+ tableRef.style.width = "".concat(parentWidth, "px");
110
+ }
111
+ if (!hasTableBeenResized(node)) {
105
112
  return;
106
113
  }
107
114
  var resizeState = parentWidth ? scaleWithParent(tableRef, parentWidth, node, start, domAtPos) : scale(tableRef, options, domAtPos);
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "1.7.3",
3
+ "version": "2.0.1",
4
4
  "sideEffects": false
5
5
  }
@@ -1,6 +1,5 @@
1
1
  import type { Command } from '@atlaskit/editor-common/types';
2
2
  import { AnalyticsEventPayload } from '@atlaskit/editor-common/analytics';
3
- import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
4
3
  import type { EditorSelectionAPI } from '@atlaskit/editor-common/selection';
5
4
  import { PluginConfig } from './types';
6
5
  import type { GetEditorFeatureFlags, NextEditorPlugin } from '@atlaskit/editor-common/types';
@@ -13,7 +12,6 @@ interface TablePluginOptions {
13
12
  allowContextualMenu?: boolean;
14
13
  fullWidthEnabled?: boolean;
15
14
  wasFullWidthEnabled?: boolean;
16
- editorAnalyticsAPI?: EditorAnalyticsAPI;
17
15
  editorSelectionAPI?: EditorSelectionAPI;
18
16
  getEditorFeatureFlags?: GetEditorFeatureFlags;
19
17
  }
@@ -4,8 +4,10 @@ import { EditorView } from 'prosemirror-view';
4
4
  import { EditorContainerWidth } from '@atlaskit/editor-common/types';
5
5
  type InnerContainerProps = {
6
6
  className: string;
7
- marginLeft: number | undefined;
8
- width: number | 'inherit';
7
+ style?: {
8
+ width: number | 'inherit';
9
+ marginLeft: number | undefined;
10
+ };
9
11
  node: PMNode;
10
12
  };
11
13
  export declare const InnerContainer: React.ForwardRefExoticComponent<InnerContainerProps & {
@@ -20,7 +22,7 @@ type ResizableTableContainerProps = {
20
22
  getPos: () => number | undefined;
21
23
  tableRef: HTMLTableElement;
22
24
  };
23
- export declare const ResizableTableContainer: ({ children, className, node, lineLength, editorView, getPos, tableRef, }: PropsWithChildren<ResizableTableContainerProps>) => JSX.Element;
25
+ export declare const ResizableTableContainer: ({ children, className, node, lineLength, containerWidth, editorView, getPos, tableRef, }: PropsWithChildren<ResizableTableContainerProps>) => JSX.Element;
24
26
  type TableContainerProps = {
25
27
  node: PMNode;
26
28
  className: string;
@@ -3,11 +3,12 @@ import { EditorView } from 'prosemirror-view';
3
3
  import { Node as PMNode } from 'prosemirror-model';
4
4
  interface TableResizerProps {
5
5
  width: number;
6
+ maxWidth: number;
6
7
  updateWidth: (width: number) => void;
7
8
  editorView: EditorView;
8
9
  getPos: () => number | undefined;
9
10
  node: PMNode;
10
11
  tableRef: HTMLTableElement;
11
12
  }
12
- export declare const TableResizer: ({ children, width, updateWidth, editorView, getPos, node, tableRef, }: PropsWithChildren<TableResizerProps>) => JSX.Element;
13
+ export declare const TableResizer: ({ children, width, maxWidth, updateWidth, editorView, getPos, node, tableRef, }: PropsWithChildren<TableResizerProps>) => JSX.Element;
13
14
  export {};
@@ -1,6 +1,5 @@
1
1
  import type { Command } from '@atlaskit/editor-common/types';
2
2
  import { AnalyticsEventPayload } from '@atlaskit/editor-common/analytics';
3
- import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
4
3
  import type { EditorSelectionAPI } from '@atlaskit/editor-common/selection';
5
4
  import { PluginConfig } from './types';
6
5
  import type { GetEditorFeatureFlags, NextEditorPlugin } from '@atlaskit/editor-common/types';
@@ -13,7 +12,6 @@ interface TablePluginOptions {
13
12
  allowContextualMenu?: boolean;
14
13
  fullWidthEnabled?: boolean;
15
14
  wasFullWidthEnabled?: boolean;
16
- editorAnalyticsAPI?: EditorAnalyticsAPI;
17
15
  editorSelectionAPI?: EditorSelectionAPI;
18
16
  getEditorFeatureFlags?: GetEditorFeatureFlags;
19
17
  }
@@ -4,8 +4,10 @@ import { EditorView } from 'prosemirror-view';
4
4
  import { EditorContainerWidth } from '@atlaskit/editor-common/types';
5
5
  type InnerContainerProps = {
6
6
  className: string;
7
- marginLeft: number | undefined;
8
- width: number | 'inherit';
7
+ style?: {
8
+ width: number | 'inherit';
9
+ marginLeft: number | undefined;
10
+ };
9
11
  node: PMNode;
10
12
  };
11
13
  export declare const InnerContainer: React.ForwardRefExoticComponent<InnerContainerProps & {
@@ -20,7 +22,7 @@ type ResizableTableContainerProps = {
20
22
  getPos: () => number | undefined;
21
23
  tableRef: HTMLTableElement;
22
24
  };
23
- export declare const ResizableTableContainer: ({ children, className, node, lineLength, editorView, getPos, tableRef, }: PropsWithChildren<ResizableTableContainerProps>) => JSX.Element;
25
+ export declare const ResizableTableContainer: ({ children, className, node, lineLength, containerWidth, editorView, getPos, tableRef, }: PropsWithChildren<ResizableTableContainerProps>) => JSX.Element;
24
26
  type TableContainerProps = {
25
27
  node: PMNode;
26
28
  className: string;
@@ -3,11 +3,12 @@ import { EditorView } from 'prosemirror-view';
3
3
  import { Node as PMNode } from 'prosemirror-model';
4
4
  interface TableResizerProps {
5
5
  width: number;
6
+ maxWidth: number;
6
7
  updateWidth: (width: number) => void;
7
8
  editorView: EditorView;
8
9
  getPos: () => number | undefined;
9
10
  node: PMNode;
10
11
  tableRef: HTMLTableElement;
11
12
  }
12
- export declare const TableResizer: ({ children, width, updateWidth, editorView, getPos, node, tableRef, }: PropsWithChildren<TableResizerProps>) => JSX.Element;
13
+ export declare const TableResizer: ({ children, width, maxWidth, updateWidth, editorView, getPos, node, tableRef, }: PropsWithChildren<TableResizerProps>) => JSX.Element;
13
14
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "1.7.3",
3
+ "version": "2.0.1",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -27,8 +27,8 @@
27
27
  "releaseModel": "continuous"
28
28
  },
29
29
  "dependencies": {
30
- "@atlaskit/adf-schema": "^26.0.0",
31
- "@atlaskit/editor-common": "^74.15.0",
30
+ "@atlaskit/adf-schema": "^26.1.0",
31
+ "@atlaskit/editor-common": "^74.18.0",
32
32
  "@atlaskit/editor-palette": "1.5.1",
33
33
  "@atlaskit/editor-plugin-analytics": "^0.0.5",
34
34
  "@atlaskit/editor-plugin-content-insertion": "^0.0.5",
@@ -60,15 +60,13 @@
60
60
  "react-intl-next": "npm:react-intl@^5.18.1"
61
61
  },
62
62
  "devDependencies": {
63
- "@af/editor-libra": "*",
64
63
  "@atlaskit/analytics-next": "^9.1.0",
65
- "@atlaskit/editor-core": "^185.8.0",
64
+ "@atlaskit/editor-core": "^185.11.0",
66
65
  "@atlaskit/editor-plugin-decorations": "^0.1.0",
67
66
  "@atlaskit/editor-plugin-feature-flags": "^0.1.0",
68
67
  "@atlaskit/editor-plugin-grid": "^0.1.0",
69
68
  "@atlaskit/editor-plugin-width": "^0.1.0",
70
- "@atlaskit/editor-test-helpers": "^18.8.0",
71
- "@atlaskit/media-integration-test-helpers": "^3.0.0",
69
+ "@atlaskit/editor-test-helpers": "^18.10.0",
72
70
  "@atlaskit/visual-regression": "*",
73
71
  "@atlaskit/webdriver-runner": "*",
74
72
  "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
package/report.api.md CHANGED
@@ -19,7 +19,6 @@ import { AnalyticsEventPayload } from '@atlaskit/editor-common/analytics';
19
19
  import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
20
20
  import type { Command } from '@atlaskit/editor-common/types';
21
21
  import type { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
22
- import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
23
22
  import type { EditorSelectionAPI } from '@atlaskit/editor-common/selection';
24
23
  import type { GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
25
24
  import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
@@ -87,8 +86,6 @@ interface TablePluginOptions {
87
86
  // (undocumented)
88
87
  breakoutEnabled?: boolean;
89
88
  // (undocumented)
90
- editorAnalyticsAPI?: EditorAnalyticsAPI;
91
- // (undocumented)
92
89
  editorSelectionAPI?: EditorSelectionAPI;
93
90
  // (undocumented)
94
91
  fullWidthEnabled?: boolean;
@@ -44,9 +44,9 @@ import tablePlugin from '../../plugins/table-plugin';
44
44
  import typeAheadPlugin from '@atlaskit/editor-core/src/plugins/type-ahead';
45
45
  import quickInsertPlugin from '@atlaskit/editor-core/src/plugins/quick-insert';
46
46
  import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
47
- import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
48
47
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
49
48
  import { widthPlugin } from '@atlaskit/editor-plugin-width';
49
+ import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
50
50
 
51
51
  const defaultTableDoc = doc(
52
52
  table()(
@@ -59,6 +59,16 @@ const defaultTableDoc = doc(
59
59
  const secondRow: Rect = { left: 0, top: 1, bottom: 2, right: 3 };
60
60
  const secondColumn: Rect = { left: 1, top: 0, bottom: 3, right: 2 };
61
61
 
62
+ // We don't need to test if the analytics implementation works (tested elsewhere)
63
+ // We just want to know if the action is called.
64
+ const mockAttachPayload = jest.fn();
65
+ const analyticsPluginFake = () => ({
66
+ name: 'analytics',
67
+ actions: {
68
+ attachAnalyticsEvent: mockAttachPayload.mockImplementation(() => () => {}),
69
+ },
70
+ });
71
+
62
72
  describe('Table analytic events', () => {
63
73
  let editorAnalyticsAPIFake: EditorAnalyticsAPI;
64
74
  const analyticFireMock = jest.fn().mockReturnValue(jest.fn());
@@ -83,15 +93,15 @@ describe('Table analytic events', () => {
83
93
  doc,
84
94
  preset: new Preset<LightEditorPlugin>()
85
95
  .add([featureFlagsPlugin, {}])
86
- .add([analyticsPlugin, {}])
96
+ .add([
97
+ analyticsPluginFake as unknown as typeof analyticsPlugin,
98
+ { createAnalyticsEvent: jest.fn() },
99
+ ])
87
100
  .add(typeAheadPlugin)
88
101
  .add(contentInsertionPlugin)
89
102
  .add(quickInsertPlugin)
90
103
  .add(widthPlugin)
91
- .add([
92
- tablePlugin,
93
- { tableOptions, editorAnalyticsAPI: editorAnalyticsAPIFake },
94
- ]),
104
+ .add([tablePlugin, { tableOptions }]),
95
105
  pluginKey,
96
106
  });
97
107
 
@@ -105,7 +115,7 @@ describe('Table analytic events', () => {
105
115
  });
106
116
 
107
117
  it('should fire v3 analytics', () => {
108
- expect(analyticFireMock).toBeCalledWith({
118
+ expect(mockAttachPayload).toBeCalledWith({
109
119
  action: 'inserted',
110
120
  actionSubject: 'document',
111
121
  actionSubjectId: 'table',
@@ -218,7 +228,7 @@ describe('Table analytic events', () => {
218
228
  });
219
229
 
220
230
  it('should fire v3 analytics', () => {
221
- expect(analyticFireMock).toHaveBeenCalledWith({
231
+ expect(mockAttachPayload).toHaveBeenCalledWith({
222
232
  action: 'cleared',
223
233
  actionSubject: 'table',
224
234
  actionSubjectId: null,
@@ -578,7 +588,7 @@ describe('Table analytic events', () => {
578
588
  });
579
589
 
580
590
  it('should fire v3 analytics', () => {
581
- expect(analyticFireMock).toHaveBeenCalledWith({
591
+ expect(mockAttachPayload).toHaveBeenCalledWith({
582
592
  action: 'addedRow',
583
593
  actionSubject: 'table',
584
594
  actionSubjectId: null,
@@ -608,7 +618,7 @@ describe('Table analytic events', () => {
608
618
  });
609
619
 
610
620
  it('should fire v3 analytics', () => {
611
- expect(analyticFireMock).toHaveBeenCalledWith({
621
+ expect(mockAttachPayload).toHaveBeenCalledWith({
612
622
  action: 'addedRow',
613
623
  actionSubject: 'table',
614
624
  actionSubjectId: null,