@@ -58,18 +58,30 @@ var Mindmap = React.createClass({
58
58
var positions = calcPos (
59
59
this . props . store . view . root ,
60
60
this . props . store . actions . db . nodes ,
61
+ 20 ,
61
62
100 ,
62
- 100 ,
63
+ 200 ,
63
64
this . state . heights ) ;
64
65
return positions
65
66
} ,
66
67
67
68
render : function ( ) {
68
69
var positions = this . calcPositions ( )
70
+ var bodies = {
71
+ default : { editor : null , renderer : null }
72
+ }
73
+ if ( this . props . nodePlugins ) {
74
+ for ( var i = 0 ; i < this . props . nodePlugins . length ; i ++ ) {
75
+ if ( this . props . nodePlugins [ i ] . bodies ) {
76
+ bodies = extend ( bodies , this . props . nodePlugins [ i ] . bodies )
77
+ }
78
+ }
79
+ }
69
80
return < div className = 'Mindmap' >
70
81
< Movable
71
82
height = { this . props . height }
72
83
width = { this . props . width }
84
+ bodies = { bodies }
73
85
positions = { positions }
74
86
reCalc = { this . _reCalc }
75
87
onHeight = { this . _onHeight }
@@ -100,7 +112,8 @@ var Movable = React.createClass({
100
112
if ( this . state . activeNode === state . activeNode ) return
101
113
var aid = state . activeNode
102
114
, pos = props . positions . boxes [ aid ]
103
- , nx = this . state . left + pos . x
115
+ if ( ! pos ) return
116
+ var nx = this . state . left + pos . x
104
117
, ny = this . state . top + pos . y
105
118
, margin = 100
106
119
, dx = 0
@@ -111,16 +124,16 @@ var Movable = React.createClass({
111
124
if ( ny - margin < 0 ) {
112
125
dy -= ny - margin
113
126
}
114
- if ( nx + pos . height + margin > this . props . width ) {
115
- dx -= nx + pos . height + margin - this . props . width
127
+ if ( nx + pos . width + margin > this . props . width ) {
128
+ dx -= nx + pos . width + margin - this . props . width
116
129
}
117
- if ( ny + pos . width + margin > this . props . height ) {
118
- dy -= ny + pos . width + margin - this . props . height
130
+ if ( ny + pos . height + margin > this . props . height ) {
131
+ dy -= ny + pos . height + margin - this . props . height
119
132
}
120
- this . setState ( {
133
+ return {
121
134
left : this . state . left + dx ,
122
135
top : this . state . top + dy ,
123
- } )
136
+ }
124
137
} ,
125
138
} )
126
139
] ,
@@ -129,7 +142,8 @@ var Movable = React.createClass({
129
142
var aid = this . props . store . view . active
130
143
, ppos = this . props . positions . boxes [ aid ]
131
144
, npos = nextProps . positions . boxes [ aid ]
132
- , dx = ppos . x - npos . x
145
+ if ( ! ppos || ! npos ) return
146
+ var dx = ppos . x - npos . x
133
147
, dy = ppos . y - npos . y
134
148
, nx = this . state . left + dx + npos . x
135
149
, ny = this . state . top + dy + npos . y
@@ -215,6 +229,7 @@ var Movable = React.createClass({
215
229
onHeight = { this . props . onHeight }
216
230
positions = { positions . boxes }
217
231
plugins = { this . props . nodePlugins }
232
+ bodies = { this . props . bodies }
218
233
store = { this . props . store }
219
234
key = { this . props . store . view . root }
220
235
id = { this . props . store . view . root }
0 commit comments