@@ -3,10 +3,14 @@ import {Checkbox} from "@khanacademy/wonder-blocks-form";
3
3
import * as React from "react" ;
4
4
import _ from "underscore" ;
5
5
6
+ import DeviceFramer from "./components/device-framer" ;
6
7
import JsonEditor from "./components/json-editor" ;
7
8
import ViewportResizer from "./components/viewport-resizer" ;
9
+ import ContentPreview from "./content-preview" ;
8
10
import CombinedHintsEditor from "./hint-editor" ;
11
+ import IframeContentRenderer from "./iframe-content-renderer" ;
9
12
import ItemEditor from "./item-editor" ;
13
+ import ItemExtrasEditor from "./item-extras-editor" ;
10
14
11
15
import type {
12
16
APIOptions ,
@@ -88,12 +92,26 @@ type Props = {
88
92
*/
89
93
itemEditor : React . ReactNode ;
90
94
95
+ /**
96
+ * A rendered component that previews the current item. It is updated
97
+ * any time the question, hints, or answerArea changes. It is also
98
+ * updaed when the `jsonModeEditor` is toggled on and the `JsonEditor`
99
+ * is changed.
100
+ */
101
+ itemPreview : React . ReactNode ;
102
+
91
103
/**
92
104
* A rendered component that provides the hints editing experience.
93
105
* TODO: Inline this component into EditorWithLayout for more layout
94
106
* control.
95
107
*/
96
108
hintsEditor : React . ReactNode ;
109
+
110
+ /**
111
+ * A rendered component that provides an editor to toggle question
112
+ * extras for this item (such as calculator, periodic table, etc).
113
+ */
114
+ questionExtras : React . ReactNode ;
97
115
} ) => React . ReactNode ;
98
116
} ;
99
117
@@ -115,6 +133,8 @@ class EditorWithLayout extends React.Component<Props, State> {
115
133
116
134
itemEditor = React . createRef < ItemEditor > ( ) ;
117
135
hintsEditor = React . createRef < CombinedHintsEditor > ( ) ;
136
+ itemExtrasEditor = React . createRef < ItemExtrasEditor > ( ) ;
137
+ previewRenderer = React . createRef < IframeContentRenderer > ( ) ;
118
138
119
139
static defaultProps : {
120
140
developerMode : boolean ;
@@ -340,6 +360,21 @@ class EditorWithLayout extends React.Component<Props, State> {
340
360
previewURL = { this . props . previewURL }
341
361
/>
342
362
) ,
363
+ itemPreview : (
364
+ < DeviceFramer
365
+ deviceType = { this . props . previewDevice }
366
+ nochrome = { true }
367
+ >
368
+ < IframeContentRenderer
369
+ ref = { this . previewRenderer }
370
+ key = { this . props . previewDevice }
371
+ datasetKey = "mobile"
372
+ datasetValue = { touch }
373
+ seamless = { true }
374
+ url = { this . props . previewURL }
375
+ />
376
+ </ DeviceFramer >
377
+ ) ,
343
378
hintsEditor : ! this . props . jsonMode && (
344
379
< CombinedHintsEditor
345
380
ref = { this . hintsEditor }
@@ -353,6 +388,21 @@ class EditorWithLayout extends React.Component<Props, State> {
353
388
highlightLint = { this . state . highlightLint }
354
389
/>
355
390
) ,
391
+ questionExtras : (
392
+ < ItemExtrasEditor
393
+ ref = { this . itemExtrasEditor }
394
+ onChange = { ( answerArea ) =>
395
+ this . handleChange ( {
396
+ // @ts -expect-error - TS2322 - Types of property 'calculator' are incompatible.
397
+ answerArea : {
398
+ ...this . props . answerArea ,
399
+ ...answerArea ,
400
+ } ,
401
+ } )
402
+ }
403
+ { ...this . props . answerArea }
404
+ />
405
+ ) ,
356
406
} ) }
357
407
</ div >
358
408
) ;
0 commit comments