@atlaskit/editor-plugin-table 7.16.1 → 7.16.2

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 (45) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/cjs/commands/insert.js +14 -2
  3. package/dist/cjs/nodeviews/TableComponent.js +4 -2
  4. package/dist/cjs/nodeviews/TableComponentWithSharedState.js +1 -0
  5. package/dist/cjs/nodeviews/TableContainer.js +72 -34
  6. package/dist/cjs/nodeviews/table.js +7 -4
  7. package/dist/cjs/plugin.js +12 -3
  8. package/dist/cjs/pm-plugins/keymap.js +1 -13
  9. package/dist/cjs/pm-plugins/main.js +1 -1
  10. package/dist/es2019/commands/insert.js +15 -3
  11. package/dist/es2019/nodeviews/TableComponent.js +5 -2
  12. package/dist/es2019/nodeviews/TableComponentWithSharedState.js +1 -0
  13. package/dist/es2019/nodeviews/TableContainer.js +51 -11
  14. package/dist/es2019/nodeviews/table.js +7 -4
  15. package/dist/es2019/plugin.js +11 -3
  16. package/dist/es2019/pm-plugins/keymap.js +4 -14
  17. package/dist/es2019/pm-plugins/main.js +1 -1
  18. package/dist/esm/commands/insert.js +15 -3
  19. package/dist/esm/nodeviews/TableComponent.js +4 -2
  20. package/dist/esm/nodeviews/TableComponentWithSharedState.js +1 -0
  21. package/dist/esm/nodeviews/TableContainer.js +73 -35
  22. package/dist/esm/nodeviews/table.js +7 -4
  23. package/dist/esm/plugin.js +12 -3
  24. package/dist/esm/pm-plugins/keymap.js +4 -16
  25. package/dist/esm/pm-plugins/main.js +1 -1
  26. package/dist/types/commands/insert.d.ts +3 -2
  27. package/dist/types/nodeviews/TableComponent.d.ts +1 -0
  28. package/dist/types/nodeviews/TableContainer.d.ts +7 -5
  29. package/dist/types/nodeviews/table.d.ts +1 -1
  30. package/dist/types/nodeviews/types.d.ts +1 -0
  31. package/dist/types-ts4.5/commands/insert.d.ts +3 -2
  32. package/dist/types-ts4.5/nodeviews/TableComponent.d.ts +1 -0
  33. package/dist/types-ts4.5/nodeviews/TableContainer.d.ts +7 -5
  34. package/dist/types-ts4.5/nodeviews/table.d.ts +1 -1
  35. package/dist/types-ts4.5/nodeviews/types.d.ts +1 -0
  36. package/package.json +5 -5
  37. package/src/commands/insert.ts +26 -18
  38. package/src/nodeviews/TableComponent.tsx +3 -0
  39. package/src/nodeviews/TableComponentWithSharedState.tsx +1 -0
  40. package/src/nodeviews/TableContainer.tsx +75 -13
  41. package/src/nodeviews/table.tsx +4 -1
  42. package/src/nodeviews/types.ts +1 -0
  43. package/src/plugin.tsx +18 -8
  44. package/src/pm-plugins/keymap.ts +4 -25
  45. package/src/pm-plugins/main.ts +1 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 7.16.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#101820](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/101820)
8
+ [`d6a194ef42d7`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/d6a194ef42d7) -
9
+ Add new left alignment to table container in editor, based on layout node attribute
10
+ - Updated dependencies
11
+
3
12
  ## 7.16.1
4
13
 
5
14
  ### Patch Changes
@@ -143,11 +143,23 @@ var insertRow = exports.insertRow = function insertRow(row, moveCursorToTheNewRo
143
143
  return true;
144
144
  };
145
145
  };
146
- var createTable = exports.createTable = function createTable(isTableScalingEnabled, isFullWidthModeEnabled) {
146
+ var createTable = exports.createTable = function createTable(isTableScalingEnabled, isFullWidthModeEnabled, editorAnalyticsAPI) {
147
147
  return function (state, dispatch) {
148
148
  var table = (0, _utils3.createTableWithWidth)(isTableScalingEnabled, isFullWidthModeEnabled)(state.schema);
149
149
  if (dispatch) {
150
- dispatch((0, _utils.safeInsert)(table)(state.tr).scrollIntoView());
150
+ var tr = (0, _utils.safeInsert)(table)(state.tr).scrollIntoView();
151
+ if (editorAnalyticsAPI) {
152
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
153
+ action: _analytics.ACTION.INSERTED,
154
+ actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
155
+ actionSubjectId: _analytics.ACTION_SUBJECT_ID.TABLE,
156
+ attributes: {
157
+ inputMethod: _analytics.INPUT_METHOD.SHORTCUT
158
+ },
159
+ eventType: _analytics.EVENT_TYPE.TRACK
160
+ })(tr);
161
+ }
162
+ dispatch(tr);
151
163
  }
152
164
  return true;
153
165
  };
@@ -652,7 +652,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
652
652
  pluginInjectionApi = _this$props11.pluginInjectionApi,
653
653
  isDragAndDropEnabled = _this$props11.isDragAndDropEnabled,
654
654
  getEditorFeatureFlags = _this$props11.getEditorFeatureFlags,
655
- isTableScalingEnabled = _this$props11.isTableScalingEnabled;
655
+ isTableScalingEnabled = _this$props11.isTableScalingEnabled,
656
+ isTableAlignmentEnabled = _this$props11.isTableAlignmentEnabled;
656
657
  var _this$props12 = this.props,
657
658
  isInDanger = _this$props12.isInDanger,
658
659
  hoveredRows = _this$props12.hoveredRows,
@@ -761,7 +762,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
761
762
  isTableResizingEnabled: options === null || options === void 0 ? void 0 : options.isTableResizingEnabled,
762
763
  isResizing: isResizing,
763
764
  isTableScalingEnabled: isTableScalingEnabled,
764
- isWholeTableInDanger: isWholeTableInDanger
765
+ isWholeTableInDanger: isWholeTableInDanger,
766
+ isTableAlignmentEnabled: isTableAlignmentEnabled
765
767
  }, /*#__PURE__*/_react.default.createElement("div", {
766
768
  className: _types.TableCssClassName.TABLE_STICKY_SENTINEL_TOP,
767
769
  "data-testid": "sticky-sentinel-top"
@@ -69,6 +69,7 @@ var TableComponentWithSharedState = exports.TableComponentWithSharedState = func
69
69
  isHeaderColumnEnabled: isHeaderColumnEnabled,
70
70
  isDragAndDropEnabled: options === null || options === void 0 ? void 0 : options.isDragAndDropEnabled,
71
71
  isTableScalingEnabled: options === null || options === void 0 ? void 0 : options.isTableScalingEnabled,
72
+ isTableAlignmentEnabled: options === null || options === void 0 ? void 0 : options.isTableAlignmentEnabled,
72
73
  tableActive: tableActive,
73
74
  ordering: ordering,
74
75
  isResizing: isResizing,
@@ -31,19 +31,57 @@ var InnerContainer = exports.InnerContainer = /*#__PURE__*/(0, _react.forwardRef
31
31
  "data-testid": "table-container"
32
32
  }, children);
33
33
  });
34
- var ResizableTableContainer = exports.ResizableTableContainer = /*#__PURE__*/_react.default.memo(function (_ref2) {
35
- var children = _ref2.children,
36
- className = _ref2.className,
37
- node = _ref2.node,
38
- containerWidth = _ref2.containerWidth,
39
- editorView = _ref2.editorView,
40
- getPos = _ref2.getPos,
41
- tableRef = _ref2.tableRef,
42
- isResizing = _ref2.isResizing,
43
- pluginInjectionApi = _ref2.pluginInjectionApi,
44
- isTableScalingEnabled = _ref2.isTableScalingEnabled,
45
- tableWrapperHeight = _ref2.tableWrapperHeight,
46
- isWholeTableInDanger = _ref2.isWholeTableInDanger;
34
+ var centerAlignStyle = {
35
+ display: 'flex',
36
+ justifyContent: 'center'
37
+ };
38
+ var leftAlignStyle = {
39
+ display: 'flex',
40
+ justifyContent: 'flex-start'
41
+ };
42
+ var AlignmentTableContainer = function AlignmentTableContainer(_ref2) {
43
+ var node = _ref2.node,
44
+ children = _ref2.children;
45
+ var alignment = node.attrs.layout;
46
+ var style = (0, _react.useMemo)(function () {
47
+ return alignment === 'align-start' ? leftAlignStyle : centerAlignStyle;
48
+ }, [alignment]);
49
+ return /*#__PURE__*/_react.default.createElement("div", {
50
+ "data-testid": "table-alignment-container",
51
+ style: style
52
+ }, children);
53
+ };
54
+ var AlignmentTableContainerWrapper = function AlignmentTableContainerWrapper(_ref3) {
55
+ var isTableAlignmentEnabled = _ref3.isTableAlignmentEnabled,
56
+ node = _ref3.node,
57
+ children = _ref3.children;
58
+ if (!isTableAlignmentEnabled) {
59
+ return /*#__PURE__*/_react.default.createElement("div", {
60
+ "data-testid": "table-alignment-container",
61
+ style: {
62
+ display: 'flex',
63
+ justifyContent: 'center'
64
+ }
65
+ }, children);
66
+ }
67
+ return /*#__PURE__*/_react.default.createElement(AlignmentTableContainer, {
68
+ node: node
69
+ }, children);
70
+ };
71
+ var ResizableTableContainer = exports.ResizableTableContainer = /*#__PURE__*/_react.default.memo(function (_ref4) {
72
+ var children = _ref4.children,
73
+ className = _ref4.className,
74
+ node = _ref4.node,
75
+ containerWidth = _ref4.containerWidth,
76
+ editorView = _ref4.editorView,
77
+ getPos = _ref4.getPos,
78
+ tableRef = _ref4.tableRef,
79
+ isResizing = _ref4.isResizing,
80
+ pluginInjectionApi = _ref4.pluginInjectionApi,
81
+ tableWrapperHeight = _ref4.tableWrapperHeight,
82
+ isWholeTableInDanger = _ref4.isWholeTableInDanger,
83
+ isTableScalingEnabled = _ref4.isTableScalingEnabled,
84
+ isTableAlignmentEnabled = _ref4.isTableAlignmentEnabled;
47
85
  var containerRef = (0, _react.useRef)(null);
48
86
  var tableWidthRef = (0, _react.useRef)(_editorSharedStyles.akEditorDefaultLayoutWidth);
49
87
  var _useState = (0, _react.useState)(false),
@@ -132,11 +170,9 @@ var ResizableTableContainer = exports.ResizableTableContainer = /*#__PURE__*/_re
132
170
  onResizeStop: onResizeStop
133
171
  };
134
172
  var isLivePageViewMode = (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view';
135
- return /*#__PURE__*/_react.default.createElement("div", {
136
- style: {
137
- display: 'flex',
138
- justifyContent: 'center'
139
- }
173
+ return /*#__PURE__*/_react.default.createElement(AlignmentTableContainerWrapper, {
174
+ isTableAlignmentEnabled: isTableAlignmentEnabled,
175
+ node: node
140
176
  }, /*#__PURE__*/_react.default.createElement("div", {
141
177
  style: {
142
178
  width: tableWidthRef.current,
@@ -156,21 +192,22 @@ var ResizableTableContainer = exports.ResizableTableContainer = /*#__PURE__*/_re
156
192
  node: node
157
193
  }, children))));
158
194
  });
159
- var TableContainer = exports.TableContainer = function TableContainer(_ref3) {
160
- var children = _ref3.children,
161
- node = _ref3.node,
162
- className = _ref3.className,
163
- editorWidth = _ref3.containerWidth.width,
164
- isTableResizingEnabled = _ref3.isTableResizingEnabled,
165
- editorView = _ref3.editorView,
166
- getPos = _ref3.getPos,
167
- tableRef = _ref3.tableRef,
168
- isNested = _ref3.isNested,
169
- tableWrapperHeight = _ref3.tableWrapperHeight,
170
- isResizing = _ref3.isResizing,
171
- pluginInjectionApi = _ref3.pluginInjectionApi,
172
- isTableScalingEnabled = _ref3.isTableScalingEnabled,
173
- isWholeTableInDanger = _ref3.isWholeTableInDanger;
195
+ var TableContainer = exports.TableContainer = function TableContainer(_ref5) {
196
+ var children = _ref5.children,
197
+ node = _ref5.node,
198
+ className = _ref5.className,
199
+ editorWidth = _ref5.containerWidth.width,
200
+ editorView = _ref5.editorView,
201
+ getPos = _ref5.getPos,
202
+ tableRef = _ref5.tableRef,
203
+ isNested = _ref5.isNested,
204
+ tableWrapperHeight = _ref5.tableWrapperHeight,
205
+ isResizing = _ref5.isResizing,
206
+ pluginInjectionApi = _ref5.pluginInjectionApi,
207
+ isWholeTableInDanger = _ref5.isWholeTableInDanger,
208
+ isTableResizingEnabled = _ref5.isTableResizingEnabled,
209
+ isTableScalingEnabled = _ref5.isTableScalingEnabled,
210
+ isTableAlignmentEnabled = _ref5.isTableAlignmentEnabled;
174
211
  if (isTableResizingEnabled && !isNested) {
175
212
  return /*#__PURE__*/_react.default.createElement(ResizableTableContainer, {
176
213
  className: className,
@@ -183,7 +220,8 @@ var TableContainer = exports.TableContainer = function TableContainer(_ref3) {
183
220
  isResizing: isResizing,
184
221
  pluginInjectionApi: pluginInjectionApi,
185
222
  isTableScalingEnabled: isTableScalingEnabled,
186
- isWholeTableInDanger: isWholeTableInDanger
223
+ isWholeTableInDanger: isWholeTableInDanger,
224
+ isTableAlignmentEnabled: isTableAlignmentEnabled
187
225
  }, children);
188
226
  }
189
227
  return /*#__PURE__*/_react.default.createElement(InnerContainer, {
@@ -176,7 +176,7 @@ var TableView = exports.default = /*#__PURE__*/function (_ReactNodeView) {
176
176
  },
177
177
  editorView: props.view,
178
178
  render: function render(pluginStates) {
179
- var _props$options;
179
+ var _props$options, _props$options2;
180
180
  var tableResizingPluginState = pluginStates.tableResizingPluginState,
181
181
  tableWidthPluginState = pluginStates.tableWidthPluginState,
182
182
  pluginState = pluginStates.pluginState,
@@ -208,8 +208,9 @@ var TableView = exports.default = /*#__PURE__*/function (_ReactNodeView) {
208
208
  isHeaderRowEnabled: pluginState.isHeaderRowEnabled,
209
209
  isHeaderColumnEnabled: pluginState.isHeaderColumnEnabled,
210
210
  isDragAndDropEnabled: pluginState.isDragAndDropEnabled,
211
- isTableScalingEnabled: (_props$options = props.options) === null || _props$options === void 0 ? void 0 : _props$options.isTableScalingEnabled // this.options?.isTableScalingEnabled sams as TableOptions.isTableScalingEnabled same as pluginState.isTableScalingEnabled
211
+ isTableScalingEnabled: (_props$options = props.options) === null || _props$options === void 0 ? void 0 : _props$options.isTableScalingEnabled // this.options?.isTableScalingEnabled same as TableOptions.isTableScalingEnabled same as pluginState.isTableScalingEnabled
212
212
  ,
213
+ isTableAlignmentEnabled: (_props$options2 = props.options) === null || _props$options2 === void 0 ? void 0 : _props$options2.isTableAlignmentEnabled,
213
214
  tableActive: tableActive,
214
215
  ordering: pluginState.ordering,
215
216
  isResizing: isResizing,
@@ -283,7 +284,7 @@ var TableView = exports.default = /*#__PURE__*/function (_ReactNodeView) {
283
284
  }]);
284
285
  return TableView;
285
286
  }(_reactNodeView.default);
286
- var createTableView = exports.createTableView = function createTableView(node, view, getPos, portalProviderAPI, eventDispatcher, getEditorContainerWidth, getEditorFeatureFlags, dispatchAnalyticsEvent, pluginInjectionApi) {
287
+ var createTableView = exports.createTableView = function createTableView(node, view, getPos, portalProviderAPI, eventDispatcher, getEditorContainerWidth, getEditorFeatureFlags, dispatchAnalyticsEvent, pluginInjectionApi, isTableAlignmentEnabled) {
287
288
  var _getPluginState2 = (0, _pluginFactory.getPluginState)(view.state),
288
289
  pluginConfig = _getPluginState2.pluginConfig,
289
290
  isFullWidthModeEnabled = _getPluginState2.isFullWidthModeEnabled,
@@ -308,7 +309,9 @@ var createTableView = exports.createTableView = function createTableView(node, v
308
309
  wasFullWidthModeEnabled: wasFullWidthModeEnabled,
309
310
  isTableResizingEnabled: isTableResizingEnabled,
310
311
  isDragAndDropEnabled: isDragAndDropEnabled,
311
- isTableScalingEnabled: isTableScalingEnabled // same as options.isTableScalingEnabled
312
+ isTableScalingEnabled: isTableScalingEnabled,
313
+ // same as options.isTableScalingEnabled
314
+ isTableAlignmentEnabled: isTableAlignmentEnabled
312
315
  },
313
316
  getEditorContainerWidth: getEditorContainerWidth,
314
317
  getEditorFeatureFlags: getEditorFeatureFlags,
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = void 0;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
8
9
  var _react = _interopRequireDefault(require("react"));
9
10
  var _adfSchema = require("@atlaskit/adf-schema");
10
11
  var _analytics = require("@atlaskit/editor-common/analytics");
@@ -45,6 +46,8 @@ var _FloatingInsertButton = _interopRequireDefault(require("./ui/FloatingInsertB
45
46
  var _FloatingToolbarLabel = require("./ui/FloatingToolbarLabel/FloatingToolbarLabel");
46
47
  var _TableFullWidthLabel = require("./ui/TableFullWidthLabel");
47
48
  var _utils2 = require("./utils");
49
+ 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; }
50
+ 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; }
48
51
  var defaultGetEditorFeatureFlags = function defaultGetEditorFeatureFlags() {
49
52
  return {};
50
53
  };
@@ -110,7 +113,11 @@ var tablesPlugin = function tablesPlugin(_ref) {
110
113
  node: node,
111
114
  options: {
112
115
  selectNodeInserted: false,
113
- analyticsPayload: analyticsPayload
116
+ analyticsPayload: _objectSpread(_objectSpread({}, analyticsPayload), {}, {
117
+ attributes: _objectSpread(_objectSpread({}, analyticsPayload.attributes), {}, {
118
+ localId: node.attrs.localId
119
+ })
120
+ })
114
121
  }
115
122
  })) !== null && _api$contentInsertion !== void 0 ? _api$contentInsertion : false;
116
123
  };
@@ -435,13 +442,15 @@ var tablesPlugin = function tablesPlugin(_ref) {
435
442
  var _api$table;
436
443
  // see comment on tablesPlugin.getSharedState on usage
437
444
  var tableState = api === null || api === void 0 || (_api$table = api.table) === null || _api$table === void 0 ? void 0 : _api$table.sharedState.currentState();
438
- var tr = insert((0, _utils2.createTableWithWidth)(options === null || options === void 0 ? void 0 : options.isTableScalingEnabled, tableState === null || tableState === void 0 ? void 0 : tableState.isFullWidthModeEnabled)(state.schema));
445
+ var tableNode = (0, _utils2.createTableWithWidth)(options === null || options === void 0 ? void 0 : options.isTableScalingEnabled, tableState === null || tableState === void 0 ? void 0 : tableState.isFullWidthModeEnabled)(state.schema);
446
+ var tr = insert(tableNode);
439
447
  editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
440
448
  action: _analytics.ACTION.INSERTED,
441
449
  actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
442
450
  actionSubjectId: _analytics.ACTION_SUBJECT_ID.TABLE,
443
451
  attributes: {
444
- inputMethod: _analytics.INPUT_METHOD.QUICK_INSERT
452
+ inputMethod: _analytics.INPUT_METHOD.QUICK_INSERT,
453
+ localId: tableNode.attrs.localId
445
454
  },
446
455
  eventType: _analytics.EVENT_TYPE.TRACK
447
456
  })(tr);
@@ -15,18 +15,6 @@ var _commandsWithAnalytics = require("../commands-with-analytics");
15
15
  var _columnResize = require("../commands/column-resize");
16
16
  var _insert = require("../commands/insert");
17
17
  var _commandsWithAnalytics2 = require("../pm-plugins/drag-and-drop/commands-with-analytics");
18
- var _analytics2 = require("../utils/analytics");
19
- var createTableWithAnalytics = function createTableWithAnalytics(isTableScalingEnabled, isFullWidthModeEnabled, editorAnalyticsAPI) {
20
- return (0, _analytics2.withEditorAnalyticsAPI)({
21
- action: _analytics.ACTION.INSERTED,
22
- actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
23
- actionSubjectId: _analytics.ACTION_SUBJECT_ID.TABLE,
24
- attributes: {
25
- inputMethod: _analytics.INPUT_METHOD.SHORTCUT
26
- },
27
- eventType: _analytics.EVENT_TYPE.TRACK
28
- })(editorAnalyticsAPI)((0, _commands2.createTable)(isTableScalingEnabled, isFullWidthModeEnabled));
29
- };
30
18
  function keymapPlugin(getEditorContainerWidth, editorAnalyticsAPI, dragAndDropEnabled) {
31
19
  var _pluginInjectionApi$a;
32
20
  var isTableScalingEnabled = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
@@ -37,7 +25,7 @@ function keymapPlugin(getEditorContainerWidth, editorAnalyticsAPI, dragAndDropEn
37
25
  var ariaNotifyPlugin = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.accessibilityUtils) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions.ariaNotify;
38
26
  (0, _keymaps.bindKeymapWithCommand)(_keymaps.nextCell.common, (0, _commands2.goToNextCell)(editorAnalyticsAPI, ariaNotifyPlugin, getIntl)(1), list);
39
27
  (0, _keymaps.bindKeymapWithCommand)(_keymaps.previousCell.common, (0, _commands2.goToNextCell)(editorAnalyticsAPI, ariaNotifyPlugin, getIntl)(-1), list);
40
- (0, _keymaps.bindKeymapWithCommand)(_keymaps.toggleTable.common, createTableWithAnalytics(isTableScalingEnabled, !!isFullWidthEnabled, editorAnalyticsAPI), list);
28
+ (0, _keymaps.bindKeymapWithCommand)(_keymaps.toggleTable.common, (0, _insert.createTable)(isTableScalingEnabled, !!isFullWidthEnabled, editorAnalyticsAPI), list);
41
29
  (0, _keymaps.bindKeymapWithCommand)(_keymaps.backspace.common, (0, _commands.chainCommands)((0, _commandsWithAnalytics.deleteTableIfSelectedWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.KEYBOARD), (0, _commandsWithAnalytics.emptyMultipleCellsWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.KEYBOARD)), list);
42
30
  (0, _keymaps.bindKeymapWithCommand)(_keymaps.backspace.common, _commands2.moveCursorBackward, list);
43
31
 
@@ -260,7 +260,7 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatchAnalytic
260
260
  },
261
261
  nodeViews: {
262
262
  table: function table(node, view, getPos) {
263
- return (0, _table.createTableView)(node, view, getPos, portalProviderAPI, eventDispatcher, getEditorContainerWidth, getEditorFeatureFlags, dispatchAnalyticsEvent, pluginInjectionApi);
263
+ return (0, _table.createTableView)(node, view, getPos, portalProviderAPI, eventDispatcher, getEditorContainerWidth, getEditorFeatureFlags, dispatchAnalyticsEvent, pluginInjectionApi, isTableAlignmentEnabled);
264
264
  },
265
265
  tableRow: function tableRow(node, view, getPos) {
266
266
  return new _TableRow.default(node, view, getPos, eventDispatcher);
@@ -1,6 +1,6 @@
1
1
  // #region Imports
2
2
  import { AddColumnStep } from '@atlaskit/custom-steps';
3
- import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
3
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
4
4
  import { Selection } from '@atlaskit/editor-prosemirror/state';
5
5
  import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
6
6
  import { TableMap } from '@atlaskit/editor-tables/table-map';
@@ -119,10 +119,22 @@ export const insertRow = (row, moveCursorToTheNewRow, isCellBackgroundDuplicated
119
119
  }
120
120
  return true;
121
121
  };
122
- export const createTable = (isTableScalingEnabled, isFullWidthModeEnabled) => (state, dispatch) => {
122
+ export const createTable = (isTableScalingEnabled, isFullWidthModeEnabled, editorAnalyticsAPI) => (state, dispatch) => {
123
123
  const table = createTableWithWidth(isTableScalingEnabled, isFullWidthModeEnabled)(state.schema);
124
124
  if (dispatch) {
125
- dispatch(safeInsert(table)(state.tr).scrollIntoView());
125
+ const tr = safeInsert(table)(state.tr).scrollIntoView();
126
+ if (editorAnalyticsAPI) {
127
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
128
+ action: ACTION.INSERTED,
129
+ actionSubject: ACTION_SUBJECT.DOCUMENT,
130
+ actionSubjectId: ACTION_SUBJECT_ID.TABLE,
131
+ attributes: {
132
+ inputMethod: INPUT_METHOD.SHORTCUT
133
+ },
134
+ eventType: EVENT_TYPE.TRACK
135
+ })(tr);
136
+ }
137
+ dispatch(tr);
126
138
  }
127
139
  return true;
128
140
  };
@@ -636,7 +636,9 @@ class TableComponent extends React.Component {
636
636
  pluginInjectionApi,
637
637
  isDragAndDropEnabled,
638
638
  getEditorFeatureFlags,
639
- isTableScalingEnabled // here we can use options.isTableScalingEnabled
639
+ isTableScalingEnabled,
640
+ // here we can use options.isTableScalingEnabled
641
+ isTableAlignmentEnabled
640
642
  } = this.props;
641
643
  let {
642
644
  isInDanger,
@@ -752,7 +754,8 @@ class TableComponent extends React.Component {
752
754
  isTableResizingEnabled: options === null || options === void 0 ? void 0 : options.isTableResizingEnabled,
753
755
  isResizing: isResizing,
754
756
  isTableScalingEnabled: isTableScalingEnabled,
755
- isWholeTableInDanger: isWholeTableInDanger
757
+ isWholeTableInDanger: isWholeTableInDanger,
758
+ isTableAlignmentEnabled: isTableAlignmentEnabled
756
759
  }, /*#__PURE__*/React.createElement("div", {
757
760
  className: ClassName.TABLE_STICKY_SENTINEL_TOP,
758
761
  "data-testid": "sticky-sentinel-top"
@@ -65,6 +65,7 @@ export const TableComponentWithSharedState = ({
65
65
  isHeaderColumnEnabled: isHeaderColumnEnabled,
66
66
  isDragAndDropEnabled: options === null || options === void 0 ? void 0 : options.isDragAndDropEnabled,
67
67
  isTableScalingEnabled: options === null || options === void 0 ? void 0 : options.isTableScalingEnabled,
68
+ isTableAlignmentEnabled: options === null || options === void 0 ? void 0 : options.isTableAlignmentEnabled,
68
69
  tableActive: tableActive,
69
70
  ordering: ordering,
70
71
  isResizing: isResizing,
@@ -1,4 +1,4 @@
1
- import React, { forwardRef, useCallback, useRef, useState } from 'react';
1
+ import React, { forwardRef, useCallback, useMemo, useRef, useState } from 'react';
2
2
  import classNames from 'classnames';
3
3
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
4
4
  import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
@@ -21,6 +21,45 @@ export const InnerContainer = /*#__PURE__*/forwardRef(({
21
21
  "data-testid": "table-container"
22
22
  }, children);
23
23
  });
24
+ const centerAlignStyle = {
25
+ display: 'flex',
26
+ justifyContent: 'center'
27
+ };
28
+ const leftAlignStyle = {
29
+ display: 'flex',
30
+ justifyContent: 'flex-start'
31
+ };
32
+ const AlignmentTableContainer = ({
33
+ node,
34
+ children
35
+ }) => {
36
+ const alignment = node.attrs.layout;
37
+ const style = useMemo(() => {
38
+ return alignment === 'align-start' ? leftAlignStyle : centerAlignStyle;
39
+ }, [alignment]);
40
+ return /*#__PURE__*/React.createElement("div", {
41
+ "data-testid": "table-alignment-container",
42
+ style: style
43
+ }, children);
44
+ };
45
+ const AlignmentTableContainerWrapper = ({
46
+ isTableAlignmentEnabled,
47
+ node,
48
+ children
49
+ }) => {
50
+ if (!isTableAlignmentEnabled) {
51
+ return /*#__PURE__*/React.createElement("div", {
52
+ "data-testid": "table-alignment-container",
53
+ style: {
54
+ display: 'flex',
55
+ justifyContent: 'center'
56
+ }
57
+ }, children);
58
+ }
59
+ return /*#__PURE__*/React.createElement(AlignmentTableContainer, {
60
+ node: node
61
+ }, children);
62
+ };
24
63
  export const ResizableTableContainer = /*#__PURE__*/React.memo(({
25
64
  children,
26
65
  className,
@@ -31,9 +70,10 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
31
70
  tableRef,
32
71
  isResizing,
33
72
  pluginInjectionApi,
34
- isTableScalingEnabled,
35
73
  tableWrapperHeight,
36
- isWholeTableInDanger
74
+ isWholeTableInDanger,
75
+ isTableScalingEnabled,
76
+ isTableAlignmentEnabled
37
77
  }) => {
38
78
  const containerRef = useRef(null);
39
79
  const tableWidthRef = useRef(akEditorDefaultLayoutWidth);
@@ -121,11 +161,9 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
121
161
  onResizeStop
122
162
  };
123
163
  const isLivePageViewMode = (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view';
124
- return /*#__PURE__*/React.createElement("div", {
125
- style: {
126
- display: 'flex',
127
- justifyContent: 'center'
128
- }
164
+ return /*#__PURE__*/React.createElement(AlignmentTableContainerWrapper, {
165
+ isTableAlignmentEnabled: isTableAlignmentEnabled,
166
+ node: node
129
167
  }, /*#__PURE__*/React.createElement("div", {
130
168
  style: {
131
169
  width: tableWidthRef.current,
@@ -152,7 +190,6 @@ export const TableContainer = ({
152
190
  containerWidth: {
153
191
  width: editorWidth
154
192
  },
155
- isTableResizingEnabled,
156
193
  editorView,
157
194
  getPos,
158
195
  tableRef,
@@ -160,8 +197,10 @@ export const TableContainer = ({
160
197
  tableWrapperHeight,
161
198
  isResizing,
162
199
  pluginInjectionApi,
200
+ isWholeTableInDanger,
201
+ isTableResizingEnabled,
163
202
  isTableScalingEnabled,
164
- isWholeTableInDanger
203
+ isTableAlignmentEnabled
165
204
  }) => {
166
205
  if (isTableResizingEnabled && !isNested) {
167
206
  return /*#__PURE__*/React.createElement(ResizableTableContainer, {
@@ -175,7 +214,8 @@ export const TableContainer = ({
175
214
  isResizing: isResizing,
176
215
  pluginInjectionApi: pluginInjectionApi,
177
216
  isTableScalingEnabled: isTableScalingEnabled,
178
- isWholeTableInDanger: isWholeTableInDanger
217
+ isWholeTableInDanger: isWholeTableInDanger,
218
+ isTableAlignmentEnabled: isTableAlignmentEnabled
179
219
  }, children);
180
220
  }
181
221
  return /*#__PURE__*/React.createElement(InnerContainer, {
@@ -144,7 +144,7 @@ export default class TableView extends ReactNodeView {
144
144
  },
145
145
  editorView: props.view,
146
146
  render: pluginStates => {
147
- var _props$options;
147
+ var _props$options, _props$options2;
148
148
  const {
149
149
  tableResizingPluginState,
150
150
  tableWidthPluginState,
@@ -178,8 +178,9 @@ export default class TableView extends ReactNodeView {
178
178
  isHeaderRowEnabled: pluginState.isHeaderRowEnabled,
179
179
  isHeaderColumnEnabled: pluginState.isHeaderColumnEnabled,
180
180
  isDragAndDropEnabled: pluginState.isDragAndDropEnabled,
181
- isTableScalingEnabled: (_props$options = props.options) === null || _props$options === void 0 ? void 0 : _props$options.isTableScalingEnabled // this.options?.isTableScalingEnabled sams as TableOptions.isTableScalingEnabled same as pluginState.isTableScalingEnabled
181
+ isTableScalingEnabled: (_props$options = props.options) === null || _props$options === void 0 ? void 0 : _props$options.isTableScalingEnabled // this.options?.isTableScalingEnabled same as TableOptions.isTableScalingEnabled same as pluginState.isTableScalingEnabled
182
182
  ,
183
+ isTableAlignmentEnabled: (_props$options2 = props.options) === null || _props$options2 === void 0 ? void 0 : _props$options2.isTableAlignmentEnabled,
183
184
  tableActive: tableActive,
184
185
  ordering: pluginState.ordering,
185
186
  isResizing: isResizing,
@@ -249,7 +250,7 @@ export default class TableView extends ReactNodeView {
249
250
  super.destroy();
250
251
  }
251
252
  }
252
- export const createTableView = (node, view, getPos, portalProviderAPI, eventDispatcher, getEditorContainerWidth, getEditorFeatureFlags, dispatchAnalyticsEvent, pluginInjectionApi) => {
253
+ export const createTableView = (node, view, getPos, portalProviderAPI, eventDispatcher, getEditorContainerWidth, getEditorFeatureFlags, dispatchAnalyticsEvent, pluginInjectionApi, isTableAlignmentEnabled) => {
253
254
  const {
254
255
  pluginConfig,
255
256
  isFullWidthModeEnabled,
@@ -276,7 +277,9 @@ export const createTableView = (node, view, getPos, portalProviderAPI, eventDisp
276
277
  wasFullWidthModeEnabled,
277
278
  isTableResizingEnabled,
278
279
  isDragAndDropEnabled,
279
- isTableScalingEnabled // same as options.isTableScalingEnabled
280
+ isTableScalingEnabled,
281
+ // same as options.isTableScalingEnabled
282
+ isTableAlignmentEnabled
280
283
  },
281
284
  getEditorContainerWidth,
282
285
  getEditorFeatureFlags,
@@ -101,7 +101,13 @@ const tablesPlugin = ({
101
101
  node,
102
102
  options: {
103
103
  selectNodeInserted: false,
104
- analyticsPayload
104
+ analyticsPayload: {
105
+ ...analyticsPayload,
106
+ attributes: {
107
+ ...analyticsPayload.attributes,
108
+ localId: node.attrs.localId
109
+ }
110
+ }
105
111
  }
106
112
  })) !== null && _api$contentInsertion !== void 0 ? _api$contentInsertion : false;
107
113
  }
@@ -429,13 +435,15 @@ const tablesPlugin = ({
429
435
  var _api$table;
430
436
  // see comment on tablesPlugin.getSharedState on usage
431
437
  const tableState = api === null || api === void 0 ? void 0 : (_api$table = api.table) === null || _api$table === void 0 ? void 0 : _api$table.sharedState.currentState();
432
- const tr = insert(createTableWithWidth(options === null || options === void 0 ? void 0 : options.isTableScalingEnabled, tableState === null || tableState === void 0 ? void 0 : tableState.isFullWidthModeEnabled)(state.schema));
438
+ const tableNode = createTableWithWidth(options === null || options === void 0 ? void 0 : options.isTableScalingEnabled, tableState === null || tableState === void 0 ? void 0 : tableState.isFullWidthModeEnabled)(state.schema);
439
+ const tr = insert(tableNode);
433
440
  editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
434
441
  action: ACTION.INSERTED,
435
442
  actionSubject: ACTION_SUBJECT.DOCUMENT,
436
443
  actionSubjectId: ACTION_SUBJECT_ID.TABLE,
437
444
  attributes: {
438
- inputMethod: INPUT_METHOD.QUICK_INSERT
445
+ inputMethod: INPUT_METHOD.QUICK_INSERT,
446
+ localId: tableNode.attrs.localId
439
447
  },
440
448
  eventType: EVENT_TYPE.TRACK
441
449
  })(tr);
@@ -1,30 +1,20 @@
1
- import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
1
+ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
2
  import { addColumnAfter, addColumnBefore, addRowAfter, addRowBefore, backspace, bindKeymapWithCommand, decreaseMediaSize, deleteColumn, deleteRow, escape, increaseMediaSize, moveColumnLeft, moveColumnRight, moveLeft, moveRight, moveRowDown, moveRowUp, nextCell, previousCell, startColumnResizing, toggleTable } from '@atlaskit/editor-common/keymaps';
3
3
  import { chainCommands } from '@atlaskit/editor-prosemirror/commands';
4
4
  import { keymap } from '@atlaskit/editor-prosemirror/keymap';
5
5
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
6
- import { createTable, goToNextCell, moveCursorBackward } from '../commands';
6
+ import { goToNextCell, moveCursorBackward } from '../commands';
7
7
  import { addRowAroundSelection, changeColumnWidthByStepWithAnalytics, deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut, deleteTableIfSelectedWithAnalytics, emptyMultipleCellsWithAnalytics } from '../commands-with-analytics';
8
8
  import { activateNextResizeArea, initiateKeyboardColumnResizing, stopKeyboardColumnResizing } from '../commands/column-resize';
9
- import { addColumnAfter as addColumnAfterCommand, addColumnBefore as addColumnBeforeCommand } from '../commands/insert';
9
+ import { addColumnAfter as addColumnAfterCommand, addColumnBefore as addColumnBeforeCommand, createTable } from '../commands/insert';
10
10
  import { moveSourceWithAnalyticsViaShortcut } from '../pm-plugins/drag-and-drop/commands-with-analytics';
11
- import { withEditorAnalyticsAPI } from '../utils/analytics';
12
- const createTableWithAnalytics = (isTableScalingEnabled, isFullWidthModeEnabled, editorAnalyticsAPI) => withEditorAnalyticsAPI({
13
- action: ACTION.INSERTED,
14
- actionSubject: ACTION_SUBJECT.DOCUMENT,
15
- actionSubjectId: ACTION_SUBJECT_ID.TABLE,
16
- attributes: {
17
- inputMethod: INPUT_METHOD.SHORTCUT
18
- },
19
- eventType: EVENT_TYPE.TRACK
20
- })(editorAnalyticsAPI)(createTable(isTableScalingEnabled, isFullWidthModeEnabled));
21
11
  export function keymapPlugin(getEditorContainerWidth, editorAnalyticsAPI, dragAndDropEnabled, isTableScalingEnabled = false, isFullWidthEnabled, pluginInjectionApi, getIntl) {
22
12
  var _pluginInjectionApi$a;
23
13
  const list = {};
24
14
  const ariaNotifyPlugin = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a = pluginInjectionApi.accessibilityUtils) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions.ariaNotify;
25
15
  bindKeymapWithCommand(nextCell.common, goToNextCell(editorAnalyticsAPI, ariaNotifyPlugin, getIntl)(1), list);
26
16
  bindKeymapWithCommand(previousCell.common, goToNextCell(editorAnalyticsAPI, ariaNotifyPlugin, getIntl)(-1), list);
27
- bindKeymapWithCommand(toggleTable.common, createTableWithAnalytics(isTableScalingEnabled, !!isFullWidthEnabled, editorAnalyticsAPI), list);
17
+ bindKeymapWithCommand(toggleTable.common, createTable(isTableScalingEnabled, !!isFullWidthEnabled, editorAnalyticsAPI), list);
28
18
  bindKeymapWithCommand(backspace.common, chainCommands(deleteTableIfSelectedWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.KEYBOARD), emptyMultipleCellsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.KEYBOARD)), list);
29
19
  bindKeymapWithCommand(backspace.common, moveCursorBackward, list);
30
20
 
@@ -257,7 +257,7 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
257
257
  return false;
258
258
  },
259
259
  nodeViews: {
260
- table: (node, view, getPos) => createTableView(node, view, getPos, portalProviderAPI, eventDispatcher, getEditorContainerWidth, getEditorFeatureFlags, dispatchAnalyticsEvent, pluginInjectionApi),
260
+ table: (node, view, getPos) => createTableView(node, view, getPos, portalProviderAPI, eventDispatcher, getEditorContainerWidth, getEditorFeatureFlags, dispatchAnalyticsEvent, pluginInjectionApi, isTableAlignmentEnabled),
261
261
  tableRow: (node, view, getPos) => new TableRow(node, view, getPos, eventDispatcher),
262
262
  tableCell: (node, view, getPos) => new TableCell(node, view, getPos, eventDispatcher),
263
263
  tableHeader: (node, view, getPos) => new TableCell(node, view, getPos, eventDispatcher)