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