@atlaskit/editor-plugin-tasks-and-decisions 10.1.15 → 10.1.16

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 CHANGED
@@ -1,5 +1,13 @@
1
1
  # @atlaskit/editor-plugin-tasks-and-decisions
2
2
 
3
+ ## 10.1.16
4
+
5
+ ### Patch Changes
6
+
7
+ - [`5decb780f02e0`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/5decb780f02e0) -
8
+ ED-29766: Add analytics instrumentation to task list toolbar button
9
+ - Updated dependencies
10
+
3
11
  ## 10.1.15
4
12
 
5
13
  ### Patch Changes
@@ -192,7 +192,7 @@ var backspaceFrom = function backspaceFrom(editorAnalyticsAPI) {
192
192
  var tr = splitListItemWith(state.tr, slice, $from, true);
193
193
  dispatch(tr);
194
194
  return true;
195
- } catch (error) {
195
+ } catch (_unused) {
196
196
  // If there's an error creating a paragraph, check if we are in a blockTaskItem
197
197
  // Block task item's can have non-text content that cannot be wrapped in a paragraph
198
198
  // So if the selection is in a blockTaskItem, just pass the content as is
@@ -231,7 +231,7 @@ var backspaceFrom = function backspaceFrom(editorAnalyticsAPI) {
231
231
  var _tr2 = splitListItemWith(state.tr, _slice, $from, true);
232
232
  dispatch(_tr2);
233
233
  return true;
234
- } catch (error) {
234
+ } catch (_unused2) {
235
235
  // If there's an error creating a paragraph, then just pass the content as is
236
236
  // Block task item's can have non-text content that cannot be wrapped in a paragraph
237
237
  if (blockTaskItem) {
@@ -333,7 +333,7 @@ var unindentTaskOrUnwrapTaskDecisionFollowing = function unindentTaskOrUnwrapTas
333
333
  var _tr4 = splitListItemWith(state.tr, slice, $next, false);
334
334
  dispatch(_tr4);
335
335
  return true;
336
- } catch (error) {
336
+ } catch (_unused3) {
337
337
  // If there's an error creating a paragraph, check if we are in a blockTaskItem
338
338
  // Block task item's can have non-text content that cannot be wrapped in a paragraph
339
339
  // So if the selection is in a blockTaskItem, just pass the content as is
@@ -697,7 +697,7 @@ var cmdOptEnter = (0, _utils.filterCommand)(_helpers.isInsideTaskOrDecisionItem,
697
697
  return true;
698
698
  });
699
699
  function keymapPlugin(_schema, api, allowNestedTasks, consumeTabs) {
700
- var _api$analytics3, _api$analytics4;
700
+ var _api$analytics4, _api$analytics5;
701
701
  var getContextIdentifier = function getContextIdentifier() {
702
702
  var _api$contextIdentifie;
703
703
  return api === null || api === void 0 || (_api$contextIdentifie = api.contextIdentifier) === null || _api$contextIdentifie === void 0 || (_api$contextIdentifie = _api$contextIdentifie.sharedState.currentState()) === null || _api$contextIdentifie === void 0 ? void 0 : _api$contextIdentifie.contextIdentifierProvider;
@@ -725,7 +725,8 @@ function keymapPlugin(_schema, api, allowNestedTasks, consumeTabs) {
725
725
  return false;
726
726
  }
727
727
  if (dispatch) {
728
- var command = (0, _toggleTasklistCommands.toggleTaskList)();
728
+ var _api$analytics3;
729
+ var command = (0, _toggleTasklistCommands.toggleTaskList)(api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions)();
729
730
  var tr = command({
730
731
  tr: state.tr
731
732
  });
@@ -737,10 +738,10 @@ function keymapPlugin(_schema, api, allowNestedTasks, consumeTabs) {
737
738
  return false;
738
739
  };
739
740
  var keymaps = _objectSpread((0, _defineProperty2.default)((0, _defineProperty2.default)({
740
- Backspace: backspace(api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions),
741
+ Backspace: backspace(api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions),
741
742
  Delete: deleteForwards,
742
743
  'Ctrl-d': deleteForwards,
743
- Enter: enter(api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions, getContextIdentifier)
744
+ Enter: enter(api === null || api === void 0 || (_api$analytics5 = api.analytics) === null || _api$analytics5 === void 0 ? void 0 : _api$analytics5.actions, getContextIdentifier)
744
745
  }, _keymaps.toggleTaskItemCheckbox.common, cmdOptEnter), _keymaps.toggleTaskList.common, toggleTaskListShortcut), allowNestedTasks ? indentHandlers : defaultHandlers);
745
746
  return (0, _keymap.keymap)(keymaps);
746
747
  }
@@ -1,70 +1,158 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.toggleTaskList = void 0;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
7
9
  var _adfSchema = require("@atlaskit/adf-schema");
10
+ var _analytics = require("@atlaskit/editor-common/analytics");
11
+ var _lists = require("@atlaskit/editor-common/lists");
8
12
  var _transforms = require("@atlaskit/editor-common/transforms");
9
13
  var _state = require("@atlaskit/editor-prosemirror/state");
10
14
  var _utils = require("@atlaskit/editor-prosemirror/utils");
11
- var toggleTaskList = exports.toggleTaskList = function toggleTaskList() {
12
- var targetType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'paragraph';
13
- return function (_ref) {
14
- var tr = _ref.tr;
15
- var nodes = tr.doc.type.schema.nodes;
16
- var selection = tr.selection;
15
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
16
+ 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; }
17
+ 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) { (0, _defineProperty2.default)(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; }
18
+ var toggleTaskList = exports.toggleTaskList = function toggleTaskList(editorAnalyticsAPI) {
19
+ return function () {
20
+ var targetType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'paragraph';
21
+ return function (_ref) {
22
+ var tr = _ref.tr;
23
+ var inputMethod = _analytics.INPUT_METHOD.TOOLBAR;
24
+ var nodes = tr.doc.type.schema.nodes;
25
+ var selection = tr.selection;
17
26
 
18
- // Handle empty selection: insert a new task item
19
- var $from = selection.$from;
20
- var isEmpty = $from.parent.content.size === 0;
21
- if (isEmpty && nodes.taskList && nodes.taskItem) {
22
- // Create an empty task list with one empty task item
23
- var listLocalId = _adfSchema.uuid.generate();
24
- var itemLocalId = _adfSchema.uuid.generate();
25
- var emptyList = nodes.taskList.create({
26
- localId: listLocalId
27
- }, [nodes.taskItem.create({
28
- localId: itemLocalId
29
- })]);
27
+ // Handle empty selection: insert a new task item
28
+ var $from = selection.$from;
29
+ var isEmpty = $from.parent.content.size === 0;
30
+ if (isEmpty && nodes.taskList && nodes.taskItem) {
31
+ // Create an empty task list with one empty task item
32
+ var listLocalId = _adfSchema.uuid.generate();
33
+ var itemLocalId = _adfSchema.uuid.generate();
34
+ var emptyList = nodes.taskList.create({
35
+ localId: listLocalId
36
+ }, [nodes.taskItem.create({
37
+ localId: itemLocalId
38
+ })]);
30
39
 
31
- // Insert the empty list at the current selection
32
- var insertTr = (0, _utils.safeInsert)(emptyList)(tr);
33
- if (insertTr !== tr) {
34
- // Set cursor inside the new task item
35
- var insertPos = insertTr.selection.$from.pos;
36
- return insertTr.setSelection(_state.TextSelection.near(insertTr.doc.resolve(insertPos)));
37
- }
38
- }
39
- var _getFormattedNode = (0, _transforms.getFormattedNode)(tr),
40
- node = _getFormattedNode.node,
41
- pos = _getFormattedNode.pos;
42
- if (node !== null && pos !== null) {
43
- if ((0, _transforms.isBulletOrOrderedList)(node.type)) {
44
- var context = {
45
- sourceNode: node,
46
- sourcePos: pos,
47
- targetNodeType: nodes.taskList,
48
- tr: tr
49
- };
50
- return (0, _transforms.transformBetweenListTypes)(context);
51
- }
52
- if ((0, _transforms.isTaskList)(node.type)) {
53
- var _context = {
54
- sourceNode: node,
55
- sourcePos: pos,
56
- targetNodeType: nodes[targetType],
57
- tr: tr
58
- };
59
- return targetType === 'paragraph' ? (0, _transforms.transformTaskListToBlockNodes)(_context) : (0, _transforms.transformBetweenListTypes)(_context);
40
+ // Insert the empty list at the current selection
41
+ var insertTr = (0, _utils.safeInsert)(emptyList)(tr);
42
+ if (insertTr !== tr) {
43
+ if ((0, _platformFeatureFlags.fg)('platform_editor_toolbar_task_list_analytics')) {
44
+ // Fire INSERT analytics event when creating a new task list
45
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
46
+ action: _analytics.ACTION.INSERTED,
47
+ actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
48
+ actionSubjectId: _analytics.ACTION_SUBJECT_ID.ACTION,
49
+ eventType: _analytics.EVENT_TYPE.TRACK,
50
+ attributes: {
51
+ inputMethod: inputMethod,
52
+ listLocalId: listLocalId,
53
+ listSize: 1,
54
+ localId: itemLocalId,
55
+ position: 0
56
+ }
57
+ })(insertTr);
58
+ }
59
+
60
+ // Set cursor inside the new task item
61
+ var insertPos = insertTr.selection.$from.pos;
62
+ return insertTr.setSelection(_state.TextSelection.near(insertTr.doc.resolve(insertPos)));
63
+ }
60
64
  }
61
- var _$from = selection.$from,
62
- $to = selection.$to;
63
- var range = _$from.blockRange($to);
64
- if (range) {
65
- return (0, _transforms.transformToTaskList)(tr, range, nodes.taskList, undefined, nodes);
65
+ var _getFormattedNode = (0, _transforms.getFormattedNode)(tr),
66
+ node = _getFormattedNode.node,
67
+ pos = _getFormattedNode.pos;
68
+ if (node !== null && pos !== null) {
69
+ if ((0, _transforms.isBulletOrOrderedList)(node.type)) {
70
+ var transformedFrom = node.type.name === 'bulletList' ? _analytics.ACTION_SUBJECT_ID.FORMAT_LIST_BULLET : _analytics.ACTION_SUBJECT_ID.FORMAT_LIST_NUMBER;
71
+ var context = {
72
+ sourceNode: node,
73
+ sourcePos: pos,
74
+ targetNodeType: nodes.taskList,
75
+ tr: tr
76
+ };
77
+ var resultTr = (0, _transforms.transformBetweenListTypes)(context);
78
+ if ((0, _platformFeatureFlags.fg)('platform_editor_toolbar_task_list_analytics')) {
79
+ // Fire CONVERTED analytics event when transforming a list to task list
80
+ if (resultTr && resultTr.docChanged) {
81
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
82
+ action: _analytics.ACTION.CONVERTED,
83
+ actionSubject: _analytics.ACTION_SUBJECT.LIST,
84
+ actionSubjectId: _analytics.ACTION_SUBJECT_ID.FORMAT_LIST_BULLET,
85
+ eventType: _analytics.EVENT_TYPE.TRACK,
86
+ attributes: _objectSpread(_objectSpread({}, (0, _lists.getCommonListAnalyticsAttributes)(tr)), {}, {
87
+ transformedFrom: transformedFrom,
88
+ inputMethod: inputMethod
89
+ })
90
+ })(resultTr);
91
+ }
92
+ }
93
+ return resultTr;
94
+ }
95
+ if ((0, _transforms.isTaskList)(node.type)) {
96
+ var _context = {
97
+ sourceNode: node,
98
+ sourcePos: pos,
99
+ targetNodeType: nodes[targetType],
100
+ tr: tr
101
+ };
102
+ var _resultTr = targetType === 'paragraph' ? (0, _transforms.transformTaskListToBlockNodes)(_context) : (0, _transforms.transformBetweenListTypes)(_context);
103
+
104
+ // Fire CONVERTED analytics event when transforming from task list
105
+ if (_resultTr && _resultTr.docChanged && targetType !== 'paragraph') {
106
+ var _transformedFrom = _analytics.ACTION_SUBJECT_ID.FORMAT_LIST_BULLET;
107
+ var targetListType = targetType === 'bulletList' ? _analytics.ACTION_SUBJECT_ID.FORMAT_LIST_BULLET : _analytics.ACTION_SUBJECT_ID.FORMAT_LIST_NUMBER;
108
+ if ((0, _platformFeatureFlags.fg)('platform_editor_toolbar_task_list_analytics')) {
109
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
110
+ action: _analytics.ACTION.CONVERTED,
111
+ actionSubject: _analytics.ACTION_SUBJECT.LIST,
112
+ actionSubjectId: targetListType,
113
+ eventType: _analytics.EVENT_TYPE.TRACK,
114
+ attributes: _objectSpread(_objectSpread({}, (0, _lists.getCommonListAnalyticsAttributes)(tr)), {}, {
115
+ transformedFrom: _transformedFrom,
116
+ inputMethod: inputMethod
117
+ })
118
+ })(_resultTr);
119
+ }
120
+ }
121
+ return _resultTr;
122
+ }
123
+ var _$from = selection.$from,
124
+ $to = selection.$to;
125
+ var range = _$from.blockRange($to);
126
+ if (range) {
127
+ var _resultTr2 = (0, _transforms.transformToTaskList)(tr, range, nodes.taskList, undefined, nodes);
128
+
129
+ // Fire INSERT analytics event when creating task list from selection
130
+ if (_resultTr2 && _resultTr2.docChanged) {
131
+ var _listNode$attrs$local, _listNode$attrs, _listNode$childCount, _listNode$firstChild$, _listNode$firstChild;
132
+ var listNode = _resultTr2.doc.nodeAt(range.start);
133
+ var listLocalIdFromNode = (_listNode$attrs$local = listNode === null || listNode === void 0 || (_listNode$attrs = listNode.attrs) === null || _listNode$attrs === void 0 ? void 0 : _listNode$attrs.localId) !== null && _listNode$attrs$local !== void 0 ? _listNode$attrs$local : _adfSchema.uuid.generate();
134
+ var listSizeFromNode = (_listNode$childCount = listNode === null || listNode === void 0 ? void 0 : listNode.childCount) !== null && _listNode$childCount !== void 0 ? _listNode$childCount : 0;
135
+ var localIdFromNode = (_listNode$firstChild$ = listNode === null || listNode === void 0 || (_listNode$firstChild = listNode.firstChild) === null || _listNode$firstChild === void 0 || (_listNode$firstChild = _listNode$firstChild.attrs) === null || _listNode$firstChild === void 0 ? void 0 : _listNode$firstChild.localId) !== null && _listNode$firstChild$ !== void 0 ? _listNode$firstChild$ : _adfSchema.uuid.generate();
136
+ if ((0, _platformFeatureFlags.fg)('platform_editor_toolbar_task_list_analytics')) {
137
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
138
+ action: _analytics.ACTION.INSERTED,
139
+ actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
140
+ actionSubjectId: _analytics.ACTION_SUBJECT_ID.ACTION,
141
+ eventType: _analytics.EVENT_TYPE.TRACK,
142
+ attributes: {
143
+ inputMethod: inputMethod,
144
+ listLocalId: listLocalIdFromNode,
145
+ listSize: listSizeFromNode,
146
+ localId: localIdFromNode,
147
+ position: 0
148
+ }
149
+ })(_resultTr2);
150
+ }
151
+ }
152
+ return _resultTr2;
153
+ }
66
154
  }
67
- }
68
- return tr;
155
+ return tr;
156
+ };
69
157
  };
70
158
  };
@@ -92,7 +92,7 @@ function ContentComponent(_ref2) {
92
92
  });
93
93
  }
94
94
  var tasksAndDecisionsPlugin = exports.tasksAndDecisionsPlugin = function tasksAndDecisionsPlugin(_ref3) {
95
- var _api$analytics, _api$analytics2, _api$analytics3;
95
+ var _api$analytics2, _api$analytics3, _api$analytics4;
96
96
  var _ref3$config = _ref3.config,
97
97
  _ref3$config2 = _ref3$config === void 0 ? {} : _ref3$config,
98
98
  allowNestedTasks = _ref3$config2.allowNestedTasks,
@@ -207,7 +207,10 @@ var tasksAndDecisionsPlugin = exports.tasksAndDecisionsPlugin = function tasksAn
207
207
  };
208
208
  },
209
209
  commands: {
210
- toggleTaskList: _toggleTasklistCommands.toggleTaskList,
210
+ toggleTaskList: function toggleTaskList(targetType) {
211
+ var _api$analytics;
212
+ return (0, _toggleTasklistCommands.toggleTaskList)(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)(targetType);
213
+ },
211
214
  updateEditPermission: function updateEditPermission(hasEditPermission) {
212
215
  return function (_ref5) {
213
216
  var tr = _ref5.tr;
@@ -226,9 +229,9 @@ var tasksAndDecisionsPlugin = exports.tasksAndDecisionsPlugin = function tasksAn
226
229
  }
227
230
  },
228
231
  actions: {
229
- insertTaskDecision: (0, _insertCommands.insertTaskDecisionCommand)(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, getIdentifierProvider),
230
- indentTaskList: (0, _keymaps.getIndentCommand)(api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions),
231
- outdentTaskList: (0, _keymaps.getUnindentCommand)(api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions),
232
+ insertTaskDecision: (0, _insertCommands.insertTaskDecisionCommand)(api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, getIdentifierProvider),
233
+ indentTaskList: (0, _keymaps.getIndentCommand)(api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions),
234
+ outdentTaskList: (0, _keymaps.getUnindentCommand)(api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions),
232
235
  setProvider: function () {
233
236
  var _setProvider2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(providerPromise) {
234
237
  var _api$core$actions$exe;
@@ -276,10 +279,10 @@ var tasksAndDecisionsPlugin = exports.tasksAndDecisionsPlugin = function tasksAn
276
279
  }, {
277
280
  name: 'tasksAndDecisionsInputRule',
278
281
  plugin: function plugin(_ref9) {
279
- var _api$analytics4;
282
+ var _api$analytics5;
280
283
  var schema = _ref9.schema,
281
284
  featureFlags = _ref9.featureFlags;
282
- return (0, _inputRules.default)(api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions, getIdentifierProvider)(schema, featureFlags);
285
+ return (0, _inputRules.default)(api === null || api === void 0 || (_api$analytics5 = api.analytics) === null || _api$analytics5 === void 0 ? void 0 : _api$analytics5.actions, getIdentifierProvider)(schema, featureFlags);
283
286
  }
284
287
  }, {
285
288
  name: 'tasksAndDecisionsKeyMap',
@@ -339,8 +342,8 @@ var tasksAndDecisionsPlugin = exports.tasksAndDecisionsPlugin = function tasksAn
339
342
  return /*#__PURE__*/React.createElement(_quickInsert.IconAction, null);
340
343
  },
341
344
  action: function action(insert, state) {
342
- var _api$analytics5;
343
- return (0, _insertCommands.insertTaskDecisionAction)(api === null || api === void 0 || (_api$analytics5 = api.analytics) === null || _api$analytics5 === void 0 ? void 0 : _api$analytics5.actions, getIdentifierProvider)(state, 'taskList', _analytics.INPUT_METHOD.QUICK_INSERT, addItem(insert, 'taskList', state.schema));
345
+ var _api$analytics6;
346
+ return (0, _insertCommands.insertTaskDecisionAction)(api === null || api === void 0 || (_api$analytics6 = api.analytics) === null || _api$analytics6 === void 0 ? void 0 : _api$analytics6.actions, getIdentifierProvider)(state, 'taskList', _analytics.INPUT_METHOD.QUICK_INSERT, addItem(insert, 'taskList', state.schema));
344
347
  }
345
348
  }, {
346
349
  id: 'decision',
@@ -352,8 +355,8 @@ var tasksAndDecisionsPlugin = exports.tasksAndDecisionsPlugin = function tasksAn
352
355
  return /*#__PURE__*/React.createElement(_quickInsert.IconDecision, null);
353
356
  },
354
357
  action: function action(insert, state) {
355
- var _api$analytics6;
356
- return (0, _insertCommands.insertTaskDecisionAction)(api === null || api === void 0 || (_api$analytics6 = api.analytics) === null || _api$analytics6 === void 0 ? void 0 : _api$analytics6.actions, getIdentifierProvider)(state, 'decisionList', _analytics.INPUT_METHOD.QUICK_INSERT, addItem(insert, 'decisionList', state.schema));
358
+ var _api$analytics7;
359
+ return (0, _insertCommands.insertTaskDecisionAction)(api === null || api === void 0 || (_api$analytics7 = api.analytics) === null || _api$analytics7 === void 0 ? void 0 : _api$analytics7.actions, getIdentifierProvider)(state, 'decisionList', _analytics.INPUT_METHOD.QUICK_INSERT, addItem(insert, 'decisionList', state.schema));
357
360
  }
358
361
  }];
359
362
  }
@@ -168,7 +168,7 @@ const backspaceFrom = editorAnalyticsAPI => $from => (state, dispatch) => {
168
168
  const tr = splitListItemWith(state.tr, slice, $from, true);
169
169
  dispatch(tr);
170
170
  return true;
171
- } catch (error) {
171
+ } catch {
172
172
  // If there's an error creating a paragraph, check if we are in a blockTaskItem
173
173
  // Block task item's can have non-text content that cannot be wrapped in a paragraph
174
174
  // So if the selection is in a blockTaskItem, just pass the content as is
@@ -207,7 +207,7 @@ const backspaceFrom = editorAnalyticsAPI => $from => (state, dispatch) => {
207
207
  const tr = splitListItemWith(state.tr, slice, $from, true);
208
208
  dispatch(tr);
209
209
  return true;
210
- } catch (error) {
210
+ } catch {
211
211
  // If there's an error creating a paragraph, then just pass the content as is
212
212
  // Block task item's can have non-text content that cannot be wrapped in a paragraph
213
213
  if (blockTaskItem) {
@@ -310,7 +310,7 @@ const unindentTaskOrUnwrapTaskDecisionFollowing = (state, dispatch) => {
310
310
  const tr = splitListItemWith(state.tr, slice, $next, false);
311
311
  dispatch(tr);
312
312
  return true;
313
- } catch (error) {
313
+ } catch {
314
314
  // If there's an error creating a paragraph, check if we are in a blockTaskItem
315
315
  // Block task item's can have non-text content that cannot be wrapped in a paragraph
316
316
  // So if the selection is in a blockTaskItem, just pass the content as is
@@ -692,7 +692,7 @@ const cmdOptEnter = filter(isInsideTaskOrDecisionItem, (state, dispatch) => {
692
692
  return true;
693
693
  });
694
694
  export function keymapPlugin(_schema, api, allowNestedTasks, consumeTabs) {
695
- var _api$analytics3, _api$analytics4;
695
+ var _api$analytics4, _api$analytics5;
696
696
  const getContextIdentifier = () => {
697
697
  var _api$contextIdentifie, _api$contextIdentifie2;
698
698
  return api === null || api === void 0 ? void 0 : (_api$contextIdentifie = api.contextIdentifier) === null || _api$contextIdentifie === void 0 ? void 0 : (_api$contextIdentifie2 = _api$contextIdentifie.sharedState.currentState()) === null || _api$contextIdentifie2 === void 0 ? void 0 : _api$contextIdentifie2.contextIdentifierProvider;
@@ -716,7 +716,8 @@ export function keymapPlugin(_schema, api, allowNestedTasks, consumeTabs) {
716
716
  return false;
717
717
  }
718
718
  if (dispatch) {
719
- const command = toggleTaskList();
719
+ var _api$analytics3;
720
+ const command = toggleTaskList(api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions)();
720
721
  const tr = command({
721
722
  tr: state.tr
722
723
  });
@@ -728,10 +729,10 @@ export function keymapPlugin(_schema, api, allowNestedTasks, consumeTabs) {
728
729
  return false;
729
730
  };
730
731
  const keymaps = {
731
- Backspace: backspace(api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions),
732
+ Backspace: backspace(api === null || api === void 0 ? void 0 : (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions),
732
733
  Delete: deleteForwards,
733
734
  'Ctrl-d': deleteForwards,
734
- Enter: enter(api === null || api === void 0 ? void 0 : (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions, getContextIdentifier),
735
+ Enter: enter(api === null || api === void 0 ? void 0 : (_api$analytics5 = api.analytics) === null || _api$analytics5 === void 0 ? void 0 : _api$analytics5.actions, getContextIdentifier),
735
736
  // Ignored via go/ees005
736
737
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
737
738
  [toggleTaskItemCheckbox.common]: cmdOptEnter,
@@ -1,71 +1,157 @@
1
1
  import { uuid } from '@atlaskit/adf-schema';
2
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
+ import { getCommonListAnalyticsAttributes } from '@atlaskit/editor-common/lists';
2
4
  import { transformBetweenListTypes, transformToTaskList, transformTaskListToBlockNodes, isBulletOrOrderedList, isTaskList, getFormattedNode } from '@atlaskit/editor-common/transforms';
3
5
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
4
6
  import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
5
- export const toggleTaskList = (targetType = 'paragraph') => ({
6
- tr
7
- }) => {
8
- const {
9
- nodes
10
- } = tr.doc.type.schema;
11
- const {
12
- selection
13
- } = tr;
7
+ import { fg } from '@atlaskit/platform-feature-flags';
8
+ export const toggleTaskList = editorAnalyticsAPI => (targetType = 'paragraph') => {
9
+ return ({
10
+ tr
11
+ }) => {
12
+ const inputMethod = INPUT_METHOD.TOOLBAR;
13
+ const {
14
+ nodes
15
+ } = tr.doc.type.schema;
16
+ const {
17
+ selection
18
+ } = tr;
14
19
 
15
- // Handle empty selection: insert a new task item
16
- const {
17
- $from
18
- } = selection;
19
- const isEmpty = $from.parent.content.size === 0;
20
- if (isEmpty && nodes.taskList && nodes.taskItem) {
21
- // Create an empty task list with one empty task item
22
- const listLocalId = uuid.generate();
23
- const itemLocalId = uuid.generate();
24
- const emptyList = nodes.taskList.create({
25
- localId: listLocalId
26
- }, [nodes.taskItem.create({
27
- localId: itemLocalId
28
- })]);
20
+ // Handle empty selection: insert a new task item
21
+ const {
22
+ $from
23
+ } = selection;
24
+ const isEmpty = $from.parent.content.size === 0;
25
+ if (isEmpty && nodes.taskList && nodes.taskItem) {
26
+ // Create an empty task list with one empty task item
27
+ const listLocalId = uuid.generate();
28
+ const itemLocalId = uuid.generate();
29
+ const emptyList = nodes.taskList.create({
30
+ localId: listLocalId
31
+ }, [nodes.taskItem.create({
32
+ localId: itemLocalId
33
+ })]);
29
34
 
30
- // Insert the empty list at the current selection
31
- const insertTr = safeInsert(emptyList)(tr);
32
- if (insertTr !== tr) {
33
- // Set cursor inside the new task item
34
- const insertPos = insertTr.selection.$from.pos;
35
- return insertTr.setSelection(TextSelection.near(insertTr.doc.resolve(insertPos)));
36
- }
37
- }
38
- const {
39
- node,
40
- pos
41
- } = getFormattedNode(tr);
42
- if (node !== null && pos !== null) {
43
- if (isBulletOrOrderedList(node.type)) {
44
- const context = {
45
- sourceNode: node,
46
- sourcePos: pos,
47
- targetNodeType: nodes.taskList,
48
- tr
49
- };
50
- return transformBetweenListTypes(context);
51
- }
52
- if (isTaskList(node.type)) {
53
- const context = {
54
- sourceNode: node,
55
- sourcePos: pos,
56
- targetNodeType: nodes[targetType],
57
- tr
58
- };
59
- return targetType === 'paragraph' ? transformTaskListToBlockNodes(context) : transformBetweenListTypes(context);
35
+ // Insert the empty list at the current selection
36
+ const insertTr = safeInsert(emptyList)(tr);
37
+ if (insertTr !== tr) {
38
+ if (fg('platform_editor_toolbar_task_list_analytics')) {
39
+ // Fire INSERT analytics event when creating a new task list
40
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
41
+ action: ACTION.INSERTED,
42
+ actionSubject: ACTION_SUBJECT.DOCUMENT,
43
+ actionSubjectId: ACTION_SUBJECT_ID.ACTION,
44
+ eventType: EVENT_TYPE.TRACK,
45
+ attributes: {
46
+ inputMethod,
47
+ listLocalId,
48
+ listSize: 1,
49
+ localId: itemLocalId,
50
+ position: 0
51
+ }
52
+ })(insertTr);
53
+ }
54
+
55
+ // Set cursor inside the new task item
56
+ const insertPos = insertTr.selection.$from.pos;
57
+ return insertTr.setSelection(TextSelection.near(insertTr.doc.resolve(insertPos)));
58
+ }
60
59
  }
61
60
  const {
62
- $from,
63
- $to
64
- } = selection;
65
- const range = $from.blockRange($to);
66
- if (range) {
67
- return transformToTaskList(tr, range, nodes.taskList, undefined, nodes);
61
+ node,
62
+ pos
63
+ } = getFormattedNode(tr);
64
+ if (node !== null && pos !== null) {
65
+ if (isBulletOrOrderedList(node.type)) {
66
+ const transformedFrom = node.type.name === 'bulletList' ? ACTION_SUBJECT_ID.FORMAT_LIST_BULLET : ACTION_SUBJECT_ID.FORMAT_LIST_NUMBER;
67
+ const context = {
68
+ sourceNode: node,
69
+ sourcePos: pos,
70
+ targetNodeType: nodes.taskList,
71
+ tr
72
+ };
73
+ const resultTr = transformBetweenListTypes(context);
74
+ if (fg('platform_editor_toolbar_task_list_analytics')) {
75
+ // Fire CONVERTED analytics event when transforming a list to task list
76
+ if (resultTr && resultTr.docChanged) {
77
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
78
+ action: ACTION.CONVERTED,
79
+ actionSubject: ACTION_SUBJECT.LIST,
80
+ actionSubjectId: ACTION_SUBJECT_ID.FORMAT_LIST_BULLET,
81
+ eventType: EVENT_TYPE.TRACK,
82
+ attributes: {
83
+ ...getCommonListAnalyticsAttributes(tr),
84
+ transformedFrom,
85
+ inputMethod
86
+ }
87
+ })(resultTr);
88
+ }
89
+ }
90
+ return resultTr;
91
+ }
92
+ if (isTaskList(node.type)) {
93
+ const context = {
94
+ sourceNode: node,
95
+ sourcePos: pos,
96
+ targetNodeType: nodes[targetType],
97
+ tr
98
+ };
99
+ const resultTr = targetType === 'paragraph' ? transformTaskListToBlockNodes(context) : transformBetweenListTypes(context);
100
+
101
+ // Fire CONVERTED analytics event when transforming from task list
102
+ if (resultTr && resultTr.docChanged && targetType !== 'paragraph') {
103
+ const transformedFrom = ACTION_SUBJECT_ID.FORMAT_LIST_BULLET;
104
+ const targetListType = targetType === 'bulletList' ? ACTION_SUBJECT_ID.FORMAT_LIST_BULLET : ACTION_SUBJECT_ID.FORMAT_LIST_NUMBER;
105
+ if (fg('platform_editor_toolbar_task_list_analytics')) {
106
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
107
+ action: ACTION.CONVERTED,
108
+ actionSubject: ACTION_SUBJECT.LIST,
109
+ actionSubjectId: targetListType,
110
+ eventType: EVENT_TYPE.TRACK,
111
+ attributes: {
112
+ ...getCommonListAnalyticsAttributes(tr),
113
+ transformedFrom,
114
+ inputMethod
115
+ }
116
+ })(resultTr);
117
+ }
118
+ }
119
+ return resultTr;
120
+ }
121
+ const {
122
+ $from,
123
+ $to
124
+ } = selection;
125
+ const range = $from.blockRange($to);
126
+ if (range) {
127
+ const resultTr = transformToTaskList(tr, range, nodes.taskList, undefined, nodes);
128
+
129
+ // Fire INSERT analytics event when creating task list from selection
130
+ if (resultTr && resultTr.docChanged) {
131
+ var _listNode$attrs$local, _listNode$attrs, _listNode$childCount, _listNode$firstChild$, _listNode$firstChild, _listNode$firstChild$2;
132
+ const listNode = resultTr.doc.nodeAt(range.start);
133
+ const listLocalIdFromNode = (_listNode$attrs$local = listNode === null || listNode === void 0 ? void 0 : (_listNode$attrs = listNode.attrs) === null || _listNode$attrs === void 0 ? void 0 : _listNode$attrs.localId) !== null && _listNode$attrs$local !== void 0 ? _listNode$attrs$local : uuid.generate();
134
+ const listSizeFromNode = (_listNode$childCount = listNode === null || listNode === void 0 ? void 0 : listNode.childCount) !== null && _listNode$childCount !== void 0 ? _listNode$childCount : 0;
135
+ const localIdFromNode = (_listNode$firstChild$ = listNode === null || listNode === void 0 ? void 0 : (_listNode$firstChild = listNode.firstChild) === null || _listNode$firstChild === void 0 ? void 0 : (_listNode$firstChild$2 = _listNode$firstChild.attrs) === null || _listNode$firstChild$2 === void 0 ? void 0 : _listNode$firstChild$2.localId) !== null && _listNode$firstChild$ !== void 0 ? _listNode$firstChild$ : uuid.generate();
136
+ if (fg('platform_editor_toolbar_task_list_analytics')) {
137
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
138
+ action: ACTION.INSERTED,
139
+ actionSubject: ACTION_SUBJECT.DOCUMENT,
140
+ actionSubjectId: ACTION_SUBJECT_ID.ACTION,
141
+ eventType: EVENT_TYPE.TRACK,
142
+ attributes: {
143
+ inputMethod,
144
+ listLocalId: listLocalIdFromNode,
145
+ listSize: listSizeFromNode,
146
+ localId: localIdFromNode,
147
+ position: 0
148
+ }
149
+ })(resultTr);
150
+ }
151
+ }
152
+ return resultTr;
153
+ }
68
154
  }
69
- }
70
- return tr;
155
+ return tr;
156
+ };
71
157
  };
@@ -95,7 +95,7 @@ export const tasksAndDecisionsPlugin = ({
95
95
  } = {},
96
96
  api
97
97
  }) => {
98
- var _api$analytics, _api$analytics2, _api$analytics3;
98
+ var _api$analytics2, _api$analytics3, _api$analytics4;
99
99
  const getIdentifierProvider = () => {
100
100
  var _api$contextIdentifie, _api$contextIdentifie2;
101
101
  return api === null || api === void 0 ? void 0 : (_api$contextIdentifie = api.contextIdentifier) === null || _api$contextIdentifie === void 0 ? void 0 : (_api$contextIdentifie2 = _api$contextIdentifie.sharedState.currentState()) === null || _api$contextIdentifie2 === void 0 ? void 0 : _api$contextIdentifie2.contextIdentifierProvider;
@@ -195,7 +195,10 @@ export const tasksAndDecisionsPlugin = ({
195
195
  };
196
196
  },
197
197
  commands: {
198
- toggleTaskList,
198
+ toggleTaskList: targetType => {
199
+ var _api$analytics;
200
+ return toggleTaskList(api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)(targetType);
201
+ },
199
202
  updateEditPermission: hasEditPermission => ({
200
203
  tr
201
204
  }) => tr.setMeta(taskPluginKey, {
@@ -208,9 +211,9 @@ export const tasksAndDecisionsPlugin = ({
208
211
  })
209
212
  },
210
213
  actions: {
211
- insertTaskDecision: insertTaskDecisionCommand(api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, getIdentifierProvider),
212
- indentTaskList: getIndentCommand(api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions),
213
- outdentTaskList: getUnindentCommand(api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions),
214
+ insertTaskDecision: insertTaskDecisionCommand(api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, getIdentifierProvider),
215
+ indentTaskList: getIndentCommand(api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions),
216
+ outdentTaskList: getUnindentCommand(api === null || api === void 0 ? void 0 : (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions),
214
217
  setProvider: async providerPromise => {
215
218
  var _api$core$actions$exe;
216
219
  const provider = await providerPromise;
@@ -241,8 +244,8 @@ export const tasksAndDecisionsPlugin = ({
241
244
  schema,
242
245
  featureFlags
243
246
  }) => {
244
- var _api$analytics4;
245
- return inputRulePlugin(api === null || api === void 0 ? void 0 : (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions, getIdentifierProvider)(schema, featureFlags);
247
+ var _api$analytics5;
248
+ return inputRulePlugin(api === null || api === void 0 ? void 0 : (_api$analytics5 = api.analytics) === null || _api$analytics5 === void 0 ? void 0 : _api$analytics5.actions, getIdentifierProvider)(schema, featureFlags);
246
249
  }
247
250
  }, {
248
251
  name: 'tasksAndDecisionsKeyMap',
@@ -301,8 +304,8 @@ export const tasksAndDecisionsPlugin = ({
301
304
  keyshortcut: '[]',
302
305
  icon: () => /*#__PURE__*/React.createElement(IconAction, null),
303
306
  action(insert, state) {
304
- var _api$analytics5;
305
- return insertTaskDecisionAction(api === null || api === void 0 ? void 0 : (_api$analytics5 = api.analytics) === null || _api$analytics5 === void 0 ? void 0 : _api$analytics5.actions, getIdentifierProvider)(state, 'taskList', INPUT_METHOD.QUICK_INSERT, addItem(insert, 'taskList', state.schema));
307
+ var _api$analytics6;
308
+ return insertTaskDecisionAction(api === null || api === void 0 ? void 0 : (_api$analytics6 = api.analytics) === null || _api$analytics6 === void 0 ? void 0 : _api$analytics6.actions, getIdentifierProvider)(state, 'taskList', INPUT_METHOD.QUICK_INSERT, addItem(insert, 'taskList', state.schema));
306
309
  }
307
310
  }, {
308
311
  id: 'decision',
@@ -312,8 +315,8 @@ export const tasksAndDecisionsPlugin = ({
312
315
  keyshortcut: '<>',
313
316
  icon: () => /*#__PURE__*/React.createElement(IconDecision, null),
314
317
  action(insert, state) {
315
- var _api$analytics6;
316
- return insertTaskDecisionAction(api === null || api === void 0 ? void 0 : (_api$analytics6 = api.analytics) === null || _api$analytics6 === void 0 ? void 0 : _api$analytics6.actions, getIdentifierProvider)(state, 'decisionList', INPUT_METHOD.QUICK_INSERT, addItem(insert, 'decisionList', state.schema));
318
+ var _api$analytics7;
319
+ return insertTaskDecisionAction(api === null || api === void 0 ? void 0 : (_api$analytics7 = api.analytics) === null || _api$analytics7 === void 0 ? void 0 : _api$analytics7.actions, getIdentifierProvider)(state, 'decisionList', INPUT_METHOD.QUICK_INSERT, addItem(insert, 'decisionList', state.schema));
317
320
  }
318
321
  }]
319
322
  }
@@ -184,7 +184,7 @@ var backspaceFrom = function backspaceFrom(editorAnalyticsAPI) {
184
184
  var tr = splitListItemWith(state.tr, slice, $from, true);
185
185
  dispatch(tr);
186
186
  return true;
187
- } catch (error) {
187
+ } catch (_unused) {
188
188
  // If there's an error creating a paragraph, check if we are in a blockTaskItem
189
189
  // Block task item's can have non-text content that cannot be wrapped in a paragraph
190
190
  // So if the selection is in a blockTaskItem, just pass the content as is
@@ -223,7 +223,7 @@ var backspaceFrom = function backspaceFrom(editorAnalyticsAPI) {
223
223
  var _tr2 = splitListItemWith(state.tr, _slice, $from, true);
224
224
  dispatch(_tr2);
225
225
  return true;
226
- } catch (error) {
226
+ } catch (_unused2) {
227
227
  // If there's an error creating a paragraph, then just pass the content as is
228
228
  // Block task item's can have non-text content that cannot be wrapped in a paragraph
229
229
  if (blockTaskItem) {
@@ -325,7 +325,7 @@ var unindentTaskOrUnwrapTaskDecisionFollowing = function unindentTaskOrUnwrapTas
325
325
  var _tr4 = splitListItemWith(state.tr, slice, $next, false);
326
326
  dispatch(_tr4);
327
327
  return true;
328
- } catch (error) {
328
+ } catch (_unused3) {
329
329
  // If there's an error creating a paragraph, check if we are in a blockTaskItem
330
330
  // Block task item's can have non-text content that cannot be wrapped in a paragraph
331
331
  // So if the selection is in a blockTaskItem, just pass the content as is
@@ -689,7 +689,7 @@ var cmdOptEnter = filter(isInsideTaskOrDecisionItem, function (state, dispatch)
689
689
  return true;
690
690
  });
691
691
  export function keymapPlugin(_schema, api, allowNestedTasks, consumeTabs) {
692
- var _api$analytics3, _api$analytics4;
692
+ var _api$analytics4, _api$analytics5;
693
693
  var getContextIdentifier = function getContextIdentifier() {
694
694
  var _api$contextIdentifie;
695
695
  return api === null || api === void 0 || (_api$contextIdentifie = api.contextIdentifier) === null || _api$contextIdentifie === void 0 || (_api$contextIdentifie = _api$contextIdentifie.sharedState.currentState()) === null || _api$contextIdentifie === void 0 ? void 0 : _api$contextIdentifie.contextIdentifierProvider;
@@ -717,7 +717,8 @@ export function keymapPlugin(_schema, api, allowNestedTasks, consumeTabs) {
717
717
  return false;
718
718
  }
719
719
  if (dispatch) {
720
- var command = toggleTaskList();
720
+ var _api$analytics3;
721
+ var command = toggleTaskList(api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions)();
721
722
  var tr = command({
722
723
  tr: state.tr
723
724
  });
@@ -729,10 +730,10 @@ export function keymapPlugin(_schema, api, allowNestedTasks, consumeTabs) {
729
730
  return false;
730
731
  };
731
732
  var keymaps = _objectSpread(_defineProperty(_defineProperty({
732
- Backspace: backspace(api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions),
733
+ Backspace: backspace(api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions),
733
734
  Delete: deleteForwards,
734
735
  'Ctrl-d': deleteForwards,
735
- Enter: enter(api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions, getContextIdentifier)
736
+ Enter: enter(api === null || api === void 0 || (_api$analytics5 = api.analytics) === null || _api$analytics5 === void 0 ? void 0 : _api$analytics5.actions, getContextIdentifier)
736
737
  }, toggleTaskItemCheckbox.common, cmdOptEnter), toggleTaskListKeymap.common, toggleTaskListShortcut), allowNestedTasks ? indentHandlers : defaultHandlers);
737
738
  return keymap(keymaps);
738
739
  }
@@ -1,64 +1,151 @@
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; }
1
4
  import { uuid } from '@atlaskit/adf-schema';
5
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
6
+ import { getCommonListAnalyticsAttributes } from '@atlaskit/editor-common/lists';
2
7
  import { transformBetweenListTypes, transformToTaskList, transformTaskListToBlockNodes, isBulletOrOrderedList, isTaskList, getFormattedNode } from '@atlaskit/editor-common/transforms';
3
8
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
4
9
  import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
5
- export var toggleTaskList = function toggleTaskList() {
6
- var targetType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'paragraph';
7
- return function (_ref) {
8
- var tr = _ref.tr;
9
- var nodes = tr.doc.type.schema.nodes;
10
- var selection = tr.selection;
10
+ import { fg } from '@atlaskit/platform-feature-flags';
11
+ export var toggleTaskList = function toggleTaskList(editorAnalyticsAPI) {
12
+ return function () {
13
+ var targetType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'paragraph';
14
+ return function (_ref) {
15
+ var tr = _ref.tr;
16
+ var inputMethod = INPUT_METHOD.TOOLBAR;
17
+ var nodes = tr.doc.type.schema.nodes;
18
+ var selection = tr.selection;
11
19
 
12
- // Handle empty selection: insert a new task item
13
- var $from = selection.$from;
14
- var isEmpty = $from.parent.content.size === 0;
15
- if (isEmpty && nodes.taskList && nodes.taskItem) {
16
- // Create an empty task list with one empty task item
17
- var listLocalId = uuid.generate();
18
- var itemLocalId = uuid.generate();
19
- var emptyList = nodes.taskList.create({
20
- localId: listLocalId
21
- }, [nodes.taskItem.create({
22
- localId: itemLocalId
23
- })]);
20
+ // Handle empty selection: insert a new task item
21
+ var $from = selection.$from;
22
+ var isEmpty = $from.parent.content.size === 0;
23
+ if (isEmpty && nodes.taskList && nodes.taskItem) {
24
+ // Create an empty task list with one empty task item
25
+ var listLocalId = uuid.generate();
26
+ var itemLocalId = uuid.generate();
27
+ var emptyList = nodes.taskList.create({
28
+ localId: listLocalId
29
+ }, [nodes.taskItem.create({
30
+ localId: itemLocalId
31
+ })]);
24
32
 
25
- // Insert the empty list at the current selection
26
- var insertTr = safeInsert(emptyList)(tr);
27
- if (insertTr !== tr) {
28
- // Set cursor inside the new task item
29
- var insertPos = insertTr.selection.$from.pos;
30
- return insertTr.setSelection(TextSelection.near(insertTr.doc.resolve(insertPos)));
31
- }
32
- }
33
- var _getFormattedNode = getFormattedNode(tr),
34
- node = _getFormattedNode.node,
35
- pos = _getFormattedNode.pos;
36
- if (node !== null && pos !== null) {
37
- if (isBulletOrOrderedList(node.type)) {
38
- var context = {
39
- sourceNode: node,
40
- sourcePos: pos,
41
- targetNodeType: nodes.taskList,
42
- tr: tr
43
- };
44
- return transformBetweenListTypes(context);
45
- }
46
- if (isTaskList(node.type)) {
47
- var _context = {
48
- sourceNode: node,
49
- sourcePos: pos,
50
- targetNodeType: nodes[targetType],
51
- tr: tr
52
- };
53
- return targetType === 'paragraph' ? transformTaskListToBlockNodes(_context) : transformBetweenListTypes(_context);
33
+ // Insert the empty list at the current selection
34
+ var insertTr = safeInsert(emptyList)(tr);
35
+ if (insertTr !== tr) {
36
+ if (fg('platform_editor_toolbar_task_list_analytics')) {
37
+ // Fire INSERT analytics event when creating a new task list
38
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
39
+ action: ACTION.INSERTED,
40
+ actionSubject: ACTION_SUBJECT.DOCUMENT,
41
+ actionSubjectId: ACTION_SUBJECT_ID.ACTION,
42
+ eventType: EVENT_TYPE.TRACK,
43
+ attributes: {
44
+ inputMethod: inputMethod,
45
+ listLocalId: listLocalId,
46
+ listSize: 1,
47
+ localId: itemLocalId,
48
+ position: 0
49
+ }
50
+ })(insertTr);
51
+ }
52
+
53
+ // Set cursor inside the new task item
54
+ var insertPos = insertTr.selection.$from.pos;
55
+ return insertTr.setSelection(TextSelection.near(insertTr.doc.resolve(insertPos)));
56
+ }
54
57
  }
55
- var _$from = selection.$from,
56
- $to = selection.$to;
57
- var range = _$from.blockRange($to);
58
- if (range) {
59
- return transformToTaskList(tr, range, nodes.taskList, undefined, nodes);
58
+ var _getFormattedNode = getFormattedNode(tr),
59
+ node = _getFormattedNode.node,
60
+ pos = _getFormattedNode.pos;
61
+ if (node !== null && pos !== null) {
62
+ if (isBulletOrOrderedList(node.type)) {
63
+ var transformedFrom = node.type.name === 'bulletList' ? ACTION_SUBJECT_ID.FORMAT_LIST_BULLET : ACTION_SUBJECT_ID.FORMAT_LIST_NUMBER;
64
+ var context = {
65
+ sourceNode: node,
66
+ sourcePos: pos,
67
+ targetNodeType: nodes.taskList,
68
+ tr: tr
69
+ };
70
+ var resultTr = transformBetweenListTypes(context);
71
+ if (fg('platform_editor_toolbar_task_list_analytics')) {
72
+ // Fire CONVERTED analytics event when transforming a list to task list
73
+ if (resultTr && resultTr.docChanged) {
74
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
75
+ action: ACTION.CONVERTED,
76
+ actionSubject: ACTION_SUBJECT.LIST,
77
+ actionSubjectId: ACTION_SUBJECT_ID.FORMAT_LIST_BULLET,
78
+ eventType: EVENT_TYPE.TRACK,
79
+ attributes: _objectSpread(_objectSpread({}, getCommonListAnalyticsAttributes(tr)), {}, {
80
+ transformedFrom: transformedFrom,
81
+ inputMethod: inputMethod
82
+ })
83
+ })(resultTr);
84
+ }
85
+ }
86
+ return resultTr;
87
+ }
88
+ if (isTaskList(node.type)) {
89
+ var _context = {
90
+ sourceNode: node,
91
+ sourcePos: pos,
92
+ targetNodeType: nodes[targetType],
93
+ tr: tr
94
+ };
95
+ var _resultTr = targetType === 'paragraph' ? transformTaskListToBlockNodes(_context) : transformBetweenListTypes(_context);
96
+
97
+ // Fire CONVERTED analytics event when transforming from task list
98
+ if (_resultTr && _resultTr.docChanged && targetType !== 'paragraph') {
99
+ var _transformedFrom = ACTION_SUBJECT_ID.FORMAT_LIST_BULLET;
100
+ var targetListType = targetType === 'bulletList' ? ACTION_SUBJECT_ID.FORMAT_LIST_BULLET : ACTION_SUBJECT_ID.FORMAT_LIST_NUMBER;
101
+ if (fg('platform_editor_toolbar_task_list_analytics')) {
102
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
103
+ action: ACTION.CONVERTED,
104
+ actionSubject: ACTION_SUBJECT.LIST,
105
+ actionSubjectId: targetListType,
106
+ eventType: EVENT_TYPE.TRACK,
107
+ attributes: _objectSpread(_objectSpread({}, getCommonListAnalyticsAttributes(tr)), {}, {
108
+ transformedFrom: _transformedFrom,
109
+ inputMethod: inputMethod
110
+ })
111
+ })(_resultTr);
112
+ }
113
+ }
114
+ return _resultTr;
115
+ }
116
+ var _$from = selection.$from,
117
+ $to = selection.$to;
118
+ var range = _$from.blockRange($to);
119
+ if (range) {
120
+ var _resultTr2 = transformToTaskList(tr, range, nodes.taskList, undefined, nodes);
121
+
122
+ // Fire INSERT analytics event when creating task list from selection
123
+ if (_resultTr2 && _resultTr2.docChanged) {
124
+ var _listNode$attrs$local, _listNode$attrs, _listNode$childCount, _listNode$firstChild$, _listNode$firstChild;
125
+ var listNode = _resultTr2.doc.nodeAt(range.start);
126
+ var listLocalIdFromNode = (_listNode$attrs$local = listNode === null || listNode === void 0 || (_listNode$attrs = listNode.attrs) === null || _listNode$attrs === void 0 ? void 0 : _listNode$attrs.localId) !== null && _listNode$attrs$local !== void 0 ? _listNode$attrs$local : uuid.generate();
127
+ var listSizeFromNode = (_listNode$childCount = listNode === null || listNode === void 0 ? void 0 : listNode.childCount) !== null && _listNode$childCount !== void 0 ? _listNode$childCount : 0;
128
+ var localIdFromNode = (_listNode$firstChild$ = listNode === null || listNode === void 0 || (_listNode$firstChild = listNode.firstChild) === null || _listNode$firstChild === void 0 || (_listNode$firstChild = _listNode$firstChild.attrs) === null || _listNode$firstChild === void 0 ? void 0 : _listNode$firstChild.localId) !== null && _listNode$firstChild$ !== void 0 ? _listNode$firstChild$ : uuid.generate();
129
+ if (fg('platform_editor_toolbar_task_list_analytics')) {
130
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
131
+ action: ACTION.INSERTED,
132
+ actionSubject: ACTION_SUBJECT.DOCUMENT,
133
+ actionSubjectId: ACTION_SUBJECT_ID.ACTION,
134
+ eventType: EVENT_TYPE.TRACK,
135
+ attributes: {
136
+ inputMethod: inputMethod,
137
+ listLocalId: listLocalIdFromNode,
138
+ listSize: listSizeFromNode,
139
+ localId: localIdFromNode,
140
+ position: 0
141
+ }
142
+ })(_resultTr2);
143
+ }
144
+ }
145
+ return _resultTr2;
146
+ }
60
147
  }
61
- }
62
- return tr;
148
+ return tr;
149
+ };
63
150
  };
64
151
  };
@@ -25,7 +25,7 @@ import { getListTypes, insertTaskDecisionAction, insertTaskDecisionCommand, setP
25
25
  import keymap, { getIndentCommand, getUnindentCommand } from './pm-plugins/keymaps';
26
26
  import { createPlugin } from './pm-plugins/main';
27
27
  import { stateKey as taskPluginKey } from './pm-plugins/plugin-key';
28
- import { toggleTaskList } from './pm-plugins/toggle-tasklist-commands';
28
+ import { toggleTaskList as _toggleTaskList } from './pm-plugins/toggle-tasklist-commands';
29
29
  import { DecisionListBlockMenuItem } from './ui/DecisionListBlockMenuItem/DecisionListBlockMenuItem';
30
30
  import { RequestToEditPopup } from './ui/Task/RequestToEditPopup';
31
31
  import { TaskListBlockMenuItem } from './ui/TaskListBlockMenuItem/TaskListBlockMenuItem';
@@ -83,7 +83,7 @@ function ContentComponent(_ref2) {
83
83
  });
84
84
  }
85
85
  export var tasksAndDecisionsPlugin = function tasksAndDecisionsPlugin(_ref3) {
86
- var _api$analytics, _api$analytics2, _api$analytics3;
86
+ var _api$analytics2, _api$analytics3, _api$analytics4;
87
87
  var _ref3$config = _ref3.config,
88
88
  _ref3$config2 = _ref3$config === void 0 ? {} : _ref3$config,
89
89
  allowNestedTasks = _ref3$config2.allowNestedTasks,
@@ -198,7 +198,10 @@ export var tasksAndDecisionsPlugin = function tasksAndDecisionsPlugin(_ref3) {
198
198
  };
199
199
  },
200
200
  commands: {
201
- toggleTaskList: toggleTaskList,
201
+ toggleTaskList: function toggleTaskList(targetType) {
202
+ var _api$analytics;
203
+ return _toggleTaskList(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)(targetType);
204
+ },
202
205
  updateEditPermission: function updateEditPermission(hasEditPermission) {
203
206
  return function (_ref5) {
204
207
  var tr = _ref5.tr;
@@ -217,9 +220,9 @@ export var tasksAndDecisionsPlugin = function tasksAndDecisionsPlugin(_ref3) {
217
220
  }
218
221
  },
219
222
  actions: {
220
- insertTaskDecision: insertTaskDecisionCommand(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, getIdentifierProvider),
221
- indentTaskList: getIndentCommand(api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions),
222
- outdentTaskList: getUnindentCommand(api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions),
223
+ insertTaskDecision: insertTaskDecisionCommand(api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, getIdentifierProvider),
224
+ indentTaskList: getIndentCommand(api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions),
225
+ outdentTaskList: getUnindentCommand(api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions),
223
226
  setProvider: function () {
224
227
  var _setProvider2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(providerPromise) {
225
228
  var _api$core$actions$exe;
@@ -267,10 +270,10 @@ export var tasksAndDecisionsPlugin = function tasksAndDecisionsPlugin(_ref3) {
267
270
  }, {
268
271
  name: 'tasksAndDecisionsInputRule',
269
272
  plugin: function plugin(_ref9) {
270
- var _api$analytics4;
273
+ var _api$analytics5;
271
274
  var schema = _ref9.schema,
272
275
  featureFlags = _ref9.featureFlags;
273
- return inputRulePlugin(api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions, getIdentifierProvider)(schema, featureFlags);
276
+ return inputRulePlugin(api === null || api === void 0 || (_api$analytics5 = api.analytics) === null || _api$analytics5 === void 0 ? void 0 : _api$analytics5.actions, getIdentifierProvider)(schema, featureFlags);
274
277
  }
275
278
  }, {
276
279
  name: 'tasksAndDecisionsKeyMap',
@@ -330,8 +333,8 @@ export var tasksAndDecisionsPlugin = function tasksAndDecisionsPlugin(_ref3) {
330
333
  return /*#__PURE__*/React.createElement(IconAction, null);
331
334
  },
332
335
  action: function action(insert, state) {
333
- var _api$analytics5;
334
- return insertTaskDecisionAction(api === null || api === void 0 || (_api$analytics5 = api.analytics) === null || _api$analytics5 === void 0 ? void 0 : _api$analytics5.actions, getIdentifierProvider)(state, 'taskList', INPUT_METHOD.QUICK_INSERT, addItem(insert, 'taskList', state.schema));
336
+ var _api$analytics6;
337
+ return insertTaskDecisionAction(api === null || api === void 0 || (_api$analytics6 = api.analytics) === null || _api$analytics6 === void 0 ? void 0 : _api$analytics6.actions, getIdentifierProvider)(state, 'taskList', INPUT_METHOD.QUICK_INSERT, addItem(insert, 'taskList', state.schema));
335
338
  }
336
339
  }, {
337
340
  id: 'decision',
@@ -343,8 +346,8 @@ export var tasksAndDecisionsPlugin = function tasksAndDecisionsPlugin(_ref3) {
343
346
  return /*#__PURE__*/React.createElement(IconDecision, null);
344
347
  },
345
348
  action: function action(insert, state) {
346
- var _api$analytics6;
347
- return insertTaskDecisionAction(api === null || api === void 0 || (_api$analytics6 = api.analytics) === null || _api$analytics6 === void 0 ? void 0 : _api$analytics6.actions, getIdentifierProvider)(state, 'decisionList', INPUT_METHOD.QUICK_INSERT, addItem(insert, 'decisionList', state.schema));
349
+ var _api$analytics7;
350
+ return insertTaskDecisionAction(api === null || api === void 0 || (_api$analytics7 = api.analytics) === null || _api$analytics7 === void 0 ? void 0 : _api$analytics7.actions, getIdentifierProvider)(state, 'decisionList', INPUT_METHOD.QUICK_INSERT, addItem(insert, 'decisionList', state.schema));
348
351
  }
349
352
  }];
350
353
  }
@@ -1,4 +1,3 @@
1
- import type { Transaction } from '@atlaskit/editor-prosemirror/state';
2
- export declare const toggleTaskList: (targetType?: "orderedList" | "bulletList" | "paragraph") => ({ tr }: {
3
- tr: Transaction;
4
- }) => Transaction | null;
1
+ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
2
+ import type { EditorCommand } from '@atlaskit/editor-common/types';
3
+ export declare const toggleTaskList: (editorAnalyticsAPI?: EditorAnalyticsAPI) => (targetType?: "orderedList" | "bulletList" | "paragraph") => EditorCommand;
@@ -1,4 +1,3 @@
1
- import type { Transaction } from '@atlaskit/editor-prosemirror/state';
2
- export declare const toggleTaskList: (targetType?: "orderedList" | "bulletList" | "paragraph") => ({ tr }: {
3
- tr: Transaction;
4
- }) => Transaction | null;
1
+ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
2
+ import type { EditorCommand } from '@atlaskit/editor-common/types';
3
+ export declare const toggleTaskList: (editorAnalyticsAPI?: EditorAnalyticsAPI) => (targetType?: "orderedList" | "bulletList" | "paragraph") => EditorCommand;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-tasks-and-decisions",
3
- "version": "10.1.15",
3
+ "version": "10.1.16",
4
4
  "description": "Tasks and decisions plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -49,14 +49,14 @@
49
49
  "@atlaskit/primitives": "^18.0.0",
50
50
  "@atlaskit/prosemirror-input-rules": "^3.6.0",
51
51
  "@atlaskit/task-decision": "^19.2.0",
52
- "@atlaskit/tmp-editor-statsig": "^25.0.0",
52
+ "@atlaskit/tmp-editor-statsig": "^25.2.0",
53
53
  "@atlaskit/tokens": "^11.0.0",
54
54
  "@babel/runtime": "^7.0.0",
55
55
  "@compiled/react": "^0.18.6",
56
56
  "bind-event-listener": "^3.0.0"
57
57
  },
58
58
  "peerDependencies": {
59
- "@atlaskit/editor-common": "^111.12.0",
59
+ "@atlaskit/editor-common": "^111.13.0",
60
60
  "react": "^18.2.0",
61
61
  "react-dom": "^18.2.0",
62
62
  "react-intl-next": "npm:react-intl@^5.18.1"
@@ -106,6 +106,9 @@
106
106
  },
107
107
  "platform_editor_blocktaskitem_patch_3": {
108
108
  "type": "boolean"
109
+ },
110
+ "platform_editor_toolbar_task_list_analytics": {
111
+ "type": "boolean"
109
112
  }
110
113
  }
111
114
  }