@pie-lib/math-toolbar 2.0.0-beta.3 → 2.0.0-next.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.json +2 -847
- package/CHANGELOG.md +196 -128
- package/LICENSE.md +5 -0
- package/NEXT.CHANGELOG.json +1 -0
- package/lib/done-button.js +33 -38
- package/lib/done-button.js.map +1 -1
- package/lib/editor-and-pad.js +270 -333
- package/lib/editor-and-pad.js.map +1 -1
- package/lib/index.js +39 -43
- package/lib/index.js.map +1 -1
- package/lib/math-preview.js +164 -184
- package/lib/math-preview.js.map +1 -1
- package/lib/utils.js +17 -0
- package/lib/utils.js.map +1 -0
- package/package.json +21 -11
- package/src/__tests__/editor-and-pad.test.js +16 -0
- package/src/__tests__/index.test.js +21 -0
- package/src/__tests__/math-preview.test.js +22 -0
- package/src/done-button.jsx +27 -33
- package/src/editor-and-pad.jsx +242 -342
- package/src/index.jsx +23 -16
- package/src/math-preview.jsx +142 -183
- package/src/utils.js +11 -0
package/lib/math-preview.js
CHANGED
|
@@ -5,209 +5,189 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports["default"] = exports.RawMathPreview = void 0;
|
|
8
|
-
var
|
|
8
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
11
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
12
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
13
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
14
|
var _react = _interopRequireDefault(require("react"));
|
|
10
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
11
|
-
var _get = _interopRequireDefault(require("lodash/get"));
|
|
12
15
|
var _debug = _interopRequireDefault(require("debug"));
|
|
13
|
-
var _styles = require("@material
|
|
16
|
+
var _styles = require("@mui/material/styles");
|
|
14
17
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
15
18
|
var _mathInput = require("@pie-lib/math-input");
|
|
19
|
+
var _utils = require("./utils");
|
|
20
|
+
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2["default"])(o), (0, _possibleConstructorReturn2["default"])(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2["default"])(t).constructor) : o.apply(t, e)); }
|
|
21
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
22
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
23
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
24
|
+
var _mq$CommonMqStyles = _mathInput.mq.CommonMqStyles,
|
|
25
|
+
commonMqFontStyles = _mq$CommonMqStyles.commonMqFontStyles,
|
|
26
|
+
longdivStyles = _mq$CommonMqStyles.longdivStyles,
|
|
27
|
+
supsubStyles = _mq$CommonMqStyles.supsubStyles;
|
|
16
28
|
var log = (0, _debug["default"])('@pie-lib:math-toolbar:math-preview');
|
|
17
|
-
var
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
29
|
+
var MathPreviewContainer = (0, _styles.styled)('div')(function (_ref) {
|
|
30
|
+
var theme = _ref.theme,
|
|
31
|
+
isSelected = _ref.isSelected;
|
|
32
|
+
return _objectSpread(_objectSpread(_objectSpread({
|
|
33
|
+
display: 'inline-flex',
|
|
34
|
+
alignItems: 'center',
|
|
35
|
+
position: 'relative',
|
|
36
|
+
'& *': commonMqFontStyles
|
|
37
|
+
}, supsubStyles), longdivStyles), {}, {
|
|
38
|
+
'& > .mq-math-mode': {
|
|
39
|
+
border: isSelected ? 'solid 0px lightgrey' : 'solid 1px lightgrey'
|
|
40
|
+
},
|
|
41
|
+
'& > .mq-focused': {
|
|
42
|
+
outline: 'none',
|
|
43
|
+
boxShadow: 'none',
|
|
44
|
+
border: 'solid 1px black',
|
|
45
|
+
borderRadius: '0px'
|
|
46
|
+
},
|
|
47
|
+
'& > .mq-math-mode .mq-root-block': {
|
|
48
|
+
paddingTop: '7px !important'
|
|
49
|
+
},
|
|
50
|
+
'& > .mq-math-mode .mq-overarc ': {
|
|
51
|
+
paddingTop: '0.45em !important'
|
|
52
|
+
},
|
|
53
|
+
'& > .mq-math-mode .mq-sqrt-prefix': {
|
|
54
|
+
verticalAlign: 'baseline !important',
|
|
55
|
+
top: '1px !important',
|
|
56
|
+
left: '-0.1em !important'
|
|
57
|
+
},
|
|
58
|
+
'& > .mq-math-mode .mq-denominator': {
|
|
59
|
+
marginTop: '-5px !important',
|
|
60
|
+
padding: '0.5em 0.1em 0.1em !important'
|
|
61
|
+
},
|
|
62
|
+
'& > .mq-math-mode .mq-numerator, .mq-math-mode .mq-over': {
|
|
63
|
+
padding: '0 0.1em !important',
|
|
64
|
+
paddingBottom: '0 !important',
|
|
65
|
+
marginBottom: '-2px'
|
|
66
|
+
},
|
|
67
|
+
'& > .mq-math-mode .mq-longdiv .mq-longdiv-inner .mq-empty': {
|
|
68
|
+
paddingTop: '6px !important',
|
|
69
|
+
paddingLeft: '4px !important'
|
|
70
|
+
},
|
|
71
|
+
'& > .mq-math-mode .mq-longdiv .mq-longdiv-inner': {
|
|
72
|
+
marginLeft: '0 !important'
|
|
73
|
+
},
|
|
74
|
+
'& > .mq-math-mode .mq-overarrow': {
|
|
75
|
+
fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important'
|
|
76
|
+
},
|
|
77
|
+
'& > .mq-math-mode .mq-paren': {
|
|
78
|
+
verticalAlign: 'top !important',
|
|
79
|
+
padding: '1px 0.1em !important'
|
|
80
|
+
},
|
|
81
|
+
'& > .mq-math-mode .mq-sqrt-stem': {
|
|
82
|
+
borderTop: '0.07em solid',
|
|
83
|
+
marginLeft: '-1.5px',
|
|
84
|
+
marginTop: '-2px !important',
|
|
85
|
+
paddingTop: '5px !important'
|
|
86
|
+
},
|
|
87
|
+
'& .mq-overarrow-inner': {
|
|
88
|
+
paddingTop: '0 !important',
|
|
89
|
+
border: 'none !important'
|
|
90
|
+
},
|
|
91
|
+
'& .mq-editable-field .mq-cursor': {
|
|
92
|
+
marginTop: '-15px !important'
|
|
93
|
+
},
|
|
94
|
+
'& .mq-overarrow.mq-arrow-both': {
|
|
95
|
+
top: '7.5px',
|
|
96
|
+
marginTop: '0px',
|
|
97
|
+
minWidth: '1.23em',
|
|
23
98
|
'& *': {
|
|
24
|
-
|
|
25
|
-
'-webkit-font-smoothing': 'antialiased !important'
|
|
26
|
-
},
|
|
27
|
-
'& > .mq-math-mode > span > var': {
|
|
28
|
-
fontFamily: 'MJXZERO, MJXTEX-I !important'
|
|
29
|
-
},
|
|
30
|
-
'& > .mq-math-mode span var': {
|
|
31
|
-
fontFamily: 'MJXZERO, MJXTEX-I !important'
|
|
32
|
-
},
|
|
33
|
-
'& > .mq-math-mode .mq-nonSymbola': {
|
|
34
|
-
fontFamily: 'MJXZERO, MJXTEX-I !important'
|
|
35
|
-
},
|
|
36
|
-
'& > .mq-math-mode > span > var.mq-operator-name': {
|
|
37
|
-
fontFamily: 'MJXZERO, MJXTEX !important'
|
|
38
|
-
},
|
|
39
|
-
'& > .mq-math-mode': {
|
|
40
|
-
border: 'solid 1px lightgrey'
|
|
41
|
-
},
|
|
42
|
-
'& > .mq-focused': {
|
|
43
|
-
outline: 'none',
|
|
44
|
-
boxShadow: 'none',
|
|
45
|
-
border: 'solid 1px black',
|
|
46
|
-
borderRadius: '0px'
|
|
47
|
-
},
|
|
48
|
-
'& > .mq-math-mode .mq-root-block': {
|
|
49
|
-
paddingTop: '7px !important'
|
|
50
|
-
},
|
|
51
|
-
'& > .mq-math-mode .mq-overarc ': {
|
|
52
|
-
paddingTop: '0.45em !important'
|
|
53
|
-
},
|
|
54
|
-
'& > .mq-math-mode .mq-sqrt-prefix': {
|
|
55
|
-
verticalAlign: 'baseline !important',
|
|
56
|
-
top: '1px !important',
|
|
57
|
-
left: '-0.1em !important'
|
|
58
|
-
},
|
|
59
|
-
'& > .mq-math-mode .mq-denominator': {
|
|
60
|
-
marginTop: '-5px !important',
|
|
61
|
-
padding: '0.5em 0.1em 0.1em !important'
|
|
62
|
-
},
|
|
63
|
-
'& > .mq-math-mode .mq-numerator, .mq-math-mode .mq-over': {
|
|
64
|
-
padding: '0 0.1em !important',
|
|
65
|
-
paddingBottom: '0 !important',
|
|
66
|
-
marginBottom: '-2px'
|
|
99
|
+
lineHeight: '1 !important'
|
|
67
100
|
},
|
|
68
|
-
'
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
paddingRight: '0.15em'
|
|
101
|
+
'&:before': {
|
|
102
|
+
top: '-0.4em',
|
|
103
|
+
left: '-1px'
|
|
72
104
|
},
|
|
73
|
-
'
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
'
|
|
77
|
-
padding: '0 !important',
|
|
78
|
-
marginLeft: '0px !important',
|
|
79
|
-
marginTop: '2px'
|
|
80
|
-
}
|
|
105
|
+
'&:after': {
|
|
106
|
+
top: '0px !important',
|
|
107
|
+
position: 'absolute !important',
|
|
108
|
+
right: '-2px'
|
|
81
109
|
},
|
|
82
|
-
'
|
|
83
|
-
|
|
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-supsub': {
|
|
93
|
-
fontSize: '70.7% !important'
|
|
94
|
-
},
|
|
95
|
-
'& > .mq-math-mode .mq-overarrow': {
|
|
96
|
-
fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important'
|
|
97
|
-
},
|
|
98
|
-
'& > .mq-math-mode .mq-paren': {
|
|
99
|
-
verticalAlign: 'top !important',
|
|
100
|
-
padding: '1px 0.1em !important'
|
|
101
|
-
},
|
|
102
|
-
'& > .mq-math-mode .mq-sqrt-stem': {
|
|
103
|
-
borderTop: '0.07em solid',
|
|
104
|
-
marginLeft: '-1.5px',
|
|
105
|
-
marginTop: '-2px !important',
|
|
106
|
-
paddingTop: '5px !important'
|
|
107
|
-
},
|
|
108
|
-
'& > .mq-supsub ': {
|
|
109
|
-
fontSize: '70.7%'
|
|
110
|
-
},
|
|
111
|
-
'& > .mq-math-mode .mq-supsub.mq-sup-only': {
|
|
112
|
-
verticalAlign: '-0.1em !important',
|
|
113
|
-
'& .mq-sup': {
|
|
114
|
-
marginBottom: '0px !important'
|
|
115
|
-
}
|
|
116
|
-
},
|
|
117
|
-
'& .mq-overarrow-inner': {
|
|
118
|
-
paddingTop: '0 !important',
|
|
119
|
-
border: 'none !important'
|
|
120
|
-
},
|
|
121
|
-
'& .mq-editable-field .mq-cursor': {
|
|
122
|
-
marginTop: '-15px !important'
|
|
123
|
-
},
|
|
124
|
-
'& .mq-overarrow.mq-arrow-both': {
|
|
125
|
-
top: '7.5px',
|
|
126
|
-
marginTop: '0px',
|
|
127
|
-
minWidth: '1.23em',
|
|
128
|
-
'& *': {
|
|
129
|
-
lineHeight: '1 !important'
|
|
130
|
-
},
|
|
131
|
-
'&:before': {
|
|
132
|
-
top: '-0.4em',
|
|
133
|
-
left: '-1px'
|
|
134
|
-
},
|
|
135
|
-
'&:after': {
|
|
136
|
-
top: '0px !important',
|
|
137
|
-
position: 'absolute',
|
|
138
|
-
right: '-2px'
|
|
139
|
-
},
|
|
140
|
-
'&.mq-empty:after': {
|
|
141
|
-
top: '-0.45em'
|
|
142
|
-
}
|
|
143
|
-
},
|
|
144
|
-
'& .mq-overarrow.mq-arrow-right': {
|
|
145
|
-
'&:before': {
|
|
146
|
-
top: '-0.4em',
|
|
147
|
-
right: '-1px'
|
|
148
|
-
}
|
|
149
|
-
},
|
|
150
|
-
'& .mq-overarrow-inner-right': {
|
|
151
|
-
display: 'none !important'
|
|
152
|
-
},
|
|
153
|
-
'& .mq-overarrow-inner-left': {
|
|
154
|
-
display: 'none !important'
|
|
155
|
-
},
|
|
156
|
-
'& .mq-longdiv-inner': {
|
|
157
|
-
borderTop: '1px solid !important',
|
|
158
|
-
paddingTop: '1.5px !important'
|
|
159
|
-
},
|
|
160
|
-
'& .mq-parallelogram': {
|
|
161
|
-
lineHeight: 0.85
|
|
110
|
+
'&.mq-empty:after': {
|
|
111
|
+
top: '-0.45em'
|
|
162
112
|
}
|
|
163
113
|
},
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
114
|
+
'& .mq-overarrow.mq-arrow-right': {
|
|
115
|
+
'&:before': {
|
|
116
|
+
top: '-0.4em',
|
|
117
|
+
right: '-1px'
|
|
168
118
|
}
|
|
169
119
|
},
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
120
|
+
'& .mq-overarrow-inner-right': {
|
|
121
|
+
display: 'none !important'
|
|
122
|
+
},
|
|
123
|
+
'& .mq-overarrow-inner-left': {
|
|
124
|
+
display: 'none !important'
|
|
125
|
+
},
|
|
126
|
+
'& .mq-longdiv-inner': {
|
|
127
|
+
borderTop: '1px solid !important',
|
|
128
|
+
paddingTop: '1.5px !important'
|
|
129
|
+
},
|
|
130
|
+
'& .mq-parallelogram': {
|
|
131
|
+
lineHeight: 0.85
|
|
132
|
+
},
|
|
133
|
+
'& span[data-prime="true"]': {
|
|
134
|
+
fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important'
|
|
176
135
|
}
|
|
177
|
-
}
|
|
136
|
+
}, isSelected && {
|
|
137
|
+
border: "solid 1px ".concat(theme.palette.primary.main)
|
|
138
|
+
});
|
|
178
139
|
});
|
|
179
|
-
var
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
attributes = props.attributes,
|
|
186
|
-
children = props.children;
|
|
187
|
-
var classes = useStyles(props);
|
|
188
|
-
return /*#__PURE__*/_react["default"].createElement("div", (0, _extends2["default"])({
|
|
189
|
-
className: (0, _classnames["default"])(classes.root, isSelected && classes.selected)
|
|
190
|
-
}, attributes, {
|
|
191
|
-
contentEditable: false,
|
|
192
|
-
ref: ref
|
|
193
|
-
}), children, " ", /*#__PURE__*/_react["default"].createElement("span", {
|
|
194
|
-
className: classes.insideOverlay
|
|
195
|
-
}), /*#__PURE__*/_react["default"].createElement(_mathInput.mq.Static, {
|
|
196
|
-
latex: latex,
|
|
197
|
-
onFocus: onFocus,
|
|
198
|
-
onBlur: onBlur
|
|
199
|
-
}));
|
|
140
|
+
var InsideOverlay = (0, _styles.styled)('span')({
|
|
141
|
+
position: 'absolute',
|
|
142
|
+
bottom: 0,
|
|
143
|
+
left: 0,
|
|
144
|
+
right: 0,
|
|
145
|
+
top: 0
|
|
200
146
|
});
|
|
201
|
-
exports.RawMathPreview =
|
|
202
|
-
RawMathPreview
|
|
203
|
-
|
|
147
|
+
var RawMathPreview = exports.RawMathPreview = /*#__PURE__*/function (_React$Component) {
|
|
148
|
+
function RawMathPreview() {
|
|
149
|
+
(0, _classCallCheck2["default"])(this, RawMathPreview);
|
|
150
|
+
return _callSuper(this, RawMathPreview, arguments);
|
|
151
|
+
}
|
|
152
|
+
(0, _inherits2["default"])(RawMathPreview, _React$Component);
|
|
153
|
+
return (0, _createClass2["default"])(RawMathPreview, [{
|
|
154
|
+
key: "componentDidMount",
|
|
155
|
+
value: function componentDidMount() {
|
|
156
|
+
(0, _utils.markFractionBaseSuperscripts)();
|
|
157
|
+
}
|
|
158
|
+
}, {
|
|
159
|
+
key: "componentDidUpdate",
|
|
160
|
+
value: function componentDidUpdate(prevProps) {
|
|
161
|
+
// Re-run only if LaTeX changed
|
|
162
|
+
if (this.props.node.data.get('latex') !== prevProps.node.data.get('latex')) {
|
|
163
|
+
(0, _utils.markFractionBaseSuperscripts)();
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}, {
|
|
167
|
+
key: "render",
|
|
168
|
+
value: function render() {
|
|
169
|
+
log('[render] data: ', this.props.node.data);
|
|
170
|
+
var latex = this.props.node.data.get('latex');
|
|
171
|
+
var _this$props = this.props,
|
|
172
|
+
isSelected = _this$props.isSelected,
|
|
173
|
+
onFocus = _this$props.onFocus,
|
|
174
|
+
onBlur = _this$props.onBlur;
|
|
175
|
+
return /*#__PURE__*/_react["default"].createElement(MathPreviewContainer, {
|
|
176
|
+
isSelected: isSelected
|
|
177
|
+
}, ' ', /*#__PURE__*/_react["default"].createElement(InsideOverlay, null), /*#__PURE__*/_react["default"].createElement(_mathInput.mq.Static, {
|
|
178
|
+
latex: latex,
|
|
179
|
+
onFocus: onFocus,
|
|
180
|
+
onBlur: onBlur
|
|
181
|
+
}));
|
|
182
|
+
}
|
|
183
|
+
}]);
|
|
184
|
+
}(_react["default"].Component);
|
|
185
|
+
(0, _defineProperty2["default"])(RawMathPreview, "propTypes", {
|
|
204
186
|
latex: _propTypes["default"].string,
|
|
205
187
|
node: _propTypes["default"].object,
|
|
206
|
-
classes: _propTypes["default"].object,
|
|
207
188
|
isSelected: _propTypes["default"].bool,
|
|
208
189
|
onFocus: _propTypes["default"].func,
|
|
209
190
|
onBlur: _propTypes["default"].func
|
|
210
|
-
};
|
|
211
|
-
var _default = RawMathPreview;
|
|
212
|
-
exports["default"] = _default;
|
|
191
|
+
});
|
|
192
|
+
var _default = exports["default"] = RawMathPreview;
|
|
213
193
|
//# sourceMappingURL=math-preview.js.map
|
package/lib/math-preview.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"math-preview.js","names":["_react","_interopRequireDefault","require","_classnames","_get","_debug","_styles","_propTypes","_mathInput","log","debug","useStyles","makeStyles","theme","root","display","alignItems","position","fontFamily","border","outline","boxShadow","borderRadius","paddingTop","verticalAlign","top","left","marginTop","padding","paddingBottom","marginBottom","fontSize","paddingRight","marginLeft","paddingLeft","borderTop","minWidth","lineHeight","right","selected","concat","get","insideOverlay","bottom","RawMathPreview","React","forwardRef","props","ref","element","data","latex","isSelected","onFocus","onBlur","attributes","children","classes","createElement","_extends2","className","classNames","contentEditable","mq","Static","exports","propTypes","PropTypes","object","string","node","bool","func","_default"],"sources":["../src/math-preview.jsx"],"sourcesContent":["import React from 'react';\nimport classNames from 'classnames';\nimport get from 'lodash/get';\nimport debug from 'debug';\nimport { makeStyles } from '@material-ui/styles';\nimport PropTypes from 'prop-types';\nimport { mq } from '@pie-lib/math-input';\n\nconst log = debug('@pie-lib:math-toolbar:math-preview');\n\nconst useStyles = makeStyles((theme) => ({\n root: {\n display: 'inline-flex',\n alignItems: 'center',\n position: 'relative',\n '& *': {\n fontFamily: 'MJXZERO, MJXTEX !important',\n '-webkit-font-smoothing': 'antialiased !important',\n },\n '& > .mq-math-mode > span > var': {\n fontFamily: 'MJXZERO, MJXTEX-I !important',\n },\n '& > .mq-math-mode span var': {\n fontFamily: 'MJXZERO, MJXTEX-I !important',\n },\n '& > .mq-math-mode .mq-nonSymbola': {\n fontFamily: 'MJXZERO, MJXTEX-I !important',\n },\n '& > .mq-math-mode > span > var.mq-operator-name': {\n fontFamily: 'MJXZERO, MJXTEX !important',\n },\n '& > .mq-math-mode': {\n border: 'solid 1px lightgrey',\n },\n '& > .mq-focused': {\n outline: 'none',\n boxShadow: 'none',\n border: 'solid 1px black',\n borderRadius: '0px',\n },\n '& > .mq-math-mode .mq-root-block': {\n paddingTop: '7px !important',\n },\n '& > .mq-math-mode .mq-overarc ': {\n paddingTop: '0.45em !important',\n },\n '& > .mq-math-mode .mq-sqrt-prefix': {\n verticalAlign: 'baseline !important',\n top: '1px !important',\n left: '-0.1em !important',\n },\n '& > .mq-math-mode .mq-denominator': {\n marginTop: '-5px !important',\n padding: '0.5em 0.1em 0.1em !important',\n },\n '& > .mq-math-mode .mq-numerator, .mq-math-mode .mq-over': {\n padding: '0 0.1em !important',\n paddingBottom: '0 !important',\n marginBottom: '-2px',\n },\n '& > .mq-math-mode sup.mq-nthroot': {\n fontSize: '70.7% !important',\n verticalAlign: '0.5em !important',\n paddingRight: '0.15em',\n },\n '& > .mq-longdiv-inner': {\n marginTop: '-1px',\n marginLeft: '5px !important;',\n\n '& > .mq-empty': {\n padding: '0 !important',\n marginLeft: '0px !important',\n marginTop: '2px',\n },\n },\n '& > .mq-math-mode .mq-longdiv': {\n display: 'inline-flex !important',\n },\n '& > .mq-math-mode .mq-longdiv .mq-longdiv-inner .mq-empty': {\n paddingTop: '6px !important',\n paddingLeft: '4px !important',\n },\n '& > .mq-math-mode .mq-longdiv .mq-longdiv-inner': {\n marginLeft: '0 !important',\n },\n '& > .mq-math-mode .mq-supsub': {\n fontSize: '70.7% !important',\n },\n '& > .mq-math-mode .mq-overarrow': {\n fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important',\n },\n '& > .mq-math-mode .mq-paren': {\n verticalAlign: 'top !important',\n padding: '1px 0.1em !important',\n },\n\n '& > .mq-math-mode .mq-sqrt-stem': {\n borderTop: '0.07em solid',\n marginLeft: '-1.5px',\n marginTop: '-2px !important',\n paddingTop: '5px !important',\n },\n '& > .mq-supsub ': {\n fontSize: '70.7%',\n },\n\n '& > .mq-math-mode .mq-supsub.mq-sup-only': {\n verticalAlign: '-0.1em !important',\n\n '& .mq-sup': {\n marginBottom: '0px !important',\n },\n },\n '& .mq-overarrow-inner': {\n paddingTop: '0 !important',\n border: 'none !important',\n },\n '& .mq-editable-field .mq-cursor': {\n marginTop: '-15px !important',\n },\n '& .mq-overarrow.mq-arrow-both': {\n top: '7.5px',\n marginTop: '0px',\n minWidth: '1.23em',\n '& *': {\n lineHeight: '1 !important',\n },\n '&:before': {\n top: '-0.4em',\n left: '-1px',\n },\n '&:after': {\n top: '0px !important',\n position: 'absolute',\n right: '-2px',\n },\n '&.mq-empty:after': {\n top: '-0.45em',\n },\n },\n '& .mq-overarrow.mq-arrow-right': {\n '&:before': {\n top: '-0.4em',\n right: '-1px',\n },\n },\n '& .mq-overarrow-inner-right': {\n display: 'none !important',\n },\n '& .mq-overarrow-inner-left': {\n display: 'none !important',\n },\n '& .mq-longdiv-inner': {\n borderTop: '1px solid !important',\n paddingTop: '1.5px !important',\n },\n '& .mq-parallelogram': {\n lineHeight: 0.85,\n },\n },\n selected: {\n border: `solid 1px ${get(theme, 'palette.primary.main')}`,\n '& > .mq-math-mode': {\n border: 'solid 0px lightgrey',\n },\n },\n insideOverlay: {\n position: 'absolute',\n bottom: 0,\n left: 0,\n right: 0,\n top: 0,\n },\n}));\n\nexport const RawMathPreview = React.forwardRef((props, ref) => {\n log('[render] data: ', props.element.data);\n const latex = props.element.data.latex;\n const { isSelected, onFocus, onBlur, attributes, children } = props;\n const classes = useStyles(props);\n\n return (\n <div\n className={classNames(classes.root, isSelected && classes.selected)}\n {...attributes}\n contentEditable={false}\n ref={ref}\n >\n {children} <span className={classes.insideOverlay} />\n <mq.Static latex={latex} onFocus={onFocus} onBlur={onBlur} />\n </div>\n );\n});\n\nRawMathPreview.propTypes = {\n element: PropTypes.object,\n latex: PropTypes.string,\n node: PropTypes.object,\n classes: PropTypes.object,\n isSelected: PropTypes.bool,\n onFocus: PropTypes.func,\n onBlur: PropTypes.func,\n};\n\nexport default RawMathPreview;\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,WAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,IAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,MAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,UAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,UAAA,GAAAN,OAAA;AAEA,IAAMO,GAAG,GAAG,IAAAC,iBAAK,EAAC,oCAAoC,CAAC;AAEvD,IAAMC,SAAS,GAAG,IAAAC,kBAAU,EAAC,UAACC,KAAK;EAAA,OAAM;IACvCC,IAAI,EAAE;MACJC,OAAO,EAAE,aAAa;MACtBC,UAAU,EAAE,QAAQ;MACpBC,QAAQ,EAAE,UAAU;MACpB,KAAK,EAAE;QACLC,UAAU,EAAE,4BAA4B;QACxC,wBAAwB,EAAE;MAC5B,CAAC;MACD,gCAAgC,EAAE;QAChCA,UAAU,EAAE;MACd,CAAC;MACD,4BAA4B,EAAE;QAC5BA,UAAU,EAAE;MACd,CAAC;MACD,kCAAkC,EAAE;QAClCA,UAAU,EAAE;MACd,CAAC;MACD,iDAAiD,EAAE;QACjDA,UAAU,EAAE;MACd,CAAC;MACD,mBAAmB,EAAE;QACnBC,MAAM,EAAE;MACV,CAAC;MACD,iBAAiB,EAAE;QACjBC,OAAO,EAAE,MAAM;QACfC,SAAS,EAAE,MAAM;QACjBF,MAAM,EAAE,iBAAiB;QACzBG,YAAY,EAAE;MAChB,CAAC;MACD,kCAAkC,EAAE;QAClCC,UAAU,EAAE;MACd,CAAC;MACD,gCAAgC,EAAE;QAChCA,UAAU,EAAE;MACd,CAAC;MACD,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qBAAS,CAACK,IAAI;EACvBlB,MAAM,EAAEa,qBAAS,CAACK;AACpB,CAAC;AAAC,IAAAC,QAAA,GAEa7B,cAAc;AAAAqB,OAAA,cAAAQ,QAAA"}
|
|
1
|
+
{"version":3,"file":"math-preview.js","names":["_react","_interopRequireDefault","require","_debug","_styles","_propTypes","_mathInput","_utils","_callSuper","t","o","e","_getPrototypeOf2","_possibleConstructorReturn2","_isNativeReflectConstruct","Reflect","construct","constructor","apply","Boolean","prototype","valueOf","call","ownKeys","r","Object","keys","getOwnPropertySymbols","filter","getOwnPropertyDescriptor","enumerable","push","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","_mq$CommonMqStyles","mq","CommonMqStyles","commonMqFontStyles","longdivStyles","supsubStyles","log","debug","MathPreviewContainer","styled","_ref","theme","isSelected","display","alignItems","position","border","outline","boxShadow","borderRadius","paddingTop","verticalAlign","top","left","marginTop","padding","paddingBottom","marginBottom","paddingLeft","marginLeft","fontFamily","borderTop","minWidth","lineHeight","right","concat","palette","primary","main","InsideOverlay","bottom","RawMathPreview","exports","_React$Component","_classCallCheck2","_inherits2","_createClass2","key","value","componentDidMount","markFractionBaseSuperscripts","componentDidUpdate","prevProps","props","node","data","get","render","latex","_this$props","onFocus","onBlur","createElement","Static","React","Component","PropTypes","string","object","bool","func","_default"],"sources":["../src/math-preview.jsx"],"sourcesContent":["import React from 'react';\nimport debug from 'debug';\nimport { styled } from '@mui/material/styles';\nimport PropTypes from 'prop-types';\nimport { mq } from '@pie-lib/math-input';\nimport { markFractionBaseSuperscripts } from './utils';\n\nconst { commonMqFontStyles, longdivStyles, supsubStyles } = mq.CommonMqStyles;\n\nconst log = debug('@pie-lib:math-toolbar:math-preview');\n\nconst MathPreviewContainer = styled('div')(({ theme, isSelected }) => ({\n display: 'inline-flex',\n alignItems: 'center',\n position: 'relative',\n '& *': commonMqFontStyles,\n ...supsubStyles,\n ...longdivStyles,\n '& > .mq-math-mode': {\n border: isSelected ? 'solid 0px lightgrey' : 'solid 1px lightgrey',\n },\n '& > .mq-focused': {\n outline: 'none',\n boxShadow: 'none',\n border: 'solid 1px black',\n borderRadius: '0px',\n },\n '& > .mq-math-mode .mq-root-block': {\n paddingTop: '7px !important',\n },\n '& > .mq-math-mode .mq-overarc ': {\n paddingTop: '0.45em !important',\n },\n '& > .mq-math-mode .mq-sqrt-prefix': {\n verticalAlign: 'baseline !important',\n top: '1px !important',\n left: '-0.1em !important',\n },\n '& > .mq-math-mode .mq-denominator': {\n marginTop: '-5px !important',\n padding: '0.5em 0.1em 0.1em !important',\n },\n '& > .mq-math-mode .mq-numerator, .mq-math-mode .mq-over': {\n padding: '0 0.1em !important',\n paddingBottom: '0 !important',\n marginBottom: '-2px',\n },\n '& > .mq-math-mode .mq-longdiv .mq-longdiv-inner .mq-empty': {\n paddingTop: '6px !important',\n paddingLeft: '4px !important',\n },\n '& > .mq-math-mode .mq-longdiv .mq-longdiv-inner': {\n marginLeft: '0 !important',\n },\n '& > .mq-math-mode .mq-overarrow': {\n fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important',\n },\n '& > .mq-math-mode .mq-paren': {\n verticalAlign: 'top !important',\n padding: '1px 0.1em !important',\n },\n '& > .mq-math-mode .mq-sqrt-stem': {\n borderTop: '0.07em solid',\n marginLeft: '-1.5px',\n marginTop: '-2px !important',\n paddingTop: '5px !important',\n },\n '& .mq-overarrow-inner': {\n paddingTop: '0 !important',\n border: 'none !important',\n },\n '& .mq-editable-field .mq-cursor': {\n marginTop: '-15px !important',\n },\n '& .mq-overarrow.mq-arrow-both': {\n top: '7.5px',\n marginTop: '0px',\n minWidth: '1.23em',\n '& *': {\n lineHeight: '1 !important',\n },\n '&:before': {\n top: '-0.4em',\n left: '-1px',\n },\n '&:after': {\n top: '0px !important',\n position: 'absolute !important',\n right: '-2px',\n },\n '&.mq-empty:after': {\n top: '-0.45em',\n },\n },\n '& .mq-overarrow.mq-arrow-right': {\n '&:before': {\n top: '-0.4em',\n right: '-1px',\n },\n },\n '& .mq-overarrow-inner-right': {\n display: 'none !important',\n },\n '& .mq-overarrow-inner-left': {\n display: 'none !important',\n },\n '& .mq-longdiv-inner': {\n borderTop: '1px solid !important',\n paddingTop: '1.5px !important',\n },\n '& .mq-parallelogram': {\n lineHeight: 0.85,\n },\n '& span[data-prime=\"true\"]': {\n fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important',\n },\n ...(isSelected && {\n border: `solid 1px ${theme.palette.primary.main}`,\n }),\n}));\n\nconst InsideOverlay = styled('span')({\n position: 'absolute',\n bottom: 0,\n left: 0,\n right: 0,\n top: 0,\n});\n\nexport class RawMathPreview extends React.Component {\n static propTypes = {\n latex: PropTypes.string,\n node: PropTypes.object,\n isSelected: PropTypes.bool,\n onFocus: PropTypes.func,\n onBlur: PropTypes.func,\n };\n\n componentDidMount() {\n markFractionBaseSuperscripts();\n }\n\n componentDidUpdate(prevProps) {\n // Re-run only if LaTeX changed\n if (this.props.node.data.get('latex') !== prevProps.node.data.get('latex')) {\n markFractionBaseSuperscripts();\n }\n }\n\n render() {\n log('[render] data: ', this.props.node.data);\n const latex = this.props.node.data.get('latex');\n const { isSelected, onFocus, onBlur } = this.props;\n return (\n <MathPreviewContainer isSelected={isSelected}>\n {' '}\n <InsideOverlay />\n <mq.Static latex={latex} onFocus={onFocus} onBlur={onBlur} />\n </MathPreviewContainer>\n );\n }\n}\n\nexport default RawMathPreview;\n"],"mappings":";;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAAuD,SAAAM,WAAAC,CAAA,EAAAC,CAAA,EAAAC,CAAA,WAAAD,CAAA,OAAAE,gBAAA,aA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AAK,CAACC,IAAI,CAACC,IAAI,CAAC;MAC5C,IAAMG,KAAK,GAAG,IAAI,CAACL,KAAK,CAACC,IAAI,CAACC,IAAI,CAACC,GAAG,CAAC,OAAO,CAAC;MAC/C,IAAAG,WAAA,GAAwC,IAAI,CAACN,KAAK;QAA1CzC,UAAU,GAAA+C,WAAA,CAAV/C,UAAU;QAAEgD,OAAO,GAAAD,WAAA,CAAPC,OAAO;QAAEC,MAAM,GAAAF,WAAA,CAANE,MAAM;MACnC,oBACErG,MAAA,YAAAsG,aAAA,CAACtD,oBAAoB;QAACI,UAAU,EAAEA;MAAW,GAC1C,GAAG,eACJpD,MAAA,YAAAsG,aAAA,CAACvB,aAAa,MAAE,CAAC,eACjB/E,MAAA,YAAAsG,aAAA,CAAChG,UAAA,CAAAmC,EAAE,CAAC8D,MAAM;QAACL,KAAK,EAAEA,KAAM;QAACE,OAAO,EAAEA,OAAQ;QAACC,MAAM,EAAEA;MAAO,CAAE,CACxC,CAAC;IAE3B;EAAC;AAAA,EA/BiCG,iBAAK,CAACC,SAAS;AAAA,IAAArE,gBAAA,aAAtC6C,cAAc,eACN;EACjBiB,KAAK,EAAEQ,qBAAS,CAACC,MAAM;EACvBb,IAAI,EAAEY,qBAAS,CAACE,MAAM;EACtBxD,UAAU,EAAEsD,qBAAS,CAACG,IAAI;EAC1BT,OAAO,EAAEM,qBAAS,CAACI,IAAI;EACvBT,MAAM,EAAEK,qBAAS,CAACI;AACpB,CAAC;AAAA,IAAAC,QAAA,GAAA7B,OAAA,cA2BYD,cAAc","ignoreList":[]}
|
package/lib/utils.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.markFractionBaseSuperscripts = void 0;
|
|
7
|
+
var markFractionBaseSuperscripts = exports.markFractionBaseSuperscripts = function markFractionBaseSuperscripts() {
|
|
8
|
+
document.querySelectorAll('.mq-supsub.mq-sup-only').forEach(function (supsub) {
|
|
9
|
+
var prev = supsub.previousElementSibling;
|
|
10
|
+
if (prev && prev.classList.contains('mq-non-leaf') && prev.querySelector('.mq-fraction')) {
|
|
11
|
+
supsub.classList.add('mq-after-fraction-group');
|
|
12
|
+
} else {
|
|
13
|
+
supsub.classList.remove('mq-after-fraction-group');
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=utils.js.map
|
package/lib/utils.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","names":["markFractionBaseSuperscripts","exports","document","querySelectorAll","forEach","supsub","prev","previousElementSibling","classList","contains","querySelector","add","remove"],"sources":["../src/utils.js"],"sourcesContent":["export const markFractionBaseSuperscripts = () => {\n document.querySelectorAll('.mq-supsub.mq-sup-only').forEach((supsub) => {\n const prev = supsub.previousElementSibling;\n\n if (prev && prev.classList.contains('mq-non-leaf') && prev.querySelector('.mq-fraction')) {\n supsub.classList.add('mq-after-fraction-group');\n } else {\n supsub.classList.remove('mq-after-fraction-group');\n }\n });\n};\n"],"mappings":";;;;;;AAAO,IAAMA,4BAA4B,GAAAC,OAAA,CAAAD,4BAAA,GAAG,SAA/BA,4BAA4BA,CAAA,EAAS;EAChDE,QAAQ,CAACC,gBAAgB,CAAC,wBAAwB,CAAC,CAACC,OAAO,CAAC,UAACC,MAAM,EAAK;IACtE,IAAMC,IAAI,GAAGD,MAAM,CAACE,sBAAsB;IAE1C,IAAID,IAAI,IAAIA,IAAI,CAACE,SAAS,CAACC,QAAQ,CAAC,aAAa,CAAC,IAAIH,IAAI,CAACI,aAAa,CAAC,cAAc,CAAC,EAAE;MACxFL,MAAM,CAACG,SAAS,CAACG,GAAG,CAAC,yBAAyB,CAAC;IACjD,CAAC,MAAM;MACLN,MAAM,CAACG,SAAS,CAACI,MAAM,CAAC,yBAAyB,CAAC;IACpD;EACF,CAAC,CAAC;AACJ,CAAC","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "2.0.0-
|
|
6
|
+
"version": "2.0.0-next.0",
|
|
7
7
|
"description": "Math toolbar for editing math equations",
|
|
8
8
|
"keywords": [
|
|
9
9
|
"math",
|
|
@@ -17,21 +17,31 @@
|
|
|
17
17
|
"author": "",
|
|
18
18
|
"license": "ISC",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@
|
|
21
|
-
"@
|
|
22
|
-
"@
|
|
23
|
-
"
|
|
20
|
+
"@emotion/react": "^11.14.0",
|
|
21
|
+
"@emotion/style": "^0.8.0",
|
|
22
|
+
"@mui/icons-material": "^7.3.4",
|
|
23
|
+
"@mui/material": "^7.3.4",
|
|
24
|
+
"@pie-lib/math-input": "6.31.2-next.16",
|
|
25
|
+
"@pie-lib/render-ui": "4.35.3-next.15",
|
|
24
26
|
"debug": "^4.1.1",
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
+
"lodash": "^4.17.11",
|
|
28
|
+
"prop-types": "^15.7.2"
|
|
27
29
|
},
|
|
28
30
|
"peerDependencies": {
|
|
29
|
-
"react": "^
|
|
30
|
-
"react-dom": "^
|
|
31
|
+
"react": "^18.2.0",
|
|
32
|
+
"react-dom": "^18.2.0"
|
|
31
33
|
},
|
|
32
34
|
"devDependencies": {
|
|
33
|
-
"@pie-lib/test-utils": "
|
|
35
|
+
"@pie-lib/test-utils": "0.22.2-next.16"
|
|
34
36
|
},
|
|
35
37
|
"scripts": {},
|
|
36
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "f104bab3116a65a39c55efc48387d8701c0c1d84",
|
|
39
|
+
"exports": {
|
|
40
|
+
".": {
|
|
41
|
+
"require": "./lib/index.js",
|
|
42
|
+
"import": "./src/index.jsx",
|
|
43
|
+
"default": "./lib/index.js"
|
|
44
|
+
},
|
|
45
|
+
"./esm": "./esm/index.js"
|
|
46
|
+
}
|
|
37
47
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { EditorAndPad } from '../editor-and-pad';
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
|
|
5
|
+
describe('EditorAndPad', () => {
|
|
6
|
+
const defaultProps = {
|
|
7
|
+
classes: {},
|
|
8
|
+
classNames: {},
|
|
9
|
+
onBlur: jest.fn(),
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
it('renders with default props', () => {
|
|
13
|
+
const { container } = render(<EditorAndPad {...defaultProps} />);
|
|
14
|
+
expect(container.firstChild).toBeInTheDocument();
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { RawPureToolbar } from '../index';
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
|
|
5
|
+
describe('RawPureToolbar', () => {
|
|
6
|
+
const defaultProps = {
|
|
7
|
+
classes: {},
|
|
8
|
+
controlledKeypad: true,
|
|
9
|
+
showKeypad: true,
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
it('renders with DONE button if hideDoneButton is not defined', () => {
|
|
13
|
+
const { container } = render(<RawPureToolbar {...defaultProps} />);
|
|
14
|
+
expect(container.firstChild).toBeInTheDocument();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('renders without DONE button if hideDoneButton value is true', () => {
|
|
18
|
+
const { container } = render(<RawPureToolbar {...defaultProps} hideDoneButton={true} />);
|
|
19
|
+
expect(container.firstChild).toBeInTheDocument();
|
|
20
|
+
});
|
|
21
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
import MathPreview from '../math-preview';
|
|
4
|
+
|
|
5
|
+
describe('MathPreview', () => {
|
|
6
|
+
const defaultProps = {
|
|
7
|
+
node: {
|
|
8
|
+
data: {
|
|
9
|
+
get: jest.fn().mockReturnValue('sqrt(5)'),
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
classes: {},
|
|
13
|
+
isSelected: false,
|
|
14
|
+
onFocus: jest.fn(),
|
|
15
|
+
onBlur: jest.fn(),
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
it('renders with default props', () => {
|
|
19
|
+
const { container } = render(<MathPreview {...defaultProps} />);
|
|
20
|
+
expect(container.firstChild).toBeInTheDocument();
|
|
21
|
+
});
|
|
22
|
+
});
|
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;
|