@atlaskit/editor-plugin-table 3.0.4 → 3.1.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 +17 -0
- package/dist/cjs/plugins/table/commands/insert.js +5 -0
- package/dist/cjs/plugins/table/commands/toggle.js +11 -1
- package/dist/cjs/plugins/table/index.js +37 -26
- package/dist/cjs/plugins/table/nodeviews/TableComponent.js +111 -46
- package/dist/cjs/plugins/table/nodeviews/TableResizer.js +9 -4
- package/dist/cjs/plugins/table/pm-plugins/table-analytics.js +83 -0
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/commands.js +5 -0
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/event-handlers.js +8 -0
- package/dist/cjs/plugins/table/transforms/delete-columns.js +5 -0
- package/dist/cjs/plugins/table/ui/ui-styles.js +1 -1
- package/dist/es2019/plugins/table/commands/insert.js +5 -0
- package/dist/es2019/plugins/table/commands/toggle.js +11 -1
- package/dist/es2019/plugins/table/index.js +12 -0
- package/dist/es2019/plugins/table/nodeviews/TableComponent.js +71 -2
- package/dist/es2019/plugins/table/nodeviews/TableResizer.js +5 -0
- package/dist/es2019/plugins/table/pm-plugins/table-analytics.js +74 -0
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/commands.js +5 -0
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/event-handlers.js +9 -1
- package/dist/es2019/plugins/table/transforms/delete-columns.js +5 -0
- package/dist/es2019/plugins/table/ui/ui-styles.js +1 -1
- package/dist/esm/plugins/table/commands/insert.js +5 -0
- package/dist/esm/plugins/table/commands/toggle.js +11 -1
- package/dist/esm/plugins/table/index.js +37 -26
- package/dist/esm/plugins/table/nodeviews/TableComponent.js +112 -47
- package/dist/esm/plugins/table/nodeviews/TableResizer.js +5 -0
- package/dist/esm/plugins/table/pm-plugins/table-analytics.js +75 -0
- package/dist/esm/plugins/table/pm-plugins/table-resizing/commands.js +5 -0
- package/dist/esm/plugins/table/pm-plugins/table-resizing/event-handlers.js +9 -1
- package/dist/esm/plugins/table/transforms/delete-columns.js +5 -0
- package/dist/esm/plugins/table/ui/ui-styles.js +1 -1
- package/dist/types/plugins/table/commands/insert.d.ts +3 -4
- package/dist/types/plugins/table/commands/toggle.d.ts +2 -2
- package/dist/types/plugins/table/nodeviews/TableComponent.d.ts +4 -1
- package/dist/types/plugins/table/pm-plugins/table-analytics.d.ts +23 -0
- package/dist/types/plugins/table/pm-plugins/table-resizing/commands.d.ts +4 -4
- package/dist/types/plugins/table/transforms/delete-columns.d.ts +2 -2
- package/dist/types-ts4.5/plugins/table/commands/insert.d.ts +3 -4
- package/dist/types-ts4.5/plugins/table/commands/toggle.d.ts +2 -2
- package/dist/types-ts4.5/plugins/table/nodeviews/TableComponent.d.ts +4 -1
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-analytics.d.ts +23 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/commands.d.ts +4 -4
- package/dist/types-ts4.5/plugins/table/transforms/delete-columns.d.ts +2 -2
- package/package.json +5 -2
- package/src/plugins/table/commands/insert.ts +12 -4
- package/src/plugins/table/commands/toggle.ts +17 -4
- package/src/plugins/table/index.tsx +17 -1
- package/src/plugins/table/nodeviews/TableComponent.tsx +99 -2
- package/src/plugins/table/nodeviews/TableResizer.tsx +6 -0
- package/src/plugins/table/pm-plugins/table-analytics.ts +102 -0
- package/src/plugins/table/pm-plugins/table-resizing/commands.ts +10 -4
- package/src/plugins/table/pm-plugins/table-resizing/event-handlers.ts +10 -0
- package/src/plugins/table/transforms/delete-columns.ts +12 -4
- package/src/plugins/table/ui/ui-styles.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@atlaskit/adf-schema": "^29.1.0",
|
|
31
|
-
"@atlaskit/editor-common": "^75.
|
|
31
|
+
"@atlaskit/editor-common": "^75.5.0",
|
|
32
32
|
"@atlaskit/editor-palette": "1.5.1",
|
|
33
33
|
"@atlaskit/editor-plugin-analytics": "^0.2.0",
|
|
34
34
|
"@atlaskit/editor-plugin-content-insertion": "^0.1.0",
|
|
@@ -110,6 +110,9 @@
|
|
|
110
110
|
},
|
|
111
111
|
"platform.editor.table-remove-update-resize-handles_djvab": {
|
|
112
112
|
"type": "boolean"
|
|
113
|
+
},
|
|
114
|
+
"platform.editor.table.overflow-state-analytics": {
|
|
115
|
+
"type": "boolean"
|
|
113
116
|
}
|
|
114
117
|
}
|
|
115
118
|
}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
// #region Imports
|
|
2
2
|
import { AddColumnStep } from '@atlaskit/adf-schema/steps';
|
|
3
|
-
import {
|
|
4
|
-
import type {
|
|
5
|
-
|
|
3
|
+
import { TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
|
|
4
|
+
import type {
|
|
5
|
+
Command,
|
|
6
|
+
GetEditorContainerWidth,
|
|
7
|
+
} from '@atlaskit/editor-common/types';
|
|
8
|
+
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
9
|
+
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
6
10
|
import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
7
|
-
import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
11
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
8
12
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
9
13
|
import {
|
|
10
14
|
addColumnAt as addColumnAtPMUtils,
|
|
@@ -14,6 +18,7 @@ import {
|
|
|
14
18
|
selectedRect,
|
|
15
19
|
} from '@atlaskit/editor-tables/utils';
|
|
16
20
|
|
|
21
|
+
import { META_KEYS } from '../pm-plugins/table-analytics';
|
|
17
22
|
import { rescaleColumns } from '../transforms/column-width';
|
|
18
23
|
import { checkIfHeaderRowEnabled, copyPreviousRow } from '../utils';
|
|
19
24
|
import { getAllowAddColumnCustomStep } from '../utils/get-allow-add-column-custom-step';
|
|
@@ -50,6 +55,9 @@ export function addColumnAt(getEditorContainerWidth: GetEditorContainerWidth) {
|
|
|
50
55
|
updatedTr,
|
|
51
56
|
);
|
|
52
57
|
}
|
|
58
|
+
updatedTr.setMeta(META_KEYS.OVERFLOW_TRIGGER, {
|
|
59
|
+
name: TABLE_OVERFLOW_CHANGE_TRIGGER.ADDED_COLUMN,
|
|
60
|
+
});
|
|
53
61
|
return updatedTr;
|
|
54
62
|
};
|
|
55
63
|
};
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
//#region Imports
|
|
2
2
|
|
|
3
|
-
import { TableLayout } from '@atlaskit/adf-schema';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import type { TableLayout } from '@atlaskit/adf-schema';
|
|
4
|
+
import { TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
|
|
5
|
+
import type { Command } from '@atlaskit/editor-common/types';
|
|
6
|
+
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
6
7
|
import { findTable, toggleHeader } from '@atlaskit/editor-tables/utils';
|
|
7
8
|
|
|
8
9
|
import { createCommand } from '../pm-plugins/plugin-factory';
|
|
10
|
+
import { META_KEYS } from '../pm-plugins/table-analytics';
|
|
9
11
|
//#endregion
|
|
10
12
|
|
|
11
13
|
// #region Utils
|
|
@@ -45,13 +47,21 @@ export const toggleHeaderColumn: Command = (state, dispatch): boolean =>
|
|
|
45
47
|
export const toggleNumberColumn: Command = (state, dispatch) => {
|
|
46
48
|
const { tr } = state;
|
|
47
49
|
const { node, pos } = findTable(state.selection)!;
|
|
50
|
+
const isNumberedColumnEnabled = node.attrs.isNumberColumnEnabled;
|
|
48
51
|
|
|
49
52
|
tr.setNodeMarkup(pos, state.schema.nodes.table, {
|
|
50
53
|
...node.attrs,
|
|
51
|
-
isNumberColumnEnabled: !
|
|
54
|
+
isNumberColumnEnabled: !isNumberedColumnEnabled,
|
|
52
55
|
});
|
|
53
56
|
tr.setMeta('scrollIntoView', false);
|
|
54
57
|
|
|
58
|
+
const tableOverflowChangeTriggerName = isNumberedColumnEnabled
|
|
59
|
+
? TABLE_OVERFLOW_CHANGE_TRIGGER.DISABLED_NUMBERED_COLUMN
|
|
60
|
+
: TABLE_OVERFLOW_CHANGE_TRIGGER.ENABLED_NUMBERED_COLUMN;
|
|
61
|
+
tr.setMeta(META_KEYS.OVERFLOW_TRIGGER, {
|
|
62
|
+
name: tableOverflowChangeTriggerName,
|
|
63
|
+
});
|
|
64
|
+
|
|
55
65
|
if (dispatch) {
|
|
56
66
|
dispatch(tr);
|
|
57
67
|
}
|
|
@@ -77,6 +87,9 @@ export const toggleTableLayout: Command = (state, dispatch): boolean => {
|
|
|
77
87
|
...table.node.attrs,
|
|
78
88
|
layout,
|
|
79
89
|
});
|
|
90
|
+
tr.setMeta(META_KEYS.OVERFLOW_TRIGGER, {
|
|
91
|
+
name: TABLE_OVERFLOW_CHANGE_TRIGGER.RESIZED,
|
|
92
|
+
});
|
|
80
93
|
return tr.setMeta('scrollIntoView', false);
|
|
81
94
|
},
|
|
82
95
|
)(state, dispatch);
|
|
@@ -41,6 +41,7 @@ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
|
41
41
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
42
42
|
import { tableEditing } from '@atlaskit/editor-tables/pm-plugins';
|
|
43
43
|
import { createTable } from '@atlaskit/editor-tables/utils';
|
|
44
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
44
45
|
|
|
45
46
|
import { pluginConfig } from './create-plugin-config';
|
|
46
47
|
import { createPlugin as createDecorationsPlugin } from './pm-plugins/decorations/plugin';
|
|
@@ -53,6 +54,10 @@ import {
|
|
|
53
54
|
findStickyHeaderForTable,
|
|
54
55
|
pluginKey as stickyHeadersPluginKey,
|
|
55
56
|
} from './pm-plugins/sticky-headers';
|
|
57
|
+
import {
|
|
58
|
+
createPlugin as createTableAnalyticsPlugin,
|
|
59
|
+
pluginKey as tableAnalyticsPluginKey,
|
|
60
|
+
} from './pm-plugins/table-analytics';
|
|
56
61
|
import { createPlugin as createTableLocalIdPlugin } from './pm-plugins/table-local-id';
|
|
57
62
|
import {
|
|
58
63
|
createPlugin as createFlexiResizingPlugin,
|
|
@@ -290,7 +295,17 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
290
295
|
)
|
|
291
296
|
: undefined,
|
|
292
297
|
},
|
|
293
|
-
|
|
298
|
+
{
|
|
299
|
+
name: 'tableAnalyticsPlugin',
|
|
300
|
+
plugin: ({ dispatch, dispatchAnalyticsEvent }) =>
|
|
301
|
+
getBooleanFF('platform.editor.table.overflow-state-analytics')
|
|
302
|
+
? createTableAnalyticsPlugin(
|
|
303
|
+
dispatch,
|
|
304
|
+
dispatchAnalyticsEvent,
|
|
305
|
+
options?.tableResizingEnabled ?? false,
|
|
306
|
+
)
|
|
307
|
+
: undefined,
|
|
308
|
+
},
|
|
294
309
|
{
|
|
295
310
|
name: 'tableGetEditorViewReferencePlugin',
|
|
296
311
|
plugin: () => {
|
|
@@ -337,6 +352,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
337
352
|
>
|
|
338
353
|
<WithPluginState
|
|
339
354
|
plugins={{
|
|
355
|
+
tableAnalyticsPluginState: tableAnalyticsPluginKey,
|
|
340
356
|
tablePluginState: pluginKey,
|
|
341
357
|
tableWidthPluginState: tableWidthPluginKey,
|
|
342
358
|
tableResizingPluginState: tableResizingPluginKey,
|
|
@@ -6,14 +6,25 @@ import memoizeOne from 'memoize-one';
|
|
|
6
6
|
import rafSchedule from 'raf-schd';
|
|
7
7
|
|
|
8
8
|
import type { TableColumnOrdering } from '@atlaskit/adf-schema/steps';
|
|
9
|
+
import {
|
|
10
|
+
ACTION_SUBJECT,
|
|
11
|
+
EVENT_TYPE,
|
|
12
|
+
TABLE_ACTION,
|
|
13
|
+
} from '@atlaskit/editor-common/analytics';
|
|
14
|
+
import type { AnalyticsDispatch } from '@atlaskit/editor-common/analytics';
|
|
9
15
|
import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
|
|
16
|
+
import { createDispatch } from '@atlaskit/editor-common/event-dispatcher';
|
|
10
17
|
import { getParentNodeWidth } from '@atlaskit/editor-common/node-width';
|
|
11
18
|
import { tableMarginSides } from '@atlaskit/editor-common/styles';
|
|
12
19
|
import type {
|
|
13
20
|
EditorContainerWidth,
|
|
14
21
|
GetEditorFeatureFlags,
|
|
15
22
|
} from '@atlaskit/editor-common/types';
|
|
16
|
-
import {
|
|
23
|
+
import {
|
|
24
|
+
analyticsEventKey,
|
|
25
|
+
browser,
|
|
26
|
+
isValidPosition,
|
|
27
|
+
} from '@atlaskit/editor-common/utils';
|
|
17
28
|
import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
18
29
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
19
30
|
import { akEditorTableToolbarSize as tableToolbarSize } from '@atlaskit/editor-shared-styles';
|
|
@@ -30,6 +41,7 @@ import {
|
|
|
30
41
|
findStickyHeaderForTable,
|
|
31
42
|
pluginKey as stickyHeadersPluginKey,
|
|
32
43
|
} from '../pm-plugins/sticky-headers';
|
|
44
|
+
import { META_KEYS } from '../pm-plugins/table-analytics';
|
|
33
45
|
import {
|
|
34
46
|
getLayoutSize,
|
|
35
47
|
insertColgroupFromNode as recreateResizeColsByNode,
|
|
@@ -53,6 +65,10 @@ import { TableContainer } from './TableContainer';
|
|
|
53
65
|
import type { TableOptions } from './types';
|
|
54
66
|
|
|
55
67
|
const isIE11 = browser.ie_version === 11;
|
|
68
|
+
// When table is inserted via paste, keyboard shortcut or quickInsert,
|
|
69
|
+
// componentDidUpdate is called multiple times. The isOverflowing value is correct only on the last update.
|
|
70
|
+
// To make sure we capture the last update, we use setTimeout.
|
|
71
|
+
const initialOverflowCaptureTimeroutDelay = 300;
|
|
56
72
|
export interface ComponentProps {
|
|
57
73
|
view: EditorView;
|
|
58
74
|
getNode: () => PmNode;
|
|
@@ -81,6 +97,7 @@ interface TableState {
|
|
|
81
97
|
[ShadowEvent.SHOW_BEFORE_SHADOW]: boolean;
|
|
82
98
|
[ShadowEvent.SHOW_AFTER_SHADOW]: boolean;
|
|
83
99
|
}
|
|
100
|
+
|
|
84
101
|
class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
85
102
|
static displayName = 'TableComponent';
|
|
86
103
|
|
|
@@ -98,11 +115,15 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
98
115
|
private layoutSize?: number;
|
|
99
116
|
private overflowShadowsObserver?: OverflowShadowsObserver;
|
|
100
117
|
|
|
118
|
+
private isInitialOverflowSent: boolean;
|
|
119
|
+
private initialOverflowCaptureTimerId?: ReturnType<typeof setTimeout>;
|
|
120
|
+
|
|
101
121
|
constructor(props: ComponentProps) {
|
|
102
122
|
super(props);
|
|
103
123
|
const { options, containerWidth, getNode } = props;
|
|
104
124
|
this.node = getNode();
|
|
105
125
|
this.containerWidth = containerWidth;
|
|
126
|
+
this.isInitialOverflowSent = false;
|
|
106
127
|
|
|
107
128
|
// store table size using previous full-width mode so can detect if it has changed
|
|
108
129
|
const isFullWidthModeEnabled = options
|
|
@@ -153,6 +174,14 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
153
174
|
}
|
|
154
175
|
|
|
155
176
|
eventDispatcher.on((stickyHeadersPluginKey as any).key, this.onStickyState);
|
|
177
|
+
|
|
178
|
+
if (getBooleanFF('platform.editor.table.overflow-state-analytics')) {
|
|
179
|
+
const initialIsOveflowing =
|
|
180
|
+
this.state[ShadowEvent.SHOW_BEFORE_SHADOW] ||
|
|
181
|
+
this.state[ShadowEvent.SHOW_AFTER_SHADOW];
|
|
182
|
+
|
|
183
|
+
this.setTimerToSendInitialOverflowCaptured(initialIsOveflowing);
|
|
184
|
+
}
|
|
156
185
|
}
|
|
157
186
|
|
|
158
187
|
componentWillUnmount() {
|
|
@@ -181,9 +210,13 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
181
210
|
(stickyHeadersPluginKey as any).key,
|
|
182
211
|
this.onStickyState,
|
|
183
212
|
);
|
|
213
|
+
|
|
214
|
+
if (this.initialOverflowCaptureTimerId) {
|
|
215
|
+
clearTimeout(this.initialOverflowCaptureTimerId);
|
|
216
|
+
}
|
|
184
217
|
}
|
|
185
218
|
|
|
186
|
-
componentDidUpdate() {
|
|
219
|
+
componentDidUpdate(_: any, prevState: TableState) {
|
|
187
220
|
const {
|
|
188
221
|
view,
|
|
189
222
|
getNode,
|
|
@@ -249,6 +282,44 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
249
282
|
|
|
250
283
|
this.handleTableResizingDebounced();
|
|
251
284
|
}
|
|
285
|
+
|
|
286
|
+
if (getBooleanFF('platform.editor.table.overflow-state-analytics')) {
|
|
287
|
+
const newIsOverflowing =
|
|
288
|
+
this.state[ShadowEvent.SHOW_BEFORE_SHADOW] ||
|
|
289
|
+
this.state[ShadowEvent.SHOW_AFTER_SHADOW];
|
|
290
|
+
|
|
291
|
+
const prevIsOverflowing =
|
|
292
|
+
prevState[ShadowEvent.SHOW_BEFORE_SHADOW] ||
|
|
293
|
+
prevState[ShadowEvent.SHOW_AFTER_SHADOW];
|
|
294
|
+
|
|
295
|
+
if (this.initialOverflowCaptureTimerId) {
|
|
296
|
+
clearTimeout(this.initialOverflowCaptureTimerId);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
if (!this.isInitialOverflowSent) {
|
|
300
|
+
this.setTimerToSendInitialOverflowCaptured(newIsOverflowing);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
if (
|
|
304
|
+
this.isInitialOverflowSent &&
|
|
305
|
+
prevIsOverflowing !== newIsOverflowing
|
|
306
|
+
) {
|
|
307
|
+
const {
|
|
308
|
+
dispatch,
|
|
309
|
+
state: { tr },
|
|
310
|
+
} = this.props.view;
|
|
311
|
+
|
|
312
|
+
dispatch(
|
|
313
|
+
tr.setMeta(META_KEYS.OVERFLOW_STATE_CHANGED, {
|
|
314
|
+
isOverflowing: newIsOverflowing,
|
|
315
|
+
wasOverflowing: prevIsOverflowing,
|
|
316
|
+
editorWidth: this.props.containerWidth.width || 0,
|
|
317
|
+
width: this.node.attrs.width || 0,
|
|
318
|
+
parentWidth: this.state?.parentWidth || 0,
|
|
319
|
+
}),
|
|
320
|
+
);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
252
323
|
}
|
|
253
324
|
|
|
254
325
|
private updateShadowState = (shadowKey: ShadowEvent, value: boolean) => {
|
|
@@ -577,6 +648,32 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
577
648
|
dispatch(tr);
|
|
578
649
|
};
|
|
579
650
|
|
|
651
|
+
private setTimerToSendInitialOverflowCaptured = (isOverflowing: boolean) => {
|
|
652
|
+
const { eventDispatcher, containerWidth, options } = this.props;
|
|
653
|
+
const dispatch: AnalyticsDispatch = createDispatch(eventDispatcher);
|
|
654
|
+
const parentWidth = this.state?.parentWidth || 0;
|
|
655
|
+
|
|
656
|
+
this.initialOverflowCaptureTimerId = setTimeout(() => {
|
|
657
|
+
dispatch(analyticsEventKey, {
|
|
658
|
+
payload: {
|
|
659
|
+
action: TABLE_ACTION.INITIAL_OVERFLOW_CAPTURED,
|
|
660
|
+
actionSubject: ACTION_SUBJECT.TABLE,
|
|
661
|
+
actionSubjectId: null,
|
|
662
|
+
eventType: EVENT_TYPE.TRACK,
|
|
663
|
+
attributes: {
|
|
664
|
+
editorWidth: containerWidth.width || 0,
|
|
665
|
+
isOverflowing,
|
|
666
|
+
tableResizingEnabled: options?.isTableResizingEnabled || false,
|
|
667
|
+
width: this.node.attrs.width || 0,
|
|
668
|
+
parentWidth,
|
|
669
|
+
},
|
|
670
|
+
},
|
|
671
|
+
});
|
|
672
|
+
|
|
673
|
+
this.isInitialOverflowSent = true;
|
|
674
|
+
}, initialOverflowCaptureTimeroutDelay);
|
|
675
|
+
};
|
|
676
|
+
|
|
580
677
|
private handleAutoSize = () => {
|
|
581
678
|
if (this.table) {
|
|
582
679
|
const { view, getNode, getPos, containerWidth } = this.props;
|
|
@@ -11,6 +11,7 @@ import rafSchd from 'raf-schd';
|
|
|
11
11
|
import { defineMessages, useIntl } from 'react-intl-next';
|
|
12
12
|
|
|
13
13
|
import type { TableEventPayload } from '@atlaskit/editor-common/analytics';
|
|
14
|
+
import { TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
|
|
14
15
|
import { getGuidelinesWithHighlights } from '@atlaskit/editor-common/guideline';
|
|
15
16
|
import type { GuidelineConfig } from '@atlaskit/editor-common/guideline';
|
|
16
17
|
import type {
|
|
@@ -25,6 +26,7 @@ import { findTable } from '@atlaskit/editor-tables/utils';
|
|
|
25
26
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
26
27
|
|
|
27
28
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
29
|
+
import { META_KEYS } from '../pm-plugins/table-analytics';
|
|
28
30
|
import {
|
|
29
31
|
COLUMN_MIN_WIDTH,
|
|
30
32
|
getColgroupChildrenLength,
|
|
@@ -215,6 +217,10 @@ export const TableResizer = ({
|
|
|
215
217
|
tr.setMeta(tableWidthPluginKey, { resizing: true });
|
|
216
218
|
displayGapCursor(false);
|
|
217
219
|
|
|
220
|
+
tr.setMeta(META_KEYS.OVERFLOW_TRIGGER, {
|
|
221
|
+
name: TABLE_OVERFLOW_CHANGE_TRIGGER.RESIZED,
|
|
222
|
+
});
|
|
223
|
+
|
|
218
224
|
dispatch(tr);
|
|
219
225
|
|
|
220
226
|
const visibleGuidelines = getVisibleGuidelines(
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A plugin is created for collecting payload data for tableOverflowChanged analytics event
|
|
3
|
+
*/
|
|
4
|
+
import {
|
|
5
|
+
ACTION_SUBJECT,
|
|
6
|
+
EVENT_TYPE,
|
|
7
|
+
TABLE_ACTION,
|
|
8
|
+
TABLE_OVERFLOW_CHANGE_TRIGGER,
|
|
9
|
+
} from '@atlaskit/editor-common/analytics';
|
|
10
|
+
import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
11
|
+
import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
|
|
12
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
13
|
+
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
14
|
+
|
|
15
|
+
interface LastTrigger {
|
|
16
|
+
name: TABLE_OVERFLOW_CHANGE_TRIGGER;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
type TableAnalyticsPluginState = {
|
|
20
|
+
lastTrigger: LastTrigger | undefined;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const pluginKey = new PluginKey<TableAnalyticsPluginState>(
|
|
24
|
+
'tableAnalyticsPlugin',
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
export const META_KEYS = {
|
|
28
|
+
OVERFLOW_TRIGGER: 'tableOverflowTrigger',
|
|
29
|
+
OVERFLOW_STATE_CHANGED: 'tableOverflowStateChanged',
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const createPlugin = (
|
|
33
|
+
dispatch: Dispatch,
|
|
34
|
+
dispatchAnalyticsEvent: DispatchAnalyticsEvent,
|
|
35
|
+
tableResizingEnabled: boolean,
|
|
36
|
+
) =>
|
|
37
|
+
new SafePlugin({
|
|
38
|
+
key: pluginKey,
|
|
39
|
+
state: {
|
|
40
|
+
init() {
|
|
41
|
+
return {
|
|
42
|
+
lastTrigger: undefined,
|
|
43
|
+
};
|
|
44
|
+
},
|
|
45
|
+
apply(tr, pluginState) {
|
|
46
|
+
const meta = tr.getMeta(META_KEYS.OVERFLOW_TRIGGER);
|
|
47
|
+
const newState = { ...pluginState };
|
|
48
|
+
if (meta) {
|
|
49
|
+
newState.lastTrigger = { ...meta };
|
|
50
|
+
dispatch(pluginKey, newState);
|
|
51
|
+
return newState;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return pluginState;
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
appendTransaction: (transactions, oldState, newState) => {
|
|
58
|
+
const newPluginState = pluginKey.getState(newState);
|
|
59
|
+
let hasAnalyticsBeenDispatched = false;
|
|
60
|
+
let lastTriggerName =
|
|
61
|
+
newPluginState?.lastTrigger?.name ||
|
|
62
|
+
// NOTE: We assume that we know and can correctly differentiate
|
|
63
|
+
// between all triggers of table overflow state change.
|
|
64
|
+
// The only trigger we can't identify is viewport width change.
|
|
65
|
+
// However, since there is still a chance that there are other triggers we didn't think of,
|
|
66
|
+
// all these unknown triggers and viwport width change trigger are captured as EXTERNAL.
|
|
67
|
+
TABLE_OVERFLOW_CHANGE_TRIGGER.EXTERNAL;
|
|
68
|
+
|
|
69
|
+
transactions.forEach((tr) => {
|
|
70
|
+
const payload = tr.getMeta(META_KEYS.OVERFLOW_STATE_CHANGED);
|
|
71
|
+
|
|
72
|
+
if (payload) {
|
|
73
|
+
dispatchAnalyticsEvent({
|
|
74
|
+
action: TABLE_ACTION.OVERFLOW_CHANGED,
|
|
75
|
+
actionSubject: ACTION_SUBJECT.TABLE,
|
|
76
|
+
actionSubjectId: null,
|
|
77
|
+
eventType: EVENT_TYPE.TRACK,
|
|
78
|
+
attributes: {
|
|
79
|
+
editorWidth: payload.editorWidth,
|
|
80
|
+
parentWidth: payload.parentWidth,
|
|
81
|
+
isOverflowing: payload.isOverflowing,
|
|
82
|
+
wasOverflowing: payload.wasOverflowing,
|
|
83
|
+
width: payload.width,
|
|
84
|
+
tableResizingEnabled,
|
|
85
|
+
trigger: lastTriggerName,
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
hasAnalyticsBeenDispatched = true;
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
if (hasAnalyticsBeenDispatched) {
|
|
94
|
+
const tr = newState.tr;
|
|
95
|
+
return tr.setMeta(META_KEYS.OVERFLOW_TRIGGER, {});
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return undefined;
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
export { createPlugin };
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
+
import { TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
|
|
1
2
|
import type { Command } 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';
|
|
3
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
4
|
+
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
5
|
+
import type { ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
|
|
5
6
|
import { isTableSelected } from '@atlaskit/editor-tables/utils';
|
|
6
7
|
|
|
7
8
|
import { updateColumnWidths } from '../../transforms';
|
|
9
|
+
import { META_KEYS } from '../table-analytics';
|
|
8
10
|
|
|
9
11
|
import { createCommand, getPluginState } from './plugin-factory';
|
|
10
|
-
import {
|
|
12
|
+
import type { ResizeState } from './utils';
|
|
13
|
+
import { evenAllColumnsWidths, isClickNear } from './utils';
|
|
11
14
|
|
|
12
15
|
export const evenColumns =
|
|
13
16
|
({
|
|
@@ -60,6 +63,9 @@ export const distributeColumnsWidths =
|
|
|
60
63
|
table.node,
|
|
61
64
|
table.start,
|
|
62
65
|
)(state.tr);
|
|
66
|
+
tr.setMeta(META_KEYS.OVERFLOW_TRIGGER, {
|
|
67
|
+
name: TABLE_OVERFLOW_CHANGE_TRIGGER.DISTRIBUTED_COLUMNS,
|
|
68
|
+
});
|
|
63
69
|
stopResizing(tr)(state, dispatch);
|
|
64
70
|
}
|
|
65
71
|
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
ACTION_SUBJECT,
|
|
4
4
|
EVENT_TYPE,
|
|
5
5
|
TABLE_ACTION,
|
|
6
|
+
TABLE_OVERFLOW_CHANGE_TRIGGER,
|
|
6
7
|
} from '@atlaskit/editor-common/analytics';
|
|
7
8
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
8
9
|
import { getParentNodeWidth } from '@atlaskit/editor-common/node-width';
|
|
@@ -20,6 +21,7 @@ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
|
20
21
|
import { updateResizeHandleDecorations } from '../../commands/misc';
|
|
21
22
|
import { updateColumnWidths } from '../../transforms';
|
|
22
23
|
import { getSelectedColumnIndexes, updateResizeHandles } from '../../utils';
|
|
24
|
+
import { META_KEYS } from '../table-analytics';
|
|
23
25
|
|
|
24
26
|
import { evenColumns, setDragging, stopResizing } from './commands';
|
|
25
27
|
import { getPluginState } from './plugin-factory';
|
|
@@ -53,6 +55,14 @@ export const handleMouseDown = (
|
|
|
53
55
|
}
|
|
54
56
|
event.preventDefault();
|
|
55
57
|
|
|
58
|
+
if (getBooleanFF('platform.editor.table.overflow-state-analytics')) {
|
|
59
|
+
const tr = view.state.tr;
|
|
60
|
+
tr.setMeta(META_KEYS.OVERFLOW_TRIGGER, {
|
|
61
|
+
name: TABLE_OVERFLOW_CHANGE_TRIGGER.RESIZED_COLUMN,
|
|
62
|
+
});
|
|
63
|
+
dispatch(tr);
|
|
64
|
+
}
|
|
65
|
+
|
|
56
66
|
const mouseDownTime = event.timeStamp;
|
|
57
67
|
const cell = state.doc.nodeAt(localResizeHandlePos);
|
|
58
68
|
const $cell = state.doc.resolve(localResizeHandlePos);
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import { CellAttributes } from '@atlaskit/adf-schema';
|
|
1
|
+
import type { CellAttributes } from '@atlaskit/adf-schema';
|
|
2
2
|
import { AddColumnStep } from '@atlaskit/adf-schema/steps';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
|
|
4
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
5
|
+
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
6
|
+
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
7
|
+
import type { Rect } from '@atlaskit/editor-tables/table-map';
|
|
8
|
+
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
6
9
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
7
10
|
|
|
11
|
+
import { META_KEYS } from '../pm-plugins/table-analytics';
|
|
12
|
+
|
|
8
13
|
import { splitCellsInColumns } from './split';
|
|
9
14
|
|
|
10
15
|
const deleteColumnsCustomStep =
|
|
@@ -244,6 +249,9 @@ function fixRowSpans(table: PMNode): PMNode | null {
|
|
|
244
249
|
export const deleteColumns =
|
|
245
250
|
(rect: Rect, allowAddColumnCustomStep = false) =>
|
|
246
251
|
(tr: Transaction): Transaction => {
|
|
252
|
+
tr.setMeta(META_KEYS.OVERFLOW_TRIGGER, {
|
|
253
|
+
name: TABLE_OVERFLOW_CHANGE_TRIGGER.DELETED_COLUMN,
|
|
254
|
+
});
|
|
247
255
|
if (allowAddColumnCustomStep) {
|
|
248
256
|
return deleteColumnsCustomStep(rect)(tr);
|
|
249
257
|
}
|
|
@@ -481,7 +481,7 @@ const getLastColumnResizerOverrides = () => {
|
|
|
481
481
|
.${ClassName.RESIZE_HANDLE_DECORATION} {
|
|
482
482
|
background-color: transparent;
|
|
483
483
|
position: absolute;
|
|
484
|
-
width: ${resizeHandlerAreaWidth}px;
|
|
484
|
+
width: ${resizeHandlerAreaWidth / 2}px;
|
|
485
485
|
height: 100%;
|
|
486
486
|
top: 0;
|
|
487
487
|
right: 0;
|