@atlaskit/editor-plugin-table 7.6.4 → 7.6.6

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 (109) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cjs/commands/column-resize.js +62 -16
  3. package/dist/cjs/commands/go-to-next-cell.js +5 -2
  4. package/dist/cjs/commands-with-analytics.js +8 -2
  5. package/dist/cjs/nodeviews/ExternalDropTargets.js +2 -0
  6. package/dist/cjs/nodeviews/TableComponent.js +8 -6
  7. package/dist/cjs/nodeviews/TableResizer.js +2 -1
  8. package/dist/cjs/plugin.js +58 -57
  9. package/dist/cjs/pm-plugins/keymap.js +26 -8
  10. package/dist/cjs/pm-plugins/main.js +15 -4
  11. package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +4 -2
  12. package/dist/cjs/ui/DragHandle/index.js +2 -2
  13. package/dist/cjs/ui/DragPreview/index.js +2 -0
  14. package/dist/cjs/ui/FloatingContextualButton/FixedButton.js +10 -6
  15. package/dist/cjs/ui/FloatingDeleteButton/index.js +2 -0
  16. package/dist/cjs/ui/FloatingInsertButton/InsertButton.js +1 -0
  17. package/dist/cjs/ui/LayoutButton/index.js +2 -0
  18. package/dist/cjs/ui/TableFloatingColumnControls/ColumnControls/index.js +2 -0
  19. package/dist/cjs/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.js +3 -0
  20. package/dist/cjs/ui/TableFloatingControls/CornerControls/ClassicCornerControls.js +1 -0
  21. package/dist/cjs/ui/TableFloatingControls/NumberColumn/index.js +1 -0
  22. package/dist/cjs/ui/TableFloatingControls/RowControls/ClassicControls.js +4 -0
  23. package/dist/cjs/ui/TableFloatingControls/RowControls/DragControls.js +3 -1
  24. package/dist/cjs/ui/common-styles.js +4 -0
  25. package/dist/cjs/ui/ui-styles.js +93 -37
  26. package/dist/es2019/commands/column-resize.js +53 -4
  27. package/dist/es2019/commands/go-to-next-cell.js +5 -2
  28. package/dist/es2019/commands-with-analytics.js +8 -2
  29. package/dist/es2019/nodeviews/ExternalDropTargets.js +2 -0
  30. package/dist/es2019/nodeviews/TableComponent.js +9 -7
  31. package/dist/es2019/nodeviews/TableResizer.js +2 -1
  32. package/dist/es2019/plugin.js +4 -2
  33. package/dist/es2019/pm-plugins/keymap.js +25 -9
  34. package/dist/es2019/pm-plugins/main.js +15 -4
  35. package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +4 -2
  36. package/dist/es2019/ui/DragHandle/index.js +2 -2
  37. package/dist/es2019/ui/DragPreview/index.js +2 -0
  38. package/dist/es2019/ui/FloatingContextualButton/FixedButton.js +10 -6
  39. package/dist/es2019/ui/FloatingDeleteButton/index.js +2 -0
  40. package/dist/es2019/ui/FloatingInsertButton/InsertButton.js +1 -0
  41. package/dist/es2019/ui/LayoutButton/index.js +2 -0
  42. package/dist/es2019/ui/TableFloatingColumnControls/ColumnControls/index.js +2 -0
  43. package/dist/es2019/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.js +3 -0
  44. package/dist/es2019/ui/TableFloatingControls/CornerControls/ClassicCornerControls.js +1 -0
  45. package/dist/es2019/ui/TableFloatingControls/NumberColumn/index.js +1 -0
  46. package/dist/es2019/ui/TableFloatingControls/RowControls/ClassicControls.js +4 -0
  47. package/dist/es2019/ui/TableFloatingControls/RowControls/DragControls.js +3 -1
  48. package/dist/es2019/ui/common-styles.js +4 -0
  49. package/dist/es2019/ui/ui-styles.js +66 -70
  50. package/dist/esm/commands/column-resize.js +62 -16
  51. package/dist/esm/commands/go-to-next-cell.js +5 -2
  52. package/dist/esm/commands-with-analytics.js +8 -2
  53. package/dist/esm/nodeviews/ExternalDropTargets.js +2 -0
  54. package/dist/esm/nodeviews/TableComponent.js +9 -7
  55. package/dist/esm/nodeviews/TableResizer.js +2 -1
  56. package/dist/esm/plugin.js +58 -57
  57. package/dist/esm/pm-plugins/keymap.js +26 -8
  58. package/dist/esm/pm-plugins/main.js +15 -4
  59. package/dist/esm/pm-plugins/table-resizing/event-handlers.js +4 -2
  60. package/dist/esm/ui/DragHandle/index.js +2 -2
  61. package/dist/esm/ui/DragPreview/index.js +2 -0
  62. package/dist/esm/ui/FloatingContextualButton/FixedButton.js +10 -6
  63. package/dist/esm/ui/FloatingDeleteButton/index.js +2 -0
  64. package/dist/esm/ui/FloatingInsertButton/InsertButton.js +1 -0
  65. package/dist/esm/ui/LayoutButton/index.js +2 -0
  66. package/dist/esm/ui/TableFloatingColumnControls/ColumnControls/index.js +2 -0
  67. package/dist/esm/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.js +3 -0
  68. package/dist/esm/ui/TableFloatingControls/CornerControls/ClassicCornerControls.js +1 -0
  69. package/dist/esm/ui/TableFloatingControls/NumberColumn/index.js +1 -0
  70. package/dist/esm/ui/TableFloatingControls/RowControls/ClassicControls.js +4 -0
  71. package/dist/esm/ui/TableFloatingControls/RowControls/DragControls.js +3 -1
  72. package/dist/esm/ui/common-styles.js +4 -0
  73. package/dist/esm/ui/ui-styles.js +93 -37
  74. package/dist/types/commands/column-resize.d.ts +23 -4
  75. package/dist/types/commands/go-to-next-cell.d.ts +2 -1
  76. package/dist/types/commands-with-analytics.d.ts +2 -1
  77. package/dist/types/pm-plugins/keymap.d.ts +3 -1
  78. package/dist/types/types.d.ts +7 -0
  79. package/dist/types-ts4.5/commands/column-resize.d.ts +23 -4
  80. package/dist/types-ts4.5/commands/go-to-next-cell.d.ts +2 -1
  81. package/dist/types-ts4.5/commands-with-analytics.d.ts +2 -1
  82. package/dist/types-ts4.5/pm-plugins/keymap.d.ts +3 -1
  83. package/dist/types-ts4.5/types.d.ts +7 -0
  84. package/package.json +4 -4
  85. package/src/commands/column-resize.ts +105 -29
  86. package/src/commands/go-to-next-cell.ts +10 -2
  87. package/src/commands-with-analytics.ts +11 -5
  88. package/src/nodeviews/ExternalDropTargets.tsx +2 -0
  89. package/src/nodeviews/TableComponent.tsx +14 -16
  90. package/src/nodeviews/TableResizer.tsx +2 -1
  91. package/src/plugin.tsx +3 -1
  92. package/src/pm-plugins/keymap.ts +44 -6
  93. package/src/pm-plugins/main.ts +18 -4
  94. package/src/pm-plugins/table-resizing/event-handlers.ts +6 -2
  95. package/src/types.ts +8 -0
  96. package/src/ui/DragHandle/index.tsx +2 -2
  97. package/src/ui/DragPreview/index.tsx +2 -0
  98. package/src/ui/FloatingContextualButton/FixedButton.tsx +9 -6
  99. package/src/ui/FloatingDeleteButton/index.tsx +2 -0
  100. package/src/ui/FloatingInsertButton/InsertButton.tsx +1 -0
  101. package/src/ui/LayoutButton/index.tsx +2 -0
  102. package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +2 -0
  103. package/src/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.tsx +3 -0
  104. package/src/ui/TableFloatingControls/CornerControls/ClassicCornerControls.tsx +1 -0
  105. package/src/ui/TableFloatingControls/NumberColumn/index.tsx +1 -0
  106. package/src/ui/TableFloatingControls/RowControls/ClassicControls.tsx +4 -0
  107. package/src/ui/TableFloatingControls/RowControls/DragControls.tsx +5 -1
  108. package/src/ui/common-styles.ts +2 -0
  109. package/src/ui/ui-styles.ts +90 -79
@@ -125,7 +125,9 @@ class LayoutButton extends React.Component<Props & WrappedComponentProps, any> {
125
125
  aria-label={title}
126
126
  style={{
127
127
  position: 'fixed',
128
+ // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
128
129
  top: pos.top + 22,
130
+ // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
129
131
  left: tablePos.right,
130
132
  }}
131
133
  >
@@ -304,7 +304,9 @@ export const ColumnControls = ({
304
304
  data-testid="table-floating-column-controls"
305
305
  style={{
306
306
  gridTemplateColumns: widths,
307
+ // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
307
308
  marginTop,
309
+ // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
308
310
  width: stickyTop ? containerWidth : undefined,
309
311
  overflowX: stickyTop ? 'hidden' : 'visible',
310
312
  pointerEvents: isDragging ? 'none' : undefined,
@@ -95,8 +95,11 @@ export const ColumnDropTarget = ({
95
95
  <div
96
96
  ref={dropTargetRef}
97
97
  style={{
98
+ // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
98
99
  width: width && `${width - 1}px`,
100
+ // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
99
101
  height: height && `${height}px`,
102
+ // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
100
103
  marginTop: marginTop && `${marginTop}px`,
101
104
  pointerEvents: 'auto',
102
105
  flexShrink: 0,
@@ -41,6 +41,7 @@ class CornerControlComponent extends Component<
41
41
  sticky: this.props.stickyTop !== undefined,
42
42
  })}
43
43
  style={{
44
+ // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
44
45
  top:
45
46
  this.props.stickyTop !== undefined
46
47
  ? `${this.props.stickyTop}px`
@@ -41,6 +41,7 @@ export default class NumberColumn extends Component<Props, any> {
41
41
  <div
42
42
  className={ClassName.NUMBERED_COLUMN}
43
43
  style={{
44
+ // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
44
45
  marginTop:
45
46
  hasHeaderRow && this.props.stickyTop !== undefined
46
47
  ? rowHeights[0]
@@ -82,11 +82,15 @@ class RowControlsComponent extends Component<Props & WrappedComponentProps> {
82
82
  )} ${thisRowSticky ? 'sticky' : ''}`}
83
83
  key={startIndex}
84
84
  style={{
85
+ // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
85
86
  height: height,
87
+ // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
86
88
  marginTop: `${marginTop}px`,
89
+ // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
87
90
  top: thisRowSticky
88
91
  ? `${this.props.stickyTop! + 3}px`
89
92
  : undefined,
93
+ // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
90
94
  paddingTop: thisRowSticky
91
95
  ? `${tableControlsSpacing}px`
92
96
  : undefined,
@@ -215,6 +215,7 @@ const DragControlsComponent = ({
215
215
  width: '9px',
216
216
  height: '100%',
217
217
  position: 'relative',
218
+ // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
218
219
  right: '-0.5px',
219
220
  }}
220
221
  data-testid={`table-floating-row-${
@@ -297,7 +298,10 @@ const DragControlsComponent = ({
297
298
  gridTemplateColumns: isDragging
298
299
  ? `${dropTargetExtendedWidth}px 14px ${tableWidth}px`
299
300
  : '0px 14px 0px',
300
- left: isDragging ? `-${dropTargetExtendedWidth + 2}px` : `-2px`,
301
+ // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
302
+ left: isDragging
303
+ ? `-${dropTargetExtendedWidth + 2}px`
304
+ : token('space.negative.025', '-2px'),
301
305
  }}
302
306
  onMouseMove={handleMouseMove}
303
307
  contentEditable={false}
@@ -211,6 +211,7 @@ const tableBorderStyles = () => {
211
211
  }
212
212
  };
213
213
 
214
+ // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
214
215
  const tableStickyHeaderColumnControlsDecorationsStyle = () => {
215
216
  if (getBooleanFF('platform.editor.table.column-controls-styles-updated')) {
216
217
  return css`
@@ -1116,6 +1117,7 @@ export const tableStyles = (props: { featureFlags?: FeatureFlags }) => css`
1116
1117
  ${shadowSentinelStyles}
1117
1118
  `;
1118
1119
 
1120
+ // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
1119
1121
  export const tableFullPageEditorStyles = css`
1120
1122
  .ProseMirror .${ClassName.TABLE_NODE_WRAPPER} > table {
1121
1123
  margin-left: 0;
@@ -55,14 +55,15 @@ const InsertLine = (cssString?: string) => css`
55
55
  }
56
56
  `;
57
57
 
58
- const Marker = () => css`
59
- background-color: ${tableBorderColor};
60
- position: absolute;
61
- height: ${lineMarkerSize}px;
62
- width: ${lineMarkerSize}px;
63
- border-radius: 50%;
64
- pointer-events: none;
65
- `;
58
+ const Marker = () =>
59
+ css({
60
+ backgroundColor: tableBorderColor,
61
+ position: 'absolute',
62
+ height: `${lineMarkerSize}px`,
63
+ width: `${lineMarkerSize}px`,
64
+ borderRadius: '50%',
65
+ pointerEvents: 'none',
66
+ });
66
67
 
67
68
  export const InsertMarker = (cssString?: string) => css`
68
69
  .${ClassName.CONTROLS_INSERT_MARKER} {
@@ -93,6 +94,8 @@ const Button = (cssString?: string) => css`
93
94
  ${cssString}
94
95
  `;
95
96
 
97
+ // Explicit pixel values required here to ensure classic row controls align correctly
98
+ // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
96
99
  export const HeaderButton = (cssString?: string) => css`
97
100
  .${ClassName.CONTROLS_BUTTON} {
98
101
  background: ${tableHeaderCellBackgroundColor};
@@ -273,28 +276,30 @@ export const dragCornerControlButton = () => css`
273
276
  }
274
277
  `;
275
278
 
276
- export const insertColumnButtonWrapper = () => css`
277
- ${InsertButton()}
278
- ${InsertButtonHover()}
279
- ${InsertLine(
280
- `
279
+ export const insertColumnButtonWrapper = () =>
280
+ css(
281
+ InsertButton(),
282
+ InsertButtonHover(),
283
+ InsertLine(
284
+ `
281
285
  width: 2px;
282
286
  left: 9px;
283
287
  `,
284
- )}
285
- `;
286
-
287
- export const insertRowButtonWrapper = () => css`
288
- ${InsertButton()}
289
- ${InsertButtonHover()}
290
- ${InsertLine(
291
- `
288
+ ),
289
+ );
290
+
291
+ export const insertRowButtonWrapper = () =>
292
+ css(
293
+ InsertButton(),
294
+ InsertButtonHover(),
295
+ InsertLine(
296
+ `
292
297
  height: 2px;
293
298
  top: -11px;
294
299
  left: ${tableInsertColumnButtonSize - 1}px;
295
300
  `,
296
- )}
297
- `;
301
+ ),
302
+ );
298
303
 
299
304
  export const columnControlsLineMarker = () => css`
300
305
  .${ClassName.TABLE_CONTAINER}.${ClassName.WITH_CONTROLS}
@@ -419,41 +424,42 @@ const overflowShadowWidhoutDnD = (
419
424
 
420
425
  const columnHeaderButton = (cssString?: string) => {
421
426
  if (getBooleanFF('platform.editor.table.column-controls-styles-updated')) {
422
- return css`
423
- background: ${tableHeaderCellBackgroundColor};
424
- display: block;
425
- box-sizing: border-box;
426
- padding: 0;
427
-
428
- :focus {
429
- outline: none;
430
- }
431
-
432
- ${cssString}
433
- `;
427
+ return css(
428
+ {
429
+ background: tableHeaderCellBackgroundColor,
430
+ display: 'block',
431
+ boxSizing: 'border-box',
432
+ padding: 0,
433
+ ':focus': {
434
+ outline: 'none',
435
+ },
436
+ },
437
+ cssString,
438
+ );
434
439
  } else {
435
- return css`
436
- background: ${tableHeaderCellBackgroundColor};
437
- border: 1px solid ${tableBorderColor};
438
- display: block;
439
- box-sizing: border-box;
440
- padding: 0;
441
-
442
- :focus {
443
- outline: none;
444
- }
445
-
446
- ${cssString}
447
- `;
440
+ return css(
441
+ {
442
+ background: tableHeaderCellBackgroundColor,
443
+ border: `1px solid ${tableBorderColor}`,
444
+ display: 'block',
445
+ boxSizing: 'border-box',
446
+ padding: 0,
447
+ ':focus': {
448
+ outline: 'none',
449
+ },
450
+ },
451
+ cssString,
452
+ );
448
453
  }
449
454
  };
450
455
 
451
- const columnHeaderButtonSelected = () => css`
452
- color: ${token('color.text.inverse', N0)};
453
- background-color: ${tableToolbarSelectedColor};
454
- border-color: ${tableBorderSelectedColor};
455
- z-index: ${columnControlsSelectedZIndex};
456
- `;
456
+ const columnHeaderButtonSelected = () =>
457
+ css({
458
+ color: token('color.text.inverse', N0),
459
+ backgroundColor: tableToolbarSelectedColor,
460
+ borderColor: tableBorderSelectedColor,
461
+ zIndex: columnControlsSelectedZIndex,
462
+ });
457
463
 
458
464
  const getFloatingDotOverrides = () => {
459
465
  return getBooleanFF('platform.editor.custom-table-width')
@@ -795,6 +801,8 @@ const getLastColumnResizerOverrides = () => {
795
801
  : '';
796
802
  };
797
803
 
804
+ // Explicit pixel values required here to ensure correct positioning and sizes of column resize handle
805
+ // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
798
806
  const resizeHandleOverrides = (isDragAndDropEnabled: boolean | undefined) => {
799
807
  if (isDragAndDropEnabled) {
800
808
  return css`
@@ -902,34 +910,37 @@ export const resizeHandle = (isDragAndDropEnabled: boolean | undefined) => css`
902
910
  `;
903
911
 
904
912
  // Drag and Drop: drop target insert line
905
- const tableCellColumnInsertLineStyles = css`
906
- content: ' ';
907
- position: absolute;
908
- height: calc(100% + ${tableCellBorderWidth * 2}px);
909
- width: ${insertLineWidth}px;
910
- z-index: ${columnControlsZIndex * 2};
911
- `;
912
-
913
- const tableCellRowInsertLineStyles = css`
914
- content: ' ';
915
- position: absolute;
916
- left: ${token('space.negative.025', '-2px')};
917
- height: ${insertLineWidth}px;
918
- width: calc(100% + ${tableCellBorderWidth * 2}px);
919
- z-index: ${columnControlsZIndex * 2};
920
- `;
921
-
922
- const insertLineActiveColor = css`
923
- background-color: ${tableBorderSelectedColor};
924
- `;
925
-
926
- const insertLineInactiveColor = css`
927
- background-color: ${token(
913
+ const tableCellColumnInsertLineStyles = css({
914
+ content: "' '",
915
+ position: 'absolute',
916
+ height: `calc(100% + ${tableCellBorderWidth * 2}px)`,
917
+ width: `${insertLineWidth}px`,
918
+ zIndex: columnControlsZIndex * 2,
919
+ });
920
+
921
+ const tableCellRowInsertLineStyles = css({
922
+ content: "' '",
923
+ position: 'absolute',
924
+ left: token('space.negative.025', '-2px'),
925
+ height: `${insertLineWidth}px`,
926
+ width: `calc(100% + ${tableCellBorderWidth * 2}px)`,
927
+ zIndex: columnControlsZIndex * 2,
928
+ });
929
+
930
+ const insertLineActiveColor = css({
931
+ backgroundColor: tableBorderSelectedColor,
932
+ });
933
+
934
+ const insertLineInactiveColor = css({
935
+ backgroundColor: token(
928
936
  'color.background.accent.gray.subtler',
929
937
  akEditorTableBorder,
930
- )};
931
- `;
938
+ ),
939
+ });
932
940
 
941
+ // Explicit pixel values required here to ensure correct positioning of line that is show on row
942
+ // or column drag
943
+ // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
933
944
  export const insertLine = () => css`
934
945
  .${ClassName.TABLE_CONTAINER} {
935
946
  td.${ClassName.WITH_FIRST_COLUMN_INSERT_LINE}::before {