@atlaskit/editor-plugin-table 1.0.1 → 1.0.3

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 (32) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/plugins/table/toolbar.js +24 -0
  3. package/dist/cjs/plugins/table/ui/FloatingContextualButton/styles.js +14 -16
  4. package/dist/cjs/plugins/table/ui/FloatingContextualMenu/styles.js +1 -3
  5. package/dist/cjs/plugins/table/ui/common-styles.js +1 -3
  6. package/dist/cjs/plugins/table/ui/consts.js +15 -17
  7. package/dist/cjs/plugins/table/ui/ui-styles.js +10 -12
  8. package/dist/cjs/plugins/table/utils/decoration.js +31 -1
  9. package/dist/cjs/version.json +1 -1
  10. package/dist/es2019/plugins/table/toolbar.js +25 -1
  11. package/dist/es2019/plugins/table/ui/FloatingContextualButton/styles.js +14 -15
  12. package/dist/es2019/plugins/table/ui/FloatingContextualMenu/styles.js +3 -4
  13. package/dist/es2019/plugins/table/ui/common-styles.js +20 -21
  14. package/dist/es2019/plugins/table/ui/consts.js +15 -16
  15. package/dist/es2019/plugins/table/ui/ui-styles.js +23 -24
  16. package/dist/es2019/plugins/table/utils/decoration.js +32 -2
  17. package/dist/es2019/version.json +1 -1
  18. package/dist/esm/plugins/table/toolbar.js +25 -1
  19. package/dist/esm/plugins/table/ui/FloatingContextualButton/styles.js +14 -15
  20. package/dist/esm/plugins/table/ui/FloatingContextualMenu/styles.js +1 -2
  21. package/dist/esm/plugins/table/ui/common-styles.js +1 -2
  22. package/dist/esm/plugins/table/ui/consts.js +15 -16
  23. package/dist/esm/plugins/table/ui/ui-styles.js +10 -11
  24. package/dist/esm/plugins/table/utils/decoration.js +32 -2
  25. package/dist/esm/version.json +1 -1
  26. package/package.json +4 -4
  27. package/report.api.md +15 -0
  28. package/src/__tests__/integration/__fixtures__/basic-table-with-merged-cell.ts +112 -0
  29. package/src/__tests__/integration/__snapshots__/floating-toolbar.ts.snap +292 -0
  30. package/src/__tests__/integration/floating-toolbar.ts +164 -8
  31. package/src/plugins/table/toolbar.tsx +23 -0
  32. package/src/plugins/table/utils/decoration.ts +27 -2
@@ -2,12 +2,11 @@ import { css } from '@emotion/react';
2
2
  import { B75, DN0, DN60, N0, N20, N30A, N700 } from '@atlaskit/theme/colors';
3
3
  import { borderRadius } from '@atlaskit/theme/constants';
4
4
  import { contextualMenuTriggerSize } from '../consts';
5
- import { token } from '@atlaskit/tokens';
6
5
  import { themed } from '@atlaskit/theme/components';
7
6
  export const tableFloatingCellButtonStyles = props => css`
8
7
  > div {
9
8
  // Sits behind button to provide surface-color background
10
- background: ${token('elevation.surface', N20)};
9
+ background: ${`var(--ds-surface, ${N20})`};
11
10
  border-radius: ${borderRadius()}px;
12
11
  display: flex;
13
12
  height: ${contextualMenuTriggerSize + 2}px;
@@ -15,12 +14,12 @@ export const tableFloatingCellButtonStyles = props => css`
15
14
  }
16
15
  && button {
17
16
  background: ${themed({
18
- light: token('color.background.neutral', 'none'),
19
- dark: token('color.background.neutral', 'none')
17
+ light: "var(--ds-background-neutral, none)",
18
+ dark: "var(--ds-background-neutral, none)"
20
19
  })(props)};
21
20
  flex-direction: column;
22
21
  margin: 2px;
23
- outline: 2px solid ${token('color.border', N0)};
22
+ outline: 2px solid ${`var(--ds-border, ${N0})`};
24
23
  border-radius: 1px;
25
24
  padding: 0;
26
25
  height: calc(100% - 4px);
@@ -28,14 +27,14 @@ export const tableFloatingCellButtonStyles = props => css`
28
27
  }
29
28
  && button:hover {
30
29
  background: ${themed({
31
- light: token('color.background.neutral.hovered', N30A),
32
- dark: token('color.background.neutral.hovered', DN60)
30
+ light: `var(--ds-background-neutral-hovered, ${N30A})`,
31
+ dark: `var(--ds-background-neutral-hovered, ${DN60})`
33
32
  })(props)};
34
33
  }
35
34
  && button:active {
36
35
  background: ${themed({
37
- light: token('color.background.neutral.pressed', 'rgba(179, 212, 255, 0.6)'),
38
- dark: token('color.background.neutral.pressed', B75)
36
+ light: "var(--ds-background-neutral-pressed, rgba(179, 212, 255, 0.6))",
37
+ dark: `var(--ds-background-neutral-pressed, ${B75})`
39
38
  })(props)};
40
39
  }
41
40
  && button > span {
@@ -48,20 +47,20 @@ export const tableFloatingCellButtonStyles = props => css`
48
47
  export const tableFloatingCellButtonSelectedStyles = props => css`
49
48
  && button {
50
49
  background: ${themed({
51
- light: token('color.background.selected', N700),
52
- dark: token('color.background.selected', DN0)
50
+ light: `var(--ds-background-selected, ${N700})`,
51
+ dark: `var(--ds-background-selected, ${DN0})`
53
52
  })(props)};
54
53
  }
55
54
  && button:hover {
56
55
  background: ${themed({
57
- light: token('color.background.selected.hovered', N700),
58
- dark: token('color.background.selected.hovered', DN0)
56
+ light: `var(--ds-background-selected-hovered, ${N700})`,
57
+ dark: `var(--ds-background-selected-hovered, ${DN0})`
59
58
  })(props)};
60
59
  }
61
60
  && button:active {
62
61
  background: ${themed({
63
- light: token('color.background.selected.pressed', N700),
64
- dark: token('color.background.selected.pressed', DN0)
62
+ light: `var(--ds-background-selected-pressed, ${N700})`,
63
+ dark: `var(--ds-background-selected-pressed, ${DN0})`
65
64
  })(props)};
66
65
  }
67
66
  `;
@@ -4,7 +4,6 @@ import { N60A, N90 } from '@atlaskit/theme/colors';
4
4
  import { contextualMenuDropdownWidth } from '../consts';
5
5
  import { TableCssClassName as ClassName } from '../../types';
6
6
  import { borderRadius } from '@atlaskit/theme/constants';
7
- import { token } from '@atlaskit/tokens';
8
7
  export const cellColourPreviewStyles = selectedColor => css`
9
8
  &::before {
10
9
  background: ${selectedColor};
@@ -13,8 +12,8 @@ export const cellColourPreviewStyles = selectedColor => css`
13
12
  export const tablePopupStyles = css`
14
13
  .${ClassName.CONTEXTUAL_SUBMENU} {
15
14
  border-radius: ${borderRadius()}px;
16
- background: ${token('elevation.surface.overlay', 'white')};
17
- box-shadow: ${token('elevation.shadow.overlay', `0 4px 8px -2px ${N60A}, 0 0 1px ${N60A}`)};
15
+ background: ${"var(--ds-surface-overlay, white)"};
16
+ box-shadow: ${`var(--ds-shadow-overlay, ${`0 4px 8px -2px ${N60A}, 0 0 1px ${N60A}`})`};
18
17
  display: block;
19
18
  position: absolute;
20
19
  top: 0;
@@ -42,7 +41,7 @@ export const tablePopupStyles = css`
42
41
  content: '›';
43
42
  margin-left: 4px;
44
43
  line-height: 20px;
45
- color: ${token('color.icon', N90)};
44
+ color: ${`var(--ds-icon, ${N90})`};
46
45
  }
47
46
  }
48
47
  `;
@@ -7,7 +7,6 @@ import { scrollbarStyles } from '@atlaskit/editor-shared-styles/scrollbar';
7
7
  import { TableCssClassName as ClassName } from '../types';
8
8
  import { tableCellBackgroundColor, tableToolbarColor, tableBorderColor, tableCellSelectedColor, tableToolbarSelectedColor, tableBorderSelectedColor, tableCellDeleteColor, tableBorderDeleteColor, tableToolbarDeleteColor, tableBorderRadiusSize, tablePadding, tableScrollbarOffset, resizeHandlerAreaWidth, resizeLineWidth, tableToolbarSize, tableInsertColumnButtonSize, tableControlsSpacing, tableTextColor, stickyRowZIndex, columnControlsDecorationHeight, stickyRowOffsetTop, stickyHeaderBorderBottomWidth } from './consts';
9
9
  import { HeaderButton, HeaderButtonHover, HeaderButtonDanger, insertColumnButtonWrapper, insertRowButtonWrapper, columnControlsLineMarker, DeleteButton, OverflowShadow, columnControlsDecoration, hoveredDeleteButton, hoveredCell, hoveredWarningCell, resizeHandle, InsertMarker } from './ui-styles';
10
- import { token } from '@atlaskit/tokens';
11
10
  const cornerControlHeight = tableToolbarSize + 1;
12
11
  /*
13
12
  compensating for half of the insert column button
@@ -61,14 +60,14 @@ export const tableStyles = props => {
61
60
 
62
61
  return css`
63
62
  .${ClassName.LAYOUT_BUTTON} button {
64
- background: ${token('color.background.neutral', N20A)};
65
- color: ${token('color.icon', N300)};
63
+ background: ${`var(--ds-background-neutral, ${N20A})`};
64
+ color: ${`var(--ds-icon, ${N300})`};
66
65
  cursor: none;
67
66
  }
68
67
 
69
68
  .${ClassName.LAYOUT_BUTTON}:not(.${ClassName.IS_RESIZING}) button:hover {
70
- background: ${token('color.background.neutral.hovered', B300)};
71
- color: ${token('color.icon', 'white')} !important;
69
+ background: ${`var(--ds-background-neutral-hovered, ${B300})`};
70
+ color: ${"var(--ds-icon, white)"} !important;
72
71
  cursor: pointer;
73
72
  }
74
73
 
@@ -131,7 +130,7 @@ export const tableStyles = props => {
131
130
 
132
131
  position: fixed !important;
133
132
  z-index: ${akEditorStickyHeaderZIndex} !important;
134
- box-shadow: 0px -${stickyRowOffsetTop}px ${token('elevation.surface', 'white')};
133
+ box-shadow: 0px -${stickyRowOffsetTop}px ${"var(--ds-surface, white)"};
135
134
  border-right: 0 none;
136
135
  /* top set by NumberColumn component */
137
136
  }
@@ -140,7 +139,7 @@ export const tableStyles = props => {
140
139
  position: fixed !important;
141
140
  /* needs to be above row controls */
142
141
  z-index: ${akEditorSmallZIndex} !important;
143
- background: ${token('elevation.surface', 'white')};
142
+ background: ${"var(--ds-surface, white)"};
144
143
 
145
144
  width: ${tableToolbarSize}px;
146
145
  height: ${tableToolbarSize}px;
@@ -165,13 +164,13 @@ export const tableStyles = props => {
165
164
  z-index: ${akEditorStickyHeaderZIndex} !important;
166
165
  display: flex;
167
166
  border-left: ${tableToolbarSize}px solid
168
- ${token('elevation.surface', 'white')};
167
+ ${"var(--ds-surface, white)"};
169
168
  margin-left: -${tableToolbarSize}px;
170
169
  }
171
170
 
172
171
  .${ClassName.TABLE_STICKY} col:first-of-type {
173
172
  /* moving rows out of a table layout does weird things in Chrome */
174
- border-right: 1px solid ${token('elevation.surface', 'green')};
173
+ border-right: 1px solid ${"var(--ds-surface, green)"};
175
174
  }
176
175
 
177
176
  tr.sticky {
@@ -188,12 +187,12 @@ export const tableStyles = props => {
188
187
  grid-auto-flow: column;
189
188
 
190
189
  /* background for where controls apply */
191
- background: ${token('elevation.surface', 'white')};
190
+ background: ${"var(--ds-surface, white)"};
192
191
  box-sizing: content-box;
193
192
 
194
193
  margin-top: 2px;
195
194
 
196
- box-shadow: ${token('elevation.shadow.overflow', `0 6px 4px -4px ${N40A}`)};
195
+ box-shadow: ${`var(--ds-shadow-overflow, ${`0 6px 4px -4px ${N40A}`})`};
197
196
  margin-left: -1px;
198
197
 
199
198
  &.no-pointer-events {
@@ -279,7 +278,7 @@ export const tableStyles = props => {
279
278
 
280
279
  .${ClassName.CORNER_CONTROLS}.sticky {
281
280
  border-top: ${tableControlsSpacing - tableToolbarSize + 2}px solid
282
- ${token('elevation.surface', 'white')};
281
+ ${"var(--ds-surface, white)"};
283
282
  }
284
283
 
285
284
  ${(_props$featureFlags = props.featureFlags) !== null && _props$featureFlags !== void 0 && _props$featureFlags.stickyHeadersOptimization ? sentinelStyles : ''}
@@ -367,7 +366,7 @@ export const tableStyles = props => {
367
366
  }
368
367
  .active .${ClassName.CONTROLS_CORNER_BUTTON} {
369
368
  border-color: ${tableBorderSelectedColor};
370
- background: ${token('color.background.selected', tableToolbarSelectedColor)};
369
+ background: ${`var(--ds-background-selected, ${tableToolbarSelectedColor})`};
371
370
  }
372
371
 
373
372
  .${ClassName.TABLE_CONTAINER}[data-number-column='true'] {
@@ -381,14 +380,14 @@ export const tableStyles = props => {
381
380
 
382
381
  :not(.${ClassName.IS_RESIZING}) .${ClassName.CONTROLS_CORNER_BUTTON}:hover {
383
382
  border-color: ${tableBorderSelectedColor};
384
- background: ${token('color.background.selected', tableToolbarSelectedColor)};
383
+ background: ${`var(--ds-background-selected, ${tableToolbarSelectedColor})`};
385
384
  cursor: pointer;
386
385
  }
387
386
 
388
387
  :not(.${ClassName.IS_RESIZING})
389
388
  .${ClassName.CONTROLS_CORNER_BUTTON}.${ClassName.HOVERED_CELL_IN_DANGER} {
390
389
  border-color: ${tableBorderDeleteColor};
391
- background: ${token('color.background.danger', tableToolbarDeleteColor)};
390
+ background: ${`var(--ds-background-danger, ${tableToolbarDeleteColor})`};
392
391
  }
393
392
 
394
393
  /* Row controls */
@@ -489,10 +488,10 @@ export const tableStyles = props => {
489
488
  .${ClassName.NUMBERED_COLUMN_BUTTON}.active {
490
489
  border-bottom: 1px solid ${tableBorderSelectedColor};
491
490
  border-color: ${tableBorderSelectedColor};
492
- background-color: ${token('color.background.selected', tableToolbarSelectedColor)};
491
+ background-color: ${`var(--ds-background-selected, ${tableToolbarSelectedColor})`};
493
492
  position: relative;
494
493
  z-index: ${akEditorUnitZIndex};
495
- color: ${token('color.text.selected', N0)};
494
+ color: ${`var(--ds-text-selected, ${N0})`};
496
495
  }
497
496
  }
498
497
  }
@@ -503,16 +502,16 @@ export const tableStyles = props => {
503
502
  .${ClassName.NUMBERED_COLUMN_BUTTON}:hover {
504
503
  border-bottom: 1px solid ${tableBorderSelectedColor};
505
504
  border-color: ${tableBorderSelectedColor};
506
- background-color: ${token('color.background.selected', tableToolbarSelectedColor)};
505
+ background-color: ${`var(--ds-background-selected, ${tableToolbarSelectedColor})`};
507
506
  position: relative;
508
507
  z-index: ${akEditorUnitZIndex};
509
- color: ${token('color.text.selected', N0)};
508
+ color: ${`var(--ds-text-selected, ${N0})`};
510
509
  }
511
510
  .${ClassName.NUMBERED_COLUMN_BUTTON}.${ClassName.HOVERED_CELL_IN_DANGER} {
512
- background-color: ${token('color.background.danger', tableToolbarDeleteColor)};
511
+ background-color: ${`var(--ds-background-danger, ${tableToolbarDeleteColor})`};
513
512
  border: 1px solid ${tableBorderDeleteColor};
514
513
  border-left: 0;
515
- color: ${token('color.text.danger', R500)};
514
+ color: ${`var(--ds-text-danger, ${R500})`};
516
515
  position: relative;
517
516
  z-index: ${akEditorUnitZIndex};
518
517
  }
@@ -1,7 +1,6 @@
1
1
  import { B200, B300, N20, R400, R75, DN400, N200, DN30, N0 } from '@atlaskit/theme/colors';
2
2
  import { tableCellBorderWidth, tableMarginTop } from '@atlaskit/editor-common/styles';
3
3
  import { akEditorTableBorder, akEditorTableBorderDark, akEditorTableToolbar, akEditorTableToolbarDark, akEditorTableToolbarSize, akEditorUnitZIndex, akRichMediaResizeZIndex } from '@atlaskit/editor-shared-styles';
4
- import { token } from '@atlaskit/tokens';
5
4
  import { RESIZE_HANDLE_AREA_DECORATION_GAP } from '../types';
6
5
  import { themed } from '@atlaskit/theme/components';
7
6
  /**
@@ -11,29 +10,29 @@ import { themed } from '@atlaskit/theme/components';
11
10
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
12
11
 
13
12
  export const tableCellBackgroundColor = themed({
14
- light: token('elevation.surface', N0),
15
- dark: token('elevation.surface', DN30)
13
+ light: `var(--ds-surface, ${N0})`,
14
+ dark: `var(--ds-surface, ${DN30})`
16
15
  });
17
16
  export const tableToolbarColor = themed({
18
- light: token('color.background.neutral.subtle', akEditorTableToolbar),
19
- dark: token('color.background.neutral.subtle', akEditorTableToolbarDark)
17
+ light: `var(--ds-background-neutral-subtle, ${akEditorTableToolbar})`,
18
+ dark: `var(--ds-background-neutral-subtle, ${akEditorTableToolbarDark})`
20
19
  });
21
20
  export const tableTextColor = themed({
22
- light: token('color.text.subtlest', N200),
23
- dark: token('color.text.subtlest', DN400)
21
+ light: `var(--ds-text-subtlest, ${N200})`,
22
+ dark: `var(--ds-text-subtlest, ${DN400})`
24
23
  });
25
24
  export const tableBorderColor = themed({
26
- light: token('color.border', akEditorTableBorder),
27
- dark: token('color.border', akEditorTableBorderDark)
25
+ light: `var(--ds-border, ${akEditorTableBorder})`,
26
+ dark: `var(--ds-border, ${akEditorTableBorderDark})`
28
27
  });
29
- export const tableFloatingControlsColor = token('color.background.neutral', N20); // TODO: https://product-fabric.atlassian.net/browse/DSP-4461
28
+ export const tableFloatingControlsColor = `var(--ds-background-neutral, ${N20})`; // TODO: https://product-fabric.atlassian.net/browse/DSP-4461
30
29
 
31
- export const tableCellSelectedColor = token('color.blanket.selected', 'rgba(179, 212, 255, 0.3)');
32
- export const tableToolbarSelectedColor = token('color.background.selected.bold', B200);
33
- export const tableBorderSelectedColor = token('color.border.selected', B300);
34
- export const tableCellDeleteColor = token('color.blanket.danger', 'rgba(255, 235, 230, 0.3)');
35
- export const tableBorderDeleteColor = token('color.border.danger', R400);
36
- export const tableToolbarDeleteColor = token('color.background.danger.bold', R75);
30
+ export const tableCellSelectedColor = "var(--ds-blanket-selected, rgba(179, 212, 255, 0.3))";
31
+ export const tableToolbarSelectedColor = `var(--ds-background-selected-bold, ${B200})`;
32
+ export const tableBorderSelectedColor = `var(--ds-border-selected, ${B300})`;
33
+ export const tableCellDeleteColor = "var(--ds-blanket-danger, rgba(255, 235, 230, 0.3))";
34
+ export const tableBorderDeleteColor = `var(--ds-border-danger, ${R400})`;
35
+ export const tableToolbarDeleteColor = `var(--ds-background-danger-bold, ${R75})`;
37
36
  export const tableBorderRadiusSize = 3;
38
37
  export const tablePadding = 8;
39
38
  export const tableScrollbarOffset = 15;
@@ -5,7 +5,6 @@ import { N40A, B300, N300, R300, N20A, N60A, N0, Y50, Y200 } from '@atlaskit/the
5
5
  import { tableToolbarColor, tableBorderColor, tableToolbarSelectedColor, tableBorderSelectedColor, tableCellDeleteColor, tableBorderDeleteColor, tableToolbarDeleteColor, lineMarkerSize, columnControlsDecorationHeight, columnControlsZIndex, columnControlsSelectedZIndex, resizeHandlerAreaWidth, resizeLineWidth, resizeHandlerZIndex, tableToolbarSize, tableInsertColumnButtonSize, tableDeleteButtonSize } from './consts';
6
6
  import { TableCssClassName as ClassName } from '../types';
7
7
  import { borderRadius } from '@atlaskit/theme/constants';
8
- import { token } from '@atlaskit/tokens';
9
8
 
10
9
  const InsertLine = cssString => css`
11
10
  .${ClassName.CONTROLS_INSERT_LINE} {
@@ -81,22 +80,22 @@ export const HeaderButton = (props, cssString) => css`
81
80
  }
82
81
 
83
82
  .active .${ClassName.CONTROLS_BUTTON} {
84
- color: ${token('color.icon.inverse', N0)};
85
- background-color: ${token('color.background.selected', tableToolbarSelectedColor)};
83
+ color: ${`var(--ds-icon-inverse, ${N0})`};
84
+ background-color: ${`var(--ds-background-selected, ${tableToolbarSelectedColor})`};
86
85
  border-color: ${tableBorderSelectedColor};
87
86
  }
88
87
  `;
89
88
  export const HeaderButtonHover = () => css`
90
89
  .${ClassName.CONTROLS_BUTTON}:hover {
91
- color: ${token('color.icon.inverse', N0)};
92
- background-color: ${token('color.background.selected', tableToolbarSelectedColor)};
90
+ color: ${`var(--ds-icon-inverse, ${N0})`};
91
+ background-color: ${`var(--ds-background-selected, ${tableToolbarSelectedColor})`};
93
92
  border-color: ${tableBorderSelectedColor};
94
93
  cursor: pointer;
95
94
  }
96
95
  `;
97
96
  export const HeaderButtonDanger = () => css`
98
97
  .${ClassName.HOVERED_CELL_IN_DANGER} .${ClassName.CONTROLS_BUTTON} {
99
- background-color: ${token('color.background.danger', tableToolbarDeleteColor)};
98
+ background-color: ${`var(--ds-background-danger, ${tableToolbarDeleteColor})`};
100
99
  border-color: ${tableBorderDeleteColor};
101
100
  position: relative;
102
101
  z-index: ${akEditorUnitZIndex};
@@ -116,9 +115,9 @@ const InsertButton = () => css`
116
115
  }
117
116
  .${ClassName.CONTROLS_INSERT_BUTTON} {
118
117
  ${Button(`
119
- background: ${token('elevation.surface.overlay', 'white')};
120
- box-shadow: ${token('elevation.shadow.overlay', `0 4px 8px -2px ${N60A}, 0 0 1px ${N60A}`)};
121
- color: ${token('color.icon', N300)};
118
+ background: ${"var(--ds-surface-overlay, white)"};
119
+ box-shadow: ${`var(--ds-shadow-overlay, ${`0 4px 8px -2px ${N60A}, 0 0 1px ${N60A}`})`};
120
+ color: ${`var(--ds-icon, ${N300})`};
122
121
  `)}
123
122
  }
124
123
  .${ClassName.CONTROLS_INSERT_LINE} {
@@ -131,8 +130,8 @@ const InsertButton = () => css`
131
130
 
132
131
  const InsertButtonHover = () => css`
133
132
  .${ClassName.CONTROLS_INSERT_BUTTON}:hover {
134
- background: ${token('color.background.brand.bold', B300)};
135
- color: ${token('color.icon.inverse', 'white')};
133
+ background: ${`var(--ds-background-brand-bold, ${B300})`};
134
+ color: ${"var(--ds-icon-inverse, white)"};
136
135
  cursor: pointer;
137
136
  }
138
137
  `;
@@ -175,15 +174,15 @@ export const DeleteButton = css`
175
174
  .${ClassName.CONTROLS_DELETE_BUTTON_WRAP} {
176
175
  .${ClassName.CONTROLS_DELETE_BUTTON} {
177
176
  ${Button(`
178
- background: ${token('color.background.neutral', N20A)};
179
- color: ${token('color.icon', N300)};
177
+ background: ${`var(--ds-background-neutral, ${N20A})`};
178
+ color: ${`var(--ds-icon, ${N300})`};
180
179
  `)}
181
180
  }
182
181
  }
183
182
 
184
183
  .${ClassName.CONTROLS_DELETE_BUTTON}:hover {
185
- background: ${token('color.background.danger.bold', R300)};
186
- color: ${token('color.icon.inverse', 'white')};
184
+ background: ${`var(--ds-background-danger-bold, ${R300})`};
185
+ color: ${"var(--ds-icon-inverse, white)"};
187
186
  cursor: pointer;
188
187
  }
189
188
  `;
@@ -201,11 +200,11 @@ export const OverflowShadow = props => css`
201
200
  background: linear-gradient(
202
201
  to left,
203
202
  transparent 0,
204
- ${token('elevation.shadow.overflow.spread', N40A)} 100%
203
+ ${`var(--ds-shadow-overflow-spread, ${N40A})`} 100%
205
204
  ),
206
205
  linear-gradient(
207
206
  to right,
208
- ${token('elevation.shadow.overflow.perimeter', 'transparent')} 0px,
207
+ ${"var(--ds-shadow-overflow-perimeter, transparent)"} 0px,
209
208
  transparent 1px
210
209
  );
211
210
  left: 0px;
@@ -217,11 +216,11 @@ export const OverflowShadow = props => css`
217
216
  background: linear-gradient(
218
217
  to right,
219
218
  transparent 0,
220
- ${token('elevation.shadow.overflow.spread', N40A)} 100%
219
+ ${`var(--ds-shadow-overflow-spread, ${N40A})`} 100%
221
220
  ),
222
221
  linear-gradient(
223
222
  to left,
224
- ${token('elevation.shadow.overflow.perimeter', 'transparent')} 0px,
223
+ ${"var(--ds-shadow-overflow-perimeter, transparent)"} 0px,
225
224
  transparent 1px
226
225
  );
227
226
  left: calc(100% + 2px);
@@ -252,8 +251,8 @@ const columnHeaderButton = (props, cssString) => css`
252
251
  `;
253
252
 
254
253
  const columnHeaderButtonSelected = css`
255
- color: ${token('color.text.inverse', N0)};
256
- background-color: ${token('color.background.selected', tableToolbarSelectedColor)};
254
+ color: ${`var(--ds-text-inverse, ${N0})`};
255
+ background-color: ${`var(--ds-background-selected, ${tableToolbarSelectedColor})`};
257
256
  border-color: ${tableBorderSelectedColor};
258
257
  z-index: ${columnControlsSelectedZIndex};
259
258
  `;
@@ -326,7 +325,7 @@ export const columnControlsDecoration = props => css`
326
325
 
327
326
  &.${ClassName.HOVERED_CELL_IN_DANGER}
328
327
  .${ClassName.COLUMN_CONTROLS_DECORATIONS}::after {
329
- background-color: ${token('color.background.danger', tableToolbarDeleteColor)};
328
+ background-color: ${`var(--ds-background-danger, ${tableToolbarDeleteColor})`};
330
329
  border: 1px solid ${tableBorderDeleteColor};
331
330
  border-bottom: none;
332
331
  z-index: ${akEditorUnitZIndex * 100};
@@ -372,8 +371,8 @@ export const hoveredWarningCell = css`
372
371
  :not(.${ClassName.IS_RESIZING})
373
372
  .${ClassName.TABLE_CONTAINER}:not(.${ClassName.HOVERED_DELETE_BUTTON}) {
374
373
  td.${ClassName.HOVERED_CELL_WARNING} {
375
- background-color: ${token('color.background.warning', Y50)} !important; // We need to override the background-color added to the cell
376
- border: 1px solid ${token('color.border.warning', Y200)};
374
+ background-color: ${`var(--ds-background-warning, ${Y50})`} !important; // We need to override the background-color added to the cell
375
+ border: 1px solid ${`var(--ds-border-warning, ${Y200})`};
377
376
  }
378
377
  }
379
378
  `;
@@ -1,4 +1,4 @@
1
- import { TableMap } from '@atlaskit/editor-tables/table-map';
1
+ import { Rect, TableMap } from '@atlaskit/editor-tables/table-map';
2
2
  import { findTable, getCellsInRow, getSelectionRect } from '@atlaskit/editor-tables/utils';
3
3
  import { Decoration } from 'prosemirror-view';
4
4
  import { nonNullable } from '@atlaskit/editor-common/utils';
@@ -43,7 +43,37 @@ export const createControlsHoverDecoration = (cells, type, tr, danger, selected)
43
43
  // to match the "clicked" selection
44
44
 
45
45
  if (danger) {
46
- const rect = map.rectBetween(min - table.start, max - table.start);
46
+ // Find the bounding rectangle of all the given cells, also considering
47
+ // merged cells.
48
+ const {
49
+ recLeft,
50
+ recTop,
51
+ recRight,
52
+ recBottom
53
+ } = cells.reduce((acc, cell) => {
54
+ const {
55
+ left,
56
+ right,
57
+ bottom,
58
+ top
59
+ } = map.findCell(cell.pos - table.start); // Finding the bounding rect requires finding the min left and top positions,
60
+ // and the max right and bottom positions of the cells
61
+
62
+ return {
63
+ recLeft: Math.min(acc.recLeft, left),
64
+ recTop: Math.min(acc.recTop, top),
65
+ recRight: Math.max(acc.recRight, right),
66
+ recBottom: Math.max(acc.recBottom, bottom)
67
+ };
68
+ }, // +-Infinity as initialisation vars which will always be overwritten
69
+ // by smaller/larger values respectively
70
+ {
71
+ recLeft: Infinity,
72
+ recTop: Infinity,
73
+ recRight: -Infinity,
74
+ recBottom: -Infinity
75
+ });
76
+ const rect = new Rect(recLeft, recTop, recRight, recBottom);
47
77
  updatedCells = map.cellsInRect(rect).map(x => x + table.start);
48
78
  }
49
79
 
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "sideEffects": false
5
5
  }
@@ -5,7 +5,7 @@ import { jsx } from '@emotion/react';
5
5
  import { defineMessages } from 'react-intl-next';
6
6
  import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
7
7
  import commonMessages from '@atlaskit/editor-common/messages';
8
- import { clearHoverSelection, hoverTable, hoverColumns, hoverRows, removeDescendantNodes } from './commands';
8
+ import { clearHoverSelection, hoverTable, hoverColumns, hoverRows, removeDescendantNodes, hoverMergedCells } from './commands';
9
9
  import { deleteTableWithAnalytics, toggleHeaderColumnWithAnalytics, toggleHeaderRowWithAnalytics, toggleNumberColumnWithAnalytics, insertRowWithAnalytics, deleteRowsWithAnalytics, mergeCellsWithAnalytics, splitCellWithAnalytics, deleteColumnsWithAnalytics, emptyMultipleCellsWithAnalytics, insertColumnWithAnalytics, wrapTableInExpandWithAnalytics, sortColumnWithAnalytics, setColorWithAnalytics, distributeColumnsWidthsWithAnalytics } from './commands-with-analytics';
10
10
  import { getPluginState } from './pm-plugins/plugin-factory';
11
11
  import { pluginKey as tableResizingPluginKey } from './pm-plugins/table-resizing';
@@ -229,6 +229,18 @@ export var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(ed
229
229
  options.push({
230
230
  id: 'editor.table.sortColumnAsc',
231
231
  title: formatMessage(ContextualMenuMessages.sortColumnASC),
232
+ onMouseOver: function onMouseOver(state, dispatch) {
233
+ if (getMergedCellsPositions(state.tr).length !== 0) {
234
+ hoverMergedCells()(state, dispatch);
235
+ return true;
236
+ }
237
+
238
+ return false;
239
+ },
240
+ onMouseOut: function onMouseOut(state, dispatch) {
241
+ clearHoverSelection()(state, dispatch);
242
+ return true;
243
+ },
232
244
  onClick: function onClick(state, dispatch) {
233
245
  sortColumnWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB, initialSelectionRect.left, SortOrder.ASC)(state, dispatch);
234
246
  return true;
@@ -240,6 +252,18 @@ export var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(ed
240
252
  options.push({
241
253
  id: 'editor.table.sortColumnDesc',
242
254
  title: formatMessage(ContextualMenuMessages.sortColumnDESC),
255
+ onMouseOver: function onMouseOver(state, dispatch) {
256
+ if (getMergedCellsPositions(state.tr).length !== 0) {
257
+ hoverMergedCells()(state, dispatch);
258
+ return true;
259
+ }
260
+
261
+ return false;
262
+ },
263
+ onMouseOut: function onMouseOut(state, dispatch) {
264
+ clearHoverSelection()(state, dispatch);
265
+ return true;
266
+ },
243
267
  onClick: function onClick(state, dispatch) {
244
268
  sortColumnWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB, initialSelectionRect.left, SortOrder.DESC)(state, dispatch);
245
269
  return true;
@@ -6,29 +6,28 @@ import { css } from '@emotion/react';
6
6
  import { B75, DN0, DN60, N0, N20, N30A, N700 } from '@atlaskit/theme/colors';
7
7
  import { borderRadius } from '@atlaskit/theme/constants';
8
8
  import { contextualMenuTriggerSize } from '../consts';
9
- import { token } from '@atlaskit/tokens';
10
9
  import { themed } from '@atlaskit/theme/components';
11
10
  export var tableFloatingCellButtonStyles = function tableFloatingCellButtonStyles(props) {
12
- return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n > div {\n // Sits behind button to provide surface-color background\n background: ", ";\n border-radius: ", "px;\n display: flex;\n height: ", "px;\n flex-direction: column;\n }\n && button {\n background: ", ";\n flex-direction: column;\n margin: 2px;\n outline: 2px solid ", ";\n border-radius: 1px;\n padding: 0;\n height: calc(100% - 4px);\n display: flex;\n }\n && button:hover {\n background: ", ";\n }\n && button:active {\n background: ", ";\n }\n && button > span {\n margin: 0px -4px;\n }\n && span {\n pointer-events: none;\n }\n"])), token('elevation.surface', N20), borderRadius(), contextualMenuTriggerSize + 2, themed({
13
- light: token('color.background.neutral', 'none'),
14
- dark: token('color.background.neutral', 'none')
15
- })(props), token('color.border', N0), themed({
16
- light: token('color.background.neutral.hovered', N30A),
17
- dark: token('color.background.neutral.hovered', DN60)
11
+ return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n > div {\n // Sits behind button to provide surface-color background\n background: ", ";\n border-radius: ", "px;\n display: flex;\n height: ", "px;\n flex-direction: column;\n }\n && button {\n background: ", ";\n flex-direction: column;\n margin: 2px;\n outline: 2px solid ", ";\n border-radius: 1px;\n padding: 0;\n height: calc(100% - 4px);\n display: flex;\n }\n && button:hover {\n background: ", ";\n }\n && button:active {\n background: ", ";\n }\n && button > span {\n margin: 0px -4px;\n }\n && span {\n pointer-events: none;\n }\n"])), "var(--ds-surface, ".concat(N20, ")"), borderRadius(), contextualMenuTriggerSize + 2, themed({
12
+ light: "var(--ds-background-neutral, none)",
13
+ dark: "var(--ds-background-neutral, none)"
14
+ })(props), "var(--ds-border, ".concat(N0, ")"), themed({
15
+ light: "var(--ds-background-neutral-hovered, ".concat(N30A, ")"),
16
+ dark: "var(--ds-background-neutral-hovered, ".concat(DN60, ")")
18
17
  })(props), themed({
19
- light: token('color.background.neutral.pressed', 'rgba(179, 212, 255, 0.6)'),
20
- dark: token('color.background.neutral.pressed', B75)
18
+ light: "var(--ds-background-neutral-pressed, rgba(179, 212, 255, 0.6))",
19
+ dark: "var(--ds-background-neutral-pressed, ".concat(B75, ")")
21
20
  })(props));
22
21
  };
23
22
  export var tableFloatingCellButtonSelectedStyles = function tableFloatingCellButtonSelectedStyles(props) {
24
23
  return css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n && button {\n background: ", ";\n }\n && button:hover {\n background: ", ";\n }\n && button:active {\n background: ", ";\n }\n"])), themed({
25
- light: token('color.background.selected', N700),
26
- dark: token('color.background.selected', DN0)
24
+ light: "var(--ds-background-selected, ".concat(N700, ")"),
25
+ dark: "var(--ds-background-selected, ".concat(DN0, ")")
27
26
  })(props), themed({
28
- light: token('color.background.selected.hovered', N700),
29
- dark: token('color.background.selected.hovered', DN0)
27
+ light: "var(--ds-background-selected-hovered, ".concat(N700, ")"),
28
+ dark: "var(--ds-background-selected-hovered, ".concat(DN0, ")")
30
29
  })(props), themed({
31
- light: token('color.background.selected.pressed', N700),
32
- dark: token('color.background.selected.pressed', DN0)
30
+ light: "var(--ds-background-selected-pressed, ".concat(N700, ")"),
31
+ dark: "var(--ds-background-selected-pressed, ".concat(DN0, ")")
33
32
  })(props));
34
33
  };
@@ -8,8 +8,7 @@ import { N60A, N90 } from '@atlaskit/theme/colors';
8
8
  import { contextualMenuDropdownWidth } from '../consts';
9
9
  import { TableCssClassName as ClassName } from '../../types';
10
10
  import { borderRadius } from '@atlaskit/theme/constants';
11
- import { token } from '@atlaskit/tokens';
12
11
  export var cellColourPreviewStyles = function cellColourPreviewStyles(selectedColor) {
13
12
  return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n &::before {\n background: ", ";\n }\n"])), selectedColor);
14
13
  };
15
- export var tablePopupStyles = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n .", " {\n border-radius: ", "px;\n background: ", ";\n box-shadow: ", ";\n display: block;\n position: absolute;\n top: 0;\n left: ", "px;\n padding: 8px;\n\n > div {\n padding: 0;\n }\n }\n\n .", " {\n display: flex;\n\n &::before {\n content: '';\n display: block;\n border: 1px solid ", ";\n border-radius: ", "px;\n width: 20px;\n height: 20px;\n }\n\n &::after {\n content: '\u203A';\n margin-left: 4px;\n line-height: 20px;\n color: ", ";\n }\n }\n"])), ClassName.CONTEXTUAL_SUBMENU, borderRadius(), token('elevation.surface.overlay', 'white'), token('elevation.shadow.overlay', "0 4px 8px -2px ".concat(N60A, ", 0 0 1px ").concat(N60A)), contextualMenuDropdownWidth, ClassName.CONTEXTUAL_MENU_ICON, tableBackgroundBorderColor, borderRadius(), token('color.icon', N90));
14
+ export var tablePopupStyles = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n .", " {\n border-radius: ", "px;\n background: ", ";\n box-shadow: ", ";\n display: block;\n position: absolute;\n top: 0;\n left: ", "px;\n padding: 8px;\n\n > div {\n padding: 0;\n }\n }\n\n .", " {\n display: flex;\n\n &::before {\n content: '';\n display: block;\n border: 1px solid ", ";\n border-radius: ", "px;\n width: 20px;\n height: 20px;\n }\n\n &::after {\n content: '\u203A';\n margin-left: 4px;\n line-height: 20px;\n color: ", ";\n }\n }\n"])), ClassName.CONTEXTUAL_SUBMENU, borderRadius(), "var(--ds-surface-overlay, white)", "var(--ds-shadow-overlay, ".concat("0 4px 8px -2px ".concat(N60A, ", 0 0 1px ").concat(N60A), ")"), contextualMenuDropdownWidth, ClassName.CONTEXTUAL_MENU_ICON, tableBackgroundBorderColor, borderRadius(), "var(--ds-icon, ".concat(N90, ")"));