@atlaskit/editor-plugin-table 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/cjs/plugins/table/index.js +2 -1
  3. package/dist/cjs/plugins/table/nodeviews/TableComponent.js +1 -2
  4. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +32 -17
  5. package/dist/cjs/plugins/table/pm-plugins/table-resizing/event-handlers.js +1 -5
  6. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/misc.js +3 -38
  7. package/dist/cjs/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +16 -3
  8. package/dist/cjs/plugins/table/ui/FloatingContextualMenu/index.js +6 -3
  9. package/dist/cjs/plugins/table/ui/common-styles.js +1 -1
  10. package/dist/cjs/types/i18n.js +5 -0
  11. package/dist/cjs/version.json +1 -1
  12. package/dist/es2019/plugins/table/index.js +2 -1
  13. package/dist/es2019/plugins/table/nodeviews/TableComponent.js +1 -2
  14. package/dist/es2019/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +32 -17
  15. package/dist/es2019/plugins/table/pm-plugins/table-resizing/event-handlers.js +1 -5
  16. package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/misc.js +1 -37
  17. package/dist/es2019/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +18 -4
  18. package/dist/es2019/plugins/table/ui/FloatingContextualMenu/index.js +6 -3
  19. package/dist/es2019/plugins/table/ui/common-styles.js +1 -0
  20. package/dist/es2019/types/i18n.js +1 -0
  21. package/dist/es2019/version.json +1 -1
  22. package/dist/esm/plugins/table/index.js +2 -1
  23. package/dist/esm/plugins/table/nodeviews/TableComponent.js +1 -2
  24. package/dist/esm/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +32 -17
  25. package/dist/esm/plugins/table/pm-plugins/table-resizing/event-handlers.js +1 -5
  26. package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/misc.js +1 -35
  27. package/dist/esm/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +17 -4
  28. package/dist/esm/plugins/table/ui/FloatingContextualMenu/index.js +6 -3
  29. package/dist/esm/plugins/table/ui/common-styles.js +1 -1
  30. package/dist/esm/types/i18n.js +1 -0
  31. package/dist/esm/version.json +1 -1
  32. package/dist/types/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.d.ts +2 -2
  33. package/dist/types/plugins/table/pm-plugins/table-resizing/utils/misc.d.ts +1 -2
  34. package/dist/types/plugins/table/ui/FloatingContextualMenu/ContextualMenu.d.ts +2 -1
  35. package/dist/types/plugins/table/ui/FloatingContextualMenu/index.d.ts +3 -2
  36. package/dist/types/types/i18n.d.ts +5 -0
  37. package/package.json +7 -7
  38. package/src/__tests__/integration/horizontal-scroll.ts +4 -9
  39. package/src/__tests__/integration/sticky-header.ts +61 -1
  40. package/src/__tests__/unit/commands/insert.ts +8 -8
  41. package/src/__tests__/unit/nodeviews/cell.ts +14 -0
  42. package/src/__tests__/unit/pm-plugins/sticky-headers/tableRow.tsx +2 -2
  43. package/src/__tests__/unit/ui/ContextualMenu.tsx +2 -0
  44. package/src/__tests__/unit/ui/FloatingContextualMenu.tsx +1 -0
  45. package/src/plugins/table/index.tsx +4 -0
  46. package/src/plugins/table/nodeviews/TableComponent.tsx +1 -2
  47. package/src/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.ts +40 -23
  48. package/src/plugins/table/pm-plugins/table-resizing/event-handlers.ts +1 -9
  49. package/src/plugins/table/pm-plugins/table-resizing/utils/misc.ts +1 -57
  50. package/src/plugins/table/ui/FloatingContextualMenu/ContextualMenu.tsx +21 -2
  51. package/src/plugins/table/ui/FloatingContextualMenu/index.tsx +8 -1
  52. package/src/plugins/table/ui/common-styles.ts +1 -0
  53. package/src/types/i18n.ts +5 -0
@@ -0,0 +1,5 @@
1
+ export interface MessageDescriptor {
2
+ id: string;
3
+ description: string;
4
+ defaultMessage: string;
5
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -19,11 +19,11 @@
19
19
  },
20
20
  "dependencies": {
21
21
  "@atlaskit/adf-schema": "^25.3.0",
22
- "@atlaskit/editor-common": "^72.5.0",
22
+ "@atlaskit/editor-common": "^72.6.0",
23
23
  "@atlaskit/editor-shared-styles": "^2.3.0",
24
24
  "@atlaskit/editor-tables": "^2.2.0",
25
25
  "@atlaskit/icon": "^21.11.0",
26
- "@atlaskit/theme": "^12.1.0",
26
+ "@atlaskit/theme": "^12.3.0",
27
27
  "@atlaskit/tokens": "^1.2.0",
28
28
  "@atlaskit/tooltip": "^17.7.0",
29
29
  "@babel/runtime": "^7.0.0",
@@ -50,14 +50,14 @@
50
50
  },
51
51
  "devDependencies": {
52
52
  "@atlaskit/analytics-next": "^9.0.0",
53
- "@atlaskit/button": "^16.5.0",
54
- "@atlaskit/editor-core": "^180.1.0",
55
- "@atlaskit/editor-test-helpers": "^18.0.0",
53
+ "@atlaskit/button": "^16.6.0",
54
+ "@atlaskit/editor-core": "^181.0.0",
55
+ "@atlaskit/editor-test-helpers": "^18.1.0",
56
56
  "@atlaskit/link-provider": "^1.5.0",
57
57
  "@atlaskit/logo": "^13.11.0",
58
58
  "@atlaskit/media-integration-test-helpers": "^2.6.0",
59
59
  "@atlaskit/synchrony-test-helpers": "^2.3.0",
60
- "@atlaskit/util-data-test": "^17.6.0",
60
+ "@atlaskit/util-data-test": "^17.7.0",
61
61
  "@atlaskit/visual-regression": "*",
62
62
  "@atlaskit/webdriver-runner": "*",
63
63
  "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
@@ -55,10 +55,9 @@ const assertTableDoesScroll = async (page: WebdriverPage) => {
55
55
  expect(tableScrollWidth).toBeGreaterThan(tableOffsetWidth);
56
56
  };
57
57
 
58
- // insertColumn helper doesn't work in Safari
59
58
  BrowserTestCase(
60
59
  'Table: Does not scroll when column is resized and a new column is inserted',
61
- { skip: ['safari'] },
60
+ { skip: [] },
62
61
  async (client: any, testName: string) => {
63
62
  for (const screenWidth of screenWidths) {
64
63
  const page = await goToEditorTestingWDExample(
@@ -84,7 +83,6 @@ BrowserTestCase(
84
83
  },
85
84
  );
86
85
 
87
- // insertColumn helper doesn't work in Safari
88
86
  BrowserTestCase(
89
87
  'Table: Does not scroll when column is resized and breakout button is clicked 3x',
90
88
  { skip: ['safari'] },
@@ -281,10 +279,9 @@ BrowserTestCase(
281
279
  },
282
280
  );
283
281
 
284
- // insertColumn helper doesn't work in Safari
285
282
  BrowserTestCase(
286
283
  'Table: Scrolls when there are more columns added than can fit the current width',
287
- { skip: ['safari'] },
284
+ { skip: [] },
288
285
  async (client: any, testName: string) => {
289
286
  for (const screenWidth of screenWidths) {
290
287
  const page = await goToEditorTestingWDExample(
@@ -315,10 +312,9 @@ BrowserTestCase(
315
312
  },
316
313
  );
317
314
 
318
- // insertColumn helper doesn't work in Safari
319
315
  BrowserTestCase(
320
316
  'Table: Does not scroll when nested in Bodied Macro, column is resized and breakout button is clicked',
321
- { skip: ['safari'] },
317
+ { skip: [] },
322
318
  async (client: any, testName: string) => {
323
319
  for (const screenWidth of screenWidths) {
324
320
  const page = await goToEditorTestingWDExample(
@@ -451,10 +447,9 @@ BrowserTestCase(
451
447
  },
452
448
  );
453
449
 
454
- // insertColumn helper doesn't work in Safari
455
450
  BrowserTestCase(
456
451
  'Table: Does not scroll when nested in full-width layout, columns is resized and new column is inserted',
457
- { skip: ['safari'] },
452
+ { skip: [] },
458
453
  async (client: any, testName: string) => {
459
454
  for (const screenWidth of screenWidths) {
460
455
  const page = await goToEditorTestingWDExample(
@@ -3,6 +3,7 @@ import { BrowserTestCase } from '@atlaskit/webdriver-runner/runner';
3
3
  import {
4
4
  fullpage,
5
5
  tableSelectors,
6
+ toggleBreakout,
6
7
  } from '@atlaskit/editor-test-helpers/integration/helpers';
7
8
  import {
8
9
  goToEditorTestingWDExample,
@@ -22,6 +23,15 @@ const scrollTo = async (page: WebdriverPage, height: number) => {
22
23
  );
23
24
  };
24
25
 
26
+ // const resizeScrollParent = async (page: WebdriverPage) => {
27
+ // const editorScrollParentSelector = '.ak-editor-fp-content-area';
28
+ // await page.execute((editorScrollParentSelector: string) => {
29
+ // const editor = document.querySelector(editorScrollParentSelector);
30
+ // console.log('editort', editor);
31
+ // editor && editor.setAttribute('width', '1000px');
32
+ // }, editorScrollParentSelector);
33
+ // };
34
+
25
35
  const insertColumn = async (page: any, cell: 'first' | 'last') => {
26
36
  const columnControl = tableSelectors.nthColumnControl(1);
27
37
  const insertButton = tableSelectors.insertButton;
@@ -41,9 +51,12 @@ const insertColumn = async (page: any, cell: 'first' | 'last') => {
41
51
  await page.click(insertButton);
42
52
  };
43
53
 
54
+ // FIXME: This test was automatically skipped due to failure on 01/04/2023: https://product-fabric.atlassian.net/browse/ED-17364
44
55
  BrowserTestCase(
45
56
  'Sticky header should correctly toggle on and off',
46
- { skip: [] },
57
+ {
58
+ skip: ['*'],
59
+ },
47
60
  async (client: any, testName: string) => {
48
61
  const page = await goToEditorTestingWDExample(
49
62
  client,
@@ -158,3 +171,50 @@ BrowserTestCase(
158
171
  expect(!numberedColStyle.includes('top')).toBeTruthy();
159
172
  },
160
173
  );
174
+
175
+ BrowserTestCase(
176
+ 'Sticky header should resize when the width of parent scroll container changes',
177
+ {},
178
+ async (client: any, testName: string) => {
179
+ const page = await goToEditorTestingWDExample(
180
+ client,
181
+ 'editor-plugin-table',
182
+ );
183
+
184
+ await mountEditor(page, {
185
+ appearance: fullpage.appearance,
186
+ defaultValue: JSON.stringify(stickyTable),
187
+ allowTables: {
188
+ advanced: true,
189
+ stickyHeaders: true,
190
+ },
191
+ featureFlags: {
192
+ stickyHeadersOptimization: true,
193
+ },
194
+ });
195
+
196
+ await page.waitForSelector('table');
197
+
198
+ await toggleBreakout(page, 2);
199
+
200
+ await scrollTo(page, window.innerHeight * 100);
201
+
202
+ await page.execute(() => {
203
+ const editorScrollParentSelector = '.fabric-editor-popup-scroll-parent';
204
+ const editor = document.querySelector(
205
+ editorScrollParentSelector,
206
+ ) as HTMLElement;
207
+ if (editor) {
208
+ editor.style.flexGrow = '0';
209
+ editor.style.width = '750px';
210
+ }
211
+ });
212
+
213
+ const table = await page.$(tableSelectors.stickyTable);
214
+ const tableWidth = await table.getSize();
215
+ const stickyHeader = await page.$(tableSelectors.stickyTr);
216
+ const stickyHeaderWidth = await stickyHeader.getSize();
217
+
218
+ expect(tableWidth.width).toEqual(stickyHeaderWidth.width);
219
+ },
220
+ );
@@ -37,14 +37,14 @@ describe('table plugin: insert', () => {
37
37
 
38
38
  const createEditor = createProsemirrorEditorFactory();
39
39
 
40
- const preset = new Preset<LightEditorPlugin>();
41
- preset.add([
42
- tablePlugin,
43
- {
44
- tableOptions: {},
45
- },
46
- ]);
47
- preset.add(widthPlugin);
40
+ const preset = new Preset<LightEditorPlugin>()
41
+ .add([
42
+ tablePlugin,
43
+ {
44
+ tableOptions: {},
45
+ },
46
+ ])
47
+ .add(widthPlugin);
48
48
 
49
49
  const editor = (doc: DocBuilder) =>
50
50
  createEditor<TablePluginState, PluginKey>({
@@ -39,6 +39,20 @@ jest.mock('@atlaskit/editor-common/utils', () => ({
39
39
  },
40
40
  }));
41
41
 
42
+ jest.mock('@atlaskit/editor-palette', () => ({
43
+ ...jest.requireActual<Object>('@atlaskit/editor-palette'),
44
+ hexToEditorBackgroundPaletteColorTokenName: jest.fn((hexColor: string) => {
45
+ return hexColor;
46
+ }),
47
+ }));
48
+
49
+ jest.mock('@atlaskit/tokens', () => ({
50
+ ...jest.requireActual<Object>('@atlaskit/tokens'),
51
+ getTokenValue: jest.fn((tokenId: string, fallback: string = '') => {
52
+ return tokenId || fallback;
53
+ }),
54
+ }));
55
+
42
56
  describe('table -> nodeviews -> tableCell.tsx', () => {
43
57
  const TABLE_LOCAL_ID = 'test-table-local-id';
44
58
  const createEditor = createProsemirrorEditorFactory();
@@ -472,7 +472,7 @@ describe('TableRowNodeView', () => {
472
472
  triggerElementIntersect({
473
473
  target: sentinelTop,
474
474
  isIntersecting: false,
475
- rootBounds: { bottom: 0, top: 0 },
475
+ rootBounds: { bottom: 0, top: 56 },
476
476
  boundingClientRect: { bottom: 0, top: 0 },
477
477
  });
478
478
 
@@ -507,7 +507,7 @@ describe('TableRowNodeView', () => {
507
507
  triggerElementIntersect({
508
508
  target: sentinelBottom,
509
509
  isIntersecting: true,
510
- rootBounds: { bottom: 0, top: 0 },
510
+ rootBounds: { bottom: 0, top: 56 },
511
511
  boundingClientRect: { bottom: 0, top: -100 },
512
512
  });
513
513
 
@@ -22,6 +22,7 @@ import { ContextualMenu } from '../../../plugins/table/ui/FloatingContextualMenu
22
22
 
23
23
  describe('ContextualMenu', () => {
24
24
  const getEditorContainerWidth = () => ({ width: 500 });
25
+ const getEditorFeatureFlags = () => ({});
25
26
  const createEditor = createProsemirrorEditorFactory();
26
27
  describe('with right table cell position in plugin state', () => {
27
28
  let editorView: EditorView;
@@ -44,6 +45,7 @@ describe('ContextualMenu', () => {
44
45
  isOpen
45
46
  selectionRect={{ bottom: 0, left: 0, right: 0, top: 0 }}
46
47
  getEditorContainerWidth={getEditorContainerWidth}
48
+ getEditorFeatureFlags={getEditorFeatureFlags}
47
49
  />,
48
50
  );
49
51
 
@@ -40,6 +40,7 @@ describe('FloatingContextualMenu', () => {
40
40
  isOpen
41
41
  pluginConfig={getPluginState(editorView.state).pluginConfig}
42
42
  getEditorContainerWidth={jest.fn()}
43
+ getEditorFeatureFlags={() => ({})}
43
44
  />
44
45
  </IntlProvider>,
45
46
  );
@@ -371,6 +371,10 @@ const tablesPlugin: NextEditorPlugin<
371
371
  pluginConfig={pluginConfig}
372
372
  editorAnalyticsAPI={options?.editorAnalyticsAPI}
373
373
  getEditorContainerWidth={defaultGetEditorContainerWidth}
374
+ getEditorFeatureFlags={
375
+ options?.getEditorFeatureFlags ||
376
+ defaultGetEditorFeatureFlags
377
+ }
374
378
  />
375
379
  {allowControls && (
376
380
  <FloatingDeleteButton
@@ -55,7 +55,6 @@ import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
55
55
 
56
56
  import memoizeOne from 'memoize-one';
57
57
  import { OverflowShadowsObserver } from './OverflowShadowsObserver';
58
- import { getParentWidthWithoutPadding } from '../pm-plugins/table-resizing/utils/misc';
59
58
 
60
59
  const isIE11 = browser.ie_version === 11;
61
60
  const NOOP = () => undefined;
@@ -689,7 +688,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
689
688
  options && options.isFullWidthModeEnabled,
690
689
  );
691
690
 
692
- return getParentWidthWithoutPadding(parentNodeWith, pos, state);
691
+ return parentNodeWith;
693
692
  };
694
693
 
695
694
  private updateParentWidth = (width?: number) => {
@@ -170,7 +170,7 @@ export class TableRowNodeView implements NodeView {
170
170
  this.topPosEditorElement = getTop(this.editorScrollableElement);
171
171
  }
172
172
 
173
- this.eventDispatcher.on('widthPlugin', this.onWidthPluginState);
173
+ this.eventDispatcher.on('widthPlugin', this.updateStickyHeaderWidth);
174
174
 
175
175
  this.eventDispatcher.on(
176
176
  (tablePluginKey as any).key,
@@ -209,7 +209,7 @@ export class TableRowNodeView implements NodeView {
209
209
  this.editorScrollableElement.removeEventListener('scroll', this.onScroll);
210
210
  }
211
211
 
212
- this.eventDispatcher.off('widthPlugin', this.onWidthPluginState);
212
+ this.eventDispatcher.off('widthPlugin', this.updateStickyHeaderWidth);
213
213
  this.eventDispatcher.off(
214
214
  (tablePluginKey as any).key,
215
215
  this.onTablePluginState,
@@ -235,6 +235,9 @@ export class TableRowNodeView implements NodeView {
235
235
  }
236
236
 
237
237
  this.resizeObserver.observe(this.dom);
238
+ if (this.editorScrollableElement) {
239
+ this.resizeObserver.observe(this.editorScrollableElement as HTMLElement);
240
+ }
238
241
 
239
242
  window.requestAnimationFrame(() => {
240
243
  // we expect tree to be defined after animation frame
@@ -268,22 +271,31 @@ export class TableRowNodeView implements NodeView {
268
271
  }
269
272
  const { table } = this.tree;
270
273
  entries.forEach((entry) => {
271
- const newHeight = entry.contentRect
272
- ? entry.contentRect.height
273
- : (entry.target as HTMLElement).offsetHeight;
274
-
274
+ // On resize of the parent scroll element we need to adjust the width
275
+ // of the sticky header
275
276
  if (
276
- this.sentinels.bottom &&
277
- // When the table header is sticky, it would be taller by a 1px (border-bottom),
278
- // So we adding this check to allow a 1px difference.
279
- Math.abs(newHeight - (this.stickyRowHeight || 0)) >
280
- stickyHeaderBorderBottomWidth
277
+ entry.target.className ===
278
+ (this.editorScrollableElement as HTMLElement)?.className
281
279
  ) {
282
- this.stickyRowHeight = newHeight;
283
- this.sentinels.bottom.style.bottom = `${
284
- tableScrollbarOffset + stickyRowOffsetTop + newHeight
285
- }px`;
286
- updateTableMargin(table);
280
+ this.updateStickyHeaderWidth();
281
+ } else {
282
+ const newHeight = entry.contentRect
283
+ ? entry.contentRect.height
284
+ : (entry.target as HTMLElement).offsetHeight;
285
+
286
+ if (
287
+ this.sentinels.bottom &&
288
+ // When the table header is sticky, it would be taller by a 1px (border-bottom),
289
+ // So we adding this check to allow a 1px difference.
290
+ Math.abs(newHeight - (this.stickyRowHeight || 0)) >
291
+ stickyHeaderBorderBottomWidth
292
+ ) {
293
+ this.stickyRowHeight = newHeight;
294
+ this.sentinels.bottom.style.bottom = `${
295
+ tableScrollbarOffset + stickyRowOffsetTop + newHeight
296
+ }px`;
297
+ updateTableMargin(table);
298
+ }
287
299
  }
288
300
  });
289
301
  });
@@ -309,7 +321,8 @@ export class TableRowNodeView implements NodeView {
309
321
  (entry.rootBounds?.bottom || 0) < entry.boundingClientRect.bottom;
310
322
 
311
323
  if (!entry.isIntersecting && !sentinelIsBelowScrollArea) {
312
- this.tree && this.makeHeaderRowSticky(this.tree);
324
+ this.tree &&
325
+ this.makeHeaderRowSticky(this.tree, entry.rootBounds?.top);
313
326
  } else {
314
327
  table && this.makeRowHeaderNotSticky(table);
315
328
  }
@@ -325,7 +338,8 @@ export class TableRowNodeView implements NodeView {
325
338
  if (table && !entry.isIntersecting && sentinelIsAboveScrollArea) {
326
339
  this.makeRowHeaderNotSticky(table);
327
340
  } else if (entry.isIntersecting && sentinelIsAboveScrollArea) {
328
- this.tree && this.makeHeaderRowSticky(this.tree);
341
+ this.tree &&
342
+ this.makeHeaderRowSticky(this.tree, entry?.rootBounds?.top);
329
343
  }
330
344
  }
331
345
  });
@@ -549,7 +563,7 @@ export class TableRowNodeView implements NodeView {
549
563
  }, 0);
550
564
  };
551
565
 
552
- onWidthPluginState = () => {
566
+ updateStickyHeaderWidth = () => {
553
567
  // table width might have changed, sync that back to sticky row
554
568
  const tree = this.tree;
555
569
  if (!tree) {
@@ -591,7 +605,7 @@ export class TableRowNodeView implements NodeView {
591
605
  return false;
592
606
  };
593
607
 
594
- makeHeaderRowSticky = (tree: TableDOMElements) => {
608
+ makeHeaderRowSticky = (tree: TableDOMElements, scrollTop?: number) => {
595
609
  // If header row height is more than 50% of viewport height don't do this
596
610
  if (this.stickyRowHeight && this.stickyRowHeight > window.innerHeight / 2) {
597
611
  return;
@@ -607,10 +621,13 @@ export class TableRowNodeView implements NodeView {
607
621
  }
608
622
 
609
623
  const currentTableTop = this.getCurrentTableTop(tree);
624
+
625
+ if (!scrollTop) {
626
+ scrollTop = getTop(this.editorScrollableElement);
627
+ }
628
+
610
629
  const domTop =
611
- currentTableTop > 0
612
- ? this.topPosEditorElement
613
- : this.topPosEditorElement + currentTableTop;
630
+ currentTableTop > 0 ? scrollTop : scrollTop + currentTableTop;
614
631
 
615
632
  if (!this.isSticky) {
616
633
  syncStickyRowToTable(table);
@@ -31,7 +31,6 @@ import type {
31
31
  GetEditorContainerWidth,
32
32
  GetEditorFeatureFlags,
33
33
  } from '@atlaskit/editor-common/types';
34
- import { getParentWidthWithoutPadding } from './utils/misc';
35
34
 
36
35
  export const handleMouseDown = (
37
36
  view: EditorView,
@@ -68,15 +67,8 @@ export const handleMouseDown = (
68
67
  const containerWidth = getEditorContainerWidth();
69
68
  const parentWidth = getParentNodeWidth(start, state, containerWidth);
70
69
 
71
- // TODO - refactor this logic into getParentNodeWidth() in editor-common [ED-16718]
72
- const parentActualWidth = getParentWidthWithoutPadding(
73
- parentWidth,
74
- start,
75
- state,
76
- );
77
-
78
70
  let maxSize =
79
- parentActualWidth ||
71
+ parentWidth ||
80
72
  getLayoutSize(
81
73
  dom.getAttribute('data-layout') as TableLayout,
82
74
  containerWidth.width,
@@ -21,8 +21,6 @@ import { Node as PMNode } from 'prosemirror-model';
21
21
  import { EditorState } from 'prosemirror-state';
22
22
  import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
23
23
  import { getParentNodeWidth } from '@atlaskit/editor-common/node-width';
24
- import { gridSize } from '@atlaskit/theme/constants';
25
- import { findParentNodeOfTypeClosestToPos } from 'prosemirror-utils';
26
24
 
27
25
  export const tableLayoutToSize: Record<string, number> = {
28
26
  default: akEditorDefaultLayoutWidth,
@@ -124,15 +122,7 @@ export const getTableMaxWidth = ({
124
122
  const containerWidth = getEditorContainerWidth();
125
123
  const parentWidth = getParentNodeWidth(tableStart, state, containerWidth);
126
124
 
127
- // TODO - refactor this logic into getParentNodeWidth() in editor-common [ED-16718]
128
- const parentActualWidth = getParentWidthWithoutPadding(
129
- parentWidth,
130
- tableStart,
131
- state,
132
- );
133
-
134
- let maxWidth =
135
- parentActualWidth || getLayoutSize(layout, containerWidth.width, {});
125
+ let maxWidth = parentWidth || getLayoutSize(layout, containerWidth.width, {});
136
126
 
137
127
  if (table.attrs.isNumberColumnEnabled) {
138
128
  maxWidth -= akEditorTableNumberColumnWidth;
@@ -140,49 +130,3 @@ export const getTableMaxWidth = ({
140
130
 
141
131
  return maxWidth;
142
132
  };
143
-
144
- export const getParentWidthWithoutPadding = (
145
- parentWidth: number,
146
- tableStartPos: number,
147
- state: EditorState,
148
- ) => {
149
- const node = getNestedParentNode(tableStartPos, state);
150
- if (!node) {
151
- return;
152
- }
153
-
154
- const { schema } = state;
155
-
156
- if (node.type === schema.nodes.expand) {
157
- // padding
158
- parentWidth -= gridSize() * 2;
159
- // gutter offset
160
- parentWidth += gridSize() * 1.5 * 2;
161
- // padding right
162
- parentWidth -= gridSize();
163
- // padding left
164
- parentWidth -= gridSize() * 4 - gridSize() / 2;
165
- }
166
-
167
- return parentWidth;
168
- };
169
-
170
- // copy of getNestedParentNode() from packages/editor/editor-common/src/node-width/index.ts
171
- // to be removed later when we will move getParentWidthWithoutPadding() logic to editor-common
172
- const getNestedParentNode = (
173
- tablePos: number,
174
- state: EditorState,
175
- ): PMNode | null => {
176
- if (tablePos === undefined) {
177
- return null;
178
- }
179
-
180
- const $pos = state.doc.resolve(tablePos);
181
- const parent = findParentNodeOfTypeClosestToPos($pos, [
182
- state.schema.nodes.bodiedExtension,
183
- state.schema.nodes.layoutSection,
184
- state.schema.nodes.expand,
185
- ]);
186
-
187
- return parent ? parent.node : null;
188
- };
@@ -18,6 +18,7 @@ import {
18
18
  } from '@atlaskit/editor-common/keymaps';
19
19
  import {
20
20
  ColorPalette,
21
+ backgroundPaletteTooltipMessages,
21
22
  cellBackgroundColorPalette,
22
23
  } from '@atlaskit/editor-common/ui-color';
23
24
  import { DropdownMenuSharedCssClassName } from '@atlaskit/editor-common/styles';
@@ -32,7 +33,10 @@ import { cellColourPreviewStyles } from './styles';
32
33
  import { closestElement } from '@atlaskit/editor-common/utils';
33
34
 
34
35
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
35
- import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
36
+ import type {
37
+ GetEditorContainerWidth,
38
+ GetEditorFeatureFlags,
39
+ } from '@atlaskit/editor-common/types';
36
40
 
37
41
  import type { MenuItem } from '@atlaskit/editor-common/ui-menu';
38
42
  type DropdownItem = MenuItem & {
@@ -131,6 +135,7 @@ export interface Props {
131
135
  offset?: Array<number>;
132
136
  editorAnalyticsAPI?: EditorAnalyticsAPI;
133
137
  getEditorContainerWidth: GetEditorContainerWidth;
138
+ getEditorFeatureFlags: GetEditorFeatureFlags;
134
139
  }
135
140
 
136
141
  export interface State {
@@ -209,9 +214,11 @@ export class ContextualMenu extends Component<
209
214
  selectionRect,
210
215
  intl: { formatMessage },
211
216
  editorView,
217
+ getEditorFeatureFlags,
212
218
  } = this.props;
213
219
  const items: any[] = [];
214
220
  const { isSubmenuOpen } = this.state;
221
+ const { useSomewhatSemanticTextColorNames } = getEditorFeatureFlags();
215
222
  // TargetCellPosition could be outdated: https://product-fabric.atlassian.net/browse/ED-8129
216
223
  const {
217
224
  targetCellPosition,
@@ -239,9 +246,21 @@ export class ContextualMenu extends Component<
239
246
  >
240
247
  <ColorPalette
241
248
  cols={7}
242
- palette={cellBackgroundColorPalette}
243
249
  onClick={this.setColor}
244
250
  selectedColor={background}
251
+ paletteOptions={{
252
+ palette: cellBackgroundColorPalette,
253
+ paletteColorTooltipMessages:
254
+ backgroundPaletteTooltipMessages,
255
+ // We did not want to create new FF or update
256
+ // useSomewhatSemanticTextColorNames name
257
+ // because it is temporary and require extra work.
258
+ // So even though it says text color names,
259
+ // we are going to use for all color pickers
260
+ // such as text, background and table charts.
261
+ showSomewhatSemanticTooltips:
262
+ useSomewhatSemanticTextColorNames,
263
+ }}
245
264
  />
246
265
  </div>
247
266
  )}
@@ -23,7 +23,10 @@ import {
23
23
  import { tablePopupStyles } from './styles';
24
24
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
25
25
 
26
- import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
26
+ import type {
27
+ GetEditorContainerWidth,
28
+ GetEditorFeatureFlags,
29
+ } from '@atlaskit/editor-common/types';
27
30
  import ContextualMenu from './ContextualMenu';
28
31
 
29
32
  // offset of the contextual menu dropdown
@@ -46,6 +49,7 @@ export interface Props {
46
49
  editorView: EditorView;
47
50
  isOpen: boolean;
48
51
  getEditorContainerWidth: GetEditorContainerWidth;
52
+ getEditorFeatureFlags: GetEditorFeatureFlags;
49
53
  targetCellPosition?: number;
50
54
  mountPoint?: HTMLElement;
51
55
  boundariesElement?: HTMLElement;
@@ -63,6 +67,7 @@ const FloatingContextualMenu = ({
63
67
  pluginConfig,
64
68
  editorAnalyticsAPI,
65
69
  getEditorContainerWidth,
70
+ getEditorFeatureFlags,
66
71
  }: Props) => {
67
72
  // TargetCellPosition could be outdated: https://product-fabric.atlassian.net/browse/ED-8129
68
73
  const { targetCellPosition } = getPluginState(editorView.state);
@@ -103,6 +108,7 @@ const FloatingContextualMenu = ({
103
108
  zIndex={akEditorFloatingOverlapPanelZIndex}
104
109
  forcePlacement={true}
105
110
  offset={[-7, 0]}
111
+ stick={true}
106
112
  >
107
113
  <div css={tablePopupStyles}>
108
114
  <ContextualMenu
@@ -120,6 +126,7 @@ const FloatingContextualMenu = ({
120
126
  boundariesElement={boundariesElement}
121
127
  editorAnalyticsAPI={editorAnalyticsAPI}
122
128
  getEditorContainerWidth={getEditorContainerWidth}
129
+ getEditorFeatureFlags={getEditorFeatureFlags}
123
130
  />
124
131
  </div>
125
132
  </Popup>
@@ -717,6 +717,7 @@ export const tableStyles = (
717
717
  padding-bottom: 0px;
718
718
  /* fixes gap cursor height */
719
719
  overflow: auto;
720
+ overflow-y: hidden;
720
721
  position: relative;
721
722
  }
722
723
  }
@@ -0,0 +1,5 @@
1
+ export interface MessageDescriptor {
2
+ id: string;
3
+ description: string;
4
+ defaultMessage: string;
5
+ }