@atlaskit/editor-plugin-mentions
Version:
Mentions plugin for @atlaskit/editor-core
40 lines • 1.81 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';
const previewImageUrls = {
light: 'https://dam-cdn.atl.orangelogic.com/AssetLink/02107p5maex03pfb4s04rw7i4hbk5jj0.png',
dark: 'https://dam-cdn.atl.orangelogic.com/AssetLink/q3254137y85cxldh4osht5k5c7q88572.png'
};
export const getMentionQuickInsertComponents = ({
api,
canOpenMentionTypeAhead,
typeAhead
}) => [{
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: () => {
var _api$mention$sharedSt;
return (canOpenMentionTypeAhead === null || canOpenMentionTypeAhead === void 0 ? void 0 : canOpenMentionTypeAhead()) === false || (api === null || api === void 0 ? void 0 : (_api$mention$sharedSt = api.mention.sharedState.currentState()) === null || _api$mention$sharedSt === void 0 ? void 0 : _api$mention$sharedSt.canInsertMention) === false;
},
match: createQuickInsertMatcher(({
formatMessage
}) => ({
description: formatMessage(messages.mentionDescription),
keywords: ['team', 'user'],
shortcut: '@',
title: formatMessage(messages.mention)
})),
component: () => /*#__PURE__*/React.createElement(MentionQuickInsertMenuItem, {
api: api,
previewImageUrls: previewImageUrls,
typeAhead: typeAhead
})
}];