@atlaskit/editor-plugin-table 5.4.7 → 5.4.9

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 (60) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/plugins/table/commands/misc.js +14 -12
  3. package/dist/cjs/plugins/table/nodeviews/TableComponent.js +2 -4
  4. package/dist/cjs/plugins/table/pm-plugins/decorations/plugin.js +9 -3
  5. package/dist/cjs/plugins/table/pm-plugins/decorations/utils/column-controls.js +8 -3
  6. package/dist/cjs/plugins/table/types.js +2 -1
  7. package/dist/cjs/plugins/table/ui/FloatingDragMenu/DragMenu.js +3 -1
  8. package/dist/cjs/plugins/table/ui/TableFloatingControls/index.js +4 -1
  9. package/dist/cjs/plugins/table/ui/common-styles.js +6 -9
  10. package/dist/cjs/plugins/table/ui/ui-styles.js +12 -16
  11. package/dist/cjs/plugins/table/utils/decoration.js +20 -25
  12. package/dist/cjs/plugins/table/utils/drag-menu.js +2 -2
  13. package/dist/es2019/plugins/table/commands/misc.js +5 -4
  14. package/dist/es2019/plugins/table/nodeviews/TableComponent.js +2 -4
  15. package/dist/es2019/plugins/table/pm-plugins/decorations/plugin.js +9 -3
  16. package/dist/es2019/plugins/table/pm-plugins/decorations/utils/column-controls.js +8 -3
  17. package/dist/es2019/plugins/table/types.js +2 -1
  18. package/dist/es2019/plugins/table/ui/FloatingDragMenu/DragMenu.js +4 -2
  19. package/dist/es2019/plugins/table/ui/TableFloatingControls/index.js +4 -1
  20. package/dist/es2019/plugins/table/ui/common-styles.js +20 -20
  21. package/dist/es2019/plugins/table/ui/ui-styles.js +18 -21
  22. package/dist/es2019/plugins/table/utils/decoration.js +20 -25
  23. package/dist/es2019/plugins/table/utils/drag-menu.js +2 -2
  24. package/dist/esm/plugins/table/commands/misc.js +13 -13
  25. package/dist/esm/plugins/table/nodeviews/TableComponent.js +2 -4
  26. package/dist/esm/plugins/table/pm-plugins/decorations/plugin.js +9 -3
  27. package/dist/esm/plugins/table/pm-plugins/decorations/utils/column-controls.js +8 -3
  28. package/dist/esm/plugins/table/types.js +2 -1
  29. package/dist/esm/plugins/table/ui/FloatingDragMenu/DragMenu.js +4 -2
  30. package/dist/esm/plugins/table/ui/TableFloatingControls/index.js +4 -1
  31. package/dist/esm/plugins/table/ui/common-styles.js +6 -9
  32. package/dist/esm/plugins/table/ui/ui-styles.js +12 -16
  33. package/dist/esm/plugins/table/utils/decoration.js +20 -25
  34. package/dist/esm/plugins/table/utils/drag-menu.js +2 -2
  35. package/dist/types/plugins/table/pm-plugins/decorations/utils/column-controls.d.ts +3 -2
  36. package/dist/types/plugins/table/pm-plugins/decorations/utils/compose-decorations.d.ts +1 -1
  37. package/dist/types/plugins/table/pm-plugins/decorations/utils/types.d.ts +10 -4
  38. package/dist/types/plugins/table/types.d.ts +2 -1
  39. package/dist/types/plugins/table/utils/drag-menu.d.ts +1 -1
  40. package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/utils/column-controls.d.ts +3 -2
  41. package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/utils/compose-decorations.d.ts +1 -1
  42. package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/utils/types.d.ts +10 -4
  43. package/dist/types-ts4.5/plugins/table/types.d.ts +2 -1
  44. package/dist/types-ts4.5/plugins/table/utils/drag-menu.d.ts +1 -1
  45. package/package.json +1 -1
  46. package/src/__tests__/unit/event-handlers.ts +37 -38
  47. package/src/__tests__/unit/pm-plugins/decorations/column-controls.ts +46 -36
  48. package/src/plugins/table/commands/misc.ts +9 -7
  49. package/src/plugins/table/nodeviews/TableComponent.tsx +20 -22
  50. package/src/plugins/table/pm-plugins/decorations/plugin.ts +7 -2
  51. package/src/plugins/table/pm-plugins/decorations/utils/column-controls.ts +20 -11
  52. package/src/plugins/table/pm-plugins/decorations/utils/compose-decorations.ts +2 -4
  53. package/src/plugins/table/pm-plugins/decorations/utils/types.ts +14 -7
  54. package/src/plugins/table/types.ts +2 -1
  55. package/src/plugins/table/ui/FloatingDragMenu/DragMenu.tsx +12 -1
  56. package/src/plugins/table/ui/TableFloatingControls/index.tsx +73 -67
  57. package/src/plugins/table/ui/common-styles.ts +20 -23
  58. package/src/plugins/table/ui/ui-styles.ts +18 -21
  59. package/src/plugins/table/utils/decoration.ts +27 -32
  60. package/src/plugins/table/utils/drag-menu.ts +8 -2
@@ -265,26 +265,6 @@ const tableStickyHeaderFirefoxFixStyle = (
265
265
  }
266
266
  };
267
267
 
268
- const tableRowControlStyles = () => {
269
- return getBooleanFF('platform.editor.table.drag-and-drop')
270
- ? css`
271
- .${ClassName.ROW_CONTROLS_WRAPPER} {
272
- position: absolute;
273
- margin-top: ${tableMarginTop}px;
274
- left: -${tableToolbarSize + 1}px;
275
- z-index: ${rowControlsZIndex + 4};
276
- }
277
- `
278
- : css`
279
- .${ClassName.ROW_CONTROLS_WRAPPER} {
280
- position: absolute;
281
- /* top of corner control is table margin top - corner control height + 1 pixel of table border. */
282
- top: ${tableMarginTop - cornerControlHeight + 1}px;
283
- left: -${tableToolbarSize}px;
284
- }
285
- `;
286
- };
287
-
288
268
  const tableWrapperStyles = () => {
289
269
  if (getBooleanFF('platform.editor.custom-table-width')) {
290
270
  return css`
@@ -558,7 +538,8 @@ export const tableStyles = (
558
538
  .less-padding {
559
539
  padding: 0 ${tablePadding}px;
560
540
 
561
- .${ClassName.ROW_CONTROLS_WRAPPER} {
541
+ .${ClassName.DRAG_ROW_CONTROLS_WRAPPER},
542
+ .${ClassName.ROW_CONTROLS_WRAPPER} {
562
543
  padding: 0 ${tablePadding}px;
563
544
 
564
545
  // https://product-fabric.atlassian.net/browse/ED-16386
@@ -1056,8 +1037,24 @@ export const tableStyles = (
1056
1037
  }
1057
1038
  }
1058
1039
  }
1059
- ${tableRowControlStyles()}
1060
- .${ClassName.ROW_CONTROLS_WRAPPER}.${ClassName.TABLE_LEFT_SHADOW} {
1040
+
1041
+ // override for DnD controls
1042
+ .${ClassName.DRAG_ROW_CONTROLS_WRAPPER} {
1043
+ position: absolute;
1044
+ margin-top: ${tableMarginTop}px;
1045
+ left: -${tableToolbarSize + 1}px;
1046
+ z-index: ${rowControlsZIndex + 4};
1047
+ }
1048
+
1049
+ .${ClassName.ROW_CONTROLS_WRAPPER} {
1050
+ position: absolute;
1051
+ /* top of corner control is table margin top - corner control height + 1 pixel of table border. */
1052
+ top: ${tableMarginTop - cornerControlHeight + 1}px;
1053
+ left: -${tableToolbarSize}px;
1054
+ }
1055
+
1056
+ .${ClassName.DRAG_ROW_CONTROLS_WRAPPER}.${ClassName.TABLE_LEFT_SHADOW},
1057
+ .${ClassName.ROW_CONTROLS_WRAPPER}.${ClassName.TABLE_LEFT_SHADOW} {
1061
1058
  z-index: ${akEditorUnitZIndex};
1062
1059
  }
1063
1060
 
@@ -500,27 +500,24 @@ export const floatingColumnControls = (props: ThemeProps) => {
500
500
  };
501
501
 
502
502
  export const rowControlsWrapperDotStyle = (props: ThemeProps) => {
503
- if (getBooleanFF('platform.editor.table.drag-and-drop')) {
504
- return css`
505
- div.${ClassName.WITH_CONTROLS}>.${ClassName.ROW_CONTROLS_WRAPPER}::after {
506
- display: none;
507
- }
508
- `;
509
- } else {
510
- return css`
511
- div.${ClassName.WITH_CONTROLS}>.${ClassName.ROW_CONTROLS_WRAPPER}::after {
512
- content: ' ';
513
- background-color: ${tableBorderColor(props)};
514
- position: absolute;
515
- height: ${lineMarkerSize}px;
516
- width: ${lineMarkerSize}px;
517
- border-radius: 50%;
518
- pointer-events: none;
519
- top: -${tableToolbarSize + tableCellBorderWidth}px;
520
- right: -1px;
521
- }
522
- `;
523
- }
503
+ return css`
504
+ // override for DnD controls
505
+ div.${ClassName.WITH_CONTROLS}>.${ClassName.DRAG_ROW_CONTROLS_WRAPPER}::after {
506
+ display: none;
507
+ }
508
+
509
+ div.${ClassName.WITH_CONTROLS}>.${ClassName.ROW_CONTROLS_WRAPPER}::after {
510
+ content: ' ';
511
+ background-color: ${tableBorderColor(props)};
512
+ position: absolute;
513
+ height: ${lineMarkerSize}px;
514
+ width: ${lineMarkerSize}px;
515
+ border-radius: 50%;
516
+ pointer-events: none;
517
+ top: -${tableToolbarSize + tableCellBorderWidth}px;
518
+ right: -1px;
519
+ }
520
+ `;
524
521
  };
525
522
 
526
523
  export const columnControlsDecoration = (props: ThemeProps) => {
@@ -22,7 +22,6 @@ import {
22
22
  getCellsInRow,
23
23
  getSelectionRect,
24
24
  } from '@atlaskit/editor-tables/utils';
25
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
26
25
 
27
26
  import type { Cell, CellColumnPositioning } from '../types';
28
27
  import { TableCssClassName as ClassName, TableDecorations } from '../types';
@@ -219,37 +218,33 @@ export const createColumnControlsDecoration = (
219
218
  ): Decoration[] => {
220
219
  const cells: ContentNodeWithPos[] = getCellsInRow(0)(selection) || [];
221
220
 
222
- if (getBooleanFF('platform.editor.table.drag-and-drop')) {
223
- return [];
224
- } else {
225
- let index = 0;
226
- return cells.map((cell) => {
227
- const colspan = (cell.node.attrs as CellAttributes).colspan || 1;
228
- // It's important these values are scoped locally as the widget callback could be executed anytime in the future
229
- // and we want to avoid value leak
230
- const startIndex = index;
231
- const endIndex = startIndex + colspan;
232
-
233
- // The next cell start index will commence from the current cell end index.
234
- index = endIndex;
235
-
236
- return Decoration.widget(
237
- cell.pos + 1,
238
- () => {
239
- const element = document.createElement('div');
240
- element.classList.add(ClassName.COLUMN_CONTROLS_DECORATIONS);
241
- element.dataset.startIndex = `${startIndex}`;
242
- element.dataset.endIndex = `${endIndex}`;
243
- return element;
244
- },
245
- {
246
- key: `${TableDecorations.COLUMN_CONTROLS_DECORATIONS}_${endIndex}`,
247
- // this decoration should be the first one, even before gap cursor.
248
- side: -100,
249
- },
250
- );
251
- });
252
- }
221
+ let index = 0;
222
+ return cells.map((cell) => {
223
+ const colspan = (cell.node.attrs as CellAttributes).colspan || 1;
224
+ // It's important these values are scoped locally as the widget callback could be executed anytime in the future
225
+ // and we want to avoid value leak
226
+ const startIndex = index;
227
+ const endIndex = startIndex + colspan;
228
+
229
+ // The next cell start index will commence from the current cell end index.
230
+ index = endIndex;
231
+
232
+ return Decoration.widget(
233
+ cell.pos + 1,
234
+ () => {
235
+ const element = document.createElement('div');
236
+ element.classList.add(ClassName.COLUMN_CONTROLS_DECORATIONS);
237
+ element.dataset.startIndex = `${startIndex}`;
238
+ element.dataset.endIndex = `${endIndex}`;
239
+ return element;
240
+ },
241
+ {
242
+ key: `${TableDecorations.COLUMN_CONTROLS_DECORATIONS}_${endIndex}`,
243
+ // this decoration should be the first one, even before gap cursor.
244
+ side: -100,
245
+ },
246
+ );
247
+ });
253
248
  };
254
249
 
255
250
  export const updateDecorations = (
@@ -57,6 +57,7 @@ export interface DragMenuConfig extends DropdownOptionT<Command> {
57
57
  export const getDragMenuConfig = (
58
58
  direction: TableDirection,
59
59
  getEditorContainerWidth: GetEditorContainerWidth,
60
+ hasMergedCells: boolean,
60
61
  tableMap?: TableMap,
61
62
  index?: number,
62
63
  targetCellPosition?: number,
@@ -95,7 +96,12 @@ export const getDragMenuConfig = (
95
96
  const moveOptions =
96
97
  direction === 'row'
97
98
  ? [
98
- { label: 'up', offset: -1, canMove: canDecrease, icon: ArrowUpIcon },
99
+ {
100
+ label: 'up',
101
+ offset: -1,
102
+ canMove: canDecrease,
103
+ icon: ArrowUpIcon,
104
+ },
99
105
  {
100
106
  label: 'down',
101
107
  offset: 1,
@@ -190,7 +196,7 @@ export const getDragMenuConfig = (
190
196
  ...moveOptions.map(({ label, offset, canMove, icon }) => ({
191
197
  id: `move_${direction}_${label}`,
192
198
  title: `Move ${direction} ${label}`,
193
- disabled: !canMove(index),
199
+ disabled: hasMergedCells || !canMove(index),
194
200
  icon,
195
201
  onClick: (state: EditorState, dispatch?: CommandDispatch) => {
196
202
  if (canMove(index)) {