@atlaskit/editor-plugin-table 7.6.2 → 7.6.3
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 +6 -0
- package/dist/cjs/nodeviews/TableComponent.js +25 -11
- package/dist/cjs/nodeviews/TableComponentWithSharedState.js +87 -0
- package/dist/cjs/nodeviews/TableContainer.js +8 -4
- package/dist/cjs/nodeviews/TableResizer.js +4 -5
- package/dist/cjs/nodeviews/table.js +21 -1
- package/dist/cjs/plugin.js +24 -2
- package/dist/cjs/types.js +3 -0
- package/dist/cjs/ui/TableFloatingColumnControls/ColumnControls/index.js +6 -2
- package/dist/cjs/ui/TableFloatingColumnControls/index.js +5 -2
- package/dist/cjs/ui/TableFloatingControls/CornerControls/DragCornerControls.js +48 -1
- package/dist/cjs/ui/TableFloatingControls/CornerControls/index.js +6 -0
- package/dist/cjs/ui/TableFloatingControls/FloatingControlsWithSelection.js +47 -0
- package/dist/cjs/ui/TableFloatingControls/RowControls/ClassicControls.js +3 -2
- package/dist/cjs/ui/TableFloatingControls/index.js +25 -3
- package/dist/cjs/ui/common-styles.js +11 -6
- package/dist/es2019/nodeviews/TableComponent.js +27 -12
- package/dist/es2019/nodeviews/TableComponentWithSharedState.js +83 -0
- package/dist/es2019/nodeviews/TableContainer.js +8 -4
- package/dist/es2019/nodeviews/TableResizer.js +2 -4
- package/dist/es2019/nodeviews/table.js +21 -1
- package/dist/es2019/plugin.js +25 -3
- package/dist/es2019/types.js +3 -0
- package/dist/es2019/ui/TableFloatingColumnControls/ColumnControls/index.js +7 -2
- package/dist/es2019/ui/TableFloatingColumnControls/index.js +5 -2
- package/dist/es2019/ui/TableFloatingControls/CornerControls/DragCornerControls.js +55 -0
- package/dist/es2019/ui/TableFloatingControls/CornerControls/index.js +1 -1
- package/dist/es2019/ui/TableFloatingControls/FloatingControlsWithSelection.js +42 -0
- package/dist/es2019/ui/TableFloatingControls/RowControls/ClassicControls.js +3 -2
- package/dist/es2019/ui/TableFloatingControls/index.js +26 -4
- package/dist/es2019/ui/common-styles.js +589 -588
- package/dist/esm/nodeviews/TableComponent.js +25 -11
- package/dist/esm/nodeviews/TableComponentWithSharedState.js +80 -0
- package/dist/esm/nodeviews/TableContainer.js +8 -4
- package/dist/esm/nodeviews/TableResizer.js +4 -5
- package/dist/esm/nodeviews/table.js +21 -1
- package/dist/esm/plugin.js +25 -3
- package/dist/esm/types.js +3 -0
- package/dist/esm/ui/TableFloatingColumnControls/ColumnControls/index.js +6 -2
- package/dist/esm/ui/TableFloatingColumnControls/index.js +5 -2
- package/dist/esm/ui/TableFloatingControls/CornerControls/DragCornerControls.js +47 -0
- package/dist/esm/ui/TableFloatingControls/CornerControls/index.js +1 -1
- package/dist/esm/ui/TableFloatingControls/FloatingControlsWithSelection.js +40 -0
- package/dist/esm/ui/TableFloatingControls/RowControls/ClassicControls.js +3 -2
- package/dist/esm/ui/TableFloatingControls/index.js +26 -4
- package/dist/esm/ui/common-styles.js +10 -5
- package/dist/types/nodeviews/TableComponent.d.ts +7 -2
- package/dist/types/nodeviews/TableComponentWithSharedState.d.ts +27 -0
- package/dist/types/nodeviews/TableContainer.d.ts +4 -2
- package/dist/types/nodeviews/TableResizer.d.ts +2 -1
- package/dist/types/nodeviews/types.d.ts +1 -0
- package/dist/types/plugin.d.ts +11 -7
- package/dist/types/types.d.ts +8 -2
- package/dist/types/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +113 -1
- package/dist/types/ui/TableFloatingColumnControls/index.d.ts +3 -2
- package/dist/types/ui/TableFloatingControls/CornerControls/DragCornerControls.d.ts +223 -0
- package/dist/types/ui/TableFloatingControls/CornerControls/index.d.ts +1 -1
- package/dist/types/ui/TableFloatingControls/FloatingControlsWithSelection.d.ts +20 -0
- package/dist/types/ui/TableFloatingControls/RowControls/ClassicControls.d.ts +2 -0
- package/dist/types/ui/TableFloatingControls/index.d.ts +113 -1
- package/dist/types/ui/common-styles.d.ts +3 -0
- package/dist/types-ts4.5/nodeviews/TableComponent.d.ts +7 -2
- package/dist/types-ts4.5/nodeviews/TableComponentWithSharedState.d.ts +27 -0
- package/dist/types-ts4.5/nodeviews/TableContainer.d.ts +4 -2
- package/dist/types-ts4.5/nodeviews/TableResizer.d.ts +2 -1
- package/dist/types-ts4.5/nodeviews/types.d.ts +1 -0
- package/dist/types-ts4.5/plugin.d.ts +11 -7
- package/dist/types-ts4.5/types.d.ts +8 -2
- package/dist/types-ts4.5/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +144 -1
- package/dist/types-ts4.5/ui/TableFloatingColumnControls/index.d.ts +3 -2
- package/dist/types-ts4.5/ui/TableFloatingControls/CornerControls/DragCornerControls.d.ts +285 -0
- package/dist/types-ts4.5/ui/TableFloatingControls/CornerControls/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/TableFloatingControls/FloatingControlsWithSelection.d.ts +20 -0
- package/dist/types-ts4.5/ui/TableFloatingControls/RowControls/ClassicControls.d.ts +2 -0
- package/dist/types-ts4.5/ui/TableFloatingControls/index.d.ts +144 -1
- package/dist/types-ts4.5/ui/common-styles.d.ts +3 -0
- package/package.json +6 -3
- package/src/nodeviews/TableComponent.tsx +36 -7
- package/src/nodeviews/TableComponentWithSharedState.tsx +125 -0
- package/src/nodeviews/TableContainer.tsx +6 -0
- package/src/nodeviews/TableResizer.tsx +2 -1
- package/src/nodeviews/table.tsx +22 -1
- package/src/nodeviews/types.ts +1 -0
- package/src/plugin.tsx +46 -6
- package/src/types.ts +27 -2
- package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +10 -2
- package/src/ui/TableFloatingColumnControls/index.tsx +13 -1
- package/src/ui/TableFloatingControls/CornerControls/DragCornerControls.tsx +58 -0
- package/src/ui/TableFloatingControls/CornerControls/index.tsx +4 -1
- package/src/ui/TableFloatingControls/FloatingControlsWithSelection.tsx +68 -0
- package/src/ui/TableFloatingControls/RowControls/ClassicControls.tsx +4 -1
- package/src/ui/TableFloatingControls/index.tsx +42 -8
- package/src/ui/common-styles.ts +611 -610
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { TableColumnOrdering } from '@atlaskit/custom-steps';
|
|
3
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
4
|
import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
4
5
|
import type { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
5
6
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
7
|
+
import type { TablePlugin } from '../../plugin';
|
|
6
8
|
import type { RowStickyState } from '../../pm-plugins/sticky-headers';
|
|
7
9
|
import type { CellHoverMeta } from '../../types';
|
|
8
10
|
export interface TableFloatingControlsProps {
|
|
@@ -27,5 +29,146 @@ export interface TableFloatingControlsProps {
|
|
|
27
29
|
insertRowButtonIndex?: number;
|
|
28
30
|
tableWrapperWidth?: number;
|
|
29
31
|
}
|
|
30
|
-
export declare const TableFloatingControls: ({ editorView, tableRef, tableNode, isInDanger, isResizing, isNumberColumnEnabled, isHeaderRowEnabled, isHeaderColumnEnabled, tableActive, hasHeaderRow, hoveredRows, stickyHeader, isDragAndDropEnabled, hoveredCell, isTableHovered, tableWrapperWidth, }: TableFloatingControlsProps
|
|
32
|
+
export declare const TableFloatingControls: ({ editorView, tableRef, tableNode, isInDanger, isResizing, isNumberColumnEnabled, isHeaderRowEnabled, isHeaderColumnEnabled, tableActive, hasHeaderRow, hoveredRows, stickyHeader, isDragAndDropEnabled, hoveredCell, isTableHovered, tableWrapperWidth, api, }: TableFloatingControlsProps & {
|
|
33
|
+
api?: import("@atlaskit/editor-common/types").PublicPluginAPI<[
|
|
34
|
+
import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"table", {
|
|
35
|
+
pluginConfiguration: import("../../plugin").TablePluginOptions | undefined;
|
|
36
|
+
actions: {
|
|
37
|
+
insertTable: (analyticsPayload: import("@atlaskit/editor-common/analytics").AnalyticsEventPayload) => import("@atlaskit/editor-common/types").Command;
|
|
38
|
+
};
|
|
39
|
+
sharedState?: import("../../types").TableSharedState | undefined;
|
|
40
|
+
commands: {
|
|
41
|
+
insertTableWithSize: (rowsCount: number, colsCount: number, inputMethod?: import("@atlaskit/editor-common/analytics").INPUT_METHOD.PICKER | undefined) => import("@atlaskit/editor-common/types").EditorCommand;
|
|
42
|
+
};
|
|
43
|
+
dependencies: [
|
|
44
|
+
import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"analytics", {
|
|
45
|
+
pluginConfiguration: import("@atlaskit/editor-plugin-analytics").AnalyticsPluginOptions;
|
|
46
|
+
sharedState: {
|
|
47
|
+
createAnalyticsEvent: import("@atlaskit/analytics-next").CreateUIAnalyticsEvent | null;
|
|
48
|
+
attachAnalyticsEvent: import("@atlaskit/editor-plugin-analytics").CreateAttachPayloadIntoTransaction | null;
|
|
49
|
+
performanceTracking: import("@atlaskit/editor-common/types").PerformanceTracking | undefined;
|
|
50
|
+
};
|
|
51
|
+
dependencies: [
|
|
52
|
+
import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"featureFlags", {
|
|
53
|
+
pluginConfiguration: import("@atlaskit/editor-common/types").FeatureFlags;
|
|
54
|
+
sharedState: import("@atlaskit/editor-common/types").FeatureFlags;
|
|
55
|
+
}, import("@atlaskit/editor-common/types").FeatureFlags>>
|
|
56
|
+
];
|
|
57
|
+
actions: import("@atlaskit/editor-common/analytics").EditorAnalyticsAPI;
|
|
58
|
+
}, import("@atlaskit/editor-plugin-analytics").AnalyticsPluginOptions>,
|
|
59
|
+
import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"contentInsertion", {
|
|
60
|
+
actions: import("@atlaskit/editor-plugin-content-insertion").InsertNodeAPI;
|
|
61
|
+
dependencies: [
|
|
62
|
+
import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"analytics", {
|
|
63
|
+
pluginConfiguration: import("@atlaskit/editor-plugin-analytics").AnalyticsPluginOptions;
|
|
64
|
+
sharedState: {
|
|
65
|
+
createAnalyticsEvent: import("@atlaskit/analytics-next").CreateUIAnalyticsEvent | null;
|
|
66
|
+
attachAnalyticsEvent: import("@atlaskit/editor-plugin-analytics").CreateAttachPayloadIntoTransaction | null;
|
|
67
|
+
performanceTracking: import("@atlaskit/editor-common/types").PerformanceTracking | undefined;
|
|
68
|
+
};
|
|
69
|
+
dependencies: [
|
|
70
|
+
import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"featureFlags", {
|
|
71
|
+
pluginConfiguration: import("@atlaskit/editor-common/types").FeatureFlags;
|
|
72
|
+
sharedState: import("@atlaskit/editor-common/types").FeatureFlags;
|
|
73
|
+
}, import("@atlaskit/editor-common/types").FeatureFlags>>
|
|
74
|
+
];
|
|
75
|
+
actions: import("@atlaskit/editor-common/analytics").EditorAnalyticsAPI;
|
|
76
|
+
}, import("@atlaskit/editor-plugin-analytics").AnalyticsPluginOptions>
|
|
77
|
+
];
|
|
78
|
+
}, undefined>,
|
|
79
|
+
import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"width", {
|
|
80
|
+
sharedState: import("@atlaskit/editor-common/types").EditorContainerWidth | undefined;
|
|
81
|
+
}, undefined>,
|
|
82
|
+
import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"guideline", {
|
|
83
|
+
dependencies: [
|
|
84
|
+
import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"width", {
|
|
85
|
+
sharedState: import("@atlaskit/editor-common/types").EditorContainerWidth | undefined;
|
|
86
|
+
}, undefined>
|
|
87
|
+
];
|
|
88
|
+
sharedState: import("@atlaskit/editor-common/guideline").GuidelinePluginState | null;
|
|
89
|
+
actions: {
|
|
90
|
+
displayGuideline: import("@atlaskit/editor-common/guideline").DisplayGuideline;
|
|
91
|
+
};
|
|
92
|
+
}, undefined>,
|
|
93
|
+
import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"selection", {
|
|
94
|
+
pluginConfiguration: import("@atlaskit/editor-plugin-selection/types").SelectionPluginOptions | undefined;
|
|
95
|
+
actions: import("@atlaskit/editor-plugin-selection").EditorSelectionAPI;
|
|
96
|
+
commands: {
|
|
97
|
+
displayGapCursor: (toggle: boolean) => import("@atlaskit/editor-common/types").EditorCommand;
|
|
98
|
+
};
|
|
99
|
+
sharedState: import("@atlaskit/editor-common/selection").SelectionSharedState;
|
|
100
|
+
}, import("@atlaskit/editor-plugin-selection/types").SelectionPluginOptions | undefined>,
|
|
101
|
+
import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"media", {
|
|
102
|
+
pluginConfiguration: any;
|
|
103
|
+
dependencies: any;
|
|
104
|
+
sharedState: any;
|
|
105
|
+
actions: any;
|
|
106
|
+
}, any>>
|
|
107
|
+
];
|
|
108
|
+
}, import("../../plugin").TablePluginOptions | undefined>,
|
|
109
|
+
import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"analytics", {
|
|
110
|
+
pluginConfiguration: import("@atlaskit/editor-plugin-analytics").AnalyticsPluginOptions;
|
|
111
|
+
sharedState: {
|
|
112
|
+
createAnalyticsEvent: import("@atlaskit/analytics-next").CreateUIAnalyticsEvent | null;
|
|
113
|
+
attachAnalyticsEvent: import("@atlaskit/editor-plugin-analytics").CreateAttachPayloadIntoTransaction | null;
|
|
114
|
+
performanceTracking: import("@atlaskit/editor-common/types").PerformanceTracking | undefined;
|
|
115
|
+
};
|
|
116
|
+
dependencies: [
|
|
117
|
+
import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"featureFlags", {
|
|
118
|
+
pluginConfiguration: import("@atlaskit/editor-common/types").FeatureFlags;
|
|
119
|
+
sharedState: import("@atlaskit/editor-common/types").FeatureFlags;
|
|
120
|
+
}, import("@atlaskit/editor-common/types").FeatureFlags>>
|
|
121
|
+
];
|
|
122
|
+
actions: import("@atlaskit/editor-common/analytics").EditorAnalyticsAPI;
|
|
123
|
+
}, import("@atlaskit/editor-plugin-analytics").AnalyticsPluginOptions>,
|
|
124
|
+
import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"contentInsertion", {
|
|
125
|
+
actions: import("@atlaskit/editor-plugin-content-insertion").InsertNodeAPI;
|
|
126
|
+
dependencies: [
|
|
127
|
+
import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"analytics", {
|
|
128
|
+
pluginConfiguration: import("@atlaskit/editor-plugin-analytics").AnalyticsPluginOptions;
|
|
129
|
+
sharedState: {
|
|
130
|
+
createAnalyticsEvent: import("@atlaskit/analytics-next").CreateUIAnalyticsEvent | null;
|
|
131
|
+
attachAnalyticsEvent: import("@atlaskit/editor-plugin-analytics").CreateAttachPayloadIntoTransaction | null;
|
|
132
|
+
performanceTracking: import("@atlaskit/editor-common/types").PerformanceTracking | undefined;
|
|
133
|
+
};
|
|
134
|
+
dependencies: [
|
|
135
|
+
import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"featureFlags", {
|
|
136
|
+
pluginConfiguration: import("@atlaskit/editor-common/types").FeatureFlags;
|
|
137
|
+
sharedState: import("@atlaskit/editor-common/types").FeatureFlags;
|
|
138
|
+
}, import("@atlaskit/editor-common/types").FeatureFlags>>
|
|
139
|
+
];
|
|
140
|
+
actions: import("@atlaskit/editor-common/analytics").EditorAnalyticsAPI;
|
|
141
|
+
}, import("@atlaskit/editor-plugin-analytics").AnalyticsPluginOptions>
|
|
142
|
+
];
|
|
143
|
+
}, undefined>,
|
|
144
|
+
import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"width", {
|
|
145
|
+
sharedState: import("@atlaskit/editor-common/types").EditorContainerWidth | undefined;
|
|
146
|
+
}, undefined>,
|
|
147
|
+
import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"guideline", {
|
|
148
|
+
dependencies: [
|
|
149
|
+
import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"width", {
|
|
150
|
+
sharedState: import("@atlaskit/editor-common/types").EditorContainerWidth | undefined;
|
|
151
|
+
}, undefined>
|
|
152
|
+
];
|
|
153
|
+
sharedState: import("@atlaskit/editor-common/guideline").GuidelinePluginState | null;
|
|
154
|
+
actions: {
|
|
155
|
+
displayGuideline: import("@atlaskit/editor-common/guideline").DisplayGuideline;
|
|
156
|
+
};
|
|
157
|
+
}, undefined>,
|
|
158
|
+
import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"selection", {
|
|
159
|
+
pluginConfiguration: import("@atlaskit/editor-plugin-selection/types").SelectionPluginOptions | undefined;
|
|
160
|
+
actions: import("@atlaskit/editor-plugin-selection").EditorSelectionAPI;
|
|
161
|
+
commands: {
|
|
162
|
+
displayGapCursor: (toggle: boolean) => import("@atlaskit/editor-common/types").EditorCommand;
|
|
163
|
+
};
|
|
164
|
+
sharedState: import("@atlaskit/editor-common/selection").SelectionSharedState;
|
|
165
|
+
}, import("@atlaskit/editor-plugin-selection/types").SelectionPluginOptions | undefined>,
|
|
166
|
+
import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"media", {
|
|
167
|
+
pluginConfiguration: any;
|
|
168
|
+
dependencies: any;
|
|
169
|
+
sharedState: any;
|
|
170
|
+
actions: any;
|
|
171
|
+
}, any>>
|
|
172
|
+
]> | undefined;
|
|
173
|
+
}) => JSX.Element | null;
|
|
31
174
|
export default TableFloatingControls;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { FeatureFlags } from '@atlaskit/editor-common/types';
|
|
2
2
|
export declare const insertColumnButtonOffset: number;
|
|
3
3
|
export declare const tableRowHeight = 44;
|
|
4
|
+
export declare const baseTableStyles: (props: {
|
|
5
|
+
featureFlags?: FeatureFlags;
|
|
6
|
+
}) => import("@emotion/react").SerializedStyles;
|
|
4
7
|
export declare const tableStyles: (props: {
|
|
5
8
|
featureFlags?: FeatureFlags;
|
|
6
9
|
}) => import("@emotion/react").SerializedStyles;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "7.6.
|
|
3
|
+
"version": "7.6.3",
|
|
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.7.0",
|
|
32
32
|
"@atlaskit/custom-steps": "^0.0.16",
|
|
33
|
-
"@atlaskit/editor-common": "^78.
|
|
33
|
+
"@atlaskit/editor-common": "^78.21.0",
|
|
34
34
|
"@atlaskit/editor-palette": "1.5.3",
|
|
35
35
|
"@atlaskit/editor-plugin-analytics": "^1.0.0",
|
|
36
36
|
"@atlaskit/editor-plugin-content-insertion": "^1.0.0",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^1.0.0",
|
|
48
48
|
"@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.0.0",
|
|
49
49
|
"@atlaskit/primitives": "^5.1.0",
|
|
50
|
-
"@atlaskit/theme": "^12.
|
|
50
|
+
"@atlaskit/theme": "^12.7.0",
|
|
51
51
|
"@atlaskit/toggle": "^13.0.0",
|
|
52
52
|
"@atlaskit/tokens": "^1.42.0",
|
|
53
53
|
"@atlaskit/tooltip": "^18.1.0",
|
|
@@ -148,6 +148,9 @@
|
|
|
148
148
|
},
|
|
149
149
|
"platform.editor.table.cmd-a-select-table": {
|
|
150
150
|
"type": "boolean"
|
|
151
|
+
},
|
|
152
|
+
"platform.editor.table.use-shared-state-hook": {
|
|
153
|
+
"type": "boolean"
|
|
151
154
|
}
|
|
152
155
|
}
|
|
153
156
|
}
|
|
@@ -57,7 +57,7 @@ import {
|
|
|
57
57
|
import { hasTableBeenResized } from '../pm-plugins/table-resizing/utils/colgroup';
|
|
58
58
|
import { TABLE_EDITOR_MARGIN } from '../pm-plugins/table-resizing/utils/consts';
|
|
59
59
|
import { updateControls } from '../pm-plugins/table-resizing/utils/dom';
|
|
60
|
-
import type { PluginInjectionAPI } from '../types';
|
|
60
|
+
import type { CellHoverMeta, PluginInjectionAPI } from '../types';
|
|
61
61
|
import { TableCssClassName as ClassName, ShadowEvent } from '../types';
|
|
62
62
|
import {
|
|
63
63
|
tableOverflowShadowWidth,
|
|
@@ -107,11 +107,18 @@ export interface ComponentProps {
|
|
|
107
107
|
isDragAndDropEnabled?: boolean;
|
|
108
108
|
isTableScalingEnabled?: boolean;
|
|
109
109
|
tableActive: boolean;
|
|
110
|
-
ordering
|
|
110
|
+
ordering?: TableColumnOrdering;
|
|
111
111
|
isResizing?: boolean;
|
|
112
112
|
getEditorFeatureFlags: GetEditorFeatureFlags;
|
|
113
113
|
dispatchAnalyticsEvent: DispatchAnalyticsEvent;
|
|
114
114
|
pluginInjectionApi?: PluginInjectionAPI;
|
|
115
|
+
|
|
116
|
+
// marking props as option to ensure backward compatibility when platform.editor.table.use-shared-state-hook disabled
|
|
117
|
+
isInDanger?: boolean;
|
|
118
|
+
hoveredRows?: number[];
|
|
119
|
+
hoveredCell?: CellHoverMeta;
|
|
120
|
+
isTableHovered?: boolean;
|
|
121
|
+
isWholeTableInDanger?: boolean;
|
|
115
122
|
}
|
|
116
123
|
|
|
117
124
|
interface TableState {
|
|
@@ -392,9 +399,15 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
392
399
|
isTableScalingEnabled,
|
|
393
400
|
getPos,
|
|
394
401
|
} = this.props;
|
|
395
|
-
|
|
402
|
+
let { isInDanger } = this.props;
|
|
403
|
+
|
|
396
404
|
const table = findTable(view.state.selection);
|
|
397
405
|
|
|
406
|
+
if (!getBooleanFF('platform.editor.table.use-shared-state-hook')) {
|
|
407
|
+
const pluginState = getPluginState(view.state);
|
|
408
|
+
isInDanger = pluginState.isInDanger;
|
|
409
|
+
}
|
|
410
|
+
|
|
398
411
|
if (isTableScalingEnabled) {
|
|
399
412
|
this.handleColgroupUpdates();
|
|
400
413
|
}
|
|
@@ -454,7 +467,6 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
454
467
|
isNoOfColumnsChanged
|
|
455
468
|
) {
|
|
456
469
|
const { view } = this.props;
|
|
457
|
-
|
|
458
470
|
const shouldRecreateResizeCols =
|
|
459
471
|
!options?.isTableResizingEnabled ||
|
|
460
472
|
!isResizing ||
|
|
@@ -570,11 +582,25 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
570
582
|
isTableScalingEnabled,
|
|
571
583
|
} = this.props;
|
|
572
584
|
|
|
585
|
+
let {
|
|
586
|
+
isInDanger,
|
|
587
|
+
hoveredRows,
|
|
588
|
+
hoveredCell,
|
|
589
|
+
isTableHovered,
|
|
590
|
+
isWholeTableInDanger,
|
|
591
|
+
} = this.props;
|
|
592
|
+
|
|
573
593
|
const { showBeforeShadow, showAfterShadow } = this.state;
|
|
574
594
|
const node = getNode();
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
getPluginState(view.state);
|
|
595
|
+
|
|
596
|
+
if (!getBooleanFF('platform.editor.table.use-shared-state-hook')) {
|
|
597
|
+
const pluginState = getPluginState(view.state);
|
|
598
|
+
isInDanger = pluginState.isInDanger;
|
|
599
|
+
hoveredRows = pluginState.hoveredRows;
|
|
600
|
+
hoveredCell = pluginState.hoveredCell;
|
|
601
|
+
isTableHovered = pluginState.isTableHovered;
|
|
602
|
+
isWholeTableInDanger = pluginState.isWholeTableInDanger;
|
|
603
|
+
}
|
|
578
604
|
|
|
579
605
|
const tableRef = this.table || undefined;
|
|
580
606
|
const headerRow = tableRef
|
|
@@ -604,6 +630,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
604
630
|
headerRowHeight={headerRow ? headerRow.offsetHeight : undefined}
|
|
605
631
|
stickyHeader={this.state.stickyHeader}
|
|
606
632
|
tableWrapperWidth={this.state.tableWrapperWidth}
|
|
633
|
+
api={pluginInjectionApi}
|
|
607
634
|
/>
|
|
608
635
|
);
|
|
609
636
|
const tableContainerWidth = getTableContainerWidth(node);
|
|
@@ -629,6 +656,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
629
656
|
isNumberColumnEnabled={node.attrs.isNumberColumnEnabled}
|
|
630
657
|
getScrollOffset={() => this.wrapper?.scrollLeft || 0}
|
|
631
658
|
tableWrapperHeight={this.state.tableWrapperHeight}
|
|
659
|
+
api={pluginInjectionApi}
|
|
632
660
|
/>
|
|
633
661
|
) : null;
|
|
634
662
|
|
|
@@ -685,6 +713,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
685
713
|
isTableResizingEnabled={options?.isTableResizingEnabled}
|
|
686
714
|
isResizing={isResizing}
|
|
687
715
|
isTableScalingEnabled={isTableScalingEnabled}
|
|
716
|
+
isWholeTableInDanger={isWholeTableInDanger}
|
|
688
717
|
>
|
|
689
718
|
<div
|
|
690
719
|
className={ClassName.TABLE_STICKY_SENTINEL_TOP}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
4
|
+
import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
|
|
5
|
+
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
6
|
+
import type {
|
|
7
|
+
GetEditorFeatureFlags,
|
|
8
|
+
getPosHandlerNode,
|
|
9
|
+
} from '@atlaskit/editor-common/types';
|
|
10
|
+
import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
11
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
12
|
+
import { findTable } from '@atlaskit/editor-tables';
|
|
13
|
+
|
|
14
|
+
import type { PluginInjectionAPI, TableSharedStateInternal } from '../types';
|
|
15
|
+
|
|
16
|
+
import TableComponent from './TableComponent';
|
|
17
|
+
import type { TableOptions } from './types';
|
|
18
|
+
|
|
19
|
+
type ForwardRef = (node: HTMLElement | null) => any;
|
|
20
|
+
|
|
21
|
+
type TableComponentWithSharedStateProps = {
|
|
22
|
+
view: EditorView;
|
|
23
|
+
options?: TableOptions;
|
|
24
|
+
getNode: () => PmNode;
|
|
25
|
+
dispatchAnalyticsEvent: DispatchAnalyticsEvent;
|
|
26
|
+
getEditorFeatureFlags: GetEditorFeatureFlags;
|
|
27
|
+
api?: PluginInjectionAPI;
|
|
28
|
+
eventDispatcher: EventDispatcher;
|
|
29
|
+
forwardRef: ForwardRef;
|
|
30
|
+
getPos: getPosHandlerNode;
|
|
31
|
+
allowColumnResizing?: boolean;
|
|
32
|
+
allowControls?: boolean;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Use useSharedPluginState to control re-renders from plugin dependencies
|
|
37
|
+
*/
|
|
38
|
+
export const TableComponentWithSharedState = ({
|
|
39
|
+
view,
|
|
40
|
+
options,
|
|
41
|
+
getNode,
|
|
42
|
+
dispatchAnalyticsEvent,
|
|
43
|
+
api,
|
|
44
|
+
getEditorFeatureFlags,
|
|
45
|
+
eventDispatcher,
|
|
46
|
+
allowColumnResizing,
|
|
47
|
+
allowControls,
|
|
48
|
+
getPos,
|
|
49
|
+
forwardRef,
|
|
50
|
+
}: TableComponentWithSharedStateProps) => {
|
|
51
|
+
const { widthState, tableState, mediaState } = useSharedPluginState(api, [
|
|
52
|
+
'width',
|
|
53
|
+
'table',
|
|
54
|
+
'media',
|
|
55
|
+
]);
|
|
56
|
+
|
|
57
|
+
if (!tableState) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const {
|
|
62
|
+
isTableResizing,
|
|
63
|
+
isHeaderColumnEnabled,
|
|
64
|
+
isHeaderRowEnabled,
|
|
65
|
+
ordering,
|
|
66
|
+
isResizing,
|
|
67
|
+
isInDanger,
|
|
68
|
+
hoveredCell,
|
|
69
|
+
hoveredRows,
|
|
70
|
+
isTableHovered,
|
|
71
|
+
isWholeTableInDanger,
|
|
72
|
+
} = tableState as TableSharedStateInternal;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* ED-19810
|
|
76
|
+
* There is a getPos issue coming from this code. We need to apply this workaround for now and apply a patch
|
|
77
|
+
* directly to confluence since this bug is now in production.
|
|
78
|
+
*/
|
|
79
|
+
let currentTablePos: number | undefined;
|
|
80
|
+
try {
|
|
81
|
+
currentTablePos = getPos ? getPos() : undefined;
|
|
82
|
+
} catch (e) {
|
|
83
|
+
currentTablePos = undefined;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const selectedTable = findTable(view.state.selection);
|
|
87
|
+
|
|
88
|
+
const tablePos = selectedTable && selectedTable.start - 1;
|
|
89
|
+
|
|
90
|
+
const tableActive =
|
|
91
|
+
typeof currentTablePos === 'number' &&
|
|
92
|
+
typeof tablePos === 'number' &&
|
|
93
|
+
currentTablePos === tablePos &&
|
|
94
|
+
!isTableResizing;
|
|
95
|
+
|
|
96
|
+
return (
|
|
97
|
+
<TableComponent
|
|
98
|
+
view={view}
|
|
99
|
+
allowColumnResizing={allowColumnResizing}
|
|
100
|
+
eventDispatcher={eventDispatcher}
|
|
101
|
+
getPos={getPos}
|
|
102
|
+
isMediaFullscreen={mediaState?.isFullscreen}
|
|
103
|
+
options={options}
|
|
104
|
+
allowControls={!!allowControls}
|
|
105
|
+
isHeaderRowEnabled={isHeaderRowEnabled}
|
|
106
|
+
isHeaderColumnEnabled={isHeaderColumnEnabled}
|
|
107
|
+
isDragAndDropEnabled={options?.isDragAndDropEnabled}
|
|
108
|
+
isTableScalingEnabled={options?.isTableScalingEnabled}
|
|
109
|
+
tableActive={tableActive}
|
|
110
|
+
ordering={ordering}
|
|
111
|
+
isResizing={isResizing}
|
|
112
|
+
getNode={getNode}
|
|
113
|
+
containerWidth={widthState!}
|
|
114
|
+
contentDOM={forwardRef}
|
|
115
|
+
getEditorFeatureFlags={getEditorFeatureFlags}
|
|
116
|
+
dispatchAnalyticsEvent={dispatchAnalyticsEvent}
|
|
117
|
+
pluginInjectionApi={api}
|
|
118
|
+
isInDanger={!!isInDanger}
|
|
119
|
+
hoveredRows={hoveredRows}
|
|
120
|
+
hoveredCell={hoveredCell}
|
|
121
|
+
isTableHovered={isTableHovered}
|
|
122
|
+
isWholeTableInDanger={isWholeTableInDanger}
|
|
123
|
+
/>
|
|
124
|
+
);
|
|
125
|
+
};
|
|
@@ -79,6 +79,7 @@ type ResizableTableContainerProps = {
|
|
|
79
79
|
pluginInjectionApi?: PluginInjectionAPI;
|
|
80
80
|
isTableScalingEnabled?: boolean;
|
|
81
81
|
tableWrapperHeight?: number;
|
|
82
|
+
isWholeTableInDanger?: boolean;
|
|
82
83
|
};
|
|
83
84
|
|
|
84
85
|
export const ResizableTableContainer = React.memo(
|
|
@@ -94,6 +95,7 @@ export const ResizableTableContainer = React.memo(
|
|
|
94
95
|
pluginInjectionApi,
|
|
95
96
|
isTableScalingEnabled,
|
|
96
97
|
tableWrapperHeight,
|
|
98
|
+
isWholeTableInDanger,
|
|
97
99
|
}: PropsWithChildren<ResizableTableContainerProps>) => {
|
|
98
100
|
const containerRef = useRef<HTMLDivElement | null>(null);
|
|
99
101
|
const tableWidthRef = useRef<number>(akEditorDefaultLayoutWidth);
|
|
@@ -207,6 +209,7 @@ export const ResizableTableContainer = React.memo(
|
|
|
207
209
|
attachAnalyticsEvent,
|
|
208
210
|
displayGapCursor,
|
|
209
211
|
isTableScalingEnabled,
|
|
212
|
+
isWholeTableInDanger,
|
|
210
213
|
};
|
|
211
214
|
|
|
212
215
|
if (getBooleanFF('platform.editor.resizing-table-height-improvement')) {
|
|
@@ -259,6 +262,7 @@ type TableContainerProps = {
|
|
|
259
262
|
pluginInjectionApi?: PluginInjectionAPI;
|
|
260
263
|
isTableScalingEnabled?: boolean;
|
|
261
264
|
tableWrapperHeight?: number;
|
|
265
|
+
isWholeTableInDanger?: boolean;
|
|
262
266
|
};
|
|
263
267
|
|
|
264
268
|
export const TableContainer = ({
|
|
@@ -276,6 +280,7 @@ export const TableContainer = ({
|
|
|
276
280
|
isResizing,
|
|
277
281
|
pluginInjectionApi,
|
|
278
282
|
isTableScalingEnabled,
|
|
283
|
+
isWholeTableInDanger,
|
|
279
284
|
}: PropsWithChildren<TableContainerProps>) => {
|
|
280
285
|
if (isTableResizingEnabled && !isNested) {
|
|
281
286
|
return (
|
|
@@ -290,6 +295,7 @@ export const TableContainer = ({
|
|
|
290
295
|
isResizing={isResizing}
|
|
291
296
|
pluginInjectionApi={pluginInjectionApi}
|
|
292
297
|
isTableScalingEnabled={isTableScalingEnabled}
|
|
298
|
+
isWholeTableInDanger={isWholeTableInDanger}
|
|
293
299
|
>
|
|
294
300
|
{children}
|
|
295
301
|
</ResizableTableContainer>
|
|
@@ -78,6 +78,7 @@ interface TableResizerProps {
|
|
|
78
78
|
) => ((tr: Transaction) => boolean) | undefined;
|
|
79
79
|
displayGapCursor: (toggle: boolean) => boolean;
|
|
80
80
|
isTableScalingEnabled?: boolean;
|
|
81
|
+
isWholeTableInDanger?: boolean;
|
|
81
82
|
}
|
|
82
83
|
|
|
83
84
|
export interface TableResizerImprovementProps extends TableResizerProps {
|
|
@@ -170,6 +171,7 @@ export const TableResizer = ({
|
|
|
170
171
|
attachAnalyticsEvent,
|
|
171
172
|
displayGapCursor,
|
|
172
173
|
isTableScalingEnabled,
|
|
174
|
+
isWholeTableInDanger,
|
|
173
175
|
}: PropsWithChildren<TableResizerImprovementProps>) => {
|
|
174
176
|
const currentGap = useRef(0);
|
|
175
177
|
// track resizing state - use ref over state to avoid re-render
|
|
@@ -208,7 +210,6 @@ export const TableResizer = ({
|
|
|
208
210
|
|
|
209
211
|
const resizerMinWidth = getResizerMinWidth(node);
|
|
210
212
|
const handleSize = getResizerHandleHeight(tableRef);
|
|
211
|
-
const { isWholeTableInDanger } = getPluginState(editorView.state);
|
|
212
213
|
|
|
213
214
|
const { startMeasure, endMeasure, countFrames } = useMeasureFramerate();
|
|
214
215
|
|
package/src/nodeviews/table.tsx
CHANGED
|
@@ -25,6 +25,7 @@ import type {
|
|
|
25
25
|
import type { EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
|
|
26
26
|
import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
|
|
27
27
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
28
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
28
29
|
|
|
29
30
|
import { pluginConfig as getPluginConfig } from '../create-plugin-config';
|
|
30
31
|
import { pluginKey as tableDragAndDropPluginKey } from '../pm-plugins/drag-and-drop';
|
|
@@ -37,6 +38,7 @@ import type { PluginInjectionAPI } from '../types';
|
|
|
37
38
|
import { isTableNested } from '../utils';
|
|
38
39
|
|
|
39
40
|
import TableComponent from './TableComponent';
|
|
41
|
+
import { TableComponentWithSharedState } from './TableComponentWithSharedState';
|
|
40
42
|
import type { Props } from './types';
|
|
41
43
|
|
|
42
44
|
type ForwardRef = (node: HTMLElement | null) => void;
|
|
@@ -182,6 +184,24 @@ export default class TableView extends ReactNodeView<Props> {
|
|
|
182
184
|
};
|
|
183
185
|
|
|
184
186
|
render(props: Props, forwardRef: ForwardRef) {
|
|
187
|
+
if (getBooleanFF('platform.editor.table.use-shared-state-hook')) {
|
|
188
|
+
return (
|
|
189
|
+
<TableComponentWithSharedState
|
|
190
|
+
forwardRef={forwardRef}
|
|
191
|
+
getNode={this.getNode}
|
|
192
|
+
view={props.view}
|
|
193
|
+
options={props.options}
|
|
194
|
+
eventDispatcher={props.eventDispatcher}
|
|
195
|
+
api={props.pluginInjectionApi}
|
|
196
|
+
allowColumnResizing={props.allowColumnResizing}
|
|
197
|
+
allowControls={props.allowControls}
|
|
198
|
+
getPos={props.getPos}
|
|
199
|
+
getEditorFeatureFlags={props.getEditorFeatureFlags}
|
|
200
|
+
dispatchAnalyticsEvent={props.dispatchAnalyticsEvent}
|
|
201
|
+
/>
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
|
|
185
205
|
// TODO: ED-15663
|
|
186
206
|
// Please, do not copy or use this kind of code below
|
|
187
207
|
// @ts-ignore
|
|
@@ -363,13 +383,14 @@ export const createTableView = (
|
|
|
363
383
|
isDragAndDropEnabled,
|
|
364
384
|
isTableScalingEnabled,
|
|
365
385
|
} = getPluginState(view.state);
|
|
366
|
-
const { allowColumnResizing } = getPluginConfig(pluginConfig);
|
|
386
|
+
const { allowColumnResizing, allowControls } = getPluginConfig(pluginConfig);
|
|
367
387
|
const hasIntlContext = true;
|
|
368
388
|
|
|
369
389
|
return new TableView({
|
|
370
390
|
node,
|
|
371
391
|
view,
|
|
372
392
|
allowColumnResizing,
|
|
393
|
+
allowControls,
|
|
373
394
|
portalProviderAPI,
|
|
374
395
|
eventDispatcher,
|
|
375
396
|
getPos: getPos as getPosHandlerNode,
|
package/src/nodeviews/types.ts
CHANGED