UNPKG

@gechiui/block-editor

Version:
37 lines (33 loc) 1.04 kB
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']; export 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); } export 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