@@ -10,32 +10,33 @@ const { REPS: { Rep }, MODE, ObjectInspectorUtils } = Reps;
1010const { ObjectInspector } = Reps ;
1111const { getChildren } = ObjectInspectorUtils ;
1212
13- import Popover from "../shared/Popover" ;
14-
15- import previewFunction from "../shared/previewFunction" ;
16- import { getLoadedObjects } from "../../selectors" ;
17- import actions from "../../actions" ;
18- import { markText } from "../../utils/editor" ;
19-
20- import type { EditorRange } from "../../utils/editor/types" ;
21-
22- import "./Preview.css" ;
23-
24- export class Preview extends Component {
13+ import actions from "../../../actions" ;
14+ import { getLoadedObjects } from "../../../selectors" ;
15+ import Popover from "../../shared/Popover" ;
16+ import previewFunction from "../../shared/previewFunction" ;
17+ import { markText } from "../../../utils/editor" ;
18+
19+ import "./Popup.css" ;
20+
21+ import type { EditorRange } from "../../../utils/editor/types" ;
22+
23+ type Props = {
24+ loadObjectProperties : Object => void ,
25+ addExpression : ( string , ?Object ) => void ,
26+ loadedObjects : Object ,
27+ popoverPos : Object ,
28+ value : Object ,
29+ expression : string ,
30+ onClose : ( ) = > void ,
31+ range : EditorRange ,
32+ editor : any ,
33+ selectSourceURL : ( string , Object ) = > void
34+ } ;
35+
36+ export class Popup extends Component {
2537 marker : any ;
2638 pos : any ;
27- props : {
28- loadObjectProperties : Object => void ,
29- addExpression : ( string , ?Object ) => void ,
30- loadedObjects : Object ,
31- popoverPos : Object ,
32- value : Object ,
33- expression : string ,
34- onClose : ( ) => void ,
35- range : EditorRange ,
36- editor : any ,
37- selectSourceURL : ( string , Object ) => void
38- } ;
39+ props : Props ;
3940
4041 componentDidMount ( ) {
4142 const {
@@ -46,7 +47,7 @@ export class Preview extends Component {
4647 range
4748 } = this . props ;
4849
49- this . marker = markText ( editor , "selection" , range ) ;
50+ this . marker = markText ( editor , "preview- selection" , range ) ;
5051
5152 if ( ! value || ! value . type == "object" ) {
5253 return ;
@@ -76,7 +77,7 @@ export class Preview extends Component {
7677 return children ;
7778 }
7879
79- return [ root ] ;
80+ return null ;
8081 }
8182
8283 renderFunctionPreview ( value : Object , root : Object ) {
@@ -85,7 +86,7 @@ export class Preview extends Component {
8586
8687 return (
8788 < div
88- className = "preview"
89+ className = "preview-popup "
8990 onClick = { ( ) => selectSourceURL ( location . url , { line : location . line } ) }
9091 >
9192 { previewFunction ( value ) }
@@ -95,15 +96,15 @@ export class Preview extends Component {
9596
9697 renderObjectPreview ( expression : string , root : Object ) {
9798 return (
98- < div className = "preview" >
99+ < div className = "preview-popup " >
99100 { this . renderObjectInspector ( root ) }
100101 </ div >
101102 ) ;
102103 }
103104
104105 renderSimplePreview ( value : Object ) {
105106 return (
106- < div className = "preview" >
107+ < div className = "preview-popup " >
107108 { Rep ( { object : value , mode : MODE . LONG } ) }
108109 </ div >
109110 ) ;
@@ -115,6 +116,10 @@ export class Preview extends Component {
115116 const getObjectProperties = id => loadedObjects [ id ] ;
116117 const roots = this . getChildren ( root , getObjectProperties ) ;
117118
119+ if ( ! roots ) {
120+ return null ;
121+ }
122+
118123 return (
119124 < ObjectInspector
120125 roots = { roots }
@@ -201,11 +206,11 @@ export class Preview extends Component {
201206 }
202207}
203208
204- Preview . displayName = "Preview " ;
209+ Popup . displayName = "Popup " ;
205210
206211export default connect (
207212 state => ( {
208213 loadedObjects : getLoadedObjects ( state )
209214 } ) ,
210215 dispatch => bindActionCreators ( actions , dispatch )
211- ) ( Preview ) ;
216+ ) ( Popup ) ;
0 commit comments