@atlaskit/editor-plugin-block-menu 4.0.6 → 4.0.8
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 +14 -0
- package/dist/cjs/ui/block-menu-provider.js +2 -8
- package/dist/cjs/ui/block-menu.js +4 -4
- package/dist/cjs/ui/consts.js +14 -2
- package/dist/cjs/ui/copy-block.js +15 -11
- package/dist/cjs/ui/copy-link.js +13 -14
- package/dist/cjs/ui/delete-button.js +12 -13
- package/dist/cjs/ui/format-menu-nested.js +16 -12
- package/dist/cjs/ui/move-down.js +12 -13
- package/dist/cjs/ui/move-up.js +12 -13
- package/dist/es2019/ui/block-menu-provider.js +2 -8
- package/dist/es2019/ui/block-menu.js +4 -4
- package/dist/es2019/ui/consts.js +13 -1
- package/dist/es2019/ui/copy-block.js +17 -13
- package/dist/es2019/ui/copy-link.js +14 -16
- package/dist/es2019/ui/delete-button.js +13 -15
- package/dist/es2019/ui/format-menu-nested.js +18 -14
- package/dist/es2019/ui/move-down.js +13 -15
- package/dist/es2019/ui/move-up.js +13 -15
- package/dist/esm/ui/block-menu-provider.js +2 -8
- package/dist/esm/ui/block-menu.js +4 -4
- package/dist/esm/ui/consts.js +13 -1
- package/dist/esm/ui/copy-block.js +16 -12
- package/dist/esm/ui/copy-link.js +14 -15
- package/dist/esm/ui/delete-button.js +13 -14
- package/dist/esm/ui/format-menu-nested.js +17 -13
- package/dist/esm/ui/move-down.js +13 -14
- package/dist/esm/ui/move-up.js +13 -14
- package/dist/types/ui/block-menu-provider.d.ts +0 -3
- package/dist/types/ui/consts.d.ts +11 -0
- package/dist/types-ts4.5/ui/block-menu-provider.d.ts +0 -3
- package/dist/types-ts4.5/ui/consts.d.ts +11 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-menu
|
|
2
2
|
|
|
3
|
+
## 4.0.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 4.0.7
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`eb4899e5362e5`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/eb4899e5362e5) -
|
|
14
|
+
Update BlockMenuItemClicked event payload
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
|
|
3
17
|
## 4.0.6
|
|
4
18
|
|
|
5
19
|
### 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
|
-
|
|
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
|
|
113
|
+
}, [api, isMenuOpen, menuTriggerBy, selectedByShortcutORDragHandle, hasFocus, shouldShowBlockMenuForEmptyLine, currentUserIntent]);
|
|
114
114
|
if (!isMenuOpen) {
|
|
115
115
|
return null;
|
|
116
116
|
}
|
package/dist/cjs/ui/consts.js
CHANGED
|
@@ -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
|
|
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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
package/dist/cjs/ui/copy-link.js
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
}, [
|
|
46
|
+
}, [api]);
|
|
43
47
|
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarNestedDropdownMenu, {
|
|
44
48
|
text: text,
|
|
45
49
|
elemBefore: /*#__PURE__*/_react.default.createElement(_changes.default, {
|
package/dist/cjs/ui/move-down.js
CHANGED
|
@@ -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
|
|
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
|
});
|
package/dist/cjs/ui/move-up.js
CHANGED
|
@@ -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
|
|
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
|
-
|
|
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
|
|
103
|
+
}, [api, isMenuOpen, menuTriggerBy, selectedByShortcutORDragHandle, hasFocus, shouldShowBlockMenuForEmptyLine, currentUserIntent]);
|
|
104
104
|
if (!isMenuOpen) {
|
|
105
105
|
return null;
|
|
106
106
|
}
|
package/dist/es2019/ui/consts.js
CHANGED
|
@@ -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,
|
|
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 {
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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,
|
|
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 {
|
|
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
|
|
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,
|
|
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 {
|
|
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;
|