@atlaskit/editor-plugin-table 1.1.5 → 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 (72) hide show
  1. package/CHANGELOG.md +32 -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 +39 -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/toolbar.js +3 -2
  8. package/dist/cjs/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +20 -4
  9. package/dist/cjs/plugins/table/ui/FloatingContextualMenu/index.js +6 -3
  10. package/dist/cjs/plugins/table/ui/common-styles.js +1 -1
  11. package/dist/cjs/plugins/table/ui/messages.js +5 -0
  12. package/dist/cjs/plugins/table/ui/ui-styles.js +2 -2
  13. package/dist/cjs/types/i18n.js +5 -0
  14. package/dist/cjs/version.json +1 -1
  15. package/dist/es2019/plugins/table/index.js +2 -1
  16. package/dist/es2019/plugins/table/nodeviews/TableComponent.js +1 -2
  17. package/dist/es2019/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +39 -17
  18. package/dist/es2019/plugins/table/pm-plugins/table-resizing/event-handlers.js +1 -5
  19. package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/misc.js +1 -37
  20. package/dist/es2019/plugins/table/toolbar.js +3 -2
  21. package/dist/es2019/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +23 -6
  22. package/dist/es2019/plugins/table/ui/FloatingContextualMenu/index.js +6 -3
  23. package/dist/es2019/plugins/table/ui/common-styles.js +10 -3
  24. package/dist/es2019/plugins/table/ui/messages.js +5 -0
  25. package/dist/es2019/plugins/table/ui/ui-styles.js +8 -4
  26. package/dist/es2019/types/i18n.js +1 -0
  27. package/dist/es2019/version.json +1 -1
  28. package/dist/esm/plugins/table/index.js +2 -1
  29. package/dist/esm/plugins/table/nodeviews/TableComponent.js +1 -2
  30. package/dist/esm/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +39 -17
  31. package/dist/esm/plugins/table/pm-plugins/table-resizing/event-handlers.js +1 -5
  32. package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/misc.js +1 -35
  33. package/dist/esm/plugins/table/toolbar.js +3 -2
  34. package/dist/esm/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +22 -6
  35. package/dist/esm/plugins/table/ui/FloatingContextualMenu/index.js +6 -3
  36. package/dist/esm/plugins/table/ui/common-styles.js +1 -1
  37. package/dist/esm/plugins/table/ui/messages.js +5 -0
  38. package/dist/esm/plugins/table/ui/ui-styles.js +3 -3
  39. package/dist/esm/types/i18n.js +1 -0
  40. package/dist/esm/version.json +1 -1
  41. package/dist/types/plugins/table/index.d.ts +3 -1
  42. package/dist/types/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.d.ts +2 -2
  43. package/dist/types/plugins/table/pm-plugins/table-resizing/utils/misc.d.ts +1 -2
  44. package/dist/types/plugins/table/ui/FloatingContextualMenu/ContextualMenu.d.ts +2 -1
  45. package/dist/types/plugins/table/ui/FloatingContextualMenu/index.d.ts +3 -2
  46. package/dist/types/plugins/table/ui/messages.d.ts +5 -0
  47. package/dist/types/types/i18n.d.ts +5 -0
  48. package/package.json +10 -10
  49. package/report.api.md +3 -2
  50. package/src/__tests__/integration/__fixtures__/large-table-with-sticky-header.ts +2311 -0
  51. package/src/__tests__/integration/horizontal-scroll.ts +4 -9
  52. package/src/__tests__/integration/sticky-header.ts +220 -0
  53. package/src/__tests__/unit/commands/insert.ts +8 -8
  54. package/src/__tests__/unit/nodeviews/cell.ts +14 -0
  55. package/src/__tests__/unit/pm-plugins/sticky-headers/tableRow.tsx +2 -2
  56. package/src/__tests__/unit/ui/ContextualMenu.tsx +2 -0
  57. package/src/__tests__/unit/ui/FloatingContextualMenu.tsx +1 -0
  58. 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
  59. 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
  60. 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
  61. package/src/plugins/table/index.tsx +7 -2
  62. package/src/plugins/table/nodeviews/TableComponent.tsx +1 -2
  63. package/src/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.ts +47 -25
  64. package/src/plugins/table/pm-plugins/table-resizing/event-handlers.ts +1 -9
  65. package/src/plugins/table/pm-plugins/table-resizing/utils/misc.ts +1 -57
  66. package/src/plugins/table/toolbar.tsx +6 -2
  67. package/src/plugins/table/ui/FloatingContextualMenu/ContextualMenu.tsx +29 -4
  68. package/src/plugins/table/ui/FloatingContextualMenu/index.tsx +8 -1
  69. package/src/plugins/table/ui/common-styles.ts +10 -3
  70. package/src/plugins/table/ui/messages.ts +5 -0
  71. package/src/plugins/table/ui/ui-styles.ts +8 -4
  72. package/src/types/i18n.ts +5 -0
@@ -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,
@@ -18,18 +18,25 @@ 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';
24
25
 
25
- import { DropdownMenu } from '@atlaskit/editor-common/ui-menu';
26
+ import {
27
+ ArrowKeyNavigationType,
28
+ DropdownMenu,
29
+ } from '@atlaskit/editor-common/ui-menu';
26
30
 
27
31
  import { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
28
32
  import { cellColourPreviewStyles } from './styles';
29
33
  import { closestElement } from '@atlaskit/editor-common/utils';
30
34
 
31
35
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
32
- import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
36
+ import type {
37
+ GetEditorContainerWidth,
38
+ GetEditorFeatureFlags,
39
+ } from '@atlaskit/editor-common/types';
33
40
 
34
41
  import type { MenuItem } from '@atlaskit/editor-common/ui-menu';
35
42
  type DropdownItem = MenuItem & {
@@ -128,6 +135,7 @@ export interface Props {
128
135
  offset?: Array<number>;
129
136
  editorAnalyticsAPI?: EditorAnalyticsAPI;
130
137
  getEditorContainerWidth: GetEditorContainerWidth;
138
+ getEditorFeatureFlags: GetEditorFeatureFlags;
131
139
  }
132
140
 
133
141
  export interface State {
@@ -162,7 +170,10 @@ export class ContextualMenu extends Component<
162
170
  mountTo={mountPoint}
163
171
  //This needs be removed when the a11y is completely handled
164
172
  //Disabling key navigation now as it works only partially
165
- disableArrowKeyNavigation={true}
173
+ arrowKeyNavigationProviderOptions={{
174
+ type: ArrowKeyNavigationType.MENU,
175
+ disableArrowKeyNavigation: true,
176
+ }}
166
177
  items={items}
167
178
  isOpen={isOpen}
168
179
  onOpenChange={this.handleOpenChange}
@@ -203,9 +214,11 @@ export class ContextualMenu extends Component<
203
214
  selectionRect,
204
215
  intl: { formatMessage },
205
216
  editorView,
217
+ getEditorFeatureFlags,
206
218
  } = this.props;
207
219
  const items: any[] = [];
208
220
  const { isSubmenuOpen } = this.state;
221
+ const { useSomewhatSemanticTextColorNames } = getEditorFeatureFlags();
209
222
  // TargetCellPosition could be outdated: https://product-fabric.atlassian.net/browse/ED-8129
210
223
  const {
211
224
  targetCellPosition,
@@ -233,9 +246,21 @@ export class ContextualMenu extends Component<
233
246
  >
234
247
  <ColorPalette
235
248
  cols={7}
236
- palette={cellBackgroundColorPalette}
237
249
  onClick={this.setColor}
238
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
+ }}
239
264
  />
240
265
  </div>
241
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>
@@ -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,10 +714,10 @@ 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;
720
+ overflow-y: hidden;
714
721
  position: relative;
715
722
  }
716
723
  }
@@ -726,7 +733,7 @@ export const tableStyles = (
726
733
  cursor: col-resize;
727
734
  }
728
735
 
729
- /*
736
+ /*
730
737
  ED-15882: When custom start numbers is enabled for lists, we have
731
738
  styles that handle this generally (in editor-common) so we can
732
739
  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: ' ';
@@ -0,0 +1,5 @@
1
+ export interface MessageDescriptor {
2
+ id: string;
3
+ description: string;
4
+ defaultMessage: string;
5
+ }