@@ -38,8 +38,10 @@ export class Node {
38
38
public toJsString ( ) : string {
39
39
const jsStringProperties : string [ ] = [ ] ;
40
40
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 } "` ) ; }
43
45
if ( this . strokeThickness !== undefined ) { jsStringProperties . push ( `borderWidth: "${ this . strokeThickness } "` ) ; }
44
46
const jsStringColorProperties : string [ ] = [ ] ;
45
47
if ( this . stroke !== undefined ) { jsStringColorProperties . push ( `border: "${ this . stroke } "` ) ; }
@@ -49,4 +51,14 @@ export class Node {
49
51
if ( jsStringColorProperties . length > 0 ) { jsStringProperties . push ( `color: { ${ jsStringColorProperties . join ( ', ' ) } }` ) ; }
50
52
return `{${ jsStringProperties . join ( ', ' ) } }` ;
51
53
}
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
+ }
52
64
}
0 commit comments