@pie-element/drawing-response 3.7.3-next.137 → 3.7.3-next.1372
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +269 -0
- package/configure/CHANGELOG.md +222 -0
- package/configure/lib/defaults.js +20 -2
- package/configure/lib/defaults.js.map +1 -1
- package/configure/lib/image-container.js +44 -24
- package/configure/lib/image-container.js.map +1 -1
- package/configure/lib/index.js +17 -9
- package/configure/lib/index.js.map +1 -1
- package/configure/lib/root.js +76 -20
- package/configure/lib/root.js.map +1 -1
- package/configure/package.json +4 -4
- package/configure/src/__tests__/__snapshots__/image-container.test.jsx.snap +3 -2
- package/configure/src/__tests__/__snapshots__/root.test.jsx.snap +32 -14
- package/configure/src/__tests__/image-container.test.jsx +2 -2
- package/configure/src/defaults.js +20 -2
- package/configure/src/image-container.jsx +82 -50
- package/configure/src/index.js +14 -6
- package/configure/src/root.jsx +70 -25
- package/controller/CHANGELOG.md +46 -0
- package/controller/lib/index.js +13 -9
- package/controller/lib/index.js.map +1 -1
- package/controller/package.json +1 -1
- package/controller/src/__tests__/index.test.js +18 -9
- package/controller/src/index.js +4 -1
- package/docs/config-schema.json +95 -0
- package/docs/config-schema.json.md +73 -1
- package/docs/demo/generate.js +3 -1
- package/docs/pie-schema.json +39 -0
- package/docs/pie-schema.json.md +28 -0
- package/lib/drawing-response/container.js +78 -23
- package/lib/drawing-response/container.js.map +1 -1
- package/lib/drawing-response/drawable-circle.js +1 -1
- package/lib/drawing-response/drawable-circle.js.map +1 -1
- package/lib/drawing-response/drawable-eraser.js +1 -1
- package/lib/drawing-response/drawable-eraser.js.map +1 -1
- package/lib/drawing-response/drawable-free-path.js +1 -1
- package/lib/drawing-response/drawable-free-path.js.map +1 -1
- package/lib/drawing-response/drawable-helper.js.map +1 -1
- package/lib/drawing-response/drawable-image.js +1 -0
- package/lib/drawing-response/drawable-image.js.map +1 -1
- package/lib/drawing-response/drawable-line.js +1 -1
- package/lib/drawing-response/drawable-line.js.map +1 -1
- package/lib/drawing-response/drawable-main.js +45 -16
- package/lib/drawing-response/drawable-main.js.map +1 -1
- package/lib/drawing-response/drawable-palette.js +1 -1
- package/lib/drawing-response/drawable-palette.js.map +1 -1
- package/lib/drawing-response/drawable-rectangle.js +1 -1
- package/lib/drawing-response/drawable-rectangle.js.map +1 -1
- package/lib/drawing-response/drawable-text.js +15 -5
- package/lib/drawing-response/drawable-text.js.map +1 -1
- package/lib/drawing-response/drawable-transformer.js +1 -1
- package/lib/drawing-response/drawable-transformer.js.map +1 -1
- package/lib/drawing-response/index.js +9 -9
- package/lib/drawing-response/index.js.map +1 -1
- package/lib/index.js +4 -1
- package/lib/index.js.map +1 -1
- package/package.json +4 -4
- package/src/drawing-response/__tests__/__snapshots__/container.test.jsx.snap +172 -288
- package/src/drawing-response/__tests__/__snapshots__/drawing-main.test.jsx.snap +26 -2
- package/src/drawing-response/__tests__/container.test.jsx +7 -0
- package/src/drawing-response/__tests__/drawing-main.test.jsx +2 -1
- package/src/drawing-response/container.jsx +78 -36
- package/src/drawing-response/drawable-image.jsx +1 -0
- package/src/drawing-response/drawable-main.jsx +45 -17
- package/src/drawing-response/drawable-text.jsx +7 -1
- package/src/drawing-response/index.jsx +6 -4
- package/src/index.js +5 -0
|
@@ -8,27 +8,45 @@ exports[`Root snapshot renders 1`] = `
|
|
|
8
8
|
configuration={
|
|
9
9
|
Object {
|
|
10
10
|
"backgroundImage": Object {
|
|
11
|
-
"enabled": true,
|
|
12
11
|
"label": "Background Image",
|
|
13
12
|
"settings": true,
|
|
14
13
|
},
|
|
14
|
+
"maxImageHeight": Object {
|
|
15
|
+
"prompt": 300,
|
|
16
|
+
"teacherInstructions": 300,
|
|
17
|
+
},
|
|
18
|
+
"maxImageWidth": Object {
|
|
19
|
+
"prompt": 300,
|
|
20
|
+
"teacherInstructions": 300,
|
|
21
|
+
},
|
|
15
22
|
"prompt": Object {
|
|
16
23
|
"label": "Prompt",
|
|
17
24
|
"settings": true,
|
|
18
25
|
},
|
|
26
|
+
"spellCheck": Object {
|
|
27
|
+
"enabled": true,
|
|
28
|
+
"label": "Spellcheck",
|
|
29
|
+
"settings": false,
|
|
30
|
+
},
|
|
19
31
|
"teacherInstructions": Object {
|
|
20
32
|
"label": "Teacher Instructions",
|
|
21
33
|
"settings": true,
|
|
22
34
|
},
|
|
35
|
+
"withRubric": Object {
|
|
36
|
+
"label": "Add Rubric",
|
|
37
|
+
"settings": false,
|
|
38
|
+
},
|
|
23
39
|
}
|
|
24
40
|
}
|
|
25
41
|
groups={
|
|
26
42
|
Object {
|
|
27
43
|
"Properties": Object {
|
|
44
|
+
"rubricEnabled": false,
|
|
45
|
+
"spellCheckEnabled": false,
|
|
28
46
|
"teacherInstructionsEnabled": undefined,
|
|
29
47
|
},
|
|
30
48
|
"Settings": Object {
|
|
31
|
-
"
|
|
49
|
+
"backgroundImageEnabled": undefined,
|
|
32
50
|
"promptEnabled": undefined,
|
|
33
51
|
},
|
|
34
52
|
}
|
|
@@ -54,7 +72,19 @@ exports[`Root snapshot renders 1`] = `
|
|
|
54
72
|
label="Item Stem"
|
|
55
73
|
>
|
|
56
74
|
<EditableHtml
|
|
75
|
+
languageCharactersProps={
|
|
76
|
+
Array [
|
|
77
|
+
Object {
|
|
78
|
+
"language": "spanish",
|
|
79
|
+
},
|
|
80
|
+
Object {
|
|
81
|
+
"language": "special",
|
|
82
|
+
},
|
|
83
|
+
]
|
|
84
|
+
}
|
|
57
85
|
markup="Test Prompt"
|
|
86
|
+
maxImageHeight={300}
|
|
87
|
+
maxImageWidth={300}
|
|
58
88
|
onChange={[Function]}
|
|
59
89
|
toolbarOpts={
|
|
60
90
|
Object {
|
|
@@ -63,18 +93,6 @@ exports[`Root snapshot renders 1`] = `
|
|
|
63
93
|
}
|
|
64
94
|
/>
|
|
65
95
|
</Component>
|
|
66
|
-
<div>
|
|
67
|
-
<WithStyles(Typography)
|
|
68
|
-
variant="subheading"
|
|
69
|
-
>
|
|
70
|
-
Define Background Image
|
|
71
|
-
</WithStyles(Typography)>
|
|
72
|
-
<WithStyles(ImageContainer)
|
|
73
|
-
imageUrl=""
|
|
74
|
-
onImageUpload={[Function]}
|
|
75
|
-
onUpdateImageDimension={[Function]}
|
|
76
|
-
/>
|
|
77
|
-
</div>
|
|
78
96
|
</div>
|
|
79
97
|
</ConfigLayout>
|
|
80
98
|
</div>
|
|
@@ -138,7 +138,7 @@ describe('ImageContainer', () => {
|
|
|
138
138
|
});
|
|
139
139
|
|
|
140
140
|
it('handleOnImageLoad calls onUpdateImageDimension', () => {
|
|
141
|
-
w.instance().handleOnImageLoad({ target: { offsetHeight: 50, offsetWidth: 50 }});
|
|
141
|
+
w.instance().handleOnImageLoad({ target: { offsetHeight: 50, offsetWidth: 50, naturalWidth: 50, naturalHeight: 50 }});
|
|
142
142
|
|
|
143
143
|
expect(onUpdateImageDimension).toHaveBeenCalledWith({
|
|
144
144
|
height: 50,
|
|
@@ -147,7 +147,7 @@ describe('ImageContainer', () => {
|
|
|
147
147
|
});
|
|
148
148
|
|
|
149
149
|
it('stopResizing calls onUpdateImageDimension', () => {
|
|
150
|
-
w.instance().handleOnImageLoad({ target: { offsetHeight: 50, offsetWidth: 50 }});
|
|
150
|
+
w.instance().handleOnImageLoad({ target: { offsetHeight: 50, offsetWidth: 50, naturalWidth: 50, naturalHeight: 50 }});
|
|
151
151
|
|
|
152
152
|
expect(onUpdateImageDimension).toHaveBeenCalledWith(w.instance().state.dimensions);
|
|
153
153
|
});
|
|
@@ -9,13 +9,19 @@ export default {
|
|
|
9
9
|
promptEnabled: true,
|
|
10
10
|
teacherInstructionsEnabled: true,
|
|
11
11
|
studentInstructionsEnabled: true,
|
|
12
|
+
backgroundImageEnabled: true,
|
|
13
|
+
spellCheckEnabled:true,
|
|
12
14
|
toolbarEditorPosition: 'bottom',
|
|
13
15
|
},
|
|
14
16
|
configuration: {
|
|
17
|
+
spellCheck: {
|
|
18
|
+
label: 'Spellcheck',
|
|
19
|
+
settings:false,
|
|
20
|
+
enabled:true
|
|
21
|
+
},
|
|
15
22
|
backgroundImage: {
|
|
16
23
|
settings: true,
|
|
17
|
-
label: 'Background Image'
|
|
18
|
-
enabled: true
|
|
24
|
+
label: 'Background Image'
|
|
19
25
|
},
|
|
20
26
|
prompt: {
|
|
21
27
|
settings: true,
|
|
@@ -24,6 +30,18 @@ export default {
|
|
|
24
30
|
teacherInstructions: {
|
|
25
31
|
settings: true,
|
|
26
32
|
label: 'Teacher Instructions',
|
|
33
|
+
},
|
|
34
|
+
maxImageWidth: {
|
|
35
|
+
teacherInstructions: 300,
|
|
36
|
+
prompt: 300
|
|
37
|
+
},
|
|
38
|
+
maxImageHeight: {
|
|
39
|
+
teacherInstructions: 300,
|
|
40
|
+
prompt: 300
|
|
41
|
+
},
|
|
42
|
+
withRubric: {
|
|
43
|
+
settings: false,
|
|
44
|
+
label: 'Add Rubric'
|
|
27
45
|
}
|
|
28
46
|
}
|
|
29
47
|
};
|
|
@@ -13,11 +13,11 @@ export class ImageContainer extends Component {
|
|
|
13
13
|
constructor(props) {
|
|
14
14
|
super(props);
|
|
15
15
|
this.state = {
|
|
16
|
-
maxImageWidth:
|
|
17
|
-
maxImageHeight:
|
|
16
|
+
maxImageWidth: "100%",
|
|
17
|
+
maxImageHeight: "auto",
|
|
18
18
|
dragEnabled: true,
|
|
19
19
|
dropzoneActive: false,
|
|
20
|
-
}
|
|
20
|
+
};
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
componentDidMount() {
|
|
@@ -26,7 +26,7 @@ export class ImageContainer extends Component {
|
|
|
26
26
|
const { height, width } = positionInfo;
|
|
27
27
|
this.setState({
|
|
28
28
|
maxImageWidth: width,
|
|
29
|
-
maxImageHeight: height
|
|
29
|
+
maxImageHeight: height,
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
32
|
}
|
|
@@ -46,7 +46,7 @@ export class ImageContainer extends Component {
|
|
|
46
46
|
this.handleFileRead(file);
|
|
47
47
|
};
|
|
48
48
|
|
|
49
|
-
makeDropzoneActive= () => this.setState({ dropzoneActive: true });
|
|
49
|
+
makeDropzoneActive = () => this.setState({ dropzoneActive: true });
|
|
50
50
|
|
|
51
51
|
makeDropzoneInactive = () => this.setState({ dropzoneActive: false });
|
|
52
52
|
|
|
@@ -84,15 +84,22 @@ export class ImageContainer extends Component {
|
|
|
84
84
|
handleDisableDrag = () => this.setState({ dragEnabled: false });
|
|
85
85
|
handleInputClick = () => this.input.click();
|
|
86
86
|
|
|
87
|
-
handleOnImageLoad = ({ target: { offsetHeight, offsetWidth } }) => {
|
|
88
|
-
const { onUpdateImageDimension } = this.props;
|
|
87
|
+
handleOnImageLoad = ({ target: { offsetHeight, offsetWidth, naturalHeight, naturalWidth } }) => {
|
|
88
|
+
const { onUpdateImageDimension, imageDimensions } = this.props;
|
|
89
89
|
const resizeHandle = this.resize;
|
|
90
90
|
|
|
91
91
|
const dimensions = {
|
|
92
|
-
height: offsetHeight,
|
|
93
|
-
width: offsetWidth
|
|
92
|
+
height: (imageDimensions && imageDimensions.height) || offsetHeight || naturalHeight,
|
|
93
|
+
width: (imageDimensions && imageDimensions.width) || offsetWidth || naturalWidth,
|
|
94
94
|
};
|
|
95
95
|
|
|
96
|
+
// check if aspect ratio is not respected on replacing image
|
|
97
|
+
const imageAspectRatio = naturalWidth / naturalHeight;
|
|
98
|
+
|
|
99
|
+
if (dimensions.width !== dimensions.height * imageAspectRatio) {
|
|
100
|
+
dimensions.width = dimensions.height * imageAspectRatio;
|
|
101
|
+
}
|
|
102
|
+
|
|
96
103
|
this.setState({ dimensions });
|
|
97
104
|
onUpdateImageDimension(dimensions);
|
|
98
105
|
|
|
@@ -117,20 +124,26 @@ export class ImageContainer extends Component {
|
|
|
117
124
|
|
|
118
125
|
startResizing = (e) => {
|
|
119
126
|
const box = this.image;
|
|
120
|
-
const { maxImageWidth } = this.state;
|
|
127
|
+
const { maxImageWidth, maxImageHeight, dimensions } = this.state;
|
|
121
128
|
|
|
122
129
|
const bounds = e.target.getBoundingClientRect();
|
|
123
130
|
const x = e.clientX - bounds.left;
|
|
124
131
|
const y = e.clientY - bounds.top;
|
|
125
132
|
|
|
126
|
-
const
|
|
133
|
+
const imageAspectRatio = dimensions.width / dimensions.height;
|
|
134
|
+
const fitsContainer = x <= maxImageWidth + 5 && (x / imageAspectRatio) <= maxImageHeight + 5;
|
|
127
135
|
const hasMinimumWidth = x > 150 && y > 150;
|
|
128
136
|
|
|
129
|
-
if (fitsContainer && hasMinimumWidth) {
|
|
137
|
+
if (fitsContainer && hasMinimumWidth && box) {
|
|
130
138
|
box.style.width = `${x}px`;
|
|
131
|
-
box.style.height = `${
|
|
139
|
+
box.style.height = `${x / imageAspectRatio}px`;
|
|
132
140
|
|
|
133
|
-
this.setState({
|
|
141
|
+
this.setState({
|
|
142
|
+
dimensions: {
|
|
143
|
+
width: x,
|
|
144
|
+
height: x / imageAspectRatio,
|
|
145
|
+
},
|
|
146
|
+
});
|
|
134
147
|
}
|
|
135
148
|
|
|
136
149
|
this.handleDisableDrag();
|
|
@@ -141,26 +154,22 @@ export class ImageContainer extends Component {
|
|
|
141
154
|
|
|
142
155
|
return (
|
|
143
156
|
<div>
|
|
144
|
-
<Button
|
|
145
|
-
label={label}
|
|
146
|
-
onClick={this.handleInputClick}
|
|
147
|
-
/>
|
|
157
|
+
<Button label={label} onClick={this.handleInputClick} />
|
|
148
158
|
<input
|
|
149
159
|
accept="image/*"
|
|
150
160
|
className={classes.input}
|
|
151
161
|
onChange={this.handleUploadImage}
|
|
152
|
-
ref={ref => {
|
|
162
|
+
ref={(ref) => {
|
|
163
|
+
this.input = ref;
|
|
164
|
+
}}
|
|
153
165
|
type="file"
|
|
154
166
|
/>
|
|
155
167
|
</div>
|
|
156
|
-
)
|
|
168
|
+
);
|
|
157
169
|
}
|
|
158
170
|
|
|
159
171
|
render() {
|
|
160
|
-
const {
|
|
161
|
-
classes,
|
|
162
|
-
imageUrl
|
|
163
|
-
} = this.props;
|
|
172
|
+
const { classes, imageUrl, imageDimensions } = this.props;
|
|
164
173
|
const {
|
|
165
174
|
dropzoneActive,
|
|
166
175
|
dragEnabled,
|
|
@@ -169,32 +178,55 @@ export class ImageContainer extends Component {
|
|
|
169
178
|
} = this.state;
|
|
170
179
|
|
|
171
180
|
return (
|
|
172
|
-
<div className={classes.base}
|
|
173
|
-
<div
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
181
|
+
<div className={classes.base}>
|
|
182
|
+
<div
|
|
183
|
+
className={`${classes.box} ${
|
|
184
|
+
dropzoneActive ? classes.boxActive : ''
|
|
185
|
+
}`}
|
|
186
|
+
{...(dragEnabled
|
|
187
|
+
? {
|
|
188
|
+
onDragExit: this.handleOnDragExit,
|
|
189
|
+
onDragLeave: this.handleOnDragExit,
|
|
190
|
+
onDragOver: this.handleOnDragOver,
|
|
191
|
+
onDrop: this.handleOnDrop,
|
|
192
|
+
}
|
|
193
|
+
: {})}
|
|
180
194
|
>
|
|
181
195
|
<div className={classes.toolbar}>
|
|
182
|
-
{this.renderUploadControl(
|
|
196
|
+
{this.renderUploadControl(
|
|
197
|
+
imageUrl ? 'Replace Image' : 'Upload Image'
|
|
198
|
+
)}
|
|
183
199
|
</div>
|
|
184
200
|
|
|
185
|
-
<div
|
|
201
|
+
<div
|
|
202
|
+
ref={(ref) => {
|
|
203
|
+
this.imageSection = ref;
|
|
204
|
+
}}
|
|
205
|
+
className={classes.drawableHeight}
|
|
206
|
+
>
|
|
186
207
|
{imageUrl ? (
|
|
187
208
|
<div className={classes.imageContainer}>
|
|
188
209
|
<img
|
|
189
210
|
className={classes.image}
|
|
190
211
|
height="auto"
|
|
191
212
|
onLoad={this.handleOnImageLoad}
|
|
192
|
-
ref={ref => {
|
|
213
|
+
ref={(ref) => {
|
|
214
|
+
this.image = ref;
|
|
215
|
+
}}
|
|
193
216
|
src={imageUrl}
|
|
194
|
-
style={{
|
|
195
|
-
|
|
217
|
+
style={{
|
|
218
|
+
width: imageDimensions && imageDimensions.width ? imageDimensions.width : undefined,
|
|
219
|
+
maxWidth: maxImageWidth,
|
|
220
|
+
maxHeight: maxImageHeight
|
|
221
|
+
}}
|
|
222
|
+
alt=""
|
|
223
|
+
/>
|
|
224
|
+
<div
|
|
225
|
+
ref={(ref) => {
|
|
226
|
+
this.resize = ref;
|
|
227
|
+
}}
|
|
228
|
+
className={classes.resize}
|
|
196
229
|
/>
|
|
197
|
-
<div ref={ref => { this.resize = ref; }} className={classes.resize} />
|
|
198
230
|
</div>
|
|
199
231
|
) : (
|
|
200
232
|
<div className={`${classes.drawableHeight} ${classes.centered}`}>
|
|
@@ -210,25 +242,25 @@ export class ImageContainer extends Component {
|
|
|
210
242
|
}
|
|
211
243
|
}
|
|
212
244
|
|
|
213
|
-
const styles = theme => ({
|
|
245
|
+
const styles = (theme) => ({
|
|
214
246
|
base: {
|
|
215
|
-
marginTop: theme.spacing.unit * 2
|
|
247
|
+
marginTop: theme.spacing.unit * 2,
|
|
216
248
|
},
|
|
217
249
|
box: {
|
|
218
250
|
border: '1px solid #E0E1E6',
|
|
219
|
-
borderRadius: '5px'
|
|
251
|
+
borderRadius: '5px',
|
|
220
252
|
},
|
|
221
253
|
boxActive: {
|
|
222
|
-
border: '1px solid #0032C2'
|
|
254
|
+
border: '1px solid #0032C2',
|
|
223
255
|
},
|
|
224
256
|
centered: {
|
|
225
257
|
alignItems: 'center',
|
|
226
258
|
display: 'flex',
|
|
227
259
|
flexDirection: 'column',
|
|
228
|
-
justifyContent: 'center'
|
|
260
|
+
justifyContent: 'center',
|
|
229
261
|
},
|
|
230
262
|
drawableHeight: {
|
|
231
|
-
minHeight: 350
|
|
263
|
+
minHeight: 350,
|
|
232
264
|
},
|
|
233
265
|
image: {
|
|
234
266
|
alignItems: 'center',
|
|
@@ -237,7 +269,7 @@ const styles = theme => ({
|
|
|
237
269
|
},
|
|
238
270
|
imageContainer: {
|
|
239
271
|
position: 'relative',
|
|
240
|
-
width: 'fit-content'
|
|
272
|
+
width: 'fit-content',
|
|
241
273
|
},
|
|
242
274
|
resize: {
|
|
243
275
|
borderBottom: '1px solid #727272',
|
|
@@ -247,10 +279,10 @@ const styles = theme => ({
|
|
|
247
279
|
height: '10px',
|
|
248
280
|
position: 'absolute',
|
|
249
281
|
right: '-10px',
|
|
250
|
-
width: '10px'
|
|
282
|
+
width: '10px',
|
|
251
283
|
},
|
|
252
284
|
input: {
|
|
253
|
-
display: 'none'
|
|
285
|
+
display: 'none',
|
|
254
286
|
},
|
|
255
287
|
toolbar: {
|
|
256
288
|
backgroundColor: '#ECEDF1',
|
|
@@ -258,15 +290,15 @@ const styles = theme => ({
|
|
|
258
290
|
borderTopLeftRadius: '5px',
|
|
259
291
|
borderTopRightRadius: '5px',
|
|
260
292
|
display: 'flex',
|
|
261
|
-
padding: '12px 8px'
|
|
262
|
-
}
|
|
293
|
+
padding: '12px 8px',
|
|
294
|
+
},
|
|
263
295
|
});
|
|
264
296
|
|
|
265
297
|
ImageContainer.propTypes = {
|
|
266
298
|
classes: PropTypes.object.isRequired,
|
|
267
299
|
imageUrl: PropTypes.string.isRequired,
|
|
268
300
|
onImageUpload: PropTypes.func.isRequired,
|
|
269
|
-
onUpdateImageDimension: PropTypes.func.isRequired
|
|
301
|
+
onUpdateImageDimension: PropTypes.func.isRequired,
|
|
270
302
|
};
|
|
271
303
|
|
|
272
304
|
export default withStyles(styles)(ImageContainer);
|
package/configure/src/index.js
CHANGED
|
@@ -2,6 +2,8 @@ import {
|
|
|
2
2
|
ModelUpdatedEvent,
|
|
3
3
|
DeleteImageEvent,
|
|
4
4
|
InsertImageEvent,
|
|
5
|
+
InsertSoundEvent,
|
|
6
|
+
DeleteSoundEvent
|
|
5
7
|
} from '@pie-framework/pie-configure-events';
|
|
6
8
|
|
|
7
9
|
import React from 'react';
|
|
@@ -49,12 +51,6 @@ export default class DrawableResponseConfigure extends HTMLElement {
|
|
|
49
51
|
};
|
|
50
52
|
|
|
51
53
|
onConfigurationChanged = (c) => {
|
|
52
|
-
if (!c.backgroundImage.enabled) {
|
|
53
|
-
this.onModelChanged({
|
|
54
|
-
...this._model,
|
|
55
|
-
imageUrl: ''
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
54
|
this._configuration = c;
|
|
59
55
|
this._render();
|
|
60
56
|
};
|
|
@@ -67,6 +63,14 @@ export default class DrawableResponseConfigure extends HTMLElement {
|
|
|
67
63
|
this.dispatchEvent(new DeleteImageEvent(src, done));
|
|
68
64
|
};
|
|
69
65
|
|
|
66
|
+
insertSound(handler) {
|
|
67
|
+
this.dispatchEvent(new InsertSoundEvent(handler));
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
onDeleteSound(src, done) {
|
|
71
|
+
this.dispatchEvent(new DeleteSoundEvent(src, done));
|
|
72
|
+
}
|
|
73
|
+
|
|
70
74
|
_render() {
|
|
71
75
|
log('_render');
|
|
72
76
|
let element = React.createElement(Root, {
|
|
@@ -77,6 +81,10 @@ export default class DrawableResponseConfigure extends HTMLElement {
|
|
|
77
81
|
imageSupport: {
|
|
78
82
|
add: this.insertImage,
|
|
79
83
|
delete: this.onDeleteImage
|
|
84
|
+
},
|
|
85
|
+
uploadSoundSupport: {
|
|
86
|
+
add: this.insertSound.bind(this),
|
|
87
|
+
delete: this.onDeleteSound.bind(this)
|
|
80
88
|
}
|
|
81
89
|
});
|
|
82
90
|
ReactDOM.render(element, this);
|
package/configure/src/root.jsx
CHANGED
|
@@ -11,22 +11,22 @@ import cloneDeep from 'lodash/cloneDeep';
|
|
|
11
11
|
const { Panel, toggle } = settings;
|
|
12
12
|
|
|
13
13
|
export class Root extends React.Component {
|
|
14
|
-
onPromptChanged = prompt => {
|
|
14
|
+
onPromptChanged = (prompt) => {
|
|
15
15
|
const { model, onModelChanged } = this.props;
|
|
16
16
|
const update = cloneDeep(model);
|
|
17
17
|
|
|
18
18
|
onModelChanged({
|
|
19
19
|
...update,
|
|
20
|
-
prompt
|
|
20
|
+
prompt,
|
|
21
21
|
});
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
onTeacherInstructionsChanged = teacherInstructions => {
|
|
24
|
+
onTeacherInstructionsChanged = (teacherInstructions) => {
|
|
25
25
|
const { model, onModelChanged } = this.props;
|
|
26
26
|
|
|
27
27
|
onModelChanged({
|
|
28
28
|
...model,
|
|
29
|
-
teacherInstructions
|
|
29
|
+
teacherInstructions,
|
|
30
30
|
});
|
|
31
31
|
};
|
|
32
32
|
|
|
@@ -35,34 +35,62 @@ export class Root extends React.Component {
|
|
|
35
35
|
|
|
36
36
|
onModelChanged({
|
|
37
37
|
...model,
|
|
38
|
-
imageDimensions: dimensions
|
|
38
|
+
imageDimensions: dimensions,
|
|
39
39
|
});
|
|
40
40
|
};
|
|
41
41
|
|
|
42
|
-
onImageUpload = imageUrl => {
|
|
42
|
+
onImageUpload = (imageUrl) => {
|
|
43
43
|
const { model, onModelChanged } = this.props;
|
|
44
44
|
|
|
45
45
|
onModelChanged({
|
|
46
46
|
...model,
|
|
47
|
-
imageUrl
|
|
47
|
+
imageUrl,
|
|
48
48
|
});
|
|
49
49
|
};
|
|
50
50
|
|
|
51
|
+
componentDidMount() {
|
|
52
|
+
const { model, onModelChanged, configuration } = this.props || {};
|
|
53
|
+
const { withRubric } = configuration || {};
|
|
54
|
+
|
|
55
|
+
if (withRubric.enabled) {
|
|
56
|
+
onModelChanged({
|
|
57
|
+
...model,
|
|
58
|
+
rubricEnabled: true,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
51
63
|
render() {
|
|
52
64
|
const {
|
|
53
65
|
classes,
|
|
54
66
|
configuration,
|
|
55
67
|
model,
|
|
56
68
|
imageSupport,
|
|
69
|
+
uploadSoundSupport,
|
|
57
70
|
onConfigurationChanged,
|
|
58
|
-
onModelChanged
|
|
71
|
+
onModelChanged,
|
|
59
72
|
} = this.props;
|
|
60
|
-
const {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
73
|
+
const {
|
|
74
|
+
backgroundImage = {},
|
|
75
|
+
prompt = {},
|
|
76
|
+
teacherInstructions = {},
|
|
77
|
+
spellCheck = {},
|
|
78
|
+
maxImageWidth = {},
|
|
79
|
+
maxImageHeight = {},
|
|
80
|
+
withRubric,
|
|
81
|
+
} = configuration || {};
|
|
82
|
+
const {
|
|
83
|
+
teacherInstructionsEnabled,
|
|
84
|
+
promptEnabled,
|
|
85
|
+
spellCheckEnabled,
|
|
86
|
+
backgroundImageEnabled,
|
|
87
|
+
rubricEnabled
|
|
88
|
+
} = model || {};
|
|
64
89
|
const toolbarOpts = {};
|
|
65
90
|
|
|
91
|
+
const defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;
|
|
92
|
+
const defaultImageMaxHeight = maxImageHeight && maxImageHeight.prompt;
|
|
93
|
+
|
|
66
94
|
switch (model.toolbarEditorPosition) {
|
|
67
95
|
case 'top':
|
|
68
96
|
toolbarOpts.position = 'top';
|
|
@@ -83,16 +111,17 @@ export class Root extends React.Component {
|
|
|
83
111
|
onChangeConfiguration={onConfigurationChanged}
|
|
84
112
|
groups={{
|
|
85
113
|
Settings: {
|
|
86
|
-
|
|
87
|
-
backgroundImage.settings &&
|
|
88
|
-
toggle(backgroundImage.label, true),
|
|
114
|
+
backgroundImageEnabled: backgroundImage.settings && toggle(backgroundImage.label),
|
|
89
115
|
promptEnabled: prompt.settings && toggle(prompt.label)
|
|
90
116
|
},
|
|
91
117
|
Properties: {
|
|
92
118
|
teacherInstructionsEnabled:
|
|
93
119
|
teacherInstructions.settings &&
|
|
94
|
-
toggle(teacherInstructions.label)
|
|
95
|
-
|
|
120
|
+
toggle(teacherInstructions.label),
|
|
121
|
+
spellCheckEnabled:
|
|
122
|
+
spellCheck.settings && toggle(spellCheck.label),
|
|
123
|
+
rubricEnabled: withRubric.settings && toggle(withRubric.label)
|
|
124
|
+
},
|
|
96
125
|
}}
|
|
97
126
|
/>
|
|
98
127
|
}
|
|
@@ -109,6 +138,11 @@ export class Root extends React.Component {
|
|
|
109
138
|
imageSupport={imageSupport}
|
|
110
139
|
nonEmpty={false}
|
|
111
140
|
toolbarOpts={toolbarOpts}
|
|
141
|
+
spellCheck={spellCheckEnabled}
|
|
142
|
+
maxImageWidth={maxImageWidth && maxImageWidth.teacherInstructions || defaultImageMaxWidth}
|
|
143
|
+
maxImageHeight={maxImageHeight && maxImageHeight.teacherInstructions || defaultImageMaxHeight}
|
|
144
|
+
uploadSoundSupport={uploadSoundSupport}
|
|
145
|
+
languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}
|
|
112
146
|
/>
|
|
113
147
|
</InputContainer>
|
|
114
148
|
)}
|
|
@@ -119,11 +153,17 @@ export class Root extends React.Component {
|
|
|
119
153
|
markup={model.prompt}
|
|
120
154
|
onChange={this.onPromptChanged}
|
|
121
155
|
toolbarOpts={toolbarOpts}
|
|
156
|
+
spellCheck={spellCheckEnabled}
|
|
157
|
+
imageSupport={imageSupport}
|
|
158
|
+
maxImageWidth={defaultImageMaxWidth}
|
|
159
|
+
maxImageHeight={defaultImageMaxHeight}
|
|
160
|
+
uploadSoundSupport={uploadSoundSupport}
|
|
161
|
+
languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}
|
|
122
162
|
/>
|
|
123
163
|
</InputContainer>
|
|
124
164
|
)}
|
|
125
165
|
|
|
126
|
-
{
|
|
166
|
+
{backgroundImageEnabled && (
|
|
127
167
|
<div>
|
|
128
168
|
<Typography className={classes.label} variant="subheading">
|
|
129
169
|
Define Background Image
|
|
@@ -133,6 +173,7 @@ export class Root extends React.Component {
|
|
|
133
173
|
imageUrl={model.imageUrl}
|
|
134
174
|
onUpdateImageDimension={this.onUpdateImageDimension}
|
|
135
175
|
onImageUpload={this.onImageUpload}
|
|
176
|
+
imageDimensions={model.imageDimensions}
|
|
136
177
|
/>
|
|
137
178
|
</div>
|
|
138
179
|
)}
|
|
@@ -143,20 +184,20 @@ export class Root extends React.Component {
|
|
|
143
184
|
}
|
|
144
185
|
}
|
|
145
186
|
|
|
146
|
-
const styles = theme => ({
|
|
187
|
+
const styles = (theme) => ({
|
|
147
188
|
base: {
|
|
148
|
-
marginTop: theme.spacing.unit * 3
|
|
189
|
+
marginTop: theme.spacing.unit * 3,
|
|
149
190
|
},
|
|
150
191
|
label: {
|
|
151
|
-
marginTop: theme.spacing.unit * 4
|
|
192
|
+
marginTop: theme.spacing.unit * 4,
|
|
152
193
|
},
|
|
153
194
|
prompt: {
|
|
154
195
|
paddingTop: theme.spacing.unit * 2,
|
|
155
|
-
width: '100%'
|
|
196
|
+
width: '100%',
|
|
156
197
|
},
|
|
157
198
|
regular: {
|
|
158
|
-
marginBottom: theme.spacing.unit * 3
|
|
159
|
-
}
|
|
199
|
+
marginBottom: theme.spacing.unit * 3,
|
|
200
|
+
},
|
|
160
201
|
});
|
|
161
202
|
|
|
162
203
|
Root.propTypes = {
|
|
@@ -165,7 +206,11 @@ Root.propTypes = {
|
|
|
165
206
|
model: PropTypes.object.isRequired,
|
|
166
207
|
imageSupport: PropTypes.shape({
|
|
167
208
|
add: PropTypes.func,
|
|
168
|
-
delete: PropTypes.func
|
|
209
|
+
delete: PropTypes.func,
|
|
210
|
+
}),
|
|
211
|
+
uploadSoundSupport: PropTypes.shape({
|
|
212
|
+
add: PropTypes.func,
|
|
213
|
+
delete: PropTypes.func,
|
|
169
214
|
}),
|
|
170
215
|
onModelChanged: PropTypes.func.isRequired,
|
|
171
216
|
onConfigurationChanged: PropTypes.func.isRequired,
|