UNPKG

@atlaskit/editor-plugin-quick-insert

Version:

Quick insert plugin for @atlaskit/editor-core

21 lines (20 loc) • 881 B
import { quickInsertProviderMenuItemKey } from '@atlaskit/editor-common/quick-insert/get-provider-menu-item-key'; var DEFAULT_ITEM_LIMIT = 30; var ECOSYSTEM_ITEM_LIMIT = 10; var isEcosystemQuickInsertItem = function isEcosystemQuickInsertItem(item) { return quickInsertProviderMenuItemKey.isEcosystem(item.key); }; /** * Keeps the initial native and ecosystem results while ensuring ecosystem registrations * remain discoverable beyond the default category item limit. */ export var selectQuickInsertCategoryItems = function selectQuickInsertCategoryItems(items) { var ecosystemItemCount = 0; return items.filter(function (item, index) { var isEcosystemItem = isEcosystemQuickInsertItem(item); if (isEcosystemItem) { ecosystemItemCount++; } return index < DEFAULT_ITEM_LIMIT || isEcosystemItem && ecosystemItemCount <= ECOSYSTEM_ITEM_LIMIT; }); };