@pie-element/drawing-response 3.6.0 → 3.6.1-beta.587
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 +507 -0
- package/configure/CHANGELOG.md +446 -0
- package/configure/lib/button.js.map +1 -1
- package/configure/lib/defaults.js +22 -7
- 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 +65 -12
- package/configure/lib/index.js.map +1 -1
- package/configure/lib/root.js +78 -48
- 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 +38 -18
- package/configure/src/__tests__/image-container.test.jsx +42 -35
- package/configure/src/__tests__/index.test.js +7 -7
- package/configure/src/__tests__/root.test.jsx +18 -25
- package/configure/src/button.jsx +4 -4
- package/configure/src/defaults.js +25 -10
- package/configure/src/image-container.jsx +80 -59
- package/configure/src/index.js +46 -14
- package/configure/src/root.jsx +72 -76
- package/controller/CHANGELOG.md +58 -0
- package/controller/lib/defaults.js.map +1 -1
- package/controller/lib/index.js +13 -12
- package/controller/lib/index.js.map +1 -1
- package/controller/package.json +1 -1
- package/controller/src/__tests__/index.test.js +35 -34
- package/controller/src/defaults.js +2 -2
- package/controller/src/index.js +13 -17
- package/docs/config-schema.json +111 -1
- package/docs/config-schema.json.md +87 -3
- package/docs/demo/config.js +2 -2
- package/docs/demo/generate.js +5 -2
- package/docs/demo/session.js +4 -4
- package/docs/pie-schema.json +70 -6
- package/docs/pie-schema.json.md +55 -4
- package/lib/drawing-response/button.js.map +1 -1
- package/lib/drawing-response/constants.js.map +1 -1
- package/lib/drawing-response/container.js +80 -25
- 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 +46 -16
- package/lib/drawing-response/drawable-main.js.map +1 -1
- package/lib/drawing-response/drawable-palette.js +7 -2
- 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/factory.js.map +1 -1
- package/lib/drawing-response/icon.js.map +1 -1
- package/lib/drawing-response/index.js +11 -15
- 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 +5 -4
- package/src/__tests__/drawing-index-test.jsx +4 -4
- package/src/drawing-response/__tests__/__snapshots__/container.test.jsx.snap +174 -290
- package/src/drawing-response/__tests__/__snapshots__/drawing-main.test.jsx.snap +26 -2
- package/src/drawing-response/__tests__/container.test.jsx +9 -2
- package/src/drawing-response/__tests__/drawable-helper.test.jsx +1 -1
- package/src/drawing-response/__tests__/drawing-main.test.jsx +74 -86
- package/src/drawing-response/button.jsx +5 -8
- package/src/drawing-response/constants.js +42 -34
- package/src/drawing-response/container.jsx +93 -70
- package/src/drawing-response/drawable-image.jsx +5 -4
- package/src/drawing-response/drawable-main.jsx +46 -17
- package/src/drawing-response/drawable-palette.jsx +18 -35
- package/src/drawing-response/drawable-text.jsx +34 -48
- package/src/drawing-response/drawable-transformer.jsx +3 -1
- package/src/drawing-response/factory.js +3 -11
- package/src/drawing-response/icon.jsx +19 -20
- package/src/drawing-response/index.jsx +14 -20
- package/src/index.js +8 -11
|
@@ -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,60 +154,68 @@ 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
|
-
|
|
162
|
-
imageUrl
|
|
163
|
-
} = this.props;
|
|
164
|
-
const {
|
|
165
|
-
dropzoneActive,
|
|
166
|
-
dragEnabled,
|
|
167
|
-
maxImageHeight,
|
|
168
|
-
maxImageWidth
|
|
169
|
-
} = this.state;
|
|
172
|
+
const { classes, imageUrl, imageDimensions } = this.props;
|
|
173
|
+
const { dropzoneActive, dragEnabled, maxImageHeight, maxImageWidth } = this.state;
|
|
170
174
|
|
|
171
175
|
return (
|
|
172
|
-
<div className={classes.base}
|
|
173
|
-
<div
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
176
|
+
<div className={classes.base}>
|
|
177
|
+
<div
|
|
178
|
+
className={`${classes.box} ${dropzoneActive ? classes.boxActive : ''}`}
|
|
179
|
+
{...(dragEnabled
|
|
180
|
+
? {
|
|
181
|
+
onDragExit: this.handleOnDragExit,
|
|
182
|
+
onDragLeave: this.handleOnDragExit,
|
|
183
|
+
onDragOver: this.handleOnDragOver,
|
|
184
|
+
onDrop: this.handleOnDrop,
|
|
185
|
+
}
|
|
186
|
+
: {})}
|
|
180
187
|
>
|
|
181
|
-
<div className={classes.toolbar}>
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
188
|
+
<div className={classes.toolbar}>{this.renderUploadControl(imageUrl ? 'Replace Image' : 'Upload Image')}</div>
|
|
189
|
+
|
|
190
|
+
<div
|
|
191
|
+
ref={(ref) => {
|
|
192
|
+
this.imageSection = ref;
|
|
193
|
+
}}
|
|
194
|
+
className={classes.drawableHeight}
|
|
195
|
+
>
|
|
186
196
|
{imageUrl ? (
|
|
187
197
|
<div className={classes.imageContainer}>
|
|
188
198
|
<img
|
|
189
199
|
className={classes.image}
|
|
190
200
|
height="auto"
|
|
191
201
|
onLoad={this.handleOnImageLoad}
|
|
192
|
-
ref={ref => {
|
|
202
|
+
ref={(ref) => {
|
|
203
|
+
this.image = ref;
|
|
204
|
+
}}
|
|
193
205
|
src={imageUrl}
|
|
194
|
-
style={{
|
|
195
|
-
|
|
206
|
+
style={{
|
|
207
|
+
width: imageDimensions && imageDimensions.width ? imageDimensions.width : undefined,
|
|
208
|
+
maxWidth: maxImageWidth,
|
|
209
|
+
maxHeight: maxImageHeight,
|
|
210
|
+
}}
|
|
211
|
+
alt=""
|
|
212
|
+
/>
|
|
213
|
+
<div
|
|
214
|
+
ref={(ref) => {
|
|
215
|
+
this.resize = ref;
|
|
216
|
+
}}
|
|
217
|
+
className={classes.resize}
|
|
196
218
|
/>
|
|
197
|
-
<div ref={ref => { this.resize = ref; }} className={classes.resize} />
|
|
198
219
|
</div>
|
|
199
220
|
) : (
|
|
200
221
|
<div className={`${classes.drawableHeight} ${classes.centered}`}>
|
|
@@ -210,25 +231,25 @@ export class ImageContainer extends Component {
|
|
|
210
231
|
}
|
|
211
232
|
}
|
|
212
233
|
|
|
213
|
-
const styles = theme => ({
|
|
234
|
+
const styles = (theme) => ({
|
|
214
235
|
base: {
|
|
215
|
-
marginTop: theme.spacing.unit * 2
|
|
236
|
+
marginTop: theme.spacing.unit * 2,
|
|
216
237
|
},
|
|
217
238
|
box: {
|
|
218
239
|
border: '1px solid #E0E1E6',
|
|
219
|
-
borderRadius: '5px'
|
|
240
|
+
borderRadius: '5px',
|
|
220
241
|
},
|
|
221
242
|
boxActive: {
|
|
222
|
-
border: '1px solid #0032C2'
|
|
243
|
+
border: '1px solid #0032C2',
|
|
223
244
|
},
|
|
224
245
|
centered: {
|
|
225
246
|
alignItems: 'center',
|
|
226
247
|
display: 'flex',
|
|
227
248
|
flexDirection: 'column',
|
|
228
|
-
justifyContent: 'center'
|
|
249
|
+
justifyContent: 'center',
|
|
229
250
|
},
|
|
230
251
|
drawableHeight: {
|
|
231
|
-
minHeight: 350
|
|
252
|
+
minHeight: 350,
|
|
232
253
|
},
|
|
233
254
|
image: {
|
|
234
255
|
alignItems: 'center',
|
|
@@ -237,7 +258,7 @@ const styles = theme => ({
|
|
|
237
258
|
},
|
|
238
259
|
imageContainer: {
|
|
239
260
|
position: 'relative',
|
|
240
|
-
width: 'fit-content'
|
|
261
|
+
width: 'fit-content',
|
|
241
262
|
},
|
|
242
263
|
resize: {
|
|
243
264
|
borderBottom: '1px solid #727272',
|
|
@@ -247,10 +268,10 @@ const styles = theme => ({
|
|
|
247
268
|
height: '10px',
|
|
248
269
|
position: 'absolute',
|
|
249
270
|
right: '-10px',
|
|
250
|
-
width: '10px'
|
|
271
|
+
width: '10px',
|
|
251
272
|
},
|
|
252
273
|
input: {
|
|
253
|
-
display: 'none'
|
|
274
|
+
display: 'none',
|
|
254
275
|
},
|
|
255
276
|
toolbar: {
|
|
256
277
|
backgroundColor: '#ECEDF1',
|
|
@@ -258,15 +279,15 @@ const styles = theme => ({
|
|
|
258
279
|
borderTopLeftRadius: '5px',
|
|
259
280
|
borderTopRightRadius: '5px',
|
|
260
281
|
display: 'flex',
|
|
261
|
-
padding: '12px 8px'
|
|
262
|
-
}
|
|
282
|
+
padding: '12px 8px',
|
|
283
|
+
},
|
|
263
284
|
});
|
|
264
285
|
|
|
265
286
|
ImageContainer.propTypes = {
|
|
266
287
|
classes: PropTypes.object.isRequired,
|
|
267
288
|
imageUrl: PropTypes.string.isRequired,
|
|
268
289
|
onImageUpload: PropTypes.func.isRequired,
|
|
269
|
-
onUpdateImageDimension: PropTypes.func.isRequired
|
|
290
|
+
onUpdateImageDimension: PropTypes.func.isRequired,
|
|
270
291
|
};
|
|
271
292
|
|
|
272
293
|
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';
|
|
@@ -14,25 +16,45 @@ import sensibleDefaults from './defaults';
|
|
|
14
16
|
const log = debug('hotspot:configure');
|
|
15
17
|
|
|
16
18
|
export default class DrawableResponseConfigure extends HTMLElement {
|
|
17
|
-
static createDefaultModel = (model = {}) =>
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
static createDefaultModel = (model = {}, config) => {
|
|
20
|
+
const defaultModel = {
|
|
21
|
+
...sensibleDefaults.model,
|
|
22
|
+
...model,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
if (config?.withRubric?.forceEnabled && !defaultModel.rubricEnabled) {
|
|
26
|
+
defaultModel.rubricEnabled = true;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return defaultModel;
|
|
30
|
+
};
|
|
21
31
|
|
|
22
32
|
constructor() {
|
|
23
33
|
super();
|
|
24
|
-
this._model = DrawableResponseConfigure.createDefaultModel();
|
|
25
34
|
this._configuration = sensibleDefaults.configuration;
|
|
35
|
+
this._model = DrawableResponseConfigure.createDefaultModel({}, this._configuration);
|
|
26
36
|
this.onModelChanged = this.onModelChanged.bind(this);
|
|
27
37
|
}
|
|
28
38
|
|
|
39
|
+
verifyRubric = async (c) => {
|
|
40
|
+
const { withRubric = {} } = c || {};
|
|
41
|
+
|
|
42
|
+
if (withRubric?.forceEnabled && !this._model.rubricEnabled) {
|
|
43
|
+
this._model.rubricEnabled = true;
|
|
44
|
+
this.dispatchEvent(new ModelUpdatedEvent(this._model));
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
29
48
|
set model(s) {
|
|
30
|
-
this._model = DrawableResponseConfigure.createDefaultModel(s);
|
|
49
|
+
this._model = DrawableResponseConfigure.createDefaultModel(s, this._configuration);
|
|
31
50
|
this._render();
|
|
32
51
|
}
|
|
33
52
|
|
|
34
53
|
set configuration(c) {
|
|
35
54
|
this._configuration = c;
|
|
55
|
+
|
|
56
|
+
this.verifyRubric(this._configuration);
|
|
57
|
+
|
|
36
58
|
this._render();
|
|
37
59
|
}
|
|
38
60
|
|
|
@@ -49,13 +71,10 @@ export default class DrawableResponseConfigure extends HTMLElement {
|
|
|
49
71
|
};
|
|
50
72
|
|
|
51
73
|
onConfigurationChanged = (c) => {
|
|
52
|
-
if (!c.backgroundImage.enabled) {
|
|
53
|
-
this.onModelChanged({
|
|
54
|
-
...this._model,
|
|
55
|
-
imageUrl: ''
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
74
|
this._configuration = c;
|
|
75
|
+
|
|
76
|
+
this.verifyRubric(this._configuration);
|
|
77
|
+
|
|
59
78
|
this._render();
|
|
60
79
|
};
|
|
61
80
|
|
|
@@ -67,8 +86,17 @@ export default class DrawableResponseConfigure extends HTMLElement {
|
|
|
67
86
|
this.dispatchEvent(new DeleteImageEvent(src, done));
|
|
68
87
|
};
|
|
69
88
|
|
|
89
|
+
insertSound(handler) {
|
|
90
|
+
this.dispatchEvent(new InsertSoundEvent(handler));
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
onDeleteSound(src, done) {
|
|
94
|
+
this.dispatchEvent(new DeleteSoundEvent(src, done));
|
|
95
|
+
}
|
|
96
|
+
|
|
70
97
|
_render() {
|
|
71
98
|
log('_render');
|
|
99
|
+
|
|
72
100
|
let element = React.createElement(Root, {
|
|
73
101
|
model: this._model,
|
|
74
102
|
configuration: this._configuration,
|
|
@@ -76,8 +104,12 @@ export default class DrawableResponseConfigure extends HTMLElement {
|
|
|
76
104
|
onConfigurationChanged: this.onConfigurationChanged,
|
|
77
105
|
imageSupport: {
|
|
78
106
|
add: this.insertImage,
|
|
79
|
-
delete: this.onDeleteImage
|
|
80
|
-
}
|
|
107
|
+
delete: this.onDeleteImage,
|
|
108
|
+
},
|
|
109
|
+
uploadSoundSupport: {
|
|
110
|
+
add: this.insertSound.bind(this),
|
|
111
|
+
delete: this.onDeleteSound.bind(this),
|
|
112
|
+
},
|
|
81
113
|
});
|
|
82
114
|
ReactDOM.render(element, this);
|
|
83
115
|
}
|
package/configure/src/root.jsx
CHANGED
|
@@ -11,69 +11,74 @@ 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
|
-
onModelChanged({
|
|
19
|
-
...update,
|
|
20
|
-
prompt
|
|
21
|
-
});
|
|
18
|
+
onModelChanged({ ...update, prompt });
|
|
22
19
|
};
|
|
23
20
|
|
|
24
|
-
|
|
21
|
+
onTeacherInstructionsChanged = (teacherInstructions) => {
|
|
25
22
|
const { model, onModelChanged } = this.props;
|
|
26
23
|
|
|
27
|
-
onModelChanged({
|
|
28
|
-
...model,
|
|
29
|
-
rationale
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
onTeacherInstructionsChanged = teacherInstructions => {
|
|
34
|
-
const { model, onModelChanged } = this.props;
|
|
35
|
-
|
|
36
|
-
onModelChanged({
|
|
37
|
-
...model,
|
|
38
|
-
teacherInstructions
|
|
39
|
-
});
|
|
24
|
+
onModelChanged({ ...model, teacherInstructions });
|
|
40
25
|
};
|
|
41
26
|
|
|
42
27
|
onUpdateImageDimension = (dimensions) => {
|
|
43
28
|
const { model, onModelChanged } = this.props;
|
|
44
29
|
|
|
45
|
-
onModelChanged({
|
|
46
|
-
...model,
|
|
47
|
-
imageDimensions: dimensions
|
|
48
|
-
});
|
|
30
|
+
onModelChanged({ ...model, imageDimensions: dimensions });
|
|
49
31
|
};
|
|
50
32
|
|
|
51
|
-
onImageUpload = imageUrl => {
|
|
33
|
+
onImageUpload = (imageUrl) => {
|
|
52
34
|
const { model, onModelChanged } = this.props;
|
|
53
35
|
|
|
54
|
-
onModelChanged({
|
|
55
|
-
...model,
|
|
56
|
-
imageUrl
|
|
57
|
-
});
|
|
36
|
+
onModelChanged({ ...model, imageUrl });
|
|
58
37
|
};
|
|
59
38
|
|
|
60
39
|
render() {
|
|
40
|
+
const { classes, configuration, imageSupport, model, onConfigurationChanged, onModelChanged, uploadSoundSupport } =
|
|
41
|
+
this.props;
|
|
61
42
|
const {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const {
|
|
72
|
-
|
|
43
|
+
backgroundImage = {},
|
|
44
|
+
maxImageWidth = {},
|
|
45
|
+
maxImageHeight = {},
|
|
46
|
+
prompt = {},
|
|
47
|
+
settingsPanelDisabled,
|
|
48
|
+
spellCheck = {},
|
|
49
|
+
teacherInstructions = {},
|
|
50
|
+
withRubric = {},
|
|
51
|
+
} = configuration || {};
|
|
52
|
+
const {
|
|
53
|
+
backgroundImageEnabled,
|
|
54
|
+
promptEnabled,
|
|
55
|
+
spellCheckEnabled,
|
|
56
|
+
teacherInstructionsEnabled,
|
|
57
|
+
toolbarEditorPosition,
|
|
58
|
+
} = model || {};
|
|
59
|
+
|
|
60
|
+
const defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;
|
|
61
|
+
const defaultImageMaxHeight = maxImageHeight && maxImageHeight.prompt;
|
|
62
|
+
|
|
63
|
+
const toolbarOpts = {
|
|
64
|
+
position: toolbarEditorPosition === 'top' ? 'top' : 'bottom',
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const panelSettings = {
|
|
68
|
+
backgroundImageEnabled: backgroundImage.settings && toggle(backgroundImage.label),
|
|
69
|
+
promptEnabled: prompt.settings && toggle(prompt.label),
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const panelProperties = {
|
|
73
|
+
teacherInstructionsEnabled: teacherInstructions.settings && toggle(teacherInstructions.label),
|
|
74
|
+
spellCheckEnabled: spellCheck.settings && toggle(spellCheck.label),
|
|
75
|
+
rubricEnabled: !withRubric?.forceEnabled && withRubric?.settings && toggle(withRubric?.label),
|
|
76
|
+
};
|
|
73
77
|
|
|
74
78
|
return (
|
|
75
79
|
<div className={classes.base}>
|
|
76
80
|
<layout.ConfigLayout
|
|
81
|
+
hideSettings={settingsPanelDisabled}
|
|
77
82
|
settings={
|
|
78
83
|
<Panel
|
|
79
84
|
model={model}
|
|
@@ -81,34 +86,26 @@ export class Root extends React.Component {
|
|
|
81
86
|
configuration={configuration}
|
|
82
87
|
onChangeConfiguration={onConfigurationChanged}
|
|
83
88
|
groups={{
|
|
84
|
-
Settings:
|
|
85
|
-
|
|
86
|
-
backgroundImage.settings &&
|
|
87
|
-
toggle(backgroundImage.label, true),
|
|
88
|
-
promptEnabled: prompt.settings && toggle(prompt.label)
|
|
89
|
-
},
|
|
90
|
-
Properties: {
|
|
91
|
-
teacherInstructionsEnabled:
|
|
92
|
-
teacherInstructions.settings &&
|
|
93
|
-
toggle(teacherInstructions.label),
|
|
94
|
-
rationaleEnabled:
|
|
95
|
-
rationale.settings && toggle(rationale.label)
|
|
96
|
-
}
|
|
89
|
+
Settings: panelSettings,
|
|
90
|
+
Properties: panelProperties,
|
|
97
91
|
}}
|
|
98
92
|
/>
|
|
99
93
|
}
|
|
100
94
|
>
|
|
101
95
|
<div className={classes.regular}>
|
|
102
96
|
{teacherInstructionsEnabled && (
|
|
103
|
-
<InputContainer
|
|
104
|
-
label={teacherInstructions.label}
|
|
105
|
-
className={classes.prompt}
|
|
106
|
-
>
|
|
97
|
+
<InputContainer label={teacherInstructions.label} className={classes.prompt}>
|
|
107
98
|
<EditableHtml
|
|
108
99
|
markup={model.teacherInstructions || ''}
|
|
109
100
|
onChange={this.onTeacherInstructionsChanged}
|
|
110
101
|
imageSupport={imageSupport}
|
|
111
102
|
nonEmpty={false}
|
|
103
|
+
toolbarOpts={toolbarOpts}
|
|
104
|
+
spellCheck={spellCheckEnabled}
|
|
105
|
+
maxImageWidth={(maxImageWidth && maxImageWidth.teacherInstructions) || defaultImageMaxWidth}
|
|
106
|
+
maxImageHeight={(maxImageHeight && maxImageHeight.teacherInstructions) || defaultImageMaxHeight}
|
|
107
|
+
uploadSoundSupport={uploadSoundSupport}
|
|
108
|
+
languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}
|
|
112
109
|
/>
|
|
113
110
|
</InputContainer>
|
|
114
111
|
)}
|
|
@@ -118,24 +115,18 @@ export class Root extends React.Component {
|
|
|
118
115
|
<EditableHtml
|
|
119
116
|
markup={model.prompt}
|
|
120
117
|
onChange={this.onPromptChanged}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
)}
|
|
124
|
-
|
|
125
|
-
{rationaleEnabled && (
|
|
126
|
-
<InputContainer
|
|
127
|
-
label={rationale.label}
|
|
128
|
-
className={classes.prompt}
|
|
129
|
-
>
|
|
130
|
-
<EditableHtml
|
|
131
|
-
markup={model.rationale || ''}
|
|
132
|
-
onChange={this.onRationaleChanged}
|
|
118
|
+
toolbarOpts={toolbarOpts}
|
|
119
|
+
spellCheck={spellCheckEnabled}
|
|
133
120
|
imageSupport={imageSupport}
|
|
121
|
+
maxImageWidth={defaultImageMaxWidth}
|
|
122
|
+
maxImageHeight={defaultImageMaxHeight}
|
|
123
|
+
uploadSoundSupport={uploadSoundSupport}
|
|
124
|
+
languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}
|
|
134
125
|
/>
|
|
135
126
|
</InputContainer>
|
|
136
127
|
)}
|
|
137
128
|
|
|
138
|
-
{
|
|
129
|
+
{backgroundImageEnabled && (
|
|
139
130
|
<div>
|
|
140
131
|
<Typography className={classes.label} variant="subheading">
|
|
141
132
|
Define Background Image
|
|
@@ -145,6 +136,7 @@ export class Root extends React.Component {
|
|
|
145
136
|
imageUrl={model.imageUrl}
|
|
146
137
|
onUpdateImageDimension={this.onUpdateImageDimension}
|
|
147
138
|
onImageUpload={this.onImageUpload}
|
|
139
|
+
imageDimensions={model.imageDimensions}
|
|
148
140
|
/>
|
|
149
141
|
</div>
|
|
150
142
|
)}
|
|
@@ -155,20 +147,20 @@ export class Root extends React.Component {
|
|
|
155
147
|
}
|
|
156
148
|
}
|
|
157
149
|
|
|
158
|
-
const styles = theme => ({
|
|
150
|
+
const styles = (theme) => ({
|
|
159
151
|
base: {
|
|
160
|
-
marginTop: theme.spacing.unit * 3
|
|
152
|
+
marginTop: theme.spacing.unit * 3,
|
|
161
153
|
},
|
|
162
154
|
label: {
|
|
163
|
-
marginTop: theme.spacing.unit * 4
|
|
155
|
+
marginTop: theme.spacing.unit * 4,
|
|
164
156
|
},
|
|
165
157
|
prompt: {
|
|
166
158
|
paddingTop: theme.spacing.unit * 2,
|
|
167
|
-
width: '100%'
|
|
159
|
+
width: '100%',
|
|
168
160
|
},
|
|
169
161
|
regular: {
|
|
170
|
-
marginBottom: theme.spacing.unit * 3
|
|
171
|
-
}
|
|
162
|
+
marginBottom: theme.spacing.unit * 3,
|
|
163
|
+
},
|
|
172
164
|
});
|
|
173
165
|
|
|
174
166
|
Root.propTypes = {
|
|
@@ -177,7 +169,11 @@ Root.propTypes = {
|
|
|
177
169
|
model: PropTypes.object.isRequired,
|
|
178
170
|
imageSupport: PropTypes.shape({
|
|
179
171
|
add: PropTypes.func,
|
|
180
|
-
delete: PropTypes.func
|
|
172
|
+
delete: PropTypes.func,
|
|
173
|
+
}),
|
|
174
|
+
uploadSoundSupport: PropTypes.shape({
|
|
175
|
+
add: PropTypes.func,
|
|
176
|
+
delete: PropTypes.func,
|
|
181
177
|
}),
|
|
182
178
|
onModelChanged: PropTypes.func.isRequired,
|
|
183
179
|
onConfigurationChanged: PropTypes.func.isRequired,
|
package/controller/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,64 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [3.2.9](https://github.com/pie-framework/pie-elements/compare/@pie-element/drawing-response-controller@3.2.8...@pie-element/drawing-response-controller@3.2.9) (2022-12-07)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* PD-1642 toggle backgroundImageEnabled property instead of just config property, keep image link in model ([6661854](https://github.com/pie-framework/pie-elements/commit/6661854ab93f801d19b8cc8014f89ea8e5d83848))
|
|
12
|
+
* tests ([b196414](https://github.com/pie-framework/pie-elements/commit/b196414b2d019dfdbd8ea6bfc996b47c2f152cb0))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## [3.2.8](https://github.com/pie-framework/pie-elements/compare/@pie-element/drawing-response-controller@3.2.7...@pie-element/drawing-response-controller@3.2.8) (2022-03-22)
|
|
19
|
+
|
|
20
|
+
**Note:** Version bump only for package @pie-element/drawing-response-controller
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
## [3.2.4](https://github.com/pie-framework/pie-elements/compare/@pie-element/drawing-response-controller@3.2.2...@pie-element/drawing-response-controller@3.2.4) (2021-11-11)
|
|
27
|
+
|
|
28
|
+
**Note:** Version bump only for package @pie-element/drawing-response-controller
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
## [3.2.3](https://github.com/pie-framework/pie-elements/compare/@pie-element/drawing-response-controller@3.2.2...@pie-element/drawing-response-controller@3.2.3) (2021-11-11)
|
|
35
|
+
|
|
36
|
+
**Note:** Version bump only for package @pie-element/drawing-response-controller
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
## [3.2.2](https://github.com/pie-framework/pie-elements/compare/@pie-element/drawing-response-controller@3.2.0...@pie-element/drawing-response-controller@3.2.2) (2021-08-05)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
### Bug Fixes
|
|
46
|
+
|
|
47
|
+
* force bump ([5ea7295](https://github.com/pie-framework/pie-elements/commit/5ea7295e4755fbc492a76e7ec69e5fc35b196919))
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
# [3.2.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/drawing-response-controller@3.1.8...@pie-element/drawing-response-controller@3.2.0) (2021-06-29)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
### Features
|
|
57
|
+
|
|
58
|
+
* **drawing-response:** remove rationale PD-191 ([#597](https://github.com/pie-framework/pie-elements/issues/597)) ([3b52331](https://github.com/pie-framework/pie-elements/commit/3b52331ac843084e6d402daad3536627ab0ddf28))
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
6
64
|
## [3.1.8](https://github.com/pie-framework/pie-elements/compare/@pie-element/drawing-response-controller@3.1.6...@pie-element/drawing-response-controller@3.1.8) (2021-03-03)
|
|
7
65
|
|
|
8
66
|
**Note:** Version bump only for package @pie-element/drawing-response-controller
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/defaults.js"],"names":["prompt","imageUrl","imageDimensions","height","width"],"mappings":";;;;;;eAAe;AACbA,EAAAA,MAAM,EAAE,6BADK;AAEbC,EAAAA,QAAQ,EAAE,EAFG;AAGbC,EAAAA,eAAe,EAAE;AACfC,IAAAA,MAAM,EAAE,CADO;AAEfC,IAAAA,KAAK,EAAE;AAFQ;AAHJ,C","sourcesContent":["export default {\n prompt: 'This is the question prompt',\n imageUrl: '',\n imageDimensions: {\n height: 0,\n width: 0
|
|
1
|
+
{"version":3,"sources":["../src/defaults.js"],"names":["prompt","imageUrl","imageDimensions","height","width"],"mappings":";;;;;;eAAe;AACbA,EAAAA,MAAM,EAAE,6BADK;AAEbC,EAAAA,QAAQ,EAAE,EAFG;AAGbC,EAAAA,eAAe,EAAE;AACfC,IAAAA,MAAM,EAAE,CADO;AAEfC,IAAAA,KAAK,EAAE;AAFQ;AAHJ,C","sourcesContent":["export default {\n prompt: 'This is the question prompt',\n imageUrl: '',\n imageDimensions: {\n height: 0,\n width: 0,\n },\n};\n"],"file":"defaults.js"}
|