@@ -510,7 +510,7 @@ MM.Item.prototype.updateSubtree = function(isSubChild) {
510
510
}
511
511
512
512
MM . Item . prototype . setText = function ( text ) {
513
- this . _dom . text . innerHTML = text . replace ( / \n / g , "<br/>" ) ;
513
+ this . _dom . text . innerHTML = text ;
514
514
this . _findLinks ( this . _dom . text ) ;
515
515
return this . update ( ) ;
516
516
}
@@ -520,7 +520,7 @@ MM.Item.prototype.getId = function() {
520
520
}
521
521
522
522
MM . Item . prototype . getText = function ( ) {
523
- return this . _dom . text . innerHTML . replace ( / < b r \s * \/ ? > / g , "\n" ) ;
523
+ return this . _dom . text . innerHTML ;
524
524
}
525
525
526
526
MM . Item . prototype . collapse = function ( ) {
@@ -1069,7 +1069,7 @@ MM.Map.prototype.getRoot = function() {
1069
1069
1070
1070
MM . Map . prototype . getName = function ( ) {
1071
1071
var name = this . _root . getText ( ) ;
1072
- return name . replace ( / \n / g, " " ) . replace ( / < .* ?> / g, "" ) . trim ( ) ;
1072
+ return MM . Format . br2nl ( name ) . replace ( / \n / g, " " ) . replace ( / < .* ?> / g, "" ) . trim ( ) ;
1073
1073
}
1074
1074
1075
1075
MM . Map . prototype . getId = function ( ) {
@@ -2790,6 +2790,14 @@ MM.Format.getByMime = function(mime) {
2790
2790
2791
2791
MM . Format . to = function ( data ) { }
2792
2792
MM . Format . from = function ( data ) { }
2793
+
2794
+ MM . Format . nl2br = function ( str ) {
2795
+ return str . replace ( / \n / g, "<br/>" ) ;
2796
+ }
2797
+
2798
+ MM . Format . br2nl = function ( str ) {
2799
+ return str . replace ( / < b r \s * \/ ? > / g, "\n" ) ;
2800
+ }
2793
2801
MM . Format . JSON = Object . create ( MM . Format , {
2794
2802
id : { value : "json" } ,
2795
2803
label : { value : "Native (JSON)" } ,
@@ -2798,7 +2806,7 @@ MM.Format.JSON = Object.create(MM.Format, {
2798
2806
} ) ;
2799
2807
2800
2808
MM . Format . JSON . to = function ( data ) {
2801
- return JSON . stringify ( data , null , 2 ) + "\n" ;
2809
+ return JSON . stringify ( data , null , "\t" ) + "\n" ;
2802
2810
}
2803
2811
2804
2812
MM . Format . JSON . from = function ( data ) {
@@ -2852,7 +2860,7 @@ MM.Format.FreeMind._serializeItem = function(doc, json) {
2852
2860
2853
2861
MM . Format . FreeMind . _serializeAttributes = function ( doc , json ) {
2854
2862
var elm = doc . createElement ( "node" ) ;
2855
- elm . setAttribute ( "TEXT" , json . text ) ;
2863
+ elm . setAttribute ( "TEXT" , MM . Format . br2nl ( json . text ) ) ;
2856
2864
elm . setAttribute ( "ID" , json . id ) ;
2857
2865
2858
2866
if ( json . side ) { elm . setAttribute ( "POSITION" , json . side ) ; }
@@ -2878,7 +2886,7 @@ MM.Format.FreeMind._parseNode = function(node, parent) {
2878
2886
MM . Format . FreeMind . _parseAttributes = function ( node , parent ) {
2879
2887
var json = {
2880
2888
children : [ ] ,
2881
- text : node . getAttribute ( "TEXT" ) || "" ,
2889
+ text : MM . Format . nl2br ( node . getAttribute ( "TEXT" ) || "" ) ,
2882
2890
id : node . getAttribute ( "ID" )
2883
2891
} ;
2884
2892
@@ -2924,7 +2932,7 @@ MM.Format.MMA = Object.create(MM.Format.FreeMind, {
2924
2932
MM . Format . MMA . _parseAttributes = function ( node , parent ) {
2925
2933
var json = {
2926
2934
children : [ ] ,
2927
- text : node . getAttribute ( "title" ) || "" ,
2935
+ text : MM . Format . nl2br ( node . getAttribute ( "title" ) || "" ) ,
2928
2936
shape : "box"
2929
2937
} ;
2930
2938
@@ -2954,7 +2962,7 @@ MM.Format.MMA._parseAttributes = function(node, parent) {
2954
2962
2955
2963
MM . Format . MMA . _serializeAttributes = function ( doc , json ) {
2956
2964
var elm = doc . createElement ( "node" ) ;
2957
- elm . setAttribute ( "title" , json . text ) ;
2965
+ elm . setAttribute ( "title" , MM . Format . br2nl ( json . text ) ) ;
2958
2966
elm . setAttribute ( "expand" , json . collapsed ? "false" : "true" ) ;
2959
2967
2960
2968
if ( json . side ) { elm . setAttribute ( "direction" , json . side == "left" ? "0" : "1" ) ; }
@@ -2993,7 +3001,7 @@ MM.Format.Mup.from = function(data) {
2993
3001
2994
3002
MM . Format . Mup . _MupToMM = function ( item ) {
2995
3003
var json = {
2996
- text : item . title ,
3004
+ text : MM . Format . nl2br ( item . title ) ,
2997
3005
id : item . id ,
2998
3006
shape : "box"
2999
3007
}
@@ -3031,7 +3039,7 @@ MM.Format.Mup._MupToMM = function(item) {
3031
3039
MM . Format . Mup . _MMtoMup = function ( item , side ) {
3032
3040
var result = {
3033
3041
id : item . id ,
3034
- title : item . text ,
3042
+ title : MM . Format . br2nl ( item . text ) ,
3035
3043
attr : { }
3036
3044
}
3037
3045
if ( item . color ) {
@@ -3103,7 +3111,7 @@ MM.Format.Plaintext._serializeItem = function(item, depth) {
3103
3111
} , this ) ;
3104
3112
3105
3113
var prefix = new Array ( depth + 1 ) . join ( "\t" ) ;
3106
- lines . unshift ( prefix + item . text . replace ( / \n / g, "<br/> " ) )
3114
+ lines . unshift ( prefix + item . text . replace ( / \n / g, "" ) ) ;
3107
3115
3108
3116
return lines . join ( "\n" ) + ( depth ? "" : "\n" ) ;
3109
3117
}
0 commit comments