UNPKG

@gechiui/block-editor

Version:
46 lines (39 loc) 1.2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.blockAllowed = blockAllowed; exports.filterInserterItems = filterInserterItems; const REUSABLE_BLOCKS_CATEGORY = 'reusable'; const ALLOWED_EMBED_VARIATIONS = ['core/embed', 'core/embed/youtube', 'core/embed/twitter', 'core/embed/gechiui', 'core/embed/instagram', 'core/embed/vimeo']; function blockAllowed(block, _ref) { let { onlyReusable, allowReusable } = _ref; const { id, category } = block; const isReusable = category === REUSABLE_BLOCKS_CATEGORY; if (onlyReusable) { return isReusable; } if (isReusable) { return allowReusable; } // We don't want to show all possible embed variations // as different blocks in the inserter. We'll only show a // few popular ones. return category !== 'embed' || ALLOWED_EMBED_VARIATIONS.includes(id); } function filterInserterItems(items) { let { onlyReusable = false, allowReusable = false } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; return items.filter(block => blockAllowed(block, { onlyReusable, allowReusable })); } //# sourceMappingURL=utils.native.js.map