import {Flex, Text} from '@gravity-ui/uikit'; import {cn} from '../../../utils/cn'; import {ClipboardButton} from '../../ClipboardButton/ClipboardButton'; import './ResponseBodySection.scss'; const b = cn('ydb-response-body-section'); interface ResponseBodySectionProps { body: string; } function detectLanguageLabel(body: string): string | undefined { const trimmed = body.trimStart(); if (trimmed.startsWith('{') || trimmed.startsWith('[')) { return 'JSON'; } if (trimmed.startsWith('<')) { return 'HTML'; } return undefined; } export function ResponseBodySection({body}: ResponseBodySectionProps) { const languageLabel = detectLanguageLabel(body); return (
{languageLabel && ( {languageLabel} )}
{body}
); }