@atlaskit/editor-plugin-mentions
Version:
Mentions plugin for @atlaskit/editor-core
51 lines (50 loc) • 2.45 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getMentionQuickInsertComponents = void 0;
var _react = _interopRequireDefault(require("react"));
var _messages = require("@atlaskit/editor-common/messages");
var _createQuickInsertMatcher = require("@atlaskit/editor-common/quick-insert/create-quick-insert-matcher");
var _keys = require("@atlaskit/editor-common/quick-insert/keys");
var _rank = require("@atlaskit/editor-common/quick-insert/rank");
var _MentionQuickInsertMenuItem = require("./MentionQuickInsertMenuItem");
var previewImageUrls = {
light: 'https://dam-cdn.atl.orangelogic.com/AssetLink/02107p5maex03pfb4s04rw7i4hbk5jj0.png',
dark: 'https://dam-cdn.atl.orangelogic.com/AssetLink/q3254137y85cxldh4osht5k5c7q88572.png'
};
var getMentionQuickInsertComponents = exports.getMentionQuickInsertComponents = function getMentionQuickInsertComponents(_ref) {
var api = _ref.api,
canOpenMentionTypeAhead = _ref.canOpenMentionTypeAhead,
typeAhead = _ref.typeAhead;
return [{
key: _keys.MENTION_MENU_ITEM.key,
type: _keys.MENTION_MENU_ITEM.type,
parents: [{
key: _keys.STRUCTURE_SECTION.key,
type: _keys.STRUCTURE_SECTION.type,
rank: _rank.STRUCTURE_SECTION_RANK[_keys.MENTION_MENU_ITEM.key]
}],
isHidden: function isHidden() {
var _api$mention$sharedSt;
return (canOpenMentionTypeAhead === null || canOpenMentionTypeAhead === void 0 ? void 0 : canOpenMentionTypeAhead()) === false || (api === null || api === void 0 || (_api$mention$sharedSt = api.mention.sharedState.currentState()) === null || _api$mention$sharedSt === void 0 ? void 0 : _api$mention$sharedSt.canInsertMention) === false;
},
match: (0, _createQuickInsertMatcher.createQuickInsertMatcher)(function (_ref2) {
var formatMessage = _ref2.formatMessage;
return {
description: formatMessage(_messages.toolbarInsertBlockMessages.mentionDescription),
keywords: ['team', 'user'],
shortcut: '@',
title: formatMessage(_messages.toolbarInsertBlockMessages.mention)
};
}),
component: function component() {
return /*#__PURE__*/_react.default.createElement(_MentionQuickInsertMenuItem.MentionQuickInsertMenuItem, {
api: api,
previewImageUrls: previewImageUrls,
typeAhead: typeAhead
});
}
}];
};