@atlaskit/editor-plugin-block-controls 2.14.1 → 2.14.2

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-block-controls
2
2
 
3
+ ## 2.14.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#169716](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/169716)
8
+ [`4fbd1fe0084b3`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/4fbd1fe0084b3) -
9
+ ED-25072 update and insert layout analytics.
10
+
3
11
  ## 2.14.1
4
12
 
5
13
  ### Patch Changes
@@ -20,6 +20,7 @@ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
20
20
  var _main = require("../pm-plugins/main");
21
21
  var _utils4 = require("../pm-plugins/utils");
22
22
  var _consts = require("../pm-plugins/utils/consts");
23
+ var _fireAnalytics = require("../pm-plugins/utils/fire-analytics");
23
24
  var _getSelection = require("../pm-plugins/utils/getSelection");
24
25
  var _removeFromSource = require("../pm-plugins/utils/remove-from-source");
25
26
  var _validation = require("../pm-plugins/utils/validation");
@@ -160,7 +161,7 @@ var moveNode = exports.moveNode = function moveNode(api) {
160
161
  var inputMethod = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _analytics.INPUT_METHOD.DRAG_AND_DROP;
161
162
  var formatMessage = arguments.length > 3 ? arguments[3] : undefined;
162
163
  return function (_ref4) {
163
- var _node$nodeSize, _api$analytics;
164
+ var _node$nodeSize;
164
165
  var tr = _ref4.tr;
165
166
  var node = tr.doc.nodeAt(start);
166
167
  var resolvedNode = tr.doc.resolve(start);
@@ -169,11 +170,11 @@ var moveNode = exports.moveNode = function moveNode(api) {
169
170
  }
170
171
  var size = (_node$nodeSize = node === null || node === void 0 ? void 0 : node.nodeSize) !== null && _node$nodeSize !== void 0 ? _node$nodeSize : 1;
171
172
  var end = start + size;
173
+ var $from = tr.doc.resolve(start);
172
174
  var mappedTo;
173
175
  if ((0, _experiments.editorExperiment)('nested-dnd', true)) {
174
176
  var nodeCopy = tr.doc.slice(start, end, false); // cut the content
175
177
  var $to = tr.doc.resolve(to);
176
- var $from = tr.doc.resolve(start);
177
178
  var destType = $to.node().type;
178
179
  var destParent = $to.node($to.depth);
179
180
  var sourceNode = $from.nodeAfter;
@@ -217,19 +218,25 @@ var moveNode = exports.moveNode = function moveNode(api) {
217
218
  });
218
219
  api === null || api === void 0 || api.core.actions.focus();
219
220
  var $mappedTo = tr.doc.resolve(mappedTo);
220
- api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.attachAnalyticsEvent({
221
- eventType: _analytics.EVENT_TYPE.TRACK,
222
- action: _analytics.ACTION.MOVED,
223
- actionSubject: _analytics.ACTION_SUBJECT.ELEMENT,
224
- actionSubjectId: _analytics.ACTION_SUBJECT_ID.ELEMENT_DRAG_HANDLE,
225
- attributes: _objectSpread({
226
- nodeDepth: resolvedNode.depth,
227
- nodeType: node.type.name,
228
- destinationNodeDepth: $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.depth
229
- }, (0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_23873') && {
230
- inputMethod: inputMethod
231
- })
232
- })(tr);
221
+ if ((0, _experiments.editorExperiment)('advanced_layouts', true)) {
222
+ (0, _fireAnalytics.fireMoveNodeAnalytics)(tr, inputMethod, resolvedNode.depth, node.type.name, $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.depth, $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.parent.type.name, $from.sameParent($mappedTo), api);
223
+ } else {
224
+ var _api$analytics;
225
+ api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.attachAnalyticsEvent({
226
+ eventType: _analytics.EVENT_TYPE.TRACK,
227
+ action: _analytics.ACTION.MOVED,
228
+ actionSubject: _analytics.ACTION_SUBJECT.ELEMENT,
229
+ actionSubjectId: _analytics.ACTION_SUBJECT_ID.ELEMENT_DRAG_HANDLE,
230
+ attributes: _objectSpread({
231
+ nodeDepth: resolvedNode.depth,
232
+ nodeType: node.type.name,
233
+ destinationNodeDepth: $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.depth,
234
+ destinationNodeType: $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.parent.type.name
235
+ }, (0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_23873') && {
236
+ inputMethod: inputMethod
237
+ })
238
+ })(tr);
239
+ }
233
240
  if ((0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_23873')) {
234
241
  var _api$accessibilityUti;
235
242
  var movedMessage = to > start ? _messages.blockControlsMessages.movedDown : _messages.blockControlsMessages.movedup;
@@ -4,9 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.moveToLayout = void 0;
7
+ var _analytics = require("@atlaskit/editor-common/analytics");
7
8
  var _model = require("@atlaskit/editor-prosemirror/model");
8
9
  var _state = require("@atlaskit/editor-prosemirror/state");
9
10
  var _consts = require("../pm-plugins/utils/consts");
11
+ var _fireAnalytics = require("../pm-plugins/utils/fire-analytics");
10
12
  var _removeFromSource = require("../pm-plugins/utils/remove-from-source");
11
13
  var _updateColumnWidths = require("../pm-plugins/utils/update-column-widths");
12
14
  var _validation = require("../pm-plugins/utils/validation");
@@ -35,16 +37,21 @@ var createNewLayout = function createNewLayout(schema, layoutContents) {
35
37
  }
36
38
  return null;
37
39
  };
38
- var moveToExistingLayout = function moveToExistingLayout(toLayout, toLayoutPos, sourceNode, from, to, tr, isSameLayout) {
40
+ var moveToExistingLayout = function moveToExistingLayout(toLayout, toLayoutPos, sourceNode, from, to, tr, $originalFrom, $originalTo, api) {
41
+ var isSameLayout = (0, _validation.isInSameLayout)($originalFrom, $originalTo);
39
42
  if (isSameLayout) {
43
+ var _$originalFrom$nodeAf;
40
44
  // reorder columns
41
45
  tr.delete(from, from + sourceNode.nodeSize);
42
46
  var mappedTo = tr.mapping.map(to);
43
47
  tr.insert(mappedTo, sourceNode).setSelection(new _state.NodeSelection(tr.doc.resolve(mappedTo))).scrollIntoView();
48
+ (0, _fireAnalytics.fireMoveNodeAnalytics)(tr, _analytics.INPUT_METHOD.DRAG_AND_DROP, $originalFrom.depth, ((_$originalFrom$nodeAf = $originalFrom.nodeAfter) === null || _$originalFrom$nodeAf === void 0 ? void 0 : _$originalFrom$nodeAf.type.name) || '', 1, 'layoutSection', true, api);
44
49
  } else if (toLayout.childCount < (0, _consts.maxLayoutColumnSupported)()) {
50
+ var _$originalFrom$nodeAf2;
45
51
  insertToDestination(tr, to, sourceNode, toLayout, toLayoutPos);
46
52
  var mappedFrom = tr.mapping.map(from);
47
53
  (0, _removeFromSource.removeFromSource)(tr, tr.doc.resolve(mappedFrom));
54
+ (0, _fireAnalytics.fireMoveNodeAnalytics)(tr, _analytics.INPUT_METHOD.DRAG_AND_DROP, $originalFrom.depth, ((_$originalFrom$nodeAf2 = $originalFrom.nodeAfter) === null || _$originalFrom$nodeAf2 === void 0 ? void 0 : _$originalFrom$nodeAf2.type.name) || '', 1, 'layoutSection', false, api);
48
55
  }
49
56
  return tr;
50
57
  };
@@ -139,12 +146,12 @@ var moveToLayout = exports.moveToLayout = function moveToLayout(api) {
139
146
  }
140
147
  if (toNode.type === layoutSection) {
141
148
  var toPos = options !== null && options !== void 0 && options.moveToEnd ? to + toNode.nodeSize - 1 : to + 1;
142
- return moveToExistingLayout(toNode, to, fromNodeWithoutBreakout, from, toPos, tr, (0, _validation.isInSameLayout)($from, $to));
149
+ return moveToExistingLayout(toNode, to, fromNodeWithoutBreakout, from, toPos, tr, $from, $to, api);
143
150
  } else if (toNode.type === layoutColumn) {
144
151
  var toLayout = $to.parent;
145
152
  var toLayoutPos = to - $to.parentOffset - 1;
146
153
  var _toPos = options !== null && options !== void 0 && options.moveToEnd ? to + toNode.nodeSize : to;
147
- return moveToExistingLayout(toLayout, toLayoutPos, fromNodeWithoutBreakout, from, _toPos, tr, (0, _validation.isInSameLayout)($from, $to));
154
+ return moveToExistingLayout(toLayout, toLayoutPos, fromNodeWithoutBreakout, from, _toPos, tr, $from, $to, api);
148
155
  } else {
149
156
  var toNodeWithoutBreakout = toNode;
150
157
 
@@ -168,6 +175,7 @@ var moveToLayout = exports.moveToLayout = function moveToLayout(api) {
168
175
  breakoutMode && tr.setNodeMarkup(mappedTo, newLayout.type, newLayout.attrs, [breakout.create({
169
176
  mode: breakoutMode
170
177
  })]);
178
+ (0, _fireAnalytics.fireInsertLayoutAnalytics)(tr, api);
171
179
  }
172
180
  return tr;
173
181
  }
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.fireMoveNodeAnalytics = exports.fireInsertLayoutAnalytics = void 0;
7
+ var _analytics = require("@atlaskit/editor-common/analytics");
8
+ var fireMoveNodeAnalytics = exports.fireMoveNodeAnalytics = function fireMoveNodeAnalytics(tr, inputMethod, fromDepth, fromNodeType, toDepth, toNodeType, isSameParent, api) {
9
+ var _api$analytics;
10
+ return api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || (_api$analytics = _api$analytics.actions) === null || _api$analytics === void 0 ? void 0 : _api$analytics.attachAnalyticsEvent({
11
+ eventType: _analytics.EVENT_TYPE.TRACK,
12
+ action: _analytics.ACTION.MOVED,
13
+ actionSubject: _analytics.ACTION_SUBJECT.ELEMENT,
14
+ actionSubjectId: _analytics.ACTION_SUBJECT_ID.ELEMENT_DRAG_HANDLE,
15
+ attributes: {
16
+ nodeDepth: fromDepth,
17
+ nodeType: fromNodeType,
18
+ destinationNodeDepth: toDepth,
19
+ destinationNodeType: toNodeType,
20
+ isSameParent: isSameParent,
21
+ inputMethod: inputMethod
22
+ }
23
+ })(tr);
24
+ };
25
+ var fireInsertLayoutAnalytics = exports.fireInsertLayoutAnalytics = function fireInsertLayoutAnalytics(tr, api) {
26
+ var _api$analytics2;
27
+ api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 || (_api$analytics2 = _api$analytics2.actions) === null || _api$analytics2 === void 0 || _api$analytics2.attachAnalyticsEvent({
28
+ action: _analytics.ACTION.INSERTED,
29
+ actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
30
+ actionSubjectId: _analytics.ACTION_SUBJECT_ID.LAYOUT,
31
+ attributes: {
32
+ inputMethod: _analytics.INPUT_METHOD.DRAG_AND_DROP
33
+ },
34
+ eventType: _analytics.EVENT_TYPE.TRACK
35
+ })(tr);
36
+ };
@@ -12,6 +12,7 @@ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
12
12
  import { key } from '../pm-plugins/main';
13
13
  import { getNestedNodePosition, selectNode } from '../pm-plugins/utils';
14
14
  import { DIRECTION } from '../pm-plugins/utils/consts';
15
+ import { fireMoveNodeAnalytics } from '../pm-plugins/utils/fire-analytics';
15
16
  import { setCursorPositionAtMovedNode } from '../pm-plugins/utils/getSelection';
16
17
  import { removeFromSource } from '../pm-plugins/utils/remove-from-source';
17
18
  import { canMoveNodeToIndex, isInsideTable, transformSliceExpandToNestedExpand } from '../pm-plugins/utils/validation';
@@ -155,7 +156,7 @@ export const moveNodeViaShortcut = (api, direction, formatMessage) => {
155
156
  export const moveNode = api => (start, to, inputMethod = INPUT_METHOD.DRAG_AND_DROP, formatMessage) => ({
156
157
  tr
157
158
  }) => {
158
- var _node$nodeSize, _api$analytics;
159
+ var _node$nodeSize;
159
160
  const node = tr.doc.nodeAt(start);
160
161
  const resolvedNode = tr.doc.resolve(start);
161
162
  if (!node) {
@@ -163,11 +164,11 @@ export const moveNode = api => (start, to, inputMethod = INPUT_METHOD.DRAG_AND_D
163
164
  }
164
165
  const size = (_node$nodeSize = node === null || node === void 0 ? void 0 : node.nodeSize) !== null && _node$nodeSize !== void 0 ? _node$nodeSize : 1;
165
166
  const end = start + size;
167
+ const $from = tr.doc.resolve(start);
166
168
  let mappedTo;
167
169
  if (editorExperiment('nested-dnd', true)) {
168
170
  const nodeCopy = tr.doc.slice(start, end, false); // cut the content
169
171
  const $to = tr.doc.resolve(to);
170
- const $from = tr.doc.resolve(start);
171
172
  const destType = $to.node().type;
172
173
  const destParent = $to.node($to.depth);
173
174
  const sourceNode = $from.nodeAfter;
@@ -211,20 +212,26 @@ export const moveNode = api => (start, to, inputMethod = INPUT_METHOD.DRAG_AND_D
211
212
  });
212
213
  api === null || api === void 0 ? void 0 : api.core.actions.focus();
213
214
  const $mappedTo = tr.doc.resolve(mappedTo);
214
- api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions.attachAnalyticsEvent({
215
- eventType: EVENT_TYPE.TRACK,
216
- action: ACTION.MOVED,
217
- actionSubject: ACTION_SUBJECT.ELEMENT,
218
- actionSubjectId: ACTION_SUBJECT_ID.ELEMENT_DRAG_HANDLE,
219
- attributes: {
220
- nodeDepth: resolvedNode.depth,
221
- nodeType: node.type.name,
222
- destinationNodeDepth: $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.depth,
223
- ...(fg('platform_editor_element_drag_and_drop_ed_23873') && {
224
- inputMethod
225
- })
226
- }
227
- })(tr);
215
+ if (editorExperiment('advanced_layouts', true)) {
216
+ fireMoveNodeAnalytics(tr, inputMethod, resolvedNode.depth, node.type.name, $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.depth, $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.parent.type.name, $from.sameParent($mappedTo), api);
217
+ } else {
218
+ var _api$analytics;
219
+ api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions.attachAnalyticsEvent({
220
+ eventType: EVENT_TYPE.TRACK,
221
+ action: ACTION.MOVED,
222
+ actionSubject: ACTION_SUBJECT.ELEMENT,
223
+ actionSubjectId: ACTION_SUBJECT_ID.ELEMENT_DRAG_HANDLE,
224
+ attributes: {
225
+ nodeDepth: resolvedNode.depth,
226
+ nodeType: node.type.name,
227
+ destinationNodeDepth: $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.depth,
228
+ destinationNodeType: $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.parent.type.name,
229
+ ...(fg('platform_editor_element_drag_and_drop_ed_23873') && {
230
+ inputMethod
231
+ })
232
+ }
233
+ })(tr);
234
+ }
228
235
  if (fg('platform_editor_element_drag_and_drop_ed_23873')) {
229
236
  var _api$accessibilityUti;
230
237
  const movedMessage = to > start ? blockControlsMessages.movedDown : blockControlsMessages.movedup;
@@ -1,6 +1,8 @@
1
+ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
1
2
  import { Fragment } from '@atlaskit/editor-prosemirror/model';
2
3
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
3
4
  import { maxLayoutColumnSupported } from '../pm-plugins/utils/consts';
5
+ import { fireInsertLayoutAnalytics, fireMoveNodeAnalytics } from '../pm-plugins/utils/fire-analytics';
4
6
  import { removeFromSource } from '../pm-plugins/utils/remove-from-source';
5
7
  import { updateColumnWidths } from '../pm-plugins/utils/update-column-widths';
6
8
  import { isInSameLayout } from '../pm-plugins/utils/validation';
@@ -30,16 +32,21 @@ const createNewLayout = (schema, layoutContents) => {
30
32
  }
31
33
  return null;
32
34
  };
33
- const moveToExistingLayout = (toLayout, toLayoutPos, sourceNode, from, to, tr, isSameLayout) => {
35
+ const moveToExistingLayout = (toLayout, toLayoutPos, sourceNode, from, to, tr, $originalFrom, $originalTo, api) => {
36
+ const isSameLayout = isInSameLayout($originalFrom, $originalTo);
34
37
  if (isSameLayout) {
38
+ var _$originalFrom$nodeAf;
35
39
  // reorder columns
36
40
  tr.delete(from, from + sourceNode.nodeSize);
37
41
  const mappedTo = tr.mapping.map(to);
38
42
  tr.insert(mappedTo, sourceNode).setSelection(new NodeSelection(tr.doc.resolve(mappedTo))).scrollIntoView();
43
+ fireMoveNodeAnalytics(tr, INPUT_METHOD.DRAG_AND_DROP, $originalFrom.depth, ((_$originalFrom$nodeAf = $originalFrom.nodeAfter) === null || _$originalFrom$nodeAf === void 0 ? void 0 : _$originalFrom$nodeAf.type.name) || '', 1, 'layoutSection', true, api);
39
44
  } else if (toLayout.childCount < maxLayoutColumnSupported()) {
45
+ var _$originalFrom$nodeAf2;
40
46
  insertToDestination(tr, to, sourceNode, toLayout, toLayoutPos);
41
47
  const mappedFrom = tr.mapping.map(from);
42
48
  removeFromSource(tr, tr.doc.resolve(mappedFrom));
49
+ fireMoveNodeAnalytics(tr, INPUT_METHOD.DRAG_AND_DROP, $originalFrom.depth, ((_$originalFrom$nodeAf2 = $originalFrom.nodeAfter) === null || _$originalFrom$nodeAf2 === void 0 ? void 0 : _$originalFrom$nodeAf2.type.name) || '', 1, 'layoutSection', false, api);
43
50
  }
44
51
  return tr;
45
52
  };
@@ -136,12 +143,12 @@ export const moveToLayout = api => (from, to, options) => ({
136
143
  }
137
144
  if (toNode.type === layoutSection) {
138
145
  const toPos = options !== null && options !== void 0 && options.moveToEnd ? to + toNode.nodeSize - 1 : to + 1;
139
- return moveToExistingLayout(toNode, to, fromNodeWithoutBreakout, from, toPos, tr, isInSameLayout($from, $to));
146
+ return moveToExistingLayout(toNode, to, fromNodeWithoutBreakout, from, toPos, tr, $from, $to, api);
140
147
  } else if (toNode.type === layoutColumn) {
141
148
  const toLayout = $to.parent;
142
149
  const toLayoutPos = to - $to.parentOffset - 1;
143
150
  const toPos = options !== null && options !== void 0 && options.moveToEnd ? to + toNode.nodeSize : to;
144
- return moveToExistingLayout(toLayout, toLayoutPos, fromNodeWithoutBreakout, from, toPos, tr, isInSameLayout($from, $to));
151
+ return moveToExistingLayout(toLayout, toLayoutPos, fromNodeWithoutBreakout, from, toPos, tr, $from, $to, api);
145
152
  } else {
146
153
  let toNodeWithoutBreakout = toNode;
147
154
 
@@ -163,6 +170,7 @@ export const moveToLayout = api => (from, to, options) => ({
163
170
  breakoutMode && tr.setNodeMarkup(mappedTo, newLayout.type, newLayout.attrs, [breakout.create({
164
171
  mode: breakoutMode
165
172
  })]);
173
+ fireInsertLayoutAnalytics(tr, api);
166
174
  }
167
175
  return tr;
168
176
  }
@@ -0,0 +1,30 @@
1
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
+ export const fireMoveNodeAnalytics = (tr, inputMethod, fromDepth, fromNodeType, toDepth, toNodeType, isSameParent, api) => {
3
+ var _api$analytics, _api$analytics$action;
4
+ return api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : (_api$analytics$action = _api$analytics.actions) === null || _api$analytics$action === void 0 ? void 0 : _api$analytics$action.attachAnalyticsEvent({
5
+ eventType: EVENT_TYPE.TRACK,
6
+ action: ACTION.MOVED,
7
+ actionSubject: ACTION_SUBJECT.ELEMENT,
8
+ actionSubjectId: ACTION_SUBJECT_ID.ELEMENT_DRAG_HANDLE,
9
+ attributes: {
10
+ nodeDepth: fromDepth,
11
+ nodeType: fromNodeType,
12
+ destinationNodeDepth: toDepth,
13
+ destinationNodeType: toNodeType,
14
+ isSameParent: isSameParent,
15
+ inputMethod
16
+ }
17
+ })(tr);
18
+ };
19
+ export const fireInsertLayoutAnalytics = (tr, api) => {
20
+ var _api$analytics2, _api$analytics2$actio;
21
+ api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : (_api$analytics2$actio = _api$analytics2.actions) === null || _api$analytics2$actio === void 0 ? void 0 : _api$analytics2$actio.attachAnalyticsEvent({
22
+ action: ACTION.INSERTED,
23
+ actionSubject: ACTION_SUBJECT.DOCUMENT,
24
+ actionSubjectId: ACTION_SUBJECT_ID.LAYOUT,
25
+ attributes: {
26
+ inputMethod: INPUT_METHOD.DRAG_AND_DROP
27
+ },
28
+ eventType: EVENT_TYPE.TRACK
29
+ })(tr);
30
+ };
@@ -15,6 +15,7 @@ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
15
15
  import { key } from '../pm-plugins/main';
16
16
  import { getNestedNodePosition, selectNode } from '../pm-plugins/utils';
17
17
  import { DIRECTION } from '../pm-plugins/utils/consts';
18
+ import { fireMoveNodeAnalytics } from '../pm-plugins/utils/fire-analytics';
18
19
  import { setCursorPositionAtMovedNode } from '../pm-plugins/utils/getSelection';
19
20
  import { removeFromSource } from '../pm-plugins/utils/remove-from-source';
20
21
  import { canMoveNodeToIndex, isInsideTable, transformSliceExpandToNestedExpand } from '../pm-plugins/utils/validation';
@@ -154,7 +155,7 @@ export var moveNode = function moveNode(api) {
154
155
  var inputMethod = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : INPUT_METHOD.DRAG_AND_DROP;
155
156
  var formatMessage = arguments.length > 3 ? arguments[3] : undefined;
156
157
  return function (_ref4) {
157
- var _node$nodeSize, _api$analytics;
158
+ var _node$nodeSize;
158
159
  var tr = _ref4.tr;
159
160
  var node = tr.doc.nodeAt(start);
160
161
  var resolvedNode = tr.doc.resolve(start);
@@ -163,11 +164,11 @@ export var moveNode = function moveNode(api) {
163
164
  }
164
165
  var size = (_node$nodeSize = node === null || node === void 0 ? void 0 : node.nodeSize) !== null && _node$nodeSize !== void 0 ? _node$nodeSize : 1;
165
166
  var end = start + size;
167
+ var $from = tr.doc.resolve(start);
166
168
  var mappedTo;
167
169
  if (editorExperiment('nested-dnd', true)) {
168
170
  var nodeCopy = tr.doc.slice(start, end, false); // cut the content
169
171
  var $to = tr.doc.resolve(to);
170
- var $from = tr.doc.resolve(start);
171
172
  var destType = $to.node().type;
172
173
  var destParent = $to.node($to.depth);
173
174
  var sourceNode = $from.nodeAfter;
@@ -211,19 +212,25 @@ export var moveNode = function moveNode(api) {
211
212
  });
212
213
  api === null || api === void 0 || api.core.actions.focus();
213
214
  var $mappedTo = tr.doc.resolve(mappedTo);
214
- api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.attachAnalyticsEvent({
215
- eventType: EVENT_TYPE.TRACK,
216
- action: ACTION.MOVED,
217
- actionSubject: ACTION_SUBJECT.ELEMENT,
218
- actionSubjectId: ACTION_SUBJECT_ID.ELEMENT_DRAG_HANDLE,
219
- attributes: _objectSpread({
220
- nodeDepth: resolvedNode.depth,
221
- nodeType: node.type.name,
222
- destinationNodeDepth: $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.depth
223
- }, fg('platform_editor_element_drag_and_drop_ed_23873') && {
224
- inputMethod: inputMethod
225
- })
226
- })(tr);
215
+ if (editorExperiment('advanced_layouts', true)) {
216
+ fireMoveNodeAnalytics(tr, inputMethod, resolvedNode.depth, node.type.name, $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.depth, $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.parent.type.name, $from.sameParent($mappedTo), api);
217
+ } else {
218
+ var _api$analytics;
219
+ api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.attachAnalyticsEvent({
220
+ eventType: EVENT_TYPE.TRACK,
221
+ action: ACTION.MOVED,
222
+ actionSubject: ACTION_SUBJECT.ELEMENT,
223
+ actionSubjectId: ACTION_SUBJECT_ID.ELEMENT_DRAG_HANDLE,
224
+ attributes: _objectSpread({
225
+ nodeDepth: resolvedNode.depth,
226
+ nodeType: node.type.name,
227
+ destinationNodeDepth: $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.depth,
228
+ destinationNodeType: $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.parent.type.name
229
+ }, fg('platform_editor_element_drag_and_drop_ed_23873') && {
230
+ inputMethod: inputMethod
231
+ })
232
+ })(tr);
233
+ }
227
234
  if (fg('platform_editor_element_drag_and_drop_ed_23873')) {
228
235
  var _api$accessibilityUti;
229
236
  var movedMessage = to > start ? blockControlsMessages.movedDown : blockControlsMessages.movedup;
@@ -1,6 +1,8 @@
1
+ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
1
2
  import { Fragment } from '@atlaskit/editor-prosemirror/model';
2
3
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
3
4
  import { maxLayoutColumnSupported } from '../pm-plugins/utils/consts';
5
+ import { fireInsertLayoutAnalytics, fireMoveNodeAnalytics } from '../pm-plugins/utils/fire-analytics';
4
6
  import { removeFromSource } from '../pm-plugins/utils/remove-from-source';
5
7
  import { updateColumnWidths } from '../pm-plugins/utils/update-column-widths';
6
8
  import { isInSameLayout } from '../pm-plugins/utils/validation';
@@ -29,16 +31,21 @@ var createNewLayout = function createNewLayout(schema, layoutContents) {
29
31
  }
30
32
  return null;
31
33
  };
32
- var moveToExistingLayout = function moveToExistingLayout(toLayout, toLayoutPos, sourceNode, from, to, tr, isSameLayout) {
34
+ var moveToExistingLayout = function moveToExistingLayout(toLayout, toLayoutPos, sourceNode, from, to, tr, $originalFrom, $originalTo, api) {
35
+ var isSameLayout = isInSameLayout($originalFrom, $originalTo);
33
36
  if (isSameLayout) {
37
+ var _$originalFrom$nodeAf;
34
38
  // reorder columns
35
39
  tr.delete(from, from + sourceNode.nodeSize);
36
40
  var mappedTo = tr.mapping.map(to);
37
41
  tr.insert(mappedTo, sourceNode).setSelection(new NodeSelection(tr.doc.resolve(mappedTo))).scrollIntoView();
42
+ fireMoveNodeAnalytics(tr, INPUT_METHOD.DRAG_AND_DROP, $originalFrom.depth, ((_$originalFrom$nodeAf = $originalFrom.nodeAfter) === null || _$originalFrom$nodeAf === void 0 ? void 0 : _$originalFrom$nodeAf.type.name) || '', 1, 'layoutSection', true, api);
38
43
  } else if (toLayout.childCount < maxLayoutColumnSupported()) {
44
+ var _$originalFrom$nodeAf2;
39
45
  insertToDestination(tr, to, sourceNode, toLayout, toLayoutPos);
40
46
  var mappedFrom = tr.mapping.map(from);
41
47
  removeFromSource(tr, tr.doc.resolve(mappedFrom));
48
+ fireMoveNodeAnalytics(tr, INPUT_METHOD.DRAG_AND_DROP, $originalFrom.depth, ((_$originalFrom$nodeAf2 = $originalFrom.nodeAfter) === null || _$originalFrom$nodeAf2 === void 0 ? void 0 : _$originalFrom$nodeAf2.type.name) || '', 1, 'layoutSection', false, api);
42
49
  }
43
50
  return tr;
44
51
  };
@@ -133,12 +140,12 @@ export var moveToLayout = function moveToLayout(api) {
133
140
  }
134
141
  if (toNode.type === layoutSection) {
135
142
  var toPos = options !== null && options !== void 0 && options.moveToEnd ? to + toNode.nodeSize - 1 : to + 1;
136
- return moveToExistingLayout(toNode, to, fromNodeWithoutBreakout, from, toPos, tr, isInSameLayout($from, $to));
143
+ return moveToExistingLayout(toNode, to, fromNodeWithoutBreakout, from, toPos, tr, $from, $to, api);
137
144
  } else if (toNode.type === layoutColumn) {
138
145
  var toLayout = $to.parent;
139
146
  var toLayoutPos = to - $to.parentOffset - 1;
140
147
  var _toPos = options !== null && options !== void 0 && options.moveToEnd ? to + toNode.nodeSize : to;
141
- return moveToExistingLayout(toLayout, toLayoutPos, fromNodeWithoutBreakout, from, _toPos, tr, isInSameLayout($from, $to));
148
+ return moveToExistingLayout(toLayout, toLayoutPos, fromNodeWithoutBreakout, from, _toPos, tr, $from, $to, api);
142
149
  } else {
143
150
  var toNodeWithoutBreakout = toNode;
144
151
 
@@ -162,6 +169,7 @@ export var moveToLayout = function moveToLayout(api) {
162
169
  breakoutMode && tr.setNodeMarkup(mappedTo, newLayout.type, newLayout.attrs, [breakout.create({
163
170
  mode: breakoutMode
164
171
  })]);
172
+ fireInsertLayoutAnalytics(tr, api);
165
173
  }
166
174
  return tr;
167
175
  }
@@ -0,0 +1,30 @@
1
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
+ export var fireMoveNodeAnalytics = function fireMoveNodeAnalytics(tr, inputMethod, fromDepth, fromNodeType, toDepth, toNodeType, isSameParent, api) {
3
+ var _api$analytics;
4
+ return api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || (_api$analytics = _api$analytics.actions) === null || _api$analytics === void 0 ? void 0 : _api$analytics.attachAnalyticsEvent({
5
+ eventType: EVENT_TYPE.TRACK,
6
+ action: ACTION.MOVED,
7
+ actionSubject: ACTION_SUBJECT.ELEMENT,
8
+ actionSubjectId: ACTION_SUBJECT_ID.ELEMENT_DRAG_HANDLE,
9
+ attributes: {
10
+ nodeDepth: fromDepth,
11
+ nodeType: fromNodeType,
12
+ destinationNodeDepth: toDepth,
13
+ destinationNodeType: toNodeType,
14
+ isSameParent: isSameParent,
15
+ inputMethod: inputMethod
16
+ }
17
+ })(tr);
18
+ };
19
+ export var fireInsertLayoutAnalytics = function fireInsertLayoutAnalytics(tr, api) {
20
+ var _api$analytics2;
21
+ api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 || (_api$analytics2 = _api$analytics2.actions) === null || _api$analytics2 === void 0 || _api$analytics2.attachAnalyticsEvent({
22
+ action: ACTION.INSERTED,
23
+ actionSubject: ACTION_SUBJECT.DOCUMENT,
24
+ actionSubjectId: ACTION_SUBJECT_ID.LAYOUT,
25
+ attributes: {
26
+ inputMethod: INPUT_METHOD.DRAG_AND_DROP
27
+ },
28
+ eventType: EVENT_TYPE.TRACK
29
+ })(tr);
30
+ };
@@ -0,0 +1,5 @@
1
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
+ import { type Transaction } from '@atlaskit/editor-prosemirror/state';
3
+ import { type BlockControlsPlugin } from '../../blockControlsPluginType';
4
+ export declare const fireMoveNodeAnalytics: (tr: Transaction, inputMethod: string, fromDepth: number, fromNodeType: string, toDepth?: number, toNodeType?: string, isSameParent?: boolean, api?: ExtractInjectionAPI<BlockControlsPlugin>) => boolean | undefined;
5
+ export declare const fireInsertLayoutAnalytics: (tr: Transaction, api?: ExtractInjectionAPI<BlockControlsPlugin>) => void;
@@ -0,0 +1,5 @@
1
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
+ import { type Transaction } from '@atlaskit/editor-prosemirror/state';
3
+ import { type BlockControlsPlugin } from '../../blockControlsPluginType';
4
+ export declare const fireMoveNodeAnalytics: (tr: Transaction, inputMethod: string, fromDepth: number, fromNodeType: string, toDepth?: number, toNodeType?: string, isSameParent?: boolean, api?: ExtractInjectionAPI<BlockControlsPlugin>) => boolean | undefined;
5
+ export declare const fireInsertLayoutAnalytics: (tr: Transaction, api?: ExtractInjectionAPI<BlockControlsPlugin>) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "2.14.1",
3
+ "version": "2.14.2",
4
4
  "description": "Block controls plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",