UNPKG

@atlaskit/editor-plugin-mentions

Version:

Mentions plugin for @atlaskit/editor-core

53 lines 2.65 kB
import _classCallCheck from "@babel/runtime/helpers/classCallCheck"; import _createClass from "@babel/runtime/helpers/createClass"; import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn"; import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf"; import _inherits from "@babel/runtime/helpers/inherits"; import _defineProperty from "@babel/runtime/helpers/defineProperty"; function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); } function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } import React, { PureComponent } from 'react'; import { injectIntl } from 'react-intl'; import { mentionMessages as messages } from '@atlaskit/editor-common/messages'; import { TOOLBAR_BUTTON, ToolbarButton } from '@atlaskit/editor-common/ui-menu'; import MentionIcon from '@atlaskit/icon/core/mention'; // Ignored via go/ees005 // eslint-disable-next-line @repo/internal/react/no-class-components var ToolbarMention = /*#__PURE__*/function (_PureComponent) { function ToolbarMention() { var _this; _classCallCheck(this, ToolbarMention); for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } _this = _callSuper(this, ToolbarMention, [].concat(args)); _defineProperty(_this, "handleInsertMention", function () { if (!_this.props.editorView) { return false; } _this.props.onInsertMention(); return true; }); return _this; } _inherits(ToolbarMention, _PureComponent); return _createClass(ToolbarMention, [{ key: "render", value: function render() { var mentionStringTranslated = this.props.intl.formatMessage(messages.mentionsIconLabel); return /*#__PURE__*/React.createElement(ToolbarButton, { testId: this.props.testId, buttonId: TOOLBAR_BUTTON.MENTION, spacing: "none", onClick: this.handleInsertMention, disabled: this.props.isDisabled, title: mentionStringTranslated + '@', iconBefore: /*#__PURE__*/React.createElement(MentionIcon, { label: mentionStringTranslated }) }); } }]); }(PureComponent); // eslint-disable-next-line @typescript-eslint/ban-types var _default_1 = injectIntl(ToolbarMention); export default _default_1;