@atlaskit/editor-plugin-tasks-and-decisions
Version:
Tasks and decisions plugin for @atlaskit/editor-core
35 lines • 1.56 kB
JavaScript
import React from 'react';
import { useIntl } from 'react-intl';
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
import { blockMenuMessages } from '@atlaskit/editor-common/messages';
import { ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
import DecisionIcon from '@atlaskit/icon/core/decision';
var NODE_NAME = 'decisionList';
export var DecisionListBlockMenuItem = function DecisionListBlockMenuItem(_ref) {
var api = _ref.api;
var _useIntl = useIntl(),
formatMessage = _useIntl.formatMessage;
var onClick = function onClick(event) {
var triggeredFrom = event.nativeEvent instanceof KeyboardEvent || event.nativeEvent.detail === 0 ? INPUT_METHOD.KEYBOARD : INPUT_METHOD.MOUSE;
var inputMethod = INPUT_METHOD.BLOCK_MENU;
api === null || api === void 0 || api.core.actions.execute(function (_ref2) {
var _api$blockMenu;
var tr = _ref2.tr;
var command = api === null || api === void 0 || (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 ? void 0 : _api$blockMenu.commands.transformNode(tr.doc.type.schema.nodes.decisionList, {
inputMethod: inputMethod,
triggeredFrom: triggeredFrom,
targetTypeName: NODE_NAME
});
return command ? command({
tr: tr
}) : null;
});
};
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
onClick: onClick,
elemBefore: /*#__PURE__*/React.createElement(DecisionIcon, {
label: "",
size: "small"
})
}, formatMessage(blockMenuMessages.decisionList));
};