@atlaskit/editor-plugin-table 7.16.0 → 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 (72) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/cjs/commands/insert.js +14 -2
  3. package/dist/cjs/commands/misc.js +15 -1
  4. package/dist/cjs/commands-with-analytics.js +25 -2
  5. package/dist/cjs/nodeviews/TableComponent.js +4 -2
  6. package/dist/cjs/nodeviews/TableComponentWithSharedState.js +1 -0
  7. package/dist/cjs/nodeviews/TableContainer.js +72 -34
  8. package/dist/cjs/nodeviews/table.js +7 -4
  9. package/dist/cjs/plugin.js +13 -5
  10. package/dist/cjs/pm-plugins/keymap.js +1 -13
  11. package/dist/cjs/pm-plugins/main.js +1 -1
  12. package/dist/cjs/toolbar.js +9 -26
  13. package/dist/cjs/utils/alignment.js +13 -0
  14. package/dist/es2019/commands/insert.js +15 -3
  15. package/dist/es2019/commands/misc.js +15 -1
  16. package/dist/es2019/commands-with-analytics.js +22 -2
  17. package/dist/es2019/nodeviews/TableComponent.js +5 -2
  18. package/dist/es2019/nodeviews/TableComponentWithSharedState.js +1 -0
  19. package/dist/es2019/nodeviews/TableContainer.js +51 -11
  20. package/dist/es2019/nodeviews/table.js +7 -4
  21. package/dist/es2019/plugin.js +13 -6
  22. package/dist/es2019/pm-plugins/keymap.js +4 -14
  23. package/dist/es2019/pm-plugins/main.js +1 -1
  24. package/dist/es2019/toolbar.js +8 -25
  25. package/dist/es2019/utils/alignment.js +5 -0
  26. package/dist/esm/commands/insert.js +15 -3
  27. package/dist/esm/commands/misc.js +14 -0
  28. package/dist/esm/commands-with-analytics.js +25 -2
  29. package/dist/esm/nodeviews/TableComponent.js +4 -2
  30. package/dist/esm/nodeviews/TableComponentWithSharedState.js +1 -0
  31. package/dist/esm/nodeviews/TableContainer.js +73 -35
  32. package/dist/esm/nodeviews/table.js +7 -4
  33. package/dist/esm/plugin.js +14 -6
  34. package/dist/esm/pm-plugins/keymap.js +4 -16
  35. package/dist/esm/pm-plugins/main.js +1 -1
  36. package/dist/esm/toolbar.js +8 -27
  37. package/dist/esm/utils/alignment.js +7 -0
  38. package/dist/types/commands/insert.d.ts +3 -2
  39. package/dist/types/commands/misc.d.ts +3 -1
  40. package/dist/types/commands-with-analytics.d.ts +3 -1
  41. package/dist/types/nodeviews/TableComponent.d.ts +1 -0
  42. package/dist/types/nodeviews/TableContainer.d.ts +7 -5
  43. package/dist/types/nodeviews/table.d.ts +1 -1
  44. package/dist/types/nodeviews/types.d.ts +1 -0
  45. package/dist/types/toolbar.d.ts +3 -4
  46. package/dist/types/types.d.ts +1 -0
  47. package/dist/types/utils/alignment.d.ts +7 -0
  48. package/dist/types-ts4.5/commands/insert.d.ts +3 -2
  49. package/dist/types-ts4.5/commands/misc.d.ts +3 -1
  50. package/dist/types-ts4.5/commands-with-analytics.d.ts +3 -1
  51. package/dist/types-ts4.5/nodeviews/TableComponent.d.ts +1 -0
  52. package/dist/types-ts4.5/nodeviews/TableContainer.d.ts +7 -5
  53. package/dist/types-ts4.5/nodeviews/table.d.ts +1 -1
  54. package/dist/types-ts4.5/nodeviews/types.d.ts +1 -0
  55. package/dist/types-ts4.5/toolbar.d.ts +3 -4
  56. package/dist/types-ts4.5/types.d.ts +1 -0
  57. package/dist/types-ts4.5/utils/alignment.d.ts +7 -0
  58. package/package.json +6 -6
  59. package/src/commands/insert.ts +26 -18
  60. package/src/commands/misc.ts +28 -6
  61. package/src/commands-with-analytics.ts +38 -1
  62. package/src/nodeviews/TableComponent.tsx +3 -0
  63. package/src/nodeviews/TableComponentWithSharedState.tsx +1 -0
  64. package/src/nodeviews/TableContainer.tsx +75 -13
  65. package/src/nodeviews/table.tsx +4 -1
  66. package/src/nodeviews/types.ts +1 -0
  67. package/src/plugin.tsx +20 -22
  68. package/src/pm-plugins/keymap.ts +4 -25
  69. package/src/pm-plugins/main.ts +1 -0
  70. package/src/toolbar.tsx +16 -37
  71. package/src/types.ts +2 -0
  72. package/src/utils/alignment.ts +10 -0
@@ -169,7 +169,7 @@ var TableView = /*#__PURE__*/function (_ReactNodeView) {
169
169
  },
170
170
  editorView: props.view,
171
171
  render: function render(pluginStates) {
172
- var _props$options;
172
+ var _props$options, _props$options2;
173
173
  var tableResizingPluginState = pluginStates.tableResizingPluginState,
174
174
  tableWidthPluginState = pluginStates.tableWidthPluginState,
175
175
  pluginState = pluginStates.pluginState,
@@ -201,8 +201,9 @@ var TableView = /*#__PURE__*/function (_ReactNodeView) {
201
201
  isHeaderRowEnabled: pluginState.isHeaderRowEnabled,
202
202
  isHeaderColumnEnabled: pluginState.isHeaderColumnEnabled,
203
203
  isDragAndDropEnabled: pluginState.isDragAndDropEnabled,
204
- 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
204
+ 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
205
205
  ,
206
+ isTableAlignmentEnabled: (_props$options2 = props.options) === null || _props$options2 === void 0 ? void 0 : _props$options2.isTableAlignmentEnabled,
206
207
  tableActive: tableActive,
207
208
  ordering: pluginState.ordering,
208
209
  isResizing: isResizing,
@@ -277,7 +278,7 @@ var TableView = /*#__PURE__*/function (_ReactNodeView) {
277
278
  return TableView;
278
279
  }(ReactNodeView);
279
280
  export { TableView as default };
280
- export var createTableView = function createTableView(node, view, getPos, portalProviderAPI, eventDispatcher, getEditorContainerWidth, getEditorFeatureFlags, dispatchAnalyticsEvent, pluginInjectionApi) {
281
+ export var createTableView = function createTableView(node, view, getPos, portalProviderAPI, eventDispatcher, getEditorContainerWidth, getEditorFeatureFlags, dispatchAnalyticsEvent, pluginInjectionApi, isTableAlignmentEnabled) {
281
282
  var _getPluginState2 = getPluginState(view.state),
282
283
  pluginConfig = _getPluginState2.pluginConfig,
283
284
  isFullWidthModeEnabled = _getPluginState2.isFullWidthModeEnabled,
@@ -302,7 +303,9 @@ export var createTableView = function createTableView(node, view, getPos, portal
302
303
  wasFullWidthModeEnabled: wasFullWidthModeEnabled,
303
304
  isTableResizingEnabled: isTableResizingEnabled,
304
305
  isDragAndDropEnabled: isDragAndDropEnabled,
305
- isTableScalingEnabled: isTableScalingEnabled // same as options.isTableScalingEnabled
306
+ isTableScalingEnabled: isTableScalingEnabled,
307
+ // same as options.isTableScalingEnabled
308
+ isTableAlignmentEnabled: isTableAlignmentEnabled
306
309
  },
307
310
  getEditorContainerWidth: getEditorContainerWidth,
308
311
  getEditorFeatureFlags: getEditorFeatureFlags,
@@ -1,5 +1,8 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1
4
  import React from 'react';
2
- import { table, tableCell, tableHeader, tableRow, tableStage0 } from '@atlaskit/adf-schema';
5
+ import { table, tableCell, tableHeader, tableRow } from '@atlaskit/adf-schema';
3
6
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
4
7
  import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
5
8
  import { IconTable } from '@atlaskit/editor-common/icons';
@@ -103,7 +106,11 @@ var tablesPlugin = function tablesPlugin(_ref) {
103
106
  node: node,
104
107
  options: {
105
108
  selectNodeInserted: false,
106
- analyticsPayload: analyticsPayload
109
+ analyticsPayload: _objectSpread(_objectSpread({}, analyticsPayload), {}, {
110
+ attributes: _objectSpread(_objectSpread({}, analyticsPayload.attributes), {}, {
111
+ localId: node.attrs.localId
112
+ })
113
+ })
107
114
  }
108
115
  })) !== null && _api$contentInsertion !== void 0 ? _api$contentInsertion : false;
109
116
  };
@@ -113,10 +120,9 @@ var tablesPlugin = function tablesPlugin(_ref) {
113
120
  insertTableWithSize: insertTableWithSize(options === null || options === void 0 ? void 0 : options.fullWidthEnabled, options === null || options === void 0 ? void 0 : options.isTableScalingEnabled, api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)
114
121
  },
115
122
  nodes: function nodes() {
116
- var tableNode = options !== null && options !== void 0 && options.isTableScalingEnabled && getBooleanFF('platform.editor.table.preserve-widths-with-lock-button') ? tableStage0 : table;
117
123
  return [{
118
124
  name: 'table',
119
- node: tableNode
125
+ node: table
120
126
  }, {
121
127
  name: 'tableHeader',
122
128
  node: tableHeader
@@ -429,13 +435,15 @@ var tablesPlugin = function tablesPlugin(_ref) {
429
435
  var _api$table;
430
436
  // see comment on tablesPlugin.getSharedState on usage
431
437
  var tableState = api === null || api === void 0 || (_api$table = api.table) === null || _api$table === void 0 ? void 0 : _api$table.sharedState.currentState();
432
- var tr = insert(createTableWithWidth(options === null || options === void 0 ? void 0 : options.isTableScalingEnabled, tableState === null || tableState === void 0 ? void 0 : tableState.isFullWidthModeEnabled)(state.schema));
438
+ var tableNode = createTableWithWidth(options === null || options === void 0 ? void 0 : options.isTableScalingEnabled, tableState === null || tableState === void 0 ? void 0 : tableState.isFullWidthModeEnabled)(state.schema);
439
+ var tr = insert(tableNode);
433
440
  editorAnalyticsAPI === null || editorAnalyticsAPI === 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,25 +1,13 @@
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
- var createTableWithAnalytics = function createTableWithAnalytics(isTableScalingEnabled, isFullWidthModeEnabled, editorAnalyticsAPI) {
13
- return withEditorAnalyticsAPI({
14
- action: ACTION.INSERTED,
15
- actionSubject: ACTION_SUBJECT.DOCUMENT,
16
- actionSubjectId: ACTION_SUBJECT_ID.TABLE,
17
- attributes: {
18
- inputMethod: INPUT_METHOD.SHORTCUT
19
- },
20
- eventType: EVENT_TYPE.TRACK
21
- })(editorAnalyticsAPI)(createTable(isTableScalingEnabled, isFullWidthModeEnabled));
22
- };
23
11
  export function keymapPlugin(getEditorContainerWidth, editorAnalyticsAPI, dragAndDropEnabled) {
24
12
  var _pluginInjectionApi$a;
25
13
  var isTableScalingEnabled = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
@@ -30,7 +18,7 @@ export function keymapPlugin(getEditorContainerWidth, editorAnalyticsAPI, dragAn
30
18
  var ariaNotifyPlugin = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.accessibilityUtils) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions.ariaNotify;
31
19
  bindKeymapWithCommand(nextCell.common, goToNextCell(editorAnalyticsAPI, ariaNotifyPlugin, getIntl)(1), list);
32
20
  bindKeymapWithCommand(previousCell.common, goToNextCell(editorAnalyticsAPI, ariaNotifyPlugin, getIntl)(-1), list);
33
- bindKeymapWithCommand(toggleTable.common, createTableWithAnalytics(isTableScalingEnabled, !!isFullWidthEnabled, editorAnalyticsAPI), list);
21
+ bindKeymapWithCommand(toggleTable.common, createTable(isTableScalingEnabled, !!isFullWidthEnabled, editorAnalyticsAPI), list);
34
22
  bindKeymapWithCommand(backspace.common, chainCommands(deleteTableIfSelectedWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.KEYBOARD), emptyMultipleCellsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.KEYBOARD)), list);
35
23
  bindKeymapWithCommand(backspace.common, moveCursorBackward, list);
36
24
 
@@ -253,7 +253,7 @@ export var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch
253
253
  },
254
254
  nodeViews: {
255
255
  table: function table(node, view, getPos) {
256
- return createTableView(node, view, getPos, portalProviderAPI, eventDispatcher, getEditorContainerWidth, getEditorFeatureFlags, dispatchAnalyticsEvent, pluginInjectionApi);
256
+ return createTableView(node, view, getPos, portalProviderAPI, eventDispatcher, getEditorContainerWidth, getEditorFeatureFlags, dispatchAnalyticsEvent, pluginInjectionApi, isTableAlignmentEnabled);
257
257
  },
258
258
  tableRow: function tableRow(node, view, getPos) {
259
259
  return new TableRow(node, view, getPos, eventDispatcher);
@@ -1,8 +1,5 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
1
  import _extends from "@babel/runtime/helpers/extends";
3
2
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
4
- 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; }
5
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
6
3
  /** @jsx jsx */
7
4
  import { jsx } from '@emotion/react';
8
5
  import { TableSortOrder as SortOrder } from '@atlaskit/custom-steps';
@@ -23,7 +20,7 @@ import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
23
20
  import TableOptionsIcon from '@atlaskit/icon/glyph/preferences';
24
21
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
25
22
  import { clearHoverSelection, hoverColumns, hoverMergedCells, hoverRows, hoverTable, removeDescendantNodes } from './commands';
26
- import { deleteColumnsWithAnalytics, deleteRowsWithAnalytics, deleteTableWithAnalytics, distributeColumnsWidthsWithAnalytics, emptyMultipleCellsWithAnalytics, insertColumnWithAnalytics, insertRowWithAnalytics, mergeCellsWithAnalytics, setColorWithAnalytics, sortColumnWithAnalytics, splitCellWithAnalytics, toggleHeaderColumnWithAnalytics, toggleHeaderRowWithAnalytics, toggleNumberColumnWithAnalytics, toggleTableLockWithAnalytics, wrapTableInExpandWithAnalytics } from './commands-with-analytics';
23
+ import { deleteColumnsWithAnalytics, deleteRowsWithAnalytics, deleteTableWithAnalytics, distributeColumnsWidthsWithAnalytics, emptyMultipleCellsWithAnalytics, insertColumnWithAnalytics, insertRowWithAnalytics, mergeCellsWithAnalytics, setColorWithAnalytics, setTableAlignmentWithAnalytics, sortColumnWithAnalytics, splitCellWithAnalytics, toggleHeaderColumnWithAnalytics, toggleHeaderRowWithAnalytics, toggleNumberColumnWithAnalytics, toggleTableLockWithAnalytics, wrapTableInExpandWithAnalytics } from './commands-with-analytics';
27
24
  import { getPluginState } from './pm-plugins/plugin-factory';
28
25
  import { pluginKey as tableResizingPluginKey } from './pm-plugins/table-resizing';
29
26
  import { getNewResizeStateFromSelectedColumns } from './pm-plugins/table-resizing/utils/resize-state';
@@ -33,6 +30,7 @@ import { TableCssClassName } from './types';
33
30
  import { FloatingAlignmentButtons } from './ui/FloatingAlignmentButtons/FloatingAlignmentButtons';
34
31
  import { DisplayModeIcon } from './ui/icons';
35
32
  import { getMergedCellsPositions, getSelectedColumnIndexes, getSelectedRowIndexes, isTableNested } from './utils';
33
+ import { normaliseAlignment } from './utils/alignment';
36
34
  export var getToolbarMenuConfig = function getToolbarMenuConfig(config, state, _ref, editorAnalyticsAPI) {
37
35
  var formatMessage = _ref.formatMessage;
38
36
  var optionItem = getBooleanFF('platform.editor.a11y-table-floating-toolbar-dropdown-menu_zkb33') ? 'item-checkbox' : 'item';
@@ -322,7 +320,7 @@ export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth,
322
320
  var menu = getToolbarMenuConfig(config, pluginState, intl, editorAnalyticsAPI);
323
321
  var alignmentMenu;
324
322
  var isNested = pluginState.tablePos && isTableNested(state, pluginState.tablePos);
325
- alignmentMenu = options !== null && options !== void 0 && options.isTableAlignmentEnabled && !isNested ? getAlignmentOptionsConfig(state, intl) : [];
323
+ alignmentMenu = options !== null && options !== void 0 && options.isTableAlignmentEnabled && !isNested ? getAlignmentOptionsConfig(state, intl, editorAnalyticsAPI) : [];
326
324
  var cellItems;
327
325
  cellItems = pluginState.isDragAndDropEnabled ? [] : getCellItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, options === null || options === void 0 ? void 0 : options.isTableScalingEnabled);
328
326
  var columnSettingsItems;
@@ -586,7 +584,7 @@ var highlightColumnsHandler = function highlightColumnsHandler(state, dispatch)
586
584
  }
587
585
  return false;
588
586
  };
589
- export var getAlignmentOptionsConfig = function getAlignmentOptionsConfig(editorState, _ref6) {
587
+ export var getAlignmentOptionsConfig = function getAlignmentOptionsConfig(editorState, _ref6, editorAnalyticsAPI) {
590
588
  var formatMessage = _ref6.formatMessage;
591
589
  var tableObject = findTable(editorState.selection);
592
590
  if (!tableObject) {
@@ -611,13 +609,14 @@ export var getAlignmentOptionsConfig = function getAlignmentOptionsConfig(editor
611
609
  var id = alignmentIcon.id,
612
610
  value = alignmentIcon.value,
613
611
  icon = alignmentIcon.icon;
612
+ var currentLayout = tableObject.node.attrs.layout;
614
613
  return {
615
614
  id: id,
616
615
  type: 'button',
617
616
  icon: icon,
618
617
  title: formatMessage(layoutToMessages[value]),
619
- selected: tableObject.node.attrs.layout === value,
620
- onClick: alignTable(value)
618
+ selected: normaliseAlignment(currentLayout) === value,
619
+ onClick: setTableAlignmentWithAnalytics(editorAnalyticsAPI)(value, currentLayout, INPUT_METHOD.FLOATING_TB)
621
620
  };
622
621
  });
623
622
  var alignmentItemOptions = {
@@ -640,27 +639,9 @@ export var getAlignmentOptionsConfig = function getAlignmentOptionsConfig(editor
640
639
  }];
641
640
  return alignmentToolbarItem;
642
641
  };
643
- var alignTable = function alignTable(nextLayoutValue) {
644
- return function (state, dispatch) {
645
- var tableObject = findTable(state.selection);
646
- if (!tableObject || !dispatch) {
647
- return false;
648
- }
649
- var nextTableAttrs = _objectSpread(_objectSpread({}, tableObject.node.attrs), {}, {
650
- layout: nextLayoutValue
651
- });
652
- var tr = state.tr.setNodeMarkup(tableObject.pos, undefined, nextTableAttrs);
653
- tr.setMeta('scrollIntoView', false);
654
-
655
- // TODO - insert analytics here for layout selection
656
-
657
- dispatch(tr);
658
- return true;
659
- };
660
- };
661
642
  export var getSelectedAlignmentIcon = function getSelectedAlignmentIcon(alignmentIcons, selectedNode) {
662
643
  var selectedAlignment = selectedNode.attrs.layout;
663
644
  return alignmentIcons.find(function (icon) {
664
- return icon.value === (selectedNode.attrs.layout === 'default' ? 'center' : selectedAlignment);
645
+ return icon.value === normaliseAlignment(selectedAlignment);
665
646
  });
666
647
  };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Normalise table layout attribute an alignment value ('center' or 'align-start'), returns
3
+ * center if layout equals a breakout value (e.g. 'default', 'wide', 'full-width')
4
+ */
5
+ export var normaliseAlignment = function normaliseAlignment(layout) {
6
+ return layout === 'center' || layout === 'align-start' ? layout : 'center';
7
+ };
@@ -1,4 +1,5 @@
1
- import type { EditorAnalyticsAPI, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
1
+ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
2
+ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
3
  import type { Command, EditorCommand } from '@atlaskit/editor-common/types';
3
4
  import type { Transaction } from '@atlaskit/editor-prosemirror/state';
4
5
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
@@ -7,5 +8,5 @@ export declare const addColumnBefore: (isTableScalingEnabled?: boolean) => Comma
7
8
  export declare const addColumnAfter: (isTableScalingEnabled?: boolean) => Command;
8
9
  export declare const insertColumn: (isTableScalingEnabled?: boolean, isCellBackgroundDuplicated?: boolean) => (column: number) => Command;
9
10
  export declare const insertRow: (row: number, moveCursorToTheNewRow: boolean, isCellBackgroundDuplicated?: boolean) => Command;
10
- export declare const createTable: (isTableScalingEnabled?: boolean, isFullWidthModeEnabled?: boolean) => Command;
11
+ export declare const createTable: (isTableScalingEnabled?: boolean, isFullWidthModeEnabled?: boolean, editorAnalyticsAPI?: EditorAnalyticsAPI | undefined | null) => Command;
11
12
  export declare const insertTableWithSize: (isFullWidthModeEnabled?: boolean, isTableScalingEnabled?: boolean, editorAnalyticsAPI?: EditorAnalyticsAPI) => (rowsCount: number, colsCount: number, inputMethod?: INPUT_METHOD.PICKER) => EditorCommand;
@@ -1,4 +1,5 @@
1
- import type { Command } from '@atlaskit/editor-common/types';
1
+ import type { TableLayout } from '@atlaskit/adf-schema';
2
+ import type { Command, EditorCommand } from '@atlaskit/editor-common/types';
2
3
  import type { Node as PMNode, Schema, Slice } from '@atlaskit/editor-prosemirror/model';
3
4
  import type { EditorState, Selection, Transaction } from '@atlaskit/editor-prosemirror/state';
4
5
  import type { ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
@@ -35,3 +36,4 @@ export declare const autoSizeTable: (view: EditorView, node: PMNode, table: HTML
35
36
  }) => boolean;
36
37
  export declare const addBoldInEmptyHeaderCells: (tableCellHeader: ContentNodeWithPos) => Command;
37
38
  export declare const updateWidthToWidest: (widthToWidest: WidthToWidest) => Command;
39
+ export declare const setTableAlignment: (newAlignment: TableLayout) => EditorCommand;
@@ -1,4 +1,5 @@
1
1
  import type { IntlShape } from 'react-intl-next/src/types';
2
+ import type { TableLayout } from '@atlaskit/adf-schema';
2
3
  import type { TableSortOrder as SortOrder } from '@atlaskit/custom-steps';
3
4
  import { INPUT_METHOD, TABLE_DISPLAY_MODE } from '@atlaskit/editor-common/analytics';
4
5
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
@@ -6,7 +7,7 @@ import type { Command, GetEditorContainerWidth } from '@atlaskit/editor-common/t
6
7
  import type { EditorView } from '@atlaskit/editor-prosemirror/dist/types/view';
7
8
  import type { Rect } from '@atlaskit/editor-tables/table-map';
8
9
  import type { ResizeStateWithAnalytics } from './pm-plugins/table-resizing/utils';
9
- import type { InsertRowMethods, InsertRowOptions, RowInsertPosition } from './types';
10
+ import type { AlignmentOptions, InsertRowMethods, InsertRowOptions, RowInsertPosition } from './types';
10
11
  export declare const emptyMultipleCellsWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.KEYBOARD | INPUT_METHOD.FLOATING_TB | INPUT_METHOD.TABLE_CONTEXT_MENU, targetCellPosition?: number) => Command;
11
12
  export declare const mergeCellsWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | null | undefined) => (inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.FLOATING_TB) => Command;
12
13
  export declare const splitCellWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.FLOATING_TB) => Command;
@@ -28,3 +29,4 @@ export declare const sortColumnWithAnalytics: (editorAnalyticsAPI: EditorAnalyti
28
29
  export declare const distributeColumnsWidthsWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.FLOATING_TB | INPUT_METHOD.TABLE_CONTEXT_MENU, { resizeState, table, attributes }: ResizeStateWithAnalytics) => Command;
29
30
  export declare const wrapTableInExpandWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => Command;
30
31
  export declare const toggleTableLockWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (displayMode: TABLE_DISPLAY_MODE | null, inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.FLOATING_TB) => Command;
32
+ export declare const setTableAlignmentWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (newAlignment: AlignmentOptions, previousAlignment: TableLayout, inputMethod: INPUT_METHOD.FLOATING_TB) => Command;
@@ -23,6 +23,7 @@ export interface ComponentProps {
23
23
  isMediaFullscreen?: boolean;
24
24
  isDragAndDropEnabled?: boolean;
25
25
  isTableScalingEnabled?: boolean;
26
+ isTableAlignmentEnabled?: boolean;
26
27
  tableActive: boolean;
27
28
  ordering?: TableColumnOrdering;
28
29
  isResizing?: boolean;
@@ -24,25 +24,27 @@ type ResizableTableContainerProps = {
24
24
  tableRef: HTMLTableElement;
25
25
  isResizing?: boolean;
26
26
  pluginInjectionApi?: PluginInjectionAPI;
27
- isTableScalingEnabled?: boolean;
28
27
  tableWrapperHeight?: number;
29
28
  isWholeTableInDanger?: boolean;
29
+ isTableScalingEnabled?: boolean;
30
+ isTableAlignmentEnabled?: boolean;
30
31
  };
31
- export declare const ResizableTableContainer: React.MemoExoticComponent<({ children, className, node, containerWidth, editorView, getPos, tableRef, isResizing, pluginInjectionApi, isTableScalingEnabled, tableWrapperHeight, isWholeTableInDanger, }: PropsWithChildren<ResizableTableContainerProps>) => JSX.Element>;
32
+ export declare const ResizableTableContainer: React.MemoExoticComponent<({ children, className, node, containerWidth, editorView, getPos, tableRef, isResizing, pluginInjectionApi, tableWrapperHeight, isWholeTableInDanger, isTableScalingEnabled, isTableAlignmentEnabled, }: PropsWithChildren<ResizableTableContainerProps>) => JSX.Element>;
32
33
  type TableContainerProps = {
33
34
  node: PMNode;
34
35
  className: string;
35
36
  containerWidth: EditorContainerWidth;
36
- isTableResizingEnabled: boolean | undefined;
37
37
  editorView: EditorView;
38
38
  getPos: () => number | undefined;
39
39
  tableRef: HTMLTableElement;
40
40
  isNested: boolean;
41
41
  isResizing?: boolean;
42
42
  pluginInjectionApi?: PluginInjectionAPI;
43
- isTableScalingEnabled?: boolean;
44
43
  tableWrapperHeight?: number;
45
44
  isWholeTableInDanger?: boolean;
45
+ isTableResizingEnabled: boolean | undefined;
46
+ isTableScalingEnabled?: boolean;
47
+ isTableAlignmentEnabled?: boolean;
46
48
  };
47
- export declare const TableContainer: ({ children, node, className, containerWidth: { width: editorWidth }, isTableResizingEnabled, editorView, getPos, tableRef, isNested, tableWrapperHeight, isResizing, pluginInjectionApi, isTableScalingEnabled, isWholeTableInDanger, }: PropsWithChildren<TableContainerProps>) => JSX.Element;
49
+ export declare const TableContainer: ({ children, node, className, containerWidth: { width: editorWidth }, editorView, getPos, tableRef, isNested, tableWrapperHeight, isResizing, pluginInjectionApi, isWholeTableInDanger, isTableResizingEnabled, isTableScalingEnabled, isTableAlignmentEnabled, }: PropsWithChildren<TableContainerProps>) => JSX.Element;
48
50
  export {};
@@ -32,5 +32,5 @@ export default class TableView extends ReactNodeView<Props> {
32
32
  }): boolean;
33
33
  destroy(): void;
34
34
  }
35
- export declare const createTableView: (node: PmNode, view: EditorView, getPos: getPosHandler, portalProviderAPI: LegacyPortalProviderAPI | PortalProviderAPI, eventDispatcher: EventDispatcher, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, dispatchAnalyticsEvent: DispatchAnalyticsEvent, pluginInjectionApi?: PluginInjectionAPI) => NodeView;
35
+ export declare const createTableView: (node: PmNode, view: EditorView, getPos: getPosHandler, portalProviderAPI: LegacyPortalProviderAPI | PortalProviderAPI, eventDispatcher: EventDispatcher, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, dispatchAnalyticsEvent: DispatchAnalyticsEvent, pluginInjectionApi?: PluginInjectionAPI, isTableAlignmentEnabled?: boolean) => NodeView;
36
36
  export {};
@@ -12,6 +12,7 @@ export type TableOptions = {
12
12
  isTableResizingEnabled?: boolean;
13
13
  isDragAndDropEnabled?: boolean;
14
14
  isTableScalingEnabled?: boolean;
15
+ isTableAlignmentEnabled?: boolean;
15
16
  };
16
17
  export interface Props {
17
18
  node: PmNode;
@@ -1,5 +1,4 @@
1
1
  /// <reference types="react" />
2
- import type { TableLayout } from '@atlaskit/adf-schema';
3
2
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
4
3
  import type { Command, FloatingToolbarDropdown, FloatingToolbarHandler, FloatingToolbarItem, GetEditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
5
4
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
@@ -7,7 +6,7 @@ import type { EditorState } from '@atlaskit/editor-prosemirror/state';
7
6
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
8
7
  import { Rect } from '@atlaskit/editor-tables/table-map';
9
8
  import type { TablePluginOptions } from './plugin';
10
- import type { PluginConfig, ToolbarMenuConfig, ToolbarMenuContext, ToolbarMenuState } from './types';
9
+ import type { AlignmentOptions, PluginConfig, ToolbarMenuConfig, ToolbarMenuContext, ToolbarMenuState } from './types';
11
10
  export declare const getToolbarMenuConfig: (config: ToolbarMenuConfig, state: ToolbarMenuState, { formatMessage }: ToolbarMenuContext, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => FloatingToolbarItem<Command>;
12
11
  export declare const getToolbarCellOptionsConfig: (editorState: EditorState, editorView: EditorView | undefined | null, initialSelectionRect: Rect, { formatMessage }: ToolbarMenuContext, getEditorContainerWidth: GetEditorContainerWidth, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null, isTableScalingEnabled?: boolean) => FloatingToolbarDropdown<Command>;
13
12
  export declare const getClosestSelectionRect: (state: EditorState) => Rect | undefined;
@@ -17,9 +16,9 @@ export declare const getLockBtnConfig: (editorAnalyticsAPI: EditorAnalyticsAPI |
17
16
  export declare const getDistributeConfig: (getEditorContainerWidth: GetEditorContainerWidth, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null, isTableScalingEnabled?: boolean) => Command;
18
17
  type AlignmentIcon = {
19
18
  id?: string;
20
- value: TableLayout;
19
+ value: AlignmentOptions;
21
20
  icon: React.ComponentClass<any>;
22
21
  };
23
- export declare const getAlignmentOptionsConfig: (editorState: EditorState, { formatMessage }: ToolbarMenuContext) => Array<FloatingToolbarDropdown<Command>>;
22
+ export declare const getAlignmentOptionsConfig: (editorState: EditorState, { formatMessage }: ToolbarMenuContext, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => Array<FloatingToolbarDropdown<Command>>;
24
23
  export declare const getSelectedAlignmentIcon: (alignmentIcons: AlignmentIcon[], selectedNode: PMNode) => AlignmentIcon | undefined;
25
24
  export {};
@@ -39,6 +39,7 @@ export type TableSharedStateInternal = Pick<TablePluginState, 'isFullWidthModeEn
39
39
  isWholeTableInDanger?: boolean;
40
40
  };
41
41
  export type TableSharedState = Pick<TablePluginState, 'isFullWidthModeEnabled' | 'wasFullWidthModeEnabled'>;
42
+ export type AlignmentOptions = 'center' | 'align-start';
42
43
  export type InsertRowMethods = INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.BUTTON | INPUT_METHOD.SHORTCUT | INPUT_METHOD.KEYBOARD | INPUT_METHOD.FLOATING_TB | INPUT_METHOD.TABLE_CONTEXT_MENU;
43
44
  export interface PluginConfig {
44
45
  advanced?: boolean;
@@ -0,0 +1,7 @@
1
+ import type { TableLayout } from '@atlaskit/adf-schema';
2
+ import type { AlignmentOptions } from '../types';
3
+ /**
4
+ * Normalise table layout attribute an alignment value ('center' or 'align-start'), returns
5
+ * center if layout equals a breakout value (e.g. 'default', 'wide', 'full-width')
6
+ */
7
+ export declare const normaliseAlignment: (layout: TableLayout) => AlignmentOptions;
@@ -1,4 +1,5 @@
1
- import type { EditorAnalyticsAPI, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
1
+ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
2
+ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
3
  import type { Command, EditorCommand } from '@atlaskit/editor-common/types';
3
4
  import type { Transaction } from '@atlaskit/editor-prosemirror/state';
4
5
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
@@ -7,5 +8,5 @@ export declare const addColumnBefore: (isTableScalingEnabled?: boolean) => Comma
7
8
  export declare const addColumnAfter: (isTableScalingEnabled?: boolean) => Command;
8
9
  export declare const insertColumn: (isTableScalingEnabled?: boolean, isCellBackgroundDuplicated?: boolean) => (column: number) => Command;
9
10
  export declare const insertRow: (row: number, moveCursorToTheNewRow: boolean, isCellBackgroundDuplicated?: boolean) => Command;
10
- export declare const createTable: (isTableScalingEnabled?: boolean, isFullWidthModeEnabled?: boolean) => Command;
11
+ export declare const createTable: (isTableScalingEnabled?: boolean, isFullWidthModeEnabled?: boolean, editorAnalyticsAPI?: EditorAnalyticsAPI | undefined | null) => Command;
11
12
  export declare const insertTableWithSize: (isFullWidthModeEnabled?: boolean, isTableScalingEnabled?: boolean, editorAnalyticsAPI?: EditorAnalyticsAPI) => (rowsCount: number, colsCount: number, inputMethod?: INPUT_METHOD.PICKER) => EditorCommand;
@@ -1,4 +1,5 @@
1
- import type { Command } from '@atlaskit/editor-common/types';
1
+ import type { TableLayout } from '@atlaskit/adf-schema';
2
+ import type { Command, EditorCommand } from '@atlaskit/editor-common/types';
2
3
  import type { Node as PMNode, Schema, Slice } from '@atlaskit/editor-prosemirror/model';
3
4
  import type { EditorState, Selection, Transaction } from '@atlaskit/editor-prosemirror/state';
4
5
  import type { ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
@@ -35,3 +36,4 @@ export declare const autoSizeTable: (view: EditorView, node: PMNode, table: HTML
35
36
  }) => boolean;
36
37
  export declare const addBoldInEmptyHeaderCells: (tableCellHeader: ContentNodeWithPos) => Command;
37
38
  export declare const updateWidthToWidest: (widthToWidest: WidthToWidest) => Command;
39
+ export declare const setTableAlignment: (newAlignment: TableLayout) => EditorCommand;
@@ -1,4 +1,5 @@
1
1
  import type { IntlShape } from 'react-intl-next/src/types';
2
+ import type { TableLayout } from '@atlaskit/adf-schema';
2
3
  import type { TableSortOrder as SortOrder } from '@atlaskit/custom-steps';
3
4
  import { INPUT_METHOD, TABLE_DISPLAY_MODE } from '@atlaskit/editor-common/analytics';
4
5
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
@@ -6,7 +7,7 @@ import type { Command, GetEditorContainerWidth } from '@atlaskit/editor-common/t
6
7
  import type { EditorView } from '@atlaskit/editor-prosemirror/dist/types/view';
7
8
  import type { Rect } from '@atlaskit/editor-tables/table-map';
8
9
  import type { ResizeStateWithAnalytics } from './pm-plugins/table-resizing/utils';
9
- import type { InsertRowMethods, InsertRowOptions, RowInsertPosition } from './types';
10
+ import type { AlignmentOptions, InsertRowMethods, InsertRowOptions, RowInsertPosition } from './types';
10
11
  export declare const emptyMultipleCellsWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.KEYBOARD | INPUT_METHOD.FLOATING_TB | INPUT_METHOD.TABLE_CONTEXT_MENU, targetCellPosition?: number) => Command;
11
12
  export declare const mergeCellsWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | null | undefined) => (inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.FLOATING_TB) => Command;
12
13
  export declare const splitCellWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.FLOATING_TB) => Command;
@@ -28,3 +29,4 @@ export declare const sortColumnWithAnalytics: (editorAnalyticsAPI: EditorAnalyti
28
29
  export declare const distributeColumnsWidthsWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.FLOATING_TB | INPUT_METHOD.TABLE_CONTEXT_MENU, { resizeState, table, attributes }: ResizeStateWithAnalytics) => Command;
29
30
  export declare const wrapTableInExpandWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => Command;
30
31
  export declare const toggleTableLockWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (displayMode: TABLE_DISPLAY_MODE | null, inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.FLOATING_TB) => Command;
32
+ export declare const setTableAlignmentWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (newAlignment: AlignmentOptions, previousAlignment: TableLayout, inputMethod: INPUT_METHOD.FLOATING_TB) => Command;
@@ -23,6 +23,7 @@ export interface ComponentProps {
23
23
  isMediaFullscreen?: boolean;
24
24
  isDragAndDropEnabled?: boolean;
25
25
  isTableScalingEnabled?: boolean;
26
+ isTableAlignmentEnabled?: boolean;
26
27
  tableActive: boolean;
27
28
  ordering?: TableColumnOrdering;
28
29
  isResizing?: boolean;
@@ -24,25 +24,27 @@ type ResizableTableContainerProps = {
24
24
  tableRef: HTMLTableElement;
25
25
  isResizing?: boolean;
26
26
  pluginInjectionApi?: PluginInjectionAPI;
27
- isTableScalingEnabled?: boolean;
28
27
  tableWrapperHeight?: number;
29
28
  isWholeTableInDanger?: boolean;
29
+ isTableScalingEnabled?: boolean;
30
+ isTableAlignmentEnabled?: boolean;
30
31
  };
31
- export declare const ResizableTableContainer: React.MemoExoticComponent<({ children, className, node, containerWidth, editorView, getPos, tableRef, isResizing, pluginInjectionApi, isTableScalingEnabled, tableWrapperHeight, isWholeTableInDanger, }: PropsWithChildren<ResizableTableContainerProps>) => JSX.Element>;
32
+ export declare const ResizableTableContainer: React.MemoExoticComponent<({ children, className, node, containerWidth, editorView, getPos, tableRef, isResizing, pluginInjectionApi, tableWrapperHeight, isWholeTableInDanger, isTableScalingEnabled, isTableAlignmentEnabled, }: PropsWithChildren<ResizableTableContainerProps>) => JSX.Element>;
32
33
  type TableContainerProps = {
33
34
  node: PMNode;
34
35
  className: string;
35
36
  containerWidth: EditorContainerWidth;
36
- isTableResizingEnabled: boolean | undefined;
37
37
  editorView: EditorView;
38
38
  getPos: () => number | undefined;
39
39
  tableRef: HTMLTableElement;
40
40
  isNested: boolean;
41
41
  isResizing?: boolean;
42
42
  pluginInjectionApi?: PluginInjectionAPI;
43
- isTableScalingEnabled?: boolean;
44
43
  tableWrapperHeight?: number;
45
44
  isWholeTableInDanger?: boolean;
45
+ isTableResizingEnabled: boolean | undefined;
46
+ isTableScalingEnabled?: boolean;
47
+ isTableAlignmentEnabled?: boolean;
46
48
  };
47
- export declare const TableContainer: ({ children, node, className, containerWidth: { width: editorWidth }, isTableResizingEnabled, editorView, getPos, tableRef, isNested, tableWrapperHeight, isResizing, pluginInjectionApi, isTableScalingEnabled, isWholeTableInDanger, }: PropsWithChildren<TableContainerProps>) => JSX.Element;
49
+ export declare const TableContainer: ({ children, node, className, containerWidth: { width: editorWidth }, editorView, getPos, tableRef, isNested, tableWrapperHeight, isResizing, pluginInjectionApi, isWholeTableInDanger, isTableResizingEnabled, isTableScalingEnabled, isTableAlignmentEnabled, }: PropsWithChildren<TableContainerProps>) => JSX.Element;
48
50
  export {};
@@ -32,5 +32,5 @@ export default class TableView extends ReactNodeView<Props> {
32
32
  }): boolean;
33
33
  destroy(): void;
34
34
  }
35
- export declare const createTableView: (node: PmNode, view: EditorView, getPos: getPosHandler, portalProviderAPI: LegacyPortalProviderAPI | PortalProviderAPI, eventDispatcher: EventDispatcher, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, dispatchAnalyticsEvent: DispatchAnalyticsEvent, pluginInjectionApi?: PluginInjectionAPI) => NodeView;
35
+ export declare const createTableView: (node: PmNode, view: EditorView, getPos: getPosHandler, portalProviderAPI: LegacyPortalProviderAPI | PortalProviderAPI, eventDispatcher: EventDispatcher, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, dispatchAnalyticsEvent: DispatchAnalyticsEvent, pluginInjectionApi?: PluginInjectionAPI, isTableAlignmentEnabled?: boolean) => NodeView;
36
36
  export {};
@@ -12,6 +12,7 @@ export type TableOptions = {
12
12
  isTableResizingEnabled?: boolean;
13
13
  isDragAndDropEnabled?: boolean;
14
14
  isTableScalingEnabled?: boolean;
15
+ isTableAlignmentEnabled?: boolean;
15
16
  };
16
17
  export interface Props {
17
18
  node: PmNode;
@@ -1,5 +1,4 @@
1
1
  /// <reference types="react" />
2
- import type { TableLayout } from '@atlaskit/adf-schema';
3
2
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
4
3
  import type { Command, FloatingToolbarDropdown, FloatingToolbarHandler, FloatingToolbarItem, GetEditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
5
4
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
@@ -7,7 +6,7 @@ import type { EditorState } from '@atlaskit/editor-prosemirror/state';
7
6
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
8
7
  import { Rect } from '@atlaskit/editor-tables/table-map';
9
8
  import type { TablePluginOptions } from './plugin';
10
- import type { PluginConfig, ToolbarMenuConfig, ToolbarMenuContext, ToolbarMenuState } from './types';
9
+ import type { AlignmentOptions, PluginConfig, ToolbarMenuConfig, ToolbarMenuContext, ToolbarMenuState } from './types';
11
10
  export declare const getToolbarMenuConfig: (config: ToolbarMenuConfig, state: ToolbarMenuState, { formatMessage }: ToolbarMenuContext, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => FloatingToolbarItem<Command>;
12
11
  export declare const getToolbarCellOptionsConfig: (editorState: EditorState, editorView: EditorView | undefined | null, initialSelectionRect: Rect, { formatMessage }: ToolbarMenuContext, getEditorContainerWidth: GetEditorContainerWidth, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null, isTableScalingEnabled?: boolean) => FloatingToolbarDropdown<Command>;
13
12
  export declare const getClosestSelectionRect: (state: EditorState) => Rect | undefined;
@@ -17,9 +16,9 @@ export declare const getLockBtnConfig: (editorAnalyticsAPI: EditorAnalyticsAPI |
17
16
  export declare const getDistributeConfig: (getEditorContainerWidth: GetEditorContainerWidth, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null, isTableScalingEnabled?: boolean) => Command;
18
17
  type AlignmentIcon = {
19
18
  id?: string;
20
- value: TableLayout;
19
+ value: AlignmentOptions;
21
20
  icon: React.ComponentClass<any>;
22
21
  };
23
- export declare const getAlignmentOptionsConfig: (editorState: EditorState, { formatMessage }: ToolbarMenuContext) => Array<FloatingToolbarDropdown<Command>>;
22
+ export declare const getAlignmentOptionsConfig: (editorState: EditorState, { formatMessage }: ToolbarMenuContext, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => Array<FloatingToolbarDropdown<Command>>;
24
23
  export declare const getSelectedAlignmentIcon: (alignmentIcons: AlignmentIcon[], selectedNode: PMNode) => AlignmentIcon | undefined;
25
24
  export {};
@@ -39,6 +39,7 @@ export type TableSharedStateInternal = Pick<TablePluginState, 'isFullWidthModeEn
39
39
  isWholeTableInDanger?: boolean;
40
40
  };
41
41
  export type TableSharedState = Pick<TablePluginState, 'isFullWidthModeEnabled' | 'wasFullWidthModeEnabled'>;
42
+ export type AlignmentOptions = 'center' | 'align-start';
42
43
  export type InsertRowMethods = INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.BUTTON | INPUT_METHOD.SHORTCUT | INPUT_METHOD.KEYBOARD | INPUT_METHOD.FLOATING_TB | INPUT_METHOD.TABLE_CONTEXT_MENU;
43
44
  export interface PluginConfig {
44
45
  advanced?: boolean;
@@ -0,0 +1,7 @@
1
+ import type { TableLayout } from '@atlaskit/adf-schema';
2
+ import type { AlignmentOptions } from '../types';
3
+ /**
4
+ * Normalise table layout attribute an alignment value ('center' or 'align-start'), returns
5
+ * center if layout equals a breakout value (e.g. 'default', 'wide', 'full-width')
6
+ */
7
+ export declare const normaliseAlignment: (layout: TableLayout) => AlignmentOptions;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "7.16.0",
3
+ "version": "7.16.2",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -28,8 +28,8 @@
28
28
  "runReact18": false
29
29
  },
30
30
  "dependencies": {
31
- "@atlaskit/adf-schema": "^36.3.0",
32
- "@atlaskit/button": "^17.14.0",
31
+ "@atlaskit/adf-schema": "^36.8.0",
32
+ "@atlaskit/button": "^17.15.0",
33
33
  "@atlaskit/custom-steps": "^0.2.0",
34
34
  "@atlaskit/editor-common": "^80.4.0",
35
35
  "@atlaskit/editor-palette": "1.6.0",
@@ -43,16 +43,16 @@
43
43
  "@atlaskit/editor-prosemirror": "4.0.1",
44
44
  "@atlaskit/editor-shared-styles": "^2.11.0",
45
45
  "@atlaskit/editor-tables": "^2.7.0",
46
- "@atlaskit/icon": "^22.2.0",
46
+ "@atlaskit/icon": "^22.3.0",
47
47
  "@atlaskit/menu": "^2.3.0",
48
48
  "@atlaskit/platform-feature-flags": "^0.2.1",
49
49
  "@atlaskit/pragmatic-drag-and-drop": "^1.1.0",
50
50
  "@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^1.3.0",
51
51
  "@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.0.0",
52
- "@atlaskit/primitives": "^6.2.0",
52
+ "@atlaskit/primitives": "^6.3.0",
53
53
  "@atlaskit/theme": "^12.8.0",
54
54
  "@atlaskit/toggle": "^13.1.0",
55
- "@atlaskit/tokens": "^1.48.0",
55
+ "@atlaskit/tokens": "^1.49.0",
56
56
  "@atlaskit/tooltip": "^18.4.0",
57
57
  "@babel/runtime": "^7.0.0",
58
58
  "@emotion/react": "^11.7.1",