import { useXMLViewerContext } from '../../context/xml-viewer-context'; import { hasBreakLines } from '../../helpers'; export interface TextElementProps { text: string; hasSiblings: boolean; indentation: string; isText: boolean; } export function TextElement(props: TextElementProps) { const { hasSiblings, text, indentation, isText } = props; const { theme } = useXMLViewerContext(); const style = isText ? { color: theme.textColor } : undefined; return hasBreakLines(text) || hasSiblings ? (
{text .split('\n') .filter((element) => !!element.trim()) .map((line, index) => (
{`${indentation}${line.trim()}`}
))}
) : ( {text} ); }