@@ -5,9 +5,9 @@ import _ from "underscore";
5
5
6
6
import JsonEditor from "./components/json-editor" ;
7
7
import ViewportResizer from "./components/viewport-resizer" ;
8
+ import CombinedHintsEditor from "./hint-editor" ;
9
+ import ItemEditor from "./item-editor" ;
8
10
9
- import type CombinedHintsEditor from "./hint-editor" ;
10
- import type ItemEditor from "./item-editor" ;
11
11
import type {
12
12
APIOptions ,
13
13
APIOptionsWithDefaults ,
@@ -55,31 +55,45 @@ type Props = {
55
55
56
56
children : ( components : {
57
57
/**
58
- * Provides a rendered component that allows users to flip between the
58
+ * A rendered component that allows users to flip between the
59
59
* standard content editors or the raw JSON view. This view should be
60
60
* gated behind a permission check and only "Developer" level folks
61
61
* should be able to access this mode.
62
62
*/
63
63
jsonModeEditor : React . ReactNode ;
64
64
65
65
/**
66
- * Provides a React Component that renders the JSON view of the current
66
+ * A React Component that renders the JSON view of the current
67
67
* item being edited. Note that this is a "Power User" editor and can
68
68
* easily break an item if not used carefully.
69
69
*/
70
70
JsonEditor : React . ComponentType < { style : StyleType } > ;
71
71
72
72
/**
73
- * Provides a rendered component that flips the preview component
73
+ * A rendered component that flips the preview component
74
74
* between different viewport sizes (ie. phone, tablet, desktop).
75
75
*/
76
76
viewportResizerElement : React . ReactNode ;
77
77
78
78
/**
79
- * Provides a rendered component that provides a button to toggle lint
79
+ * A rendered component of a button to toggle lint
80
80
* warnings on and off in the other editors.
81
81
*/
82
82
hudElement : React . ReactNode ;
83
+
84
+ /**
85
+ * A rendered component that provides the item editing experience.
86
+ * TODO: Inline this component into EditorWithLayout for more layout
87
+ * control.
88
+ */
89
+ itemEditor : React . ReactNode ;
90
+
91
+ /**
92
+ * A rendered component that provides the hints editing experience.
93
+ * TODO: Inline this component into EditorWithLayout for more layout
94
+ * control.
95
+ */
96
+ hintsEditor : React . ReactNode ;
83
97
} ) => React . ReactNode ;
84
98
} ;
85
99
@@ -285,8 +299,6 @@ class EditorWithLayout extends React.Component<Props, State> {
285
299
{ this . props . children ( {
286
300
jsonModeEditor : jsonModeEditor ,
287
301
JsonEditor : ( { style} : { style : StyleType } ) => (
288
- // I suspect this will need some way to pass styles in
289
- // so the host can define its size.
290
302
< JsonEditor
291
303
value = { this . state . json }
292
304
onChange = { this . changeJSON }
@@ -313,41 +325,38 @@ class EditorWithLayout extends React.Component<Props, State> {
313
325
} }
314
326
/>
315
327
) ,
328
+ itemEditor : ! this . props . jsonMode && (
329
+ < ItemEditor
330
+ ref = { this . itemEditor }
331
+ itemId = { this . props . itemId }
332
+ question = { this . props . question }
333
+ answerArea = { this . props . answerArea }
334
+ imageUploader = { this . props . imageUploader }
335
+ onChange = { this . handleChange }
336
+ wasAnswered = { this . state . wasAnswered }
337
+ gradeMessage = { this . state . gradeMessage }
338
+ deviceType = { this . props . previewDevice }
339
+ apiOptions = { deviceBasedApiOptions }
340
+ previewURL = { this . props . previewURL }
341
+ />
342
+ ) ,
343
+ hintsEditor : ! this . props . jsonMode && (
344
+ < CombinedHintsEditor
345
+ ref = { this . hintsEditor }
346
+ itemId = { this . props . itemId }
347
+ hints = { this . props . hints }
348
+ imageUploader = { this . props . imageUploader }
349
+ onChange = { this . handleChange }
350
+ deviceType = { this . props . previewDevice }
351
+ apiOptions = { deviceBasedApiOptions }
352
+ previewURL = { this . props . previewURL }
353
+ highlightLint = { this . state . highlightLint }
354
+ />
355
+ ) ,
316
356
} ) }
317
357
</ div >
318
358
) ;
319
359
}
320
360
}
321
- /*
322
-
323
- {(!this.props.developerMode || !this.props.jsonMode) && (
324
- <ItemEditor
325
- ref={this.itemEditor}
326
- itemId={this.props.itemId}
327
- question={this.props.question}
328
- answerArea={this.props.answerArea}
329
- imageUploader={this.props.imageUploader}
330
- onChange={this.handleChange}
331
- wasAnswered={this.state.wasAnswered}
332
- gradeMessage={this.state.gradeMessage}
333
- deviceType={this.props.previewDevice}
334
- apiOptions={deviceBasedApiOptions}
335
- previewURL={this.props.previewURL}
336
- />
337
- )}
338
-
339
- {(!this.props.developerMode || !this.props.jsonMode) && (
340
- <CombinedHintsEditor
341
- ref={this.hintsEditor}
342
- itemId={this.props.itemId}
343
- hints={this.props.hints}
344
- imageUploader={this.props.imageUploader}
345
- onChange={this.handleChange}
346
- deviceType={this.props.previewDevice}
347
- apiOptions={deviceBasedApiOptions}
348
- previewURL={this.props.previewURL}
349
- highlightLint={this.state.highlightLint}
350
- />
351
- )}
352
- */
361
+
353
362
export default EditorWithLayout ;
0 commit comments