File tree Expand file tree Collapse file tree 4 files changed +22
-9
lines changed Expand file tree Collapse file tree 4 files changed +22
-9
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " @typebot.io/js" ,
3
- "version" : " 0.2.71 " ,
3
+ "version" : " 0.2.72 " ,
4
4
"description" : " Javascript library to display typebots on your website" ,
5
5
"type" : " module" ,
6
6
"main" : " dist/index.js" ,
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import { streamingMessage } from '@/utils/streamingMessageSignal'
2
2
import { For , createEffect , createSignal } from 'solid-js'
3
3
import { marked } from 'marked'
4
4
import domPurify from 'dompurify'
5
+ import { isNotEmpty } from '@typebot.io/lib'
5
6
6
7
type Props = {
7
8
streamingMessageId : string
@@ -22,12 +23,24 @@ export const StreamingBubble = (props: Props) => {
22
23
if ( streamingMessage ( ) ?. id !== props . streamingMessageId ) return [ ]
23
24
setContent (
24
25
streamingMessage ( )
25
- ?. content . split ( '\n\n' )
26
- . map ( ( line ) =>
27
- domPurify . sanitize ( marked . parse ( line ) , {
28
- ADD_ATTR : [ 'target' ] ,
29
- } )
30
- ) ?? [ ]
26
+ ?. content . split ( '```' )
27
+ . map ( ( block , index ) => {
28
+ if ( index % 2 === 0 ) {
29
+ return block . split ( '\n\n' ) . map ( ( line ) =>
30
+ domPurify . sanitize ( marked . parse ( line ) , {
31
+ ADD_ATTR : [ 'target' ] ,
32
+ } )
33
+ )
34
+ } else {
35
+ return [
36
+ domPurify . sanitize ( marked . parse ( '```' + block + '```' ) , {
37
+ ADD_ATTR : [ 'target' ] ,
38
+ } ) ,
39
+ ]
40
+ }
41
+ } )
42
+ . flat ( )
43
+ . filter ( isNotEmpty ) ?? [ ]
31
44
)
32
45
} )
33
46
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " @typebot.io/nextjs" ,
3
- "version" : " 0.2.71 " ,
3
+ "version" : " 0.2.72 " ,
4
4
"description" : " Convenient library to display typebots on your Next.js website" ,
5
5
"main" : " dist/index.js" ,
6
6
"types" : " dist/index.d.ts" ,
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " @typebot.io/react" ,
3
- "version" : " 0.2.71 " ,
3
+ "version" : " 0.2.72 " ,
4
4
"description" : " Convenient library to display typebots on your React app" ,
5
5
"main" : " dist/index.js" ,
6
6
"types" : " dist/index.d.ts" ,
You can’t perform that action at this time.
0 commit comments