@atlaskit/editor-plugin-table 7.9.0 → 7.10.0

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 (41) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/cjs/commands/column-resize.js +18 -6
  3. package/dist/cjs/nodeviews/TableComponent.js +11 -3
  4. package/dist/cjs/utils/index.js +12 -0
  5. package/dist/cjs/utils/nodes.js +6 -1
  6. package/dist/cjs/utils/table.js +34 -1
  7. package/dist/es2019/commands/column-resize.js +18 -6
  8. package/dist/es2019/nodeviews/TableComponent.js +12 -4
  9. package/dist/es2019/utils/index.js +2 -2
  10. package/dist/es2019/utils/nodes.js +5 -0
  11. package/dist/es2019/utils/table.js +36 -1
  12. package/dist/esm/commands/column-resize.js +18 -6
  13. package/dist/esm/nodeviews/TableComponent.js +12 -4
  14. package/dist/esm/utils/index.js +2 -2
  15. package/dist/esm/utils/nodes.js +5 -0
  16. package/dist/esm/utils/table.js +33 -0
  17. package/dist/types/commands/column-resize.d.ts +5 -4
  18. package/dist/types/nodeviews/TableComponent.d.ts +6 -54
  19. package/dist/types/plugin.d.ts +1 -1
  20. package/dist/types/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +16 -20
  21. package/dist/types/ui/TableFloatingControls/CornerControls/DragCornerControls.d.ts +32 -40
  22. package/dist/types/ui/TableFloatingControls/index.d.ts +16 -20
  23. package/dist/types/utils/index.d.ts +2 -2
  24. package/dist/types/utils/nodes.d.ts +1 -0
  25. package/dist/types/utils/table.d.ts +3 -0
  26. package/dist/types-ts4.5/commands/column-resize.d.ts +5 -4
  27. package/dist/types-ts4.5/nodeviews/TableComponent.d.ts +6 -54
  28. package/dist/types-ts4.5/plugin.d.ts +1 -1
  29. package/dist/types-ts4.5/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +16 -20
  30. package/dist/types-ts4.5/ui/TableFloatingControls/CornerControls/DragCornerControls.d.ts +32 -40
  31. package/dist/types-ts4.5/ui/TableFloatingControls/index.d.ts +16 -20
  32. package/dist/types-ts4.5/utils/index.d.ts +2 -2
  33. package/dist/types-ts4.5/utils/nodes.d.ts +1 -0
  34. package/dist/types-ts4.5/utils/table.d.ts +3 -0
  35. package/package.json +1 -1
  36. package/src/commands/column-resize.ts +31 -8
  37. package/src/nodeviews/TableComponent.tsx +21 -6
  38. package/src/plugin.tsx +1 -1
  39. package/src/utils/index.ts +2 -1
  40. package/src/utils/nodes.ts +10 -0
  41. package/src/utils/table.ts +36 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 7.10.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#85498](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/85498) [`ae3b8e85ce49`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/ae3b8e85ce49) - [ux] [ECA11Y-17] Added screen reader announcement for insertion and removal of table columns and rows
8
+
3
9
  ## 7.9.0
4
10
 
5
11
  ### Minor Changes
@@ -78,7 +78,9 @@ var initiateKeyboardColumnResizing = exports.initiateKeyboardColumnResizing = fu
78
78
  var selectionRect = (0, _utils.isSelectionType)(selection, 'cell') ? (0, _utils.getSelectionRect)(selection) : (0, _utils.findCellRectClosestToPos)(selection.$from);
79
79
  var cell = (0, _utils.findCellClosestToPos)(selection.$from);
80
80
  if (ariaNotify && getIntl) {
81
- ariaNotify(getIntl().formatMessage(_messages.tableMessages.startedColumnResize));
81
+ ariaNotify(getIntl().formatMessage(_messages.tableMessages.startedColumnResize), {
82
+ priority: 'important'
83
+ });
82
84
  }
83
85
  if (selectionRect && cell && view) {
84
86
  return updateResizeHandleAndStatePosition(selectionRect.top, selectionRect.right, cell.pos)(state, dispatch);
@@ -122,12 +124,16 @@ var activateNextResizeArea = exports.activateNextResizeArea = function activateN
122
124
  if (direction === 1) {
123
125
  ariaNotify(getIntl().formatMessage(_messages.tableMessages.focusedOtherResize, {
124
126
  direction: 'right'
125
- }));
127
+ }), {
128
+ priority: 'important'
129
+ });
126
130
  }
127
131
  if (direction === -1) {
128
132
  ariaNotify(getIntl().formatMessage(_messages.tableMessages.focusedOtherResize, {
129
133
  direction: 'left'
130
- }));
134
+ }), {
135
+ priority: 'important'
136
+ });
131
137
  }
132
138
  }
133
139
  if ($nextCell) {
@@ -223,10 +229,14 @@ var changeColumnWidthByStep = exports.changeColumnWidthByStep = function changeC
223
229
  }));
224
230
  if (newResizeState.cols.length === colIndex + 1) {
225
231
  if (newResizeState.overflow === true) {
226
- ariaNotify(getIntl().formatMessage(_messages.tableMessages.columnResizeLast));
232
+ ariaNotify(getIntl().formatMessage(_messages.tableMessages.columnResizeLast), {
233
+ priority: 'important'
234
+ });
227
235
  }
228
236
  if (newResizeState.overflow === false) {
229
- ariaNotify(getIntl().formatMessage(_messages.tableMessages.columnResizeOverflow));
237
+ ariaNotify(getIntl().formatMessage(_messages.tableMessages.columnResizeOverflow), {
238
+ priority: 'important'
239
+ });
230
240
  }
231
241
  }
232
242
  }
@@ -262,7 +272,9 @@ var stopKeyboardColumnResizing = exports.stopKeyboardColumnResizing = function s
262
272
  return customTr.setMeta('scrollIntoView', false);
263
273
  })(state, fakeDispatch);
264
274
  if (ariaNotify && getIntl) {
265
- ariaNotify(getIntl().formatMessage(_messages.tableMessages.columnResizeStop));
275
+ ariaNotify(getIntl().formatMessage(_messages.tableMessages.columnResizeStop), {
276
+ priority: 'important'
277
+ });
266
278
  }
267
279
  if (dispatch) {
268
280
  dispatch(customTr);
@@ -17,6 +17,7 @@ var _react = _interopRequireDefault(require("react"));
17
17
  var _classnames2 = _interopRequireDefault(require("classnames"));
18
18
  var _memoizeOne = _interopRequireDefault(require("memoize-one"));
19
19
  var _rafSchd = _interopRequireDefault(require("raf-schd"));
20
+ var _reactIntlNext = require("react-intl-next");
20
21
  var _analytics = require("@atlaskit/editor-common/analytics");
21
22
  var _nodeWidth = require("@atlaskit/editor-common/node-width");
22
23
  var _styles = require("@atlaskit/editor-common/styles");
@@ -522,6 +523,15 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
522
523
  this.overflowShadowsObserver.observeShadowSentinels((_this$state$stickyHea = this.state.stickyHeader) === null || _this$state$stickyHea === void 0 ? void 0 : _this$state$stickyHea.sticky);
523
524
  }
524
525
  var currentTable = getNode();
526
+ var previousTable = this.node;
527
+ var isNoOfColumnsChanged = (0, _utils5.tablesHaveDifferentNoOfColumns)(currentTable, previousTable);
528
+ var isNoOfRowsChanged = (0, _utils5.tablesHaveDifferentNoOfRows)(currentTable, previousTable);
529
+ if (isNoOfColumnsChanged || isNoOfRowsChanged) {
530
+ var _this$props$pluginInj;
531
+ (_this$props$pluginInj = this.props.pluginInjectionApi) === null || _this$props$pluginInj === void 0 || (_this$props$pluginInj = _this$props$pluginInj.accessibilityUtils) === null || _this$props$pluginInj === void 0 || _this$props$pluginInj.actions.ariaNotify((0, _utils5.getAssistiveMessage)(previousTable, currentTable, this.props.intl), {
532
+ priority: 'important'
533
+ });
534
+ }
525
535
  if (currentTable.attrs.__autoSize) {
526
536
  // Wait for next tick to handle auto sizing, gives the browser time to do layout calc etc.
527
537
  this.handleAutoSizeDebounced();
@@ -531,8 +541,6 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
531
541
  else if (allowColumnResizing && this.table && !isMediaFullscreen) {
532
542
  // If col widths (e.g. via collab) or number of columns (e.g. delete a column) have changed,
533
543
  // re-draw colgroup.
534
- var previousTable = this.node;
535
- var isNoOfColumnsChanged = (0, _utils5.tablesHaveDifferentNoOfColumns)(currentTable, previousTable);
536
544
  if ((0, _utils5.tablesHaveDifferentColumnWidths)(currentTable, previousTable) || isNoOfColumnsChanged) {
537
545
  var _view = this.props.view;
538
546
  var shouldRecreateResizeCols = !(options !== null && options !== void 0 && options.isTableResizingEnabled) || !isResizing || isNoOfColumnsChanged && isResizing;
@@ -793,4 +801,4 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
793
801
  return TableComponent;
794
802
  }(_react.default.Component);
795
803
  (0, _defineProperty3.default)(TableComponent, "displayName", 'TableComponent');
796
- var _default = exports.default = TableComponent;
804
+ var _default = exports.default = (0, _reactIntlNext.injectIntl)(TableComponent);
@@ -129,6 +129,12 @@ Object.defineProperty(exports, "findNearestCellIndexToPoint", {
129
129
  return _dom.findNearestCellIndexToPoint;
130
130
  }
131
131
  });
132
+ Object.defineProperty(exports, "getAssistiveMessage", {
133
+ enumerable: true,
134
+ get: function get() {
135
+ return _table.getAssistiveMessage;
136
+ }
137
+ });
132
138
  Object.defineProperty(exports, "getColumnClassNames", {
133
139
  enumerable: true,
134
140
  get: function get() {
@@ -399,6 +405,12 @@ Object.defineProperty(exports, "tablesHaveDifferentNoOfColumns", {
399
405
  return _nodes.tablesHaveDifferentNoOfColumns;
400
406
  }
401
407
  });
408
+ Object.defineProperty(exports, "tablesHaveDifferentNoOfRows", {
409
+ enumerable: true,
410
+ get: function get() {
411
+ return _nodes.tablesHaveDifferentNoOfRows;
412
+ }
413
+ });
402
414
  Object.defineProperty(exports, "transformSliceToCorrectEmptyTableCells", {
403
415
  enumerable: true,
404
416
  get: function get() {
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.tablesHaveDifferentNoOfColumns = exports.tablesHaveDifferentColumnWidths = exports.supportedHeaderRow = exports.isTableNested = exports.isIsolating = exports.getTableWidth = exports.containsHeaderRow = exports.containsHeaderColumn = exports.checkIfNumberColumnEnabled = exports.checkIfHeaderRowEnabled = exports.checkIfHeaderColumnEnabled = exports.anyChildCellMergedAcrossRow = void 0;
7
+ exports.tablesHaveDifferentNoOfRows = exports.tablesHaveDifferentNoOfColumns = exports.tablesHaveDifferentColumnWidths = exports.supportedHeaderRow = exports.isTableNested = exports.isIsolating = exports.getTableWidth = exports.containsHeaderRow = exports.containsHeaderColumn = exports.checkIfNumberColumnEnabled = exports.checkIfHeaderRowEnabled = exports.checkIfHeaderColumnEnabled = exports.anyChildCellMergedAcrossRow = void 0;
8
8
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
9
  var _utils = require("@atlaskit/editor-common/utils");
10
10
  var _tableMap = require("@atlaskit/editor-tables/table-map");
@@ -75,6 +75,11 @@ var tablesHaveDifferentNoOfColumns = exports.tablesHaveDifferentNoOfColumns = fu
75
75
  var currentMap = _tableMap.TableMap.get(currentTable);
76
76
  return prevMap.width !== currentMap.width;
77
77
  };
78
+ var tablesHaveDifferentNoOfRows = exports.tablesHaveDifferentNoOfRows = function tablesHaveDifferentNoOfRows(currentTable, previousTable) {
79
+ var prevMap = _tableMap.TableMap.get(previousTable);
80
+ var currentMap = _tableMap.TableMap.get(currentTable);
81
+ return prevMap.height !== currentMap.height;
82
+ };
78
83
  function filterNearSelection(selection, findNode, predicate, defaultValue) {
79
84
  var found = findNode(selection);
80
85
  if (!found) {
@@ -4,8 +4,9 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.getMergedCellsPositions = exports.colsToRect = void 0;
7
+ exports.getMergedCellsPositions = exports.getAssistiveMessage = exports.colsToRect = void 0;
8
8
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
+ var _messages = require("@atlaskit/editor-common/messages");
9
10
  var _tableMap = require("@atlaskit/editor-tables/table-map");
10
11
  var _utils = require("@atlaskit/editor-tables/utils");
11
12
  var getMergedCellsPositions = exports.getMergedCellsPositions = function getMergedCellsPositions(tr) {
@@ -32,4 +33,36 @@ var colsToRect = exports.colsToRect = function colsToRect(cols, noOfRows) {
32
33
  top: 0,
33
34
  bottom: noOfRows
34
35
  };
36
+ };
37
+ var getAssistiveMessage = exports.getAssistiveMessage = function getAssistiveMessage(prevTableNode, currentTableNode, intl) {
38
+ var formatMessage = intl.formatMessage;
39
+ var prevTableMap = _tableMap.TableMap.get(prevTableNode);
40
+ var currentTableMap = _tableMap.TableMap.get(currentTableNode);
41
+ if (currentTableMap.width !== prevTableMap.width) {
42
+ var diff = Math.abs(currentTableMap.width - prevTableMap.width);
43
+ if (currentTableMap.width > prevTableMap.width) {
44
+ return formatMessage(_messages.tableMessages.columnsAreInserted, {
45
+ count: diff
46
+ });
47
+ }
48
+ if (currentTableMap.width < prevTableMap.width) {
49
+ return formatMessage(_messages.tableMessages.columnsAreRemoved, {
50
+ count: diff
51
+ });
52
+ }
53
+ }
54
+ if (currentTableMap.height !== prevTableMap.height) {
55
+ var _diff = Math.abs(currentTableMap.height - prevTableMap.height);
56
+ if (currentTableMap.height > prevTableMap.height) {
57
+ return formatMessage(_messages.tableMessages.rowsAreInserted, {
58
+ count: _diff
59
+ });
60
+ }
61
+ if (currentTableMap.height < prevTableMap.height) {
62
+ return formatMessage(_messages.tableMessages.rowsAreRemoved, {
63
+ count: _diff
64
+ });
65
+ }
66
+ }
67
+ return '';
35
68
  };
@@ -71,7 +71,9 @@ export const initiateKeyboardColumnResizing = ({
71
71
  const selectionRect = isSelectionType(selection, 'cell') ? getSelectionRect(selection) : findCellRectClosestToPos(selection.$from);
72
72
  const cell = findCellClosestToPos(selection.$from);
73
73
  if (ariaNotify && getIntl) {
74
- ariaNotify(getIntl().formatMessage(messages.startedColumnResize));
74
+ ariaNotify(getIntl().formatMessage(messages.startedColumnResize), {
75
+ priority: 'important'
76
+ });
75
77
  }
76
78
  if (selectionRect && cell && view) {
77
79
  return updateResizeHandleAndStatePosition(selectionRect.top, selectionRect.right, cell.pos)(state, dispatch);
@@ -117,12 +119,16 @@ export const activateNextResizeArea = ({
117
119
  if (direction === 1) {
118
120
  ariaNotify(getIntl().formatMessage(messages.focusedOtherResize, {
119
121
  direction: 'right'
120
- }));
122
+ }), {
123
+ priority: 'important'
124
+ });
121
125
  }
122
126
  if (direction === -1) {
123
127
  ariaNotify(getIntl().formatMessage(messages.focusedOtherResize, {
124
128
  direction: 'left'
125
- }));
129
+ }), {
130
+ priority: 'important'
131
+ });
126
132
  }
127
133
  }
128
134
  if ($nextCell) {
@@ -218,10 +224,14 @@ export const changeColumnWidthByStep = ({
218
224
  }));
219
225
  if (newResizeState.cols.length === colIndex + 1) {
220
226
  if (newResizeState.overflow === true) {
221
- ariaNotify(getIntl().formatMessage(messages.columnResizeLast));
227
+ ariaNotify(getIntl().formatMessage(messages.columnResizeLast), {
228
+ priority: 'important'
229
+ });
222
230
  }
223
231
  if (newResizeState.overflow === false) {
224
- ariaNotify(getIntl().formatMessage(messages.columnResizeOverflow));
232
+ ariaNotify(getIntl().formatMessage(messages.columnResizeOverflow), {
233
+ priority: 'important'
234
+ });
225
235
  }
226
236
  }
227
237
  }
@@ -254,7 +264,9 @@ export const stopKeyboardColumnResizing = ({
254
264
  type: 'STOP_RESIZING'
255
265
  }, () => customTr.setMeta('scrollIntoView', false))(state, fakeDispatch);
256
266
  if (ariaNotify && getIntl) {
257
- ariaNotify(getIntl().formatMessage(messages.columnResizeStop));
267
+ ariaNotify(getIntl().formatMessage(messages.columnResizeStop), {
268
+ priority: 'important'
269
+ });
258
270
  }
259
271
  if (dispatch) {
260
272
  dispatch(customTr);
@@ -3,6 +3,7 @@ import React from 'react';
3
3
  import classnames from 'classnames';
4
4
  import memoizeOne from 'memoize-one';
5
5
  import rafSchedule from 'raf-schd';
6
+ import { injectIntl } from 'react-intl-next';
6
7
  import { ACTION_SUBJECT, EVENT_TYPE, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
7
8
  import { getParentNodeWidth, getTableContainerWidth } from '@atlaskit/editor-common/node-width';
8
9
  import { tableMarginSides } from '@atlaskit/editor-common/styles';
@@ -23,7 +24,7 @@ import { updateControls } from '../pm-plugins/table-resizing/utils/dom';
23
24
  import { TableCssClassName as ClassName, ShadowEvent } from '../types';
24
25
  import TableFloatingColumnControls from '../ui/TableFloatingColumnControls';
25
26
  import TableFloatingControls from '../ui/TableFloatingControls';
26
- import { containsHeaderRow, isTableNested, tablesHaveDifferentColumnWidths, tablesHaveDifferentNoOfColumns } from '../utils';
27
+ import { containsHeaderRow, getAssistiveMessage, isTableNested, tablesHaveDifferentColumnWidths, tablesHaveDifferentNoOfColumns, tablesHaveDifferentNoOfRows } from '../utils';
27
28
  import { ExternalDropTargets } from './ExternalDropTargets';
28
29
  import { OverflowShadowsObserver } from './OverflowShadowsObserver';
29
30
  import { TableContainer } from './TableContainer';
@@ -506,6 +507,15 @@ class TableComponent extends React.Component {
506
507
  this.overflowShadowsObserver.observeShadowSentinels((_this$state$stickyHea = this.state.stickyHeader) === null || _this$state$stickyHea === void 0 ? void 0 : _this$state$stickyHea.sticky);
507
508
  }
508
509
  const currentTable = getNode();
510
+ const previousTable = this.node;
511
+ const isNoOfColumnsChanged = tablesHaveDifferentNoOfColumns(currentTable, previousTable);
512
+ const isNoOfRowsChanged = tablesHaveDifferentNoOfRows(currentTable, previousTable);
513
+ if (isNoOfColumnsChanged || isNoOfRowsChanged) {
514
+ var _this$props$pluginInj, _this$props$pluginInj2;
515
+ (_this$props$pluginInj = this.props.pluginInjectionApi) === null || _this$props$pluginInj === void 0 ? void 0 : (_this$props$pluginInj2 = _this$props$pluginInj.accessibilityUtils) === null || _this$props$pluginInj2 === void 0 ? void 0 : _this$props$pluginInj2.actions.ariaNotify(getAssistiveMessage(previousTable, currentTable, this.props.intl), {
516
+ priority: 'important'
517
+ });
518
+ }
509
519
  if (currentTable.attrs.__autoSize) {
510
520
  // Wait for next tick to handle auto sizing, gives the browser time to do layout calc etc.
511
521
  this.handleAutoSizeDebounced();
@@ -515,8 +525,6 @@ class TableComponent extends React.Component {
515
525
  else if (allowColumnResizing && this.table && !isMediaFullscreen) {
516
526
  // If col widths (e.g. via collab) or number of columns (e.g. delete a column) have changed,
517
527
  // re-draw colgroup.
518
- const previousTable = this.node;
519
- const isNoOfColumnsChanged = tablesHaveDifferentNoOfColumns(currentTable, previousTable);
520
528
  if (tablesHaveDifferentColumnWidths(currentTable, previousTable) || isNoOfColumnsChanged) {
521
529
  const {
522
530
  view
@@ -780,4 +788,4 @@ class TableComponent extends React.Component {
780
788
  }
781
789
  }
782
790
  _defineProperty(TableComponent, "displayName", 'TableComponent');
783
- export default TableComponent;
791
+ export default injectIntl(TableComponent);
@@ -1,12 +1,12 @@
1
1
  export { getSelectedColumnIndexes, getSelectedRowIndexes, normalizeSelection, isSelectionUpdated } from './selection';
2
2
  export { findControlsHoverDecoration, createControlsHoverDecoration, createColumnControlsDecoration, createColumnSelectedDecoration, createCellHoverDecoration, updateDecorations, createResizeHandleDecoration, createColumnInsertLine, createColumnLineResize, createRowInsertLine } from './decoration';
3
- export { isIsolating, containsHeaderColumn, containsHeaderRow, checkIfHeaderColumnEnabled, checkIfHeaderRowEnabled, checkIfNumberColumnEnabled, getTableWidth, tablesHaveDifferentColumnWidths, tablesHaveDifferentNoOfColumns, isTableNested, anyChildCellMergedAcrossRow, supportedHeaderRow } from './nodes';
3
+ export { isIsolating, containsHeaderColumn, containsHeaderRow, checkIfHeaderColumnEnabled, checkIfHeaderRowEnabled, checkIfNumberColumnEnabled, getTableWidth, tablesHaveDifferentColumnWidths, tablesHaveDifferentNoOfColumns, tablesHaveDifferentNoOfRows, isTableNested, anyChildCellMergedAcrossRow, supportedHeaderRow } from './nodes';
4
4
  export { unwrapContentFromTable, removeTableFromFirstChild, removeTableFromLastChild, transformSliceToRemoveOpenTable, transformSliceToCorrectEmptyTableCells, transformSliceToFixHardBreakProblemOnCopyFromCell } from './paste';
5
5
  export { isCell, isCornerButton, isInsertRowButton, isColumnControlsDecorations, isTableControlsButton, isTableContainerOrWrapper, isRowControlsButton, isDragRowControlsButton, isDragColumnFloatingInsertDot, isDragRowFloatingInsertDot, isDragCornerButton, getColumnOrRowIndex, getMousePositionHorizontalRelativeByElement, getMousePositionVerticalRelativeByElement, isResizeHandleDecoration, hasResizeHandler, findNearestCellIndexToPoint } from './dom';
6
6
  export { convertHTMLCellIndexToColumnIndex, getColumnsWidths, isColumnDeleteButtonVisible, getColumnDeleteButtonParams, getColumnClassNames, getColumnIndexMappedToColumnIndexInFirstRow } from './column-controls';
7
7
  export { getRowHeights, isRowDeleteButtonVisible, getRowDeleteButtonParams, getRowsParams, getRowClassNames, copyPreviousRow } from './row-controls';
8
8
  export { getSelectedTableInfo, getSelectedCellInfo } from './analytics';
9
- export { getMergedCellsPositions } from './table';
9
+ export { getMergedCellsPositions, getAssistiveMessage } from './table';
10
10
  export { updatePluginStateDecorations } from './update-plugin-state-decorations';
11
11
  export { hasMergedCellsInColumn, hasMergedCellsInRow, hasMergedCellsInBetween, hasMergedCellsInSelection, findDuplicatePosition, checkEdgeHasMergedCells } from './merged-cells';
12
12
  export { createTableWithWidth } from './create';
@@ -57,6 +57,11 @@ export const tablesHaveDifferentNoOfColumns = (currentTable, previousTable) => {
57
57
  const currentMap = TableMap.get(currentTable);
58
58
  return prevMap.width !== currentMap.width;
59
59
  };
60
+ export const tablesHaveDifferentNoOfRows = (currentTable, previousTable) => {
61
+ const prevMap = TableMap.get(previousTable);
62
+ const currentMap = TableMap.get(currentTable);
63
+ return prevMap.height !== currentMap.height;
64
+ };
60
65
  function filterNearSelection(selection, findNode, predicate, defaultValue) {
61
66
  const found = findNode(selection);
62
67
  if (!found) {
@@ -1,3 +1,4 @@
1
+ import { tableMessages as messages } from '@atlaskit/editor-common/messages';
1
2
  import { TableMap } from '@atlaskit/editor-tables/table-map';
2
3
  import { findTable } from '@atlaskit/editor-tables/utils';
3
4
  export const getMergedCellsPositions = tr => {
@@ -22,4 +23,38 @@ export const colsToRect = (cols, noOfRows) => ({
22
23
  right: Math.max(...cols) + 1,
23
24
  top: 0,
24
25
  bottom: noOfRows
25
- });
26
+ });
27
+ export const getAssistiveMessage = (prevTableNode, currentTableNode, intl) => {
28
+ const {
29
+ formatMessage
30
+ } = intl;
31
+ const prevTableMap = TableMap.get(prevTableNode);
32
+ const currentTableMap = TableMap.get(currentTableNode);
33
+ if (currentTableMap.width !== prevTableMap.width) {
34
+ const diff = Math.abs(currentTableMap.width - prevTableMap.width);
35
+ if (currentTableMap.width > prevTableMap.width) {
36
+ return formatMessage(messages.columnsAreInserted, {
37
+ count: diff
38
+ });
39
+ }
40
+ if (currentTableMap.width < prevTableMap.width) {
41
+ return formatMessage(messages.columnsAreRemoved, {
42
+ count: diff
43
+ });
44
+ }
45
+ }
46
+ if (currentTableMap.height !== prevTableMap.height) {
47
+ const diff = Math.abs(currentTableMap.height - prevTableMap.height);
48
+ if (currentTableMap.height > prevTableMap.height) {
49
+ return formatMessage(messages.rowsAreInserted, {
50
+ count: diff
51
+ });
52
+ }
53
+ if (currentTableMap.height < prevTableMap.height) {
54
+ return formatMessage(messages.rowsAreRemoved, {
55
+ count: diff
56
+ });
57
+ }
58
+ }
59
+ return '';
60
+ };
@@ -72,7 +72,9 @@ export var initiateKeyboardColumnResizing = function initiateKeyboardColumnResiz
72
72
  var selectionRect = isSelectionType(selection, 'cell') ? getSelectionRect(selection) : findCellRectClosestToPos(selection.$from);
73
73
  var cell = findCellClosestToPos(selection.$from);
74
74
  if (ariaNotify && getIntl) {
75
- ariaNotify(getIntl().formatMessage(messages.startedColumnResize));
75
+ ariaNotify(getIntl().formatMessage(messages.startedColumnResize), {
76
+ priority: 'important'
77
+ });
76
78
  }
77
79
  if (selectionRect && cell && view) {
78
80
  return updateResizeHandleAndStatePosition(selectionRect.top, selectionRect.right, cell.pos)(state, dispatch);
@@ -116,12 +118,16 @@ export var activateNextResizeArea = function activateNextResizeArea(_ref2) {
116
118
  if (direction === 1) {
117
119
  ariaNotify(getIntl().formatMessage(messages.focusedOtherResize, {
118
120
  direction: 'right'
119
- }));
121
+ }), {
122
+ priority: 'important'
123
+ });
120
124
  }
121
125
  if (direction === -1) {
122
126
  ariaNotify(getIntl().formatMessage(messages.focusedOtherResize, {
123
127
  direction: 'left'
124
- }));
128
+ }), {
129
+ priority: 'important'
130
+ });
125
131
  }
126
132
  }
127
133
  if ($nextCell) {
@@ -217,10 +223,14 @@ export var changeColumnWidthByStep = function changeColumnWidthByStep(_ref4) {
217
223
  }));
218
224
  if (newResizeState.cols.length === colIndex + 1) {
219
225
  if (newResizeState.overflow === true) {
220
- ariaNotify(getIntl().formatMessage(messages.columnResizeLast));
226
+ ariaNotify(getIntl().formatMessage(messages.columnResizeLast), {
227
+ priority: 'important'
228
+ });
221
229
  }
222
230
  if (newResizeState.overflow === false) {
223
- ariaNotify(getIntl().formatMessage(messages.columnResizeOverflow));
231
+ ariaNotify(getIntl().formatMessage(messages.columnResizeOverflow), {
232
+ priority: 'important'
233
+ });
224
234
  }
225
235
  }
226
236
  }
@@ -256,7 +266,9 @@ export var stopKeyboardColumnResizing = function stopKeyboardColumnResizing(_ref
256
266
  return customTr.setMeta('scrollIntoView', false);
257
267
  })(state, fakeDispatch);
258
268
  if (ariaNotify && getIntl) {
259
- ariaNotify(getIntl().formatMessage(messages.columnResizeStop));
269
+ ariaNotify(getIntl().formatMessage(messages.columnResizeStop), {
270
+ priority: 'important'
271
+ });
260
272
  }
261
273
  if (dispatch) {
262
274
  dispatch(customTr);
@@ -17,6 +17,7 @@ import React from 'react';
17
17
  import classnames from 'classnames';
18
18
  import memoizeOne from 'memoize-one';
19
19
  import rafSchedule from 'raf-schd';
20
+ import { injectIntl } from 'react-intl-next';
20
21
  import { ACTION_SUBJECT, EVENT_TYPE, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
21
22
  import { getParentNodeWidth, getTableContainerWidth } from '@atlaskit/editor-common/node-width';
22
23
  import { tableMarginSides } from '@atlaskit/editor-common/styles';
@@ -37,7 +38,7 @@ import { updateControls } from '../pm-plugins/table-resizing/utils/dom';
37
38
  import { TableCssClassName as ClassName, ShadowEvent } from '../types';
38
39
  import TableFloatingColumnControls from '../ui/TableFloatingColumnControls';
39
40
  import TableFloatingControls from '../ui/TableFloatingControls';
40
- import { containsHeaderRow, isTableNested, tablesHaveDifferentColumnWidths, tablesHaveDifferentNoOfColumns } from '../utils';
41
+ import { containsHeaderRow, getAssistiveMessage, isTableNested, tablesHaveDifferentColumnWidths, tablesHaveDifferentNoOfColumns, tablesHaveDifferentNoOfRows } from '../utils';
41
42
  import { ExternalDropTargets } from './ExternalDropTargets';
42
43
  import { OverflowShadowsObserver } from './OverflowShadowsObserver';
43
44
  import { TableContainer } from './TableContainer';
@@ -515,6 +516,15 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
515
516
  this.overflowShadowsObserver.observeShadowSentinels((_this$state$stickyHea = this.state.stickyHeader) === null || _this$state$stickyHea === void 0 ? void 0 : _this$state$stickyHea.sticky);
516
517
  }
517
518
  var currentTable = getNode();
519
+ var previousTable = this.node;
520
+ var isNoOfColumnsChanged = tablesHaveDifferentNoOfColumns(currentTable, previousTable);
521
+ var isNoOfRowsChanged = tablesHaveDifferentNoOfRows(currentTable, previousTable);
522
+ if (isNoOfColumnsChanged || isNoOfRowsChanged) {
523
+ var _this$props$pluginInj;
524
+ (_this$props$pluginInj = this.props.pluginInjectionApi) === null || _this$props$pluginInj === void 0 || (_this$props$pluginInj = _this$props$pluginInj.accessibilityUtils) === null || _this$props$pluginInj === void 0 || _this$props$pluginInj.actions.ariaNotify(getAssistiveMessage(previousTable, currentTable, this.props.intl), {
525
+ priority: 'important'
526
+ });
527
+ }
518
528
  if (currentTable.attrs.__autoSize) {
519
529
  // Wait for next tick to handle auto sizing, gives the browser time to do layout calc etc.
520
530
  this.handleAutoSizeDebounced();
@@ -524,8 +534,6 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
524
534
  else if (allowColumnResizing && this.table && !isMediaFullscreen) {
525
535
  // If col widths (e.g. via collab) or number of columns (e.g. delete a column) have changed,
526
536
  // re-draw colgroup.
527
- var previousTable = this.node;
528
- var isNoOfColumnsChanged = tablesHaveDifferentNoOfColumns(currentTable, previousTable);
529
537
  if (tablesHaveDifferentColumnWidths(currentTable, previousTable) || isNoOfColumnsChanged) {
530
538
  var _view = this.props.view;
531
539
  var shouldRecreateResizeCols = !(options !== null && options !== void 0 && options.isTableResizingEnabled) || !isResizing || isNoOfColumnsChanged && isResizing;
@@ -786,4 +794,4 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
786
794
  return TableComponent;
787
795
  }(React.Component);
788
796
  _defineProperty(TableComponent, "displayName", 'TableComponent');
789
- export default TableComponent;
797
+ export default injectIntl(TableComponent);
@@ -1,12 +1,12 @@
1
1
  export { getSelectedColumnIndexes, getSelectedRowIndexes, normalizeSelection, isSelectionUpdated } from './selection';
2
2
  export { findControlsHoverDecoration, createControlsHoverDecoration, createColumnControlsDecoration, createColumnSelectedDecoration, createCellHoverDecoration, updateDecorations, createResizeHandleDecoration, createColumnInsertLine, createColumnLineResize, createRowInsertLine } from './decoration';
3
- export { isIsolating, containsHeaderColumn, containsHeaderRow, checkIfHeaderColumnEnabled, checkIfHeaderRowEnabled, checkIfNumberColumnEnabled, getTableWidth, tablesHaveDifferentColumnWidths, tablesHaveDifferentNoOfColumns, isTableNested, anyChildCellMergedAcrossRow, supportedHeaderRow } from './nodes';
3
+ export { isIsolating, containsHeaderColumn, containsHeaderRow, checkIfHeaderColumnEnabled, checkIfHeaderRowEnabled, checkIfNumberColumnEnabled, getTableWidth, tablesHaveDifferentColumnWidths, tablesHaveDifferentNoOfColumns, tablesHaveDifferentNoOfRows, isTableNested, anyChildCellMergedAcrossRow, supportedHeaderRow } from './nodes';
4
4
  export { unwrapContentFromTable, removeTableFromFirstChild, removeTableFromLastChild, transformSliceToRemoveOpenTable, transformSliceToCorrectEmptyTableCells, transformSliceToFixHardBreakProblemOnCopyFromCell } from './paste';
5
5
  export { isCell, isCornerButton, isInsertRowButton, isColumnControlsDecorations, isTableControlsButton, isTableContainerOrWrapper, isRowControlsButton, isDragRowControlsButton, isDragColumnFloatingInsertDot, isDragRowFloatingInsertDot, isDragCornerButton, getColumnOrRowIndex, getMousePositionHorizontalRelativeByElement, getMousePositionVerticalRelativeByElement, isResizeHandleDecoration, hasResizeHandler, findNearestCellIndexToPoint } from './dom';
6
6
  export { convertHTMLCellIndexToColumnIndex, getColumnsWidths, isColumnDeleteButtonVisible, getColumnDeleteButtonParams, getColumnClassNames, getColumnIndexMappedToColumnIndexInFirstRow } from './column-controls';
7
7
  export { getRowHeights, isRowDeleteButtonVisible, getRowDeleteButtonParams, getRowsParams, getRowClassNames, copyPreviousRow } from './row-controls';
8
8
  export { getSelectedTableInfo, getSelectedCellInfo } from './analytics';
9
- export { getMergedCellsPositions } from './table';
9
+ export { getMergedCellsPositions, getAssistiveMessage } from './table';
10
10
  export { updatePluginStateDecorations } from './update-plugin-state-decorations';
11
11
  export { hasMergedCellsInColumn, hasMergedCellsInRow, hasMergedCellsInBetween, hasMergedCellsInSelection, findDuplicatePosition, checkEdgeHasMergedCells } from './merged-cells';
12
12
  export { createTableWithWidth } from './create';
@@ -68,6 +68,11 @@ export var tablesHaveDifferentNoOfColumns = function tablesHaveDifferentNoOfColu
68
68
  var currentMap = TableMap.get(currentTable);
69
69
  return prevMap.width !== currentMap.width;
70
70
  };
71
+ export var tablesHaveDifferentNoOfRows = function tablesHaveDifferentNoOfRows(currentTable, previousTable) {
72
+ var prevMap = TableMap.get(previousTable);
73
+ var currentMap = TableMap.get(currentTable);
74
+ return prevMap.height !== currentMap.height;
75
+ };
71
76
  function filterNearSelection(selection, findNode, predicate, defaultValue) {
72
77
  var found = findNode(selection);
73
78
  if (!found) {
@@ -1,4 +1,5 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ import { tableMessages as messages } from '@atlaskit/editor-common/messages';
2
3
  import { TableMap } from '@atlaskit/editor-tables/table-map';
3
4
  import { findTable } from '@atlaskit/editor-tables/utils';
4
5
  export var getMergedCellsPositions = function getMergedCellsPositions(tr) {
@@ -25,4 +26,36 @@ export var colsToRect = function colsToRect(cols, noOfRows) {
25
26
  top: 0,
26
27
  bottom: noOfRows
27
28
  };
29
+ };
30
+ export var getAssistiveMessage = function getAssistiveMessage(prevTableNode, currentTableNode, intl) {
31
+ var formatMessage = intl.formatMessage;
32
+ var prevTableMap = TableMap.get(prevTableNode);
33
+ var currentTableMap = TableMap.get(currentTableNode);
34
+ if (currentTableMap.width !== prevTableMap.width) {
35
+ var diff = Math.abs(currentTableMap.width - prevTableMap.width);
36
+ if (currentTableMap.width > prevTableMap.width) {
37
+ return formatMessage(messages.columnsAreInserted, {
38
+ count: diff
39
+ });
40
+ }
41
+ if (currentTableMap.width < prevTableMap.width) {
42
+ return formatMessage(messages.columnsAreRemoved, {
43
+ count: diff
44
+ });
45
+ }
46
+ }
47
+ if (currentTableMap.height !== prevTableMap.height) {
48
+ var _diff = Math.abs(currentTableMap.height - prevTableMap.height);
49
+ if (currentTableMap.height > prevTableMap.height) {
50
+ return formatMessage(messages.rowsAreInserted, {
51
+ count: _diff
52
+ });
53
+ }
54
+ if (currentTableMap.height < prevTableMap.height) {
55
+ return formatMessage(messages.rowsAreRemoved, {
56
+ count: _diff
57
+ });
58
+ }
59
+ }
60
+ return '';
28
61
  };
@@ -1,26 +1,27 @@
1
1
  import type { IntlShape } from 'react-intl-next/src/types';
2
2
  import type { Command, GetEditorContainerWidth } from '@atlaskit/editor-common/types';
3
+ import type { AriaLiveElementAttributes } from '@atlaskit/editor-plugin-accessibility-utils';
3
4
  import type { Transaction } from '@atlaskit/editor-prosemirror/state';
4
5
  import type { Direction } from '@atlaskit/editor-tables/types';
5
6
  export declare const initiateKeyboardColumnResizing: ({ ariaNotify, getIntl, }: {
6
- ariaNotify?: ((message: string) => void) | undefined;
7
+ ariaNotify?: ((message: string, ariaLiveElementAttributes?: AriaLiveElementAttributes) => void) | undefined;
7
8
  getIntl?: (() => IntlShape) | undefined;
8
9
  }) => Command;
9
10
  export declare const activateNextResizeArea: ({ direction, ariaNotify, getIntl, }: {
10
11
  direction: Direction;
11
- ariaNotify?: ((message: string) => void) | undefined;
12
+ ariaNotify?: ((message: string, ariaLiveElementAttributes?: AriaLiveElementAttributes) => void) | undefined;
12
13
  getIntl?: (() => IntlShape) | undefined;
13
14
  }) => Command;
14
15
  export declare const changeColumnWidthByStep: ({ stepSize, getEditorContainerWidth, isTableScalingEnabled, ariaNotify, getIntl, }: {
15
16
  stepSize: number;
16
17
  getEditorContainerWidth: GetEditorContainerWidth;
17
18
  isTableScalingEnabled: boolean;
18
- ariaNotify?: ((message: string) => void) | undefined;
19
+ ariaNotify?: ((message: string, ariaLiveElementAttributes?: AriaLiveElementAttributes) => void) | undefined;
19
20
  getIntl?: (() => IntlShape) | undefined;
20
21
  originalTr?: Transaction | undefined;
21
22
  }) => Command;
22
23
  export declare const stopKeyboardColumnResizing: ({ ariaNotify, getIntl, originalTr, }: {
23
- ariaNotify?: ((message: string) => void) | undefined;
24
+ ariaNotify?: ((message: string, ariaLiveElementAttributes?: AriaLiveElementAttributes) => void) | undefined;
24
25
  getIntl?: (() => IntlShape) | undefined;
25
26
  originalTr?: Transaction | undefined;
26
27
  }) => Command;