@atlaskit/editor-plugin-table 0.0.7 → 0.0.8

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 +6 -0
  2. package/dist/cjs/plugins/table/nodeviews/table.js +4 -2
  3. package/dist/cjs/plugins/table/toolbar.js +0 -1
  4. package/dist/cjs/plugins/table/ui/TableFloatingControls/CornerControls/index.js +23 -10
  5. package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/index.js +23 -10
  6. package/dist/cjs/plugins/table/ui/TableFloatingControls/index.js +4 -4
  7. package/dist/cjs/version.json +1 -1
  8. package/dist/es2019/plugins/table/nodeviews/table.js +4 -2
  9. package/dist/es2019/plugins/table/toolbar.js +1 -2
  10. package/dist/es2019/plugins/table/ui/TableFloatingControls/CornerControls/index.js +18 -3
  11. package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/index.js +18 -3
  12. package/dist/es2019/plugins/table/ui/TableFloatingControls/index.js +2 -2
  13. package/dist/es2019/version.json +1 -1
  14. package/dist/esm/plugins/table/nodeviews/table.js +4 -2
  15. package/dist/esm/plugins/table/toolbar.js +1 -2
  16. package/dist/esm/plugins/table/ui/TableFloatingControls/CornerControls/index.js +19 -9
  17. package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/index.js +19 -9
  18. package/dist/esm/plugins/table/ui/TableFloatingControls/index.js +2 -2
  19. package/dist/esm/version.json +1 -1
  20. package/dist/types/plugins/table/nodeviews/types.d.ts +1 -0
  21. package/dist/types/plugins/table/ui/TableFloatingControls/CornerControls/index.d.ts +5 -8
  22. package/dist/types/plugins/table/ui/TableFloatingControls/RowControls/index.d.ts +5 -5
  23. package/dist/types-ts4.0/plugins/table/nodeviews/types.d.ts +1 -0
  24. package/dist/types-ts4.0/plugins/table/ui/TableFloatingControls/CornerControls/index.d.ts +5 -8
  25. package/dist/types-ts4.0/plugins/table/ui/TableFloatingControls/RowControls/index.d.ts +5 -5
  26. package/package.json +7 -2
  27. package/src/__tests__/unit/hover-selection.ts +1 -1
  28. package/src/__tests__/unit/index-with-fake-timers.ts +1 -0
  29. package/src/__tests__/unit/ui/CornerControls.tsx +22 -22
  30. package/src/__tests__/unit/ui/FloatingDeleteButton.tsx +3 -3
  31. package/src/__tests__/unit/ui/FloatingInsertButton.tsx +15 -15
  32. package/src/__tests__/unit/ui/RowControls.tsx +1 -1
  33. package/src/__tests__/unit/ui/TableFloatingControls.tsx +2 -2
  34. package/src/plugins/table/__tests__/unit/commands/insert.ts +2 -2
  35. package/src/plugins/table/__tests__/unit/commands.ts +2 -2
  36. package/src/plugins/table/__tests__/unit/nodeviews/TableComponent.tsx +2 -2
  37. package/src/plugins/table/__tests__/unit/nodeviews/table.ts +1 -0
  38. package/src/plugins/table/nodeviews/table.tsx +7 -0
  39. package/src/plugins/table/nodeviews/types.ts +1 -0
  40. package/src/plugins/table/toolbar.ts +0 -1
  41. package/src/plugins/table/ui/FloatingContextualMenu/__tests__/ContextualMenu.tsx +1 -1
  42. package/src/plugins/table/ui/FloatingContextualMenu/__tests__/FloatingContextualMenu.tsx +1 -1
  43. package/src/plugins/table/ui/TableFloatingControls/CornerControls/index.tsx +19 -1
  44. package/src/plugins/table/ui/TableFloatingControls/RowControls/index.tsx +16 -1
  45. package/src/plugins/table/ui/TableFloatingControls/index.tsx +2 -2
@@ -1,5 +1,6 @@
1
- import { Component } from 'react';
1
+ import React from 'react';
2
2
  import { EditorView } from 'prosemirror-view';
3
+ import type { WrappedComponentProps } from 'react-intl-next';
3
4
  export interface Props {
4
5
  editorView: EditorView;
5
6
  tableRef: HTMLTableElement;
@@ -11,7 +12,6 @@ export interface Props {
11
12
  insertRowButtonIndex?: number;
12
13
  stickyTop?: number;
13
14
  }
14
- export default class RowControls extends Component<Props> {
15
- render(): JSX.Element | null;
16
- private clearHoverSelection;
17
- }
15
+ export declare const RowControls: React.FC<import("react-intl-next").WithIntlProps<Props & WrappedComponentProps<"intl">>> & {
16
+ WrappedComponent: React.ComponentType<Props & WrappedComponentProps<"intl">>;
17
+ };
@@ -20,4 +20,5 @@ export interface Props {
20
20
  tableRenderOptimization?: boolean;
21
21
  getEditorContainerWidth: GetEditorContainerWidth;
22
22
  getEditorFeatureFlags: GetEditorFeatureFlags;
23
+ hasIntlContext: boolean;
23
24
  }
@@ -1,4 +1,5 @@
1
- import { Component } from 'react';
1
+ import React from 'react';
2
+ import type { WrappedComponentProps } from 'react-intl-next';
2
3
  import { EditorView } from 'prosemirror-view';
3
4
  export interface Props {
4
5
  editorView: EditorView;
@@ -10,10 +11,6 @@ export interface Props {
10
11
  isHeaderRowEnabled?: boolean;
11
12
  stickyTop?: number;
12
13
  }
13
- export default class CornerControls extends Component<Props, any> {
14
- render(): JSX.Element | null;
15
- private isActive;
16
- private clearHoverSelection;
17
- private selectTable;
18
- private hoverTable;
19
- }
14
+ export declare const CornerControls: React.FC<import("react-intl-next").WithIntlProps<Props & WrappedComponentProps<"intl">>> & {
15
+ WrappedComponent: React.ComponentType<Props & WrappedComponentProps<"intl">>;
16
+ };
@@ -1,5 +1,6 @@
1
- import { Component } from 'react';
1
+ import React from 'react';
2
2
  import { EditorView } from 'prosemirror-view';
3
+ import type { WrappedComponentProps } from 'react-intl-next';
3
4
  export interface Props {
4
5
  editorView: EditorView;
5
6
  tableRef: HTMLTableElement;
@@ -11,7 +12,6 @@ export interface Props {
11
12
  insertRowButtonIndex?: number;
12
13
  stickyTop?: number;
13
14
  }
14
- export default class RowControls extends Component<Props> {
15
- render(): JSX.Element | null;
16
- private clearHoverSelection;
17
- }
15
+ export declare const RowControls: React.FC<import("react-intl-next").WithIntlProps<Props & WrappedComponentProps<"intl">>> & {
16
+ WrappedComponent: React.ComponentType<Props & WrappedComponentProps<"intl">>;
17
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -68,6 +68,7 @@
68
68
  "@atlaskit/visual-regression": "*",
69
69
  "@atlaskit/webdriver-runner": "*",
70
70
  "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
71
+ "@testing-library/react": "^12.1.5",
71
72
  "@types/prosemirror-history": "^1.0.1",
72
73
  "enzyme": "^3.10.0",
73
74
  "prosemirror-history": "^1.1.3",
@@ -81,7 +82,11 @@
81
82
  "prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.1",
82
83
  "techstack": {
83
84
  "@repo/internal": {
84
- "theming": "tokens"
85
+ "theming": "tokens",
86
+ "deprecation": "no-deprecated-imports",
87
+ "styling": [
88
+ "emotion"
89
+ ]
85
90
  }
86
91
  }
87
92
  }
@@ -87,7 +87,7 @@ describe('table hover selection plugin', () => {
87
87
  selectColumns([column])(editorView.state, editorView.dispatch);
88
88
  });
89
89
 
90
- test('should add decoration', () => {
90
+ it('should add decoration', () => {
91
91
  const cells = getCellsInColumn(column)(editorView.state.selection)!;
92
92
 
93
93
  const decor = getTableDecorations(
@@ -82,6 +82,7 @@ describe.skip('TableView', () => {
82
82
  getPos: () => 1,
83
83
  getEditorContainerWidth,
84
84
  getEditorFeatureFlags: fakeGetEditorFeatureFlags,
85
+ hasIntlContext: true,
85
86
  }).init();
86
87
 
87
88
  // we expect to have a contentDOM after instanciating the NodeView so that
@@ -1,7 +1,8 @@
1
1
  import React from 'react';
2
+ import { fireEvent, render, screen } from '@testing-library/react';
3
+ import { IntlProvider } from 'react-intl-next';
2
4
  import { isTableSelected } from '@atlaskit/editor-tables/utils';
3
5
  import { createEditorFactory } from '@atlaskit/editor-test-helpers/create-editor';
4
- import { mountWithIntl } from '@atlaskit/editor-test-helpers/enzyme';
5
6
  import {
6
7
  doc,
7
8
  table,
@@ -10,17 +11,12 @@ import {
10
11
  DocBuilder,
11
12
  } from '@atlaskit/editor-test-helpers/doc-builder';
12
13
 
13
- import {
14
- TablePluginState,
15
- TableCssClassName as ClassName,
16
- } from '../../../plugins/table/types';
17
- import CornerControls from '../../../plugins/table/ui/TableFloatingControls/CornerControls';
14
+ import { TablePluginState } from '../../../plugins/table/types';
15
+ import { CornerControls } from '../../../plugins/table/ui/TableFloatingControls/CornerControls';
18
16
  import { getPluginState } from '../../../plugins/table/pm-plugins/plugin-factory';
19
17
  import { pluginKey } from '../../../plugins/table/pm-plugins/plugin-key';
20
18
  import tablePlugin from '../../../plugins/table-plugin';
21
19
 
22
- const CornerButton = `.${ClassName.CONTROLS_CORNER_BUTTON}`;
23
-
24
20
  describe('CornerControls', () => {
25
21
  const createEditor = createEditorFactory<TablePluginState>();
26
22
 
@@ -40,17 +36,19 @@ describe('CornerControls', () => {
40
36
  doc(table()(tr(thEmpty, thEmpty, thEmpty))),
41
37
  );
42
38
 
43
- const controls = mountWithIntl(
44
- <CornerControls
45
- tableRef={document.querySelector('table')!}
46
- editorView={editorView}
47
- />,
39
+ const ref = editorView.dom.querySelector('table') || undefined;
40
+
41
+ render(
42
+ <IntlProvider locale="en">
43
+ <CornerControls tableRef={ref} editorView={editorView} />
44
+ </IntlProvider>,
48
45
  );
49
46
 
50
- controls.find(CornerButton).simulate('click');
47
+ const cornerControl = screen.getByLabelText('Highlight table');
48
+
49
+ fireEvent.click(cornerControl);
51
50
 
52
51
  expect(isTableSelected(editorView.state.selection)).toBe(true);
53
- controls.unmount();
54
52
  });
55
53
  });
56
54
 
@@ -62,19 +60,21 @@ describe('CornerControls', () => {
62
60
  ),
63
61
  );
64
62
 
65
- const controls = mountWithIntl(
66
- <CornerControls
67
- tableRef={document.querySelector('table')!}
68
- editorView={editorView}
69
- />,
63
+ const ref = editorView.dom.querySelector('table') || undefined;
64
+
65
+ render(
66
+ <IntlProvider locale="en">
67
+ <CornerControls tableRef={ref} editorView={editorView} />
68
+ </IntlProvider>,
70
69
  );
71
70
 
72
- controls.find(CornerButton).simulate('mouseover');
71
+ const cornerControl = screen.getByLabelText('Highlight table');
72
+
73
+ fireEvent.mouseOver(cornerControl);
73
74
 
74
75
  const { hoveredColumns, hoveredRows } = getPluginState(editorView.state);
75
76
  expect(hoveredColumns).toEqual([0, 1, 2]);
76
77
  expect(hoveredRows).toEqual([0, 1]);
77
- controls.unmount();
78
78
  });
79
79
  });
80
80
  });
@@ -69,11 +69,11 @@ describe('Floating Delete Button', () => {
69
69
  }
70
70
  });
71
71
 
72
- test('should not render a delete button with no selection', () => {
72
+ it('should not render a delete button with no selection', () => {
73
73
  expect(wrapper.find(DeleteButton).length).toBe(0);
74
74
  });
75
75
 
76
- test('should not render a delete button with whole table selected', () => {
76
+ it('should not render a delete button with whole table selected', () => {
77
77
  // select the whole table
78
78
  editorView.dispatch(selectTable(editorView.state.tr));
79
79
 
@@ -112,7 +112,7 @@ describe('Floating Delete Button', () => {
112
112
  },
113
113
  );
114
114
 
115
- test('should render a single delete button over multiple column selections', () => {
115
+ it('should render a single delete button over multiple column selections', () => {
116
116
  selectColumns([0, 1])(editorView.state, editorView.dispatch);
117
117
 
118
118
  // We need to force renderer
@@ -94,8 +94,8 @@ describe('Floating Insert Button when findDomRefAtPos fails', () => {
94
94
  jest.restoreAllMocks();
95
95
  });
96
96
 
97
- test('sends error analytics event after attempting to render for second column', () => {
98
- // We need to set the props here, as by default insertColumnButtonIndex in undefined (in
97
+ it('sends error analytics event after attempting to render for second column', () => {
98
+ // We need to set the props here, as by default insertColumnButtonIndex is undefined (in
99
99
  // mountWithIntl()) and rendering halts when it's undefined
100
100
  wrapper.setProps({
101
101
  insertColumnButtonIndex: 1,
@@ -115,11 +115,11 @@ describe('Floating Insert Button when findDomRefAtPos fails', () => {
115
115
  });
116
116
  });
117
117
 
118
- test('should not render insert button with index', () => {
118
+ it('should not render insert button by default', () => {
119
119
  expect(wrapper.find(InsertButton).length).toBe(0);
120
120
  });
121
121
 
122
- test("shouldn't render insert button for second column", () => {
122
+ it("shouldn't render insert button for second column", () => {
123
123
  wrapper.setProps({
124
124
  insertColumnButtonIndex: 1,
125
125
  });
@@ -127,7 +127,7 @@ describe('Floating Insert Button when findDomRefAtPos fails', () => {
127
127
  expect(wrapper.find(InsertButton).length).toBe(0);
128
128
  });
129
129
 
130
- test("shouldn't render insert button for second row", () => {
130
+ it("shouldn't render insert button for second row", () => {
131
131
  wrapper.setProps({
132
132
  insertRowButtonIndex: 1,
133
133
  });
@@ -181,21 +181,21 @@ describe('Floating Insert Button', () => {
181
181
  wrapper.unmount();
182
182
  });
183
183
 
184
- test('should not render insert button with index', () => {
184
+ it('should not render insert button by default', () => {
185
185
  expect(wrapper.find(InsertButton).length).toBe(0);
186
186
  });
187
187
 
188
- test('should render insert button for second column', () => {
188
+ it('should render insert button for second column', () => {
189
189
  wrapper.setProps({ insertColumnButtonIndex: 1 });
190
190
  expect(wrapper.find(InsertButton).length).toBe(1);
191
191
  });
192
192
 
193
- test('should render insert button for second row', () => {
193
+ it('should render insert button for second row', () => {
194
194
  wrapper.setProps({ insertRowButtonIndex: 1 });
195
195
  expect(wrapper.find(InsertButton).length).toBe(1);
196
196
  });
197
197
 
198
- test('should no render insert button for first row when row header is enabled', () => {
198
+ it('should not render insert button for first row when row header is enabled', () => {
199
199
  wrapper.setProps({
200
200
  insertRowButtonIndex: 0,
201
201
  isHeaderRowEnabled: true,
@@ -204,7 +204,7 @@ describe('Floating Insert Button', () => {
204
204
  expect(wrapper.find(InsertButton).length).toBe(0);
205
205
  });
206
206
 
207
- test('should render insert button for first row when row header is disabled', () => {
207
+ it('should render insert button for first row when row header is disabled', () => {
208
208
  wrapper.setProps({
209
209
  insertRowButtonIndex: 0,
210
210
  isHeaderRowEnabled: false,
@@ -213,7 +213,7 @@ describe('Floating Insert Button', () => {
213
213
  expect(wrapper.find(InsertButton).length).toBe(1);
214
214
  });
215
215
 
216
- test('should no render insert button for first col when column header is enabled', () => {
216
+ it('should not render insert button for first col when column header is enabled', () => {
217
217
  wrapper.setProps({
218
218
  insertColumnButtonIndex: 0,
219
219
  isHeaderColumnEnabled: true,
@@ -222,7 +222,7 @@ describe('Floating Insert Button', () => {
222
222
  expect(wrapper.find(InsertButton).length).toBe(0);
223
223
  });
224
224
 
225
- test('should render insert button for first col when column header is disabled', () => {
225
+ it('should render insert button for first col when column header is disabled', () => {
226
226
  wrapper.setProps({
227
227
  insertColumnButtonIndex: 0,
228
228
  isHeaderColumnEnabled: false,
@@ -231,7 +231,7 @@ describe('Floating Insert Button', () => {
231
231
  expect(wrapper.find(InsertButton).length).toBe(1);
232
232
  });
233
233
 
234
- test('should render insert button when a single cell is selected', () => {
234
+ it('should render insert button when a single cell is selected', () => {
235
235
  selectCell(1, 1)(editorView.state, editorView.dispatch);
236
236
 
237
237
  wrapper.setProps({
@@ -242,7 +242,7 @@ describe('Floating Insert Button', () => {
242
242
  expect(wrapper.find(InsertButton).length).toBe(1);
243
243
  });
244
244
 
245
- test('should no render insert button when a whole column is selected', () => {
245
+ it('should not render insert button when a whole column is selected', () => {
246
246
  selectColumns([1])(editorView.state, editorView.dispatch);
247
247
 
248
248
  wrapper.setProps({
@@ -253,7 +253,7 @@ describe('Floating Insert Button', () => {
253
253
  expect(wrapper.find(InsertButton).length).toBe(0);
254
254
  });
255
255
 
256
- test('should no render insert button when a whole row is selected', () => {
256
+ it('should no render insert button when a whole row is selected', () => {
257
257
  selectRows([1])(editorView.state, editorView.dispatch);
258
258
 
259
259
  wrapper.setProps({
@@ -22,7 +22,7 @@ import {
22
22
  TablePluginState,
23
23
  } from '../../../plugins/table/types';
24
24
  import TableFloatingControls from '../../../plugins/table/ui/TableFloatingControls';
25
- import RowControls from '../../../plugins/table/ui/TableFloatingControls/RowControls';
25
+ import { RowControls } from '../../../plugins/table/ui/TableFloatingControls/RowControls';
26
26
  import { pluginKey } from '../../../plugins/table/pm-plugins/plugin-key';
27
27
  import { ReactWrapper } from 'enzyme';
28
28
  import tablePlugin from '../../../plugins/table-plugin';
@@ -19,8 +19,8 @@ import {
19
19
  import { TablePluginState } from '../../../plugins/table/types';
20
20
  import { hoverTable } from '../../../plugins/table/commands';
21
21
  import TableFloatingControls from '../../../plugins/table/ui/TableFloatingControls';
22
- import CornerControls from '../../../plugins/table/ui/TableFloatingControls/CornerControls';
23
- import RowControls from '../../../plugins/table/ui/TableFloatingControls/RowControls';
22
+ import { CornerControls } from '../../../plugins/table/ui/TableFloatingControls/CornerControls';
23
+ import { RowControls } from '../../../plugins/table/ui/TableFloatingControls/RowControls';
24
24
  import { pluginKey } from '../../../plugins/table/pm-plugins/plugin-key';
25
25
  import { getDecorations } from '../../../plugins/table/pm-plugins/decorations/plugin';
26
26
  import tablePlugin from '../../../plugins/table-plugin';
@@ -53,7 +53,7 @@ describe('table plugin: insert', () => {
53
53
  pluginKey,
54
54
  });
55
55
 
56
- test('does scale cells in tables which are not overflowing', () => {
56
+ it('does scale cells in tables which are not overflowing', () => {
57
57
  const { editorView } = editor(
58
58
  doc(
59
59
  table({ localId: TABLE_LOCAL_ID })(
@@ -84,7 +84,7 @@ describe('table plugin: insert', () => {
84
84
  );
85
85
  });
86
86
 
87
- test('does not scale cells in tables which are overflowing', () => {
87
+ it('does not scale cells in tables which are overflowing', () => {
88
88
  const { editorView } = editor(
89
89
  doc(
90
90
  table({ localId: TABLE_LOCAL_ID })(
@@ -810,7 +810,7 @@ describe('table plugin: actions', () => {
810
810
  * | th | th | th |
811
811
  * | th | td | td |
812
812
  */
813
- test('should keep right row header and cells after split', () => {
813
+ it('should keep right row header and cells after split', () => {
814
814
  const { editorView } = editor(
815
815
  doc(
816
816
  table()(
@@ -833,7 +833,7 @@ describe('table plugin: actions', () => {
833
833
  );
834
834
  });
835
835
 
836
- test('should split cell with media selected', () => {
836
+ it('should split cell with media selected', () => {
837
837
  const { editorView } = editor(
838
838
  doc(
839
839
  table()(
@@ -259,7 +259,7 @@ describe('table -> nodeviews -> TableComponent.tsx', () => {
259
259
  return { wrapper, view };
260
260
  }
261
261
 
262
- describe('with optimisation on', () => {
262
+ describe('with optimization on', () => {
263
263
  let wrapper: ReactWrapper;
264
264
  beforeEach(() => {
265
265
  wrapper = setupTable(true).wrapper;
@@ -306,7 +306,7 @@ describe('table -> nodeviews -> TableComponent.tsx', () => {
306
306
  });
307
307
  });
308
308
 
309
- describe('with optimisation off', () => {
309
+ describe('with optimization off', () => {
310
310
  let wrapper: ReactWrapper;
311
311
  beforeEach(() => {
312
312
  wrapper = setupTable(false).wrapper;
@@ -73,6 +73,7 @@ describe('table -> nodeviews -> table.tsx', () => {
73
73
  tableRenderOptimization: true,
74
74
  getEditorContainerWidth: () => ({ width: 500 }),
75
75
  getEditorFeatureFlags: () => ({}),
76
+ hasIntlContext: true,
76
77
  }).init();
77
78
 
78
79
  renderSpy = jest.spyOn(tableNodeView, 'render');
@@ -72,6 +72,10 @@ export default class TableView extends ReactNodeView<Props> {
72
72
  props.portalProviderAPI,
73
73
  props.eventDispatcher,
74
74
  props,
75
+ undefined,
76
+ undefined,
77
+ undefined,
78
+ props.hasIntlContext,
75
79
  );
76
80
  this.getPos = props.getPos;
77
81
  this.tableRenderOptimization = props.tableRenderOptimization;
@@ -233,6 +237,8 @@ export const createTableView = (
233
237
  const { pluginConfig } = getPluginState(view.state);
234
238
  const { allowColumnResizing } = getPluginConfig(pluginConfig);
235
239
  const { tableRenderOptimization } = getEditorFeatureFlags();
240
+ const hasIntlContext = true;
241
+
236
242
  return new TableView({
237
243
  node,
238
244
  view,
@@ -244,5 +250,6 @@ export const createTableView = (
244
250
  tableRenderOptimization,
245
251
  getEditorContainerWidth,
246
252
  getEditorFeatureFlags,
253
+ hasIntlContext,
247
254
  }).init();
248
255
  };
@@ -26,4 +26,5 @@ export interface Props {
26
26
  tableRenderOptimization?: boolean;
27
27
  getEditorContainerWidth: GetEditorContainerWidth;
28
28
  getEditorFeatureFlags: GetEditorFeatureFlags;
29
+ hasIntlContext: boolean;
29
30
  }
@@ -57,7 +57,6 @@ import { findParentDomRefOfType } from 'prosemirror-utils';
57
57
  import { EditorView } from 'prosemirror-view';
58
58
  import { closestElement } from '@atlaskit/editor-common/utils';
59
59
 
60
- // TODO: ED-14403 investigate why these translations don't work
61
60
  export const messages = defineMessages({
62
61
  tableOptions: {
63
62
  id: 'fabric.editor.tableOptions',
@@ -37,7 +37,7 @@ it.skip('TODO: restore unit', () => {});
37
37
  // }));
38
38
  // });
39
39
 
40
- // test('should render contextual menu when no tableCellPosition is passed but exist on editor state ', () => {
40
+ // it('should render contextual menu when no tableCellPosition is passed but exist on editor state ', () => {
41
41
  // const intl = createIntl({ locale: 'en' });
42
42
  // const wrapper = shallow(
43
43
  // <ContextualMenu
@@ -34,7 +34,7 @@ it.skip('TODO: restore unit', () => {});
34
34
  // }));
35
35
  // });
36
36
 
37
- // test('should render floating contextual menu when no tableCellPosition is passed but exist on editor state ', () => {
37
+ // it('should render floating contextual menu when no tableCellPosition is passed but exist on editor state ', () => {
38
38
  // const wrapper = shallow(
39
39
  // <FloatingContextualMenu
40
40
  // editorView={editorView}
@@ -1,4 +1,6 @@
1
1
  import React, { Component } from 'react';
2
+ import type { WrappedComponentProps } from 'react-intl-next';
3
+ import { defineMessages, injectIntl } from 'react-intl-next';
2
4
 
3
5
  import classnames from 'classnames';
4
6
  import { TableMap } from '@atlaskit/editor-tables/table-map';
@@ -12,6 +14,15 @@ import { EditorView } from 'prosemirror-view';
12
14
  import { clearHoverSelection, hoverTable } from '../../../commands';
13
15
  import { TableCssClassName as ClassName } from '../../../types';
14
16
 
17
+ const messages = defineMessages({
18
+ cornerControl: {
19
+ id: 'fabric.editor.cornerControl',
20
+ defaultMessage: 'Highlight table',
21
+ description:
22
+ 'A button on the upper left corner of the table that shows up when the table is in focus. Clicking on it will select the entire table.',
23
+ },
24
+ });
25
+
15
26
  export interface Props {
16
27
  editorView: EditorView;
17
28
  tableRef?: HTMLTableElement;
@@ -23,13 +34,17 @@ export interface Props {
23
34
  stickyTop?: number;
24
35
  }
25
36
 
26
- export default class CornerControls extends Component<Props, any> {
37
+ class CornerControlComponent extends Component<
38
+ Props & WrappedComponentProps,
39
+ any
40
+ > {
27
41
  render() {
28
42
  const {
29
43
  isInDanger,
30
44
  tableRef,
31
45
  isHeaderColumnEnabled,
32
46
  isHeaderRowEnabled,
47
+ intl: { formatMessage },
33
48
  } = this.props;
34
49
  if (!tableRef) {
35
50
  return null;
@@ -50,6 +65,7 @@ export default class CornerControls extends Component<Props, any> {
50
65
  }}
51
66
  >
52
67
  <button
68
+ aria-label={formatMessage(messages.cornerControl)}
53
69
  type="button"
54
70
  className={classnames(ClassName.CONTROLS_CORNER_BUTTON, {
55
71
  danger: isActive && isInDanger,
@@ -103,3 +119,5 @@ export default class CornerControls extends Component<Props, any> {
103
119
  hoverTable()(state, dispatch);
104
120
  };
105
121
  }
122
+
123
+ export const CornerControls = injectIntl(CornerControlComponent);
@@ -1,6 +1,8 @@
1
1
  import React, { Component } from 'react';
2
2
 
3
3
  import { EditorView } from 'prosemirror-view';
4
+ import type { WrappedComponentProps } from 'react-intl-next';
5
+ import { defineMessages, injectIntl } from 'react-intl-next';
4
6
 
5
7
  import { clearHoverSelection } from '../../../commands';
6
8
  import { TableCssClassName as ClassName } from '../../../types';
@@ -12,6 +14,15 @@ import {
12
14
  } from '../../../utils';
13
15
  import { tableControlsSpacing, tableToolbarSize } from '../../consts';
14
16
 
17
+ const messages = defineMessages({
18
+ rowControl: {
19
+ id: 'fabric.editor.rowControl',
20
+ defaultMessage: 'Highlight row',
21
+ description:
22
+ 'A button on the left of each row that shows up when the table is in focus. Clicking on it will select the entire row.',
23
+ },
24
+ });
25
+
15
26
  export interface Props {
16
27
  editorView: EditorView;
17
28
  tableRef: HTMLTableElement;
@@ -24,7 +35,7 @@ export interface Props {
24
35
  stickyTop?: number;
25
36
  }
26
37
 
27
- export default class RowControls extends Component<Props> {
38
+ class RowControlsComponent extends Component<Props & WrappedComponentProps> {
28
39
  render() {
29
40
  const {
30
41
  editorView,
@@ -32,6 +43,7 @@ export default class RowControls extends Component<Props> {
32
43
  hoveredRows,
33
44
  isInDanger,
34
45
  isResizing,
46
+ intl: { formatMessage },
35
47
  } = this.props;
36
48
  if (!tableRef) {
37
49
  return null;
@@ -89,6 +101,7 @@ export default class RowControls extends Component<Props> {
89
101
  }}
90
102
  >
91
103
  <button
104
+ aria-label={formatMessage(messages.rowControl)}
92
105
  type="button"
93
106
  className={`${ClassName.ROW_CONTROLS_BUTTON}
94
107
  ${ClassName.CONTROLS_BUTTON}
@@ -117,3 +130,5 @@ export default class RowControls extends Component<Props> {
117
130
  clearHoverSelection()(state, dispatch);
118
131
  };
119
132
  }
133
+
134
+ export const RowControls = injectIntl(RowControlsComponent);
@@ -11,9 +11,9 @@ import { RowStickyState } from '../../pm-plugins/sticky-headers';
11
11
 
12
12
  import { isSelectionUpdated } from '../../utils';
13
13
 
14
- import CornerControls from './CornerControls';
14
+ import { CornerControls } from './CornerControls';
15
15
  import NumberColumn from './NumberColumn';
16
- import RowControls from './RowControls';
16
+ import { RowControls } from './RowControls';
17
17
  import type { GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
18
18
 
19
19
  export interface Props {