@pie-lib/math-toolbar 1.31.1 → 1.32.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 +8 -15
- package/lib/done-button.js +34 -51
- package/lib/done-button.js.map +1 -1
- package/lib/editor-and-pad.js +265 -330
- 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 +215 -229
- package/src/index.jsx +11 -14
- package/src/math-preview.jsx +124 -139
package/src/math-preview.jsx
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import classNames from 'classnames';
|
|
3
2
|
import debug from 'debug';
|
|
4
|
-
import {
|
|
3
|
+
import { styled } from '@mui/material/styles';
|
|
5
4
|
import PropTypes from 'prop-types';
|
|
6
5
|
import { mq } from '@pie-lib/math-input';
|
|
7
6
|
import { markFractionBaseSuperscripts } from './utils';
|
|
@@ -10,11 +9,128 @@ const { commonMqFontStyles, longdivStyles, supsubStyles } = mq.CommonMqStyles;
|
|
|
10
9
|
|
|
11
10
|
const log = debug('@pie-lib:math-toolbar:math-preview');
|
|
12
11
|
|
|
12
|
+
const MathPreviewContainer = styled('div')(({ theme, isSelected }) => ({
|
|
13
|
+
display: 'inline-flex',
|
|
14
|
+
alignItems: 'center',
|
|
15
|
+
position: 'relative',
|
|
16
|
+
'& *': commonMqFontStyles,
|
|
17
|
+
...supsubStyles,
|
|
18
|
+
...longdivStyles,
|
|
19
|
+
'& > .mq-math-mode': {
|
|
20
|
+
border: isSelected ? 'solid 0px lightgrey' : 'solid 1px lightgrey',
|
|
21
|
+
},
|
|
22
|
+
'& > .mq-focused': {
|
|
23
|
+
outline: 'none',
|
|
24
|
+
boxShadow: 'none',
|
|
25
|
+
border: 'solid 1px black',
|
|
26
|
+
borderRadius: '0px',
|
|
27
|
+
},
|
|
28
|
+
'& > .mq-math-mode .mq-root-block': {
|
|
29
|
+
paddingTop: '7px !important',
|
|
30
|
+
},
|
|
31
|
+
'& > .mq-math-mode .mq-overarc ': {
|
|
32
|
+
paddingTop: '0.45em !important',
|
|
33
|
+
},
|
|
34
|
+
'& > .mq-math-mode .mq-sqrt-prefix': {
|
|
35
|
+
verticalAlign: 'baseline !important',
|
|
36
|
+
top: '1px !important',
|
|
37
|
+
left: '-0.1em !important',
|
|
38
|
+
},
|
|
39
|
+
'& > .mq-math-mode .mq-denominator': {
|
|
40
|
+
marginTop: '-5px !important',
|
|
41
|
+
padding: '0.5em 0.1em 0.1em !important',
|
|
42
|
+
},
|
|
43
|
+
'& > .mq-math-mode .mq-numerator, .mq-math-mode .mq-over': {
|
|
44
|
+
padding: '0 0.1em !important',
|
|
45
|
+
paddingBottom: '0 !important',
|
|
46
|
+
marginBottom: '-2px',
|
|
47
|
+
},
|
|
48
|
+
'& > .mq-math-mode .mq-longdiv .mq-longdiv-inner .mq-empty': {
|
|
49
|
+
paddingTop: '6px !important',
|
|
50
|
+
paddingLeft: '4px !important',
|
|
51
|
+
},
|
|
52
|
+
'& > .mq-math-mode .mq-longdiv .mq-longdiv-inner': {
|
|
53
|
+
marginLeft: '0 !important',
|
|
54
|
+
},
|
|
55
|
+
'& > .mq-math-mode .mq-overarrow': {
|
|
56
|
+
fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important',
|
|
57
|
+
},
|
|
58
|
+
'& > .mq-math-mode .mq-paren': {
|
|
59
|
+
verticalAlign: 'top !important',
|
|
60
|
+
padding: '1px 0.1em !important',
|
|
61
|
+
},
|
|
62
|
+
'& > .mq-math-mode .mq-sqrt-stem': {
|
|
63
|
+
borderTop: '0.07em solid',
|
|
64
|
+
marginLeft: '-1.5px',
|
|
65
|
+
marginTop: '-2px !important',
|
|
66
|
+
paddingTop: '5px !important',
|
|
67
|
+
},
|
|
68
|
+
'& .mq-overarrow-inner': {
|
|
69
|
+
paddingTop: '0 !important',
|
|
70
|
+
border: 'none !important',
|
|
71
|
+
},
|
|
72
|
+
'& .mq-editable-field .mq-cursor': {
|
|
73
|
+
marginTop: '-15px !important',
|
|
74
|
+
},
|
|
75
|
+
'& .mq-overarrow.mq-arrow-both': {
|
|
76
|
+
top: '7.5px',
|
|
77
|
+
marginTop: '0px',
|
|
78
|
+
minWidth: '1.23em',
|
|
79
|
+
'& *': {
|
|
80
|
+
lineHeight: '1 !important',
|
|
81
|
+
},
|
|
82
|
+
'&:before': {
|
|
83
|
+
top: '-0.4em',
|
|
84
|
+
left: '-1px',
|
|
85
|
+
},
|
|
86
|
+
'&:after': {
|
|
87
|
+
top: '0px !important',
|
|
88
|
+
position: 'absolute !important',
|
|
89
|
+
right: '-2px',
|
|
90
|
+
},
|
|
91
|
+
'&.mq-empty:after': {
|
|
92
|
+
top: '-0.45em',
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
'& .mq-overarrow.mq-arrow-right': {
|
|
96
|
+
'&:before': {
|
|
97
|
+
top: '-0.4em',
|
|
98
|
+
right: '-1px',
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
'& .mq-overarrow-inner-right': {
|
|
102
|
+
display: 'none !important',
|
|
103
|
+
},
|
|
104
|
+
'& .mq-overarrow-inner-left': {
|
|
105
|
+
display: 'none !important',
|
|
106
|
+
},
|
|
107
|
+
'& .mq-longdiv-inner': {
|
|
108
|
+
borderTop: '1px solid !important',
|
|
109
|
+
paddingTop: '1.5px !important',
|
|
110
|
+
},
|
|
111
|
+
'& .mq-parallelogram': {
|
|
112
|
+
lineHeight: 0.85,
|
|
113
|
+
},
|
|
114
|
+
'& span[data-prime="true"]': {
|
|
115
|
+
fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important',
|
|
116
|
+
},
|
|
117
|
+
...(isSelected && {
|
|
118
|
+
border: `solid 1px ${theme.palette.primary.main}`,
|
|
119
|
+
}),
|
|
120
|
+
}));
|
|
121
|
+
|
|
122
|
+
const InsideOverlay = styled('span')({
|
|
123
|
+
position: 'absolute',
|
|
124
|
+
bottom: 0,
|
|
125
|
+
left: 0,
|
|
126
|
+
right: 0,
|
|
127
|
+
top: 0,
|
|
128
|
+
});
|
|
129
|
+
|
|
13
130
|
export class RawMathPreview extends React.Component {
|
|
14
131
|
static propTypes = {
|
|
15
132
|
latex: PropTypes.string,
|
|
16
133
|
node: PropTypes.object,
|
|
17
|
-
classes: PropTypes.object,
|
|
18
134
|
isSelected: PropTypes.bool,
|
|
19
135
|
onFocus: PropTypes.func,
|
|
20
136
|
onBlur: PropTypes.func,
|
|
@@ -34,146 +150,15 @@ export class RawMathPreview extends React.Component {
|
|
|
34
150
|
render() {
|
|
35
151
|
log('[render] data: ', this.props.node.data);
|
|
36
152
|
const latex = this.props.node.data.get('latex');
|
|
37
|
-
const {
|
|
153
|
+
const { isSelected, onFocus, onBlur } = this.props;
|
|
38
154
|
return (
|
|
39
|
-
<
|
|
155
|
+
<MathPreviewContainer isSelected={isSelected}>
|
|
40
156
|
{' '}
|
|
41
|
-
<
|
|
157
|
+
<InsideOverlay />
|
|
42
158
|
<mq.Static latex={latex} onFocus={onFocus} onBlur={onBlur} />
|
|
43
|
-
</
|
|
159
|
+
</MathPreviewContainer>
|
|
44
160
|
);
|
|
45
161
|
}
|
|
46
162
|
}
|
|
47
163
|
|
|
48
|
-
|
|
49
|
-
root: {
|
|
50
|
-
display: 'inline-flex',
|
|
51
|
-
alignItems: 'center',
|
|
52
|
-
position: 'relative',
|
|
53
|
-
'& *': commonMqFontStyles,
|
|
54
|
-
...supsubStyles,
|
|
55
|
-
...longdivStyles,
|
|
56
|
-
'& > .mq-math-mode': {
|
|
57
|
-
border: 'solid 1px lightgrey',
|
|
58
|
-
},
|
|
59
|
-
'& > .mq-focused': {
|
|
60
|
-
outline: 'none',
|
|
61
|
-
boxShadow: 'none',
|
|
62
|
-
border: 'solid 1px black',
|
|
63
|
-
borderRadius: '0px',
|
|
64
|
-
},
|
|
65
|
-
'& > .mq-math-mode .mq-root-block': {
|
|
66
|
-
paddingTop: '7px !important',
|
|
67
|
-
},
|
|
68
|
-
'& > .mq-math-mode .mq-overarc ': {
|
|
69
|
-
paddingTop: '0.45em !important',
|
|
70
|
-
},
|
|
71
|
-
'& > .mq-math-mode .mq-sqrt-prefix': {
|
|
72
|
-
verticalAlign: 'baseline !important',
|
|
73
|
-
top: '1px !important',
|
|
74
|
-
left: '-0.1em !important',
|
|
75
|
-
},
|
|
76
|
-
'& > .mq-math-mode .mq-denominator': {
|
|
77
|
-
marginTop: '-5px !important',
|
|
78
|
-
padding: '0.5em 0.1em 0.1em !important',
|
|
79
|
-
},
|
|
80
|
-
'& > .mq-math-mode .mq-numerator, .mq-math-mode .mq-over': {
|
|
81
|
-
padding: '0 0.1em !important',
|
|
82
|
-
paddingBottom: '0 !important',
|
|
83
|
-
marginBottom: '-2px',
|
|
84
|
-
},
|
|
85
|
-
'& > .mq-math-mode .mq-longdiv .mq-longdiv-inner .mq-empty': {
|
|
86
|
-
paddingTop: '6px !important',
|
|
87
|
-
paddingLeft: '4px !important',
|
|
88
|
-
},
|
|
89
|
-
'& > .mq-math-mode .mq-longdiv .mq-longdiv-inner': {
|
|
90
|
-
marginLeft: '0 !important',
|
|
91
|
-
},
|
|
92
|
-
'& > .mq-math-mode .mq-overarrow': {
|
|
93
|
-
fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important',
|
|
94
|
-
},
|
|
95
|
-
'& > .mq-math-mode .mq-paren': {
|
|
96
|
-
verticalAlign: 'top !important',
|
|
97
|
-
padding: '1px 0.1em !important',
|
|
98
|
-
},
|
|
99
|
-
|
|
100
|
-
'& > .mq-math-mode .mq-sqrt-stem': {
|
|
101
|
-
borderTop: '0.07em solid',
|
|
102
|
-
marginLeft: '-1.5px',
|
|
103
|
-
marginTop: '-2px !important',
|
|
104
|
-
paddingTop: '5px !important',
|
|
105
|
-
},
|
|
106
|
-
|
|
107
|
-
'& .mq-overarrow-inner': {
|
|
108
|
-
paddingTop: '0 !important',
|
|
109
|
-
border: 'none !important',
|
|
110
|
-
},
|
|
111
|
-
'& .mq-editable-field .mq-cursor': {
|
|
112
|
-
marginTop: '-15px !important',
|
|
113
|
-
},
|
|
114
|
-
'& .mq-overarrow.mq-arrow-both': {
|
|
115
|
-
top: '7.5px',
|
|
116
|
-
marginTop: '0px',
|
|
117
|
-
minWidth: '1.23em',
|
|
118
|
-
'& *': {
|
|
119
|
-
lineHeight: '1 !important',
|
|
120
|
-
},
|
|
121
|
-
'&:before': {
|
|
122
|
-
top: '-0.4em',
|
|
123
|
-
left: '-1px',
|
|
124
|
-
},
|
|
125
|
-
// NOTE: This workaround adds `!important` to enforce the correct positioning and styling
|
|
126
|
-
// of `.mq-overarrow.mq-arrow-both` elements in MathQuill. This ensures consistent display
|
|
127
|
-
// regardless of the order in which MathQuill is initialized on our websites.
|
|
128
|
-
//
|
|
129
|
-
// In the future, investigate why MathQuill scripts and styles are being initialized
|
|
130
|
-
// more than once and address the root cause to prevent potential conflicts and ensure
|
|
131
|
-
// optimal performance.
|
|
132
|
-
'&:after': {
|
|
133
|
-
top: '0px !important',
|
|
134
|
-
position: 'absolute !important',
|
|
135
|
-
right: '-2px',
|
|
136
|
-
},
|
|
137
|
-
'&.mq-empty:after': {
|
|
138
|
-
top: '-0.45em',
|
|
139
|
-
},
|
|
140
|
-
},
|
|
141
|
-
'& .mq-overarrow.mq-arrow-right': {
|
|
142
|
-
'&:before': {
|
|
143
|
-
top: '-0.4em',
|
|
144
|
-
right: '-1px',
|
|
145
|
-
},
|
|
146
|
-
},
|
|
147
|
-
'& .mq-overarrow-inner-right': {
|
|
148
|
-
display: 'none !important',
|
|
149
|
-
},
|
|
150
|
-
'& .mq-overarrow-inner-left': {
|
|
151
|
-
display: 'none !important',
|
|
152
|
-
},
|
|
153
|
-
'& .mq-longdiv-inner': {
|
|
154
|
-
borderTop: '1px solid !important',
|
|
155
|
-
paddingTop: '1.5px !important',
|
|
156
|
-
},
|
|
157
|
-
'& .mq-parallelogram': {
|
|
158
|
-
lineHeight: 0.85,
|
|
159
|
-
},
|
|
160
|
-
'& span[data-prime="true"]': {
|
|
161
|
-
fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important',
|
|
162
|
-
},
|
|
163
|
-
},
|
|
164
|
-
selected: {
|
|
165
|
-
border: `solid 1px ${theme.palette.primary.main}`,
|
|
166
|
-
'& > .mq-math-mode': {
|
|
167
|
-
border: 'solid 0px lightgrey',
|
|
168
|
-
},
|
|
169
|
-
},
|
|
170
|
-
insideOverlay: {
|
|
171
|
-
position: 'absolute',
|
|
172
|
-
bottom: 0,
|
|
173
|
-
left: 0,
|
|
174
|
-
right: 0,
|
|
175
|
-
top: 0,
|
|
176
|
-
},
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
export default withStyles(mp)(RawMathPreview);
|
|
164
|
+
export default RawMathPreview;
|