@@ -38,8 +38,10 @@ export class Node {
3838 public toJsString ( ) : string {
3939 const jsStringProperties : string [ ] = [ ] ;
4040 if ( this . id !== undefined ) { jsStringProperties . push ( `id: "${ this . id } "` ) ; }
41- if ( this . label !== undefined ) { jsStringProperties . push ( `label: "${ this . label } "` ) ; }
42- if ( this . description !== undefined ) { jsStringProperties . push ( `title: "${ this . description } "` ) ; }
41+ const label = this . convertNewlines ( this . label ) ;
42+ if ( this . label !== undefined ) { jsStringProperties . push ( `label: "${ label } "` ) ; }
43+ const description = this . convertNewlines ( this . description ) ;
44+ if ( this . description !== undefined ) { jsStringProperties . push ( `title: "${ description } "` ) ; }
4345 if ( this . strokeThickness !== undefined ) { jsStringProperties . push ( `borderWidth: "${ this . strokeThickness } "` ) ; }
4446 const jsStringColorProperties : string [ ] = [ ] ;
4547 if ( this . stroke !== undefined ) { jsStringColorProperties . push ( `border: "${ this . stroke } "` ) ; }
@@ -49,4 +51,14 @@ export class Node {
4951 if ( jsStringColorProperties . length > 0 ) { jsStringProperties . push ( `color: { ${ jsStringColorProperties . join ( ', ' ) } }` ) ; }
5052 return `{${ jsStringProperties . join ( ', ' ) } }` ;
5153 }
54+
55+ private convertNewlines ( text : string | undefined ) : string {
56+ if ( text === undefined ) {
57+ return '' ;
58+ }
59+ text = text . replace ( '
' , '\\n' ) ;
60+ text = text . replace ( '
' , '\\n' ) ;
61+ text = text . replace ( '
' , '\\n' ) ;
62+ return text ;
63+ }
5264}
0 commit comments