RocketChat/Rocket.Chat

View on GitHub
packages/ui-kit/src/blocks/isContextBlockElement.ts

Summary

Maintainability
A
0 mins
Test Coverage
import type { BlockElement } from './BlockElement';
import { BlockElementType } from './BlockElementType';
import type { TextObject } from './TextObject';
import { TextObjectType } from './TextObjectType';
import type { ContextBlock } from './layout/ContextBlock';

export const isContextBlockElement = (block: TextObject | BlockElement): block is ContextBlock['elements'][number] => {
    switch (block.type as ContextBlock['elements'][number]['type']) {
        case BlockElementType.IMAGE:
        case TextObjectType.PLAIN_TEXT:
        case TextObjectType.MARKDOWN:
            return true;

        default:
            return false;
    }
};