@pie-element/drawing-response 3.9.9 → 3.9.10-beta.1443
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 +370 -0
- package/configure/CHANGELOG.md +355 -0
- package/configure/lib/button.js.map +1 -1
- package/configure/lib/defaults.js +21 -2
- package/configure/lib/defaults.js.map +1 -1
- package/configure/lib/image-container.js +37 -21
- package/configure/lib/image-container.js.map +1 -1
- package/configure/lib/index.js +64 -11
- package/configure/lib/index.js.map +1 -1
- package/configure/lib/root.js +65 -30
- 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 +34 -14
- 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 -18
- package/configure/src/button.jsx +4 -4
- package/configure/src/defaults.js +24 -5
- package/configure/src/image-container.jsx +80 -59
- package/configure/src/index.js +46 -14
- package/configure/src/root.jsx +71 -63
- package/controller/CHANGELOG.md +20 -0
- package/controller/lib/defaults.js.map +1 -1
- package/controller/lib/index.js +13 -7
- package/controller/lib/index.js.map +1 -1
- package/controller/package.json +1 -1
- package/controller/src/__tests__/index.test.js +29 -19
- package/controller/src/defaults.js +2 -2
- package/controller/src/index.js +13 -14
- package/docs/config-schema.json +126 -0
- package/docs/config-schema.json.md +97 -1
- package/docs/demo/config.js +2 -2
- package/docs/demo/generate.js +4 -2
- package/docs/demo/session.js +4 -4
- package/docs/pie-schema.json +60 -0
- package/docs/pie-schema.json.md +44 -0
- package/lib/drawing-response/button.js.map +1 -1
- package/lib/drawing-response/constants.js.map +1 -1
- package/lib/drawing-response/container.js +73 -22
- package/lib/drawing-response/container.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-main.js +45 -15
- package/lib/drawing-response/drawable-main.js.map +1 -1
- package/lib/drawing-response/drawable-palette.js +6 -1
- package/lib/drawing-response/drawable-palette.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.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 +3 -0
- package/lib/drawing-response/index.js.map +1 -1
- package/lib/index.js +3 -0
- package/lib/index.js.map +1 -1
- package/package.json +4 -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 +9 -15
- package/src/index.js +8 -11
|
@@ -3,10 +3,7 @@ import { Text } from 'react-konva';
|
|
|
3
3
|
|
|
4
4
|
import Transformer from './drawable-transformer';
|
|
5
5
|
|
|
6
|
-
export const generateId = () =>
|
|
7
|
-
Math.random()
|
|
8
|
-
.toString(36)
|
|
9
|
-
.substring(2) + new Date().getTime().toString(36);
|
|
6
|
+
export const generateId = () => Math.random().toString(36).substring(2) + new Date().getTime().toString(36);
|
|
10
7
|
|
|
11
8
|
export default class TextDrawable {
|
|
12
9
|
static getTextareaNode(id) {
|
|
@@ -26,10 +23,9 @@ export default class TextDrawable {
|
|
|
26
23
|
this.eventListenersDetachArray = [];
|
|
27
24
|
}
|
|
28
25
|
|
|
29
|
-
removeEventListeners = () =>
|
|
30
|
-
this.eventListenersDetachArray.forEach(fn => fn());
|
|
26
|
+
removeEventListeners = () => this.eventListenersDetachArray.forEach((fn) => fn());
|
|
31
27
|
|
|
32
|
-
setAll = all => {
|
|
28
|
+
setAll = (all) => {
|
|
33
29
|
this.all = all;
|
|
34
30
|
this.props.forceUpdate();
|
|
35
31
|
};
|
|
@@ -49,14 +45,14 @@ export default class TextDrawable {
|
|
|
49
45
|
transformerVisible: true,
|
|
50
46
|
textareaVisible: false,
|
|
51
47
|
createdAt: new Date(),
|
|
52
|
-
type: 'text-entry'
|
|
48
|
+
type: 'text-entry',
|
|
53
49
|
});
|
|
54
50
|
|
|
55
51
|
this.props.handleSessionChange();
|
|
56
52
|
};
|
|
57
53
|
|
|
58
54
|
showOnlyTextNodes() {
|
|
59
|
-
this.all.map(item => {
|
|
55
|
+
this.all.map((item) => {
|
|
60
56
|
item.textVisible = true;
|
|
61
57
|
item.transformerVisible = false;
|
|
62
58
|
item.textareaVisible = false;
|
|
@@ -64,13 +60,13 @@ export default class TextDrawable {
|
|
|
64
60
|
}
|
|
65
61
|
|
|
66
62
|
toggleTextarea(id, value) {
|
|
67
|
-
this.all = this.all.map(item => {
|
|
63
|
+
this.all = this.all.map((item) => {
|
|
68
64
|
if (item.id === id) {
|
|
69
65
|
return {
|
|
70
66
|
...item,
|
|
71
67
|
textVisible: !value,
|
|
72
68
|
transformerVisible: !value,
|
|
73
|
-
textareaVisible: value
|
|
69
|
+
textareaVisible: value,
|
|
74
70
|
};
|
|
75
71
|
}
|
|
76
72
|
return item;
|
|
@@ -80,7 +76,7 @@ export default class TextDrawable {
|
|
|
80
76
|
|
|
81
77
|
initializeDefault(id, isDefault) {
|
|
82
78
|
if (isDefault) {
|
|
83
|
-
const current = this.all.filter(item => item.id === id)[0];
|
|
79
|
+
const current = this.all.filter((item) => item.id === id)[0];
|
|
84
80
|
current.isDefault = false;
|
|
85
81
|
}
|
|
86
82
|
}
|
|
@@ -89,7 +85,7 @@ export default class TextDrawable {
|
|
|
89
85
|
if (textareaNode.value) {
|
|
90
86
|
textNode.text(textareaNode.value);
|
|
91
87
|
} else {
|
|
92
|
-
this.all = this.all.filter(text => text.id !== id);
|
|
88
|
+
this.all = this.all.filter((text) => text.id !== id);
|
|
93
89
|
this.props.forceUpdate();
|
|
94
90
|
}
|
|
95
91
|
|
|
@@ -100,7 +96,7 @@ export default class TextDrawable {
|
|
|
100
96
|
handleMouseUp = () => this.props.toggleTextSelected(false);
|
|
101
97
|
|
|
102
98
|
handleClick = (e, id) => {
|
|
103
|
-
const current = this.all.filter(item => item.id === id)[0];
|
|
99
|
+
const current = this.all.filter((item) => item.id === id)[0];
|
|
104
100
|
current.transformerVisible = true;
|
|
105
101
|
this.props.forceUpdate();
|
|
106
102
|
};
|
|
@@ -119,8 +115,7 @@ export default class TextDrawable {
|
|
|
119
115
|
textareaNode.style.top = areaPosition.y + 'px';
|
|
120
116
|
textareaNode.style.left = areaPosition.x + 'px';
|
|
121
117
|
textareaNode.style.width = textNode.width() - textNode.padding() * 2 + 'px';
|
|
122
|
-
textareaNode.style.height =
|
|
123
|
-
textNode.height() - textNode.padding() * 2 + 5 + 'px';
|
|
118
|
+
textareaNode.style.height = textNode.height() - textNode.padding() * 2 + 5 + 'px';
|
|
124
119
|
textareaNode.style.fontSize = textNode.fontSize() + 'px';
|
|
125
120
|
textareaNode.style.border = 'none';
|
|
126
121
|
textareaNode.style.padding = '0px';
|
|
@@ -156,7 +151,7 @@ export default class TextDrawable {
|
|
|
156
151
|
|
|
157
152
|
textareaNode.focus();
|
|
158
153
|
|
|
159
|
-
const keyDownHandler = e => {
|
|
154
|
+
const keyDownHandler = (e) => {
|
|
160
155
|
// hide on enter but don't hide on shift + enter
|
|
161
156
|
if (e.keyCode === 13 && !e.shiftKey) {
|
|
162
157
|
this.toggleTextarea(id, false);
|
|
@@ -171,9 +166,7 @@ export default class TextDrawable {
|
|
|
171
166
|
|
|
172
167
|
textareaNode.addEventListener('keydown', keyDownHandler);
|
|
173
168
|
|
|
174
|
-
this.eventListenersDetachArray.push(() =>
|
|
175
|
-
textareaNode.removeEventListener('keydown', keyDownHandler)
|
|
176
|
-
);
|
|
169
|
+
this.eventListenersDetachArray.push(() => textareaNode.removeEventListener('keydown', keyDownHandler));
|
|
177
170
|
|
|
178
171
|
const blurHandler = () => {
|
|
179
172
|
this.showOnlyTextNodes();
|
|
@@ -182,9 +175,7 @@ export default class TextDrawable {
|
|
|
182
175
|
|
|
183
176
|
textareaNode.addEventListener('blur', blurHandler);
|
|
184
177
|
|
|
185
|
-
this.eventListenersDetachArray.push(() =>
|
|
186
|
-
textareaNode.removeEventListener('blur', blurHandler)
|
|
187
|
-
);
|
|
178
|
+
this.eventListenersDetachArray.push(() => textareaNode.removeEventListener('blur', blurHandler));
|
|
188
179
|
|
|
189
180
|
this.initializeDefault(id, isDefault);
|
|
190
181
|
this.props.forceUpdate();
|
|
@@ -193,19 +184,19 @@ export default class TextDrawable {
|
|
|
193
184
|
handleTransform = (e, textNode) => {
|
|
194
185
|
this[textNode].setAttrs({
|
|
195
186
|
width: this[textNode].width() * this[textNode].scaleX(),
|
|
196
|
-
scaleX:
|
|
187
|
+
scaleX: this.props.scale,
|
|
197
188
|
});
|
|
198
189
|
};
|
|
199
190
|
|
|
200
191
|
renderTextareas() {
|
|
201
|
-
return this.all.map(text => {
|
|
192
|
+
return this.all.map((text) => {
|
|
202
193
|
const { id, textareaVisible } = text;
|
|
203
194
|
const textareaNode = `textarea_${id}`;
|
|
204
195
|
|
|
205
196
|
return (
|
|
206
197
|
<textarea
|
|
207
198
|
key={textareaNode}
|
|
208
|
-
ref={textarea => {
|
|
199
|
+
ref={(textarea) => {
|
|
209
200
|
this[textareaNode] = textarea;
|
|
210
201
|
}}
|
|
211
202
|
style={{ display: `${textareaVisible ? 'block' : 'none'}` }}
|
|
@@ -228,7 +219,7 @@ export default class TextDrawable {
|
|
|
228
219
|
|
|
229
220
|
// setting the handler only once
|
|
230
221
|
if (newStage !== this.stage) {
|
|
231
|
-
const stageClickHandler = e => {
|
|
222
|
+
const stageClickHandler = (e) => {
|
|
232
223
|
if (e.target !== this.stage) {
|
|
233
224
|
return;
|
|
234
225
|
}
|
|
@@ -239,25 +230,14 @@ export default class TextDrawable {
|
|
|
239
230
|
|
|
240
231
|
newStage.on('click', stageClickHandler);
|
|
241
232
|
|
|
242
|
-
this.eventListenersDetachArray.push(() =>
|
|
243
|
-
newStage.off('click', stageClickHandler)
|
|
244
|
-
);
|
|
233
|
+
this.eventListenersDetachArray.push(() => newStage.off('click', stageClickHandler));
|
|
245
234
|
}
|
|
246
235
|
|
|
247
236
|
this.stage = newStage;
|
|
248
237
|
}
|
|
249
238
|
|
|
250
|
-
return this.all.map(text => {
|
|
251
|
-
const {
|
|
252
|
-
id,
|
|
253
|
-
label,
|
|
254
|
-
x,
|
|
255
|
-
y,
|
|
256
|
-
width,
|
|
257
|
-
textVisible,
|
|
258
|
-
rotation,
|
|
259
|
-
transformerVisible
|
|
260
|
-
} = text;
|
|
239
|
+
return this.all.map((text) => {
|
|
240
|
+
const { id, label, x, y, width, textVisible, rotation, transformerVisible } = text;
|
|
261
241
|
|
|
262
242
|
const textNode = `text_${id}`;
|
|
263
243
|
const transformerNode = `transformer_${id}`;
|
|
@@ -265,16 +245,20 @@ export default class TextDrawable {
|
|
|
265
245
|
|
|
266
246
|
if (!props.disabled) {
|
|
267
247
|
extraProps = {
|
|
268
|
-
onClick: e => this.handleClick(e, id),
|
|
269
|
-
|
|
270
|
-
|
|
248
|
+
onClick: (e) => this.handleClick(e, id),
|
|
249
|
+
onTap: (e) => this.handleClick(e, id),
|
|
250
|
+
onDblClick: (e) => this.handleDblClick(e, text),
|
|
251
|
+
onDblTap: (e) => this.handleDblClick(e, text),
|
|
252
|
+
onTransform: (e) => this.handleTransform(e, textNode),
|
|
271
253
|
onTransformEnd: this.props.handleSessionChange,
|
|
272
254
|
onMouseDown: this.handleMouseDown,
|
|
255
|
+
onTouchStart: this.handleMouseDown,
|
|
273
256
|
onMouseUp: this.handleMouseUp,
|
|
257
|
+
onTouchEnd: this.handleMouseUp,
|
|
274
258
|
onDragEnd: this.props.handleSessionChange,
|
|
275
259
|
onMouseEnter: this.props.onMouseOverElement,
|
|
276
260
|
onMouseLeave: this.props.onMouseOutElement,
|
|
277
|
-
}
|
|
261
|
+
};
|
|
278
262
|
}
|
|
279
263
|
|
|
280
264
|
if (rotation) {
|
|
@@ -286,7 +270,7 @@ export default class TextDrawable {
|
|
|
286
270
|
key={id}
|
|
287
271
|
bubbles={true}
|
|
288
272
|
id={id}
|
|
289
|
-
ref={text => {
|
|
273
|
+
ref={(text) => {
|
|
290
274
|
this[textNode] = text;
|
|
291
275
|
}}
|
|
292
276
|
text={text.text || label}
|
|
@@ -302,14 +286,16 @@ export default class TextDrawable {
|
|
|
302
286
|
transformerVisible && (
|
|
303
287
|
<Transformer
|
|
304
288
|
key={`transformer_${id}`}
|
|
305
|
-
ref={text => {
|
|
289
|
+
ref={(text) => {
|
|
306
290
|
this[transformerNode] = text;
|
|
307
291
|
}}
|
|
308
292
|
selectedShapeName={textNode}
|
|
309
293
|
onMouseDown={this.handleMouseDown}
|
|
294
|
+
onTouchStart={this.handleMouseDown}
|
|
310
295
|
onMouseUp={this.handleMouseUp}
|
|
296
|
+
onTouchEnd={this.handleMouseUp}
|
|
311
297
|
/>
|
|
312
|
-
)
|
|
298
|
+
),
|
|
313
299
|
];
|
|
314
300
|
});
|
|
315
301
|
}
|
|
@@ -35,7 +35,9 @@ class TransformerComponent extends React.Component {
|
|
|
35
35
|
render() {
|
|
36
36
|
return (
|
|
37
37
|
<Transformer
|
|
38
|
-
ref={node => {
|
|
38
|
+
ref={(node) => {
|
|
39
|
+
this.transformer = node;
|
|
40
|
+
}}
|
|
39
41
|
enabledAnchors={['middle-left', 'middle-right']}
|
|
40
42
|
{...this.props}
|
|
41
43
|
/>
|
|
@@ -4,22 +4,14 @@ import RectangleDrawable from './drawable-rectangle';
|
|
|
4
4
|
import CircleDrawable from './drawable-circle';
|
|
5
5
|
import EraserDrawable from './drawable-eraser';
|
|
6
6
|
|
|
7
|
-
const DRAWABLES = [
|
|
8
|
-
FreePathDrawable,
|
|
9
|
-
LineDrawable,
|
|
10
|
-
RectangleDrawable,
|
|
11
|
-
CircleDrawable,
|
|
12
|
-
EraserDrawable
|
|
13
|
-
];
|
|
7
|
+
const DRAWABLES = [FreePathDrawable, LineDrawable, RectangleDrawable, CircleDrawable, EraserDrawable];
|
|
14
8
|
|
|
15
9
|
export default (type, props) => {
|
|
16
|
-
const T = DRAWABLES.find(D => D.TYPE === type);
|
|
10
|
+
const T = DRAWABLES.find((D) => D.TYPE === type);
|
|
17
11
|
|
|
18
12
|
if (T) {
|
|
19
13
|
return new T(props);
|
|
20
14
|
}
|
|
21
15
|
|
|
22
|
-
throw new Error(
|
|
23
|
-
`Can't find drawable for type: ${type} and props: ${JSON.stringify(props)}`
|
|
24
|
-
);
|
|
16
|
+
throw new Error(`Can't find drawable for type: ${type} and props: ${JSON.stringify(props)}`);
|
|
25
17
|
};
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
mdiCircle,
|
|
10
10
|
mdiFormatColorText,
|
|
11
11
|
mdiFormatColorFill,
|
|
12
|
-
mdiEraser
|
|
12
|
+
mdiEraser,
|
|
13
13
|
} from '@mdi/js';
|
|
14
14
|
|
|
15
15
|
const IconWrapper = ({ path }) => {
|
|
@@ -17,37 +17,36 @@ const IconWrapper = ({ path }) => {
|
|
|
17
17
|
|
|
18
18
|
switch (path) {
|
|
19
19
|
case 'mdiPencil':
|
|
20
|
-
iconPath = mdiPencil;
|
|
20
|
+
iconPath = mdiPencil;
|
|
21
|
+
break;
|
|
21
22
|
case 'mdiMinus':
|
|
22
|
-
iconPath = mdiMinus;
|
|
23
|
+
iconPath = mdiMinus;
|
|
24
|
+
break;
|
|
23
25
|
case 'mdiCircle':
|
|
24
|
-
iconPath = mdiCircle;
|
|
26
|
+
iconPath = mdiCircle;
|
|
27
|
+
break;
|
|
25
28
|
case 'mdiRectangle':
|
|
26
|
-
iconPath = mdiRectangle;
|
|
29
|
+
iconPath = mdiRectangle;
|
|
30
|
+
break;
|
|
27
31
|
case 'mdiFormatColorText':
|
|
28
|
-
iconPath = mdiFormatColorText;
|
|
32
|
+
iconPath = mdiFormatColorText;
|
|
33
|
+
break;
|
|
29
34
|
case 'mdiFormatColorFill':
|
|
30
|
-
iconPath = mdiFormatColorFill;
|
|
35
|
+
iconPath = mdiFormatColorFill;
|
|
36
|
+
break;
|
|
31
37
|
case 'mdiEraser':
|
|
32
|
-
iconPath = mdiEraser;
|
|
38
|
+
iconPath = mdiEraser;
|
|
39
|
+
break;
|
|
33
40
|
default:
|
|
34
|
-
iconPath = mdiCursorDefault;
|
|
41
|
+
iconPath = mdiCursorDefault;
|
|
42
|
+
break;
|
|
35
43
|
}
|
|
36
44
|
|
|
37
|
-
return
|
|
38
|
-
<Icon
|
|
39
|
-
path={iconPath}
|
|
40
|
-
size={0.8}
|
|
41
|
-
rotate={180}
|
|
42
|
-
horizontal
|
|
43
|
-
vertical
|
|
44
|
-
color="#2B3963"
|
|
45
|
-
/>
|
|
46
|
-
)
|
|
45
|
+
return <Icon path={iconPath} size={0.8} rotate={180} horizontal vertical color="#2B3963" />;
|
|
47
46
|
};
|
|
48
47
|
|
|
49
48
|
IconWrapper.propTypes = {
|
|
50
|
-
path: PropTypes.string.isRequired
|
|
49
|
+
path: PropTypes.string.isRequired,
|
|
51
50
|
};
|
|
52
51
|
|
|
53
52
|
export default IconWrapper;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import Typography from '@material-ui/core/Typography';
|
|
4
|
-
import {Collapsible, PreviewPrompt} from '@pie-lib/render-ui';
|
|
4
|
+
import { Collapsible, PreviewPrompt } from '@pie-lib/render-ui';
|
|
5
5
|
import { withStyles } from '@material-ui/core/styles';
|
|
6
6
|
|
|
7
7
|
import Container from './container';
|
|
@@ -11,7 +11,7 @@ class DrawingResponseComponent extends React.Component {
|
|
|
11
11
|
super(props);
|
|
12
12
|
this.state = {
|
|
13
13
|
showCorrect: false,
|
|
14
|
-
hasError: false
|
|
14
|
+
hasError: false,
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
17
|
|
|
@@ -21,17 +21,10 @@ class DrawingResponseComponent extends React.Component {
|
|
|
21
21
|
|
|
22
22
|
render() {
|
|
23
23
|
const {
|
|
24
|
-
model: {
|
|
25
|
-
disabled,
|
|
26
|
-
imageDimensions,
|
|
27
|
-
imageUrl,
|
|
28
|
-
prompt,
|
|
29
|
-
mode,
|
|
30
|
-
teacherInstructions
|
|
31
|
-
},
|
|
24
|
+
model: { disabled, imageDimensions, imageUrl, prompt, mode, teacherInstructions, backgroundImageEnabled = true },
|
|
32
25
|
session,
|
|
33
26
|
onSessionChange,
|
|
34
|
-
classes
|
|
27
|
+
classes,
|
|
35
28
|
} = this.props;
|
|
36
29
|
const { hasError, errorMessage } = this.state;
|
|
37
30
|
const isEvaluateMode = mode === 'evaluate';
|
|
@@ -45,7 +38,7 @@ class DrawingResponseComponent extends React.Component {
|
|
|
45
38
|
<Collapsible
|
|
46
39
|
labels={{
|
|
47
40
|
hidden: 'Show Teacher Instructions',
|
|
48
|
-
visible: 'Hide Teacher Instructions'
|
|
41
|
+
visible: 'Hide Teacher Instructions',
|
|
49
42
|
}}
|
|
50
43
|
>
|
|
51
44
|
<PreviewPrompt prompt={teacherInstructions} />
|
|
@@ -64,6 +57,7 @@ class DrawingResponseComponent extends React.Component {
|
|
|
64
57
|
isEvaluateMode={isEvaluateMode}
|
|
65
58
|
imageDimensions={imageDimensions}
|
|
66
59
|
imageUrl={imageUrl}
|
|
60
|
+
backgroundImageEnabled={backgroundImageEnabled}
|
|
67
61
|
disabled={disabled}
|
|
68
62
|
/>
|
|
69
63
|
</div>
|
|
@@ -75,13 +69,13 @@ DrawingResponseComponent.propTypes = {
|
|
|
75
69
|
classes: PropTypes.object,
|
|
76
70
|
model: PropTypes.object.isRequired,
|
|
77
71
|
onSessionChange: PropTypes.func.isRequired,
|
|
78
|
-
session: PropTypes.object.isRequired
|
|
72
|
+
session: PropTypes.object.isRequired,
|
|
79
73
|
};
|
|
80
74
|
|
|
81
75
|
const styles = () => ({
|
|
82
76
|
prompt: {
|
|
83
|
-
fontSize: 'inherit'
|
|
84
|
-
}
|
|
77
|
+
fontSize: 'inherit',
|
|
78
|
+
},
|
|
85
79
|
});
|
|
86
80
|
|
|
87
81
|
export default withStyles(styles)(DrawingResponseComponent);
|
package/src/index.js
CHANGED
|
@@ -10,13 +10,7 @@ export default class DrawingResponse extends HTMLElement {
|
|
|
10
10
|
set model(m) {
|
|
11
11
|
this._model = m;
|
|
12
12
|
|
|
13
|
-
this.dispatchEvent(
|
|
14
|
-
new ModelSetEvent(
|
|
15
|
-
this.tagName.toLowerCase(),
|
|
16
|
-
this.isComplete(),
|
|
17
|
-
!!this._model
|
|
18
|
-
)
|
|
19
|
-
);
|
|
13
|
+
this.dispatchEvent(new ModelSetEvent(this.tagName.toLowerCase(), this.isComplete(), !!this._model));
|
|
20
14
|
this._render();
|
|
21
15
|
}
|
|
22
16
|
|
|
@@ -28,9 +22,7 @@ export default class DrawingResponse extends HTMLElement {
|
|
|
28
22
|
this._session.drawables = update.drawables;
|
|
29
23
|
this._session.texts = update.texts;
|
|
30
24
|
|
|
31
|
-
this.dispatchEvent(
|
|
32
|
-
new SessionChangedEvent(this.tagName.toLowerCase(), this.isComplete())
|
|
33
|
-
);
|
|
25
|
+
this.dispatchEvent(new SessionChangedEvent(this.tagName.toLowerCase(), this.isComplete()));
|
|
34
26
|
|
|
35
27
|
this._render();
|
|
36
28
|
};
|
|
@@ -40,6 +32,10 @@ export default class DrawingResponse extends HTMLElement {
|
|
|
40
32
|
this._render();
|
|
41
33
|
}
|
|
42
34
|
|
|
35
|
+
get session() {
|
|
36
|
+
return this._session;
|
|
37
|
+
}
|
|
38
|
+
|
|
43
39
|
connectedCallback() {
|
|
44
40
|
this._render();
|
|
45
41
|
}
|
|
@@ -49,8 +45,9 @@ export default class DrawingResponse extends HTMLElement {
|
|
|
49
45
|
const el = React.createElement(DrawingResponseComponent, {
|
|
50
46
|
model: this._model,
|
|
51
47
|
session: this._session,
|
|
52
|
-
onSessionChange: this.sessionChanged
|
|
48
|
+
onSessionChange: this.sessionChanged,
|
|
53
49
|
});
|
|
50
|
+
|
|
54
51
|
ReactDOM.render(el, this, () => {
|
|
55
52
|
renderMath(this);
|
|
56
53
|
});
|