@atlaskit/editor-plugin-mentions
Version:
Mentions plugin for @atlaskit/editor-core
38 lines (37 loc) • 1.39 kB
JavaScript
import _defineProperty from "@babel/runtime/helpers/defineProperty";
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
class ToolbarMention extends PureComponent {
constructor(...args) {
super(...args);
_defineProperty(this, "handleInsertMention", () => {
if (!this.props.editorView) {
return false;
}
this.props.onInsertMention();
return true;
});
}
render() {
const 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
})
});
}
}
// eslint-disable-next-line @typescript-eslint/ban-types
const _default_1 = injectIntl(ToolbarMention);
export default _default_1;