@atlaskit/editor-plugin-block-menu 4.0.6 → 4.0.7

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-menu
2
2
 
3
+ ## 4.0.7
4
+
5
+ ### Patch Changes
6
+
7
+ - [`eb4899e5362e5`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/eb4899e5362e5) -
8
+ Update BlockMenuItemClicked event payload
9
+ - Updated dependencies
10
+
3
11
  ## 4.0.6
4
12
 
5
13
  ### Patch Changes
@@ -8,8 +8,7 @@ exports.useBlockMenu = exports.BlockMenuProvider = void 0;
8
8
  var _react = _interopRequireWildcard(require("react"));
9
9
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
10
10
  var BlockMenuContext = /*#__PURE__*/(0, _react.createContext)({
11
- onDropdownOpenChanged: function onDropdownOpenChanged() {},
12
- fireAnalyticsEvent: function fireAnalyticsEvent() {}
11
+ onDropdownOpenChanged: function onDropdownOpenChanged() {}
13
12
  });
14
13
  var useBlockMenu = exports.useBlockMenu = function useBlockMenu() {
15
14
  var context = (0, _react.useContext)(BlockMenuContext);
@@ -33,14 +32,9 @@ var BlockMenuProvider = exports.BlockMenuProvider = function BlockMenuProvider(_
33
32
  }, 1);
34
33
  }
35
34
  }, [api]);
36
- var fireAnalyticsEvent = (0, _react.useCallback)(function (payload) {
37
- var _api$analytics;
38
- api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.fireAnalyticsEvent(payload);
39
- }, [api]);
40
35
  return /*#__PURE__*/_react.default.createElement(BlockMenuContext.Provider, {
41
36
  value: {
42
- onDropdownOpenChanged: onDropdownOpenChanged,
43
- fireAnalyticsEvent: fireAnalyticsEvent
37
+ onDropdownOpenChanged: onDropdownOpenChanged
44
38
  }
45
39
  }, children);
46
40
  };
@@ -79,8 +79,7 @@ var BlockMenu = function BlockMenu(_ref2) {
79
79
  currentUserIntent = _useSharedPluginState.currentUserIntent,
80
80
  openedViaKeyboard = _useSharedPluginState.openedViaKeyboard;
81
81
  var _useBlockMenu = (0, _blockMenuProvider.useBlockMenu)(),
82
- onDropdownOpenChanged = _useBlockMenu.onDropdownOpenChanged,
83
- fireAnalyticsEvent = _useBlockMenu.fireAnalyticsEvent;
82
+ onDropdownOpenChanged = _useBlockMenu.onDropdownOpenChanged;
84
83
  var targetHandleRef = editorView === null || editorView === void 0 || (_editorView$dom = editorView.dom) === null || _editorView$dom === void 0 ? void 0 : _editorView$dom.querySelector(_styles.DRAG_HANDLE_SELECTOR);
85
84
  var prevIsMenuOpenRef = (0, _react.useRef)(false);
86
85
  var hasFocus = (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true) ? (_ref3 = (editorView === null || editorView === void 0 ? void 0 : editorView.hasFocus()) || document.activeElement === targetHandleRef) !== null && _ref3 !== void 0 ? _ref3 : false : (_editorView$hasFocus = editorView === null || editorView === void 0 ? void 0 : editorView.hasFocus()) !== null && _editorView$hasFocus !== void 0 ? _editorView$hasFocus : false;
@@ -97,7 +96,8 @@ var BlockMenu = function BlockMenu(_ref2) {
97
96
 
98
97
  // Fire analytics event when block menu opens (only on first transition from closed to open)
99
98
  if (!prevIsMenuOpenRef.current && isMenuOpen) {
100
- fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 || fireAnalyticsEvent({
99
+ var _api$analytics;
100
+ api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.fireAnalyticsEvent({
101
101
  action: _analytics.ACTION.OPENED,
102
102
  actionSubject: _analytics.ACTION_SUBJECT.BLOCK_MENU,
103
103
  eventType: _analytics.EVENT_TYPE.UI,
@@ -110,7 +110,7 @@ var BlockMenu = function BlockMenu(_ref2) {
110
110
  // Update the previous state
111
111
  prevIsMenuOpenRef.current = isMenuOpen;
112
112
  api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 || (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 ? void 0 : _api$userIntent.commands.setCurrentUserIntent('blockMenuOpen'));
113
- }, [api, isMenuOpen, menuTriggerBy, selectedByShortcutORDragHandle, hasFocus, shouldShowBlockMenuForEmptyLine, currentUserIntent, fireAnalyticsEvent]);
113
+ }, [api, isMenuOpen, menuTriggerBy, selectedByShortcutORDragHandle, hasFocus, shouldShowBlockMenuForEmptyLine, currentUserIntent]);
114
114
  if (!isMenuOpen) {
115
115
  return null;
116
116
  }
@@ -3,5 +3,17 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.BLOCK_MENU_LABEL = void 0;
7
- var BLOCK_MENU_LABEL = exports.BLOCK_MENU_LABEL = 'Editor Block Menu';
6
+ exports.BLOCK_MENU_LABEL = exports.BLOCK_MENU_ITEM_NAME = void 0;
7
+ var BLOCK_MENU_LABEL = exports.BLOCK_MENU_LABEL = 'Editor Block Menu';
8
+
9
+ /**
10
+ * Constants for block menu analytics menu item names
11
+ */
12
+ var BLOCK_MENU_ITEM_NAME = exports.BLOCK_MENU_ITEM_NAME = {
13
+ COPY_LINK_TO_BLOCK: 'copyLinkToBlock',
14
+ MOVE_UP: 'moveUp',
15
+ MOVE_DOWN: 'moveDown',
16
+ DELETE: 'delete',
17
+ FORMAT_MENU: 'formatMenu',
18
+ COPY_CONTENT: 'copyContent'
19
+ };
@@ -19,7 +19,7 @@ var _utils = require("@atlaskit/editor-tables/utils");
19
19
  var _editorToolbar = require("@atlaskit/editor-toolbar");
20
20
  var _copy = _interopRequireDefault(require("@atlaskit/icon/core/copy"));
21
21
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
22
- var _blockMenuProvider = require("./block-menu-provider");
22
+ var _consts = require("./consts");
23
23
  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; }
24
24
  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; }
25
25
  var toDOMFromFragment = function toDOMFromFragment(fragment, schema) {
@@ -29,18 +29,22 @@ var CopyBlockMenuItem = function CopyBlockMenuItem(_ref) {
29
29
  var api = _ref.api;
30
30
  var _useIntl = (0, _reactIntlNext.useIntl)(),
31
31
  formatMessage = _useIntl.formatMessage;
32
- var _useBlockMenu = (0, _blockMenuProvider.useBlockMenu)(),
33
- fireAnalyticsEvent = _useBlockMenu.fireAnalyticsEvent;
34
32
  var copyHandler = function copyHandler(event) {
35
33
  var _api$selection;
36
- fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 || fireAnalyticsEvent({
37
- action: _analytics.ACTION.CLICKED,
38
- actionSubject: _analytics.ACTION_SUBJECT.BLOCK_MENU_ITEM,
39
- actionSubjectId: _analytics.ACTION_SUBJECT_ID.COPY_BLOCK,
40
- eventType: _analytics.EVENT_TYPE.UI,
41
- attributes: {
42
- inputMethod: _analytics.INPUT_METHOD.MOUSE
43
- }
34
+ api === null || api === void 0 || api.core.actions.execute(function (_ref2) {
35
+ var _api$analytics;
36
+ var tr = _ref2.tr;
37
+ var payload = {
38
+ action: _analytics.ACTION.CLICKED,
39
+ actionSubject: _analytics.ACTION_SUBJECT.BLOCK_MENU_ITEM,
40
+ attributes: {
41
+ inputMethod: _analytics.INPUT_METHOD.MOUSE,
42
+ menuItemName: _consts.BLOCK_MENU_ITEM_NAME.COPY_CONTENT
43
+ },
44
+ eventType: _analytics.EVENT_TYPE.UI
45
+ };
46
+ 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);
47
+ return tr;
44
48
  });
45
49
 
46
50
  // prevent click event from bubbling up to the ancestor elements
@@ -13,7 +13,7 @@ var _messages = require("@atlaskit/editor-common/messages");
13
13
  var _editorToolbar = require("@atlaskit/editor-toolbar");
14
14
  var _link = _interopRequireDefault(require("@atlaskit/icon/core/link"));
15
15
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
16
- var _blockMenuProvider = require("./block-menu-provider");
16
+ var _consts = require("./consts");
17
17
  var _copyLink = require("./utils/copyLink");
18
18
  var _isNestedNode = require("./utils/isNestedNode");
19
19
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
@@ -22,21 +22,20 @@ var CopyLinkDropdownItemContent = function CopyLinkDropdownItemContent(_ref) {
22
22
  config = _ref.config;
23
23
  var _useIntl = (0, _reactIntlNext.useIntl)(),
24
24
  formatMessage = _useIntl.formatMessage;
25
- var _useBlockMenu = (0, _blockMenuProvider.useBlockMenu)(),
26
- fireAnalyticsEvent = _useBlockMenu.fireAnalyticsEvent;
27
25
  var handleClick = (0, _react.useCallback)(function () {
28
- fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 || fireAnalyticsEvent({
29
- action: _analytics.ACTION.CLICKED,
30
- actionSubject: _analytics.ACTION_SUBJECT.BLOCK_MENU_ITEM,
31
- actionSubjectId: _analytics.ACTION_SUBJECT_ID.COPY_LINK_TO_BLOCK,
32
- eventType: _analytics.EVENT_TYPE.UI,
33
- attributes: {
34
- inputMethod: _analytics.INPUT_METHOD.MOUSE
35
- }
36
- });
37
26
  api === null || api === void 0 || api.core.actions.execute(function (_ref2) {
38
- var _api$blockControls;
27
+ var _api$analytics, _api$blockControls;
39
28
  var tr = _ref2.tr;
29
+ var payload = {
30
+ action: _analytics.ACTION.CLICKED,
31
+ actionSubject: _analytics.ACTION_SUBJECT.BLOCK_MENU_ITEM,
32
+ attributes: {
33
+ inputMethod: _analytics.INPUT_METHOD.MOUSE,
34
+ menuItemName: _consts.BLOCK_MENU_ITEM_NAME.COPY_LINK_TO_BLOCK
35
+ },
36
+ eventType: _analytics.EVENT_TYPE.UI
37
+ };
38
+ 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);
40
39
  api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || (_api$blockControls = _api$blockControls.commands) === null || _api$blockControls === void 0 || _api$blockControls.toggleBlockMenu({
41
40
  closeMenu: true
42
41
  })({
@@ -46,7 +45,7 @@ var CopyLinkDropdownItemContent = function CopyLinkDropdownItemContent(_ref) {
46
45
  });
47
46
  api === null || api === void 0 || api.core.actions.focus();
48
47
  return (0, _copyLink.copyLink)(config === null || config === void 0 ? void 0 : config.getLinkPath, config === null || config === void 0 ? void 0 : config.blockQueryParam, api);
49
- }, [config === null || config === void 0 ? void 0 : config.getLinkPath, config === null || config === void 0 ? void 0 : config.blockQueryParam, api, fireAnalyticsEvent]);
48
+ }, [config === null || config === void 0 ? void 0 : config.getLinkPath, config === null || config === void 0 ? void 0 : config.blockQueryParam, api]);
50
49
  var checkIsNestedNode = (0, _react.useCallback)(function () {
51
50
  var _api$selection, _api$blockControls2;
52
51
  var selection = api === null || api === void 0 || (_api$selection = api.selection) === null || _api$selection === void 0 || (_api$selection = _api$selection.sharedState) === null || _api$selection === void 0 || (_api$selection = _api$selection.currentState()) === null || _api$selection === void 0 ? void 0 : _api$selection.selection;
@@ -19,29 +19,28 @@ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
19
19
  var _box = require("@atlaskit/primitives/box");
20
20
  var _text = _interopRequireDefault(require("@atlaskit/primitives/text"));
21
21
  var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
22
- var _blockMenuProvider = require("./block-menu-provider");
22
+ var _consts = require("./consts");
23
23
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
24
24
  var DeleteDropdownItemContent = function DeleteDropdownItemContent(_ref) {
25
25
  var _api$core$sharedState;
26
26
  var api = _ref.api;
27
27
  var _useIntl = (0, _reactIntlNext.useIntl)(),
28
28
  formatMessage = _useIntl.formatMessage;
29
- var _useBlockMenu = (0, _blockMenuProvider.useBlockMenu)(),
30
- fireAnalyticsEvent = _useBlockMenu.fireAnalyticsEvent;
31
29
  var nodeTypes = Object.values((api === null || api === void 0 || (_api$core$sharedState = api.core.sharedState.currentState()) === null || _api$core$sharedState === void 0 || (_api$core$sharedState = _api$core$sharedState.schema) === null || _api$core$sharedState === void 0 ? void 0 : _api$core$sharedState.nodes) || {});
32
30
  var onClick = function onClick() {
33
- fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 || fireAnalyticsEvent({
34
- action: _analytics.ACTION.CLICKED,
35
- actionSubject: _analytics.ACTION_SUBJECT.BLOCK_MENU_ITEM,
36
- actionSubjectId: _analytics.ACTION_SUBJECT_ID.DELETE_BLOCK,
37
- eventType: _analytics.EVENT_TYPE.UI,
38
- attributes: {
39
- inputMethod: _analytics.INPUT_METHOD.MOUSE
40
- }
41
- });
42
31
  api === null || api === void 0 || api.core.actions.execute(function (_ref2) {
43
- var _api$blockControls;
32
+ var _api$analytics, _api$blockControls;
44
33
  var tr = _ref2.tr;
34
+ var payload = {
35
+ action: _analytics.ACTION.CLICKED,
36
+ actionSubject: _analytics.ACTION_SUBJECT.BLOCK_MENU_ITEM,
37
+ attributes: {
38
+ inputMethod: _analytics.INPUT_METHOD.MOUSE,
39
+ menuItemName: _consts.BLOCK_MENU_ITEM_NAME.DELETE
40
+ },
41
+ eventType: _analytics.EVENT_TYPE.UI
42
+ };
43
+ 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);
45
44
  var selection = tr.selection;
46
45
  var from = selection.$from.pos;
47
46
  var to = selection.$to.pos;
@@ -15,7 +15,7 @@ var _editorToolbar = require("@atlaskit/editor-toolbar");
15
15
  var _changes = _interopRequireDefault(require("@atlaskit/icon/core/changes"));
16
16
  var _chevronRight = _interopRequireDefault(require("@atlaskit/icon/core/chevron-right"));
17
17
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
18
- var _blockMenuProvider = require("./block-menu-provider");
18
+ var _consts = require("./consts");
19
19
  var _checkIsFormatMenuHidden = require("./utils/checkIsFormatMenuHidden");
20
20
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
21
21
  var FormatMenuComponent = exports.FormatMenuComponent = function FormatMenuComponent(_ref) {
@@ -23,23 +23,27 @@ var FormatMenuComponent = exports.FormatMenuComponent = function FormatMenuCompo
23
23
  children = _ref.children;
24
24
  var _useIntl = (0, _reactIntlNext.useIntl)(),
25
25
  formatMessage = _useIntl.formatMessage;
26
- var _useBlockMenu = (0, _blockMenuProvider.useBlockMenu)(),
27
- fireAnalyticsEvent = _useBlockMenu.fireAnalyticsEvent;
28
26
  var text = (0, _platformFeatureFlags.fg)('platform_editor_block_menu_patch_1') ? formatMessage(_messages.blockMenuMessages.turnInto) : formatMessage(_blockMenu.messages.turnInto);
29
27
  var isDisabled = (0, _react.useMemo)(function () {
30
28
  return (0, _platformFeatureFlags.fg)('platform_editor_block_menu_for_disabled_nodes') ? (0, _checkIsFormatMenuHidden.checkIsFormatMenuHidden)(api) : false;
31
29
  }, [api]);
32
30
  var handleClick = (0, _react.useCallback)(function () {
33
- fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 || fireAnalyticsEvent({
34
- action: _analytics.ACTION.CLICKED,
35
- actionSubject: _analytics.ACTION_SUBJECT.BLOCK_MENU_ITEM,
36
- actionSubjectId: _analytics.ACTION_SUBJECT_ID.FORMAT_MENU,
37
- eventType: _analytics.EVENT_TYPE.UI,
38
- attributes: {
39
- inputMethod: _analytics.INPUT_METHOD.MOUSE
40
- }
31
+ api === null || api === void 0 || api.core.actions.execute(function (_ref2) {
32
+ var _api$analytics;
33
+ var tr = _ref2.tr;
34
+ var payload = {
35
+ action: _analytics.ACTION.CLICKED,
36
+ actionSubject: _analytics.ACTION_SUBJECT.BLOCK_MENU_ITEM,
37
+ attributes: {
38
+ inputMethod: _analytics.INPUT_METHOD.MOUSE,
39
+ menuItemName: _consts.BLOCK_MENU_ITEM_NAME.FORMAT_MENU
40
+ },
41
+ eventType: _analytics.EVENT_TYPE.UI
42
+ };
43
+ 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);
44
+ return tr;
41
45
  });
42
- }, [fireAnalyticsEvent]);
46
+ }, [api]);
43
47
  return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarNestedDropdownMenu, {
44
48
  text: text,
45
49
  elemBefore: /*#__PURE__*/_react.default.createElement(_changes.default, {
@@ -13,13 +13,11 @@ var _messages = require("@atlaskit/editor-common/messages");
13
13
  var _types = require("@atlaskit/editor-common/types");
14
14
  var _editorToolbar = require("@atlaskit/editor-toolbar");
15
15
  var _arrowDown = _interopRequireDefault(require("@atlaskit/icon/core/arrow-down"));
16
- var _blockMenuProvider = require("./block-menu-provider");
16
+ var _consts = require("./consts");
17
17
  var MoveDownDropdownItemContent = function MoveDownDropdownItemContent(_ref) {
18
18
  var api = _ref.api;
19
19
  var _useIntl = (0, _reactIntlNext.useIntl)(),
20
20
  formatMessage = _useIntl.formatMessage;
21
- var _useBlockMenu = (0, _blockMenuProvider.useBlockMenu)(),
22
- fireAnalyticsEvent = _useBlockMenu.fireAnalyticsEvent;
23
21
  var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['blockControls'], function (_ref2) {
24
22
  var _blockControlsState$b;
25
23
  var blockControlsState = _ref2.blockControlsState;
@@ -29,18 +27,19 @@ var MoveDownDropdownItemContent = function MoveDownDropdownItemContent(_ref) {
29
27
  }),
30
28
  canMoveDown = _useSharedPluginState.canMoveDown;
31
29
  var handleClick = function handleClick() {
32
- fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 || fireAnalyticsEvent({
33
- action: _analytics.ACTION.CLICKED,
34
- actionSubject: _analytics.ACTION_SUBJECT.BLOCK_MENU_ITEM,
35
- actionSubjectId: _analytics.ACTION_SUBJECT_ID.MOVE_DOWN_BLOCK,
36
- eventType: _analytics.EVENT_TYPE.UI,
37
- attributes: {
38
- inputMethod: _analytics.INPUT_METHOD.MOUSE
39
- }
40
- });
41
30
  api === null || api === void 0 || api.core.actions.execute(function (_ref3) {
42
- var _api$blockControls, _api$blockControls2;
31
+ var _api$analytics, _api$blockControls, _api$blockControls2;
43
32
  var tr = _ref3.tr;
33
+ var payload = {
34
+ action: _analytics.ACTION.CLICKED,
35
+ actionSubject: _analytics.ACTION_SUBJECT.BLOCK_MENU_ITEM,
36
+ attributes: {
37
+ inputMethod: _analytics.INPUT_METHOD.MOUSE,
38
+ menuItemName: _consts.BLOCK_MENU_ITEM_NAME.MOVE_DOWN
39
+ },
40
+ eventType: _analytics.EVENT_TYPE.UI
41
+ };
42
+ 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);
44
43
  api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || (_api$blockControls = _api$blockControls.commands) === null || _api$blockControls === void 0 || _api$blockControls.moveNodeWithBlockMenu(_types.DIRECTION.DOWN)({
45
44
  tr: tr
46
45
  });
@@ -13,13 +13,11 @@ var _messages = require("@atlaskit/editor-common/messages");
13
13
  var _types = require("@atlaskit/editor-common/types");
14
14
  var _editorToolbar = require("@atlaskit/editor-toolbar");
15
15
  var _arrowUp = _interopRequireDefault(require("@atlaskit/icon/core/arrow-up"));
16
- var _blockMenuProvider = require("./block-menu-provider");
16
+ var _consts = require("./consts");
17
17
  var MoveUpDropdownItemContent = function MoveUpDropdownItemContent(_ref) {
18
18
  var api = _ref.api;
19
19
  var _useIntl = (0, _reactIntlNext.useIntl)(),
20
20
  formatMessage = _useIntl.formatMessage;
21
- var _useBlockMenu = (0, _blockMenuProvider.useBlockMenu)(),
22
- fireAnalyticsEvent = _useBlockMenu.fireAnalyticsEvent;
23
21
  var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['blockControls'], function (_ref2) {
24
22
  var _blockControlsState$b;
25
23
  var blockControlsState = _ref2.blockControlsState;
@@ -29,18 +27,19 @@ var MoveUpDropdownItemContent = function MoveUpDropdownItemContent(_ref) {
29
27
  }),
30
28
  canMoveUp = _useSharedPluginState.canMoveUp;
31
29
  var handleClick = function handleClick() {
32
- fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 || fireAnalyticsEvent({
33
- action: _analytics.ACTION.CLICKED,
34
- actionSubject: _analytics.ACTION_SUBJECT.BLOCK_MENU_ITEM,
35
- actionSubjectId: _analytics.ACTION_SUBJECT_ID.MOVE_UP_BLOCK,
36
- eventType: _analytics.EVENT_TYPE.UI,
37
- attributes: {
38
- inputMethod: _analytics.INPUT_METHOD.MOUSE
39
- }
40
- });
41
30
  api === null || api === void 0 || api.core.actions.execute(function (_ref3) {
42
- var _api$blockControls, _api$blockControls2;
31
+ var _api$analytics, _api$blockControls, _api$blockControls2;
43
32
  var tr = _ref3.tr;
33
+ var payload = {
34
+ action: _analytics.ACTION.CLICKED,
35
+ actionSubject: _analytics.ACTION_SUBJECT.BLOCK_MENU_ITEM,
36
+ attributes: {
37
+ inputMethod: _analytics.INPUT_METHOD.MOUSE,
38
+ menuItemName: _consts.BLOCK_MENU_ITEM_NAME.MOVE_UP
39
+ },
40
+ eventType: _analytics.EVENT_TYPE.UI
41
+ };
42
+ 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);
44
43
  api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || (_api$blockControls = _api$blockControls.commands) === null || _api$blockControls === void 0 || _api$blockControls.moveNodeWithBlockMenu(_types.DIRECTION.UP)({
45
44
  tr: tr
46
45
  });
@@ -1,7 +1,6 @@
1
1
  import React, { useCallback, createContext, useContext } from 'react';
2
2
  const BlockMenuContext = /*#__PURE__*/createContext({
3
- onDropdownOpenChanged: () => {},
4
- fireAnalyticsEvent: () => {}
3
+ onDropdownOpenChanged: () => {}
5
4
  });
6
5
  export const useBlockMenu = () => {
7
6
  const context = useContext(BlockMenuContext);
@@ -24,14 +23,9 @@ export const BlockMenuProvider = ({
24
23
  }), 1);
25
24
  }
26
25
  }, [api]);
27
- const fireAnalyticsEvent = useCallback(payload => {
28
- var _api$analytics;
29
- api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions.fireAnalyticsEvent(payload);
30
- }, [api]);
31
26
  return /*#__PURE__*/React.createElement(BlockMenuContext.Provider, {
32
27
  value: {
33
- onDropdownOpenChanged,
34
- fireAnalyticsEvent
28
+ onDropdownOpenChanged
35
29
  }
36
30
  }, children);
37
31
  };
@@ -68,8 +68,7 @@ const BlockMenu = ({
68
68
  };
69
69
  });
70
70
  const {
71
- onDropdownOpenChanged,
72
- fireAnalyticsEvent
71
+ onDropdownOpenChanged
73
72
  } = useBlockMenu();
74
73
  const targetHandleRef = editorView === null || editorView === void 0 ? void 0 : (_editorView$dom = editorView.dom) === null || _editorView$dom === void 0 ? void 0 : _editorView$dom.querySelector(DRAG_HANDLE_SELECTOR);
75
74
  const prevIsMenuOpenRef = useRef(false);
@@ -87,7 +86,8 @@ const BlockMenu = ({
87
86
 
88
87
  // Fire analytics event when block menu opens (only on first transition from closed to open)
89
88
  if (!prevIsMenuOpenRef.current && isMenuOpen) {
90
- fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 ? void 0 : fireAnalyticsEvent({
89
+ var _api$analytics;
90
+ api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions.fireAnalyticsEvent({
91
91
  action: ACTION.OPENED,
92
92
  actionSubject: ACTION_SUBJECT.BLOCK_MENU,
93
93
  eventType: EVENT_TYPE.UI,
@@ -100,7 +100,7 @@ const BlockMenu = ({
100
100
  // Update the previous state
101
101
  prevIsMenuOpenRef.current = isMenuOpen;
102
102
  api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 ? void 0 : _api$userIntent.commands.setCurrentUserIntent('blockMenuOpen'));
103
- }, [api, isMenuOpen, menuTriggerBy, selectedByShortcutORDragHandle, hasFocus, shouldShowBlockMenuForEmptyLine, currentUserIntent, fireAnalyticsEvent]);
103
+ }, [api, isMenuOpen, menuTriggerBy, selectedByShortcutORDragHandle, hasFocus, shouldShowBlockMenuForEmptyLine, currentUserIntent]);
104
104
  if (!isMenuOpen) {
105
105
  return null;
106
106
  }
@@ -1 +1,13 @@
1
- export const BLOCK_MENU_LABEL = 'Editor Block Menu';
1
+ export const BLOCK_MENU_LABEL = 'Editor Block Menu';
2
+
3
+ /**
4
+ * Constants for block menu analytics menu item names
5
+ */
6
+ export const BLOCK_MENU_ITEM_NAME = {
7
+ COPY_LINK_TO_BLOCK: 'copyLinkToBlock',
8
+ MOVE_UP: 'moveUp',
9
+ MOVE_DOWN: 'moveDown',
10
+ DELETE: 'delete',
11
+ FORMAT_MENU: 'formatMenu',
12
+ COPY_CONTENT: 'copyContent'
13
+ };
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { injectIntl, useIntl } from 'react-intl-next';
3
- import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
+ import { ACTION, ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
4
  import { messages } from '@atlaskit/editor-common/block-menu';
5
5
  import { copyHTMLToClipboard } from '@atlaskit/editor-common/clipboard';
6
6
  import { toDOM, copyDomNode } from '@atlaskit/editor-common/copy-button';
@@ -11,7 +11,7 @@ import { isTableSelected } from '@atlaskit/editor-tables/utils';
11
11
  import { ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
12
12
  import CopyIcon from '@atlaskit/icon/core/copy';
13
13
  import { fg } from '@atlaskit/platform-feature-flags';
14
- import { useBlockMenu } from './block-menu-provider';
14
+ import { BLOCK_MENU_ITEM_NAME } from './consts';
15
15
  const toDOMFromFragment = (fragment, schema) => {
16
16
  return DOMSerializer.fromSchema(schema).serializeFragment(fragment);
17
17
  };
@@ -21,19 +21,23 @@ const CopyBlockMenuItem = ({
21
21
  const {
22
22
  formatMessage
23
23
  } = useIntl();
24
- const {
25
- fireAnalyticsEvent
26
- } = useBlockMenu();
27
24
  const copyHandler = event => {
28
25
  var _api$selection, _api$selection$shared, _api$selection$shared2;
29
- fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 ? void 0 : fireAnalyticsEvent({
30
- action: ACTION.CLICKED,
31
- actionSubject: ACTION_SUBJECT.BLOCK_MENU_ITEM,
32
- actionSubjectId: ACTION_SUBJECT_ID.COPY_BLOCK,
33
- eventType: EVENT_TYPE.UI,
34
- attributes: {
35
- inputMethod: INPUT_METHOD.MOUSE
36
- }
26
+ api === null || api === void 0 ? void 0 : api.core.actions.execute(({
27
+ tr
28
+ }) => {
29
+ var _api$analytics, _api$analytics$action;
30
+ const payload = {
31
+ action: ACTION.CLICKED,
32
+ actionSubject: ACTION_SUBJECT.BLOCK_MENU_ITEM,
33
+ attributes: {
34
+ inputMethod: INPUT_METHOD.MOUSE,
35
+ menuItemName: BLOCK_MENU_ITEM_NAME.COPY_CONTENT
36
+ },
37
+ eventType: EVENT_TYPE.UI
38
+ };
39
+ 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(payload)(tr);
40
+ return tr;
37
41
  });
38
42
 
39
43
  // prevent click event from bubbling up to the ancestor elements
@@ -1,11 +1,11 @@
1
1
  import React, { useCallback } from 'react';
2
2
  import { useIntl, injectIntl } from 'react-intl-next';
3
- import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
+ import { ACTION, ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
4
  import { blockMenuMessages as messages } from '@atlaskit/editor-common/messages';
5
5
  import { ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
6
6
  import LinkIcon from '@atlaskit/icon/core/link';
7
7
  import { fg } from '@atlaskit/platform-feature-flags';
8
- import { useBlockMenu } from './block-menu-provider';
8
+ import { BLOCK_MENU_ITEM_NAME } from './consts';
9
9
  import { copyLink } from './utils/copyLink';
10
10
  import { isNestedNode } from './utils/isNestedNode';
11
11
  const CopyLinkDropdownItemContent = ({
@@ -15,23 +15,21 @@ const CopyLinkDropdownItemContent = ({
15
15
  const {
16
16
  formatMessage
17
17
  } = useIntl();
18
- const {
19
- fireAnalyticsEvent
20
- } = useBlockMenu();
21
18
  const handleClick = useCallback(() => {
22
- fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 ? void 0 : fireAnalyticsEvent({
23
- action: ACTION.CLICKED,
24
- actionSubject: ACTION_SUBJECT.BLOCK_MENU_ITEM,
25
- actionSubjectId: ACTION_SUBJECT_ID.COPY_LINK_TO_BLOCK,
26
- eventType: EVENT_TYPE.UI,
27
- attributes: {
28
- inputMethod: INPUT_METHOD.MOUSE
29
- }
30
- });
31
19
  api === null || api === void 0 ? void 0 : api.core.actions.execute(({
32
20
  tr
33
21
  }) => {
34
- var _api$blockControls, _api$blockControls$co;
22
+ var _api$analytics, _api$analytics$action, _api$blockControls, _api$blockControls$co;
23
+ const payload = {
24
+ action: ACTION.CLICKED,
25
+ actionSubject: ACTION_SUBJECT.BLOCK_MENU_ITEM,
26
+ attributes: {
27
+ inputMethod: INPUT_METHOD.MOUSE,
28
+ menuItemName: BLOCK_MENU_ITEM_NAME.COPY_LINK_TO_BLOCK
29
+ },
30
+ eventType: EVENT_TYPE.UI
31
+ };
32
+ 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(payload)(tr);
35
33
  api === null || api === void 0 ? void 0 : (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : (_api$blockControls$co = _api$blockControls.commands) === null || _api$blockControls$co === void 0 ? void 0 : _api$blockControls$co.toggleBlockMenu({
36
34
  closeMenu: true
37
35
  })({
@@ -41,7 +39,7 @@ const CopyLinkDropdownItemContent = ({
41
39
  });
42
40
  api === null || api === void 0 ? void 0 : api.core.actions.focus();
43
41
  return copyLink(config === null || config === void 0 ? void 0 : config.getLinkPath, config === null || config === void 0 ? void 0 : config.blockQueryParam, api);
44
- }, [config === null || config === void 0 ? void 0 : config.getLinkPath, config === null || config === void 0 ? void 0 : config.blockQueryParam, api, fireAnalyticsEvent]);
42
+ }, [config === null || config === void 0 ? void 0 : config.getLinkPath, config === null || config === void 0 ? void 0 : config.blockQueryParam, api]);
45
43
  const checkIsNestedNode = useCallback(() => {
46
44
  var _api$selection, _api$selection$shared, _api$selection$shared2, _api$blockControls2, _api$blockControls2$s, _api$blockControls2$s2;
47
45
  const selection = api === null || api === void 0 ? void 0 : (_api$selection = api.selection) === null || _api$selection === void 0 ? void 0 : (_api$selection$shared = _api$selection.sharedState) === null || _api$selection$shared === void 0 ? void 0 : (_api$selection$shared2 = _api$selection$shared.currentState()) === null || _api$selection$shared2 === void 0 ? void 0 : _api$selection$shared2.selection;
@@ -1,6 +1,6 @@
1
1
  import React, { useCallback, useEffect } from 'react';
2
2
  import { useIntl, injectIntl } from 'react-intl-next';
3
- import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
+ import { ACTION, ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
4
  import { messages } from '@atlaskit/editor-common/block-menu';
5
5
  import { blockMenuMessages } from '@atlaskit/editor-common/messages';
6
6
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
@@ -11,7 +11,7 @@ import { fg } from '@atlaskit/platform-feature-flags';
11
11
  import { Box } from '@atlaskit/primitives/box';
12
12
  import Text from '@atlaskit/primitives/text';
13
13
  import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
14
- import { useBlockMenu } from './block-menu-provider';
14
+ import { BLOCK_MENU_ITEM_NAME } from './consts';
15
15
  const DeleteDropdownItemContent = ({
16
16
  api
17
17
  }) => {
@@ -19,24 +19,22 @@ const DeleteDropdownItemContent = ({
19
19
  const {
20
20
  formatMessage
21
21
  } = useIntl();
22
- const {
23
- fireAnalyticsEvent
24
- } = useBlockMenu();
25
22
  const nodeTypes = Object.values((api === null || api === void 0 ? void 0 : (_api$core$sharedState = api.core.sharedState.currentState()) === null || _api$core$sharedState === void 0 ? void 0 : (_api$core$sharedState2 = _api$core$sharedState.schema) === null || _api$core$sharedState2 === void 0 ? void 0 : _api$core$sharedState2.nodes) || {});
26
23
  const onClick = () => {
27
- fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 ? void 0 : fireAnalyticsEvent({
28
- action: ACTION.CLICKED,
29
- actionSubject: ACTION_SUBJECT.BLOCK_MENU_ITEM,
30
- actionSubjectId: ACTION_SUBJECT_ID.DELETE_BLOCK,
31
- eventType: EVENT_TYPE.UI,
32
- attributes: {
33
- inputMethod: INPUT_METHOD.MOUSE
34
- }
35
- });
36
24
  api === null || api === void 0 ? void 0 : api.core.actions.execute(({
37
25
  tr
38
26
  }) => {
39
- var _api$blockControls, _api$blockControls$co;
27
+ var _api$analytics, _api$analytics$action, _api$blockControls, _api$blockControls$co;
28
+ const payload = {
29
+ action: ACTION.CLICKED,
30
+ actionSubject: ACTION_SUBJECT.BLOCK_MENU_ITEM,
31
+ attributes: {
32
+ inputMethod: INPUT_METHOD.MOUSE,
33
+ menuItemName: BLOCK_MENU_ITEM_NAME.DELETE
34
+ },
35
+ eventType: EVENT_TYPE.UI
36
+ };
37
+ 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(payload)(tr);
40
38
  const selection = tr.selection;
41
39
  let from = selection.$from.pos;
42
40
  let to = selection.$to.pos;
@@ -1,13 +1,13 @@
1
1
  import React, { useMemo, useCallback } from 'react';
2
2
  import { useIntl } from 'react-intl-next';
3
- import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
+ import { ACTION, ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
4
  import { messages } from '@atlaskit/editor-common/block-menu';
5
5
  import { blockMenuMessages } from '@atlaskit/editor-common/messages';
6
6
  import { ToolbarNestedDropdownMenu } from '@atlaskit/editor-toolbar';
7
7
  import ChangesIcon from '@atlaskit/icon/core/changes';
8
8
  import ChevronRightIcon from '@atlaskit/icon/core/chevron-right';
9
9
  import { fg } from '@atlaskit/platform-feature-flags';
10
- import { useBlockMenu } from './block-menu-provider';
10
+ import { BLOCK_MENU_ITEM_NAME } from './consts';
11
11
  import { checkIsFormatMenuHidden } from './utils/checkIsFormatMenuHidden';
12
12
  export const FormatMenuComponent = ({
13
13
  api,
@@ -16,24 +16,28 @@ export const FormatMenuComponent = ({
16
16
  const {
17
17
  formatMessage
18
18
  } = useIntl();
19
- const {
20
- fireAnalyticsEvent
21
- } = useBlockMenu();
22
19
  const text = fg('platform_editor_block_menu_patch_1') ? formatMessage(blockMenuMessages.turnInto) : formatMessage(messages.turnInto);
23
20
  const isDisabled = useMemo(() => {
24
21
  return fg('platform_editor_block_menu_for_disabled_nodes') ? checkIsFormatMenuHidden(api) : false;
25
22
  }, [api]);
26
23
  const handleClick = useCallback(() => {
27
- fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 ? void 0 : fireAnalyticsEvent({
28
- action: ACTION.CLICKED,
29
- actionSubject: ACTION_SUBJECT.BLOCK_MENU_ITEM,
30
- actionSubjectId: ACTION_SUBJECT_ID.FORMAT_MENU,
31
- eventType: EVENT_TYPE.UI,
32
- attributes: {
33
- inputMethod: INPUT_METHOD.MOUSE
34
- }
24
+ api === null || api === void 0 ? void 0 : api.core.actions.execute(({
25
+ tr
26
+ }) => {
27
+ var _api$analytics, _api$analytics$action;
28
+ const payload = {
29
+ action: ACTION.CLICKED,
30
+ actionSubject: ACTION_SUBJECT.BLOCK_MENU_ITEM,
31
+ attributes: {
32
+ inputMethod: INPUT_METHOD.MOUSE,
33
+ menuItemName: BLOCK_MENU_ITEM_NAME.FORMAT_MENU
34
+ },
35
+ eventType: EVENT_TYPE.UI
36
+ };
37
+ 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(payload)(tr);
38
+ return tr;
35
39
  });
36
- }, [fireAnalyticsEvent]);
40
+ }, [api]);
37
41
  return /*#__PURE__*/React.createElement(ToolbarNestedDropdownMenu, {
38
42
  text: text,
39
43
  elemBefore: /*#__PURE__*/React.createElement(ChangesIcon, {
@@ -1,21 +1,18 @@
1
1
  import React from 'react';
2
2
  import { useIntl, injectIntl } from 'react-intl-next';
3
- import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
+ import { ACTION, ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
4
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
5
5
  import { blockMenuMessages as messages } from '@atlaskit/editor-common/messages';
6
6
  import { DIRECTION } from '@atlaskit/editor-common/types';
7
7
  import { ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
8
8
  import ArrowDownIcon from '@atlaskit/icon/core/arrow-down';
9
- import { useBlockMenu } from './block-menu-provider';
9
+ import { BLOCK_MENU_ITEM_NAME } from './consts';
10
10
  const MoveDownDropdownItemContent = ({
11
11
  api
12
12
  }) => {
13
13
  const {
14
14
  formatMessage
15
15
  } = useIntl();
16
- const {
17
- fireAnalyticsEvent
18
- } = useBlockMenu();
19
16
  const {
20
17
  canMoveDown
21
18
  } = useSharedPluginStateWithSelector(api, ['blockControls'], ({
@@ -27,19 +24,20 @@ const MoveDownDropdownItemContent = ({
27
24
  };
28
25
  });
29
26
  const handleClick = () => {
30
- fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 ? void 0 : fireAnalyticsEvent({
31
- action: ACTION.CLICKED,
32
- actionSubject: ACTION_SUBJECT.BLOCK_MENU_ITEM,
33
- actionSubjectId: ACTION_SUBJECT_ID.MOVE_DOWN_BLOCK,
34
- eventType: EVENT_TYPE.UI,
35
- attributes: {
36
- inputMethod: INPUT_METHOD.MOUSE
37
- }
38
- });
39
27
  api === null || api === void 0 ? void 0 : api.core.actions.execute(({
40
28
  tr
41
29
  }) => {
42
- var _api$blockControls, _api$blockControls$co, _api$blockControls2, _api$blockControls2$c;
30
+ var _api$analytics, _api$analytics$action, _api$blockControls, _api$blockControls$co, _api$blockControls2, _api$blockControls2$c;
31
+ const payload = {
32
+ action: ACTION.CLICKED,
33
+ actionSubject: ACTION_SUBJECT.BLOCK_MENU_ITEM,
34
+ attributes: {
35
+ inputMethod: INPUT_METHOD.MOUSE,
36
+ menuItemName: BLOCK_MENU_ITEM_NAME.MOVE_DOWN
37
+ },
38
+ eventType: EVENT_TYPE.UI
39
+ };
40
+ 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(payload)(tr);
43
41
  api === null || api === void 0 ? void 0 : (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : (_api$blockControls$co = _api$blockControls.commands) === null || _api$blockControls$co === void 0 ? void 0 : _api$blockControls$co.moveNodeWithBlockMenu(DIRECTION.DOWN)({
44
42
  tr
45
43
  });
@@ -1,21 +1,18 @@
1
1
  import React from 'react';
2
2
  import { useIntl, injectIntl } from 'react-intl-next';
3
- import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
+ import { ACTION, ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
4
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
5
5
  import { blockMenuMessages as messages } from '@atlaskit/editor-common/messages';
6
6
  import { DIRECTION } from '@atlaskit/editor-common/types';
7
7
  import { ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
8
8
  import ArrowUpIcon from '@atlaskit/icon/core/arrow-up';
9
- import { useBlockMenu } from './block-menu-provider';
9
+ import { BLOCK_MENU_ITEM_NAME } from './consts';
10
10
  const MoveUpDropdownItemContent = ({
11
11
  api
12
12
  }) => {
13
13
  const {
14
14
  formatMessage
15
15
  } = useIntl();
16
- const {
17
- fireAnalyticsEvent
18
- } = useBlockMenu();
19
16
  const {
20
17
  canMoveUp
21
18
  } = useSharedPluginStateWithSelector(api, ['blockControls'], ({
@@ -27,19 +24,20 @@ const MoveUpDropdownItemContent = ({
27
24
  };
28
25
  });
29
26
  const handleClick = () => {
30
- fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 ? void 0 : fireAnalyticsEvent({
31
- action: ACTION.CLICKED,
32
- actionSubject: ACTION_SUBJECT.BLOCK_MENU_ITEM,
33
- actionSubjectId: ACTION_SUBJECT_ID.MOVE_UP_BLOCK,
34
- eventType: EVENT_TYPE.UI,
35
- attributes: {
36
- inputMethod: INPUT_METHOD.MOUSE
37
- }
38
- });
39
27
  api === null || api === void 0 ? void 0 : api.core.actions.execute(({
40
28
  tr
41
29
  }) => {
42
- var _api$blockControls, _api$blockControls$co, _api$blockControls2, _api$blockControls2$c;
30
+ var _api$analytics, _api$analytics$action, _api$blockControls, _api$blockControls$co, _api$blockControls2, _api$blockControls2$c;
31
+ const payload = {
32
+ action: ACTION.CLICKED,
33
+ actionSubject: ACTION_SUBJECT.BLOCK_MENU_ITEM,
34
+ attributes: {
35
+ inputMethod: INPUT_METHOD.MOUSE,
36
+ menuItemName: BLOCK_MENU_ITEM_NAME.MOVE_UP
37
+ },
38
+ eventType: EVENT_TYPE.UI
39
+ };
40
+ 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(payload)(tr);
43
41
  api === null || api === void 0 ? void 0 : (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : (_api$blockControls$co = _api$blockControls.commands) === null || _api$blockControls$co === void 0 ? void 0 : _api$blockControls$co.moveNodeWithBlockMenu(DIRECTION.UP)({
44
42
  tr
45
43
  });
@@ -1,7 +1,6 @@
1
1
  import React, { useCallback, createContext, useContext } from 'react';
2
2
  var BlockMenuContext = /*#__PURE__*/createContext({
3
- onDropdownOpenChanged: function onDropdownOpenChanged() {},
4
- fireAnalyticsEvent: function fireAnalyticsEvent() {}
3
+ onDropdownOpenChanged: function onDropdownOpenChanged() {}
5
4
  });
6
5
  export var useBlockMenu = function useBlockMenu() {
7
6
  var context = useContext(BlockMenuContext);
@@ -25,14 +24,9 @@ export var BlockMenuProvider = function BlockMenuProvider(_ref) {
25
24
  }, 1);
26
25
  }
27
26
  }, [api]);
28
- var fireAnalyticsEvent = useCallback(function (payload) {
29
- var _api$analytics;
30
- api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.fireAnalyticsEvent(payload);
31
- }, [api]);
32
27
  return /*#__PURE__*/React.createElement(BlockMenuContext.Provider, {
33
28
  value: {
34
- onDropdownOpenChanged: onDropdownOpenChanged,
35
- fireAnalyticsEvent: fireAnalyticsEvent
29
+ onDropdownOpenChanged: onDropdownOpenChanged
36
30
  }
37
31
  }, children);
38
32
  };
@@ -71,8 +71,7 @@ var BlockMenu = function BlockMenu(_ref2) {
71
71
  currentUserIntent = _useSharedPluginState.currentUserIntent,
72
72
  openedViaKeyboard = _useSharedPluginState.openedViaKeyboard;
73
73
  var _useBlockMenu = useBlockMenu(),
74
- onDropdownOpenChanged = _useBlockMenu.onDropdownOpenChanged,
75
- fireAnalyticsEvent = _useBlockMenu.fireAnalyticsEvent;
74
+ onDropdownOpenChanged = _useBlockMenu.onDropdownOpenChanged;
76
75
  var targetHandleRef = editorView === null || editorView === void 0 || (_editorView$dom = editorView.dom) === null || _editorView$dom === void 0 ? void 0 : _editorView$dom.querySelector(DRAG_HANDLE_SELECTOR);
77
76
  var prevIsMenuOpenRef = useRef(false);
78
77
  var hasFocus = expValEqualsNoExposure('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true) ? (_ref3 = (editorView === null || editorView === void 0 ? void 0 : editorView.hasFocus()) || document.activeElement === targetHandleRef) !== null && _ref3 !== void 0 ? _ref3 : false : (_editorView$hasFocus = editorView === null || editorView === void 0 ? void 0 : editorView.hasFocus()) !== null && _editorView$hasFocus !== void 0 ? _editorView$hasFocus : false;
@@ -89,7 +88,8 @@ var BlockMenu = function BlockMenu(_ref2) {
89
88
 
90
89
  // Fire analytics event when block menu opens (only on first transition from closed to open)
91
90
  if (!prevIsMenuOpenRef.current && isMenuOpen) {
92
- fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 || fireAnalyticsEvent({
91
+ var _api$analytics;
92
+ api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.fireAnalyticsEvent({
93
93
  action: ACTION.OPENED,
94
94
  actionSubject: ACTION_SUBJECT.BLOCK_MENU,
95
95
  eventType: EVENT_TYPE.UI,
@@ -102,7 +102,7 @@ var BlockMenu = function BlockMenu(_ref2) {
102
102
  // Update the previous state
103
103
  prevIsMenuOpenRef.current = isMenuOpen;
104
104
  api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 || (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 ? void 0 : _api$userIntent.commands.setCurrentUserIntent('blockMenuOpen'));
105
- }, [api, isMenuOpen, menuTriggerBy, selectedByShortcutORDragHandle, hasFocus, shouldShowBlockMenuForEmptyLine, currentUserIntent, fireAnalyticsEvent]);
105
+ }, [api, isMenuOpen, menuTriggerBy, selectedByShortcutORDragHandle, hasFocus, shouldShowBlockMenuForEmptyLine, currentUserIntent]);
106
106
  if (!isMenuOpen) {
107
107
  return null;
108
108
  }
@@ -1 +1,13 @@
1
- export var BLOCK_MENU_LABEL = 'Editor Block Menu';
1
+ export var BLOCK_MENU_LABEL = 'Editor Block Menu';
2
+
3
+ /**
4
+ * Constants for block menu analytics menu item names
5
+ */
6
+ export var BLOCK_MENU_ITEM_NAME = {
7
+ COPY_LINK_TO_BLOCK: 'copyLinkToBlock',
8
+ MOVE_UP: 'moveUp',
9
+ MOVE_DOWN: 'moveDown',
10
+ DELETE: 'delete',
11
+ FORMAT_MENU: 'formatMenu',
12
+ COPY_CONTENT: 'copyContent'
13
+ };
@@ -3,7 +3,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
3
3
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
4
  import React from 'react';
5
5
  import { injectIntl, useIntl } from 'react-intl-next';
6
- import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
6
+ import { ACTION, ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
7
7
  import { messages } from '@atlaskit/editor-common/block-menu';
8
8
  import { copyHTMLToClipboard } from '@atlaskit/editor-common/clipboard';
9
9
  import { toDOM, copyDomNode } from '@atlaskit/editor-common/copy-button';
@@ -14,7 +14,7 @@ import { isTableSelected } from '@atlaskit/editor-tables/utils';
14
14
  import { ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
15
15
  import CopyIcon from '@atlaskit/icon/core/copy';
16
16
  import { fg } from '@atlaskit/platform-feature-flags';
17
- import { useBlockMenu } from './block-menu-provider';
17
+ import { BLOCK_MENU_ITEM_NAME } from './consts';
18
18
  var toDOMFromFragment = function toDOMFromFragment(fragment, schema) {
19
19
  return DOMSerializer.fromSchema(schema).serializeFragment(fragment);
20
20
  };
@@ -22,18 +22,22 @@ var CopyBlockMenuItem = function CopyBlockMenuItem(_ref) {
22
22
  var api = _ref.api;
23
23
  var _useIntl = useIntl(),
24
24
  formatMessage = _useIntl.formatMessage;
25
- var _useBlockMenu = useBlockMenu(),
26
- fireAnalyticsEvent = _useBlockMenu.fireAnalyticsEvent;
27
25
  var copyHandler = function copyHandler(event) {
28
26
  var _api$selection;
29
- fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 || fireAnalyticsEvent({
30
- action: ACTION.CLICKED,
31
- actionSubject: ACTION_SUBJECT.BLOCK_MENU_ITEM,
32
- actionSubjectId: ACTION_SUBJECT_ID.COPY_BLOCK,
33
- eventType: EVENT_TYPE.UI,
34
- attributes: {
35
- inputMethod: INPUT_METHOD.MOUSE
36
- }
27
+ api === null || api === void 0 || api.core.actions.execute(function (_ref2) {
28
+ var _api$analytics;
29
+ var tr = _ref2.tr;
30
+ var payload = {
31
+ action: ACTION.CLICKED,
32
+ actionSubject: ACTION_SUBJECT.BLOCK_MENU_ITEM,
33
+ attributes: {
34
+ inputMethod: INPUT_METHOD.MOUSE,
35
+ menuItemName: BLOCK_MENU_ITEM_NAME.COPY_CONTENT
36
+ },
37
+ eventType: EVENT_TYPE.UI
38
+ };
39
+ 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);
40
+ return tr;
37
41
  });
38
42
 
39
43
  // prevent click event from bubbling up to the ancestor elements
@@ -1,11 +1,11 @@
1
1
  import React, { useCallback } from 'react';
2
2
  import { useIntl, injectIntl } from 'react-intl-next';
3
- import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
+ import { ACTION, ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
4
  import { blockMenuMessages as messages } from '@atlaskit/editor-common/messages';
5
5
  import { ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
6
6
  import LinkIcon from '@atlaskit/icon/core/link';
7
7
  import { fg } from '@atlaskit/platform-feature-flags';
8
- import { useBlockMenu } from './block-menu-provider';
8
+ import { BLOCK_MENU_ITEM_NAME } from './consts';
9
9
  import { copyLink } from './utils/copyLink';
10
10
  import { isNestedNode } from './utils/isNestedNode';
11
11
  var CopyLinkDropdownItemContent = function CopyLinkDropdownItemContent(_ref) {
@@ -13,21 +13,20 @@ var CopyLinkDropdownItemContent = function CopyLinkDropdownItemContent(_ref) {
13
13
  config = _ref.config;
14
14
  var _useIntl = useIntl(),
15
15
  formatMessage = _useIntl.formatMessage;
16
- var _useBlockMenu = useBlockMenu(),
17
- fireAnalyticsEvent = _useBlockMenu.fireAnalyticsEvent;
18
16
  var handleClick = useCallback(function () {
19
- fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 || fireAnalyticsEvent({
20
- action: ACTION.CLICKED,
21
- actionSubject: ACTION_SUBJECT.BLOCK_MENU_ITEM,
22
- actionSubjectId: ACTION_SUBJECT_ID.COPY_LINK_TO_BLOCK,
23
- eventType: EVENT_TYPE.UI,
24
- attributes: {
25
- inputMethod: INPUT_METHOD.MOUSE
26
- }
27
- });
28
17
  api === null || api === void 0 || api.core.actions.execute(function (_ref2) {
29
- var _api$blockControls;
18
+ var _api$analytics, _api$blockControls;
30
19
  var tr = _ref2.tr;
20
+ var payload = {
21
+ action: ACTION.CLICKED,
22
+ actionSubject: ACTION_SUBJECT.BLOCK_MENU_ITEM,
23
+ attributes: {
24
+ inputMethod: INPUT_METHOD.MOUSE,
25
+ menuItemName: BLOCK_MENU_ITEM_NAME.COPY_LINK_TO_BLOCK
26
+ },
27
+ eventType: EVENT_TYPE.UI
28
+ };
29
+ 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);
31
30
  api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || (_api$blockControls = _api$blockControls.commands) === null || _api$blockControls === void 0 || _api$blockControls.toggleBlockMenu({
32
31
  closeMenu: true
33
32
  })({
@@ -37,7 +36,7 @@ var CopyLinkDropdownItemContent = function CopyLinkDropdownItemContent(_ref) {
37
36
  });
38
37
  api === null || api === void 0 || api.core.actions.focus();
39
38
  return copyLink(config === null || config === void 0 ? void 0 : config.getLinkPath, config === null || config === void 0 ? void 0 : config.blockQueryParam, api);
40
- }, [config === null || config === void 0 ? void 0 : config.getLinkPath, config === null || config === void 0 ? void 0 : config.blockQueryParam, api, fireAnalyticsEvent]);
39
+ }, [config === null || config === void 0 ? void 0 : config.getLinkPath, config === null || config === void 0 ? void 0 : config.blockQueryParam, api]);
41
40
  var checkIsNestedNode = useCallback(function () {
42
41
  var _api$selection, _api$blockControls2;
43
42
  var selection = api === null || api === void 0 || (_api$selection = api.selection) === null || _api$selection === void 0 || (_api$selection = _api$selection.sharedState) === null || _api$selection === void 0 || (_api$selection = _api$selection.currentState()) === null || _api$selection === void 0 ? void 0 : _api$selection.selection;
@@ -1,6 +1,6 @@
1
1
  import React, { useCallback, useEffect } from 'react';
2
2
  import { useIntl, injectIntl } from 'react-intl-next';
3
- import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
+ import { ACTION, ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
4
  import { messages } from '@atlaskit/editor-common/block-menu';
5
5
  import { blockMenuMessages } from '@atlaskit/editor-common/messages';
6
6
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
@@ -11,28 +11,27 @@ import { fg } from '@atlaskit/platform-feature-flags';
11
11
  import { Box } from '@atlaskit/primitives/box';
12
12
  import Text from '@atlaskit/primitives/text';
13
13
  import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
14
- import { useBlockMenu } from './block-menu-provider';
14
+ import { BLOCK_MENU_ITEM_NAME } from './consts';
15
15
  var DeleteDropdownItemContent = function DeleteDropdownItemContent(_ref) {
16
16
  var _api$core$sharedState;
17
17
  var api = _ref.api;
18
18
  var _useIntl = useIntl(),
19
19
  formatMessage = _useIntl.formatMessage;
20
- var _useBlockMenu = useBlockMenu(),
21
- fireAnalyticsEvent = _useBlockMenu.fireAnalyticsEvent;
22
20
  var nodeTypes = Object.values((api === null || api === void 0 || (_api$core$sharedState = api.core.sharedState.currentState()) === null || _api$core$sharedState === void 0 || (_api$core$sharedState = _api$core$sharedState.schema) === null || _api$core$sharedState === void 0 ? void 0 : _api$core$sharedState.nodes) || {});
23
21
  var onClick = function onClick() {
24
- fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 || fireAnalyticsEvent({
25
- action: ACTION.CLICKED,
26
- actionSubject: ACTION_SUBJECT.BLOCK_MENU_ITEM,
27
- actionSubjectId: ACTION_SUBJECT_ID.DELETE_BLOCK,
28
- eventType: EVENT_TYPE.UI,
29
- attributes: {
30
- inputMethod: INPUT_METHOD.MOUSE
31
- }
32
- });
33
22
  api === null || api === void 0 || api.core.actions.execute(function (_ref2) {
34
- var _api$blockControls;
23
+ var _api$analytics, _api$blockControls;
35
24
  var tr = _ref2.tr;
25
+ var payload = {
26
+ action: ACTION.CLICKED,
27
+ actionSubject: ACTION_SUBJECT.BLOCK_MENU_ITEM,
28
+ attributes: {
29
+ inputMethod: INPUT_METHOD.MOUSE,
30
+ menuItemName: BLOCK_MENU_ITEM_NAME.DELETE
31
+ },
32
+ eventType: EVENT_TYPE.UI
33
+ };
34
+ 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);
36
35
  var selection = tr.selection;
37
36
  var from = selection.$from.pos;
38
37
  var to = selection.$to.pos;
@@ -1,36 +1,40 @@
1
1
  import React, { useMemo, useCallback } from 'react';
2
2
  import { useIntl } from 'react-intl-next';
3
- import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
+ import { ACTION, ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
4
  import { messages } from '@atlaskit/editor-common/block-menu';
5
5
  import { blockMenuMessages } from '@atlaskit/editor-common/messages';
6
6
  import { ToolbarNestedDropdownMenu } from '@atlaskit/editor-toolbar';
7
7
  import ChangesIcon from '@atlaskit/icon/core/changes';
8
8
  import ChevronRightIcon from '@atlaskit/icon/core/chevron-right';
9
9
  import { fg } from '@atlaskit/platform-feature-flags';
10
- import { useBlockMenu } from './block-menu-provider';
10
+ import { BLOCK_MENU_ITEM_NAME } from './consts';
11
11
  import { checkIsFormatMenuHidden } from './utils/checkIsFormatMenuHidden';
12
12
  export var FormatMenuComponent = function FormatMenuComponent(_ref) {
13
13
  var api = _ref.api,
14
14
  children = _ref.children;
15
15
  var _useIntl = useIntl(),
16
16
  formatMessage = _useIntl.formatMessage;
17
- var _useBlockMenu = useBlockMenu(),
18
- fireAnalyticsEvent = _useBlockMenu.fireAnalyticsEvent;
19
17
  var text = fg('platform_editor_block_menu_patch_1') ? formatMessage(blockMenuMessages.turnInto) : formatMessage(messages.turnInto);
20
18
  var isDisabled = useMemo(function () {
21
19
  return fg('platform_editor_block_menu_for_disabled_nodes') ? checkIsFormatMenuHidden(api) : false;
22
20
  }, [api]);
23
21
  var handleClick = useCallback(function () {
24
- fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 || fireAnalyticsEvent({
25
- action: ACTION.CLICKED,
26
- actionSubject: ACTION_SUBJECT.BLOCK_MENU_ITEM,
27
- actionSubjectId: ACTION_SUBJECT_ID.FORMAT_MENU,
28
- eventType: EVENT_TYPE.UI,
29
- attributes: {
30
- inputMethod: INPUT_METHOD.MOUSE
31
- }
22
+ api === null || api === void 0 || api.core.actions.execute(function (_ref2) {
23
+ var _api$analytics;
24
+ var tr = _ref2.tr;
25
+ var payload = {
26
+ action: ACTION.CLICKED,
27
+ actionSubject: ACTION_SUBJECT.BLOCK_MENU_ITEM,
28
+ attributes: {
29
+ inputMethod: INPUT_METHOD.MOUSE,
30
+ menuItemName: BLOCK_MENU_ITEM_NAME.FORMAT_MENU
31
+ },
32
+ eventType: EVENT_TYPE.UI
33
+ };
34
+ 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);
35
+ return tr;
32
36
  });
33
- }, [fireAnalyticsEvent]);
37
+ }, [api]);
34
38
  return /*#__PURE__*/React.createElement(ToolbarNestedDropdownMenu, {
35
39
  text: text,
36
40
  elemBefore: /*#__PURE__*/React.createElement(ChangesIcon, {
@@ -1,18 +1,16 @@
1
1
  import React from 'react';
2
2
  import { useIntl, injectIntl } from 'react-intl-next';
3
- import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
+ import { ACTION, ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
4
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
5
5
  import { blockMenuMessages as messages } from '@atlaskit/editor-common/messages';
6
6
  import { DIRECTION } from '@atlaskit/editor-common/types';
7
7
  import { ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
8
8
  import ArrowDownIcon from '@atlaskit/icon/core/arrow-down';
9
- import { useBlockMenu } from './block-menu-provider';
9
+ import { BLOCK_MENU_ITEM_NAME } from './consts';
10
10
  var MoveDownDropdownItemContent = function MoveDownDropdownItemContent(_ref) {
11
11
  var api = _ref.api;
12
12
  var _useIntl = useIntl(),
13
13
  formatMessage = _useIntl.formatMessage;
14
- var _useBlockMenu = useBlockMenu(),
15
- fireAnalyticsEvent = _useBlockMenu.fireAnalyticsEvent;
16
14
  var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['blockControls'], function (_ref2) {
17
15
  var _blockControlsState$b;
18
16
  var blockControlsState = _ref2.blockControlsState;
@@ -22,18 +20,19 @@ var MoveDownDropdownItemContent = function MoveDownDropdownItemContent(_ref) {
22
20
  }),
23
21
  canMoveDown = _useSharedPluginState.canMoveDown;
24
22
  var handleClick = function handleClick() {
25
- fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 || fireAnalyticsEvent({
26
- action: ACTION.CLICKED,
27
- actionSubject: ACTION_SUBJECT.BLOCK_MENU_ITEM,
28
- actionSubjectId: ACTION_SUBJECT_ID.MOVE_DOWN_BLOCK,
29
- eventType: EVENT_TYPE.UI,
30
- attributes: {
31
- inputMethod: INPUT_METHOD.MOUSE
32
- }
33
- });
34
23
  api === null || api === void 0 || api.core.actions.execute(function (_ref3) {
35
- var _api$blockControls, _api$blockControls2;
24
+ var _api$analytics, _api$blockControls, _api$blockControls2;
36
25
  var tr = _ref3.tr;
26
+ var payload = {
27
+ action: ACTION.CLICKED,
28
+ actionSubject: ACTION_SUBJECT.BLOCK_MENU_ITEM,
29
+ attributes: {
30
+ inputMethod: INPUT_METHOD.MOUSE,
31
+ menuItemName: BLOCK_MENU_ITEM_NAME.MOVE_DOWN
32
+ },
33
+ eventType: EVENT_TYPE.UI
34
+ };
35
+ 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
36
  api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || (_api$blockControls = _api$blockControls.commands) === null || _api$blockControls === void 0 || _api$blockControls.moveNodeWithBlockMenu(DIRECTION.DOWN)({
38
37
  tr: tr
39
38
  });
@@ -1,18 +1,16 @@
1
1
  import React from 'react';
2
2
  import { useIntl, injectIntl } from 'react-intl-next';
3
- import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
+ import { ACTION, ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
4
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
5
5
  import { blockMenuMessages as messages } from '@atlaskit/editor-common/messages';
6
6
  import { DIRECTION } from '@atlaskit/editor-common/types';
7
7
  import { ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
8
8
  import ArrowUpIcon from '@atlaskit/icon/core/arrow-up';
9
- import { useBlockMenu } from './block-menu-provider';
9
+ import { BLOCK_MENU_ITEM_NAME } from './consts';
10
10
  var MoveUpDropdownItemContent = function MoveUpDropdownItemContent(_ref) {
11
11
  var api = _ref.api;
12
12
  var _useIntl = useIntl(),
13
13
  formatMessage = _useIntl.formatMessage;
14
- var _useBlockMenu = useBlockMenu(),
15
- fireAnalyticsEvent = _useBlockMenu.fireAnalyticsEvent;
16
14
  var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['blockControls'], function (_ref2) {
17
15
  var _blockControlsState$b;
18
16
  var blockControlsState = _ref2.blockControlsState;
@@ -22,18 +20,19 @@ var MoveUpDropdownItemContent = function MoveUpDropdownItemContent(_ref) {
22
20
  }),
23
21
  canMoveUp = _useSharedPluginState.canMoveUp;
24
22
  var handleClick = function handleClick() {
25
- fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 || fireAnalyticsEvent({
26
- action: ACTION.CLICKED,
27
- actionSubject: ACTION_SUBJECT.BLOCK_MENU_ITEM,
28
- actionSubjectId: ACTION_SUBJECT_ID.MOVE_UP_BLOCK,
29
- eventType: EVENT_TYPE.UI,
30
- attributes: {
31
- inputMethod: INPUT_METHOD.MOUSE
32
- }
33
- });
34
23
  api === null || api === void 0 || api.core.actions.execute(function (_ref3) {
35
- var _api$blockControls, _api$blockControls2;
24
+ var _api$analytics, _api$blockControls, _api$blockControls2;
36
25
  var tr = _ref3.tr;
26
+ var payload = {
27
+ action: ACTION.CLICKED,
28
+ actionSubject: ACTION_SUBJECT.BLOCK_MENU_ITEM,
29
+ attributes: {
30
+ inputMethod: INPUT_METHOD.MOUSE,
31
+ menuItemName: BLOCK_MENU_ITEM_NAME.MOVE_UP
32
+ },
33
+ eventType: EVENT_TYPE.UI
34
+ };
35
+ 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
36
  api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || (_api$blockControls = _api$blockControls.commands) === null || _api$blockControls === void 0 || _api$blockControls.moveNodeWithBlockMenu(DIRECTION.UP)({
38
37
  tr: tr
39
38
  });
@@ -1,14 +1,11 @@
1
1
  import React from 'react';
2
- import type { BlockMenuEventPayload } from '@atlaskit/editor-common/analytics';
3
2
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
4
3
  import type { BlockMenuPlugin } from '../blockMenuPluginType';
5
4
  type BlockMenuProviderProps = {
6
5
  api: ExtractInjectionAPI<BlockMenuPlugin> | undefined;
7
6
  children: React.ReactNode;
8
7
  };
9
- type FireAnalyticsEvent = (payload: BlockMenuEventPayload) => void | undefined;
10
8
  export type BlockMenuContextType = {
11
- fireAnalyticsEvent?: FireAnalyticsEvent;
12
9
  /**
13
10
  * Callback for when the dropdown is open/closed. Receives an object with `isOpen` state.
14
11
  *
@@ -1 +1,12 @@
1
1
  export declare const BLOCK_MENU_LABEL = "Editor Block Menu";
2
+ /**
3
+ * Constants for block menu analytics menu item names
4
+ */
5
+ export declare const BLOCK_MENU_ITEM_NAME: {
6
+ readonly COPY_LINK_TO_BLOCK: "copyLinkToBlock";
7
+ readonly MOVE_UP: "moveUp";
8
+ readonly MOVE_DOWN: "moveDown";
9
+ readonly DELETE: "delete";
10
+ readonly FORMAT_MENU: "formatMenu";
11
+ readonly COPY_CONTENT: "copyContent";
12
+ };
@@ -1,14 +1,11 @@
1
1
  import React from 'react';
2
- import type { BlockMenuEventPayload } from '@atlaskit/editor-common/analytics';
3
2
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
4
3
  import type { BlockMenuPlugin } from '../blockMenuPluginType';
5
4
  type BlockMenuProviderProps = {
6
5
  api: ExtractInjectionAPI<BlockMenuPlugin> | undefined;
7
6
  children: React.ReactNode;
8
7
  };
9
- type FireAnalyticsEvent = (payload: BlockMenuEventPayload) => void | undefined;
10
8
  export type BlockMenuContextType = {
11
- fireAnalyticsEvent?: FireAnalyticsEvent;
12
9
  /**
13
10
  * Callback for when the dropdown is open/closed. Receives an object with `isOpen` state.
14
11
  *
@@ -1 +1,12 @@
1
1
  export declare const BLOCK_MENU_LABEL = "Editor Block Menu";
2
+ /**
3
+ * Constants for block menu analytics menu item names
4
+ */
5
+ export declare const BLOCK_MENU_ITEM_NAME: {
6
+ readonly COPY_LINK_TO_BLOCK: "copyLinkToBlock";
7
+ readonly MOVE_UP: "moveUp";
8
+ readonly MOVE_DOWN: "moveDown";
9
+ readonly DELETE: "delete";
10
+ readonly FORMAT_MENU: "formatMenu";
11
+ readonly COPY_CONTENT: "copyContent";
12
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-menu",
3
- "version": "4.0.6",
3
+ "version": "4.0.7",
4
4
  "description": "BlockMenu plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",