@pie-lib/math-toolbar 1.31.2-next.0 → 1.33.0-mui-update.0
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 +11 -7
- package/lib/done-button.js +34 -51
- package/lib/done-button.js.map +1 -1
- package/lib/editor-and-pad.js +285 -332
- package/lib/editor-and-pad.js.map +1 -1
- package/lib/index.js +64 -109
- package/lib/index.js.map +1 -1
- package/lib/math-preview.js +138 -185
- package/lib/math-preview.js.map +1 -1
- package/lib/utils.js +1 -5
- package/lib/utils.js.map +1 -1
- package/package.json +11 -9
- package/src/done-button.jsx +27 -33
- package/src/editor-and-pad.jsx +231 -229
- package/src/index.jsx +11 -14
- package/src/math-preview.jsx +124 -139
package/src/editor-and-pad.jsx
CHANGED
|
@@ -2,11 +2,13 @@ import React from 'react';
|
|
|
2
2
|
import debug from 'debug';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import cx from 'classnames';
|
|
5
|
-
import Button from '@material
|
|
6
|
-
import {
|
|
7
|
-
import MenuItem from '@material
|
|
8
|
-
import Select from '@material
|
|
5
|
+
import Button from '@mui/material/Button';
|
|
6
|
+
import { styled } from '@mui/material/styles';
|
|
7
|
+
import MenuItem from '@mui/material/MenuItem';
|
|
8
|
+
import Select from '@mui/material/Select';
|
|
9
9
|
import isEqual from 'lodash/isEqual';
|
|
10
|
+
import FormControl from '@mui/material/FormControl';
|
|
11
|
+
import InputLabel from '@mui/material/InputLabel';
|
|
10
12
|
|
|
11
13
|
import { HorizontalKeypad, mq, updateSpans } from '@pie-lib/math-input';
|
|
12
14
|
import { color, InputContainer } from '@pie-lib/render-ui';
|
|
@@ -17,6 +19,201 @@ const log = debug('@pie-lib:math-toolbar:editor-and-pad');
|
|
|
17
19
|
|
|
18
20
|
const decimalRegex = /\.|,/g;
|
|
19
21
|
|
|
22
|
+
const MathToolbarContainer = styled('div')(({ theme }) => ({
|
|
23
|
+
zIndex: 9,
|
|
24
|
+
position: 'relative',
|
|
25
|
+
textAlign: 'center',
|
|
26
|
+
width: 'auto',
|
|
27
|
+
'& > .mq-math-mode': {
|
|
28
|
+
border: 'solid 1px lightgrey',
|
|
29
|
+
},
|
|
30
|
+
'& > .mq-focused': {
|
|
31
|
+
outline: 'none',
|
|
32
|
+
boxShadow: 'none',
|
|
33
|
+
border: `dotted 1px ${theme.palette.primary.main}`,
|
|
34
|
+
borderRadius: '0px',
|
|
35
|
+
},
|
|
36
|
+
'& .mq-overarrow-inner': {
|
|
37
|
+
border: 'none !important',
|
|
38
|
+
paddingTop: '0 !important',
|
|
39
|
+
},
|
|
40
|
+
'& .mq-overarrow-inner-right': {
|
|
41
|
+
display: 'none !important',
|
|
42
|
+
},
|
|
43
|
+
'& .mq-overarrow-inner-left': {
|
|
44
|
+
display: 'none !important',
|
|
45
|
+
},
|
|
46
|
+
'& .mq-longdiv-inner': {
|
|
47
|
+
borderTop: '1px solid !important',
|
|
48
|
+
paddingTop: '1.5px !important',
|
|
49
|
+
},
|
|
50
|
+
'& .mq-overarrow.mq-arrow-both': {
|
|
51
|
+
top: '7.8px',
|
|
52
|
+
marginTop: '0px',
|
|
53
|
+
minWidth: '1.23em',
|
|
54
|
+
},
|
|
55
|
+
'& .mq-parallelogram': {
|
|
56
|
+
lineHeight: 0.85,
|
|
57
|
+
},
|
|
58
|
+
}));
|
|
59
|
+
|
|
60
|
+
const InputAndTypeContainer = styled('div')(({ theme, hide }) => ({
|
|
61
|
+
display: hide ? 'none' : 'flex',
|
|
62
|
+
alignItems: 'center',
|
|
63
|
+
'& .mq-editable-field .mq-cursor': {
|
|
64
|
+
top: '-4px',
|
|
65
|
+
},
|
|
66
|
+
'& .mq-math-mode .mq-selection, .mq-editable-field .mq-selection': {
|
|
67
|
+
paddingTop: '18px',
|
|
68
|
+
},
|
|
69
|
+
'& .mq-math-mode .mq-overarrow': {
|
|
70
|
+
fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important',
|
|
71
|
+
},
|
|
72
|
+
'& .mq-math-mode .mq-overline .mq-overline-inner': {
|
|
73
|
+
paddingTop: '0.4em !important',
|
|
74
|
+
},
|
|
75
|
+
'& .mq-overarrow.mq-arrow-both': {
|
|
76
|
+
minWidth: '1.23em',
|
|
77
|
+
'& *': {
|
|
78
|
+
lineHeight: '1 !important',
|
|
79
|
+
},
|
|
80
|
+
'&:before': {
|
|
81
|
+
top: '-0.45em',
|
|
82
|
+
left: '-1px',
|
|
83
|
+
},
|
|
84
|
+
'&:after': {
|
|
85
|
+
position: 'absolute !important',
|
|
86
|
+
top: '0px !important',
|
|
87
|
+
right: '-2px',
|
|
88
|
+
},
|
|
89
|
+
'&.mq-empty:after': {
|
|
90
|
+
top: '-0.45em',
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
'& .mq-overarrow.mq-arrow-right': {
|
|
94
|
+
'&:before': {
|
|
95
|
+
top: '-0.4em',
|
|
96
|
+
right: '-1px',
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
'& *': {
|
|
100
|
+
...commonMqFontStyles,
|
|
101
|
+
...supsubStyles,
|
|
102
|
+
...longdivStyles,
|
|
103
|
+
'& .mq-math-mode .mq-sqrt-prefix': {
|
|
104
|
+
verticalAlign: 'baseline !important',
|
|
105
|
+
top: '1px !important',
|
|
106
|
+
left: '-0.1em !important',
|
|
107
|
+
},
|
|
108
|
+
'& .mq-math-mode .mq-overarc ': {
|
|
109
|
+
paddingTop: '0.45em !important',
|
|
110
|
+
},
|
|
111
|
+
'& .mq-math-mode .mq-empty': {
|
|
112
|
+
padding: '9px 1px !important',
|
|
113
|
+
},
|
|
114
|
+
'& .mq-math-mode .mq-root-block': {
|
|
115
|
+
paddingTop: '10px',
|
|
116
|
+
},
|
|
117
|
+
'& .mq-scaled .mq-sqrt-prefix': {
|
|
118
|
+
top: '0 !important',
|
|
119
|
+
},
|
|
120
|
+
'& .mq-math-mode .mq-longdiv .mq-longdiv-inner': {
|
|
121
|
+
marginLeft: '4px !important',
|
|
122
|
+
paddingTop: '6px !important',
|
|
123
|
+
paddingLeft: '6px !important',
|
|
124
|
+
},
|
|
125
|
+
'& .mq-math-mode .mq-paren': {
|
|
126
|
+
verticalAlign: 'top !important',
|
|
127
|
+
padding: '1px 0.1em !important',
|
|
128
|
+
},
|
|
129
|
+
'& .mq-math-mode .mq-sqrt-stem': {
|
|
130
|
+
borderTop: '0.07em solid',
|
|
131
|
+
marginLeft: '-1.5px',
|
|
132
|
+
marginTop: '-2px !important',
|
|
133
|
+
paddingTop: '5px !important',
|
|
134
|
+
},
|
|
135
|
+
'& .mq-math-mode .mq-denominator': {
|
|
136
|
+
marginTop: '-5px !important',
|
|
137
|
+
padding: '0.5em 0.1em 0.1em !important',
|
|
138
|
+
},
|
|
139
|
+
'& .mq-math-mode .mq-numerator, .mq-math-mode .mq-over': {
|
|
140
|
+
padding: '0 0.1em !important',
|
|
141
|
+
paddingBottom: '0 !important',
|
|
142
|
+
marginBottom: '-2px',
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
'& span[data-prime="true"]': {
|
|
146
|
+
fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important',
|
|
147
|
+
},
|
|
148
|
+
}));
|
|
149
|
+
|
|
150
|
+
const StyledFormControl = styled(FormControl)({
|
|
151
|
+
flex: 'initial',
|
|
152
|
+
width: '25%',
|
|
153
|
+
minWidth: '100px',
|
|
154
|
+
marginLeft: '15px',
|
|
155
|
+
marginTop: '5px',
|
|
156
|
+
marginBottom: '5px',
|
|
157
|
+
marginRight: '5px',
|
|
158
|
+
'& label': {
|
|
159
|
+
fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important',
|
|
160
|
+
},
|
|
161
|
+
'& div': {
|
|
162
|
+
fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important',
|
|
163
|
+
},
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
const StyledInputLabel = styled(InputLabel)(() => ({
|
|
168
|
+
backgroundColor: 'transparent',
|
|
169
|
+
}));
|
|
170
|
+
|
|
171
|
+
const InputContainerDiv = styled('div')(({ theme, error }) => ({
|
|
172
|
+
minWidth: '500px',
|
|
173
|
+
maxWidth: '900px',
|
|
174
|
+
minHeight: '30px',
|
|
175
|
+
width: '100%',
|
|
176
|
+
display: 'flex',
|
|
177
|
+
marginTop: theme.spacing(1),
|
|
178
|
+
marginBottom: theme.spacing(1),
|
|
179
|
+
...(error && {
|
|
180
|
+
border: '2px solid red',
|
|
181
|
+
}),
|
|
182
|
+
'& .mq-sqrt-prefix .mq-scaled': {
|
|
183
|
+
verticalAlign: 'middle !important',
|
|
184
|
+
},
|
|
185
|
+
}));
|
|
186
|
+
|
|
187
|
+
const MathEditor = styled(mq.Input)(({ controlledKeypadMode }) => ({
|
|
188
|
+
maxWidth: controlledKeypadMode ? '400px' : '500px',
|
|
189
|
+
color: color.text(),
|
|
190
|
+
backgroundColor: color.background(),
|
|
191
|
+
padding: '2px',
|
|
192
|
+
}));
|
|
193
|
+
|
|
194
|
+
const AddAnswerBlockButton = styled(Button)({
|
|
195
|
+
position: 'absolute',
|
|
196
|
+
right: '12px',
|
|
197
|
+
border: '1px solid lightgrey',
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
const StyledHr = styled('hr')(({ theme }) => ({
|
|
201
|
+
padding: 0,
|
|
202
|
+
margin: 0,
|
|
203
|
+
height: '1px',
|
|
204
|
+
border: 'none',
|
|
205
|
+
borderBottom: `solid 1px ${theme.palette.primary.main}`,
|
|
206
|
+
}));
|
|
207
|
+
|
|
208
|
+
const KeyboardContainer = styled(HorizontalKeypad)(({ mode }) => ({
|
|
209
|
+
...commonMqKeyboardStyles,
|
|
210
|
+
...(mode === 'language' && {
|
|
211
|
+
'& *': {
|
|
212
|
+
fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important',
|
|
213
|
+
},
|
|
214
|
+
}),
|
|
215
|
+
}));
|
|
216
|
+
|
|
20
217
|
const toNodeData = (data) => {
|
|
21
218
|
if (!data) {
|
|
22
219
|
return;
|
|
@@ -56,7 +253,6 @@ export class EditorAndPad extends React.Component {
|
|
|
56
253
|
onFocus: PropTypes.func,
|
|
57
254
|
onBlur: PropTypes.func,
|
|
58
255
|
onChange: PropTypes.func.isRequired,
|
|
59
|
-
classes: PropTypes.object,
|
|
60
256
|
setKeypadInteraction: PropTypes.func,
|
|
61
257
|
};
|
|
62
258
|
|
|
@@ -218,7 +414,6 @@ export class EditorAndPad extends React.Component {
|
|
|
218
414
|
latex,
|
|
219
415
|
onFocus,
|
|
220
416
|
onBlur,
|
|
221
|
-
classes,
|
|
222
417
|
error,
|
|
223
418
|
} = this.props;
|
|
224
419
|
const shouldShowKeypad = !controlledKeypad || (controlledKeypad && showKeypad);
|
|
@@ -227,11 +422,22 @@ export class EditorAndPad extends React.Component {
|
|
|
227
422
|
log('[render]', latex);
|
|
228
423
|
|
|
229
424
|
return (
|
|
230
|
-
<
|
|
231
|
-
<
|
|
425
|
+
<MathToolbarContainer className={cx(classNames.mathToolbar)}>
|
|
426
|
+
<InputAndTypeContainer hide={hideInput}>
|
|
232
427
|
{controlledKeypadMode && (
|
|
233
|
-
<
|
|
234
|
-
<
|
|
428
|
+
<StyledFormControl variant={'standard'}>
|
|
429
|
+
<StyledInputLabel id="equation-editor-label">
|
|
430
|
+
{'Equation Editor'}
|
|
431
|
+
</StyledInputLabel>
|
|
432
|
+
<Select
|
|
433
|
+
labelId="equation-editor-label"
|
|
434
|
+
id="equation-editor-select"
|
|
435
|
+
name="equationEditor"
|
|
436
|
+
label={'Equation Editor'}
|
|
437
|
+
onChange={this.onEditorTypeChange}
|
|
438
|
+
value={this.state.equationEditor}
|
|
439
|
+
MenuProps={{ transitionDuration: { enter: 225, exit: 195 } }}
|
|
440
|
+
>
|
|
235
441
|
<MenuItem value="non-negative-integers">Numeric - Non-Negative Integers</MenuItem>
|
|
236
442
|
<MenuItem value="integers">Numeric - Integers</MenuItem>
|
|
237
443
|
<MenuItem value="decimals">Numeric - Decimals</MenuItem>
|
|
@@ -245,10 +451,10 @@ export class EditorAndPad extends React.Component {
|
|
|
245
451
|
<MenuItem value={'statistics'}>Statistics</MenuItem>
|
|
246
452
|
<MenuItem value={'item-authoring'}>Item Authoring</MenuItem>
|
|
247
453
|
</Select>
|
|
248
|
-
</
|
|
454
|
+
</StyledFormControl>
|
|
249
455
|
)}
|
|
250
|
-
<
|
|
251
|
-
<
|
|
456
|
+
<InputContainerDiv error={error}>
|
|
457
|
+
<MathEditor
|
|
252
458
|
onFocus={() => {
|
|
253
459
|
onFocus && onFocus();
|
|
254
460
|
this.updateDisable(false);
|
|
@@ -257,243 +463,39 @@ export class EditorAndPad extends React.Component {
|
|
|
257
463
|
this.updateDisable(false);
|
|
258
464
|
onBlur && onBlur(event);
|
|
259
465
|
}}
|
|
260
|
-
className={cx(
|
|
261
|
-
|
|
466
|
+
className={cx(classNames.editor)}
|
|
467
|
+
controlledKeypadMode={controlledKeypadMode}
|
|
468
|
+
ref={(r) => (this.input = r)}
|
|
262
469
|
latex={latex}
|
|
263
470
|
onChange={this.onEditorChange}
|
|
264
471
|
/>
|
|
265
|
-
</
|
|
266
|
-
</
|
|
472
|
+
</InputContainerDiv>
|
|
473
|
+
</InputAndTypeContainer>
|
|
267
474
|
{allowAnswerBlock && (
|
|
268
|
-
<
|
|
269
|
-
className={classes.addAnswerBlockButton}
|
|
475
|
+
<AddAnswerBlockButton
|
|
270
476
|
type="primary"
|
|
271
477
|
style={{ bottom: shouldShowKeypad ? '320px' : '20px' }}
|
|
272
478
|
onClick={this.onAnswerBlockClick}
|
|
273
479
|
disabled={addDisabled}
|
|
274
480
|
>
|
|
275
481
|
+ Response Area
|
|
276
|
-
</
|
|
482
|
+
</AddAnswerBlockButton>
|
|
277
483
|
)}
|
|
278
|
-
<
|
|
484
|
+
<StyledHr />
|
|
279
485
|
{shouldShowKeypad && (
|
|
280
|
-
<
|
|
281
|
-
|
|
486
|
+
<KeyboardContainer
|
|
487
|
+
mode={controlledKeypadMode ? this.state.equationEditor : keypadMode}
|
|
282
488
|
controlledKeypadMode={controlledKeypadMode}
|
|
283
489
|
layoutForKeyPad={layoutForKeyPad}
|
|
284
490
|
additionalKeys={additionalKeys}
|
|
285
|
-
mode={controlledKeypadMode ? this.state.equationEditor : keypadMode}
|
|
286
491
|
onClick={this.onClick}
|
|
287
492
|
noDecimal={noDecimal}
|
|
288
493
|
setKeypadInteraction={setKeypadInteraction}
|
|
289
494
|
/>
|
|
290
495
|
)}
|
|
291
|
-
</
|
|
496
|
+
</MathToolbarContainer>
|
|
292
497
|
);
|
|
293
498
|
}
|
|
294
499
|
}
|
|
295
500
|
|
|
296
|
-
|
|
297
|
-
inputAndTypeContainer: {
|
|
298
|
-
display: 'flex',
|
|
299
|
-
alignItems: 'center',
|
|
300
|
-
'& .mq-editable-field .mq-cursor': {
|
|
301
|
-
top: '-4px',
|
|
302
|
-
},
|
|
303
|
-
'& .mq-math-mode .mq-selection, .mq-editable-field .mq-selection': {
|
|
304
|
-
paddingTop: '18px',
|
|
305
|
-
},
|
|
306
|
-
'& .mq-math-mode .mq-overarrow': {
|
|
307
|
-
fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important',
|
|
308
|
-
},
|
|
309
|
-
'& .mq-math-mode .mq-overline .mq-overline-inner': {
|
|
310
|
-
paddingTop: '0.4em !important',
|
|
311
|
-
},
|
|
312
|
-
'& .mq-overarrow.mq-arrow-both': {
|
|
313
|
-
minWidth: '1.23em',
|
|
314
|
-
'& *': {
|
|
315
|
-
lineHeight: '1 !important',
|
|
316
|
-
},
|
|
317
|
-
'&:before': {
|
|
318
|
-
top: '-0.45em',
|
|
319
|
-
left: '-1px',
|
|
320
|
-
},
|
|
321
|
-
'&:after': {
|
|
322
|
-
position: 'absolute !important',
|
|
323
|
-
top: '0px !important',
|
|
324
|
-
right: '-2px',
|
|
325
|
-
},
|
|
326
|
-
'&.mq-empty:after': {
|
|
327
|
-
top: '-0.45em',
|
|
328
|
-
},
|
|
329
|
-
},
|
|
330
|
-
'& .mq-overarrow.mq-arrow-right': {
|
|
331
|
-
'&:before': {
|
|
332
|
-
top: '-0.4em',
|
|
333
|
-
right: '-1px',
|
|
334
|
-
},
|
|
335
|
-
},
|
|
336
|
-
|
|
337
|
-
'& *': {
|
|
338
|
-
...commonMqFontStyles,
|
|
339
|
-
...supsubStyles,
|
|
340
|
-
...longdivStyles,
|
|
341
|
-
'& .mq-math-mode .mq-sqrt-prefix': {
|
|
342
|
-
verticalAlign: 'baseline !important',
|
|
343
|
-
top: '1px !important',
|
|
344
|
-
left: '-0.1em !important',
|
|
345
|
-
},
|
|
346
|
-
|
|
347
|
-
'& .mq-math-mode .mq-overarc ': {
|
|
348
|
-
paddingTop: '0.45em !important',
|
|
349
|
-
},
|
|
350
|
-
|
|
351
|
-
'& .mq-math-mode .mq-empty': {
|
|
352
|
-
padding: '9px 1px !important',
|
|
353
|
-
},
|
|
354
|
-
|
|
355
|
-
'& .mq-math-mode .mq-root-block': {
|
|
356
|
-
paddingTop: '10px',
|
|
357
|
-
},
|
|
358
|
-
|
|
359
|
-
'& .mq-scaled .mq-sqrt-prefix': {
|
|
360
|
-
top: '0 !important',
|
|
361
|
-
},
|
|
362
|
-
|
|
363
|
-
'& .mq-math-mode .mq-longdiv .mq-longdiv-inner': {
|
|
364
|
-
marginLeft: '4px !important',
|
|
365
|
-
paddingTop: '6px !important',
|
|
366
|
-
paddingLeft: '6px !important',
|
|
367
|
-
},
|
|
368
|
-
|
|
369
|
-
'& .mq-math-mode .mq-paren': {
|
|
370
|
-
verticalAlign: 'top !important',
|
|
371
|
-
padding: '1px 0.1em !important',
|
|
372
|
-
},
|
|
373
|
-
|
|
374
|
-
'& .mq-math-mode .mq-sqrt-stem': {
|
|
375
|
-
borderTop: '0.07em solid',
|
|
376
|
-
marginLeft: '-1.5px',
|
|
377
|
-
marginTop: '-2px !important',
|
|
378
|
-
paddingTop: '5px !important',
|
|
379
|
-
},
|
|
380
|
-
|
|
381
|
-
'& .mq-math-mode .mq-denominator': {
|
|
382
|
-
marginTop: '-5px !important',
|
|
383
|
-
padding: '0.5em 0.1em 0.1em !important',
|
|
384
|
-
},
|
|
385
|
-
|
|
386
|
-
'& .mq-math-mode .mq-numerator, .mq-math-mode .mq-over': {
|
|
387
|
-
padding: '0 0.1em !important',
|
|
388
|
-
paddingBottom: '0 !important',
|
|
389
|
-
marginBottom: '-2px',
|
|
390
|
-
},
|
|
391
|
-
},
|
|
392
|
-
|
|
393
|
-
'& span[data-prime="true"]': {
|
|
394
|
-
fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important',
|
|
395
|
-
},
|
|
396
|
-
},
|
|
397
|
-
hide: {
|
|
398
|
-
display: 'none',
|
|
399
|
-
},
|
|
400
|
-
selectContainer: {
|
|
401
|
-
flex: 'initial',
|
|
402
|
-
width: '25%',
|
|
403
|
-
minWidth: '100px',
|
|
404
|
-
marginLeft: '15px',
|
|
405
|
-
marginTop: '5px',
|
|
406
|
-
marginBottom: '5px',
|
|
407
|
-
marginRight: '5px',
|
|
408
|
-
|
|
409
|
-
'& label': {
|
|
410
|
-
fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important',
|
|
411
|
-
},
|
|
412
|
-
|
|
413
|
-
'& div': {
|
|
414
|
-
fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important',
|
|
415
|
-
},
|
|
416
|
-
},
|
|
417
|
-
mathEditor: {
|
|
418
|
-
maxWidth: '400px',
|
|
419
|
-
color: color.text(),
|
|
420
|
-
backgroundColor: color.background(),
|
|
421
|
-
padding: '2px',
|
|
422
|
-
},
|
|
423
|
-
longMathEditor: {
|
|
424
|
-
maxWidth: '500px',
|
|
425
|
-
},
|
|
426
|
-
addAnswerBlockButton: {
|
|
427
|
-
position: 'absolute',
|
|
428
|
-
right: '12px',
|
|
429
|
-
border: '1px solid lightgrey',
|
|
430
|
-
},
|
|
431
|
-
hr: {
|
|
432
|
-
padding: 0,
|
|
433
|
-
margin: 0,
|
|
434
|
-
height: '1px',
|
|
435
|
-
border: 'none',
|
|
436
|
-
borderBottom: `solid 1px ${theme.palette.primary.main}`,
|
|
437
|
-
},
|
|
438
|
-
mathToolbar: {
|
|
439
|
-
zIndex: 9,
|
|
440
|
-
position: 'relative',
|
|
441
|
-
textAlign: 'center',
|
|
442
|
-
width: 'auto',
|
|
443
|
-
'& > .mq-math-mode': {
|
|
444
|
-
border: 'solid 1px lightgrey',
|
|
445
|
-
},
|
|
446
|
-
'& > .mq-focused': {
|
|
447
|
-
outline: 'none',
|
|
448
|
-
boxShadow: 'none',
|
|
449
|
-
border: `dotted 1px ${theme.palette.primary.main}`,
|
|
450
|
-
borderRadius: '0px',
|
|
451
|
-
},
|
|
452
|
-
'& .mq-overarrow-inner': {
|
|
453
|
-
border: 'none !important',
|
|
454
|
-
paddingTop: '0 !important',
|
|
455
|
-
},
|
|
456
|
-
'& .mq-overarrow-inner-right': {
|
|
457
|
-
display: 'none !important',
|
|
458
|
-
},
|
|
459
|
-
'& .mq-overarrow-inner-left': {
|
|
460
|
-
display: 'none !important',
|
|
461
|
-
},
|
|
462
|
-
'& .mq-longdiv-inner': {
|
|
463
|
-
borderTop: '1px solid !important',
|
|
464
|
-
paddingTop: '1.5px !important',
|
|
465
|
-
},
|
|
466
|
-
'& .mq-overarrow.mq-arrow-both': {
|
|
467
|
-
top: '7.8px',
|
|
468
|
-
marginTop: '0px',
|
|
469
|
-
minWidth: '1.23em',
|
|
470
|
-
},
|
|
471
|
-
'& .mq-parallelogram': {
|
|
472
|
-
lineHeight: 0.85,
|
|
473
|
-
},
|
|
474
|
-
},
|
|
475
|
-
inputContainer: {
|
|
476
|
-
minWidth: '500px',
|
|
477
|
-
maxWidth: '900px',
|
|
478
|
-
minHeight: '30px',
|
|
479
|
-
width: '100%',
|
|
480
|
-
display: 'flex',
|
|
481
|
-
marginTop: theme.spacing.unit,
|
|
482
|
-
marginBottom: theme.spacing.unit,
|
|
483
|
-
|
|
484
|
-
'& .mq-sqrt-prefix .mq-scaled': {
|
|
485
|
-
verticalAlign: 'middle !important',
|
|
486
|
-
},
|
|
487
|
-
},
|
|
488
|
-
error: {
|
|
489
|
-
border: '2px solid red',
|
|
490
|
-
},
|
|
491
|
-
keyboard: commonMqKeyboardStyles,
|
|
492
|
-
language: {
|
|
493
|
-
'& *': {
|
|
494
|
-
fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important',
|
|
495
|
-
},
|
|
496
|
-
},
|
|
497
|
-
});
|
|
498
|
-
|
|
499
|
-
export default withStyles(styles)(EditorAndPad);
|
|
501
|
+
export default EditorAndPad;
|
package/src/index.jsx
CHANGED
|
@@ -3,11 +3,18 @@ import PropTypes from 'prop-types';
|
|
|
3
3
|
import cx from 'classnames';
|
|
4
4
|
import EditorAndPad from './editor-and-pad';
|
|
5
5
|
import { DoneButton } from './done-button';
|
|
6
|
-
import {
|
|
6
|
+
import { styled } from '@mui/material/styles';
|
|
7
7
|
import MathPreview from './math-preview';
|
|
8
8
|
|
|
9
9
|
export { MathPreview };
|
|
10
10
|
|
|
11
|
+
const PureToolbarContainer = styled('div')({
|
|
12
|
+
display: 'flex',
|
|
13
|
+
width: '100%',
|
|
14
|
+
zIndex: 8,
|
|
15
|
+
alignItems: 'center',
|
|
16
|
+
});
|
|
17
|
+
|
|
11
18
|
export class MathToolbar extends React.Component {
|
|
12
19
|
static propTypes = {
|
|
13
20
|
autoFocus: PropTypes.bool,
|
|
@@ -131,7 +138,6 @@ export class RawPureToolbar extends React.Component {
|
|
|
131
138
|
onAnswerBlockAdd: PropTypes.func,
|
|
132
139
|
additionalKeys: PropTypes.array,
|
|
133
140
|
onFocus: PropTypes.func,
|
|
134
|
-
classes: PropTypes.object.isRequired,
|
|
135
141
|
autoFocus: PropTypes.bool,
|
|
136
142
|
noDecimal: PropTypes.bool,
|
|
137
143
|
allowAnswerBlock: PropTypes.bool,
|
|
@@ -175,13 +181,12 @@ export class RawPureToolbar extends React.Component {
|
|
|
175
181
|
onBlur,
|
|
176
182
|
hideDoneButton,
|
|
177
183
|
hideDoneButtonBackground,
|
|
178
|
-
classes,
|
|
179
184
|
error,
|
|
180
185
|
maxResponseAreas,
|
|
181
186
|
} = this.props;
|
|
182
187
|
|
|
183
188
|
return (
|
|
184
|
-
<
|
|
189
|
+
<PureToolbarContainer className={cx((classNames || {}).toolbar)} ref={keyPadCharacterRef}>
|
|
185
190
|
<div />
|
|
186
191
|
<EditorAndPad
|
|
187
192
|
autoFocus={autoFocus}
|
|
@@ -208,17 +213,9 @@ export class RawPureToolbar extends React.Component {
|
|
|
208
213
|
{(!controlledKeypad || (controlledKeypad && showKeypad)) && !hideDoneButton && (
|
|
209
214
|
<DoneButton hideBackground={hideDoneButtonBackground} onClick={onDone} />
|
|
210
215
|
)}
|
|
211
|
-
</
|
|
216
|
+
</PureToolbarContainer>
|
|
212
217
|
);
|
|
213
218
|
}
|
|
214
219
|
}
|
|
215
|
-
const styles = () => ({
|
|
216
|
-
pureToolbar: {
|
|
217
|
-
display: 'flex',
|
|
218
|
-
width: '100%',
|
|
219
|
-
zIndex: 8,
|
|
220
|
-
alignItems: 'center',
|
|
221
|
-
},
|
|
222
|
-
});
|
|
223
220
|
|
|
224
|
-
export const PureToolbar =
|
|
221
|
+
export const PureToolbar = RawPureToolbar;
|