@atlaskit/editor-plugin-table 4.1.0 → 4.2.0

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 +13 -0
  2. package/dist/cjs/plugins/table/commands/delete.js +18 -0
  3. package/dist/cjs/plugins/table/commands-with-analytics.js +2 -7
  4. package/dist/cjs/plugins/table/event-handlers.js +2 -2
  5. package/dist/cjs/plugins/table/nodeviews/TableContainer.js +27 -9
  6. package/dist/cjs/plugins/table/pm-plugins/main.js +1 -1
  7. package/dist/cjs/plugins/table/transforms/column-width.js +110 -5
  8. package/dist/cjs/plugins/table/transforms/delete-columns.js +16 -6
  9. package/dist/cjs/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +1 -1
  10. package/dist/cjs/plugins/table/ui/FloatingDeleteButton/index.js +1 -1
  11. package/dist/cjs/plugins/table/ui/common-styles.js +1 -1
  12. package/dist/es2019/plugins/table/commands/delete.js +10 -0
  13. package/dist/es2019/plugins/table/commands-with-analytics.js +3 -8
  14. package/dist/es2019/plugins/table/event-handlers.js +2 -2
  15. package/dist/es2019/plugins/table/nodeviews/TableContainer.js +27 -9
  16. package/dist/es2019/plugins/table/pm-plugins/main.js +1 -1
  17. package/dist/es2019/plugins/table/transforms/column-width.js +105 -5
  18. package/dist/es2019/plugins/table/transforms/delete-columns.js +16 -5
  19. package/dist/es2019/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +1 -1
  20. package/dist/es2019/plugins/table/ui/FloatingDeleteButton/index.js +1 -1
  21. package/dist/es2019/plugins/table/ui/common-styles.js +0 -1
  22. package/dist/esm/plugins/table/commands/delete.js +12 -0
  23. package/dist/esm/plugins/table/commands-with-analytics.js +3 -8
  24. package/dist/esm/plugins/table/event-handlers.js +2 -2
  25. package/dist/esm/plugins/table/nodeviews/TableContainer.js +27 -9
  26. package/dist/esm/plugins/table/pm-plugins/main.js +1 -1
  27. package/dist/esm/plugins/table/transforms/column-width.js +111 -5
  28. package/dist/esm/plugins/table/transforms/delete-columns.js +16 -6
  29. package/dist/esm/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +1 -1
  30. package/dist/esm/plugins/table/ui/FloatingDeleteButton/index.js +1 -1
  31. package/dist/esm/plugins/table/ui/common-styles.js +1 -1
  32. package/dist/types/plugins/table/commands/delete.d.ts +3 -0
  33. package/dist/types/plugins/table/event-handlers.d.ts +1 -1
  34. package/dist/types/plugins/table/nodeviews/TableContainer.d.ts +3 -3
  35. package/dist/types/plugins/table/pm-plugins/table-resizing/utils/misc.d.ts +1 -1
  36. package/dist/types/plugins/table/transforms/column-width.d.ts +25 -6
  37. package/dist/types/plugins/table/transforms/delete-columns.d.ts +2 -1
  38. package/dist/types/plugins/table/ui/FloatingDeleteButton/index.d.ts +4 -4
  39. package/dist/types-ts4.5/plugins/table/commands/delete.d.ts +3 -0
  40. package/dist/types-ts4.5/plugins/table/event-handlers.d.ts +1 -1
  41. package/dist/types-ts4.5/plugins/table/nodeviews/TableContainer.d.ts +3 -3
  42. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/misc.d.ts +1 -1
  43. package/dist/types-ts4.5/plugins/table/transforms/column-width.d.ts +25 -6
  44. package/dist/types-ts4.5/plugins/table/transforms/delete-columns.d.ts +2 -1
  45. package/dist/types-ts4.5/plugins/table/ui/FloatingDeleteButton/index.d.ts +4 -4
  46. package/package.json +8 -2
  47. package/src/__tests__/unit/commands.ts +1 -0
  48. package/src/__tests__/unit/transforms/delete-columns.ts +406 -105
  49. package/src/__tests__/unit/undo-redo.ts +1 -1
  50. package/src/plugins/table/commands/delete.ts +20 -0
  51. package/src/plugins/table/commands-with-analytics.ts +3 -10
  52. package/src/plugins/table/event-handlers.ts +6 -1
  53. package/src/plugins/table/nodeviews/TableContainer.tsx +189 -159
  54. package/src/plugins/table/pm-plugins/main.ts +7 -1
  55. package/src/plugins/table/pm-plugins/table-resizing/utils/misc.ts +1 -1
  56. package/src/plugins/table/transforms/column-width.ts +155 -15
  57. package/src/plugins/table/transforms/delete-columns.ts +23 -6
  58. package/src/plugins/table/ui/FloatingContextualMenu/ContextualMenu.tsx +1 -1
  59. package/src/plugins/table/ui/FloatingDeleteButton/index.tsx +7 -6
  60. package/src/plugins/table/ui/common-styles.ts +0 -1
@@ -1,9 +1,16 @@
1
1
  import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
2
- import { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
3
- import { Transaction } from '@atlaskit/editor-prosemirror/state';
4
- import { ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
5
- import { EditorView } from '@atlaskit/editor-prosemirror/view';
6
- import { ResizeState } from '../pm-plugins/table-resizing/utils';
2
+ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
3
+ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
4
+ import type { ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
5
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
6
+ import type { ResizeState } from '../pm-plugins/table-resizing/utils';
7
+ /**
8
+ * Given a new ResizeState object, create a transaction that replaces and updates the table node based on new state.
9
+ * @param resizeState
10
+ * @param table
11
+ * @param start
12
+ * @returns
13
+ */
7
14
  export declare const updateColumnWidths: (resizeState: ResizeState, table: PMNode, start: number) => (tr: Transaction) => Transaction;
8
15
  /**
9
16
  * This function is called when user inserts/deletes a column in a table to;
@@ -15,4 +22,16 @@ export declare const updateColumnWidths: (resizeState: ResizeState, table: PMNod
15
22
  * @param view
16
23
  * @returns Updated transaction with rescaled columns for a given table
17
24
  */
18
- export declare const rescaleColumns: (getEditorContainerWidth: GetEditorContainerWidth) => (table: ContentNodeWithPos, view: EditorView | undefined) => (tr: Transaction) => Transaction;
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;
@@ -1,3 +1,4 @@
1
1
  import type { Transaction } from '@atlaskit/editor-prosemirror/state';
2
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
2
3
  import type { Rect } from '@atlaskit/editor-tables/table-map';
3
- export declare const deleteColumns: (rect: Rect, allowAddColumnCustomStep?: boolean) => (tr: Transaction) => Transaction;
4
+ export declare const deleteColumns: (rect: Rect, allowCustomStep: boolean, view?: EditorView) => (tr: Transaction) => Transaction;
@@ -1,9 +1,9 @@
1
1
  import { Component } from 'react';
2
2
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
3
- import { Selection } from '@atlaskit/editor-prosemirror/state';
4
- import { EditorView } from '@atlaskit/editor-prosemirror/view';
5
- import { RowStickyState } from '../../pm-plugins/sticky-headers';
6
- import { CellSelectionType } from './types';
3
+ import type { Selection } from '@atlaskit/editor-prosemirror/state';
4
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
5
+ import type { RowStickyState } from '../../pm-plugins/sticky-headers';
6
+ import type { CellSelectionType } from './types';
7
7
  export interface Props {
8
8
  editorView: EditorView;
9
9
  selection: Selection;
@@ -0,0 +1,3 @@
1
+ import type { Command } from '@atlaskit/editor-common/types';
2
+ import type { Rect } from '@atlaskit/editor-tables/table-map';
3
+ export declare const deleteColumnsCommand: (rect: Rect) => Command;
@@ -11,5 +11,5 @@ export declare const handleMouseOut: (view: EditorView, mouseEvent: Event) => bo
11
11
  export declare const handleMouseLeave: (view: EditorView, event: Event) => boolean;
12
12
  export declare const handleMouseMove: (view: EditorView, event: Event, elementContentRects?: ElementContentRects) => boolean;
13
13
  export declare function handleTripleClick(view: EditorView, pos: number): boolean;
14
- export declare const handleCut: (oldTr: Transaction, oldState: EditorState, newState: EditorState, editorAnalyticsAPI?: EditorAnalyticsAPI) => Transaction;
14
+ export declare const handleCut: (oldTr: Transaction, oldState: EditorState, newState: EditorState, editorAnalyticsAPI?: EditorAnalyticsAPI, editorView?: EditorView) => Transaction;
15
15
  export declare const whenTableInFocus: (eventHandler: (view: EditorView, mouseEvent: Event, elementContentRects?: ElementContentRects) => boolean, elementContentRects?: ElementContentRects) => (view: EditorView, mouseEvent: Event) => boolean;
@@ -8,7 +8,7 @@ type InnerContainerProps = {
8
8
  className: string;
9
9
  style?: {
10
10
  width: number | 'inherit';
11
- marginLeft: number | undefined;
11
+ marginLeft?: number;
12
12
  };
13
13
  node: PMNode;
14
14
  };
@@ -17,7 +17,7 @@ export declare const InnerContainer: React.ForwardRefExoticComponent<InnerContai
17
17
  } & React.RefAttributes<HTMLDivElement>>;
18
18
  type ResizableTableContainerProps = {
19
19
  containerWidth: number;
20
- lineLength: number;
20
+ lineLength?: number;
21
21
  node: PMNode;
22
22
  className: string;
23
23
  editorView: EditorView;
@@ -26,7 +26,7 @@ type ResizableTableContainerProps = {
26
26
  isResizing?: boolean;
27
27
  pluginInjectionApi?: PluginInjectionAPI;
28
28
  };
29
- export declare const ResizableTableContainer: ({ children, className, node, lineLength, containerWidth, editorView, getPos, tableRef, isResizing, pluginInjectionApi, }: PropsWithChildren<ResizableTableContainerProps>) => JSX.Element;
29
+ export declare const ResizableTableContainer: React.MemoExoticComponent<({ children, className, node, lineLength, containerWidth, editorView, getPos, tableRef, isResizing, pluginInjectionApi, }: PropsWithChildren<ResizableTableContainerProps>) => JSX.Element>;
30
30
  type TableContainerProps = {
31
31
  node: PMNode;
32
32
  className: string;
@@ -16,5 +16,5 @@ interface getTableMaxWidthProps {
16
16
  layout: TableLayout;
17
17
  getEditorContainerWidth: GetEditorContainerWidth;
18
18
  }
19
- export declare const getTableMaxWidth: ({ table, tableStart, state, layout, getEditorContainerWidth, }: getTableMaxWidthProps) => any;
19
+ export declare const getTableMaxWidth: ({ table, tableStart, state, layout, getEditorContainerWidth, }: getTableMaxWidthProps) => number;
20
20
  export {};
@@ -1,9 +1,16 @@
1
1
  import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
2
- import { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
3
- import { Transaction } from '@atlaskit/editor-prosemirror/state';
4
- import { ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
5
- import { EditorView } from '@atlaskit/editor-prosemirror/view';
6
- import { ResizeState } from '../pm-plugins/table-resizing/utils';
2
+ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
3
+ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
4
+ import type { ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
5
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
6
+ import type { ResizeState } from '../pm-plugins/table-resizing/utils';
7
+ /**
8
+ * Given a new ResizeState object, create a transaction that replaces and updates the table node based on new state.
9
+ * @param resizeState
10
+ * @param table
11
+ * @param start
12
+ * @returns
13
+ */
7
14
  export declare const updateColumnWidths: (resizeState: ResizeState, table: PMNode, start: number) => (tr: Transaction) => Transaction;
8
15
  /**
9
16
  * This function is called when user inserts/deletes a column in a table to;
@@ -15,4 +22,16 @@ export declare const updateColumnWidths: (resizeState: ResizeState, table: PMNod
15
22
  * @param view
16
23
  * @returns Updated transaction with rescaled columns for a given table
17
24
  */
18
- export declare const rescaleColumns: (getEditorContainerWidth: GetEditorContainerWidth) => (table: ContentNodeWithPos, view: EditorView | undefined) => (tr: Transaction) => Transaction;
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;
@@ -1,3 +1,4 @@
1
1
  import type { Transaction } from '@atlaskit/editor-prosemirror/state';
2
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
2
3
  import type { Rect } from '@atlaskit/editor-tables/table-map';
3
- export declare const deleteColumns: (rect: Rect, allowAddColumnCustomStep?: boolean) => (tr: Transaction) => Transaction;
4
+ export declare const deleteColumns: (rect: Rect, allowCustomStep: boolean, view?: EditorView) => (tr: Transaction) => Transaction;
@@ -1,9 +1,9 @@
1
1
  import { Component } from 'react';
2
2
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
3
- import { Selection } from '@atlaskit/editor-prosemirror/state';
4
- import { EditorView } from '@atlaskit/editor-prosemirror/view';
5
- import { RowStickyState } from '../../pm-plugins/sticky-headers';
6
- import { CellSelectionType } from './types';
3
+ import type { Selection } from '@atlaskit/editor-prosemirror/state';
4
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
5
+ import type { RowStickyState } from '../../pm-plugins/sticky-headers';
6
+ import type { CellSelectionType } from './types';
7
7
  export interface Props {
8
8
  editorView: EditorView;
9
9
  selection: Selection;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "4.1.0",
3
+ "version": "4.2.0",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -29,7 +29,7 @@
29
29
  "dependencies": {
30
30
  "@atlaskit/adf-schema": "^32.0.0",
31
31
  "@atlaskit/custom-steps": "^0.0.2",
32
- "@atlaskit/editor-common": "^76.5.0",
32
+ "@atlaskit/editor-common": "^76.6.0",
33
33
  "@atlaskit/editor-palette": "1.5.1",
34
34
  "@atlaskit/editor-plugin-analytics": "^0.2.0",
35
35
  "@atlaskit/editor-plugin-content-insertion": "^0.1.0",
@@ -123,6 +123,12 @@
123
123
  },
124
124
  "platform.editor.table.increase-shadow-visibility_lh89r": {
125
125
  "type": "boolean"
126
+ },
127
+ "platform.editor.table.update-table-resizer-styles": {
128
+ "type": "boolean"
129
+ },
130
+ "platform.editor.table-update-colwidths-after-column-is-deleted": {
131
+ "type": "boolean"
126
132
  }
127
133
  }
128
134
  }
@@ -327,6 +327,7 @@ describe('table plugin: actions', () => {
327
327
  const editorAnalyticsAPIFake: EditorAnalyticsAPI = {
328
328
  attachAnalyticsEvent: jest.fn().mockReturnValue(() => jest.fn()),
329
329
  };
330
+
330
331
  describe('when the entire table is selected', () => {
331
332
  it('should remove the table', () => {
332
333
  const { editorView, refs } = editor(