@atlaskit/editor-plugin-table 1.7.3 → 2.0.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 +8 -0
- package/dist/cjs/plugins/table/index.js +11 -16
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/plugins/table/index.js +11 -16
- package/dist/es2019/version.json +1 -1
- package/dist/esm/plugins/table/index.js +11 -16
- package/dist/esm/version.json +1 -1
- package/dist/types/plugins/table/index.d.ts +0 -2
- package/dist/types-ts4.5/plugins/table/index.d.ts +0 -2
- package/package.json +4 -4
- package/report.api.md +0 -3
- package/src/__tests__/unit/analytics.ts +20 -10
- package/src/__tests__/unit/keymap.ts +14 -21
- package/src/__tests__/unit/pm-plugins/table-resizing/event-handlers.ts +12 -7
- package/src/plugins/table/index.tsx +12 -25
- package/tmp/api-report-tmp.d.ts +0 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 2.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [`bdb840c6eaa`](https://bitbucket.org/atlassian/atlassian-frontend/commits/bdb840c6eaa) - Remove EditorAnalyticsAPI parameter from tables plugin as it now gets this from `editor-plugin-analytics`. This parameter is unused and the action is just to remove it.
|
|
8
|
+
|
|
9
|
+
Fix issue where internal analytics plugin was not being called correctly.
|
|
10
|
+
|
|
3
11
|
## 1.7.3
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -40,6 +40,7 @@ var defaultGetEditorFeatureFlags = function defaultGetEditorFeatureFlags() {
|
|
|
40
40
|
return {};
|
|
41
41
|
};
|
|
42
42
|
var tablesPlugin = function tablesPlugin(options, api) {
|
|
43
|
+
var _api$dependencies$ana;
|
|
43
44
|
var editorViewRef = {
|
|
44
45
|
current: null
|
|
45
46
|
};
|
|
@@ -50,6 +51,7 @@ var tablesPlugin = function tablesPlugin(options, api) {
|
|
|
50
51
|
};
|
|
51
52
|
return (_api$dependencies$wid = api === null || api === void 0 ? void 0 : api.dependencies.width.sharedState.currentState()) !== null && _api$dependencies$wid !== void 0 ? _api$dependencies$wid : defaultState;
|
|
52
53
|
};
|
|
54
|
+
var editorAnalyticsAPI = api === null || api === void 0 ? void 0 : (_api$dependencies$ana = api.dependencies.analytics) === null || _api$dependencies$ana === void 0 ? void 0 : _api$dependencies$ana.actions;
|
|
53
55
|
return {
|
|
54
56
|
name: 'table',
|
|
55
57
|
actions: {
|
|
@@ -91,19 +93,15 @@ var tablesPlugin = function tablesPlugin(options, api) {
|
|
|
91
93
|
var plugins = [{
|
|
92
94
|
name: 'table',
|
|
93
95
|
plugin: function plugin(_ref) {
|
|
94
|
-
var _api$dependencies$ana;
|
|
95
96
|
var dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent,
|
|
96
97
|
dispatch = _ref.dispatch,
|
|
97
98
|
portalProviderAPI = _ref.portalProviderAPI,
|
|
98
99
|
eventDispatcher = _ref.eventDispatcher;
|
|
99
|
-
var _ref2 = options || {
|
|
100
|
-
editorAnalyticsAPI: api === null || api === void 0 ? void 0 : (_api$dependencies$ana = api.dependencies.analytics) === null || _api$dependencies$ana === void 0 ? void 0 : _api$dependencies$ana.actions
|
|
101
|
-
},
|
|
100
|
+
var _ref2 = options || {},
|
|
102
101
|
fullWidthEnabled = _ref2.fullWidthEnabled,
|
|
103
102
|
wasFullWidthEnabled = _ref2.wasFullWidthEnabled,
|
|
104
103
|
breakoutEnabled = _ref2.breakoutEnabled,
|
|
105
104
|
tableOptions = _ref2.tableOptions,
|
|
106
|
-
editorAnalyticsAPI = _ref2.editorAnalyticsAPI,
|
|
107
105
|
getEditorFeatureFlags = _ref2.getEditorFeatureFlags;
|
|
108
106
|
return (0, _main.createPlugin)(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, (0, _createPluginConfig.pluginConfig)(tableOptions), defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, breakoutEnabled, fullWidthEnabled, wasFullWidthEnabled, editorAnalyticsAPI);
|
|
109
107
|
}
|
|
@@ -114,7 +112,6 @@ var tablesPlugin = function tablesPlugin(options, api) {
|
|
|
114
112
|
var _ref4 = options || {},
|
|
115
113
|
fullWidthEnabled = _ref4.fullWidthEnabled,
|
|
116
114
|
tableOptions = _ref4.tableOptions,
|
|
117
|
-
editorAnalyticsAPI = _ref4.editorAnalyticsAPI,
|
|
118
115
|
getEditorFeatureFlags = _ref4.getEditorFeatureFlags;
|
|
119
116
|
var _pluginConfig = (0, _createPluginConfig.pluginConfig)(tableOptions),
|
|
120
117
|
allowColumnResizing = _pluginConfig.allowColumnResizing;
|
|
@@ -133,7 +130,7 @@ var tablesPlugin = function tablesPlugin(options, api) {
|
|
|
133
130
|
{
|
|
134
131
|
name: 'tableKeymap',
|
|
135
132
|
plugin: function plugin() {
|
|
136
|
-
return (0, _keymap.keymapPlugin)(defaultGetEditorContainerWidth,
|
|
133
|
+
return (0, _keymap.keymapPlugin)(defaultGetEditorContainerWidth, editorAnalyticsAPI);
|
|
137
134
|
}
|
|
138
135
|
}, {
|
|
139
136
|
name: 'tableSelectionKeymap',
|
|
@@ -145,11 +142,10 @@ var tablesPlugin = function tablesPlugin(options, api) {
|
|
|
145
142
|
plugin: function plugin() {
|
|
146
143
|
return (0, _pmPlugins.tableEditing)({
|
|
147
144
|
reportFixedTable: function reportFixedTable(_ref5) {
|
|
148
|
-
var _options$editorAnalyt;
|
|
149
145
|
var state = _ref5.state,
|
|
150
146
|
tr = _ref5.tr,
|
|
151
147
|
reason = _ref5.reason;
|
|
152
|
-
|
|
148
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
153
149
|
action: _analytics.TABLE_ACTION.FIXED,
|
|
154
150
|
actionSubject: _analytics.ACTION_SUBJECT.TABLE,
|
|
155
151
|
actionSubjectId: null,
|
|
@@ -256,7 +252,7 @@ var tablesPlugin = function tablesPlugin(options, api) {
|
|
|
256
252
|
layout: layout,
|
|
257
253
|
isResizing: !!resizingPluginState && !!resizingPluginState.dragging,
|
|
258
254
|
stickyHeader: stickyHeader,
|
|
259
|
-
editorAnalyticsAPI:
|
|
255
|
+
editorAnalyticsAPI: editorAnalyticsAPI
|
|
260
256
|
}) : null;
|
|
261
257
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, targetCellPosition && tableRef && !isDragging && options && options.allowContextualMenu && /*#__PURE__*/_react.default.createElement(_FloatingContextualButton.default, {
|
|
262
258
|
isNumberColumnEnabled: tableNode && tableNode.attrs.isNumberColumnEnabled,
|
|
@@ -283,7 +279,7 @@ var tablesPlugin = function tablesPlugin(options, api) {
|
|
|
283
279
|
scrollableElement: popupsScrollableElement,
|
|
284
280
|
hasStickyHeaders: stickyHeader && stickyHeader.sticky,
|
|
285
281
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
286
|
-
editorAnalyticsAPI:
|
|
282
|
+
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
287
283
|
getEditorContainerWidth: defaultGetEditorContainerWidth
|
|
288
284
|
}), /*#__PURE__*/_react.default.createElement(_FloatingContextualMenu.default, {
|
|
289
285
|
editorView: editorView,
|
|
@@ -292,7 +288,7 @@ var tablesPlugin = function tablesPlugin(options, api) {
|
|
|
292
288
|
targetCellPosition: targetCellPosition,
|
|
293
289
|
isOpen: Boolean(isContextualMenuOpen),
|
|
294
290
|
pluginConfig: pluginConfig,
|
|
295
|
-
editorAnalyticsAPI:
|
|
291
|
+
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
296
292
|
getEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
297
293
|
getEditorFeatureFlags: (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags
|
|
298
294
|
}), allowControls && /*#__PURE__*/_react.default.createElement(_FloatingDeleteButton.default, {
|
|
@@ -304,7 +300,7 @@ var tablesPlugin = function tablesPlugin(options, api) {
|
|
|
304
300
|
scrollableElement: popupsScrollableElement,
|
|
305
301
|
stickyHeaders: stickyHeader,
|
|
306
302
|
isNumberColumnEnabled: tableNode && tableNode.attrs.isNumberColumnEnabled,
|
|
307
|
-
editorAnalyticsAPI:
|
|
303
|
+
editorAnalyticsAPI: editorAnalyticsAPI
|
|
308
304
|
}), LayoutContent);
|
|
309
305
|
}
|
|
310
306
|
}));
|
|
@@ -323,11 +319,10 @@ var tablesPlugin = function tablesPlugin(options, api) {
|
|
|
323
319
|
return /*#__PURE__*/_react.default.createElement(_icons.IconTable, null);
|
|
324
320
|
},
|
|
325
321
|
action: function action(insert, state) {
|
|
326
|
-
var _options$editorAnalyt2;
|
|
327
322
|
var tr = insert((0, _utils2.createTable)({
|
|
328
323
|
schema: state.schema
|
|
329
324
|
}));
|
|
330
|
-
|
|
325
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
331
326
|
action: _analytics.ACTION.INSERTED,
|
|
332
327
|
actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
|
|
333
328
|
actionSubjectId: _analytics.ACTION_SUBJECT_ID.TABLE,
|
|
@@ -340,7 +335,7 @@ var tablesPlugin = function tablesPlugin(options, api) {
|
|
|
340
335
|
}
|
|
341
336
|
}];
|
|
342
337
|
},
|
|
343
|
-
floatingToolbar: (0, _toolbar.getToolbarConfig)(defaultGetEditorContainerWidth,
|
|
338
|
+
floatingToolbar: (0, _toolbar.getToolbarConfig)(defaultGetEditorContainerWidth, editorAnalyticsAPI, (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags, function () {
|
|
344
339
|
return editorViewRef.current;
|
|
345
340
|
})((0, _createPluginConfig.pluginConfig)(options === null || options === void 0 ? void 0 : options.tableOptions))
|
|
346
341
|
}
|
package/dist/cjs/version.json
CHANGED
|
@@ -31,6 +31,7 @@ import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
|
|
|
31
31
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
32
32
|
const defaultGetEditorFeatureFlags = () => ({});
|
|
33
33
|
const tablesPlugin = (options, api) => {
|
|
34
|
+
var _api$dependencies$ana;
|
|
34
35
|
const editorViewRef = {
|
|
35
36
|
current: null
|
|
36
37
|
};
|
|
@@ -41,6 +42,7 @@ const tablesPlugin = (options, api) => {
|
|
|
41
42
|
};
|
|
42
43
|
return (_api$dependencies$wid = api === null || api === void 0 ? void 0 : api.dependencies.width.sharedState.currentState()) !== null && _api$dependencies$wid !== void 0 ? _api$dependencies$wid : defaultState;
|
|
43
44
|
};
|
|
45
|
+
const editorAnalyticsAPI = api === null || api === void 0 ? void 0 : (_api$dependencies$ana = api.dependencies.analytics) === null || _api$dependencies$ana === void 0 ? void 0 : _api$dependencies$ana.actions;
|
|
44
46
|
return {
|
|
45
47
|
name: 'table',
|
|
46
48
|
actions: {
|
|
@@ -85,17 +87,13 @@ const tablesPlugin = (options, api) => {
|
|
|
85
87
|
portalProviderAPI,
|
|
86
88
|
eventDispatcher
|
|
87
89
|
}) => {
|
|
88
|
-
var _api$dependencies$ana;
|
|
89
90
|
const {
|
|
90
91
|
fullWidthEnabled,
|
|
91
92
|
wasFullWidthEnabled,
|
|
92
93
|
breakoutEnabled,
|
|
93
94
|
tableOptions,
|
|
94
|
-
editorAnalyticsAPI,
|
|
95
95
|
getEditorFeatureFlags
|
|
96
|
-
} = options || {
|
|
97
|
-
editorAnalyticsAPI: api === null || api === void 0 ? void 0 : (_api$dependencies$ana = api.dependencies.analytics) === null || _api$dependencies$ana === void 0 ? void 0 : _api$dependencies$ana.actions
|
|
98
|
-
};
|
|
96
|
+
} = options || {};
|
|
99
97
|
return createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig(tableOptions), defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, breakoutEnabled, fullWidthEnabled, wasFullWidthEnabled, editorAnalyticsAPI);
|
|
100
98
|
}
|
|
101
99
|
}, {
|
|
@@ -106,7 +104,6 @@ const tablesPlugin = (options, api) => {
|
|
|
106
104
|
const {
|
|
107
105
|
fullWidthEnabled,
|
|
108
106
|
tableOptions,
|
|
109
|
-
editorAnalyticsAPI,
|
|
110
107
|
getEditorFeatureFlags
|
|
111
108
|
} = options || {};
|
|
112
109
|
const {
|
|
@@ -124,7 +121,7 @@ const tablesPlugin = (options, api) => {
|
|
|
124
121
|
// plugin as it is currently swallowing backspace events inside tables
|
|
125
122
|
{
|
|
126
123
|
name: 'tableKeymap',
|
|
127
|
-
plugin: () => keymapPlugin(defaultGetEditorContainerWidth,
|
|
124
|
+
plugin: () => keymapPlugin(defaultGetEditorContainerWidth, editorAnalyticsAPI)
|
|
128
125
|
}, {
|
|
129
126
|
name: 'tableSelectionKeymap',
|
|
130
127
|
plugin: () => tableSelectionKeymapPlugin(options === null || options === void 0 ? void 0 : options.editorSelectionAPI)
|
|
@@ -136,8 +133,7 @@ const tablesPlugin = (options, api) => {
|
|
|
136
133
|
tr,
|
|
137
134
|
reason
|
|
138
135
|
}) => {
|
|
139
|
-
|
|
140
|
-
options === null || options === void 0 ? void 0 : (_options$editorAnalyt = options.editorAnalyticsAPI) === null || _options$editorAnalyt === void 0 ? void 0 : _options$editorAnalyt.attachAnalyticsEvent({
|
|
136
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
141
137
|
action: TABLE_ACTION.FIXED,
|
|
142
138
|
actionSubject: ACTION_SUBJECT.TABLE,
|
|
143
139
|
actionSubjectId: null,
|
|
@@ -245,7 +241,7 @@ const tablesPlugin = (options, api) => {
|
|
|
245
241
|
layout: layout,
|
|
246
242
|
isResizing: !!resizingPluginState && !!resizingPluginState.dragging,
|
|
247
243
|
stickyHeader: stickyHeader,
|
|
248
|
-
editorAnalyticsAPI:
|
|
244
|
+
editorAnalyticsAPI: editorAnalyticsAPI
|
|
249
245
|
}) : null;
|
|
250
246
|
return /*#__PURE__*/React.createElement(React.Fragment, null, targetCellPosition && tableRef && !isDragging && options && options.allowContextualMenu && /*#__PURE__*/React.createElement(FloatingContextualButton, {
|
|
251
247
|
isNumberColumnEnabled: tableNode && tableNode.attrs.isNumberColumnEnabled,
|
|
@@ -272,7 +268,7 @@ const tablesPlugin = (options, api) => {
|
|
|
272
268
|
scrollableElement: popupsScrollableElement,
|
|
273
269
|
hasStickyHeaders: stickyHeader && stickyHeader.sticky,
|
|
274
270
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
275
|
-
editorAnalyticsAPI:
|
|
271
|
+
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
276
272
|
getEditorContainerWidth: defaultGetEditorContainerWidth
|
|
277
273
|
}), /*#__PURE__*/React.createElement(FloatingContextualMenu, {
|
|
278
274
|
editorView: editorView,
|
|
@@ -281,7 +277,7 @@ const tablesPlugin = (options, api) => {
|
|
|
281
277
|
targetCellPosition: targetCellPosition,
|
|
282
278
|
isOpen: Boolean(isContextualMenuOpen),
|
|
283
279
|
pluginConfig: pluginConfig,
|
|
284
|
-
editorAnalyticsAPI:
|
|
280
|
+
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
285
281
|
getEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
286
282
|
getEditorFeatureFlags: (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags
|
|
287
283
|
}), allowControls && /*#__PURE__*/React.createElement(FloatingDeleteButton, {
|
|
@@ -293,7 +289,7 @@ const tablesPlugin = (options, api) => {
|
|
|
293
289
|
scrollableElement: popupsScrollableElement,
|
|
294
290
|
stickyHeaders: stickyHeader,
|
|
295
291
|
isNumberColumnEnabled: tableNode && tableNode.attrs.isNumberColumnEnabled,
|
|
296
|
-
editorAnalyticsAPI:
|
|
292
|
+
editorAnalyticsAPI: editorAnalyticsAPI
|
|
297
293
|
}), LayoutContent);
|
|
298
294
|
}
|
|
299
295
|
}));
|
|
@@ -310,11 +306,10 @@ const tablesPlugin = (options, api) => {
|
|
|
310
306
|
keyshortcut: tooltip(toggleTable),
|
|
311
307
|
icon: () => /*#__PURE__*/React.createElement(IconTable, null),
|
|
312
308
|
action(insert, state) {
|
|
313
|
-
var _options$editorAnalyt2;
|
|
314
309
|
const tr = insert(createTable({
|
|
315
310
|
schema: state.schema
|
|
316
311
|
}));
|
|
317
|
-
|
|
312
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
318
313
|
action: ACTION.INSERTED,
|
|
319
314
|
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
320
315
|
actionSubjectId: ACTION_SUBJECT_ID.TABLE,
|
|
@@ -326,7 +321,7 @@ const tablesPlugin = (options, api) => {
|
|
|
326
321
|
return tr;
|
|
327
322
|
}
|
|
328
323
|
}],
|
|
329
|
-
floatingToolbar: getToolbarConfig(defaultGetEditorContainerWidth,
|
|
324
|
+
floatingToolbar: getToolbarConfig(defaultGetEditorContainerWidth, editorAnalyticsAPI, (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags, () => editorViewRef.current)(pluginConfig(options === null || options === void 0 ? void 0 : options.tableOptions))
|
|
330
325
|
}
|
|
331
326
|
};
|
|
332
327
|
};
|
package/dist/es2019/version.json
CHANGED
|
@@ -33,6 +33,7 @@ var defaultGetEditorFeatureFlags = function defaultGetEditorFeatureFlags() {
|
|
|
33
33
|
return {};
|
|
34
34
|
};
|
|
35
35
|
var tablesPlugin = function tablesPlugin(options, api) {
|
|
36
|
+
var _api$dependencies$ana;
|
|
36
37
|
var editorViewRef = {
|
|
37
38
|
current: null
|
|
38
39
|
};
|
|
@@ -43,6 +44,7 @@ var tablesPlugin = function tablesPlugin(options, api) {
|
|
|
43
44
|
};
|
|
44
45
|
return (_api$dependencies$wid = api === null || api === void 0 ? void 0 : api.dependencies.width.sharedState.currentState()) !== null && _api$dependencies$wid !== void 0 ? _api$dependencies$wid : defaultState;
|
|
45
46
|
};
|
|
47
|
+
var editorAnalyticsAPI = api === null || api === void 0 ? void 0 : (_api$dependencies$ana = api.dependencies.analytics) === null || _api$dependencies$ana === void 0 ? void 0 : _api$dependencies$ana.actions;
|
|
46
48
|
return {
|
|
47
49
|
name: 'table',
|
|
48
50
|
actions: {
|
|
@@ -84,19 +86,15 @@ var tablesPlugin = function tablesPlugin(options, api) {
|
|
|
84
86
|
var plugins = [{
|
|
85
87
|
name: 'table',
|
|
86
88
|
plugin: function plugin(_ref) {
|
|
87
|
-
var _api$dependencies$ana;
|
|
88
89
|
var dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent,
|
|
89
90
|
dispatch = _ref.dispatch,
|
|
90
91
|
portalProviderAPI = _ref.portalProviderAPI,
|
|
91
92
|
eventDispatcher = _ref.eventDispatcher;
|
|
92
|
-
var _ref2 = options || {
|
|
93
|
-
editorAnalyticsAPI: api === null || api === void 0 ? void 0 : (_api$dependencies$ana = api.dependencies.analytics) === null || _api$dependencies$ana === void 0 ? void 0 : _api$dependencies$ana.actions
|
|
94
|
-
},
|
|
93
|
+
var _ref2 = options || {},
|
|
95
94
|
fullWidthEnabled = _ref2.fullWidthEnabled,
|
|
96
95
|
wasFullWidthEnabled = _ref2.wasFullWidthEnabled,
|
|
97
96
|
breakoutEnabled = _ref2.breakoutEnabled,
|
|
98
97
|
tableOptions = _ref2.tableOptions,
|
|
99
|
-
editorAnalyticsAPI = _ref2.editorAnalyticsAPI,
|
|
100
98
|
getEditorFeatureFlags = _ref2.getEditorFeatureFlags;
|
|
101
99
|
return createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig(tableOptions), defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, breakoutEnabled, fullWidthEnabled, wasFullWidthEnabled, editorAnalyticsAPI);
|
|
102
100
|
}
|
|
@@ -107,7 +105,6 @@ var tablesPlugin = function tablesPlugin(options, api) {
|
|
|
107
105
|
var _ref4 = options || {},
|
|
108
106
|
fullWidthEnabled = _ref4.fullWidthEnabled,
|
|
109
107
|
tableOptions = _ref4.tableOptions,
|
|
110
|
-
editorAnalyticsAPI = _ref4.editorAnalyticsAPI,
|
|
111
108
|
getEditorFeatureFlags = _ref4.getEditorFeatureFlags;
|
|
112
109
|
var _pluginConfig = pluginConfig(tableOptions),
|
|
113
110
|
allowColumnResizing = _pluginConfig.allowColumnResizing;
|
|
@@ -126,7 +123,7 @@ var tablesPlugin = function tablesPlugin(options, api) {
|
|
|
126
123
|
{
|
|
127
124
|
name: 'tableKeymap',
|
|
128
125
|
plugin: function plugin() {
|
|
129
|
-
return keymapPlugin(defaultGetEditorContainerWidth,
|
|
126
|
+
return keymapPlugin(defaultGetEditorContainerWidth, editorAnalyticsAPI);
|
|
130
127
|
}
|
|
131
128
|
}, {
|
|
132
129
|
name: 'tableSelectionKeymap',
|
|
@@ -138,11 +135,10 @@ var tablesPlugin = function tablesPlugin(options, api) {
|
|
|
138
135
|
plugin: function plugin() {
|
|
139
136
|
return tableEditing({
|
|
140
137
|
reportFixedTable: function reportFixedTable(_ref5) {
|
|
141
|
-
var _options$editorAnalyt;
|
|
142
138
|
var state = _ref5.state,
|
|
143
139
|
tr = _ref5.tr,
|
|
144
140
|
reason = _ref5.reason;
|
|
145
|
-
|
|
141
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
146
142
|
action: TABLE_ACTION.FIXED,
|
|
147
143
|
actionSubject: ACTION_SUBJECT.TABLE,
|
|
148
144
|
actionSubjectId: null,
|
|
@@ -249,7 +245,7 @@ var tablesPlugin = function tablesPlugin(options, api) {
|
|
|
249
245
|
layout: layout,
|
|
250
246
|
isResizing: !!resizingPluginState && !!resizingPluginState.dragging,
|
|
251
247
|
stickyHeader: stickyHeader,
|
|
252
|
-
editorAnalyticsAPI:
|
|
248
|
+
editorAnalyticsAPI: editorAnalyticsAPI
|
|
253
249
|
}) : null;
|
|
254
250
|
return /*#__PURE__*/React.createElement(React.Fragment, null, targetCellPosition && tableRef && !isDragging && options && options.allowContextualMenu && /*#__PURE__*/React.createElement(FloatingContextualButton, {
|
|
255
251
|
isNumberColumnEnabled: tableNode && tableNode.attrs.isNumberColumnEnabled,
|
|
@@ -276,7 +272,7 @@ var tablesPlugin = function tablesPlugin(options, api) {
|
|
|
276
272
|
scrollableElement: popupsScrollableElement,
|
|
277
273
|
hasStickyHeaders: stickyHeader && stickyHeader.sticky,
|
|
278
274
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
279
|
-
editorAnalyticsAPI:
|
|
275
|
+
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
280
276
|
getEditorContainerWidth: defaultGetEditorContainerWidth
|
|
281
277
|
}), /*#__PURE__*/React.createElement(FloatingContextualMenu, {
|
|
282
278
|
editorView: editorView,
|
|
@@ -285,7 +281,7 @@ var tablesPlugin = function tablesPlugin(options, api) {
|
|
|
285
281
|
targetCellPosition: targetCellPosition,
|
|
286
282
|
isOpen: Boolean(isContextualMenuOpen),
|
|
287
283
|
pluginConfig: pluginConfig,
|
|
288
|
-
editorAnalyticsAPI:
|
|
284
|
+
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
289
285
|
getEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
290
286
|
getEditorFeatureFlags: (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags
|
|
291
287
|
}), allowControls && /*#__PURE__*/React.createElement(FloatingDeleteButton, {
|
|
@@ -297,7 +293,7 @@ var tablesPlugin = function tablesPlugin(options, api) {
|
|
|
297
293
|
scrollableElement: popupsScrollableElement,
|
|
298
294
|
stickyHeaders: stickyHeader,
|
|
299
295
|
isNumberColumnEnabled: tableNode && tableNode.attrs.isNumberColumnEnabled,
|
|
300
|
-
editorAnalyticsAPI:
|
|
296
|
+
editorAnalyticsAPI: editorAnalyticsAPI
|
|
301
297
|
}), LayoutContent);
|
|
302
298
|
}
|
|
303
299
|
}));
|
|
@@ -316,11 +312,10 @@ var tablesPlugin = function tablesPlugin(options, api) {
|
|
|
316
312
|
return /*#__PURE__*/React.createElement(IconTable, null);
|
|
317
313
|
},
|
|
318
314
|
action: function action(insert, state) {
|
|
319
|
-
var _options$editorAnalyt2;
|
|
320
315
|
var tr = insert(createTable({
|
|
321
316
|
schema: state.schema
|
|
322
317
|
}));
|
|
323
|
-
|
|
318
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
324
319
|
action: ACTION.INSERTED,
|
|
325
320
|
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
326
321
|
actionSubjectId: ACTION_SUBJECT_ID.TABLE,
|
|
@@ -333,7 +328,7 @@ var tablesPlugin = function tablesPlugin(options, api) {
|
|
|
333
328
|
}
|
|
334
329
|
}];
|
|
335
330
|
},
|
|
336
|
-
floatingToolbar: getToolbarConfig(defaultGetEditorContainerWidth,
|
|
331
|
+
floatingToolbar: getToolbarConfig(defaultGetEditorContainerWidth, editorAnalyticsAPI, (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags, function () {
|
|
337
332
|
return editorViewRef.current;
|
|
338
333
|
})(pluginConfig(options === null || options === void 0 ? void 0 : options.tableOptions))
|
|
339
334
|
}
|
package/dist/esm/version.json
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { Command } from '@atlaskit/editor-common/types';
|
|
2
2
|
import { AnalyticsEventPayload } from '@atlaskit/editor-common/analytics';
|
|
3
|
-
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
4
3
|
import type { EditorSelectionAPI } from '@atlaskit/editor-common/selection';
|
|
5
4
|
import { PluginConfig } from './types';
|
|
6
5
|
import type { GetEditorFeatureFlags, NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
@@ -13,7 +12,6 @@ interface TablePluginOptions {
|
|
|
13
12
|
allowContextualMenu?: boolean;
|
|
14
13
|
fullWidthEnabled?: boolean;
|
|
15
14
|
wasFullWidthEnabled?: boolean;
|
|
16
|
-
editorAnalyticsAPI?: EditorAnalyticsAPI;
|
|
17
15
|
editorSelectionAPI?: EditorSelectionAPI;
|
|
18
16
|
getEditorFeatureFlags?: GetEditorFeatureFlags;
|
|
19
17
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { Command } from '@atlaskit/editor-common/types';
|
|
2
2
|
import { AnalyticsEventPayload } from '@atlaskit/editor-common/analytics';
|
|
3
|
-
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
4
3
|
import type { EditorSelectionAPI } from '@atlaskit/editor-common/selection';
|
|
5
4
|
import { PluginConfig } from './types';
|
|
6
5
|
import type { GetEditorFeatureFlags, NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
@@ -13,7 +12,6 @@ interface TablePluginOptions {
|
|
|
13
12
|
allowContextualMenu?: boolean;
|
|
14
13
|
fullWidthEnabled?: boolean;
|
|
15
14
|
wasFullWidthEnabled?: boolean;
|
|
16
|
-
editorAnalyticsAPI?: EditorAnalyticsAPI;
|
|
17
15
|
editorSelectionAPI?: EditorSelectionAPI;
|
|
18
16
|
getEditorFeatureFlags?: GetEditorFeatureFlags;
|
|
19
17
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"releaseModel": "continuous"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@atlaskit/adf-schema": "^26.
|
|
30
|
+
"@atlaskit/adf-schema": "^26.1.0",
|
|
31
31
|
"@atlaskit/editor-common": "^74.15.0",
|
|
32
32
|
"@atlaskit/editor-palette": "1.5.1",
|
|
33
33
|
"@atlaskit/editor-plugin-analytics": "^0.0.5",
|
|
@@ -62,12 +62,12 @@
|
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@af/editor-libra": "*",
|
|
64
64
|
"@atlaskit/analytics-next": "^9.1.0",
|
|
65
|
-
"@atlaskit/editor-core": "^185.
|
|
65
|
+
"@atlaskit/editor-core": "^185.9.0",
|
|
66
66
|
"@atlaskit/editor-plugin-decorations": "^0.1.0",
|
|
67
67
|
"@atlaskit/editor-plugin-feature-flags": "^0.1.0",
|
|
68
68
|
"@atlaskit/editor-plugin-grid": "^0.1.0",
|
|
69
69
|
"@atlaskit/editor-plugin-width": "^0.1.0",
|
|
70
|
-
"@atlaskit/editor-test-helpers": "^18.
|
|
70
|
+
"@atlaskit/editor-test-helpers": "^18.9.0",
|
|
71
71
|
"@atlaskit/media-integration-test-helpers": "^3.0.0",
|
|
72
72
|
"@atlaskit/visual-regression": "*",
|
|
73
73
|
"@atlaskit/webdriver-runner": "*",
|
package/report.api.md
CHANGED
|
@@ -19,7 +19,6 @@ import { AnalyticsEventPayload } from '@atlaskit/editor-common/analytics';
|
|
|
19
19
|
import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
20
20
|
import type { Command } from '@atlaskit/editor-common/types';
|
|
21
21
|
import type { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
|
|
22
|
-
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
23
22
|
import type { EditorSelectionAPI } from '@atlaskit/editor-common/selection';
|
|
24
23
|
import type { GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
|
|
25
24
|
import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
@@ -87,8 +86,6 @@ interface TablePluginOptions {
|
|
|
87
86
|
// (undocumented)
|
|
88
87
|
breakoutEnabled?: boolean;
|
|
89
88
|
// (undocumented)
|
|
90
|
-
editorAnalyticsAPI?: EditorAnalyticsAPI;
|
|
91
|
-
// (undocumented)
|
|
92
89
|
editorSelectionAPI?: EditorSelectionAPI;
|
|
93
90
|
// (undocumented)
|
|
94
91
|
fullWidthEnabled?: boolean;
|
|
@@ -44,9 +44,9 @@ import tablePlugin from '../../plugins/table-plugin';
|
|
|
44
44
|
import typeAheadPlugin from '@atlaskit/editor-core/src/plugins/type-ahead';
|
|
45
45
|
import quickInsertPlugin from '@atlaskit/editor-core/src/plugins/quick-insert';
|
|
46
46
|
import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
|
|
47
|
-
import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
48
47
|
import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
|
|
49
48
|
import { widthPlugin } from '@atlaskit/editor-plugin-width';
|
|
49
|
+
import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
50
50
|
|
|
51
51
|
const defaultTableDoc = doc(
|
|
52
52
|
table()(
|
|
@@ -59,6 +59,16 @@ const defaultTableDoc = doc(
|
|
|
59
59
|
const secondRow: Rect = { left: 0, top: 1, bottom: 2, right: 3 };
|
|
60
60
|
const secondColumn: Rect = { left: 1, top: 0, bottom: 3, right: 2 };
|
|
61
61
|
|
|
62
|
+
// We don't need to test if the analytics implementation works (tested elsewhere)
|
|
63
|
+
// We just want to know if the action is called.
|
|
64
|
+
const mockAttachPayload = jest.fn();
|
|
65
|
+
const analyticsPluginFake = () => ({
|
|
66
|
+
name: 'analytics',
|
|
67
|
+
actions: {
|
|
68
|
+
attachAnalyticsEvent: mockAttachPayload.mockImplementation(() => () => {}),
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
|
|
62
72
|
describe('Table analytic events', () => {
|
|
63
73
|
let editorAnalyticsAPIFake: EditorAnalyticsAPI;
|
|
64
74
|
const analyticFireMock = jest.fn().mockReturnValue(jest.fn());
|
|
@@ -83,15 +93,15 @@ describe('Table analytic events', () => {
|
|
|
83
93
|
doc,
|
|
84
94
|
preset: new Preset<LightEditorPlugin>()
|
|
85
95
|
.add([featureFlagsPlugin, {}])
|
|
86
|
-
.add([
|
|
96
|
+
.add([
|
|
97
|
+
analyticsPluginFake as unknown as typeof analyticsPlugin,
|
|
98
|
+
{ createAnalyticsEvent: jest.fn() },
|
|
99
|
+
])
|
|
87
100
|
.add(typeAheadPlugin)
|
|
88
101
|
.add(contentInsertionPlugin)
|
|
89
102
|
.add(quickInsertPlugin)
|
|
90
103
|
.add(widthPlugin)
|
|
91
|
-
.add([
|
|
92
|
-
tablePlugin,
|
|
93
|
-
{ tableOptions, editorAnalyticsAPI: editorAnalyticsAPIFake },
|
|
94
|
-
]),
|
|
104
|
+
.add([tablePlugin, { tableOptions }]),
|
|
95
105
|
pluginKey,
|
|
96
106
|
});
|
|
97
107
|
|
|
@@ -105,7 +115,7 @@ describe('Table analytic events', () => {
|
|
|
105
115
|
});
|
|
106
116
|
|
|
107
117
|
it('should fire v3 analytics', () => {
|
|
108
|
-
expect(
|
|
118
|
+
expect(mockAttachPayload).toBeCalledWith({
|
|
109
119
|
action: 'inserted',
|
|
110
120
|
actionSubject: 'document',
|
|
111
121
|
actionSubjectId: 'table',
|
|
@@ -218,7 +228,7 @@ describe('Table analytic events', () => {
|
|
|
218
228
|
});
|
|
219
229
|
|
|
220
230
|
it('should fire v3 analytics', () => {
|
|
221
|
-
expect(
|
|
231
|
+
expect(mockAttachPayload).toHaveBeenCalledWith({
|
|
222
232
|
action: 'cleared',
|
|
223
233
|
actionSubject: 'table',
|
|
224
234
|
actionSubjectId: null,
|
|
@@ -578,7 +588,7 @@ describe('Table analytic events', () => {
|
|
|
578
588
|
});
|
|
579
589
|
|
|
580
590
|
it('should fire v3 analytics', () => {
|
|
581
|
-
expect(
|
|
591
|
+
expect(mockAttachPayload).toHaveBeenCalledWith({
|
|
582
592
|
action: 'addedRow',
|
|
583
593
|
actionSubject: 'table',
|
|
584
594
|
actionSubjectId: null,
|
|
@@ -608,7 +618,7 @@ describe('Table analytic events', () => {
|
|
|
608
618
|
});
|
|
609
619
|
|
|
610
620
|
it('should fire v3 analytics', () => {
|
|
611
|
-
expect(
|
|
621
|
+
expect(mockAttachPayload).toHaveBeenCalledWith({
|
|
612
622
|
action: 'addedRow',
|
|
613
623
|
actionSubject: 'table',
|
|
614
624
|
actionSubjectId: null,
|
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
} from '@atlaskit/editor-tables/utils';
|
|
9
9
|
import { PluginKey } from 'prosemirror-state';
|
|
10
10
|
|
|
11
|
-
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
12
11
|
import {
|
|
13
12
|
createProsemirrorEditorFactory,
|
|
14
13
|
LightEditorPlugin,
|
|
@@ -29,10 +28,6 @@ import {
|
|
|
29
28
|
import { pmNodeBuilder } from '@atlaskit/editor-test-helpers/schema-element-builder';
|
|
30
29
|
import defaultSchema from '@atlaskit/editor-test-helpers/schema';
|
|
31
30
|
import sendKeyToPm from '@atlaskit/editor-test-helpers/send-key-to-pm';
|
|
32
|
-
import {
|
|
33
|
-
CreateUIAnalyticsEvent,
|
|
34
|
-
UIAnalyticsEvent,
|
|
35
|
-
} from '@atlaskit/analytics-next';
|
|
36
31
|
import { uuid } from '@atlaskit/adf-schema';
|
|
37
32
|
import { uuid as tablesUuid } from '@atlaskit/editor-tables';
|
|
38
33
|
|
|
@@ -42,8 +37,7 @@ import expandPlugin from '@atlaskit/editor-core/src/plugins/expand';
|
|
|
42
37
|
import tasksDecisionsPlugin from '@atlaskit/editor-core/src/plugins/tasks-and-decisions';
|
|
43
38
|
import selectionPlugin from '@atlaskit/editor-core/src/plugins/selection';
|
|
44
39
|
import mediaPlugin from '@atlaskit/editor-core/src/plugins/media';
|
|
45
|
-
import
|
|
46
|
-
import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
40
|
+
import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
47
41
|
import listPlugin from '@atlaskit/editor-core/src/plugins/list';
|
|
48
42
|
import blockTypePlugin from '@atlaskit/editor-core/src/plugins/block-type';
|
|
49
43
|
import codeBlockPlugin from '@atlaskit/editor-core/src/plugins/code-block';
|
|
@@ -67,6 +61,16 @@ import { decorationsPlugin } from '@atlaskit/editor-plugin-decorations';
|
|
|
67
61
|
|
|
68
62
|
const TABLE_LOCAL_ID = 'test-table-local-id';
|
|
69
63
|
|
|
64
|
+
// We don't need to test if the analytics implementation works (tested elsewhere)
|
|
65
|
+
// We just want to know if the action is called.
|
|
66
|
+
const mockAttachPayload = jest.fn();
|
|
67
|
+
const analyticsPluginFake = () => ({
|
|
68
|
+
name: 'analytics',
|
|
69
|
+
actions: {
|
|
70
|
+
attachAnalyticsEvent: mockAttachPayload.mockImplementation(() => () => {}),
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
|
|
70
74
|
describe('table keymap', () => {
|
|
71
75
|
beforeAll(() => {
|
|
72
76
|
uuid.setStatic(TABLE_LOCAL_ID);
|
|
@@ -78,27 +82,16 @@ describe('table keymap', () => {
|
|
|
78
82
|
tablesUuid.setStatic(false);
|
|
79
83
|
});
|
|
80
84
|
|
|
81
|
-
let editorAnalyticsAPIFake: EditorAnalyticsAPI = {
|
|
82
|
-
attachAnalyticsEvent: jest.fn().mockReturnValue(jest.fn()),
|
|
83
|
-
};
|
|
84
|
-
const createAnalyticsEvent: CreateUIAnalyticsEvent = jest.fn(
|
|
85
|
-
() => ({ fire() {} } as UIAnalyticsEvent),
|
|
86
|
-
);
|
|
87
|
-
|
|
88
85
|
const createEditor = createProsemirrorEditorFactory();
|
|
89
86
|
const preset = new Preset<LightEditorPlugin>()
|
|
90
87
|
.add([featureFlagsPlugin, {}])
|
|
91
|
-
.add([analyticsPlugin, {
|
|
92
|
-
.add([deprecatedAnalyticsPlugin, { createAnalyticsEvent }])
|
|
88
|
+
.add([analyticsPluginFake as unknown as typeof analyticsPlugin, {}])
|
|
93
89
|
.add(contentInsertionPlugin)
|
|
94
90
|
.add(decorationsPlugin)
|
|
95
91
|
.add(widthPlugin)
|
|
96
92
|
.add(gridPlugin)
|
|
97
93
|
.add(selectionPlugin)
|
|
98
|
-
.add([
|
|
99
|
-
tablePlugin,
|
|
100
|
-
{ tableOptions: {}, editorAnalyticsAPI: editorAnalyticsAPIFake },
|
|
101
|
-
])
|
|
94
|
+
.add([tablePlugin, { tableOptions: {} }])
|
|
102
95
|
.add(expandPlugin)
|
|
103
96
|
.add(tasksDecisionsPlugin)
|
|
104
97
|
.add(panelPlugin)
|
|
@@ -604,7 +597,7 @@ describe('table keymap', () => {
|
|
|
604
597
|
});
|
|
605
598
|
|
|
606
599
|
it('should dispatch analytics event', () => {
|
|
607
|
-
expect(
|
|
600
|
+
expect(mockAttachPayload).toBeCalledWith({
|
|
608
601
|
action: 'inserted',
|
|
609
602
|
actionSubject: 'document',
|
|
610
603
|
actionSubjectId: 'table',
|
|
@@ -25,7 +25,6 @@ import { TextSelection, NodeSelection, EditorState } from 'prosemirror-state';
|
|
|
25
25
|
import { EditorView } from 'prosemirror-view';
|
|
26
26
|
import panelPlugin from '@atlaskit/editor-core/src/plugins/panel';
|
|
27
27
|
import { widthPlugin } from '@atlaskit/editor-plugin-width';
|
|
28
|
-
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
29
28
|
import {
|
|
30
29
|
akEditorFullPageMaxWidth,
|
|
31
30
|
akEditorDefaultLayoutWidth,
|
|
@@ -35,10 +34,17 @@ import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
|
|
|
35
34
|
import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
|
|
36
35
|
import { decorationsPlugin } from '@atlaskit/editor-plugin-decorations';
|
|
37
36
|
|
|
37
|
+
// We don't need to test if the analytics implementation works (tested elsewhere)
|
|
38
|
+
// We just want to know if the action is called.
|
|
39
|
+
const mockAttachPayload = jest.fn();
|
|
40
|
+
const analyticsPluginFake = () => ({
|
|
41
|
+
name: 'analytics',
|
|
42
|
+
actions: {
|
|
43
|
+
attachAnalyticsEvent: mockAttachPayload.mockImplementation(() => () => {}),
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
|
|
38
47
|
describe('table-resizing/event-handlers', () => {
|
|
39
|
-
const editorAnalyticsAPIFake: EditorAnalyticsAPI = {
|
|
40
|
-
attachAnalyticsEvent: jest.fn().mockReturnValue(() => jest.fn()),
|
|
41
|
-
};
|
|
42
48
|
let editor: any;
|
|
43
49
|
beforeEach(() => {
|
|
44
50
|
const createEditor = createProsemirrorEditorFactory();
|
|
@@ -48,7 +54,7 @@ describe('table-resizing/event-handlers', () => {
|
|
|
48
54
|
attachTo: document.body,
|
|
49
55
|
preset: new Preset<LightEditorPlugin>()
|
|
50
56
|
.add([featureFlagsPlugin, {}])
|
|
51
|
-
.add([analyticsPlugin, {}])
|
|
57
|
+
.add([analyticsPluginFake as unknown as typeof analyticsPlugin, {}])
|
|
52
58
|
.add(contentInsertionPlugin)
|
|
53
59
|
.add(decorationsPlugin)
|
|
54
60
|
.add(widthPlugin)
|
|
@@ -56,7 +62,6 @@ describe('table-resizing/event-handlers', () => {
|
|
|
56
62
|
tablePlugin,
|
|
57
63
|
{
|
|
58
64
|
tableOptions: { allowColumnResizing: true },
|
|
59
|
-
editorAnalyticsAPI: editorAnalyticsAPIFake,
|
|
60
65
|
},
|
|
61
66
|
])
|
|
62
67
|
.add(panelPlugin),
|
|
@@ -72,7 +77,7 @@ describe('table-resizing/event-handlers', () => {
|
|
|
72
77
|
|
|
73
78
|
resizeColumn(view, 12, 150, 250);
|
|
74
79
|
|
|
75
|
-
expect(
|
|
80
|
+
expect(mockAttachPayload).toHaveBeenCalledWith(
|
|
76
81
|
expect.objectContaining({
|
|
77
82
|
action: TABLE_ACTION.ATTEMPTED_TABLE_WIDTH_CHANGE,
|
|
78
83
|
actionSubject: ACTION_SUBJECT.TABLE,
|
|
@@ -32,7 +32,6 @@ import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/
|
|
|
32
32
|
|
|
33
33
|
import { IconTable } from '@atlaskit/editor-common/icons';
|
|
34
34
|
|
|
35
|
-
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
36
35
|
import type { EditorSelectionAPI } from '@atlaskit/editor-common/selection';
|
|
37
36
|
|
|
38
37
|
import { pluginConfig } from './create-plugin-config';
|
|
@@ -80,7 +79,6 @@ interface TablePluginOptions {
|
|
|
80
79
|
// TODO these two need to be rethought
|
|
81
80
|
fullWidthEnabled?: boolean;
|
|
82
81
|
wasFullWidthEnabled?: boolean;
|
|
83
|
-
editorAnalyticsAPI?: EditorAnalyticsAPI;
|
|
84
82
|
editorSelectionAPI?: EditorSelectionAPI;
|
|
85
83
|
getEditorFeatureFlags?: GetEditorFeatureFlags;
|
|
86
84
|
}
|
|
@@ -110,6 +108,7 @@ const tablesPlugin: NextEditorPlugin<
|
|
|
110
108
|
};
|
|
111
109
|
return api?.dependencies.width.sharedState.currentState() ?? defaultState;
|
|
112
110
|
};
|
|
111
|
+
const editorAnalyticsAPI = api?.dependencies.analytics?.actions;
|
|
113
112
|
|
|
114
113
|
return {
|
|
115
114
|
name: 'table',
|
|
@@ -165,13 +164,8 @@ const tablesPlugin: NextEditorPlugin<
|
|
|
165
164
|
wasFullWidthEnabled,
|
|
166
165
|
breakoutEnabled,
|
|
167
166
|
tableOptions,
|
|
168
|
-
editorAnalyticsAPI,
|
|
169
167
|
getEditorFeatureFlags,
|
|
170
|
-
} =
|
|
171
|
-
options ||
|
|
172
|
-
({
|
|
173
|
-
editorAnalyticsAPI: api?.dependencies.analytics?.actions,
|
|
174
|
-
} as TablePluginOptions);
|
|
168
|
+
} = options || ({} as TablePluginOptions);
|
|
175
169
|
return createPlugin(
|
|
176
170
|
dispatchAnalyticsEvent,
|
|
177
171
|
dispatch,
|
|
@@ -191,12 +185,8 @@ const tablesPlugin: NextEditorPlugin<
|
|
|
191
185
|
{
|
|
192
186
|
name: 'tablePMColResizing',
|
|
193
187
|
plugin: ({ dispatch }) => {
|
|
194
|
-
const {
|
|
195
|
-
|
|
196
|
-
tableOptions,
|
|
197
|
-
editorAnalyticsAPI,
|
|
198
|
-
getEditorFeatureFlags,
|
|
199
|
-
} = options || ({} as TablePluginOptions);
|
|
188
|
+
const { fullWidthEnabled, tableOptions, getEditorFeatureFlags } =
|
|
189
|
+
options || ({} as TablePluginOptions);
|
|
200
190
|
const { allowColumnResizing } = pluginConfig(tableOptions);
|
|
201
191
|
return allowColumnResizing
|
|
202
192
|
? createFlexiResizingPlugin(
|
|
@@ -217,10 +207,7 @@ const tablesPlugin: NextEditorPlugin<
|
|
|
217
207
|
{
|
|
218
208
|
name: 'tableKeymap',
|
|
219
209
|
plugin: () =>
|
|
220
|
-
keymapPlugin(
|
|
221
|
-
defaultGetEditorContainerWidth,
|
|
222
|
-
options?.editorAnalyticsAPI,
|
|
223
|
-
),
|
|
210
|
+
keymapPlugin(defaultGetEditorContainerWidth, editorAnalyticsAPI),
|
|
224
211
|
},
|
|
225
212
|
{
|
|
226
213
|
name: 'tableSelectionKeymap',
|
|
@@ -239,7 +226,7 @@ const tablesPlugin: NextEditorPlugin<
|
|
|
239
226
|
tr: Transaction;
|
|
240
227
|
reason: string;
|
|
241
228
|
}) => {
|
|
242
|
-
|
|
229
|
+
editorAnalyticsAPI?.attachAnalyticsEvent({
|
|
243
230
|
action: TABLE_ACTION.FIXED,
|
|
244
231
|
actionSubject: ACTION_SUBJECT.TABLE,
|
|
245
232
|
actionSubjectId: null,
|
|
@@ -374,7 +361,7 @@ const tablesPlugin: NextEditorPlugin<
|
|
|
374
361
|
!!resizingPluginState && !!resizingPluginState.dragging
|
|
375
362
|
}
|
|
376
363
|
stickyHeader={stickyHeader}
|
|
377
|
-
editorAnalyticsAPI={
|
|
364
|
+
editorAnalyticsAPI={editorAnalyticsAPI}
|
|
378
365
|
/>
|
|
379
366
|
) : null;
|
|
380
367
|
|
|
@@ -415,7 +402,7 @@ const tablesPlugin: NextEditorPlugin<
|
|
|
415
402
|
scrollableElement={popupsScrollableElement}
|
|
416
403
|
hasStickyHeaders={stickyHeader && stickyHeader.sticky}
|
|
417
404
|
dispatchAnalyticsEvent={dispatchAnalyticsEvent}
|
|
418
|
-
editorAnalyticsAPI={
|
|
405
|
+
editorAnalyticsAPI={editorAnalyticsAPI}
|
|
419
406
|
getEditorContainerWidth={defaultGetEditorContainerWidth}
|
|
420
407
|
/>
|
|
421
408
|
)}
|
|
@@ -426,7 +413,7 @@ const tablesPlugin: NextEditorPlugin<
|
|
|
426
413
|
targetCellPosition={targetCellPosition}
|
|
427
414
|
isOpen={Boolean(isContextualMenuOpen)}
|
|
428
415
|
pluginConfig={pluginConfig}
|
|
429
|
-
editorAnalyticsAPI={
|
|
416
|
+
editorAnalyticsAPI={editorAnalyticsAPI}
|
|
430
417
|
getEditorContainerWidth={defaultGetEditorContainerWidth}
|
|
431
418
|
getEditorFeatureFlags={
|
|
432
419
|
options?.getEditorFeatureFlags ||
|
|
@@ -445,7 +432,7 @@ const tablesPlugin: NextEditorPlugin<
|
|
|
445
432
|
isNumberColumnEnabled={
|
|
446
433
|
tableNode && tableNode.attrs.isNumberColumnEnabled
|
|
447
434
|
}
|
|
448
|
-
editorAnalyticsAPI={
|
|
435
|
+
editorAnalyticsAPI={editorAnalyticsAPI}
|
|
449
436
|
/>
|
|
450
437
|
)}
|
|
451
438
|
{LayoutContent}
|
|
@@ -473,7 +460,7 @@ const tablesPlugin: NextEditorPlugin<
|
|
|
473
460
|
schema: state.schema,
|
|
474
461
|
}),
|
|
475
462
|
);
|
|
476
|
-
|
|
463
|
+
editorAnalyticsAPI?.attachAnalyticsEvent({
|
|
477
464
|
action: ACTION.INSERTED,
|
|
478
465
|
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
479
466
|
actionSubjectId: ACTION_SUBJECT_ID.TABLE,
|
|
@@ -486,7 +473,7 @@ const tablesPlugin: NextEditorPlugin<
|
|
|
486
473
|
],
|
|
487
474
|
floatingToolbar: getToolbarConfig(
|
|
488
475
|
defaultGetEditorContainerWidth,
|
|
489
|
-
|
|
476
|
+
editorAnalyticsAPI,
|
|
490
477
|
options?.getEditorFeatureFlags || defaultGetEditorFeatureFlags,
|
|
491
478
|
() => editorViewRef.current,
|
|
492
479
|
)(pluginConfig(options?.tableOptions)),
|
package/tmp/api-report-tmp.d.ts
CHANGED
|
@@ -8,7 +8,6 @@ import { AnalyticsEventPayload } from '@atlaskit/editor-common/analytics';
|
|
|
8
8
|
import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
9
9
|
import type { Command } from '@atlaskit/editor-common/types';
|
|
10
10
|
import type { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
|
|
11
|
-
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
12
11
|
import type { EditorSelectionAPI } from '@atlaskit/editor-common/selection';
|
|
13
12
|
import type { GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
|
|
14
13
|
import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
@@ -76,8 +75,6 @@ interface TablePluginOptions {
|
|
|
76
75
|
// (undocumented)
|
|
77
76
|
breakoutEnabled?: boolean;
|
|
78
77
|
// (undocumented)
|
|
79
|
-
editorAnalyticsAPI?: EditorAnalyticsAPI;
|
|
80
|
-
// (undocumented)
|
|
81
78
|
editorSelectionAPI?: EditorSelectionAPI;
|
|
82
79
|
// (undocumented)
|
|
83
80
|
fullWidthEnabled?: boolean;
|