UNPKG

@atlaskit/editor-plugin-quick-insert

Version:

Quick insert plugin for @atlaskit/editor-core

27 lines (25 loc) • 1.06 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.selectQuickInsertCategoryItems = void 0; var _getProviderMenuItemKey = require("@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 _getProviderMenuItemKey.quickInsertProviderMenuItemKey.isEcosystem(item.key); }; /** * Keeps the initial native and ecosystem results while ensuring ecosystem registrations * remain discoverable beyond the default category item limit. */ var selectQuickInsertCategoryItems = exports.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; }); };