@atlaskit/editor-plugin-table 1.1.4 → 1.2.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 (40) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +7 -0
  3. package/dist/cjs/plugins/table/toolbar.js +3 -2
  4. package/dist/cjs/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +4 -1
  5. package/dist/cjs/plugins/table/ui/common-styles.js +1 -1
  6. package/dist/cjs/plugins/table/ui/messages.js +5 -0
  7. package/dist/cjs/plugins/table/ui/ui-styles.js +2 -2
  8. package/dist/cjs/version.json +1 -1
  9. package/dist/es2019/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +7 -0
  10. package/dist/es2019/plugins/table/toolbar.js +3 -2
  11. package/dist/es2019/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +5 -2
  12. package/dist/es2019/plugins/table/ui/common-styles.js +9 -3
  13. package/dist/es2019/plugins/table/ui/messages.js +5 -0
  14. package/dist/es2019/plugins/table/ui/ui-styles.js +8 -4
  15. package/dist/es2019/version.json +1 -1
  16. package/dist/esm/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +7 -0
  17. package/dist/esm/plugins/table/toolbar.js +3 -2
  18. package/dist/esm/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +5 -2
  19. package/dist/esm/plugins/table/ui/common-styles.js +1 -1
  20. package/dist/esm/plugins/table/ui/messages.js +5 -0
  21. package/dist/esm/plugins/table/ui/ui-styles.js +3 -3
  22. package/dist/esm/version.json +1 -1
  23. package/dist/types/plugins/table/index.d.ts +3 -1
  24. package/dist/types/plugins/table/ui/messages.d.ts +5 -0
  25. package/package.json +6 -6
  26. package/report.api.md +3 -2
  27. package/src/__tests__/integration/__fixtures__/large-table-with-sticky-header.ts +2311 -0
  28. package/src/__tests__/integration/delete-last-column-in-full-width.ts +1 -1
  29. package/src/__tests__/integration/floating-toolbar.ts +1 -1
  30. package/src/__tests__/integration/sticky-header.ts +160 -0
  31. package/src/__tests__/visual-regression/__image_snapshots__/cell-options-menu-ts-table-cell-options-menu-delete-column-menu-item-visual-hints-should-be-added-to-the-table-column-on-hover-1-snap.png +2 -2
  32. package/src/__tests__/visual-regression/__image_snapshots__/cell-options-menu-ts-table-cell-options-menu-delete-row-menu-item-visual-hints-should-be-added-to-the-table-row-on-hover-1-snap.png +2 -2
  33. package/src/__tests__/visual-regression/__image_snapshots__/index-ts-snapshot-test-table-numbered-list-should-not-overflow-table-cell-when-there-are-more-than-100-ordered-list-items-3-snap.png +2 -2
  34. package/src/plugins/table/index.tsx +3 -2
  35. package/src/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.ts +7 -2
  36. package/src/plugins/table/toolbar.tsx +6 -2
  37. package/src/plugins/table/ui/FloatingContextualMenu/ContextualMenu.tsx +8 -2
  38. package/src/plugins/table/ui/common-styles.ts +9 -3
  39. package/src/plugins/table/ui/messages.ts +5 -0
  40. package/src/plugins/table/ui/ui-styles.ts +8 -4
@@ -16,7 +16,7 @@ import {
16
16
  BrowserTestCase(
17
17
  'Delete last table column in full-width mode',
18
18
  // Only Chrome has logging support in BrowserStack now
19
- { skip: ['safari'] },
19
+ { skip: [] },
20
20
  async (client: any, testName: string) => {
21
21
  const page = await goToEditorTestingWDExample(
22
22
  client,
@@ -330,7 +330,7 @@ BrowserTestCase(
330
330
 
331
331
  BrowserTestCase(
332
332
  'should the context menu disabled item stay open when clicked.',
333
- { skip: ['safari'] }, // The test does not pass on CI but works on physical browser
333
+ { skip: [] },
334
334
  async (client: any, testName: string) => {
335
335
  const page = await goToEditorTestingWDExample(
336
336
  client,
@@ -0,0 +1,160 @@
1
+ import WebdriverPage from '@atlaskit/webdriver-runner/wd-wrapper';
2
+ import { BrowserTestCase } from '@atlaskit/webdriver-runner/runner';
3
+ import {
4
+ fullpage,
5
+ tableSelectors,
6
+ } from '@atlaskit/editor-test-helpers/integration/helpers';
7
+ import {
8
+ goToEditorTestingWDExample,
9
+ mountEditor,
10
+ } from '@atlaskit/editor-test-helpers/testing-example-page';
11
+ import stickyTable from './__fixtures__/large-table-with-sticky-header';
12
+
13
+ const scrollTo = async (page: WebdriverPage, height: number) => {
14
+ const editorScrollParentSelector = '.fabric-editor-popup-scroll-parent';
15
+ await page.execute(
16
+ (editorScrollParentSelector: string, height: number) => {
17
+ const editor = document.querySelector(editorScrollParentSelector);
18
+ editor && editor.scroll(0, height);
19
+ },
20
+ editorScrollParentSelector,
21
+ height,
22
+ );
23
+ };
24
+
25
+ const insertColumn = async (page: any, cell: 'first' | 'last') => {
26
+ const columnControl = tableSelectors.nthColumnControl(1);
27
+ const insertButton = tableSelectors.insertButton;
28
+ const firstCell = tableSelectors.topLeftCell;
29
+ const firstCellLastRow = `table > tbody > tr:nth-child(48) > td:nth-child(1)`;
30
+
31
+ if (cell === 'first') {
32
+ await page.click(firstCell);
33
+ } else if (cell === 'last') {
34
+ await page.click(firstCellLastRow);
35
+ }
36
+
37
+ const columnDecorationSelector = columnControl;
38
+ await page.hover(columnDecorationSelector);
39
+
40
+ await page.waitForSelector(insertButton);
41
+ await page.click(insertButton);
42
+ };
43
+
44
+ BrowserTestCase(
45
+ 'Sticky header should correctly toggle on and off',
46
+ { skip: [] },
47
+ async (client: any, testName: string) => {
48
+ const page = await goToEditorTestingWDExample(
49
+ client,
50
+ 'editor-plugin-table',
51
+ );
52
+
53
+ await mountEditor(page, {
54
+ appearance: fullpage.appearance,
55
+ defaultValue: JSON.stringify(stickyTable),
56
+ allowTables: {
57
+ advanced: true,
58
+ stickyHeaders: true,
59
+ },
60
+ });
61
+
62
+ await page.waitForSelector('table');
63
+
64
+ expect(
65
+ await page.waitForSelector(tableSelectors.stickyTable, {}, true),
66
+ ).toBeTruthy();
67
+ expect(
68
+ await page.waitForSelector(tableSelectors.stickyTr, {}, true),
69
+ ).toBeTruthy();
70
+
71
+ await scrollTo(page, window.innerHeight * 100);
72
+
73
+ expect(await page.waitForSelector(tableSelectors.stickyTable)).toBeTruthy();
74
+ expect(await page.waitForSelector(tableSelectors.stickyTr)).toBeTruthy();
75
+
76
+ await scrollTo(page, 0);
77
+
78
+ expect(
79
+ await page.waitForSelector(tableSelectors.stickyTable, {}, true),
80
+ ).toBeTruthy();
81
+ expect(
82
+ await page.waitForSelector(tableSelectors.stickyTr, {}, true),
83
+ ).toBeTruthy();
84
+ },
85
+ );
86
+
87
+ BrowserTestCase(
88
+ 'Sticky header should still correctly toggle on and off, after a column has been added',
89
+ { skip: ['safari'] },
90
+ async (client: any, testName: string) => {
91
+ const page = await goToEditorTestingWDExample(
92
+ client,
93
+ 'editor-plugin-table',
94
+ );
95
+
96
+ await mountEditor(page, {
97
+ appearance: fullpage.appearance,
98
+ defaultValue: JSON.stringify(stickyTable),
99
+ allowTables: {
100
+ advanced: true,
101
+ stickyHeaders: true,
102
+ },
103
+ });
104
+
105
+ await page.waitForSelector('table');
106
+
107
+ expect(
108
+ await page.waitForSelector(tableSelectors.stickyTable, {}, true),
109
+ ).toBeTruthy();
110
+ expect(
111
+ await page.waitForSelector(tableSelectors.stickyTr, {}, true),
112
+ ).toBeTruthy();
113
+
114
+ await insertColumn(page, 'first');
115
+
116
+ await scrollTo(page, window.innerHeight * 100);
117
+
118
+ expect(await page.waitForSelector(tableSelectors.stickyTable)).toBeTruthy();
119
+ expect(await page.waitForSelector(tableSelectors.stickyTr)).toBeTruthy();
120
+ },
121
+ );
122
+
123
+ BrowserTestCase(
124
+ 'Sticky header should correctly toggle on and off, after table is scrolled to the bottom and a column has been added',
125
+ { skip: ['safari'] },
126
+ async (client: any, testName: string) => {
127
+ const page = await goToEditorTestingWDExample(
128
+ client,
129
+ 'editor-plugin-table',
130
+ );
131
+
132
+ await mountEditor(page, {
133
+ appearance: fullpage.appearance,
134
+ defaultValue: JSON.stringify(stickyTable),
135
+ allowTables: {
136
+ advanced: true,
137
+ stickyHeaders: true,
138
+ },
139
+ });
140
+
141
+ await page.waitForSelector('table');
142
+
143
+ await scrollTo(page, window.innerHeight * 100);
144
+
145
+ await insertColumn(page, 'last');
146
+
147
+ expect(
148
+ await page.waitForSelector(tableSelectors.stickyTable, {}, true),
149
+ ).toBeTruthy();
150
+ expect(
151
+ await page.waitForSelector(tableSelectors.stickyTr, {}, true),
152
+ ).toBeTruthy();
153
+
154
+ // ED-16817 This checks for a bug where the table row would become not sticky
155
+ // but the numbered column header would stay sticky
156
+ const numberedCol = await page.$(tableSelectors.numberedColumnTopLeftCell);
157
+ const numberedColStyle = await numberedCol.getAttribute('style');
158
+ expect(!numberedColStyle.includes('top')).toBeTruthy();
159
+ },
160
+ );
@@ -1,3 +1,3 @@
1
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:73e26bdfa1009884d8657a69ff2a721ecf9f0a0763629cae053550cf9b640425
3
- size 29791
2
+ oid sha256:ac570fb3172970569166ac27d43c4d4330ed10407894ae2882fc91268b7c6543
3
+ size 29647
@@ -1,3 +1,3 @@
1
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:4c6f837604b1df78aef416e043bfd090906490e7604121f6f0c683d43dd7c9da
3
- size 29783
2
+ oid sha256:91b791b54bbda59e690dbec1a779bbba00ccdfdd2b1658def547de0edb8164c5
3
+ size 29662
@@ -1,3 +1,3 @@
1
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:61cd30f491d1cf3499042fe4c002d5ec610520b57e395cc78c998b71dadc9cd3
3
- size 42193
2
+ oid sha256:918d6eca1f77862b22c2530a59567a7bed80e221c1d1050a3e45c0803112437e
3
+ size 42897
@@ -79,8 +79,9 @@ const defaultGetEditorFeatureFlags = () => ({});
79
79
 
80
80
  const tablesPlugin: NextEditorPlugin<
81
81
  'table',
82
- never,
83
- TablePluginOptions | undefined
82
+ {
83
+ pluginConfiguration: TablePluginOptions | undefined;
84
+ }
84
85
  > = (options?: TablePluginOptions) => {
85
86
  const editorViewRef: Record<'current', EditorView | null> = { current: null };
86
87
  const defaultGetEditorContainerWidth: GetEditorContainerWidth = () => {
@@ -190,9 +190,15 @@ export class TableRowNodeView implements NodeView {
190
190
  if (!this.listening) {
191
191
  return;
192
192
  }
193
-
194
193
  if (this.intersectionObserver) {
195
194
  this.intersectionObserver.disconnect();
195
+ // ED-16211 Once intersection observer is disconnected, we need to remove the isObserved from the sentinels
196
+ // Otherwise when new intersection observer is created it will not observe because it thinks its already being observed
197
+ [this.sentinels.top, this.sentinels.bottom].forEach((el) => {
198
+ if (el) {
199
+ delete el.dataset.isObserved;
200
+ }
201
+ });
196
202
  }
197
203
 
198
204
  if (this.resizeObserver) {
@@ -633,7 +639,6 @@ export class TableRowNodeView implements NodeView {
633
639
  table.classList.remove(ClassName.TABLE_STICKY);
634
640
 
635
641
  this.isSticky = false;
636
-
637
642
  this.dom.style.top = '';
638
643
  table.style.removeProperty('margin-top');
639
644
 
@@ -475,6 +475,8 @@ export const getToolbarConfig =
475
475
  let confirmDialog;
476
476
 
477
477
  if (isReferencedSource(state, tableObject.node)) {
478
+ const localSourceName = intl.formatMessage(tableMessages.unnamedSource);
479
+
478
480
  confirmDialog = (): ConfirmDialogOptions => ({
479
481
  title: intl.formatMessage(tableMessages.deleteElementTitle),
480
482
  okButtonLabel: intl.formatMessage(
@@ -482,7 +484,9 @@ export const getToolbarConfig =
482
484
  ),
483
485
  message: intl.formatMessage(
484
486
  tableMessages.confirmDeleteLinkedModalMessage,
485
- { nodeName: getNodeName(state, tableObject.node) },
487
+ {
488
+ nodeName: getNodeName(state, tableObject.node) || localSourceName,
489
+ },
486
490
  ),
487
491
  messagePrefix: intl.formatMessage(
488
492
  tableMessages.confirmDeleteLinkedModalMessagePrefix,
@@ -524,7 +528,7 @@ export const getToolbarConfig =
524
528
  title: 'Table floating controls',
525
529
  getDomRef,
526
530
  nodeType,
527
- offset: [0, 3],
531
+ offset: [0, 18],
528
532
  zIndex: akEditorFloatingPanelZIndex + 1, // Place the context menu slightly above the others
529
533
  items: [
530
534
  menu,
@@ -22,7 +22,10 @@ import {
22
22
  } from '@atlaskit/editor-common/ui-color';
23
23
  import { DropdownMenuSharedCssClassName } from '@atlaskit/editor-common/styles';
24
24
 
25
- import { DropdownMenu } from '@atlaskit/editor-common/ui-menu';
25
+ import {
26
+ ArrowKeyNavigationType,
27
+ DropdownMenu,
28
+ } from '@atlaskit/editor-common/ui-menu';
26
29
 
27
30
  import { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
28
31
  import { cellColourPreviewStyles } from './styles';
@@ -162,7 +165,10 @@ export class ContextualMenu extends Component<
162
165
  mountTo={mountPoint}
163
166
  //This needs be removed when the a11y is completely handled
164
167
  //Disabling key navigation now as it works only partially
165
- disableArrowKeyNavigation={true}
168
+ arrowKeyNavigationProviderOptions={{
169
+ type: ArrowKeyNavigationType.MENU,
170
+ disableArrowKeyNavigation: true,
171
+ }}
166
172
  items={items}
167
173
  isOpen={isOpen}
168
174
  onOpenChange={this.handleOpenChange}
@@ -362,6 +362,13 @@ export const tableStyles = (
362
362
 
363
363
  .${ClassName.ROW_CONTROLS_WRAPPER} {
364
364
  padding: 0 ${tablePadding}px;
365
+
366
+ // https://product-fabric.atlassian.net/browse/ED-16386
367
+ // Fixes issue where the extra padding that is added here throws off the position
368
+ // of the rows control dot
369
+ &::after {
370
+ right: 6px !important;
371
+ }
365
372
  }
366
373
 
367
374
  &.${ClassName.TABLE_CONTAINER}[data-number-column='true'] {
@@ -707,8 +714,7 @@ export const tableStyles = (
707
714
  .${ClassName.TABLE_NODE_WRAPPER} {
708
715
  padding-right: ${insertColumnButtonOffset}px;
709
716
  margin-right: -${insertColumnButtonOffset}px;
710
- padding-bottom: ${tableScrollbarOffset}px;
711
- margin-bottom: -${tableScrollbarOffset}px;
717
+ padding-bottom: 0px;
712
718
  /* fixes gap cursor height */
713
719
  overflow: auto;
714
720
  position: relative;
@@ -726,7 +732,7 @@ export const tableStyles = (
726
732
  cursor: col-resize;
727
733
  }
728
734
 
729
- /*
735
+ /*
730
736
  ED-15882: When custom start numbers is enabled for lists, we have
731
737
  styles that handle this generally (in editor-common) so we can
732
738
  throw away the older table-specific styles here.
@@ -55,4 +55,9 @@ export default defineMessages({
55
55
  description:
56
56
  'Title text for confirm modal when deleting an extension linked to a data consumer.',
57
57
  },
58
+ unnamedSource: {
59
+ id: 'fabric.editor.extension.sourceNoTitledName',
60
+ defaultMessage: 'this element',
61
+ description: 'The current element without preset name been selected',
62
+ },
58
63
  });
@@ -1,8 +1,8 @@
1
1
  import { css } from '@emotion/react';
2
2
  import {
3
3
  tableCellBorderWidth,
4
- tableMarginBottom,
5
4
  tableMarginTop,
5
+ tableMarginTopWithControl,
6
6
  } from '@atlaskit/editor-common/styles';
7
7
  import {
8
8
  akEditorShadowZIndex,
@@ -246,7 +246,7 @@ export const DeleteButton = css`
246
246
  export const OverflowShadow = (props: ThemeProps) => css`
247
247
  .${ClassName.TABLE_RIGHT_SHADOW}, .${ClassName.TABLE_LEFT_SHADOW} {
248
248
  display: block;
249
- height: calc(100% - ${tableMarginTop + tableMarginBottom}px);
249
+ height: calc(100% - ${tableMarginTop}px);
250
250
  position: absolute;
251
251
  pointer-events: none;
252
252
  top: ${tableMarginTop}px;
@@ -282,10 +282,13 @@ export const OverflowShadow = (props: ThemeProps) => css`
282
282
  );
283
283
  left: calc(100% + 2px);
284
284
  }
285
+ .${ClassName.TABLE_COLUMN_CONTROLS_DECORATIONS} {
286
+ z-index: 0;
287
+ }
285
288
  .${ClassName.WITH_CONTROLS} {
286
289
  .${ClassName.TABLE_RIGHT_SHADOW}, .${ClassName.TABLE_LEFT_SHADOW} {
287
- height: calc(100% - ${tableMarginTop + tableMarginBottom}px);
288
- top: ${tableMarginTop}px;
290
+ height: calc(100% - ${tableMarginTopWithControl}px);
291
+ top: ${tableMarginTopWithControl}px;
289
292
  }
290
293
  .${ClassName.TABLE_LEFT_SHADOW} {
291
294
  border-left: 1px solid ${tableBorderColor(props)};
@@ -326,6 +329,7 @@ export const columnControlsDecoration = (props: ThemeProps) => css`
326
329
  left: -1px;
327
330
  top: -${columnControlsDecorationHeight + tableCellBorderWidth}px;
328
331
  height: ${columnControlsDecorationHeight}px;
332
+ z-index: 0;
329
333
 
330
334
  &::before {
331
335
  content: ' ';