@atlaskit/editor-plugin-table 1.5.5 → 1.6.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.
- package/CHANGELOG.md +10 -0
- package/dist/cjs/plugins/table/index.js +12 -11
- package/dist/cjs/plugins/table/nodeviews/TableComponent.js +37 -78
- package/dist/cjs/plugins/table/nodeviews/TableContainer.js +131 -0
- package/dist/cjs/plugins/table/nodeviews/TableResizer.js +65 -0
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/commands.js +4 -49
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/index.js +0 -7
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/index.js +12 -6
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/misc.js +3 -11
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/scale-table.js +61 -2
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/plugins/table/index.js +12 -11
- package/dist/es2019/plugins/table/nodeviews/TableComponent.js +17 -64
- package/dist/es2019/plugins/table/nodeviews/TableContainer.js +124 -0
- package/dist/es2019/plugins/table/nodeviews/TableResizer.js +56 -0
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/commands.js +2 -48
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/index.js +0 -1
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/index.js +2 -2
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/misc.js +5 -10
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/scale-table.js +61 -2
- package/dist/es2019/version.json +1 -1
- package/dist/esm/plugins/table/index.js +12 -11
- package/dist/esm/plugins/table/nodeviews/TableComponent.js +39 -81
- package/dist/esm/plugins/table/nodeviews/TableContainer.js +119 -0
- package/dist/esm/plugins/table/nodeviews/TableResizer.js +57 -0
- package/dist/esm/plugins/table/pm-plugins/table-resizing/commands.js +4 -48
- package/dist/esm/plugins/table/pm-plugins/table-resizing/index.js +0 -1
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/index.js +2 -2
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/misc.js +5 -10
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/scale-table.js +59 -2
- package/dist/esm/version.json +1 -1
- package/dist/types/plugins/table/nodeviews/TableComponent.d.ts +0 -3
- package/dist/types/plugins/table/nodeviews/TableContainer.d.ts +35 -0
- package/dist/types/plugins/table/nodeviews/TableResizer.d.ts +13 -0
- package/dist/types/plugins/table/pm-plugins/table-resizing/commands.d.ts +2 -4
- package/dist/types/plugins/table/pm-plugins/table-resizing/index.d.ts +0 -1
- package/dist/types/plugins/table/pm-plugins/table-resizing/utils/index.d.ts +2 -2
- package/dist/types/plugins/table/pm-plugins/table-resizing/utils/misc.d.ts +0 -1
- package/dist/types/plugins/table/pm-plugins/table-resizing/utils/scale-table.d.ts +3 -0
- package/dist/types/plugins/table/types.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/nodeviews/TableComponent.d.ts +0 -3
- package/dist/types-ts4.5/plugins/table/nodeviews/TableContainer.d.ts +35 -0
- package/dist/types-ts4.5/plugins/table/nodeviews/TableResizer.d.ts +13 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/commands.d.ts +2 -4
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/index.d.ts +0 -1
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/index.d.ts +2 -2
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/misc.d.ts +0 -1
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/scale-table.d.ts +3 -0
- package/dist/types-ts4.5/plugins/table/types.d.ts +1 -0
- package/package.json +3 -3
- package/src/__tests__/integration/sticky-header.ts +4 -1
- package/src/__tests__/unit/nodeviews/TableContainer.tsx +164 -0
- package/src/plugins/table/index.tsx +21 -18
- package/src/plugins/table/nodeviews/TableComponent.tsx +21 -78
- package/src/plugins/table/nodeviews/TableContainer.tsx +200 -0
- package/src/plugins/table/nodeviews/TableResizer.tsx +88 -0
- package/src/plugins/table/pm-plugins/table-resizing/commands.ts +3 -72
- package/src/plugins/table/pm-plugins/table-resizing/index.ts +0 -1
- package/src/plugins/table/pm-plugins/table-resizing/utils/index.ts +6 -2
- package/src/plugins/table/pm-plugins/table-resizing/utils/misc.ts +7 -12
- package/src/plugins/table/pm-plugins/table-resizing/utils/scale-table.ts +79 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React, { PropsWithChildren } from 'react';
|
|
2
|
+
import { Node as PMNode } from 'prosemirror-model';
|
|
3
|
+
import { EditorView } from 'prosemirror-view';
|
|
4
|
+
import { EditorContainerWidth } from '@atlaskit/editor-common/types';
|
|
5
|
+
type InnerContainerProps = {
|
|
6
|
+
className: string;
|
|
7
|
+
marginLeft: number | undefined;
|
|
8
|
+
width: number | 'inherit';
|
|
9
|
+
node: PMNode;
|
|
10
|
+
};
|
|
11
|
+
export declare const InnerContainer: React.ForwardRefExoticComponent<InnerContainerProps & {
|
|
12
|
+
children?: React.ReactNode;
|
|
13
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
14
|
+
type ResizableTableContainerProps = {
|
|
15
|
+
containerWidth: number;
|
|
16
|
+
lineLength: number;
|
|
17
|
+
node: PMNode;
|
|
18
|
+
className: string;
|
|
19
|
+
editorView: EditorView;
|
|
20
|
+
getPos: () => number;
|
|
21
|
+
tableRef: HTMLTableElement;
|
|
22
|
+
};
|
|
23
|
+
export declare const ResizableTableContainer: ({ children, className, node, lineLength, editorView, getPos, tableRef, }: PropsWithChildren<ResizableTableContainerProps>) => JSX.Element;
|
|
24
|
+
type TableContainerProps = {
|
|
25
|
+
node: PMNode;
|
|
26
|
+
className: string;
|
|
27
|
+
containerWidth: EditorContainerWidth;
|
|
28
|
+
isFullWidthModeEnabled: boolean | undefined;
|
|
29
|
+
isBreakoutEnabled: boolean | undefined;
|
|
30
|
+
editorView: EditorView;
|
|
31
|
+
getPos: () => number;
|
|
32
|
+
tableRef: HTMLTableElement;
|
|
33
|
+
};
|
|
34
|
+
export declare const TableContainer: ({ children, node, className, containerWidth: { lineLength, width: editorWidth }, isFullWidthModeEnabled, isBreakoutEnabled, editorView, getPos, tableRef, }: PropsWithChildren<TableContainerProps>) => JSX.Element;
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
import { EditorView } from 'prosemirror-view';
|
|
3
|
+
import { Node as PMNode } from 'prosemirror-model';
|
|
4
|
+
interface TableResizerProps {
|
|
5
|
+
width: number;
|
|
6
|
+
updateWidth: (width: number) => void;
|
|
7
|
+
editorView: EditorView;
|
|
8
|
+
getPos: () => number;
|
|
9
|
+
node: PMNode;
|
|
10
|
+
tableRef: HTMLTableElement;
|
|
11
|
+
}
|
|
12
|
+
export declare const TableResizer: ({ children, width, updateWidth, editorView, getPos, node, tableRef, }: PropsWithChildren<TableResizerProps>) => JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { Node as PMNode } from 'prosemirror-model';
|
|
2
2
|
import { Transaction } from 'prosemirror-state';
|
|
3
|
-
import type { Command } from '@atlaskit/editor-common/types';
|
|
4
|
-
import type { DomAtPos } from 'prosemirror-utils';
|
|
5
|
-
import { ResizeState, ScaleOptions } from './utils';
|
|
6
3
|
import { ContentNodeWithPos } from 'prosemirror-utils';
|
|
7
|
-
|
|
4
|
+
import type { Command } from '@atlaskit/editor-common/types';
|
|
5
|
+
import { ResizeState } from './utils';
|
|
8
6
|
export declare const evenColumns: ({ resizeState, table, start, event, }: {
|
|
9
7
|
resizeState: ResizeState;
|
|
10
8
|
table: PMNode;
|
|
@@ -4,9 +4,9 @@ export { getColumnStateFromDOM, getFreeSpace, getCellsRefsInColumn, calculateCol
|
|
|
4
4
|
export type { ColumnState } from './column-state';
|
|
5
5
|
export { growColumn, shrinkColumn, reduceSpace } from './resize-logic';
|
|
6
6
|
export { getResizeState, updateColgroup, getTotalWidth, evenAllColumnsWidths, bulkColumnsResize, areColumnsEven, adjustColumnsWidths, } from './resize-state';
|
|
7
|
-
export {
|
|
7
|
+
export { getLayoutSize, getDefaultLayoutMaxWidth, pointsAtCell, currentColWidth, domCellAround, } from './misc';
|
|
8
8
|
export { updateControls, isClickNear, getResizeCellPos } from './dom';
|
|
9
|
-
export { scale, scaleWithParent } from './scale-table';
|
|
9
|
+
export { scale, scaleWithParent, scaleTable, previewScaleTable, } from './scale-table';
|
|
10
10
|
export type { ScaleOptions } from './scale-table';
|
|
11
11
|
export type { ResizeState, ResizeStateWithAnalytics } from './types';
|
|
12
12
|
export { resizeColumn } from './resize-column';
|
|
@@ -5,7 +5,6 @@ import { TableOptions } from '../../../nodeviews/types';
|
|
|
5
5
|
import { Node as PMNode } from 'prosemirror-model';
|
|
6
6
|
import { EditorState } from 'prosemirror-state';
|
|
7
7
|
import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
|
|
8
|
-
export declare const tableLayoutToSize: Record<string, number>;
|
|
9
8
|
export declare function getLayoutSize(tableLayout: TableLayout, containerWidth: number | undefined, options: TableOptions): number;
|
|
10
9
|
export declare function getDefaultLayoutMaxWidth(containerWidth?: number): number;
|
|
11
10
|
export declare function pointsAtCell($pos: ResolvedPos<any>): false | PMNode<any> | null | undefined;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Node as PMNode } from 'prosemirror-model';
|
|
2
|
+
import { Transaction } from 'prosemirror-state';
|
|
2
3
|
import type { DomAtPos } from 'prosemirror-utils';
|
|
3
4
|
import { ResizeState } from '../utils/types';
|
|
4
5
|
export interface ScaleOptions {
|
|
@@ -15,3 +16,5 @@ export interface ScaleOptions {
|
|
|
15
16
|
export declare const scale: (tableRef: HTMLTableElement, options: ScaleOptions, domAtPos: DomAtPos) => ResizeState | undefined;
|
|
16
17
|
export declare const scaleWithParent: (tableRef: HTMLTableElement, parentWidth: number, table: PMNode, start: number, domAtPos: DomAtPos) => ResizeState;
|
|
17
18
|
export declare function scaleTableTo(state: ResizeState, maxSize: number): ResizeState;
|
|
19
|
+
export declare const previewScaleTable: (tableRef: HTMLTableElement | null | undefined, options: ScaleOptions, domAtPos: DomAtPos) => void;
|
|
20
|
+
export declare const scaleTable: (tableRef: HTMLTableElement | null | undefined, options: ScaleOptions, domAtPos: DomAtPos) => (tr: Transaction) => Transaction<any>;
|
|
@@ -298,6 +298,7 @@ export declare const TableCssClassName: {
|
|
|
298
298
|
TABLE_HEADER_CELL_WRAPPER: string;
|
|
299
299
|
TABLE_ROW_CONTROLS_WRAPPER: string;
|
|
300
300
|
TABLE_COLUMN_CONTROLS_DECORATIONS: string;
|
|
301
|
+
TABLE_RESIZER_CONTAINER: string;
|
|
301
302
|
};
|
|
302
303
|
export interface ToolbarMenuConfig {
|
|
303
304
|
allowHeaderRow?: boolean;
|
|
@@ -28,7 +28,6 @@ export interface ComponentProps {
|
|
|
28
28
|
}
|
|
29
29
|
interface TableState {
|
|
30
30
|
scroll: number;
|
|
31
|
-
tableContainerWidth: string;
|
|
32
31
|
parentWidth?: number;
|
|
33
32
|
isLoading: boolean;
|
|
34
33
|
stickyHeader?: RowStickyState;
|
|
@@ -54,13 +53,11 @@ declare class TableComponent extends React.Component<ComponentProps, TableState>
|
|
|
54
53
|
onStickyState: (state: StickyPluginState) => void;
|
|
55
54
|
prevTableState: any;
|
|
56
55
|
render(): JSX.Element;
|
|
57
|
-
private getMarginLeft;
|
|
58
56
|
private handleScroll;
|
|
59
57
|
private handleTableResizing;
|
|
60
58
|
private scaleTable;
|
|
61
59
|
private handleAutoSize;
|
|
62
60
|
private handleWindowResize;
|
|
63
|
-
private updateTableContainerWidth;
|
|
64
61
|
private getParentNodeWidth;
|
|
65
62
|
private updateParentWidth;
|
|
66
63
|
private tableNodeLayoutSize;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React, { PropsWithChildren } from 'react';
|
|
2
|
+
import { Node as PMNode } from 'prosemirror-model';
|
|
3
|
+
import { EditorView } from 'prosemirror-view';
|
|
4
|
+
import { EditorContainerWidth } from '@atlaskit/editor-common/types';
|
|
5
|
+
type InnerContainerProps = {
|
|
6
|
+
className: string;
|
|
7
|
+
marginLeft: number | undefined;
|
|
8
|
+
width: number | 'inherit';
|
|
9
|
+
node: PMNode;
|
|
10
|
+
};
|
|
11
|
+
export declare const InnerContainer: React.ForwardRefExoticComponent<InnerContainerProps & {
|
|
12
|
+
children?: React.ReactNode;
|
|
13
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
14
|
+
type ResizableTableContainerProps = {
|
|
15
|
+
containerWidth: number;
|
|
16
|
+
lineLength: number;
|
|
17
|
+
node: PMNode;
|
|
18
|
+
className: string;
|
|
19
|
+
editorView: EditorView;
|
|
20
|
+
getPos: () => number;
|
|
21
|
+
tableRef: HTMLTableElement;
|
|
22
|
+
};
|
|
23
|
+
export declare const ResizableTableContainer: ({ children, className, node, lineLength, editorView, getPos, tableRef, }: PropsWithChildren<ResizableTableContainerProps>) => JSX.Element;
|
|
24
|
+
type TableContainerProps = {
|
|
25
|
+
node: PMNode;
|
|
26
|
+
className: string;
|
|
27
|
+
containerWidth: EditorContainerWidth;
|
|
28
|
+
isFullWidthModeEnabled: boolean | undefined;
|
|
29
|
+
isBreakoutEnabled: boolean | undefined;
|
|
30
|
+
editorView: EditorView;
|
|
31
|
+
getPos: () => number;
|
|
32
|
+
tableRef: HTMLTableElement;
|
|
33
|
+
};
|
|
34
|
+
export declare const TableContainer: ({ children, node, className, containerWidth: { lineLength, width: editorWidth }, isFullWidthModeEnabled, isBreakoutEnabled, editorView, getPos, tableRef, }: PropsWithChildren<TableContainerProps>) => JSX.Element;
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
import { EditorView } from 'prosemirror-view';
|
|
3
|
+
import { Node as PMNode } from 'prosemirror-model';
|
|
4
|
+
interface TableResizerProps {
|
|
5
|
+
width: number;
|
|
6
|
+
updateWidth: (width: number) => void;
|
|
7
|
+
editorView: EditorView;
|
|
8
|
+
getPos: () => number;
|
|
9
|
+
node: PMNode;
|
|
10
|
+
tableRef: HTMLTableElement;
|
|
11
|
+
}
|
|
12
|
+
export declare const TableResizer: ({ children, width, updateWidth, editorView, getPos, node, tableRef, }: PropsWithChildren<TableResizerProps>) => JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { Node as PMNode } from 'prosemirror-model';
|
|
2
2
|
import { Transaction } from 'prosemirror-state';
|
|
3
|
-
import type { Command } from '@atlaskit/editor-common/types';
|
|
4
|
-
import type { DomAtPos } from 'prosemirror-utils';
|
|
5
|
-
import { ResizeState, ScaleOptions } from './utils';
|
|
6
3
|
import { ContentNodeWithPos } from 'prosemirror-utils';
|
|
7
|
-
|
|
4
|
+
import type { Command } from '@atlaskit/editor-common/types';
|
|
5
|
+
import { ResizeState } from './utils';
|
|
8
6
|
export declare const evenColumns: ({ resizeState, table, start, event, }: {
|
|
9
7
|
resizeState: ResizeState;
|
|
10
8
|
table: PMNode;
|
|
@@ -4,9 +4,9 @@ export { getColumnStateFromDOM, getFreeSpace, getCellsRefsInColumn, calculateCol
|
|
|
4
4
|
export type { ColumnState } from './column-state';
|
|
5
5
|
export { growColumn, shrinkColumn, reduceSpace } from './resize-logic';
|
|
6
6
|
export { getResizeState, updateColgroup, getTotalWidth, evenAllColumnsWidths, bulkColumnsResize, areColumnsEven, adjustColumnsWidths, } from './resize-state';
|
|
7
|
-
export {
|
|
7
|
+
export { getLayoutSize, getDefaultLayoutMaxWidth, pointsAtCell, currentColWidth, domCellAround, } from './misc';
|
|
8
8
|
export { updateControls, isClickNear, getResizeCellPos } from './dom';
|
|
9
|
-
export { scale, scaleWithParent } from './scale-table';
|
|
9
|
+
export { scale, scaleWithParent, scaleTable, previewScaleTable, } from './scale-table';
|
|
10
10
|
export type { ScaleOptions } from './scale-table';
|
|
11
11
|
export type { ResizeState, ResizeStateWithAnalytics } from './types';
|
|
12
12
|
export { resizeColumn } from './resize-column';
|
|
@@ -5,7 +5,6 @@ import { TableOptions } from '../../../nodeviews/types';
|
|
|
5
5
|
import { Node as PMNode } from 'prosemirror-model';
|
|
6
6
|
import { EditorState } from 'prosemirror-state';
|
|
7
7
|
import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
|
|
8
|
-
export declare const tableLayoutToSize: Record<string, number>;
|
|
9
8
|
export declare function getLayoutSize(tableLayout: TableLayout, containerWidth: number | undefined, options: TableOptions): number;
|
|
10
9
|
export declare function getDefaultLayoutMaxWidth(containerWidth?: number): number;
|
|
11
10
|
export declare function pointsAtCell($pos: ResolvedPos<any>): false | PMNode<any> | null | undefined;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Node as PMNode } from 'prosemirror-model';
|
|
2
|
+
import { Transaction } from 'prosemirror-state';
|
|
2
3
|
import type { DomAtPos } from 'prosemirror-utils';
|
|
3
4
|
import { ResizeState } from '../utils/types';
|
|
4
5
|
export interface ScaleOptions {
|
|
@@ -15,3 +16,5 @@ export interface ScaleOptions {
|
|
|
15
16
|
export declare const scale: (tableRef: HTMLTableElement, options: ScaleOptions, domAtPos: DomAtPos) => ResizeState | undefined;
|
|
16
17
|
export declare const scaleWithParent: (tableRef: HTMLTableElement, parentWidth: number, table: PMNode, start: number, domAtPos: DomAtPos) => ResizeState;
|
|
17
18
|
export declare function scaleTableTo(state: ResizeState, maxSize: number): ResizeState;
|
|
19
|
+
export declare const previewScaleTable: (tableRef: HTMLTableElement | null | undefined, options: ScaleOptions, domAtPos: DomAtPos) => void;
|
|
20
|
+
export declare const scaleTable: (tableRef: HTMLTableElement | null | undefined, options: ScaleOptions, domAtPos: DomAtPos) => (tr: Transaction) => Transaction<any>;
|
|
@@ -298,6 +298,7 @@ export declare const TableCssClassName: {
|
|
|
298
298
|
TABLE_HEADER_CELL_WRAPPER: string;
|
|
299
299
|
TABLE_ROW_CONTROLS_WRAPPER: string;
|
|
300
300
|
TABLE_COLUMN_CONTROLS_DECORATIONS: string;
|
|
301
|
+
TABLE_RESIZER_CONTAINER: string;
|
|
301
302
|
};
|
|
302
303
|
export interface ToolbarMenuConfig {
|
|
303
304
|
allowHeaderRow?: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@atlaskit/adf-schema": "^25.8.0",
|
|
30
|
-
"@atlaskit/editor-common": "^74.
|
|
30
|
+
"@atlaskit/editor-common": "^74.7.0",
|
|
31
31
|
"@atlaskit/editor-palette": "1.4.3",
|
|
32
32
|
"@atlaskit/editor-plugin-analytics": "^0.0.2",
|
|
33
33
|
"@atlaskit/editor-plugin-content-insertion": "^0.0.2",
|
|
@@ -73,10 +73,10 @@
|
|
|
73
73
|
"@atlaskit/logo": "^13.14.0",
|
|
74
74
|
"@atlaskit/media-integration-test-helpers": "^3.0.0",
|
|
75
75
|
"@atlaskit/synchrony-test-helpers": "^2.3.0",
|
|
76
|
-
"@atlaskit/util-data-test": "^17.8.0",
|
|
77
76
|
"@atlaskit/visual-regression": "*",
|
|
78
77
|
"@atlaskit/webdriver-runner": "*",
|
|
79
78
|
"@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
|
|
79
|
+
"@atlassian/feature-flags-test-utils": "^0.1.2",
|
|
80
80
|
"@testing-library/react": "^12.1.5",
|
|
81
81
|
"@types/prosemirror-history": "^1.0.1",
|
|
82
82
|
"prosemirror-history": "^1.1.3",
|
|
@@ -173,9 +173,12 @@ BrowserTestCase(
|
|
|
173
173
|
},
|
|
174
174
|
);
|
|
175
175
|
|
|
176
|
+
// FIXME: This test was automatically skipped due to failure on 10/06/2023: https://product-fabric.atlassian.net/browse/ED-18761
|
|
176
177
|
BrowserTestCase(
|
|
177
178
|
'Sticky header should resize when the width of parent scroll container changes',
|
|
178
|
-
{
|
|
179
|
+
{
|
|
180
|
+
skip: ['*'],
|
|
181
|
+
},
|
|
179
182
|
async (client: any, testName: string) => {
|
|
180
183
|
const page = await goToEditorTestingWDExample(
|
|
181
184
|
client,
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
|
|
4
|
+
import { createEditorFactory } from '@atlaskit/editor-test-helpers/create-editor';
|
|
5
|
+
import { ffTest } from '@atlassian/feature-flags-test-utils';
|
|
6
|
+
import {
|
|
7
|
+
doc,
|
|
8
|
+
p,
|
|
9
|
+
table,
|
|
10
|
+
tr,
|
|
11
|
+
td,
|
|
12
|
+
tdEmpty,
|
|
13
|
+
DocBuilder,
|
|
14
|
+
} from '@atlaskit/editor-test-helpers/doc-builder';
|
|
15
|
+
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
16
|
+
|
|
17
|
+
import { pluginKey } from '../../../plugins/table/pm-plugins/plugin-key';
|
|
18
|
+
import {
|
|
19
|
+
ResizableTableContainer,
|
|
20
|
+
TableContainer,
|
|
21
|
+
} from '../../../plugins/table/nodeviews/TableContainer';
|
|
22
|
+
import { TablePluginState } from '../../../plugins/table/types';
|
|
23
|
+
import tablePlugin from '../../../plugins/table-plugin';
|
|
24
|
+
import { TableAttributes } from '@atlaskit/adf-schema';
|
|
25
|
+
import { akEditorWideLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
26
|
+
|
|
27
|
+
describe('table -> nodeviews -> TableContainer.tsx', () => {
|
|
28
|
+
const createEditor = createEditorFactory<TablePluginState>();
|
|
29
|
+
const editor = (
|
|
30
|
+
doc: DocBuilder,
|
|
31
|
+
featureFlags?: { [featureFlag: string]: string | boolean },
|
|
32
|
+
) => {
|
|
33
|
+
return createEditor({
|
|
34
|
+
doc,
|
|
35
|
+
editorProps: {
|
|
36
|
+
allowTables: false,
|
|
37
|
+
dangerouslyAppendPlugins: {
|
|
38
|
+
__plugins: [tablePlugin()],
|
|
39
|
+
},
|
|
40
|
+
featureFlags,
|
|
41
|
+
},
|
|
42
|
+
pluginKey,
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
const createNode = (attrs?: TableAttributes) => {
|
|
46
|
+
const { editorView: view } = editor(
|
|
47
|
+
doc(p('text'), table(attrs)(tr(td()(p('{<>}text')), tdEmpty, tdEmpty))),
|
|
48
|
+
);
|
|
49
|
+
const resolvedTable = findTable(view.state.selection);
|
|
50
|
+
|
|
51
|
+
return resolvedTable!.node;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
describe('show correct container for FF and options', () => {
|
|
55
|
+
const buildContainer = (allowResizing: boolean) => {
|
|
56
|
+
const node = createNode();
|
|
57
|
+
|
|
58
|
+
const { container } = render(
|
|
59
|
+
<TableContainer
|
|
60
|
+
containerWidth={{
|
|
61
|
+
width: 1800,
|
|
62
|
+
lineLength: 720,
|
|
63
|
+
}}
|
|
64
|
+
node={node}
|
|
65
|
+
isFullWidthModeEnabled={allowResizing}
|
|
66
|
+
isBreakoutEnabled={allowResizing}
|
|
67
|
+
className={''}
|
|
68
|
+
editorView={{} as any}
|
|
69
|
+
getPos={() => 1}
|
|
70
|
+
tableRef={{} as any}
|
|
71
|
+
/>,
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
return container;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const buildTest = (
|
|
78
|
+
allowResizing: boolean,
|
|
79
|
+
expected?: { ffTrue?: boolean; ffFalse?: boolean },
|
|
80
|
+
) => {
|
|
81
|
+
ffTest(
|
|
82
|
+
'platform.editor.custom-table-width',
|
|
83
|
+
async () => {
|
|
84
|
+
const container = buildContainer(allowResizing);
|
|
85
|
+
|
|
86
|
+
expect(!!container.querySelector('.resizer-item')).toBe(
|
|
87
|
+
expected?.ffTrue ?? true,
|
|
88
|
+
);
|
|
89
|
+
},
|
|
90
|
+
async () => {
|
|
91
|
+
const container = buildContainer(allowResizing);
|
|
92
|
+
|
|
93
|
+
expect(!!container.querySelector('.resizer-item')).toBe(
|
|
94
|
+
expected?.ffFalse ?? false,
|
|
95
|
+
);
|
|
96
|
+
},
|
|
97
|
+
);
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
describe('when allowResizing is true', () => {
|
|
101
|
+
buildTest(true);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
describe('when allowResizing is false', () => {
|
|
105
|
+
buildTest(false, {
|
|
106
|
+
ffTrue: false,
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
describe('sets width and margin correctly for resizable container', () => {
|
|
112
|
+
const buildContainer = (attrs: TableAttributes) => {
|
|
113
|
+
const node = createNode(attrs);
|
|
114
|
+
|
|
115
|
+
const { container } = render(
|
|
116
|
+
<ResizableTableContainer
|
|
117
|
+
containerWidth={1800}
|
|
118
|
+
lineLength={720}
|
|
119
|
+
node={node}
|
|
120
|
+
className={''}
|
|
121
|
+
editorView={{} as any}
|
|
122
|
+
getPos={() => 1}
|
|
123
|
+
tableRef={{} as any}
|
|
124
|
+
/>,
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
return container;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
describe('when width attribute is not set', () => {
|
|
131
|
+
ffTest('platform.editor.custom-table-width', () => {
|
|
132
|
+
const container = buildContainer({ layout: 'wide' });
|
|
133
|
+
|
|
134
|
+
const style = window.getComputedStyle(container.firstChild as Element);
|
|
135
|
+
expect(style.width).toBe(`${akEditorWideLayoutWidth}px`);
|
|
136
|
+
expect(style.marginLeft).toBe('-120px');
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
describe('when width attribute is set', () => {
|
|
141
|
+
ffTest(
|
|
142
|
+
'platform.editor.custom-table-width',
|
|
143
|
+
() => {
|
|
144
|
+
const container = buildContainer({ width: 860 });
|
|
145
|
+
|
|
146
|
+
const style = window.getComputedStyle(
|
|
147
|
+
container.firstChild as Element,
|
|
148
|
+
);
|
|
149
|
+
expect(style.width).toBe(`860px`);
|
|
150
|
+
expect(style.marginLeft).toBe('-70px');
|
|
151
|
+
}, // fallback to layout because width can't be an attribute in schema
|
|
152
|
+
() => {
|
|
153
|
+
const container = buildContainer({ width: 860 });
|
|
154
|
+
|
|
155
|
+
const style = window.getComputedStyle(
|
|
156
|
+
container.firstChild as Element,
|
|
157
|
+
);
|
|
158
|
+
expect(style.width).toBe(`760px`);
|
|
159
|
+
expect(style.marginLeft).toBe('-20px');
|
|
160
|
+
},
|
|
161
|
+
);
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
});
|
|
@@ -347,6 +347,26 @@ const tablesPlugin: NextEditorPlugin<
|
|
|
347
347
|
? findStickyHeaderForTable(stickyHeadersState, tablePos)
|
|
348
348
|
: undefined;
|
|
349
349
|
|
|
350
|
+
const LayoutContent = getBooleanFF(
|
|
351
|
+
'platform.editor.custom-table-width',
|
|
352
|
+
) ? null : isLayoutSupported(state) &&
|
|
353
|
+
options &&
|
|
354
|
+
options.breakoutEnabled ? (
|
|
355
|
+
<LayoutButton
|
|
356
|
+
editorView={editorView}
|
|
357
|
+
mountPoint={popupsMountPoint}
|
|
358
|
+
boundariesElement={popupsBoundariesElement}
|
|
359
|
+
scrollableElement={popupsScrollableElement}
|
|
360
|
+
targetRef={tableWrapperTarget!}
|
|
361
|
+
layout={layout}
|
|
362
|
+
isResizing={
|
|
363
|
+
!!resizingPluginState && !!resizingPluginState.dragging
|
|
364
|
+
}
|
|
365
|
+
stickyHeader={stickyHeader}
|
|
366
|
+
editorAnalyticsAPI={options?.editorAnalyticsAPI}
|
|
367
|
+
/>
|
|
368
|
+
) : null;
|
|
369
|
+
|
|
350
370
|
return (
|
|
351
371
|
<>
|
|
352
372
|
{targetCellPosition &&
|
|
@@ -416,24 +436,7 @@ const tablesPlugin: NextEditorPlugin<
|
|
|
416
436
|
editorAnalyticsAPI={options?.editorAnalyticsAPI}
|
|
417
437
|
/>
|
|
418
438
|
)}
|
|
419
|
-
{
|
|
420
|
-
options &&
|
|
421
|
-
options.breakoutEnabled && (
|
|
422
|
-
<LayoutButton
|
|
423
|
-
editorView={editorView}
|
|
424
|
-
mountPoint={popupsMountPoint}
|
|
425
|
-
boundariesElement={popupsBoundariesElement}
|
|
426
|
-
scrollableElement={popupsScrollableElement}
|
|
427
|
-
targetRef={tableWrapperTarget!}
|
|
428
|
-
layout={layout}
|
|
429
|
-
isResizing={
|
|
430
|
-
!!resizingPluginState &&
|
|
431
|
-
!!resizingPluginState.dragging
|
|
432
|
-
}
|
|
433
|
-
stickyHeader={stickyHeader}
|
|
434
|
-
editorAnalyticsAPI={options?.editorAnalyticsAPI}
|
|
435
|
-
/>
|
|
436
|
-
)}
|
|
439
|
+
{LayoutContent}
|
|
437
440
|
</>
|
|
438
441
|
);
|
|
439
442
|
}}
|