@atlaskit/editor-plugin-block-menu 6.0.26 → 6.0.28

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.
Files changed (27) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/blockMenuPlugin.js +14 -0
  3. package/dist/cjs/editor-commands/transformNode.js +1 -0
  4. package/dist/cjs/pm-plugins/experiences/block-menu-experiences.js +190 -0
  5. package/dist/cjs/pm-plugins/experiences/experience-check-utils.js +147 -0
  6. package/dist/cjs/ui/delete-button.js +27 -2
  7. package/dist/cjs/ui/move-down.js +3 -1
  8. package/dist/cjs/ui/move-up.js +3 -1
  9. package/dist/es2019/blockMenuPlugin.js +12 -0
  10. package/dist/es2019/editor-commands/transformNode.js +1 -0
  11. package/dist/es2019/pm-plugins/experiences/block-menu-experiences.js +181 -0
  12. package/dist/es2019/pm-plugins/experiences/experience-check-utils.js +125 -0
  13. package/dist/es2019/ui/delete-button.js +29 -4
  14. package/dist/es2019/ui/move-down.js +4 -2
  15. package/dist/es2019/ui/move-up.js +4 -2
  16. package/dist/esm/blockMenuPlugin.js +14 -0
  17. package/dist/esm/editor-commands/transformNode.js +1 -0
  18. package/dist/esm/pm-plugins/experiences/block-menu-experiences.js +184 -0
  19. package/dist/esm/pm-plugins/experiences/experience-check-utils.js +140 -0
  20. package/dist/esm/ui/delete-button.js +29 -4
  21. package/dist/esm/ui/move-down.js +4 -2
  22. package/dist/esm/ui/move-up.js +4 -2
  23. package/dist/types/pm-plugins/experiences/block-menu-experiences.d.ts +10 -0
  24. package/dist/types/pm-plugins/experiences/experience-check-utils.d.ts +62 -0
  25. package/dist/types-ts4.5/pm-plugins/experiences/block-menu-experiences.d.ts +10 -0
  26. package/dist/types-ts4.5/pm-plugins/experiences/experience-check-utils.d.ts +62 -0
  27. package/package.json +4 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @atlaskit/editor-plugin-block-menu
2
2
 
3
+ ## 6.0.28
4
+
5
+ ### Patch Changes
6
+
7
+ - [`957d9e1880c62`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/957d9e1880c62) -
8
+ EDITOR-3806 Block menu action experience tracking
9
+ - Updated dependencies
10
+
11
+ ## 6.0.27
12
+
13
+ ### Patch Changes
14
+
15
+ - [`4cafa94a73e1e`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/4cafa94a73e1e) -
16
+ Add delete track event for block menu
17
+ - Updated dependencies
18
+
3
19
  ## 6.0.26
4
20
 
5
21
  ### Patch Changes
@@ -10,6 +10,7 @@ var _editorActions = require("./editor-actions");
10
10
  var _isTransformToTargetDisabled = require("./editor-actions/isTransformToTargetDisabled");
11
11
  var _formatNode2 = require("./editor-commands/formatNode");
12
12
  var _transformNode2 = require("./editor-commands/transformNode");
13
+ var _blockMenuExperiences = require("./pm-plugins/experiences/block-menu-experiences");
13
14
  var _keymap = require("./pm-plugins/keymap");
14
15
  var _main = require("./pm-plugins/main");
15
16
  var _blockMenu = _interopRequireDefault(require("./ui/block-menu"));
@@ -24,6 +25,7 @@ var blockMenuPlugin = exports.blockMenuPlugin = function blockMenuPlugin(_ref) {
24
25
  api: api,
25
26
  config: config
26
27
  }));
28
+ var refs = {};
27
29
  return {
28
30
  name: 'blockMenu',
29
31
  pmPlugins: function pmPlugins() {
@@ -37,6 +39,17 @@ var blockMenuPlugin = exports.blockMenuPlugin = function blockMenuPlugin(_ref) {
37
39
  plugin: function plugin() {
38
40
  return (0, _keymap.keymapPlugin)(api, config);
39
41
  }
42
+ }, {
43
+ name: 'blockMenuExperiences',
44
+ plugin: function plugin() {
45
+ return (0, _blockMenuExperiences.getBlockMenuExperiencesPlugin)({
46
+ refs: refs,
47
+ dispatchAnalyticsEvent: function dispatchAnalyticsEvent(payload) {
48
+ var _api$analytics;
49
+ 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.fireAnalyticsEvent(payload);
50
+ }
51
+ });
52
+ }
40
53
  }];
41
54
  },
42
55
  actions: {
@@ -94,6 +107,7 @@ var blockMenuPlugin = exports.blockMenuPlugin = function blockMenuPlugin(_ref) {
94
107
  popupsMountPoint = _ref2.popupsMountPoint,
95
108
  popupsBoundariesElement = _ref2.popupsBoundariesElement,
96
109
  popupsScrollableElement = _ref2.popupsScrollableElement;
110
+ refs.popupsMountPoint = popupsMountPoint || undefined;
97
111
  return /*#__PURE__*/_react.default.createElement(_blockMenuProvider.BlockMenuProvider, {
98
112
  api: api,
99
113
  editorView: editorView
@@ -84,6 +84,7 @@ var transformNode = exports.transformNode = function transformNode(api) {
84
84
  isNested: isNested,
85
85
  sourceNodesCount: sourceNodes.length,
86
86
  sourceNodesCountByType: sourceNodeTypes,
87
+ sourceNodeType: sourceNodes.length === 1 ? sourceNodes[0].type.name : 'multiple',
87
88
  startTime: startTime,
88
89
  targetNodeType: targetType.name,
89
90
  outputNodesCount: content.length,
@@ -0,0 +1,190 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getBlockMenuExperiencesPlugin = void 0;
7
+ var _bindEventListener = require("bind-event-listener");
8
+ var _analytics = require("@atlaskit/editor-common/analytics");
9
+ var _blockMenu = require("@atlaskit/editor-common/block-menu");
10
+ var _experiences = require("@atlaskit/editor-common/experiences");
11
+ var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
12
+ var _state = require("@atlaskit/editor-prosemirror/state");
13
+ var _experienceCheckUtils = require("./experience-check-utils");
14
+ var TIMEOUT_DURATION = 1000;
15
+ var pluginKey = new _state.PluginKey('blockMenuExperiences');
16
+ var START_METHOD = {
17
+ DRAG_HANDLE_CLICK: 'dragHandleClick',
18
+ KEYBOARD: 'keyboard'
19
+ };
20
+ var ABORT_REASON = {
21
+ USER_CANCELED: 'userCanceled',
22
+ EDITOR_DESTROYED: 'editorDestroyed'
23
+ };
24
+ var getBlockMenuExperiencesPlugin = exports.getBlockMenuExperiencesPlugin = function getBlockMenuExperiencesPlugin(_ref) {
25
+ var refs = _ref.refs,
26
+ dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent;
27
+ var popupTargetEl;
28
+ var editorView;
29
+ var getPopupsTarget = function getPopupsTarget() {
30
+ if (!popupTargetEl) {
31
+ var _editorView;
32
+ popupTargetEl = refs.popupsMountPoint || (0, _experiences.getPopupContainerFromEditorView)((_editorView = editorView) === null || _editorView === void 0 ? void 0 : _editorView.dom);
33
+ }
34
+ return popupTargetEl;
35
+ };
36
+ var blockMenuOpenExperience = new _experiences.Experience(_experiences.EXPERIENCE_ID.MENU_OPEN, {
37
+ actionSubjectId: _analytics.ACTION_SUBJECT_ID.BLOCK_MENU,
38
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent,
39
+ checks: [new _experiences.ExperienceCheckTimeout({
40
+ durationMs: TIMEOUT_DURATION
41
+ }), new _experiences.ExperienceCheckDomMutation({
42
+ onDomMutation: _experienceCheckUtils.handleMenuOpenDomMutation,
43
+ observeConfig: function observeConfig() {
44
+ return {
45
+ target: getPopupsTarget(),
46
+ options: {
47
+ childList: true
48
+ }
49
+ };
50
+ }
51
+ })]
52
+ });
53
+ var actionObserveConfig = function actionObserveConfig() {
54
+ return {
55
+ target: (0, _experienceCheckUtils.getParentDOMAtSelection)(editorView),
56
+ options: {
57
+ childList: true
58
+ }
59
+ };
60
+ };
61
+ var blockMoveUpExperience = new _experiences.Experience(_experiences.EXPERIENCE_ID.MENU_ACTION, {
62
+ action: _analytics.ACTION.MOVED,
63
+ actionSubjectId: _analytics.ACTION_SUBJECT_ID.MOVE_UP_BLOCK,
64
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent,
65
+ checks: [new _experiences.ExperienceCheckTimeout({
66
+ durationMs: TIMEOUT_DURATION
67
+ }), new _experiences.ExperienceCheckDomMutation({
68
+ onDomMutation: _experienceCheckUtils.handleMoveDomMutation,
69
+ observeConfig: actionObserveConfig
70
+ })]
71
+ });
72
+ var blockMoveDownExperience = new _experiences.Experience(_experiences.EXPERIENCE_ID.MENU_ACTION, {
73
+ action: _analytics.ACTION.MOVED,
74
+ actionSubjectId: _analytics.ACTION_SUBJECT_ID.MOVE_DOWN_BLOCK,
75
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent,
76
+ checks: [new _experiences.ExperienceCheckTimeout({
77
+ durationMs: TIMEOUT_DURATION
78
+ }), new _experiences.ExperienceCheckDomMutation({
79
+ onDomMutation: _experienceCheckUtils.handleMoveDomMutation,
80
+ observeConfig: actionObserveConfig
81
+ })]
82
+ });
83
+ var blockDeleteExperience = new _experiences.Experience(_experiences.EXPERIENCE_ID.MENU_ACTION, {
84
+ action: _analytics.ACTION.DELETED,
85
+ actionSubjectId: _analytics.ACTION_SUBJECT_ID.DELETE_BLOCK,
86
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent,
87
+ checks: [new _experiences.ExperienceCheckTimeout({
88
+ durationMs: TIMEOUT_DURATION
89
+ }), new _experiences.ExperienceCheckDomMutation({
90
+ onDomMutation: _experienceCheckUtils.handleDeleteDomMutation,
91
+ observeConfig: actionObserveConfig
92
+ })]
93
+ });
94
+ var handleMenuOpened = function handleMenuOpened(method) {
95
+ // Don't start if block menu is already visible
96
+ if ((0, _experienceCheckUtils.isBlockMenuVisible)(getPopupsTarget())) {
97
+ return;
98
+ }
99
+ blockMenuOpenExperience.start({
100
+ method: method
101
+ });
102
+ };
103
+ var handleItemActioned = function handleItemActioned(target) {
104
+ var button = target.closest('button[data-testid]');
105
+ if (!button || !(button instanceof HTMLButtonElement) || button.disabled || button.getAttribute('aria-disabled') === 'true') {
106
+ return;
107
+ }
108
+ var testId = button.dataset.testid;
109
+ if (!testId) {
110
+ return;
111
+ }
112
+ switch (testId) {
113
+ case _blockMenu.BLOCK_MENU_ACTION_TEST_ID.MOVE_UP:
114
+ blockMoveUpExperience.start();
115
+ break;
116
+ case _blockMenu.BLOCK_MENU_ACTION_TEST_ID.MOVE_DOWN:
117
+ blockMoveDownExperience.start();
118
+ break;
119
+ case _blockMenu.BLOCK_MENU_ACTION_TEST_ID.DELETE:
120
+ blockDeleteExperience.start();
121
+ break;
122
+ }
123
+ };
124
+ var unbindClickListener = (0, _bindEventListener.bind)(document, {
125
+ type: 'click',
126
+ listener: function listener(event) {
127
+ var target = event.target;
128
+ if (!(target instanceof HTMLElement)) {
129
+ return;
130
+ }
131
+ if ((0, _experienceCheckUtils.isDragHandleElement)(target)) {
132
+ handleMenuOpened(START_METHOD.DRAG_HANDLE_CLICK);
133
+ } else {
134
+ handleItemActioned(target);
135
+ }
136
+ },
137
+ options: {
138
+ capture: true
139
+ }
140
+ });
141
+ var unbindKeydownListener = (0, _bindEventListener.bind)(document, {
142
+ type: 'keydown',
143
+ listener: function listener(event) {
144
+ var target = event.target;
145
+ if (!(target instanceof HTMLElement)) {
146
+ return;
147
+ }
148
+
149
+ // Check if Enter or Space is pressed on a drag handle
150
+ if ((event.key === 'Enter' || event.key === ' ') && (0, _experienceCheckUtils.isDragHandleElement)(target)) {
151
+ handleMenuOpened(START_METHOD.KEYBOARD);
152
+ }
153
+
154
+ // Abort on Escape key if block menu is not yet visible
155
+ if (event.key === 'Escape' && !(0, _experienceCheckUtils.isBlockMenuVisible)(getPopupsTarget())) {
156
+ blockMenuOpenExperience.abort({
157
+ reason: ABORT_REASON.USER_CANCELED
158
+ });
159
+ }
160
+ },
161
+ options: {
162
+ capture: true
163
+ }
164
+ });
165
+ return new _safePlugin.SafePlugin({
166
+ key: pluginKey,
167
+ view: function view(_view) {
168
+ editorView = _view;
169
+ return {
170
+ destroy: function destroy() {
171
+ blockMenuOpenExperience.abort({
172
+ reason: ABORT_REASON.EDITOR_DESTROYED
173
+ });
174
+ blockMoveUpExperience.abort({
175
+ reason: ABORT_REASON.EDITOR_DESTROYED
176
+ });
177
+ blockMoveDownExperience.abort({
178
+ reason: ABORT_REASON.EDITOR_DESTROYED
179
+ });
180
+ blockDeleteExperience.abort({
181
+ reason: ABORT_REASON.EDITOR_DESTROYED
182
+ });
183
+ editorView = undefined;
184
+ unbindClickListener();
185
+ unbindKeydownListener();
186
+ }
187
+ };
188
+ }
189
+ });
190
+ };
@@ -0,0 +1,147 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.isDragHandleElement = exports.isBlockMenuVisible = exports.handleMoveDomMutation = exports.handleMenuOpenDomMutation = exports.handleDeleteDomMutation = exports.getParentDOMAtSelection = void 0;
8
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
+ var _experiences = require("@atlaskit/editor-common/experiences");
10
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
11
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
12
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
13
+ /**
14
+ * Checks if the given element or any of its ancestors is a drag handle element.
15
+ *
16
+ * @param element - The DOM element to check.
17
+ * @returns True if the element is a drag handle, false otherwise.
18
+ */
19
+ var isDragHandleElement = exports.isDragHandleElement = function isDragHandleElement(element) {
20
+ return !!(element !== null && element !== void 0 && element.closest('[data-editor-block-ctrl-drag-handle]'));
21
+ };
22
+
23
+ /**
24
+ * Checks if the block menu is currently visible within the provided popups target element.
25
+ *
26
+ * @param popupsTarget - The container element for popups.
27
+ * @returns True if the block menu is visible, false otherwise.
28
+ */
29
+ var isBlockMenuVisible = exports.isBlockMenuVisible = function isBlockMenuVisible(popupsTarget) {
30
+ if (!popupsTarget) {
31
+ return false;
32
+ }
33
+ return (0, _experiences.popupWithNestedElement)(popupsTarget, '[data-testid="editor-block-menu"]') !== null;
34
+ };
35
+
36
+ /**
37
+ * Gets the parent DOM element at the starting position of the current selection
38
+ * from the provided editor view.
39
+ *
40
+ * @param editorView - The editor view from which to get the parent DOM element
41
+ * @returns The parent HTMLElement at the selection start, or null if not found
42
+ */
43
+ var getParentDOMAtSelection = exports.getParentDOMAtSelection = function getParentDOMAtSelection(editorView) {
44
+ if (!editorView) {
45
+ return null;
46
+ }
47
+ var selection = editorView.state.selection;
48
+ var from = selection.from;
49
+ var nodeDOM = editorView.nodeDOM(from);
50
+ if (nodeDOM instanceof HTMLElement) {
51
+ return nodeDOM.parentElement;
52
+ }
53
+ return null;
54
+ };
55
+ var isBlockMenuAddedInMutation = function isBlockMenuAddedInMutation(_ref) {
56
+ var type = _ref.type,
57
+ addedNodes = _ref.addedNodes;
58
+ return type === 'childList' && (0, _toConsumableArray2.default)(addedNodes).some(isBlockMenuWithinNode);
59
+ };
60
+ var isBlockMenuWithinNode = function isBlockMenuWithinNode(node) {
61
+ return (0, _experiences.popupWithNestedElement)(node, '[data-testid="editor-block-menu"]') !== null;
62
+ };
63
+
64
+ /**
65
+ * Handles DOM mutations to determine if the block menu was opened
66
+ *
67
+ * This function looks for mutations that indicate the block menu
68
+ * has been added to the DOM.
69
+ *
70
+ * @param mutations - The list of DOM mutations to evaluate
71
+ * @returns An ExperienceCheckResult indicating success if the menu was opened, otherwise undefined
72
+ */
73
+ var handleMenuOpenDomMutation = exports.handleMenuOpenDomMutation = function handleMenuOpenDomMutation(_ref2) {
74
+ var mutations = _ref2.mutations;
75
+ // Look for a mutation that added the block menu
76
+ var _iterator = _createForOfIteratorHelper(mutations),
77
+ _step;
78
+ try {
79
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
80
+ var mutation = _step.value;
81
+ if (isBlockMenuAddedInMutation(mutation)) {
82
+ return {
83
+ status: 'success'
84
+ };
85
+ }
86
+ }
87
+ } catch (err) {
88
+ _iterator.e(err);
89
+ } finally {
90
+ _iterator.f();
91
+ }
92
+ return undefined;
93
+ };
94
+
95
+ /**
96
+ * Handles DOM mutations to determine if a move action was performed
97
+ *
98
+ * Move actions typically produce two mutations: one where nodes are removed
99
+ * from their original location, and another where the same number of nodes are
100
+ * added to a new location. This function checks for that pattern.
101
+ *
102
+ * @param mutations - The list of DOM mutations to evaluate
103
+ * @returns An ExperienceCheckResult indicating success if a move was detected, otherwise undefined
104
+ */
105
+ var handleMoveDomMutation = exports.handleMoveDomMutation = function handleMoveDomMutation(_ref3) {
106
+ var mutations = _ref3.mutations;
107
+ var removeMutation = mutations.find(function (m) {
108
+ return m.type === 'childList' && m.removedNodes.length > 0;
109
+ });
110
+ var addMutation = mutations.find(function (m) {
111
+ return m.type === 'childList' && m.addedNodes.length > 0;
112
+ });
113
+ if (removeMutation && addMutation && removeMutation.removedNodes.length === addMutation.addedNodes.length) {
114
+ return {
115
+ status: 'success'
116
+ };
117
+ }
118
+ return undefined;
119
+ };
120
+
121
+ /**
122
+ * Handles DOM mutations to determine if a delete action was performed
123
+ *
124
+ * Delete actions typically produce a single mutation where nodes are removed
125
+ * from the DOM without any corresponding additions. This function checks for
126
+ * that specific pattern.
127
+ *
128
+ * @param mutations - The list of DOM mutations to evaluate
129
+ * @returns An ExperienceCheckResult indicating success if a delete was detected, otherwise undefined
130
+ */
131
+ var handleDeleteDomMutation = exports.handleDeleteDomMutation = function handleDeleteDomMutation(_ref4) {
132
+ var mutations = _ref4.mutations;
133
+ // Delete action produces a single childList mutation with only removedNodes
134
+ var childListMutations = mutations.filter(function (m) {
135
+ return m.type === 'childList';
136
+ });
137
+
138
+ // Check for at least one mutation with removedNodes but no addedNodes
139
+ if (childListMutations.some(function (m) {
140
+ return m.removedNodes.length > 0 && m.addedNodes.length === 0;
141
+ })) {
142
+ return {
143
+ status: 'success'
144
+ };
145
+ }
146
+ return undefined;
147
+ };
@@ -9,6 +9,7 @@ exports.DeleteDropdownItem = void 0;
9
9
  var _react = _interopRequireWildcard(require("react"));
10
10
  var _reactIntlNext = require("react-intl-next");
11
11
  var _analytics = require("@atlaskit/editor-common/analytics");
12
+ var _blockMenu = require("@atlaskit/editor-common/block-menu");
12
13
  var _messages = require("@atlaskit/editor-common/messages");
13
14
  var _selection = require("@atlaskit/editor-common/selection");
14
15
  var _editorToolbar = require("@atlaskit/editor-toolbar");
@@ -34,7 +35,30 @@ var DeleteDropdownItemContent = function DeleteDropdownItemContent(_ref) {
34
35
  eventType: _analytics.EVENT_TYPE.UI
35
36
  };
36
37
  api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || (_api$analytics = _api$analytics.actions) === null || _api$analytics === void 0 || _api$analytics.attachAnalyticsEvent(payload)(tr);
37
- (0, _selection.deleteSelectedRange)(tr, api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || (_api$blockControls = _api$blockControls.sharedState.currentState()) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.preservedSelection);
38
+
39
+ // Extract node information before deletion
40
+ var preservedSelection = api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || (_api$blockControls = _api$blockControls.sharedState.currentState()) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.preservedSelection;
41
+ var selection = preservedSelection || tr.selection;
42
+ var sourceNodes = (0, _selection.getSourceNodesFromSelectionRange)(tr, selection);
43
+ var nodeCount = sourceNodes.length;
44
+
45
+ // Fire node deletion analytics event if nodes are being deleted
46
+ if (nodeCount > 0) {
47
+ var _api$analytics2;
48
+ var nodeType = sourceNodes.length === 1 ? sourceNodes[0].type.name : 'multiple';
49
+ var nodeDeletedPayload = {
50
+ action: _analytics.ACTION.DELETED,
51
+ actionSubject: _analytics.ACTION_SUBJECT.ELEMENT,
52
+ attributes: {
53
+ inputMethod: _analytics.INPUT_METHOD.BLOCK_MENU,
54
+ nodeType: nodeType,
55
+ nodeCount: nodeCount
56
+ },
57
+ eventType: _analytics.EVENT_TYPE.TRACK
58
+ };
59
+ 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(nodeDeletedPayload)(tr);
60
+ }
61
+ (0, _selection.deleteSelectedRange)(tr, preservedSelection);
38
62
  api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || (_api$blockControls2 = _api$blockControls2.commands) === null || _api$blockControls2 === void 0 || _api$blockControls2.toggleBlockMenu({
39
63
  closeMenu: true
40
64
  })({
@@ -82,7 +106,8 @@ var DeleteDropdownItemContent = function DeleteDropdownItemContent(_ref) {
82
106
  color: "var(--ds-icon-danger, #C9372C)",
83
107
  label: ""
84
108
  }),
85
- onClick: onClick
109
+ onClick: onClick,
110
+ testId: _blockMenu.BLOCK_MENU_ACTION_TEST_ID.DELETE
86
111
  }, /*#__PURE__*/_react.default.createElement(_text.default, {
87
112
  as: "span",
88
113
  color: "color.text.danger"
@@ -10,6 +10,7 @@ var _react = _interopRequireWildcard(require("react"));
10
10
  var _reactIntlNext = require("react-intl-next");
11
11
  var _browserApis = require("@atlaskit/browser-apis");
12
12
  var _analytics = require("@atlaskit/editor-common/analytics");
13
+ var _blockMenu = require("@atlaskit/editor-common/block-menu");
13
14
  var _hooks = require("@atlaskit/editor-common/hooks");
14
15
  var _messages = require("@atlaskit/editor-common/messages");
15
16
  var _types = require("@atlaskit/editor-common/types");
@@ -72,7 +73,8 @@ var MoveDownDropdownItemContent = function MoveDownDropdownItemContent(_ref) {
72
73
  elemBefore: /*#__PURE__*/_react.default.createElement(_arrowDown.default, {
73
74
  label: ""
74
75
  }),
75
- isDisabled: !canMoveDown
76
+ isDisabled: !canMoveDown,
77
+ testId: _blockMenu.BLOCK_MENU_ACTION_TEST_ID.MOVE_DOWN
76
78
  }, formatMessage(_messages.blockMenuMessages.moveDownBlock));
77
79
  };
78
80
  var MoveDownDropdownItem = exports.MoveDownDropdownItem = (0, _reactIntlNext.injectIntl)(MoveDownDropdownItemContent);
@@ -10,6 +10,7 @@ var _react = _interopRequireWildcard(require("react"));
10
10
  var _reactIntlNext = require("react-intl-next");
11
11
  var _browserApis = require("@atlaskit/browser-apis");
12
12
  var _analytics = require("@atlaskit/editor-common/analytics");
13
+ var _blockMenu = require("@atlaskit/editor-common/block-menu");
13
14
  var _hooks = require("@atlaskit/editor-common/hooks");
14
15
  var _messages = require("@atlaskit/editor-common/messages");
15
16
  var _types = require("@atlaskit/editor-common/types");
@@ -70,7 +71,8 @@ var MoveUpDropdownItemContent = function MoveUpDropdownItemContent(_ref) {
70
71
  elemBefore: /*#__PURE__*/_react.default.createElement(_arrowUp.default, {
71
72
  label: ""
72
73
  }),
73
- isDisabled: !canMoveUp
74
+ isDisabled: !canMoveUp,
75
+ testId: _blockMenu.BLOCK_MENU_ACTION_TEST_ID.MOVE_UP
74
76
  }, formatMessage(_messages.blockMenuMessages.moveUpBlock));
75
77
  };
76
78
  var MoveUpDropdownItem = exports.MoveUpDropdownItem = (0, _reactIntlNext.injectIntl)(MoveUpDropdownItemContent);
@@ -3,6 +3,7 @@ import { createBlockMenuRegistry } from './editor-actions';
3
3
  import { isTransformToTargetDisabled } from './editor-actions/isTransformToTargetDisabled';
4
4
  import { formatNode } from './editor-commands/formatNode';
5
5
  import { transformNode } from './editor-commands/transformNode';
6
+ import { getBlockMenuExperiencesPlugin } from './pm-plugins/experiences/block-menu-experiences';
6
7
  import { keymapPlugin } from './pm-plugins/keymap';
7
8
  import { blockMenuPluginKey, createPlugin } from './pm-plugins/main';
8
9
  import BlockMenu from './ui/block-menu';
@@ -18,6 +19,7 @@ export const blockMenuPlugin = ({
18
19
  api,
19
20
  config
20
21
  }));
22
+ const refs = {};
21
23
  return {
22
24
  name: 'blockMenu',
23
25
  pmPlugins() {
@@ -27,6 +29,15 @@ export const blockMenuPlugin = ({
27
29
  }, {
28
30
  name: 'blockMenuKeymap',
29
31
  plugin: () => keymapPlugin(api, config)
32
+ }, {
33
+ name: 'blockMenuExperiences',
34
+ plugin: () => getBlockMenuExperiencesPlugin({
35
+ refs,
36
+ dispatchAnalyticsEvent: payload => {
37
+ var _api$analytics, _api$analytics$action;
38
+ 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.fireAnalyticsEvent(payload);
39
+ }
40
+ })
30
41
  }];
31
42
  },
32
43
  actions: {
@@ -85,6 +96,7 @@ export const blockMenuPlugin = ({
85
96
  popupsBoundariesElement,
86
97
  popupsScrollableElement
87
98
  }) {
99
+ refs.popupsMountPoint = popupsMountPoint || undefined;
88
100
  return /*#__PURE__*/React.createElement(BlockMenuProvider, {
89
101
  api: api,
90
102
  editorView: editorView
@@ -76,6 +76,7 @@ export const transformNode = api => (targetType, metadata) => ({
76
76
  isNested,
77
77
  sourceNodesCount: sourceNodes.length,
78
78
  sourceNodesCountByType: sourceNodeTypes,
79
+ sourceNodeType: sourceNodes.length === 1 ? sourceNodes[0].type.name : 'multiple',
79
80
  startTime,
80
81
  targetNodeType: targetType.name,
81
82
  outputNodesCount: content.length,