@atlaskit/editor-plugin-table 3.0.5 → 3.1.1
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 +16 -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 +112 -47
- 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/common-styles.js +1 -1
- package/dist/cjs/plugins/table/ui/consts.js +3 -1
- 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 +73 -4
- 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/common-styles.js +4 -1
- package/dist/es2019/plugins/table/ui/consts.js +1 -0
- package/dist/es2019/plugins/table/ui/ui-styles.js +7 -5
- 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 +114 -49
- 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/common-styles.js +2 -2
- package/dist/esm/plugins/table/ui/consts.js +1 -0
- package/dist/esm/plugins/table/ui/ui-styles.js +2 -2
- 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/plugins/table/ui/consts.d.ts +1 -0
- 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/dist/types-ts4.5/plugins/table/ui/consts.d.ts +1 -0
- package/package.json +8 -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 +110 -4
- 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/common-styles.ts +4 -0
- package/src/plugins/table/ui/consts.ts +1 -0
- package/src/plugins/table/ui/ui-styles.ts +28 -5
|
@@ -98,6 +98,7 @@ export const stickyRowZIndex = resizeHandlerZIndex + 2;
|
|
|
98
98
|
export const stickyRowOffsetTop = 8;
|
|
99
99
|
export const stickyHeaderBorderBottomWidth = 1;
|
|
100
100
|
export const tableOverflowShadowWidth = 8;
|
|
101
|
+
export const tableOverflowShadowWidthWide = 32;
|
|
101
102
|
export const TABLE_SNAP_GAP = 9;
|
|
102
103
|
export const TABLE_HIGHLIGHT_GAP = 10;
|
|
103
104
|
export const TABLE_HIGHLIGHT_TOLERANCE = 2;
|
|
@@ -5,7 +5,7 @@ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
|
5
5
|
import { B300, N0, N300, N40A, N60A, Y200, Y50 } from '@atlaskit/theme/colors';
|
|
6
6
|
import { borderRadius } from '@atlaskit/theme/constants';
|
|
7
7
|
import { TableCssClassName as ClassName } from '../types';
|
|
8
|
-
import { columnControlsDecorationHeight, columnControlsSelectedZIndex, columnControlsZIndex, lineMarkerSize, resizeHandlerAreaWidth, resizeHandlerZIndex, resizeLineWidth, tableBorderColor, tableBorderDeleteColor, tableBorderSelectedColor, tableCellDeleteColor, tableCellHoverDeleteIconBackground, tableCellHoverDeleteIconColor, tableCellSelectedDeleteIconBackground, tableCellSelectedDeleteIconColor, tableDeleteButtonSize, tableHeaderCellBackgroundColor, tableInsertColumnButtonSize, tableOverflowShadowWidth, tableToolbarDeleteColor, tableToolbarSelectedColor, tableToolbarSize } from './consts';
|
|
8
|
+
import { columnControlsDecorationHeight, columnControlsSelectedZIndex, columnControlsZIndex, lineMarkerSize, resizeHandlerAreaWidth, resizeHandlerZIndex, resizeLineWidth, tableBorderColor, tableBorderDeleteColor, tableBorderSelectedColor, tableCellDeleteColor, tableCellHoverDeleteIconBackground, tableCellHoverDeleteIconColor, tableCellSelectedDeleteIconBackground, tableCellSelectedDeleteIconColor, tableDeleteButtonSize, tableHeaderCellBackgroundColor, tableInsertColumnButtonSize, tableOverflowShadowWidth, tableOverflowShadowWidthWide, tableToolbarDeleteColor, tableToolbarSelectedColor, tableToolbarSize } from './consts';
|
|
9
9
|
const InsertLine = (props, cssString) => css`
|
|
10
10
|
.${ClassName.CONTROLS_INSERT_LINE} {
|
|
11
11
|
background: ${tableBorderSelectedColor(props)};
|
|
@@ -187,13 +187,14 @@ export const OverflowShadow = props => css`
|
|
|
187
187
|
pointer-events: none;
|
|
188
188
|
top: ${tableMarginTop}px;
|
|
189
189
|
z-index: ${akEditorShadowZIndex};
|
|
190
|
-
width: ${tableOverflowShadowWidth}px;
|
|
190
|
+
width: ${getBooleanFF('platform.editor.table.increase-shadow-visibility_lh89r') ? tableOverflowShadowWidthWide : tableOverflowShadowWidth}px;
|
|
191
191
|
}
|
|
192
192
|
.${ClassName.TABLE_LEFT_SHADOW} {
|
|
193
193
|
background: linear-gradient(
|
|
194
194
|
to left,
|
|
195
195
|
transparent 0,
|
|
196
|
-
${`var(--ds-shadow-overflow-spread, ${N40A})`}
|
|
196
|
+
${`var(--ds-shadow-overflow-spread, ${N40A})`}
|
|
197
|
+
${getBooleanFF('platform.editor.table.increase-shadow-visibility_lh89r') ? 140 : 100}%
|
|
197
198
|
),
|
|
198
199
|
linear-gradient(
|
|
199
200
|
to right,
|
|
@@ -209,14 +210,15 @@ export const OverflowShadow = props => css`
|
|
|
209
210
|
background: linear-gradient(
|
|
210
211
|
to right,
|
|
211
212
|
transparent 0,
|
|
212
|
-
${`var(--ds-shadow-overflow-spread, ${N40A})`}
|
|
213
|
+
${`var(--ds-shadow-overflow-spread, ${N40A})`}
|
|
214
|
+
${getBooleanFF('platform.editor.table.increase-shadow-visibility_lh89r') ? 140 : 100}%
|
|
213
215
|
),
|
|
214
216
|
linear-gradient(
|
|
215
217
|
to left,
|
|
216
218
|
${"var(--ds-shadow-overflow-perimeter, transparent)"} 0px,
|
|
217
219
|
transparent 1px
|
|
218
220
|
);
|
|
219
|
-
left: ${getBooleanFF('platform.editor.custom-table-width') ? `calc(100% - ${tableOverflowShadowWidth}px)` :
|
|
221
|
+
left: ${getBooleanFF('platform.editor.custom-table-width') ? `calc(100% - ${getBooleanFF('platform.editor.table.increase-shadow-visibility_lh89r') ? tableOverflowShadowWidthWide : tableOverflowShadowWidth}px)` : `calc(100% - ${getBooleanFF('platform.editor.table.increase-shadow-visibility_lh89r') ? tableOverflowShadowWidthWide - 10 : -2}px)`};
|
|
220
222
|
}
|
|
221
223
|
.${ClassName.WITH_CONTROLS} {
|
|
222
224
|
.${ClassName.TABLE_RIGHT_SHADOW}, .${ClassName.TABLE_LEFT_SHADOW} {
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
// #region Imports
|
|
2
2
|
import { AddColumnStep } from '@atlaskit/adf-schema/steps';
|
|
3
|
+
import { TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
|
|
3
4
|
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
4
5
|
import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
5
6
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
6
7
|
import { addColumnAt as addColumnAtPMUtils, addRowAt, createTable as createTableNode, findTable, selectedRect } from '@atlaskit/editor-tables/utils';
|
|
8
|
+
import { META_KEYS } from '../pm-plugins/table-analytics';
|
|
7
9
|
import { rescaleColumns } from '../transforms/column-width';
|
|
8
10
|
import { checkIfHeaderRowEnabled, copyPreviousRow } from '../utils';
|
|
9
11
|
import { getAllowAddColumnCustomStep } from '../utils/get-allow-add-column-custom-step';
|
|
@@ -35,6 +37,9 @@ export function addColumnAt(getEditorContainerWidth) {
|
|
|
35
37
|
// [ED-8288] Update colwidths manually to avoid multiple dispatch in TableComponent
|
|
36
38
|
updatedTr = rescaleColumns(getEditorContainerWidth)(table, view)(updatedTr);
|
|
37
39
|
}
|
|
40
|
+
updatedTr.setMeta(META_KEYS.OVERFLOW_TRIGGER, {
|
|
41
|
+
name: TABLE_OVERFLOW_CHANGE_TRIGGER.ADDED_COLUMN
|
|
42
|
+
});
|
|
38
43
|
return updatedTr;
|
|
39
44
|
};
|
|
40
45
|
};
|
|
@@ -3,8 +3,10 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
3
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
4
|
//#region Imports
|
|
5
5
|
|
|
6
|
+
import { TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
|
|
6
7
|
import { findTable, toggleHeader } from '@atlaskit/editor-tables/utils';
|
|
7
8
|
import { createCommand } from '../pm-plugins/plugin-factory';
|
|
9
|
+
import { META_KEYS } from '../pm-plugins/table-analytics';
|
|
8
10
|
//#endregion
|
|
9
11
|
|
|
10
12
|
// #region Utils
|
|
@@ -50,10 +52,15 @@ export var toggleNumberColumn = function toggleNumberColumn(state, dispatch) {
|
|
|
50
52
|
var _ref = findTable(state.selection),
|
|
51
53
|
node = _ref.node,
|
|
52
54
|
pos = _ref.pos;
|
|
55
|
+
var isNumberedColumnEnabled = node.attrs.isNumberColumnEnabled;
|
|
53
56
|
tr.setNodeMarkup(pos, state.schema.nodes.table, _objectSpread(_objectSpread({}, node.attrs), {}, {
|
|
54
|
-
isNumberColumnEnabled: !
|
|
57
|
+
isNumberColumnEnabled: !isNumberedColumnEnabled
|
|
55
58
|
}));
|
|
56
59
|
tr.setMeta('scrollIntoView', false);
|
|
60
|
+
var tableOverflowChangeTriggerName = isNumberedColumnEnabled ? TABLE_OVERFLOW_CHANGE_TRIGGER.DISABLED_NUMBERED_COLUMN : TABLE_OVERFLOW_CHANGE_TRIGGER.ENABLED_NUMBERED_COLUMN;
|
|
61
|
+
tr.setMeta(META_KEYS.OVERFLOW_TRIGGER, {
|
|
62
|
+
name: tableOverflowChangeTriggerName
|
|
63
|
+
});
|
|
57
64
|
if (dispatch) {
|
|
58
65
|
dispatch(tr);
|
|
59
66
|
}
|
|
@@ -74,6 +81,9 @@ export var toggleTableLayout = function toggleTableLayout(state, dispatch) {
|
|
|
74
81
|
tr.setNodeMarkup(table.pos, state.schema.nodes.table, _objectSpread(_objectSpread({}, table.node.attrs), {}, {
|
|
75
82
|
layout: layout
|
|
76
83
|
}));
|
|
84
|
+
tr.setMeta(META_KEYS.OVERFLOW_TRIGGER, {
|
|
85
|
+
name: TABLE_OVERFLOW_CHANGE_TRIGGER.RESIZED
|
|
86
|
+
});
|
|
77
87
|
return tr.setMeta('scrollIntoView', false);
|
|
78
88
|
})(state, dispatch);
|
|
79
89
|
};
|
|
@@ -10,6 +10,7 @@ import { browser } from '@atlaskit/editor-common/utils';
|
|
|
10
10
|
import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
|
|
11
11
|
import { tableEditing } from '@atlaskit/editor-tables/pm-plugins';
|
|
12
12
|
import { createTable } from '@atlaskit/editor-tables/utils';
|
|
13
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
13
14
|
import { pluginConfig } from './create-plugin-config';
|
|
14
15
|
import { createPlugin as createDecorationsPlugin } from './pm-plugins/decorations/plugin';
|
|
15
16
|
import { keymapPlugin } from './pm-plugins/keymap';
|
|
@@ -17,6 +18,7 @@ import { createPlugin } from './pm-plugins/main';
|
|
|
17
18
|
import { pluginKey } from './pm-plugins/plugin-key';
|
|
18
19
|
import { createPlugin as createTableSafariDeleteCompositionTextIssueWorkaroundPlugin } from './pm-plugins/safari-delete-composition-text-issue-workaround';
|
|
19
20
|
import { createPlugin as createStickyHeadersPlugin, findStickyHeaderForTable, pluginKey as stickyHeadersPluginKey } from './pm-plugins/sticky-headers';
|
|
21
|
+
import { createPlugin as createTableAnalyticsPlugin, pluginKey as tableAnalyticsPluginKey } from './pm-plugins/table-analytics';
|
|
20
22
|
import { createPlugin as createTableLocalIdPlugin } from './pm-plugins/table-local-id';
|
|
21
23
|
import { createPlugin as createFlexiResizingPlugin, pluginKey as tableResizingPluginKey } from './pm-plugins/table-resizing';
|
|
22
24
|
import { tableSelectionKeymapPlugin } from './pm-plugins/table-selection-keymap';
|
|
@@ -182,6 +184,14 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
182
184
|
dispatch = _ref9.dispatch;
|
|
183
185
|
return options !== null && options !== void 0 && options.tableResizingEnabled ? createTableWidthPlugin(dispatch, dispatchAnalyticsEvent, (_options$fullWidthEna = options === null || options === void 0 ? void 0 : options.fullWidthEnabled) !== null && _options$fullWidthEna !== void 0 ? _options$fullWidthEna : false) : undefined;
|
|
184
186
|
}
|
|
187
|
+
}, {
|
|
188
|
+
name: 'tableAnalyticsPlugin',
|
|
189
|
+
plugin: function plugin(_ref10) {
|
|
190
|
+
var _options$tableResizin;
|
|
191
|
+
var dispatch = _ref10.dispatch,
|
|
192
|
+
dispatchAnalyticsEvent = _ref10.dispatchAnalyticsEvent;
|
|
193
|
+
return getBooleanFF('platform.editor.table.overflow-state-analytics') ? createTableAnalyticsPlugin(dispatch, dispatchAnalyticsEvent, (_options$tableResizin = options === null || options === void 0 ? void 0 : options.tableResizingEnabled) !== null && _options$tableResizin !== void 0 ? _options$tableResizin : false) : undefined;
|
|
194
|
+
}
|
|
185
195
|
}, {
|
|
186
196
|
name: 'tableGetEditorViewReferencePlugin',
|
|
187
197
|
plugin: function plugin() {
|
|
@@ -210,45 +220,46 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
210
220
|
}
|
|
211
221
|
return plugins;
|
|
212
222
|
},
|
|
213
|
-
contentComponent: function contentComponent(
|
|
214
|
-
var editorView =
|
|
215
|
-
popupsMountPoint =
|
|
216
|
-
popupsBoundariesElement =
|
|
217
|
-
popupsScrollableElement =
|
|
218
|
-
dispatchAnalyticsEvent =
|
|
223
|
+
contentComponent: function contentComponent(_ref11) {
|
|
224
|
+
var editorView = _ref11.editorView,
|
|
225
|
+
popupsMountPoint = _ref11.popupsMountPoint,
|
|
226
|
+
popupsBoundariesElement = _ref11.popupsBoundariesElement,
|
|
227
|
+
popupsScrollableElement = _ref11.popupsScrollableElement,
|
|
228
|
+
dispatchAnalyticsEvent = _ref11.dispatchAnalyticsEvent;
|
|
219
229
|
return /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
220
230
|
component: ACTION_SUBJECT.TABLES_PLUGIN,
|
|
221
231
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
222
232
|
fallbackComponent: null
|
|
223
233
|
}, /*#__PURE__*/React.createElement(WithPluginState, {
|
|
224
234
|
plugins: {
|
|
235
|
+
tableAnalyticsPluginState: tableAnalyticsPluginKey,
|
|
225
236
|
tablePluginState: pluginKey,
|
|
226
237
|
tableWidthPluginState: tableWidthPluginKey,
|
|
227
238
|
tableResizingPluginState: tableResizingPluginKey,
|
|
228
239
|
stickyHeadersState: stickyHeadersPluginKey
|
|
229
240
|
},
|
|
230
|
-
render: function render(
|
|
231
|
-
var resizingPluginState =
|
|
232
|
-
stickyHeadersState =
|
|
233
|
-
tablePluginState =
|
|
234
|
-
tableWidthPluginState =
|
|
241
|
+
render: function render(_ref12) {
|
|
242
|
+
var resizingPluginState = _ref12.tableResizingPluginState,
|
|
243
|
+
stickyHeadersState = _ref12.stickyHeadersState,
|
|
244
|
+
tablePluginState = _ref12.tablePluginState,
|
|
245
|
+
tableWidthPluginState = _ref12.tableWidthPluginState;
|
|
235
246
|
var state = editorView.state;
|
|
236
247
|
var isColumnResizing = resizingPluginState === null || resizingPluginState === void 0 ? void 0 : resizingPluginState.dragging;
|
|
237
248
|
var isTableResizing = tableWidthPluginState === null || tableWidthPluginState === void 0 ? void 0 : tableWidthPluginState.resizing;
|
|
238
249
|
var isResizing = isColumnResizing || isTableResizing;
|
|
239
|
-
var
|
|
240
|
-
tableNode =
|
|
241
|
-
tablePos =
|
|
242
|
-
targetCellPosition =
|
|
243
|
-
isContextualMenuOpen =
|
|
244
|
-
layout =
|
|
245
|
-
tableRef =
|
|
246
|
-
pluginConfig =
|
|
247
|
-
insertColumnButtonIndex =
|
|
248
|
-
insertRowButtonIndex =
|
|
249
|
-
isHeaderColumnEnabled =
|
|
250
|
-
isHeaderRowEnabled =
|
|
251
|
-
tableWrapperTarget =
|
|
250
|
+
var _ref13 = tablePluginState,
|
|
251
|
+
tableNode = _ref13.tableNode,
|
|
252
|
+
tablePos = _ref13.tablePos,
|
|
253
|
+
targetCellPosition = _ref13.targetCellPosition,
|
|
254
|
+
isContextualMenuOpen = _ref13.isContextualMenuOpen,
|
|
255
|
+
layout = _ref13.layout,
|
|
256
|
+
tableRef = _ref13.tableRef,
|
|
257
|
+
pluginConfig = _ref13.pluginConfig,
|
|
258
|
+
insertColumnButtonIndex = _ref13.insertColumnButtonIndex,
|
|
259
|
+
insertRowButtonIndex = _ref13.insertRowButtonIndex,
|
|
260
|
+
isHeaderColumnEnabled = _ref13.isHeaderColumnEnabled,
|
|
261
|
+
isHeaderRowEnabled = _ref13.isHeaderRowEnabled,
|
|
262
|
+
tableWrapperTarget = _ref13.tableWrapperTarget;
|
|
252
263
|
var allowControls = pluginConfig.allowControls;
|
|
253
264
|
var stickyHeader = stickyHeadersState ? findStickyHeaderForTable(stickyHeadersState, tablePos) : undefined;
|
|
254
265
|
var LayoutContent = options && !options.tableResizingEnabled && isLayoutSupported(state) && options.breakoutEnabled ? /*#__PURE__*/React.createElement(LayoutButton, {
|
|
@@ -314,8 +325,8 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
314
325
|
}));
|
|
315
326
|
},
|
|
316
327
|
pluginsOptions: {
|
|
317
|
-
quickInsert: function quickInsert(
|
|
318
|
-
var formatMessage =
|
|
328
|
+
quickInsert: function quickInsert(_ref14) {
|
|
329
|
+
var formatMessage = _ref14.formatMessage;
|
|
319
330
|
return [{
|
|
320
331
|
id: 'table',
|
|
321
332
|
title: formatMessage(messages.table),
|
|
@@ -13,25 +13,32 @@ import React from 'react';
|
|
|
13
13
|
import classnames from 'classnames';
|
|
14
14
|
import memoizeOne from 'memoize-one';
|
|
15
15
|
import rafSchedule from 'raf-schd';
|
|
16
|
+
import { ACTION_SUBJECT, EVENT_TYPE, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
|
|
17
|
+
import { createDispatch } from '@atlaskit/editor-common/event-dispatcher';
|
|
16
18
|
import { getParentNodeWidth } from '@atlaskit/editor-common/node-width';
|
|
17
19
|
import { tableMarginSides } from '@atlaskit/editor-common/styles';
|
|
18
|
-
import { browser, isValidPosition } from '@atlaskit/editor-common/utils';
|
|
20
|
+
import { analyticsEventKey, browser, isValidPosition } from '@atlaskit/editor-common/utils';
|
|
19
21
|
import { akEditorTableToolbarSize as tableToolbarSize } from '@atlaskit/editor-shared-styles';
|
|
20
22
|
import { findTable, isTableSelected } from '@atlaskit/editor-tables/utils';
|
|
21
23
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
22
24
|
import { autoSizeTable, clearHoverSelection } from '../commands';
|
|
23
25
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
24
26
|
import { findStickyHeaderForTable, pluginKey as stickyHeadersPluginKey } from '../pm-plugins/sticky-headers';
|
|
27
|
+
import { META_KEYS } from '../pm-plugins/table-analytics';
|
|
25
28
|
import { getLayoutSize, insertColgroupFromNode as recreateResizeColsByNode, scaleTable } from '../pm-plugins/table-resizing/utils';
|
|
26
29
|
import { hasTableBeenResized } from '../pm-plugins/table-resizing/utils/colgroup';
|
|
27
30
|
import { updateControls } from '../pm-plugins/table-resizing/utils/dom';
|
|
28
31
|
import { TableCssClassName as ClassName, ShadowEvent } from '../types';
|
|
29
|
-
import { tableOverflowShadowWidth } from '../ui/consts';
|
|
32
|
+
import { tableOverflowShadowWidth, tableOverflowShadowWidthWide } from '../ui/consts';
|
|
30
33
|
import TableFloatingControls from '../ui/TableFloatingControls';
|
|
31
34
|
import { containsHeaderRow, isTableNested, tablesHaveDifferentColumnWidths, tablesHaveDifferentNoOfColumns } from '../utils';
|
|
32
35
|
import { OverflowShadowsObserver } from './OverflowShadowsObserver';
|
|
33
36
|
import { TableContainer } from './TableContainer';
|
|
34
37
|
var isIE11 = browser.ie_version === 11;
|
|
38
|
+
// When table is inserted via paste, keyboard shortcut or quickInsert,
|
|
39
|
+
// componentDidUpdate is called multiple times. The isOverflowing value is correct only on the last update.
|
|
40
|
+
// To make sure we capture the last update, we use setTimeout.
|
|
41
|
+
var initialOverflowCaptureTimeroutDelay = 300;
|
|
35
42
|
var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
36
43
|
_inherits(TableComponent, _React$Component);
|
|
37
44
|
var _super = _createSuper(TableComponent);
|
|
@@ -169,13 +176,40 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
169
176
|
}, options), domAtPos)(state.tr);
|
|
170
177
|
dispatch(tr);
|
|
171
178
|
});
|
|
179
|
+
_defineProperty(_assertThisInitialized(_this), "setTimerToSendInitialOverflowCaptured", function (isOverflowing) {
|
|
180
|
+
var _this$state;
|
|
181
|
+
var _this$props3 = _this.props,
|
|
182
|
+
eventDispatcher = _this$props3.eventDispatcher,
|
|
183
|
+
containerWidth = _this$props3.containerWidth,
|
|
184
|
+
options = _this$props3.options;
|
|
185
|
+
var dispatch = createDispatch(eventDispatcher);
|
|
186
|
+
var parentWidth = ((_this$state = _this.state) === null || _this$state === void 0 ? void 0 : _this$state.parentWidth) || 0;
|
|
187
|
+
_this.initialOverflowCaptureTimerId = setTimeout(function () {
|
|
188
|
+
dispatch(analyticsEventKey, {
|
|
189
|
+
payload: {
|
|
190
|
+
action: TABLE_ACTION.INITIAL_OVERFLOW_CAPTURED,
|
|
191
|
+
actionSubject: ACTION_SUBJECT.TABLE,
|
|
192
|
+
actionSubjectId: null,
|
|
193
|
+
eventType: EVENT_TYPE.TRACK,
|
|
194
|
+
attributes: {
|
|
195
|
+
editorWidth: containerWidth.width || 0,
|
|
196
|
+
isOverflowing: isOverflowing,
|
|
197
|
+
tableResizingEnabled: (options === null || options === void 0 ? void 0 : options.isTableResizingEnabled) || false,
|
|
198
|
+
width: _this.node.attrs.width || 0,
|
|
199
|
+
parentWidth: parentWidth
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
_this.isInitialOverflowSent = true;
|
|
204
|
+
}, initialOverflowCaptureTimeroutDelay);
|
|
205
|
+
});
|
|
172
206
|
_defineProperty(_assertThisInitialized(_this), "handleAutoSize", function () {
|
|
173
207
|
if (_this.table) {
|
|
174
|
-
var _this$
|
|
175
|
-
view = _this$
|
|
176
|
-
getNode = _this$
|
|
177
|
-
getPos = _this$
|
|
178
|
-
containerWidth = _this$
|
|
208
|
+
var _this$props4 = _this.props,
|
|
209
|
+
view = _this$props4.view,
|
|
210
|
+
getNode = _this$props4.getNode,
|
|
211
|
+
getPos = _this$props4.getPos,
|
|
212
|
+
containerWidth = _this$props4.containerWidth;
|
|
179
213
|
var _node = getNode();
|
|
180
214
|
var pos = getPos();
|
|
181
215
|
if (!isValidPosition(pos, view.state)) {
|
|
@@ -188,9 +222,9 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
188
222
|
});
|
|
189
223
|
_defineProperty(_assertThisInitialized(_this), "handleWindowResize", function () {
|
|
190
224
|
var _node$attrs, _node$attrs2;
|
|
191
|
-
var _this$
|
|
192
|
-
getNode = _this$
|
|
193
|
-
containerWidth = _this$
|
|
225
|
+
var _this$props5 = _this.props,
|
|
226
|
+
getNode = _this$props5.getNode,
|
|
227
|
+
containerWidth = _this$props5.containerWidth;
|
|
194
228
|
var node = getNode();
|
|
195
229
|
var prevNode = _this.node;
|
|
196
230
|
var layoutSize = _this.tableNodeLayoutSize(node);
|
|
@@ -206,11 +240,11 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
206
240
|
});
|
|
207
241
|
});
|
|
208
242
|
_defineProperty(_assertThisInitialized(_this), "getParentNodeWidth", function () {
|
|
209
|
-
var _this$
|
|
210
|
-
getPos = _this$
|
|
211
|
-
containerWidth = _this$
|
|
212
|
-
options = _this$
|
|
213
|
-
state = _this$
|
|
243
|
+
var _this$props6 = _this.props,
|
|
244
|
+
getPos = _this$props6.getPos,
|
|
245
|
+
containerWidth = _this$props6.containerWidth,
|
|
246
|
+
options = _this$props6.options,
|
|
247
|
+
state = _this$props6.view.state;
|
|
214
248
|
var pos = getPos();
|
|
215
249
|
if (!isValidPosition(pos, state)) {
|
|
216
250
|
return;
|
|
@@ -236,6 +270,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
236
270
|
_getNode = props.getNode;
|
|
237
271
|
_this.node = _getNode();
|
|
238
272
|
_this.containerWidth = _containerWidth;
|
|
273
|
+
_this.isInitialOverflowSent = false;
|
|
239
274
|
|
|
240
275
|
// store table size using previous full-width mode so can detect if it has changed
|
|
241
276
|
var isFullWidthModeEnabled = _options ? _options.wasFullWidthModeEnabled : false;
|
|
@@ -257,10 +292,10 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
257
292
|
_createClass(TableComponent, [{
|
|
258
293
|
key: "componentDidMount",
|
|
259
294
|
value: function componentDidMount() {
|
|
260
|
-
var _this$
|
|
261
|
-
allowColumnResizing = _this$
|
|
262
|
-
eventDispatcher = _this$
|
|
263
|
-
options = _this$
|
|
295
|
+
var _this$props7 = this.props,
|
|
296
|
+
allowColumnResizing = _this$props7.allowColumnResizing,
|
|
297
|
+
eventDispatcher = _this$props7.eventDispatcher,
|
|
298
|
+
options = _this$props7.options;
|
|
264
299
|
if (allowColumnResizing && this.wrapper && !isIE11) {
|
|
265
300
|
this.wrapper.addEventListener('scroll', this.handleScrollDebounced);
|
|
266
301
|
}
|
|
@@ -279,14 +314,18 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
279
314
|
this.onStickyState(currentStickyState);
|
|
280
315
|
}
|
|
281
316
|
eventDispatcher.on(stickyHeadersPluginKey.key, this.onStickyState);
|
|
317
|
+
if (getBooleanFF('platform.editor.table.overflow-state-analytics')) {
|
|
318
|
+
var initialIsOveflowing = this.state[ShadowEvent.SHOW_BEFORE_SHADOW] || this.state[ShadowEvent.SHOW_AFTER_SHADOW];
|
|
319
|
+
this.setTimerToSendInitialOverflowCaptured(initialIsOveflowing);
|
|
320
|
+
}
|
|
282
321
|
}
|
|
283
322
|
}, {
|
|
284
323
|
key: "componentWillUnmount",
|
|
285
324
|
value: function componentWillUnmount() {
|
|
286
|
-
var _this$
|
|
287
|
-
allowColumnResizing = _this$
|
|
288
|
-
eventDispatcher = _this$
|
|
289
|
-
options = _this$
|
|
325
|
+
var _this$props8 = this.props,
|
|
326
|
+
allowColumnResizing = _this$props8.allowColumnResizing,
|
|
327
|
+
eventDispatcher = _this$props8.eventDispatcher,
|
|
328
|
+
options = _this$props8.options;
|
|
290
329
|
if (this.wrapper && !isIE11) {
|
|
291
330
|
this.wrapper.removeEventListener('scroll', this.handleScrollDebounced);
|
|
292
331
|
}
|
|
@@ -304,18 +343,21 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
304
343
|
this.overflowShadowsObserver.dispose();
|
|
305
344
|
}
|
|
306
345
|
eventDispatcher.off(stickyHeadersPluginKey.key, this.onStickyState);
|
|
346
|
+
if (this.initialOverflowCaptureTimerId) {
|
|
347
|
+
clearTimeout(this.initialOverflowCaptureTimerId);
|
|
348
|
+
}
|
|
307
349
|
}
|
|
308
350
|
}, {
|
|
309
351
|
key: "componentDidUpdate",
|
|
310
|
-
value: function componentDidUpdate() {
|
|
352
|
+
value: function componentDidUpdate(_, prevState) {
|
|
311
353
|
var _this$wrapper;
|
|
312
|
-
var _this$
|
|
313
|
-
view = _this$
|
|
314
|
-
getNode = _this$
|
|
315
|
-
isMediaFullscreen = _this$
|
|
316
|
-
allowColumnResizing = _this$
|
|
317
|
-
isResizing = _this$
|
|
318
|
-
options = _this$
|
|
354
|
+
var _this$props9 = this.props,
|
|
355
|
+
view = _this$props9.view,
|
|
356
|
+
getNode = _this$props9.getNode,
|
|
357
|
+
isMediaFullscreen = _this$props9.isMediaFullscreen,
|
|
358
|
+
allowColumnResizing = _this$props9.allowColumnResizing,
|
|
359
|
+
isResizing = _this$props9.isResizing,
|
|
360
|
+
options = _this$props9.options;
|
|
319
361
|
var _getPluginState = getPluginState(view.state),
|
|
320
362
|
isInDanger = _getPluginState.isInDanger;
|
|
321
363
|
var table = findTable(view.state.selection);
|
|
@@ -350,29 +392,52 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
350
392
|
}
|
|
351
393
|
this.handleTableResizingDebounced();
|
|
352
394
|
}
|
|
395
|
+
if (getBooleanFF('platform.editor.table.overflow-state-analytics')) {
|
|
396
|
+
var newIsOverflowing = this.state[ShadowEvent.SHOW_BEFORE_SHADOW] || this.state[ShadowEvent.SHOW_AFTER_SHADOW];
|
|
397
|
+
var prevIsOverflowing = prevState[ShadowEvent.SHOW_BEFORE_SHADOW] || prevState[ShadowEvent.SHOW_AFTER_SHADOW];
|
|
398
|
+
if (this.initialOverflowCaptureTimerId) {
|
|
399
|
+
clearTimeout(this.initialOverflowCaptureTimerId);
|
|
400
|
+
}
|
|
401
|
+
if (!this.isInitialOverflowSent) {
|
|
402
|
+
this.setTimerToSendInitialOverflowCaptured(newIsOverflowing);
|
|
403
|
+
}
|
|
404
|
+
if (this.isInitialOverflowSent && prevIsOverflowing !== newIsOverflowing) {
|
|
405
|
+
var _this$state2;
|
|
406
|
+
var _this$props$view = this.props.view,
|
|
407
|
+
dispatch = _this$props$view.dispatch,
|
|
408
|
+
tr = _this$props$view.state.tr;
|
|
409
|
+
dispatch(tr.setMeta(META_KEYS.OVERFLOW_STATE_CHANGED, {
|
|
410
|
+
isOverflowing: newIsOverflowing,
|
|
411
|
+
wasOverflowing: prevIsOverflowing,
|
|
412
|
+
editorWidth: this.props.containerWidth.width || 0,
|
|
413
|
+
width: this.node.attrs.width || 0,
|
|
414
|
+
parentWidth: ((_this$state2 = this.state) === null || _this$state2 === void 0 ? void 0 : _this$state2.parentWidth) || 0
|
|
415
|
+
}));
|
|
416
|
+
}
|
|
417
|
+
}
|
|
353
418
|
}
|
|
354
419
|
}, {
|
|
355
420
|
key: "render",
|
|
356
421
|
value: function render() {
|
|
357
422
|
var _classnames,
|
|
358
423
|
_this2 = this;
|
|
359
|
-
var _this$
|
|
360
|
-
view = _this$
|
|
361
|
-
getNode = _this$
|
|
362
|
-
isResizing = _this$
|
|
363
|
-
_this$
|
|
364
|
-
allowControls = _this$
|
|
365
|
-
isHeaderRowEnabled = _this$
|
|
366
|
-
ordering = _this$
|
|
367
|
-
isHeaderColumnEnabled = _this$
|
|
368
|
-
tableActive = _this$
|
|
369
|
-
containerWidth = _this$
|
|
370
|
-
options = _this$
|
|
371
|
-
getPos = _this$
|
|
372
|
-
pluginInjectionApi = _this$
|
|
373
|
-
var _this$
|
|
374
|
-
showBeforeShadow = _this$
|
|
375
|
-
showAfterShadow = _this$
|
|
424
|
+
var _this$props10 = this.props,
|
|
425
|
+
view = _this$props10.view,
|
|
426
|
+
getNode = _this$props10.getNode,
|
|
427
|
+
isResizing = _this$props10.isResizing,
|
|
428
|
+
_this$props10$allowCo = _this$props10.allowControls,
|
|
429
|
+
allowControls = _this$props10$allowCo === void 0 ? true : _this$props10$allowCo,
|
|
430
|
+
isHeaderRowEnabled = _this$props10.isHeaderRowEnabled,
|
|
431
|
+
ordering = _this$props10.ordering,
|
|
432
|
+
isHeaderColumnEnabled = _this$props10.isHeaderColumnEnabled,
|
|
433
|
+
tableActive = _this$props10.tableActive,
|
|
434
|
+
containerWidth = _this$props10.containerWidth,
|
|
435
|
+
options = _this$props10.options,
|
|
436
|
+
getPos = _this$props10.getPos,
|
|
437
|
+
pluginInjectionApi = _this$props10.pluginInjectionApi;
|
|
438
|
+
var _this$state3 = this.state,
|
|
439
|
+
showBeforeShadow = _this$state3.showBeforeShadow,
|
|
440
|
+
showAfterShadow = _this$state3.showAfterShadow;
|
|
376
441
|
var node = getNode();
|
|
377
442
|
// doesn't work well with WithPluginState
|
|
378
443
|
var _getPluginState2 = getPluginState(view.state),
|
|
@@ -464,7 +529,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
464
529
|
}), this.state.stickyHeader && /*#__PURE__*/React.createElement("div", {
|
|
465
530
|
style: {
|
|
466
531
|
position: 'absolute',
|
|
467
|
-
right: getBooleanFF('platform.editor.custom-table-width') ? "".concat(tableOverflowShadowWidth, "px") : '-2px'
|
|
532
|
+
right: getBooleanFF('platform.editor.custom-table-width') ? "".concat(getBooleanFF('platform.editor.table.increase-shadow-visibility_lh89r') ? tableOverflowShadowWidthWide : tableOverflowShadowWidth, "px") : '-2px'
|
|
468
533
|
}
|
|
469
534
|
}, /*#__PURE__*/React.createElement("div", {
|
|
470
535
|
className: "".concat(ClassName.TABLE_RIGHT_SHADOW, " ").concat(ClassName.TABLE_STICKY_SHADOW),
|
|
@@ -5,11 +5,13 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
5
5
|
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
6
6
|
import rafSchd from 'raf-schd';
|
|
7
7
|
import { defineMessages, useIntl } from 'react-intl-next';
|
|
8
|
+
import { TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
|
|
8
9
|
import { getGuidelinesWithHighlights } from '@atlaskit/editor-common/guideline';
|
|
9
10
|
import { ResizerNext } from '@atlaskit/editor-common/resizer';
|
|
10
11
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
11
12
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
12
13
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
14
|
+
import { META_KEYS } from '../pm-plugins/table-analytics';
|
|
13
15
|
import { COLUMN_MIN_WIDTH, getColgroupChildrenLength, previewScaleTable, scaleTable } from '../pm-plugins/table-resizing/utils';
|
|
14
16
|
import { pluginKey as tableWidthPluginKey } from '../pm-plugins/table-width';
|
|
15
17
|
import { TABLE_HIGHLIGHT_GAP, TABLE_HIGHLIGHT_TOLERANCE, TABLE_SNAP_GAP } from '../ui/consts';
|
|
@@ -135,6 +137,9 @@ export var TableResizer = function TableResizer(_ref) {
|
|
|
135
137
|
resizing: true
|
|
136
138
|
});
|
|
137
139
|
displayGapCursor(false);
|
|
140
|
+
tr.setMeta(META_KEYS.OVERFLOW_TRIGGER, {
|
|
141
|
+
name: TABLE_OVERFLOW_CHANGE_TRIGGER.RESIZED
|
|
142
|
+
});
|
|
138
143
|
dispatch(tr);
|
|
139
144
|
var visibleGuidelines = getVisibleGuidelines(defaultGuidelines, containerWidth);
|
|
140
145
|
setSnappingEnabled(displayGuideline(visibleGuidelines));
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
/**
|
|
5
|
+
* A plugin is created for collecting payload data for tableOverflowChanged analytics event
|
|
6
|
+
*/
|
|
7
|
+
import { ACTION_SUBJECT, EVENT_TYPE, TABLE_ACTION, TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
|
|
8
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
9
|
+
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
10
|
+
export var pluginKey = new PluginKey('tableAnalyticsPlugin');
|
|
11
|
+
export var META_KEYS = {
|
|
12
|
+
OVERFLOW_TRIGGER: 'tableOverflowTrigger',
|
|
13
|
+
OVERFLOW_STATE_CHANGED: 'tableOverflowStateChanged'
|
|
14
|
+
};
|
|
15
|
+
var createPlugin = function createPlugin(dispatch, dispatchAnalyticsEvent, tableResizingEnabled) {
|
|
16
|
+
return new SafePlugin({
|
|
17
|
+
key: pluginKey,
|
|
18
|
+
state: {
|
|
19
|
+
init: function init() {
|
|
20
|
+
return {
|
|
21
|
+
lastTrigger: undefined
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
apply: function apply(tr, pluginState) {
|
|
25
|
+
var meta = tr.getMeta(META_KEYS.OVERFLOW_TRIGGER);
|
|
26
|
+
var newState = _objectSpread({}, pluginState);
|
|
27
|
+
if (meta) {
|
|
28
|
+
newState.lastTrigger = _objectSpread({}, meta);
|
|
29
|
+
dispatch(pluginKey, newState);
|
|
30
|
+
return newState;
|
|
31
|
+
}
|
|
32
|
+
return pluginState;
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
appendTransaction: function appendTransaction(transactions, oldState, newState) {
|
|
36
|
+
var _newPluginState$lastT;
|
|
37
|
+
var newPluginState = pluginKey.getState(newState);
|
|
38
|
+
var hasAnalyticsBeenDispatched = false;
|
|
39
|
+
var lastTriggerName = (newPluginState === null || newPluginState === void 0 ? void 0 : (_newPluginState$lastT = newPluginState.lastTrigger) === null || _newPluginState$lastT === void 0 ? void 0 : _newPluginState$lastT.name) ||
|
|
40
|
+
// NOTE: We assume that we know and can correctly differentiate
|
|
41
|
+
// between all triggers of table overflow state change.
|
|
42
|
+
// The only trigger we can't identify is viewport width change.
|
|
43
|
+
// However, since there is still a chance that there are other triggers we didn't think of,
|
|
44
|
+
// all these unknown triggers and viwport width change trigger are captured as EXTERNAL.
|
|
45
|
+
TABLE_OVERFLOW_CHANGE_TRIGGER.EXTERNAL;
|
|
46
|
+
transactions.forEach(function (tr) {
|
|
47
|
+
var payload = tr.getMeta(META_KEYS.OVERFLOW_STATE_CHANGED);
|
|
48
|
+
if (payload) {
|
|
49
|
+
dispatchAnalyticsEvent({
|
|
50
|
+
action: TABLE_ACTION.OVERFLOW_CHANGED,
|
|
51
|
+
actionSubject: ACTION_SUBJECT.TABLE,
|
|
52
|
+
actionSubjectId: null,
|
|
53
|
+
eventType: EVENT_TYPE.TRACK,
|
|
54
|
+
attributes: {
|
|
55
|
+
editorWidth: payload.editorWidth,
|
|
56
|
+
parentWidth: payload.parentWidth,
|
|
57
|
+
isOverflowing: payload.isOverflowing,
|
|
58
|
+
wasOverflowing: payload.wasOverflowing,
|
|
59
|
+
width: payload.width,
|
|
60
|
+
tableResizingEnabled: tableResizingEnabled,
|
|
61
|
+
trigger: lastTriggerName
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
hasAnalyticsBeenDispatched = true;
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
if (hasAnalyticsBeenDispatched) {
|
|
68
|
+
var tr = newState.tr;
|
|
69
|
+
return tr.setMeta(META_KEYS.OVERFLOW_TRIGGER, {});
|
|
70
|
+
}
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
export { createPlugin };
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
|
|
1
2
|
import { isTableSelected } from '@atlaskit/editor-tables/utils';
|
|
2
3
|
import { updateColumnWidths } from '../../transforms';
|
|
4
|
+
import { META_KEYS } from '../table-analytics';
|
|
3
5
|
import { createCommand, getPluginState } from './plugin-factory';
|
|
4
6
|
import { evenAllColumnsWidths, isClickNear } from './utils';
|
|
5
7
|
export var evenColumns = function evenColumns(_ref) {
|
|
@@ -36,6 +38,9 @@ export var distributeColumnsWidths = function distributeColumnsWidths(newResizeS
|
|
|
36
38
|
return function (state, dispatch) {
|
|
37
39
|
if (dispatch) {
|
|
38
40
|
var _tr = updateColumnWidths(newResizeState, table.node, table.start)(state.tr);
|
|
41
|
+
_tr.setMeta(META_KEYS.OVERFLOW_TRIGGER, {
|
|
42
|
+
name: TABLE_OVERFLOW_CHANGE_TRIGGER.DISTRIBUTED_COLUMNS
|
|
43
|
+
});
|
|
39
44
|
stopResizing(_tr)(state, dispatch);
|
|
40
45
|
}
|
|
41
46
|
return true;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ACTION_SUBJECT, EVENT_TYPE, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
|
|
1
|
+
import { ACTION_SUBJECT, EVENT_TYPE, TABLE_ACTION, TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import { getParentNodeWidth } from '@atlaskit/editor-common/node-width';
|
|
3
3
|
import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
4
4
|
import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
|
|
@@ -8,6 +8,7 @@ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
|
8
8
|
import { updateResizeHandleDecorations } from '../../commands/misc';
|
|
9
9
|
import { updateColumnWidths } from '../../transforms';
|
|
10
10
|
import { getSelectedColumnIndexes, updateResizeHandles } from '../../utils';
|
|
11
|
+
import { META_KEYS } from '../table-analytics';
|
|
11
12
|
import { evenColumns, setDragging, stopResizing } from './commands';
|
|
12
13
|
import { getPluginState } from './plugin-factory';
|
|
13
14
|
import { currentColWidth, getLayoutSize, getResizeState, pointsAtCell, resizeColumn, updateControls } from './utils';
|
|
@@ -20,6 +21,13 @@ export var handleMouseDown = function handleMouseDown(view, event, localResizeHa
|
|
|
20
21
|
return false;
|
|
21
22
|
}
|
|
22
23
|
event.preventDefault();
|
|
24
|
+
if (getBooleanFF('platform.editor.table.overflow-state-analytics')) {
|
|
25
|
+
var tr = view.state.tr;
|
|
26
|
+
tr.setMeta(META_KEYS.OVERFLOW_TRIGGER, {
|
|
27
|
+
name: TABLE_OVERFLOW_CHANGE_TRIGGER.RESIZED_COLUMN
|
|
28
|
+
});
|
|
29
|
+
dispatch(tr);
|
|
30
|
+
}
|
|
23
31
|
var mouseDownTime = event.timeStamp;
|
|
24
32
|
var cell = state.doc.nodeAt(localResizeHandlePos);
|
|
25
33
|
var $cell = state.doc.resolve(localResizeHandlePos);
|