@atlaskit/editor-plugin-table 5.7.2 → 5.7.4

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 (86) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/cjs/commands/insert.js +1 -1
  3. package/dist/cjs/nodeviews/TableComponent.js +4 -1
  4. package/dist/cjs/plugin.js +2 -1
  5. package/dist/cjs/pm-plugins/main.js +5 -16
  6. package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +0 -4
  7. package/dist/cjs/transforms/column-width.js +3 -105
  8. package/dist/cjs/transforms/delete-columns.js +2 -5
  9. package/dist/cjs/types.js +0 -2
  10. package/dist/cjs/ui/FloatingDragMenu/index.js +5 -2
  11. package/dist/cjs/ui/FloatingInsertButton/InsertButton.js +3 -3
  12. package/dist/cjs/ui/FloatingInsertButton/index.js +1 -1
  13. package/dist/cjs/ui/TableFloatingColumnControls/ColumnControls/index.js +39 -8
  14. package/dist/cjs/ui/TableFloatingColumnControls/index.js +17 -8
  15. package/dist/cjs/ui/common-styles.js +1 -1
  16. package/dist/cjs/utils/decoration.js +48 -34
  17. package/dist/cjs/utils/dom.js +1 -19
  18. package/dist/cjs/utils/index.js +0 -6
  19. package/dist/es2019/commands/insert.js +1 -1
  20. package/dist/es2019/nodeviews/TableComponent.js +5 -2
  21. package/dist/es2019/plugin.js +2 -1
  22. package/dist/es2019/pm-plugins/main.js +1 -12
  23. package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +1 -5
  24. package/dist/es2019/transforms/column-width.js +4 -102
  25. package/dist/es2019/transforms/delete-columns.js +2 -5
  26. package/dist/es2019/types.js +0 -2
  27. package/dist/es2019/ui/FloatingDragMenu/index.js +6 -3
  28. package/dist/es2019/ui/FloatingInsertButton/InsertButton.js +3 -3
  29. package/dist/es2019/ui/FloatingInsertButton/index.js +2 -2
  30. package/dist/es2019/ui/TableFloatingColumnControls/ColumnControls/index.js +34 -4
  31. package/dist/es2019/ui/TableFloatingColumnControls/index.js +18 -9
  32. package/dist/es2019/ui/common-styles.js +6 -1
  33. package/dist/es2019/utils/decoration.js +47 -33
  34. package/dist/es2019/utils/dom.js +0 -18
  35. package/dist/es2019/utils/index.js +1 -1
  36. package/dist/esm/commands/insert.js +1 -1
  37. package/dist/esm/nodeviews/TableComponent.js +5 -2
  38. package/dist/esm/plugin.js +2 -1
  39. package/dist/esm/pm-plugins/main.js +1 -12
  40. package/dist/esm/pm-plugins/table-resizing/event-handlers.js +1 -5
  41. package/dist/esm/transforms/column-width.js +4 -106
  42. package/dist/esm/transforms/delete-columns.js +2 -5
  43. package/dist/esm/types.js +0 -2
  44. package/dist/esm/ui/FloatingDragMenu/index.js +6 -3
  45. package/dist/esm/ui/FloatingInsertButton/InsertButton.js +3 -3
  46. package/dist/esm/ui/FloatingInsertButton/index.js +2 -2
  47. package/dist/esm/ui/TableFloatingColumnControls/ColumnControls/index.js +35 -4
  48. package/dist/esm/ui/TableFloatingColumnControls/index.js +18 -9
  49. package/dist/esm/ui/common-styles.js +2 -2
  50. package/dist/esm/utils/decoration.js +48 -34
  51. package/dist/esm/utils/dom.js +0 -18
  52. package/dist/esm/utils/index.js +1 -1
  53. package/dist/types/transforms/column-width.d.ts +1 -14
  54. package/dist/types/types.d.ts +0 -1
  55. package/dist/types/ui/FloatingDragMenu/index.d.ts +3 -1
  56. package/dist/types/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +3 -1
  57. package/dist/types/ui/TableFloatingColumnControls/index.d.ts +2 -0
  58. package/dist/types/utils/dom.d.ts +0 -1
  59. package/dist/types/utils/index.d.ts +1 -1
  60. package/dist/types-ts4.5/transforms/column-width.d.ts +1 -14
  61. package/dist/types-ts4.5/types.d.ts +0 -1
  62. package/dist/types-ts4.5/ui/FloatingDragMenu/index.d.ts +3 -1
  63. package/dist/types-ts4.5/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +3 -1
  64. package/dist/types-ts4.5/ui/TableFloatingColumnControls/index.d.ts +2 -0
  65. package/dist/types-ts4.5/utils/dom.d.ts +0 -1
  66. package/dist/types-ts4.5/utils/index.d.ts +1 -1
  67. package/package.json +6 -9
  68. package/src/__tests__/unit/commands/insert.ts +7 -0
  69. package/src/__tests__/unit/transforms/delete-columns.ts +147 -368
  70. package/src/commands/insert.ts +1 -3
  71. package/src/nodeviews/TableComponent.tsx +7 -2
  72. package/src/plugin.tsx +1 -0
  73. package/src/pm-plugins/main.ts +0 -18
  74. package/src/pm-plugins/table-resizing/event-handlers.ts +1 -8
  75. package/src/transforms/column-width.ts +4 -137
  76. package/src/transforms/delete-columns.ts +3 -9
  77. package/src/types.ts +0 -2
  78. package/src/ui/FloatingDragMenu/index.tsx +14 -2
  79. package/src/ui/FloatingInsertButton/InsertButton.tsx +6 -2
  80. package/src/ui/FloatingInsertButton/index.tsx +4 -2
  81. package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +48 -3
  82. package/src/ui/TableFloatingColumnControls/index.tsx +23 -11
  83. package/src/ui/common-styles.ts +6 -0
  84. package/src/utils/decoration.ts +41 -28
  85. package/src/utils/dom.ts +0 -23
  86. package/src/utils/index.ts +0 -1
@@ -1,4 +1,3 @@
1
- import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
2
1
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
3
2
  import type { Transaction } from '@atlaskit/editor-prosemirror/state';
4
3
  import type { ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
@@ -22,16 +21,4 @@ export declare const updateColumnWidths: (resizeState: ResizeState, table: PMNod
22
21
  * @param view
23
22
  * @returns Updated transaction with rescaled columns for a given table
24
23
  */
25
- export declare const rescaleColumnsNew: () => (table: ContentNodeWithPos, view: EditorView | undefined) => (tr: Transaction) => Transaction;
26
- /**
27
- * This function is called when user inserts/deletes a column in a table to;
28
- * - rescale all columns (if the table did not overflow before the insertion)
29
- * - and update column widths.
30
- *
31
- * This is done manually to avoid a multi-dispatch in TableComponent. See [ED-8288].
32
- * @param table
33
- * @param view
34
- * @returns Updated transaction with rescaled columns for a given table
35
- */
36
- export declare const rescaleColumnsOld: (getEditorContainerWidth: GetEditorContainerWidth) => (table: ContentNodeWithPos, view: EditorView | undefined) => (tr: Transaction) => Transaction;
37
- export declare const rescaleColumns: (getEditorContainerWidth?: GetEditorContainerWidth) => (table: ContentNodeWithPos, view: EditorView | undefined) => (tr: Transaction) => Transaction;
24
+ export declare const rescaleColumns: () => (table: ContentNodeWithPos, view: EditorView | undefined) => (tr: Transaction) => Transaction;
@@ -322,7 +322,6 @@ export declare const TableCssClassName: {
322
322
  RESIZING_PLUGIN: string;
323
323
  RESIZE_CURSOR: string;
324
324
  IS_RESIZING: string;
325
- RESIZE_HANDLE: string;
326
325
  RESIZE_HANDLE_DECORATION: string;
327
326
  CONTEXTUAL_SUBMENU: string;
328
327
  CONTEXTUAL_MENU_BUTTON_WRAP: string;
@@ -3,6 +3,7 @@ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
3
3
  import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
4
4
  import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
5
5
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
6
+ import type { RowStickyState } from '../../pm-plugins/sticky-headers';
6
7
  import type { TableDirection } from '../../types';
7
8
  export interface Props {
8
9
  editorView: EditorView;
@@ -18,9 +19,10 @@ export interface Props {
18
19
  getEditorContainerWidth: GetEditorContainerWidth;
19
20
  canDrag?: boolean;
20
21
  editorAnalyticsAPI?: EditorAnalyticsAPI;
22
+ stickyHeaders?: RowStickyState;
21
23
  }
22
24
  declare const FloatingDragMenu: {
23
- ({ mountPoint, boundariesElement, scrollableElement, editorView, isOpen, tableNode, direction, index, targetCellPosition, getEditorContainerWidth, canDrag, editorAnalyticsAPI, }: Props): JSX.Element | null;
25
+ ({ mountPoint, boundariesElement, scrollableElement, editorView, isOpen, tableNode, direction, index, targetCellPosition, getEditorContainerWidth, canDrag, editorAnalyticsAPI, stickyHeaders, }: Props): JSX.Element | null;
24
26
  displayName: string;
25
27
  };
26
28
  export default FloatingDragMenu;
@@ -15,6 +15,8 @@ export interface ColumnControlsProps {
15
15
  hasHeaderColumn?: boolean;
16
16
  isTableHovered?: boolean;
17
17
  canDrag?: boolean;
18
+ tableContainerWidth?: number;
19
+ isNumberColumnEnabled?: boolean;
18
20
  }
19
- export declare const ColumnControls: ({ editorView, tableActive, tableRef, hoveredCell, isResizing, stickyTop, localId, isInDanger, rowHeights, colWidths, hasHeaderColumn, isTableHovered, canDrag, }: ColumnControlsProps) => JSX.Element;
21
+ export declare const ColumnControls: ({ editorView, tableActive, tableRef, hoveredCell, isResizing, stickyTop, localId, isInDanger, rowHeights, colWidths, hasHeaderColumn, isTableHovered, canDrag, tableContainerWidth, isNumberColumnEnabled, }: ColumnControlsProps) => JSX.Element;
20
22
  export default ColumnControls;
@@ -23,6 +23,8 @@ export interface Props {
23
23
  stickyHeader?: RowStickyState;
24
24
  isTableHovered?: boolean;
25
25
  canDrag?: boolean;
26
+ tableContainerWidth?: number;
27
+ isNumberColumnEnabled?: boolean;
26
28
  }
27
29
  export declare const TableFloatingColumnControls: React.FC<Props>;
28
30
  export default TableFloatingColumnControls;
@@ -18,7 +18,6 @@ export declare const isDragColumnFloatingInsertDot: (node: HTMLElement | null) =
18
18
  export declare const isDragCornerButton: (node: HTMLElement | null) => boolean;
19
19
  export declare const getMousePositionHorizontalRelativeByElement: (mouseEvent: MouseEvent, elementContentRects?: ElementContentRects, gapInPixels?: number, isDragAndDropEnabled?: boolean) => 'left' | 'right' | null;
20
20
  export declare const getMousePositionVerticalRelativeByElement: (mouseEvent: MouseEvent) => 'top' | 'bottom' | null;
21
- export declare const updateResizeHandles: (tableRef?: HTMLElement) => void;
22
21
  export declare const hasResizeHandler: ({ columnEndIndexTarget, target, }: {
23
22
  columnEndIndexTarget: number;
24
23
  target: HTMLElement;
@@ -2,7 +2,7 @@ export { getSelectedColumnIndexes, getSelectedRowIndexes, normalizeSelection, is
2
2
  export { findControlsHoverDecoration, createControlsHoverDecoration, createColumnControlsDecoration, createColumnSelectedDecoration, createCellHoverDecoration, updateDecorations, createResizeHandleDecoration, createColumnInsertLine, createColumnLineResize, createRowInsertLine, } from './decoration';
3
3
  export { isIsolating, containsHeaderColumn, containsHeaderRow, checkIfHeaderColumnEnabled, checkIfHeaderRowEnabled, checkIfNumberColumnEnabled, isLayoutSupported, getTableWidth, tablesHaveDifferentColumnWidths, tablesHaveDifferentNoOfColumns, isTableNested, anyChildCellMergedAcrossRow, supportedHeaderRow, } from './nodes';
4
4
  export { unwrapContentFromTable, removeTableFromFirstChild, removeTableFromLastChild, transformSliceToRemoveOpenTable, transformSliceToCorrectEmptyTableCells, transformSliceToFixHardBreakProblemOnCopyFromCell, } from './paste';
5
- export { isCell, isCornerButton, isInsertRowButton, isColumnControlsDecorations, isTableControlsButton, isTableContainerOrWrapper, isRowControlsButton, isDragRowControlsButton, isDragColumnFloatingInsertDot, isDragRowFloatingInsertDot, isDragCornerButton, getColumnOrRowIndex, getMousePositionHorizontalRelativeByElement, getMousePositionVerticalRelativeByElement, updateResizeHandles, isResizeHandleDecoration, hasResizeHandler, findNearestCellIndexToPoint, } from './dom';
5
+ export { isCell, isCornerButton, isInsertRowButton, isColumnControlsDecorations, isTableControlsButton, isTableContainerOrWrapper, isRowControlsButton, isDragRowControlsButton, isDragColumnFloatingInsertDot, isDragRowFloatingInsertDot, isDragCornerButton, getColumnOrRowIndex, getMousePositionHorizontalRelativeByElement, getMousePositionVerticalRelativeByElement, isResizeHandleDecoration, hasResizeHandler, findNearestCellIndexToPoint, } from './dom';
6
6
  export { convertHTMLCellIndexToColumnIndex, getColumnsWidths, isColumnDeleteButtonVisible, getColumnDeleteButtonParams, getColumnClassNames, getColumnIndexMappedToColumnIndexInFirstRow, } from './column-controls';
7
7
  export { getRowHeights, isRowDeleteButtonVisible, getRowDeleteButtonParams, getRowsParams, getRowClassNames, copyPreviousRow, } from './row-controls';
8
8
  export type { RowParams } from './row-controls';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "5.7.2",
3
+ "version": "5.7.4",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -30,7 +30,7 @@
30
30
  "dependencies": {
31
31
  "@atlaskit/adf-schema": "^35.2.0",
32
32
  "@atlaskit/custom-steps": "^0.0.10",
33
- "@atlaskit/editor-common": "^76.29.0",
33
+ "@atlaskit/editor-common": "^76.30.0",
34
34
  "@atlaskit/editor-palette": "1.5.2",
35
35
  "@atlaskit/editor-plugin-analytics": "^0.4.0",
36
36
  "@atlaskit/editor-plugin-content-insertion": "^0.1.0",
@@ -119,18 +119,12 @@
119
119
  "platform.editor.resizing-table-height-improvement": {
120
120
  "type": "boolean"
121
121
  },
122
- "platform.editor.table-remove-update-resize-handles_djvab": {
123
- "type": "boolean"
124
- },
125
122
  "platform.editor.table.increase-shadow-visibility_lh89r": {
126
123
  "type": "boolean"
127
124
  },
128
125
  "platform.editor.table.shift-arrowup-fix": {
129
126
  "type": "boolean"
130
127
  },
131
- "platform.editor.table-update-colwidths-after-column-is-deleted": {
132
- "type": "boolean"
133
- },
134
128
  "platform.editor.table.alternative-sticky-header-logic": {
135
129
  "type": "boolean"
136
130
  },
@@ -148,6 +142,9 @@
148
142
  },
149
143
  "platform.editor.menu.group-items": {
150
144
  "type": "boolean"
145
+ },
146
+ "platform.editor.table.in-danger-hover-merged-cells-fix": {
147
+ "type": "boolean"
151
148
  }
152
149
  }
153
- }
150
+ }
@@ -69,6 +69,11 @@ describe('table plugin: insert', () => {
69
69
  });
70
70
 
71
71
  it('does scale cells in tables which are not overflowing', () => {
72
+ jest
73
+ .spyOn(HTMLElement.prototype, 'clientWidth', 'get')
74
+ .mockImplementationOnce(() => 760)
75
+ .mockImplementationOnce(() => 770);
76
+
72
77
  const { editorView } = editor(
73
78
  doc(
74
79
  table({ localId: TABLE_LOCAL_ID })(
@@ -97,6 +102,8 @@ describe('table plugin: insert', () => {
97
102
  expect(updatedLastTableCellNode?.attrs.colwidth[0]).not.toBe(
98
103
  lastTableCellNode?.attrs.colwidth[0],
99
104
  );
105
+
106
+ jest.restoreAllMocks();
100
107
  });
101
108
 
102
109
  it('does not scale cells in tables which are overflowing', () => {