11import React from "react" ;
2- import { renderToString } from "react-dom/server" ;
3- import * as ReactIs from "react-is" ;
42
53import { TestableComponent } from "../../components/interfaces" ;
64import { CLASSPREFIX as eccgui } from "../../configuration/constants" ;
75
86import { Markdown , MarkdownProps } from "./../../cmem/markdown/Markdown" ;
7+ import { ContentShrinker } from "./../ContentShrinker/ContentShrinker" ;
98import { DepictionProps } from "./../Depiction/Depiction" ;
109import { FlexibleLayoutContainer , FlexibleLayoutItem } from "./../FlexibleLayout" ;
1110import { IconButton } from "./../Icon/IconButton" ;
1211import { Spacing } from "./../Separation/Spacing" ;
13- import { HtmlContentBlock , OverflowText , OverflowTextProps } from "./../Typography" ;
12+ import { HtmlContentBlock , OverflowTextProps } from "./../Typography" ;
1413
1514export interface ChatContentProps extends React . HTMLAttributes < HTMLDivElement > , TestableComponent {
1615 /**
@@ -97,35 +96,6 @@ export const ChatContent = ({
9796 const content =
9897 markdownProps && typeof children === "string" ? < Markdown { ...markdownProps } > { children } </ Markdown > : children ;
9998
100- const onlyText = ( children : React . ReactNode | React . ReactNode [ ] ) : string => {
101- if ( children instanceof Array ) {
102- return children
103- . map ( ( child : React . ReactNode ) => {
104- return onlyText ( child ) ;
105- } )
106- . join ( " " ) ;
107- }
108-
109- return React . Children . toArray ( children )
110- . map ( ( child ) => {
111- if ( ReactIs . isFragment ( child ) ) {
112- return onlyText ( child . props ?. children ) ;
113- }
114- if ( typeof child === "string" ) {
115- return child ;
116- }
117- if ( typeof child === "number" ) {
118- return child . toString ( ) ;
119- }
120- if ( ReactIs . isElement ( child ) ) {
121- // for some reasons `renderToString` returns empty string if not wrappe in a `span`
122- return renderToString ( < span > { child } </ span > ) ;
123- }
124- return "" ;
125- } )
126- . join ( " " ) ;
127- } ;
128-
12999 const chatitem = (
130100 < div
131101 className = {
@@ -143,13 +113,7 @@ export const ChatContent = ({
143113 < Spacing size = "tiny" />
144114 </ HtmlContentBlock >
145115 ) }
146- { displayShrinked && autoShrink ? (
147- < OverflowText passDown >
148- < Markdown removeMarkup > { onlyText ( content ) } </ Markdown >
149- </ OverflowText >
150- ) : (
151- content
152- ) }
116+ { displayShrinked && autoShrink ? < ContentShrinker > { content } </ ContentShrinker > : content }
153117 </ div >
154118 ) ;
155119
0 commit comments