@atlaskit/editor-plugin-table 7.16.1 → 7.16.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 +18 -0
- package/dist/cjs/commands/insert.js +14 -2
- package/dist/cjs/nodeviews/TableComponent.js +4 -2
- package/dist/cjs/nodeviews/TableComponentWithSharedState.js +1 -0
- package/dist/cjs/nodeviews/TableContainer.js +73 -34
- package/dist/cjs/nodeviews/TableResizer.js +4 -1
- package/dist/cjs/nodeviews/table.js +7 -4
- package/dist/cjs/plugin.js +12 -3
- package/dist/cjs/pm-plugins/keymap.js +1 -13
- package/dist/cjs/pm-plugins/main.js +1 -1
- package/dist/es2019/commands/insert.js +15 -3
- package/dist/es2019/nodeviews/TableComponent.js +5 -2
- package/dist/es2019/nodeviews/TableComponentWithSharedState.js +1 -0
- package/dist/es2019/nodeviews/TableContainer.js +52 -11
- package/dist/es2019/nodeviews/TableResizer.js +4 -1
- package/dist/es2019/nodeviews/table.js +7 -4
- package/dist/es2019/plugin.js +11 -3
- package/dist/es2019/pm-plugins/keymap.js +4 -14
- package/dist/es2019/pm-plugins/main.js +1 -1
- package/dist/esm/commands/insert.js +15 -3
- package/dist/esm/nodeviews/TableComponent.js +4 -2
- package/dist/esm/nodeviews/TableComponentWithSharedState.js +1 -0
- package/dist/esm/nodeviews/TableContainer.js +74 -35
- package/dist/esm/nodeviews/TableResizer.js +4 -1
- package/dist/esm/nodeviews/table.js +7 -4
- package/dist/esm/plugin.js +12 -3
- package/dist/esm/pm-plugins/keymap.js +4 -16
- package/dist/esm/pm-plugins/main.js +1 -1
- package/dist/types/commands/insert.d.ts +3 -2
- package/dist/types/nodeviews/TableComponent.d.ts +1 -0
- package/dist/types/nodeviews/TableContainer.d.ts +7 -5
- package/dist/types/nodeviews/TableResizer.d.ts +2 -1
- package/dist/types/nodeviews/table.d.ts +1 -1
- package/dist/types/nodeviews/types.d.ts +1 -0
- package/dist/types-ts4.5/commands/insert.d.ts +3 -2
- package/dist/types-ts4.5/nodeviews/TableComponent.d.ts +1 -0
- package/dist/types-ts4.5/nodeviews/TableContainer.d.ts +7 -5
- package/dist/types-ts4.5/nodeviews/TableResizer.d.ts +2 -1
- package/dist/types-ts4.5/nodeviews/table.d.ts +1 -1
- package/dist/types-ts4.5/nodeviews/types.d.ts +1 -0
- package/package.json +5 -5
- package/src/commands/insert.ts +26 -18
- package/src/nodeviews/TableComponent.tsx +3 -0
- package/src/nodeviews/TableComponentWithSharedState.tsx +1 -0
- package/src/nodeviews/TableContainer.tsx +76 -13
- package/src/nodeviews/TableResizer.tsx +11 -1
- package/src/nodeviews/table.tsx +4 -1
- package/src/nodeviews/types.ts +1 -0
- package/src/plugin.tsx +18 -8
- package/src/pm-plugins/keymap.ts +4 -25
- package/src/pm-plugins/main.ts +1 -0
|
@@ -32,5 +32,5 @@ export default class TableView extends ReactNodeView<Props> {
|
|
|
32
32
|
}): boolean;
|
|
33
33
|
destroy(): void;
|
|
34
34
|
}
|
|
35
|
-
export declare const createTableView: (node: PmNode, view: EditorView, getPos: getPosHandler, portalProviderAPI: LegacyPortalProviderAPI | PortalProviderAPI, eventDispatcher: EventDispatcher, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, dispatchAnalyticsEvent: DispatchAnalyticsEvent, pluginInjectionApi?: PluginInjectionAPI) => NodeView;
|
|
35
|
+
export declare const createTableView: (node: PmNode, view: EditorView, getPos: getPosHandler, portalProviderAPI: LegacyPortalProviderAPI | PortalProviderAPI, eventDispatcher: EventDispatcher, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, dispatchAnalyticsEvent: DispatchAnalyticsEvent, pluginInjectionApi?: PluginInjectionAPI, isTableAlignmentEnabled?: boolean) => NodeView;
|
|
36
36
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "7.16.
|
|
3
|
+
"version": "7.16.3",
|
|
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
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@atlaskit/adf-schema": "^36.8.0",
|
|
32
|
-
"@atlaskit/button": "^17.
|
|
32
|
+
"@atlaskit/button": "^17.15.0",
|
|
33
33
|
"@atlaskit/custom-steps": "^0.2.0",
|
|
34
34
|
"@atlaskit/editor-common": "^80.4.0",
|
|
35
35
|
"@atlaskit/editor-palette": "1.6.0",
|
|
@@ -43,16 +43,16 @@
|
|
|
43
43
|
"@atlaskit/editor-prosemirror": "4.0.1",
|
|
44
44
|
"@atlaskit/editor-shared-styles": "^2.11.0",
|
|
45
45
|
"@atlaskit/editor-tables": "^2.7.0",
|
|
46
|
-
"@atlaskit/icon": "^22.
|
|
46
|
+
"@atlaskit/icon": "^22.3.0",
|
|
47
47
|
"@atlaskit/menu": "^2.3.0",
|
|
48
48
|
"@atlaskit/platform-feature-flags": "^0.2.1",
|
|
49
49
|
"@atlaskit/pragmatic-drag-and-drop": "^1.1.0",
|
|
50
50
|
"@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^1.3.0",
|
|
51
51
|
"@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.0.0",
|
|
52
|
-
"@atlaskit/primitives": "^6.
|
|
52
|
+
"@atlaskit/primitives": "^6.3.0",
|
|
53
53
|
"@atlaskit/theme": "^12.8.0",
|
|
54
54
|
"@atlaskit/toggle": "^13.1.0",
|
|
55
|
-
"@atlaskit/tokens": "^1.
|
|
55
|
+
"@atlaskit/tokens": "^1.49.0",
|
|
56
56
|
"@atlaskit/tooltip": "^18.4.0",
|
|
57
57
|
"@babel/runtime": "^7.0.0",
|
|
58
58
|
"@emotion/react": "^11.7.1",
|
package/src/commands/insert.ts
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
// #region Imports
|
|
2
2
|
import { AddColumnStep } from '@atlaskit/custom-steps';
|
|
3
|
-
import type {
|
|
4
|
-
EditorAnalyticsAPI,
|
|
5
|
-
INPUT_METHOD,
|
|
6
|
-
} from '@atlaskit/editor-common/analytics';
|
|
3
|
+
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
7
4
|
import {
|
|
8
5
|
ACTION,
|
|
9
6
|
ACTION_SUBJECT,
|
|
10
7
|
ACTION_SUBJECT_ID,
|
|
11
8
|
EVENT_TYPE,
|
|
9
|
+
INPUT_METHOD,
|
|
12
10
|
TABLE_OVERFLOW_CHANGE_TRIGGER,
|
|
13
11
|
} from '@atlaskit/editor-common/analytics';
|
|
14
12
|
import type { Command, EditorCommand } from '@atlaskit/editor-common/types';
|
|
@@ -203,22 +201,32 @@ export const insertRow =
|
|
|
203
201
|
return true;
|
|
204
202
|
};
|
|
205
203
|
|
|
206
|
-
export const createTable =
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
)(state.schema);
|
|
204
|
+
export const createTable = (
|
|
205
|
+
isTableScalingEnabled?: boolean,
|
|
206
|
+
isFullWidthModeEnabled?: boolean,
|
|
207
|
+
editorAnalyticsAPI?: EditorAnalyticsAPI | undefined | null,
|
|
208
|
+
): Command => (state, dispatch) => {
|
|
209
|
+
const table = createTableWithWidth(
|
|
210
|
+
isTableScalingEnabled,
|
|
211
|
+
isFullWidthModeEnabled,
|
|
212
|
+
)(state.schema);
|
|
216
213
|
|
|
217
|
-
|
|
218
|
-
|
|
214
|
+
if (dispatch) {
|
|
215
|
+
const tr = safeInsert(table)(state.tr).scrollIntoView();
|
|
216
|
+
if (editorAnalyticsAPI) {
|
|
217
|
+
editorAnalyticsAPI?.attachAnalyticsEvent({
|
|
218
|
+
action: ACTION.INSERTED,
|
|
219
|
+
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
220
|
+
actionSubjectId: ACTION_SUBJECT_ID.TABLE,
|
|
221
|
+
attributes: { inputMethod: INPUT_METHOD.SHORTCUT },
|
|
222
|
+
eventType: EVENT_TYPE.TRACK,
|
|
223
|
+
})(tr);
|
|
219
224
|
}
|
|
220
|
-
|
|
221
|
-
}
|
|
225
|
+
dispatch(tr);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
return true;
|
|
229
|
+
}
|
|
222
230
|
|
|
223
231
|
export const insertTableWithSize =
|
|
224
232
|
(
|
|
@@ -104,6 +104,7 @@ export interface ComponentProps {
|
|
|
104
104
|
isMediaFullscreen?: boolean;
|
|
105
105
|
isDragAndDropEnabled?: boolean;
|
|
106
106
|
isTableScalingEnabled?: boolean;
|
|
107
|
+
isTableAlignmentEnabled?: boolean;
|
|
107
108
|
tableActive: boolean;
|
|
108
109
|
ordering?: TableColumnOrdering;
|
|
109
110
|
isResizing?: boolean;
|
|
@@ -687,6 +688,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
687
688
|
isDragAndDropEnabled,
|
|
688
689
|
getEditorFeatureFlags,
|
|
689
690
|
isTableScalingEnabled, // here we can use options.isTableScalingEnabled
|
|
691
|
+
isTableAlignmentEnabled
|
|
690
692
|
} = this.props;
|
|
691
693
|
|
|
692
694
|
let {
|
|
@@ -820,6 +822,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
820
822
|
isResizing={isResizing}
|
|
821
823
|
isTableScalingEnabled={isTableScalingEnabled}
|
|
822
824
|
isWholeTableInDanger={isWholeTableInDanger}
|
|
825
|
+
isTableAlignmentEnabled={isTableAlignmentEnabled}
|
|
823
826
|
>
|
|
824
827
|
<div
|
|
825
828
|
className={ClassName.TABLE_STICKY_SENTINEL_TOP}
|
|
@@ -106,6 +106,7 @@ export const TableComponentWithSharedState = ({
|
|
|
106
106
|
isHeaderColumnEnabled={isHeaderColumnEnabled}
|
|
107
107
|
isDragAndDropEnabled={options?.isDragAndDropEnabled}
|
|
108
108
|
isTableScalingEnabled={options?.isTableScalingEnabled}
|
|
109
|
+
isTableAlignmentEnabled={options?.isTableAlignmentEnabled}
|
|
109
110
|
tableActive={tableActive}
|
|
110
111
|
ordering={ordering}
|
|
111
112
|
isResizing={isResizing}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import type { PropsWithChildren } from 'react';
|
|
2
|
-
import React, {
|
|
2
|
+
import React, {
|
|
3
|
+
forwardRef,
|
|
4
|
+
useCallback,
|
|
5
|
+
useMemo,
|
|
6
|
+
useRef,
|
|
7
|
+
useState,
|
|
8
|
+
} from 'react';
|
|
3
9
|
|
|
4
10
|
import classNames from 'classnames';
|
|
5
11
|
|
|
@@ -50,6 +56,57 @@ export const InnerContainer = forwardRef<
|
|
|
50
56
|
);
|
|
51
57
|
});
|
|
52
58
|
|
|
59
|
+
const centerAlignStyle = { display: 'flex', justifyContent: 'center' };
|
|
60
|
+
|
|
61
|
+
const leftAlignStyle = { display: 'flex', justifyContent: 'flex-start' };
|
|
62
|
+
|
|
63
|
+
type AlignmentTableContainerProps = {
|
|
64
|
+
node: PMNode;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const AlignmentTableContainer = ({
|
|
68
|
+
node,
|
|
69
|
+
children,
|
|
70
|
+
}: PropsWithChildren<AlignmentTableContainerProps>) => {
|
|
71
|
+
const alignment = node.attrs.layout;
|
|
72
|
+
|
|
73
|
+
const style = useMemo(() => {
|
|
74
|
+
return alignment === 'align-start' ? leftAlignStyle : centerAlignStyle;
|
|
75
|
+
}, [alignment]);
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<div data-testid="table-alignment-container" style={style}>
|
|
79
|
+
{children}
|
|
80
|
+
</div>
|
|
81
|
+
);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const AlignmentTableContainerWrapper = ({
|
|
85
|
+
isTableAlignmentEnabled,
|
|
86
|
+
node,
|
|
87
|
+
children,
|
|
88
|
+
}: PropsWithChildren<
|
|
89
|
+
AlignmentTableContainerProps & { isTableAlignmentEnabled?: boolean }
|
|
90
|
+
>) => {
|
|
91
|
+
if (!isTableAlignmentEnabled) {
|
|
92
|
+
return (
|
|
93
|
+
<div
|
|
94
|
+
data-testid="table-alignment-container"
|
|
95
|
+
style={{
|
|
96
|
+
display: 'flex',
|
|
97
|
+
justifyContent: 'center',
|
|
98
|
+
}}
|
|
99
|
+
>
|
|
100
|
+
{children}
|
|
101
|
+
</div>
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return (
|
|
106
|
+
<AlignmentTableContainer node={node}>{children}</AlignmentTableContainer>
|
|
107
|
+
);
|
|
108
|
+
};
|
|
109
|
+
|
|
53
110
|
type ResizableTableContainerProps = {
|
|
54
111
|
containerWidth: number;
|
|
55
112
|
node: PMNode;
|
|
@@ -59,9 +116,11 @@ type ResizableTableContainerProps = {
|
|
|
59
116
|
tableRef: HTMLTableElement;
|
|
60
117
|
isResizing?: boolean;
|
|
61
118
|
pluginInjectionApi?: PluginInjectionAPI;
|
|
62
|
-
isTableScalingEnabled?: boolean;
|
|
63
119
|
tableWrapperHeight?: number;
|
|
64
120
|
isWholeTableInDanger?: boolean;
|
|
121
|
+
|
|
122
|
+
isTableScalingEnabled?: boolean;
|
|
123
|
+
isTableAlignmentEnabled?: boolean;
|
|
65
124
|
};
|
|
66
125
|
|
|
67
126
|
export const ResizableTableContainer = React.memo(
|
|
@@ -75,9 +134,10 @@ export const ResizableTableContainer = React.memo(
|
|
|
75
134
|
tableRef,
|
|
76
135
|
isResizing,
|
|
77
136
|
pluginInjectionApi,
|
|
78
|
-
isTableScalingEnabled,
|
|
79
137
|
tableWrapperHeight,
|
|
80
138
|
isWholeTableInDanger,
|
|
139
|
+
isTableScalingEnabled,
|
|
140
|
+
isTableAlignmentEnabled,
|
|
81
141
|
}: PropsWithChildren<ResizableTableContainerProps>) => {
|
|
82
142
|
const containerRef = useRef<HTMLDivElement | null>(null);
|
|
83
143
|
const tableWidthRef = useRef<number>(akEditorDefaultLayoutWidth);
|
|
@@ -194,6 +254,7 @@ export const ResizableTableContainer = React.memo(
|
|
|
194
254
|
displayGuideline,
|
|
195
255
|
attachAnalyticsEvent,
|
|
196
256
|
displayGapCursor,
|
|
257
|
+
isTableAlignmentEnabled,
|
|
197
258
|
isTableScalingEnabled,
|
|
198
259
|
isWholeTableInDanger,
|
|
199
260
|
pluginInjectionApi,
|
|
@@ -204,11 +265,9 @@ export const ResizableTableContainer = React.memo(
|
|
|
204
265
|
const isLivePageViewMode = editorViewModeState?.mode === 'view';
|
|
205
266
|
|
|
206
267
|
return (
|
|
207
|
-
<
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
justifyContent: 'center',
|
|
211
|
-
}}
|
|
268
|
+
<AlignmentTableContainerWrapper
|
|
269
|
+
isTableAlignmentEnabled={isTableAlignmentEnabled}
|
|
270
|
+
node={node}
|
|
212
271
|
>
|
|
213
272
|
<div
|
|
214
273
|
style={{
|
|
@@ -237,7 +296,7 @@ export const ResizableTableContainer = React.memo(
|
|
|
237
296
|
</TableResizer>
|
|
238
297
|
)}
|
|
239
298
|
</div>
|
|
240
|
-
</
|
|
299
|
+
</AlignmentTableContainerWrapper>
|
|
241
300
|
);
|
|
242
301
|
},
|
|
243
302
|
);
|
|
@@ -246,16 +305,18 @@ type TableContainerProps = {
|
|
|
246
305
|
node: PMNode;
|
|
247
306
|
className: string;
|
|
248
307
|
containerWidth: EditorContainerWidth;
|
|
249
|
-
isTableResizingEnabled: boolean | undefined;
|
|
250
308
|
editorView: EditorView;
|
|
251
309
|
getPos: () => number | undefined;
|
|
252
310
|
tableRef: HTMLTableElement;
|
|
253
311
|
isNested: boolean;
|
|
254
312
|
isResizing?: boolean;
|
|
255
313
|
pluginInjectionApi?: PluginInjectionAPI;
|
|
256
|
-
isTableScalingEnabled?: boolean;
|
|
257
314
|
tableWrapperHeight?: number;
|
|
258
315
|
isWholeTableInDanger?: boolean;
|
|
316
|
+
|
|
317
|
+
isTableResizingEnabled: boolean | undefined;
|
|
318
|
+
isTableScalingEnabled?: boolean;
|
|
319
|
+
isTableAlignmentEnabled?: boolean;
|
|
259
320
|
};
|
|
260
321
|
|
|
261
322
|
export const TableContainer = ({
|
|
@@ -263,7 +324,6 @@ export const TableContainer = ({
|
|
|
263
324
|
node,
|
|
264
325
|
className,
|
|
265
326
|
containerWidth: { width: editorWidth },
|
|
266
|
-
isTableResizingEnabled,
|
|
267
327
|
editorView,
|
|
268
328
|
getPos,
|
|
269
329
|
tableRef,
|
|
@@ -271,8 +331,10 @@ export const TableContainer = ({
|
|
|
271
331
|
tableWrapperHeight,
|
|
272
332
|
isResizing,
|
|
273
333
|
pluginInjectionApi,
|
|
274
|
-
isTableScalingEnabled,
|
|
275
334
|
isWholeTableInDanger,
|
|
335
|
+
isTableResizingEnabled,
|
|
336
|
+
isTableScalingEnabled,
|
|
337
|
+
isTableAlignmentEnabled,
|
|
276
338
|
}: PropsWithChildren<TableContainerProps>) => {
|
|
277
339
|
if (isTableResizingEnabled && !isNested) {
|
|
278
340
|
return (
|
|
@@ -288,6 +350,7 @@ export const TableContainer = ({
|
|
|
288
350
|
pluginInjectionApi={pluginInjectionApi}
|
|
289
351
|
isTableScalingEnabled={isTableScalingEnabled}
|
|
290
352
|
isWholeTableInDanger={isWholeTableInDanger}
|
|
353
|
+
isTableAlignmentEnabled={isTableAlignmentEnabled}
|
|
291
354
|
>
|
|
292
355
|
{children}
|
|
293
356
|
</ResizableTableContainer>
|
|
@@ -48,6 +48,7 @@ import {
|
|
|
48
48
|
TABLE_HIGHLIGHT_TOLERANCE,
|
|
49
49
|
TABLE_SNAP_GAP,
|
|
50
50
|
} from '../ui/consts';
|
|
51
|
+
import { normaliseAlignment } from '../utils/alignment';
|
|
51
52
|
import {
|
|
52
53
|
generateResizedPayload,
|
|
53
54
|
generateResizeFrameRatePayloads,
|
|
@@ -79,6 +80,7 @@ interface TableResizerProps {
|
|
|
79
80
|
displayGapCursor: (toggle: boolean) => boolean;
|
|
80
81
|
pluginInjectionApi?: PluginInjectionAPI;
|
|
81
82
|
isTableScalingEnabled?: boolean;
|
|
83
|
+
isTableAlignmentEnabled?: boolean;
|
|
82
84
|
isWholeTableInDanger?: boolean;
|
|
83
85
|
}
|
|
84
86
|
|
|
@@ -169,6 +171,7 @@ export const TableResizer = ({
|
|
|
169
171
|
attachAnalyticsEvent,
|
|
170
172
|
displayGapCursor,
|
|
171
173
|
isTableScalingEnabled,
|
|
174
|
+
isTableAlignmentEnabled,
|
|
172
175
|
isWholeTableInDanger,
|
|
173
176
|
pluginInjectionApi,
|
|
174
177
|
}: PropsWithChildren<TableResizerImprovementProps>) => {
|
|
@@ -594,6 +597,13 @@ export const TableResizer = ({
|
|
|
594
597
|
}
|
|
595
598
|
}, [width]);
|
|
596
599
|
|
|
600
|
+
const resizeRatio =
|
|
601
|
+
!isTableAlignmentEnabled ||
|
|
602
|
+
(isTableAlignmentEnabled &&
|
|
603
|
+
normaliseAlignment(node.attrs.layout) === 'center')
|
|
604
|
+
? 2
|
|
605
|
+
: 1;
|
|
606
|
+
|
|
597
607
|
return (
|
|
598
608
|
<>
|
|
599
609
|
<ResizerNext
|
|
@@ -606,7 +616,7 @@ export const TableResizer = ({
|
|
|
606
616
|
handleResizeStart={handleResizeStart}
|
|
607
617
|
handleResize={scheduleResize}
|
|
608
618
|
handleResizeStop={handleResizeStop}
|
|
609
|
-
resizeRatio={
|
|
619
|
+
resizeRatio={resizeRatio}
|
|
610
620
|
minWidth={resizerMinWidth}
|
|
611
621
|
maxWidth={maxWidth}
|
|
612
622
|
snapGap={TABLE_SNAP_GAP}
|
package/src/nodeviews/table.tsx
CHANGED
|
@@ -292,7 +292,8 @@ export default class TableView extends ReactNodeView<Props> {
|
|
|
292
292
|
isHeaderRowEnabled={pluginState!.isHeaderRowEnabled}
|
|
293
293
|
isHeaderColumnEnabled={pluginState!.isHeaderColumnEnabled}
|
|
294
294
|
isDragAndDropEnabled={pluginState!.isDragAndDropEnabled}
|
|
295
|
-
isTableScalingEnabled={props.options?.isTableScalingEnabled} // this.options?.isTableScalingEnabled
|
|
295
|
+
isTableScalingEnabled={props.options?.isTableScalingEnabled} // this.options?.isTableScalingEnabled same as TableOptions.isTableScalingEnabled same as pluginState.isTableScalingEnabled
|
|
296
|
+
isTableAlignmentEnabled={props.options?.isTableAlignmentEnabled}
|
|
296
297
|
tableActive={tableActive}
|
|
297
298
|
ordering={pluginState!.ordering as TableColumnOrdering}
|
|
298
299
|
isResizing={isResizing}
|
|
@@ -391,6 +392,7 @@ export const createTableView = (
|
|
|
391
392
|
getEditorFeatureFlags: GetEditorFeatureFlags,
|
|
392
393
|
dispatchAnalyticsEvent: DispatchAnalyticsEvent,
|
|
393
394
|
pluginInjectionApi?: PluginInjectionAPI,
|
|
395
|
+
isTableAlignmentEnabled?: boolean,
|
|
394
396
|
): NodeView => {
|
|
395
397
|
const {
|
|
396
398
|
pluginConfig,
|
|
@@ -417,6 +419,7 @@ export const createTableView = (
|
|
|
417
419
|
isTableResizingEnabled,
|
|
418
420
|
isDragAndDropEnabled,
|
|
419
421
|
isTableScalingEnabled, // same as options.isTableScalingEnabled
|
|
422
|
+
isTableAlignmentEnabled
|
|
420
423
|
},
|
|
421
424
|
getEditorContainerWidth,
|
|
422
425
|
getEditorFeatureFlags,
|
package/src/nodeviews/types.ts
CHANGED
package/src/plugin.tsx
CHANGED
|
@@ -212,7 +212,13 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
212
212
|
|
|
213
213
|
options: {
|
|
214
214
|
selectNodeInserted: false,
|
|
215
|
-
analyticsPayload
|
|
215
|
+
analyticsPayload: {
|
|
216
|
+
...analyticsPayload,
|
|
217
|
+
attributes: {
|
|
218
|
+
...analyticsPayload.attributes,
|
|
219
|
+
localId: node.attrs.localId,
|
|
220
|
+
},
|
|
221
|
+
},
|
|
216
222
|
},
|
|
217
223
|
}) ?? false
|
|
218
224
|
);
|
|
@@ -638,17 +644,21 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
638
644
|
// see comment on tablesPlugin.getSharedState on usage
|
|
639
645
|
const tableState = api?.table?.sharedState.currentState();
|
|
640
646
|
|
|
641
|
-
const
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
);
|
|
647
|
+
const tableNode = createTableWithWidth(
|
|
648
|
+
options?.isTableScalingEnabled,
|
|
649
|
+
tableState?.isFullWidthModeEnabled,
|
|
650
|
+
)(state.schema);
|
|
651
|
+
|
|
652
|
+
const tr = insert(tableNode);
|
|
653
|
+
|
|
647
654
|
editorAnalyticsAPI?.attachAnalyticsEvent({
|
|
648
655
|
action: ACTION.INSERTED,
|
|
649
656
|
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
650
657
|
actionSubjectId: ACTION_SUBJECT_ID.TABLE,
|
|
651
|
-
attributes: {
|
|
658
|
+
attributes: {
|
|
659
|
+
inputMethod: INPUT_METHOD.QUICK_INSERT,
|
|
660
|
+
localId: tableNode.attrs.localId,
|
|
661
|
+
},
|
|
652
662
|
eventType: EVENT_TYPE.TRACK,
|
|
653
663
|
})(tr);
|
|
654
664
|
return tr;
|
package/src/pm-plugins/keymap.ts
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
import type { IntlShape } from 'react-intl-next/src/types';
|
|
2
2
|
|
|
3
3
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
4
|
-
import {
|
|
5
|
-
ACTION,
|
|
6
|
-
ACTION_SUBJECT,
|
|
7
|
-
ACTION_SUBJECT_ID,
|
|
8
|
-
EVENT_TYPE,
|
|
9
|
-
INPUT_METHOD,
|
|
10
|
-
} from '@atlaskit/editor-common/analytics';
|
|
4
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
11
5
|
import {
|
|
12
6
|
addColumnAfter,
|
|
13
7
|
addColumnBefore,
|
|
@@ -37,7 +31,7 @@ import { chainCommands } from '@atlaskit/editor-prosemirror/commands';
|
|
|
37
31
|
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
38
32
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
39
33
|
|
|
40
|
-
import {
|
|
34
|
+
import { goToNextCell, moveCursorBackward } from '../commands';
|
|
41
35
|
import {
|
|
42
36
|
addRowAroundSelection,
|
|
43
37
|
changeColumnWidthByStepWithAnalytics,
|
|
@@ -53,25 +47,10 @@ import {
|
|
|
53
47
|
import {
|
|
54
48
|
addColumnAfter as addColumnAfterCommand,
|
|
55
49
|
addColumnBefore as addColumnBeforeCommand,
|
|
50
|
+
createTable,
|
|
56
51
|
} from '../commands/insert';
|
|
57
52
|
import { moveSourceWithAnalyticsViaShortcut } from '../pm-plugins/drag-and-drop/commands-with-analytics';
|
|
58
53
|
import type { PluginInjectionAPIWithA11y } from '../types';
|
|
59
|
-
import { withEditorAnalyticsAPI } from '../utils/analytics';
|
|
60
|
-
|
|
61
|
-
const createTableWithAnalytics = (
|
|
62
|
-
isTableScalingEnabled: boolean,
|
|
63
|
-
isFullWidthModeEnabled: boolean,
|
|
64
|
-
editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null,
|
|
65
|
-
) =>
|
|
66
|
-
withEditorAnalyticsAPI({
|
|
67
|
-
action: ACTION.INSERTED,
|
|
68
|
-
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
69
|
-
actionSubjectId: ACTION_SUBJECT_ID.TABLE,
|
|
70
|
-
attributes: { inputMethod: INPUT_METHOD.SHORTCUT },
|
|
71
|
-
eventType: EVENT_TYPE.TRACK,
|
|
72
|
-
})(editorAnalyticsAPI)(
|
|
73
|
-
createTable(isTableScalingEnabled, isFullWidthModeEnabled),
|
|
74
|
-
);
|
|
75
54
|
|
|
76
55
|
export function keymapPlugin(
|
|
77
56
|
getEditorContainerWidth: GetEditorContainerWidth,
|
|
@@ -99,7 +78,7 @@ export function keymapPlugin(
|
|
|
99
78
|
);
|
|
100
79
|
bindKeymapWithCommand(
|
|
101
80
|
toggleTable.common!,
|
|
102
|
-
|
|
81
|
+
createTable(
|
|
103
82
|
isTableScalingEnabled,
|
|
104
83
|
!!isFullWidthEnabled,
|
|
105
84
|
editorAnalyticsAPI,
|
package/src/pm-plugins/main.ts
CHANGED