@pie-element/drawing-response 3.7.3-next.135 → 3.7.3-next.1353
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 +50 -11
- 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 +58 -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
|
@@ -26,7 +26,12 @@ exports[`DrawingResponse DrawableMain snapshot renders 1`] = `
|
|
|
26
26
|
</div>
|
|
27
27
|
<div>
|
|
28
28
|
<WithStyles(DrawableImage)
|
|
29
|
-
dimensions={
|
|
29
|
+
dimensions={
|
|
30
|
+
Object {
|
|
31
|
+
"height": NaN,
|
|
32
|
+
"width": NaN,
|
|
33
|
+
}
|
|
34
|
+
}
|
|
30
35
|
url="url"
|
|
31
36
|
/>
|
|
32
37
|
<ForwardRef
|
|
@@ -34,6 +39,8 @@ exports[`DrawingResponse DrawableMain snapshot renders 1`] = `
|
|
|
34
39
|
height={350}
|
|
35
40
|
onMouseMove={[Function]}
|
|
36
41
|
onMouseUp={[Function]}
|
|
42
|
+
onTouchEnd={[Function]}
|
|
43
|
+
onTouchMove={[Function]}
|
|
37
44
|
width={353}
|
|
38
45
|
>
|
|
39
46
|
<Layer />
|
|
@@ -58,7 +65,12 @@ exports[`DrawingResponse DrawableMain snapshot renders disabled 1`] = `
|
|
|
58
65
|
</div>
|
|
59
66
|
<div>
|
|
60
67
|
<WithStyles(DrawableImage)
|
|
61
|
-
dimensions={
|
|
68
|
+
dimensions={
|
|
69
|
+
Object {
|
|
70
|
+
"height": NaN,
|
|
71
|
+
"width": NaN,
|
|
72
|
+
}
|
|
73
|
+
}
|
|
62
74
|
url="url"
|
|
63
75
|
/>
|
|
64
76
|
<ForwardRef
|
|
@@ -83,9 +95,13 @@ exports[`DrawingResponse DrawableText snapshot renders 1`] = `
|
|
|
83
95
|
name="text_gcifqhhimf8k2d6g8hs"
|
|
84
96
|
onClick={[Function]}
|
|
85
97
|
onDblClick={[Function]}
|
|
98
|
+
onDblTap={[Function]}
|
|
86
99
|
onDragEnd={[MockFunction]}
|
|
87
100
|
onMouseDown={[Function]}
|
|
88
101
|
onMouseUp={[Function]}
|
|
102
|
+
onTap={[Function]}
|
|
103
|
+
onTouchEnd={[Function]}
|
|
104
|
+
onTouchStart={[Function]}
|
|
89
105
|
onTransform={[Function]}
|
|
90
106
|
onTransformEnd={[MockFunction]}
|
|
91
107
|
text="Double click to edit this text. Press Enter to submit."
|
|
@@ -98,6 +114,8 @@ exports[`DrawingResponse DrawableText snapshot renders 1`] = `
|
|
|
98
114
|
key="transformer_gcifqhhimf8k2d6g8hs"
|
|
99
115
|
onMouseDown={[Function]}
|
|
100
116
|
onMouseUp={[Function]}
|
|
117
|
+
onTouchEnd={[Function]}
|
|
118
|
+
onTouchStart={[Function]}
|
|
101
119
|
selectedShapeName="text_gcifqhhimf8k2d6g8hs"
|
|
102
120
|
/>
|
|
103
121
|
</div>
|
|
@@ -127,9 +145,13 @@ exports[`DrawingResponse DrawableText snapshot when there is no value renders 1`
|
|
|
127
145
|
name="text_gcifqhhimf8k2d6g8hs"
|
|
128
146
|
onClick={[Function]}
|
|
129
147
|
onDblClick={[Function]}
|
|
148
|
+
onDblTap={[Function]}
|
|
130
149
|
onDragEnd={[MockFunction]}
|
|
131
150
|
onMouseDown={[Function]}
|
|
132
151
|
onMouseUp={[Function]}
|
|
152
|
+
onTap={[Function]}
|
|
153
|
+
onTouchEnd={[Function]}
|
|
154
|
+
onTouchStart={[Function]}
|
|
133
155
|
onTransform={[Function]}
|
|
134
156
|
onTransformEnd={[MockFunction]}
|
|
135
157
|
text="Double click to edit this text. Press Enter to submit."
|
|
@@ -142,6 +164,8 @@ exports[`DrawingResponse DrawableText snapshot when there is no value renders 1`
|
|
|
142
164
|
key="transformer_gcifqhhimf8k2d6g8hs"
|
|
143
165
|
onMouseDown={[Function]}
|
|
144
166
|
onMouseUp={[Function]}
|
|
167
|
+
onTouchEnd={[Function]}
|
|
168
|
+
onTouchStart={[Function]}
|
|
145
169
|
selectedShapeName="text_gcifqhhimf8k2d6g8hs"
|
|
146
170
|
/>
|
|
147
171
|
</div>
|
|
@@ -29,7 +29,8 @@ export class Container extends Component {
|
|
|
29
29
|
session: PropTypes.object.isRequired,
|
|
30
30
|
onSessionChange: PropTypes.func.isRequired,
|
|
31
31
|
imageDimensions: PropTypes.object.isRequired,
|
|
32
|
-
imageUrl: PropTypes.string.isRequired
|
|
32
|
+
imageUrl: PropTypes.string.isRequired,
|
|
33
|
+
backgroundImageEnabled: PropTypes.bool.isRequired
|
|
33
34
|
};
|
|
34
35
|
|
|
35
36
|
constructor(props) {
|
|
@@ -37,6 +38,7 @@ export class Container extends Component {
|
|
|
37
38
|
const TextEntry = new DrawableText();
|
|
38
39
|
|
|
39
40
|
this.state = {
|
|
41
|
+
scale: 1,
|
|
40
42
|
drawableDimensions: {
|
|
41
43
|
height: 0,
|
|
42
44
|
width: 0
|
|
@@ -80,12 +82,42 @@ export class Container extends Component {
|
|
|
80
82
|
|
|
81
83
|
componentDidMount() {
|
|
82
84
|
this.setDimensions();
|
|
85
|
+
|
|
86
|
+
this.observer = new MutationObserver((mutations) => {
|
|
87
|
+
mutations.forEach(() => {
|
|
88
|
+
const target = document.getElementById('question-container')?.style?.cssText
|
|
89
|
+
const zoom = target?.substring(
|
|
90
|
+
target.indexOf('--pie-zoom') + 11,
|
|
91
|
+
target.lastIndexOf('%')
|
|
92
|
+
);
|
|
93
|
+
const zoomParsed = zoom?.replace(/\s/g, '');
|
|
94
|
+
|
|
95
|
+
if (zoomParsed) {
|
|
96
|
+
const newScale = parseFloat(zoomParsed) / 100;
|
|
97
|
+
if (newScale !== this.state.scale) {
|
|
98
|
+
this.setState({
|
|
99
|
+
scale: parseFloat(zoomParsed) / 100,
|
|
100
|
+
})
|
|
101
|
+
}
|
|
102
|
+
} else if (!zoomParsed && this.state.scale !== 1) {
|
|
103
|
+
this.setState({
|
|
104
|
+
scale: 1,
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
const target = document.getElementById('question-container');
|
|
111
|
+
if (target) {
|
|
112
|
+
this.observer.observe(target, { attributes : true, attributeFilter : ['style'] })
|
|
113
|
+
}
|
|
83
114
|
}
|
|
84
115
|
|
|
85
116
|
componentWillUnmount() {
|
|
86
117
|
const { TextEntry } = this.state;
|
|
87
118
|
|
|
88
119
|
TextEntry.removeEventListeners();
|
|
120
|
+
this.observer?.disconnect();
|
|
89
121
|
}
|
|
90
122
|
|
|
91
123
|
handleMakeToolActive(tool) {
|
|
@@ -131,7 +163,8 @@ export class Container extends Component {
|
|
|
131
163
|
imageUrl,
|
|
132
164
|
imageDimensions,
|
|
133
165
|
onSessionChange,
|
|
134
|
-
session
|
|
166
|
+
session,
|
|
167
|
+
backgroundImageEnabled
|
|
135
168
|
} = this.props;
|
|
136
169
|
const {
|
|
137
170
|
drawableDimensions,
|
|
@@ -145,39 +178,41 @@ export class Container extends Component {
|
|
|
145
178
|
TextEntry
|
|
146
179
|
} = this.state;
|
|
147
180
|
|
|
181
|
+
const heightToUse = drawableDimensions.height * this.state.scale;
|
|
182
|
+
|
|
148
183
|
return (
|
|
149
184
|
<div className={classes.base}>
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
185
|
+
{!disabled &&
|
|
186
|
+
<DrawablePalette
|
|
187
|
+
fillColor={fillColor}
|
|
188
|
+
fillList={fillColorList}
|
|
189
|
+
outlineColor={outlineColor}
|
|
190
|
+
outlineList={outlineColorList}
|
|
191
|
+
paintColor={paintColor}
|
|
192
|
+
paintList={paintColorList}
|
|
193
|
+
onFillColorChange={color => this.handleColorChange('fill', color)}
|
|
194
|
+
onOutlineColorChange={color =>
|
|
195
|
+
this.handleColorChange('outline', color)
|
|
196
|
+
}
|
|
197
|
+
onPaintColorChange={color => this.handleColorChange('paint', color)}
|
|
198
|
+
/>
|
|
199
|
+
}
|
|
163
200
|
|
|
164
201
|
<div className={classes.box}>
|
|
165
202
|
<div className={classes.toolbar}>
|
|
166
|
-
|
|
167
|
-
{
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
})}
|
|
180
|
-
</div>
|
|
203
|
+
{TOOLS.map(tool => {
|
|
204
|
+
const { type, label, icon } = tool;
|
|
205
|
+
|
|
206
|
+
return (
|
|
207
|
+
<Button
|
|
208
|
+
title={label}
|
|
209
|
+
key={type}
|
|
210
|
+
disabled={this.checkIfToolIsDisabled(type)}
|
|
211
|
+
onClick={() => this.handleMakeToolActive(tool)}
|
|
212
|
+
label={<Icon path={icon} />}
|
|
213
|
+
/>
|
|
214
|
+
);
|
|
215
|
+
})}
|
|
181
216
|
</div>
|
|
182
217
|
|
|
183
218
|
<div
|
|
@@ -185,8 +220,10 @@ export class Container extends Component {
|
|
|
185
220
|
this.drawable = drawable;
|
|
186
221
|
}}
|
|
187
222
|
className={classes.drawableHeight}
|
|
223
|
+
style={{ height: heightToUse, maxHeight: heightToUse }}
|
|
188
224
|
>
|
|
189
225
|
<DrawableMain
|
|
226
|
+
scale={this.state.scale}
|
|
190
227
|
session={session}
|
|
191
228
|
disabled={disabled}
|
|
192
229
|
onSessionChange={onSessionChange}
|
|
@@ -198,6 +235,7 @@ export class Container extends Component {
|
|
|
198
235
|
imageDimensions={imageDimensions}
|
|
199
236
|
toolActive={toolActive}
|
|
200
237
|
TextEntry={TextEntry}
|
|
238
|
+
backgroundImageEnabled={backgroundImageEnabled}
|
|
201
239
|
/>
|
|
202
240
|
</div>
|
|
203
241
|
</div>
|
|
@@ -213,19 +251,23 @@ const styles = theme => ({
|
|
|
213
251
|
box: {
|
|
214
252
|
border: '1px solid #E0E1E6',
|
|
215
253
|
borderRadius: '5px',
|
|
216
|
-
marginTop: theme.spacing.unit * 2
|
|
254
|
+
marginTop: theme.spacing.unit * 2,
|
|
255
|
+
backgroundColor: '#ECEDF1'
|
|
217
256
|
},
|
|
218
257
|
drawableHeight: {
|
|
219
|
-
minHeight: 350
|
|
258
|
+
minHeight: 350,
|
|
259
|
+
backgroundColor: '#fff'
|
|
220
260
|
},
|
|
221
261
|
toolbar: {
|
|
222
|
-
backgroundColor: '#ECEDF1',
|
|
223
262
|
borderBottom: '1px solid #E0E1E6',
|
|
224
263
|
borderTopLeftRadius: '5px',
|
|
225
264
|
borderTopRightRadius: '5px',
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
265
|
+
padding: '12px 8px 4px',
|
|
266
|
+
boxSizing: 'border-box',
|
|
267
|
+
maxWidth: 'calc(100% - 163px)', // 163px is the width set on undoControls
|
|
268
|
+
'& button': {
|
|
269
|
+
marginBottom: '8px'
|
|
270
|
+
}
|
|
229
271
|
}
|
|
230
272
|
});
|
|
231
273
|
|
|
@@ -89,14 +89,18 @@ export class DrawableMain extends React.Component {
|
|
|
89
89
|
onMouseOutElement = () => this.setState({ isOver: false });
|
|
90
90
|
|
|
91
91
|
handleMouseDown = e => {
|
|
92
|
+
// ONLY IF MOBILE?
|
|
93
|
+
document.body.style.overflow = 'hidden';
|
|
94
|
+
|
|
92
95
|
const { newDrawable, textIsSelected } = this.state;
|
|
93
|
-
const { toolActive, fillColor, outlineColor } = this.props;
|
|
96
|
+
const { toolActive, fillColor, outlineColor, scale } = this.props;
|
|
94
97
|
|
|
95
98
|
if (newDrawable.length === 0 && !textIsSelected) {
|
|
96
99
|
const { x, y } = e.target.getStage().getPointerPosition();
|
|
100
|
+
|
|
97
101
|
const newDrawable = factory(toolActive.type, {
|
|
98
|
-
startx: x,
|
|
99
|
-
starty: y,
|
|
102
|
+
startx: x / scale,
|
|
103
|
+
starty: y / scale,
|
|
100
104
|
fillColor,
|
|
101
105
|
outlineColor,
|
|
102
106
|
createdAt: new Date()
|
|
@@ -109,13 +113,17 @@ export class DrawableMain extends React.Component {
|
|
|
109
113
|
};
|
|
110
114
|
|
|
111
115
|
handleMouseUp = e => {
|
|
116
|
+
// ONLY IF MOBILE?
|
|
117
|
+
document.body.style.overflow = 'initial';
|
|
118
|
+
|
|
112
119
|
const { newDrawable, drawables } = this.state;
|
|
120
|
+
const { scale } = this.props;
|
|
113
121
|
|
|
114
122
|
if (newDrawable.length === 1) {
|
|
115
123
|
const { x, y } = e.target.getStage().getPointerPosition();
|
|
116
124
|
const drawableToAdd = newDrawable[0];
|
|
117
125
|
|
|
118
|
-
drawableToAdd.registerMovement(x, y);
|
|
126
|
+
drawableToAdd.registerMovement(x / scale, y / scale);
|
|
119
127
|
drawables.push(drawableToAdd);
|
|
120
128
|
|
|
121
129
|
this.setState(
|
|
@@ -130,12 +138,13 @@ export class DrawableMain extends React.Component {
|
|
|
130
138
|
|
|
131
139
|
handleMouseMove = e => {
|
|
132
140
|
const { newDrawable } = this.state;
|
|
141
|
+
const { scale } = this.props;
|
|
133
142
|
|
|
134
143
|
if (newDrawable.length === 1) {
|
|
135
144
|
const { x, y } = e.target.getStage().getPointerPosition();
|
|
136
145
|
const updatedNewDrawable = newDrawable[0];
|
|
137
146
|
|
|
138
|
-
updatedNewDrawable.registerMovement(x, y);
|
|
147
|
+
updatedNewDrawable.registerMovement(x / scale, y / scale);
|
|
139
148
|
|
|
140
149
|
this.setState({
|
|
141
150
|
newDrawable: [updatedNewDrawable]
|
|
@@ -185,7 +194,9 @@ export class DrawableMain extends React.Component {
|
|
|
185
194
|
paintColor,
|
|
186
195
|
outlineColor,
|
|
187
196
|
TextEntry,
|
|
188
|
-
|
|
197
|
+
backgroundImageEnabled = true,
|
|
198
|
+
toolActive: { type },
|
|
199
|
+
scale
|
|
189
200
|
} = this.props;
|
|
190
201
|
const { isOver, newDrawable } = this.state;
|
|
191
202
|
|
|
@@ -205,7 +216,8 @@ export class DrawableMain extends React.Component {
|
|
|
205
216
|
handleSessionChange: this.handleSessionChange,
|
|
206
217
|
stage: this.stage,
|
|
207
218
|
onMouseOverElement: this.onMouseOverElement,
|
|
208
|
-
onMouseOutElement: this.onMouseOutElement
|
|
219
|
+
onMouseOutElement: this.onMouseOutElement,
|
|
220
|
+
scale
|
|
209
221
|
};
|
|
210
222
|
|
|
211
223
|
let listeners = {};
|
|
@@ -213,35 +225,45 @@ export class DrawableMain extends React.Component {
|
|
|
213
225
|
if (!disabled) {
|
|
214
226
|
listeners = {
|
|
215
227
|
onMouseUp: this.handleMouseUp,
|
|
216
|
-
|
|
228
|
+
onTouchEnd: this.handleMouseUp,
|
|
229
|
+
onMouseMove: this.handleMouseMove,
|
|
230
|
+
onTouchMove: this.handleMouseMove,
|
|
217
231
|
};
|
|
218
232
|
|
|
219
233
|
if (!draggable) {
|
|
220
234
|
listeners.onMouseDown = this.handleMouseDown;
|
|
235
|
+
listeners.onTouchStart = this.handleMouseDown;
|
|
221
236
|
}
|
|
222
237
|
}
|
|
223
238
|
|
|
239
|
+
const imageHeight = imageDimensions?.height * scale;
|
|
240
|
+
const imageWidth = imageDimensions?.width * scale;
|
|
241
|
+
|
|
224
242
|
return (
|
|
225
|
-
<div>
|
|
243
|
+
<div className={classes.wrapper}>
|
|
226
244
|
<div className={classes.undoControls}>
|
|
227
|
-
<Button disabled={disabled} onClick={this.handleUndo} label="Undo"
|
|
228
|
-
<Button disabled={disabled} onClick={this.handleClearAll} label="Clear all"
|
|
245
|
+
<Button disabled={disabled} onClick={this.handleUndo} label="Undo"/>
|
|
246
|
+
<Button disabled={disabled} onClick={this.handleClearAll} label="Clear all"/>
|
|
229
247
|
</div>
|
|
230
248
|
<div className={classes.base}>
|
|
231
|
-
{imageUrl && (
|
|
232
|
-
<ImageBackground
|
|
249
|
+
{backgroundImageEnabled && imageUrl && (
|
|
250
|
+
<ImageBackground
|
|
251
|
+
dimensions={{ height: imageHeight, width: imageWidth }}
|
|
252
|
+
url={imageUrl}/>
|
|
233
253
|
)}
|
|
234
254
|
|
|
235
255
|
{TextEntry.renderTextareas()}
|
|
236
256
|
|
|
237
257
|
<Stage
|
|
258
|
+
scaleX={scale}
|
|
259
|
+
scaleY={scale}
|
|
238
260
|
ref={ref => {
|
|
239
261
|
this.stage = ref;
|
|
240
262
|
}}
|
|
241
263
|
className={classnames(classes.stage, {
|
|
242
264
|
[classes.active]:
|
|
243
|
-
|
|
244
|
-
|
|
265
|
+
draggable &&
|
|
266
|
+
(isOver || (newDrawable && newDrawable.length === 1))
|
|
245
267
|
})}
|
|
246
268
|
height={drawableDimensions.height}
|
|
247
269
|
width={drawableDimensions.width}
|
|
@@ -266,6 +288,11 @@ export class DrawableMain extends React.Component {
|
|
|
266
288
|
}
|
|
267
289
|
|
|
268
290
|
const styles = () => ({
|
|
291
|
+
wrapper: {
|
|
292
|
+
display: 'flex',
|
|
293
|
+
flexWrap: 'wrap',
|
|
294
|
+
justifyContent: 'flex-end'
|
|
295
|
+
},
|
|
269
296
|
base: {
|
|
270
297
|
position: 'relative',
|
|
271
298
|
width: '100%'
|
|
@@ -279,7 +306,6 @@ const styles = () => ({
|
|
|
279
306
|
cursor: 'pointer'
|
|
280
307
|
},
|
|
281
308
|
undoControls: {
|
|
282
|
-
float: 'right',
|
|
283
309
|
marginTop: -43,
|
|
284
310
|
width: 163
|
|
285
311
|
}
|
|
@@ -297,7 +323,9 @@ DrawableMain.propTypes = {
|
|
|
297
323
|
imageUrl: PropTypes.string.isRequired,
|
|
298
324
|
TextEntry: PropTypes.object.isRequired,
|
|
299
325
|
toolActive: PropTypes.object.isRequired,
|
|
300
|
-
session: PropTypes.object.isRequired
|
|
326
|
+
session: PropTypes.object.isRequired,
|
|
327
|
+
backgroundImageEnabled: PropTypes.bool.isRequired,
|
|
328
|
+
scale: PropTypes.number.isRequired
|
|
301
329
|
};
|
|
302
330
|
|
|
303
331
|
export default withStyles(styles)(DrawableMain);
|
|
@@ -193,7 +193,7 @@ export default class TextDrawable {
|
|
|
193
193
|
handleTransform = (e, textNode) => {
|
|
194
194
|
this[textNode].setAttrs({
|
|
195
195
|
width: this[textNode].width() * this[textNode].scaleX(),
|
|
196
|
-
scaleX:
|
|
196
|
+
scaleX: this.props.scale,
|
|
197
197
|
});
|
|
198
198
|
};
|
|
199
199
|
|
|
@@ -266,11 +266,15 @@ export default class TextDrawable {
|
|
|
266
266
|
if (!props.disabled) {
|
|
267
267
|
extraProps = {
|
|
268
268
|
onClick: e => this.handleClick(e, id),
|
|
269
|
+
onTap: e => this.handleClick(e, id),
|
|
269
270
|
onDblClick: e => this.handleDblClick(e, text),
|
|
271
|
+
onDblTap: e => this.handleDblClick(e, text),
|
|
270
272
|
onTransform: e => this.handleTransform(e, textNode),
|
|
271
273
|
onTransformEnd: this.props.handleSessionChange,
|
|
272
274
|
onMouseDown: this.handleMouseDown,
|
|
275
|
+
onTouchStart: this.handleMouseDown,
|
|
273
276
|
onMouseUp: this.handleMouseUp,
|
|
277
|
+
onTouchEnd: this.handleMouseUp,
|
|
274
278
|
onDragEnd: this.props.handleSessionChange,
|
|
275
279
|
onMouseEnter: this.props.onMouseOverElement,
|
|
276
280
|
onMouseLeave: this.props.onMouseOutElement,
|
|
@@ -307,7 +311,9 @@ export default class TextDrawable {
|
|
|
307
311
|
}}
|
|
308
312
|
selectedShapeName={textNode}
|
|
309
313
|
onMouseDown={this.handleMouseDown}
|
|
314
|
+
onTouchStart={this.handleMouseDown}
|
|
310
315
|
onMouseUp={this.handleMouseUp}
|
|
316
|
+
onTouchEnd={this.handleMouseUp}
|
|
311
317
|
/>
|
|
312
318
|
)
|
|
313
319
|
];
|
|
@@ -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 {
|
|
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';
|
|
@@ -27,7 +27,8 @@ class DrawingResponseComponent extends React.Component {
|
|
|
27
27
|
imageUrl,
|
|
28
28
|
prompt,
|
|
29
29
|
mode,
|
|
30
|
-
teacherInstructions
|
|
30
|
+
teacherInstructions,
|
|
31
|
+
backgroundImageEnabled = true
|
|
31
32
|
},
|
|
32
33
|
session,
|
|
33
34
|
onSessionChange,
|
|
@@ -48,14 +49,14 @@ class DrawingResponseComponent extends React.Component {
|
|
|
48
49
|
visible: 'Hide Teacher Instructions'
|
|
49
50
|
}}
|
|
50
51
|
>
|
|
51
|
-
<
|
|
52
|
+
<PreviewPrompt prompt={teacherInstructions} />
|
|
52
53
|
</Collapsible>
|
|
53
54
|
<br />
|
|
54
55
|
</React.Fragment>
|
|
55
56
|
)}
|
|
56
57
|
|
|
57
58
|
<Typography className={classes.prompt}>
|
|
58
|
-
<span
|
|
59
|
+
<PreviewPrompt tagName="span" prompt={prompt} />
|
|
59
60
|
</Typography>
|
|
60
61
|
|
|
61
62
|
<Container
|
|
@@ -64,6 +65,7 @@ class DrawingResponseComponent extends React.Component {
|
|
|
64
65
|
isEvaluateMode={isEvaluateMode}
|
|
65
66
|
imageDimensions={imageDimensions}
|
|
66
67
|
imageUrl={imageUrl}
|
|
68
|
+
backgroundImageEnabled={backgroundImageEnabled}
|
|
67
69
|
disabled={disabled}
|
|
68
70
|
/>
|
|
69
71
|
</div>
|
package/src/index.js
CHANGED
|
@@ -40,6 +40,10 @@ export default class DrawingResponse extends HTMLElement {
|
|
|
40
40
|
this._render();
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
get session() {
|
|
44
|
+
return this._session;
|
|
45
|
+
}
|
|
46
|
+
|
|
43
47
|
connectedCallback() {
|
|
44
48
|
this._render();
|
|
45
49
|
}
|
|
@@ -51,6 +55,7 @@ export default class DrawingResponse extends HTMLElement {
|
|
|
51
55
|
session: this._session,
|
|
52
56
|
onSessionChange: this.sessionChanged
|
|
53
57
|
});
|
|
58
|
+
|
|
54
59
|
ReactDOM.render(el, this, () => {
|
|
55
60
|
renderMath(this);
|
|
56
61
|
});
|