@atlaskit/editor-plugin-mentions
Version:
Mentions plugin for @atlaskit/editor-core
44 lines • 2.09 kB
JavaScript
import React from 'react';
import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
import { createQuickInsertMatcher } from '@atlaskit/editor-common/quick-insert/create-quick-insert-matcher';
import { MENTION_MENU_ITEM, STRUCTURE_SECTION } from '@atlaskit/editor-common/quick-insert/keys';
import { STRUCTURE_SECTION_RANK } from '@atlaskit/editor-common/quick-insert/rank';
import { MentionQuickInsertMenuItem } from './MentionQuickInsertMenuItem';
var previewImageUrls = {
light: 'https://dam-cdn.atl.orangelogic.com/AssetLink/02107p5maex03pfb4s04rw7i4hbk5jj0.png',
dark: 'https://dam-cdn.atl.orangelogic.com/AssetLink/q3254137y85cxldh4osht5k5c7q88572.png'
};
export var getMentionQuickInsertComponents = function getMentionQuickInsertComponents(_ref) {
var api = _ref.api,
canOpenMentionTypeAhead = _ref.canOpenMentionTypeAhead,
typeAhead = _ref.typeAhead;
return [{
key: MENTION_MENU_ITEM.key,
type: MENTION_MENU_ITEM.type,
parents: [{
key: STRUCTURE_SECTION.key,
type: STRUCTURE_SECTION.type,
rank: STRUCTURE_SECTION_RANK[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: createQuickInsertMatcher(function (_ref2) {
var formatMessage = _ref2.formatMessage;
return {
description: formatMessage(messages.mentionDescription),
keywords: ['team', 'user'],
shortcut: '@',
title: formatMessage(messages.mention)
};
}),
component: function component() {
return /*#__PURE__*/React.createElement(MentionQuickInsertMenuItem, {
api: api,
previewImageUrls: previewImageUrls,
typeAhead: typeAhead
});
}
}];
};