@zzish/math-rich-input 0.1.39 → 0.1.40
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/dist/index.js +14 -2
- package/dist/math-rich-input.css +130 -130
- package/package.json +1 -1
- package/src/MathRichInput.jsx +14 -1
package/dist/index.js
CHANGED
|
@@ -22718,7 +22718,7 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
|
|
|
22718
22718
|
_defineProperty(_assertThisInitialized(_this2), "handleInput", function (event) {
|
|
22719
22719
|
try {
|
|
22720
22720
|
// console.log("handleInput")
|
|
22721
|
-
if (
|
|
22721
|
+
if (_this2.isComposing) return;
|
|
22722
22722
|
var raw_text = elementToMarkedRawText(_this2.editableDiv, null, 0, _this2.enableHtml());
|
|
22723
22723
|
|
|
22724
22724
|
var params = _this2._getRangeParams();
|
|
@@ -23547,6 +23547,14 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
|
|
|
23547
23547
|
}
|
|
23548
23548
|
});
|
|
23549
23549
|
|
|
23550
|
+
_defineProperty(_assertThisInitialized(_this2), "handleCompositionStart", function (event) {
|
|
23551
|
+
_this2.isComposing = true;
|
|
23552
|
+
});
|
|
23553
|
+
|
|
23554
|
+
_defineProperty(_assertThisInitialized(_this2), "handleCompositionEnd", function (event) {
|
|
23555
|
+
_this2.isComposing = false;
|
|
23556
|
+
});
|
|
23557
|
+
|
|
23550
23558
|
_this2.state = {
|
|
23551
23559
|
showEquationEditor: false,
|
|
23552
23560
|
equationEditorLatex: "",
|
|
@@ -23593,7 +23601,9 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
|
|
|
23593
23601
|
_this2.initialHistoryState = null;
|
|
23594
23602
|
_this2.undoHistory = [];
|
|
23595
23603
|
_this2.redoHistory = [];
|
|
23596
|
-
_this2.accent = "";
|
|
23604
|
+
_this2.accent = ""; // keeps track of whether user is composing in an IME - see https://developer.mozilla.org/en-US/docs/Web/API/CompositionEvent
|
|
23605
|
+
|
|
23606
|
+
_this2.isComposing = false;
|
|
23597
23607
|
return _this2;
|
|
23598
23608
|
}
|
|
23599
23609
|
|
|
@@ -23803,6 +23813,8 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
|
|
|
23803
23813
|
onMouseUp: this.handleMouseUp,
|
|
23804
23814
|
onFocus: this.handleFocus,
|
|
23805
23815
|
onBlur: this.handleBlur,
|
|
23816
|
+
onCompositionStart: this.handleCompositionStart,
|
|
23817
|
+
onCompositionEnd: this.handleCompositionEnd,
|
|
23806
23818
|
dangerouslySetInnerHTML: {
|
|
23807
23819
|
__html: html
|
|
23808
23820
|
},
|
package/dist/math-rich-input.css
CHANGED
|
@@ -78,136 +78,6 @@
|
|
|
78
78
|
padding: 2px;
|
|
79
79
|
margin: 0px 2px;
|
|
80
80
|
}
|
|
81
|
-
/* Note that the top left position of the toolbar is set programatically in componentDidMount */
|
|
82
|
-
|
|
83
|
-
.Toolbar {
|
|
84
|
-
position: absolute;
|
|
85
|
-
z-index: 1;
|
|
86
|
-
display: flex;
|
|
87
|
-
height: 42px;
|
|
88
|
-
background-color: white;
|
|
89
|
-
border: 1px solid #d0d0d0;
|
|
90
|
-
border-radius: 5px;
|
|
91
|
-
box-shadow: 1px 1px 5px #a0a0a0;
|
|
92
|
-
animation: 0.5s fadeIn1;
|
|
93
|
-
animation-fill-mode: forwards;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
@keyframes fadeIn1 {
|
|
97
|
-
0% {
|
|
98
|
-
opacity: 0;
|
|
99
|
-
}
|
|
100
|
-
100% {
|
|
101
|
-
opacity: 1;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
.Toolbar-button {
|
|
106
|
-
font-family: sans-serif;
|
|
107
|
-
font-size: 16px;
|
|
108
|
-
width: 40px;
|
|
109
|
-
height: 36px;
|
|
110
|
-
background-color: white;
|
|
111
|
-
border-radius: 5px;
|
|
112
|
-
border: 0px;
|
|
113
|
-
padding: 1px;
|
|
114
|
-
margin: 2px;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
.Toolbar-button:hover {
|
|
118
|
-
color: white;
|
|
119
|
-
background: #663676;
|
|
120
|
-
cursor: pointer;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
.Toolbar-button:active {
|
|
124
|
-
background: #808080;
|
|
125
|
-
color: white;
|
|
126
|
-
cursor: pointer;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
.TB-narrow {
|
|
130
|
-
width: 30px;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
.TB-wide {
|
|
134
|
-
width: 46px;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
.TB-selected {
|
|
138
|
-
background: #d0d0d0;
|
|
139
|
-
color: black;
|
|
140
|
-
cursor: pointer;
|
|
141
|
-
animation: 0.2s TB-fadeIn;
|
|
142
|
-
animation-fill-mode: forwards;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
.TB-selected:hover {
|
|
146
|
-
color: white;
|
|
147
|
-
background: #663676;
|
|
148
|
-
cursor: pointer;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
@keyframes TB-fadeIn {
|
|
152
|
-
00% {
|
|
153
|
-
background: white;
|
|
154
|
-
}
|
|
155
|
-
100% {
|
|
156
|
-
background: #d0d0d0;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/* Tooltip text */
|
|
161
|
-
.Toolbar-button .tooltiptext {
|
|
162
|
-
font-weight: normal;
|
|
163
|
-
visibility: hidden;
|
|
164
|
-
width: 100px;
|
|
165
|
-
background-color: #222;
|
|
166
|
-
color: #fff;
|
|
167
|
-
/*font-weight: bold;*/
|
|
168
|
-
font-size: 12px;
|
|
169
|
-
text-align: center;
|
|
170
|
-
padding: 4px 10px;
|
|
171
|
-
border-radius: 6px;
|
|
172
|
-
|
|
173
|
-
/* Position the tooltip text - see examples below! */
|
|
174
|
-
position: absolute;
|
|
175
|
-
z-index: 2;
|
|
176
|
-
top: -90%; /* Must leave a small gap between tooltip and button */
|
|
177
|
-
left: 50px;
|
|
178
|
-
|
|
179
|
-
/* transform: translate (50%,0%); */
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
/* Show the tooltip text when you mouse over the tooltip container */
|
|
183
|
-
.Toolbar-button:hover .tooltiptext {
|
|
184
|
-
animation: 0.8s fadeIn2;
|
|
185
|
-
animation-fill-mode: forwards;
|
|
186
|
-
visibility: visible;
|
|
187
|
-
/* width: 100px; */
|
|
188
|
-
/* top: -90%; */ /* Must leave a small gap between tooltip and button */
|
|
189
|
-
/* left: 20%; */
|
|
190
|
-
/* margin-left: -50px; */
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
@keyframes fadeIn2 {
|
|
194
|
-
00% {
|
|
195
|
-
opacity: 0;
|
|
196
|
-
}
|
|
197
|
-
70% {
|
|
198
|
-
opacity: 0;
|
|
199
|
-
}
|
|
200
|
-
100% {
|
|
201
|
-
visibility: visible;
|
|
202
|
-
opacity: 0.9;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
/* .tooltip {
|
|
207
|
-
position: relative;
|
|
208
|
-
display: inline-block;
|
|
209
|
-
border-bottom: 1px dotted black; /* If you want dots under the hoverable text
|
|
210
|
-
} */
|
|
211
81
|
.EquationEditorModal-background {
|
|
212
82
|
position: fixed;
|
|
213
83
|
top: 0;
|
|
@@ -363,6 +233,136 @@
|
|
|
363
233
|
.EquationEditorModal .slider.round:before {
|
|
364
234
|
border-radius: 50%;
|
|
365
235
|
}
|
|
236
|
+
/* Note that the top left position of the toolbar is set programatically in componentDidMount */
|
|
237
|
+
|
|
238
|
+
.Toolbar {
|
|
239
|
+
position: absolute;
|
|
240
|
+
z-index: 1;
|
|
241
|
+
display: flex;
|
|
242
|
+
height: 42px;
|
|
243
|
+
background-color: white;
|
|
244
|
+
border: 1px solid #d0d0d0;
|
|
245
|
+
border-radius: 5px;
|
|
246
|
+
box-shadow: 1px 1px 5px #a0a0a0;
|
|
247
|
+
animation: 0.5s fadeIn1;
|
|
248
|
+
animation-fill-mode: forwards;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
@keyframes fadeIn1 {
|
|
252
|
+
0% {
|
|
253
|
+
opacity: 0;
|
|
254
|
+
}
|
|
255
|
+
100% {
|
|
256
|
+
opacity: 1;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
.Toolbar-button {
|
|
261
|
+
font-family: sans-serif;
|
|
262
|
+
font-size: 16px;
|
|
263
|
+
width: 40px;
|
|
264
|
+
height: 36px;
|
|
265
|
+
background-color: white;
|
|
266
|
+
border-radius: 5px;
|
|
267
|
+
border: 0px;
|
|
268
|
+
padding: 1px;
|
|
269
|
+
margin: 2px;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
.Toolbar-button:hover {
|
|
273
|
+
color: white;
|
|
274
|
+
background: #663676;
|
|
275
|
+
cursor: pointer;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
.Toolbar-button:active {
|
|
279
|
+
background: #808080;
|
|
280
|
+
color: white;
|
|
281
|
+
cursor: pointer;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
.TB-narrow {
|
|
285
|
+
width: 30px;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
.TB-wide {
|
|
289
|
+
width: 46px;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
.TB-selected {
|
|
293
|
+
background: #d0d0d0;
|
|
294
|
+
color: black;
|
|
295
|
+
cursor: pointer;
|
|
296
|
+
animation: 0.2s TB-fadeIn;
|
|
297
|
+
animation-fill-mode: forwards;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
.TB-selected:hover {
|
|
301
|
+
color: white;
|
|
302
|
+
background: #663676;
|
|
303
|
+
cursor: pointer;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
@keyframes TB-fadeIn {
|
|
307
|
+
00% {
|
|
308
|
+
background: white;
|
|
309
|
+
}
|
|
310
|
+
100% {
|
|
311
|
+
background: #d0d0d0;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/* Tooltip text */
|
|
316
|
+
.Toolbar-button .tooltiptext {
|
|
317
|
+
font-weight: normal;
|
|
318
|
+
visibility: hidden;
|
|
319
|
+
width: 100px;
|
|
320
|
+
background-color: #222;
|
|
321
|
+
color: #fff;
|
|
322
|
+
/*font-weight: bold;*/
|
|
323
|
+
font-size: 12px;
|
|
324
|
+
text-align: center;
|
|
325
|
+
padding: 4px 10px;
|
|
326
|
+
border-radius: 6px;
|
|
327
|
+
|
|
328
|
+
/* Position the tooltip text - see examples below! */
|
|
329
|
+
position: absolute;
|
|
330
|
+
z-index: 2;
|
|
331
|
+
top: -90%; /* Must leave a small gap between tooltip and button */
|
|
332
|
+
left: 50px;
|
|
333
|
+
|
|
334
|
+
/* transform: translate (50%,0%); */
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/* Show the tooltip text when you mouse over the tooltip container */
|
|
338
|
+
.Toolbar-button:hover .tooltiptext {
|
|
339
|
+
animation: 0.8s fadeIn2;
|
|
340
|
+
animation-fill-mode: forwards;
|
|
341
|
+
visibility: visible;
|
|
342
|
+
/* width: 100px; */
|
|
343
|
+
/* top: -90%; */ /* Must leave a small gap between tooltip and button */
|
|
344
|
+
/* left: 20%; */
|
|
345
|
+
/* margin-left: -50px; */
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
@keyframes fadeIn2 {
|
|
349
|
+
00% {
|
|
350
|
+
opacity: 0;
|
|
351
|
+
}
|
|
352
|
+
70% {
|
|
353
|
+
opacity: 0;
|
|
354
|
+
}
|
|
355
|
+
100% {
|
|
356
|
+
visibility: visible;
|
|
357
|
+
opacity: 0.9;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/* .tooltip {
|
|
362
|
+
position: relative;
|
|
363
|
+
display: inline-block;
|
|
364
|
+
border-bottom: 1px dotted black; /* If you want dots under the hoverable text
|
|
365
|
+
} */
|
|
366
366
|
/* Note that the top left position of the accent bar is set programatically in componentDidMount */
|
|
367
367
|
|
|
368
368
|
.AccentBar {
|
package/package.json
CHANGED
package/src/MathRichInput.jsx
CHANGED
|
@@ -208,6 +208,9 @@ export default class MathRichInput extends React.Component {
|
|
|
208
208
|
this.undoHistory = [];
|
|
209
209
|
this.redoHistory = [];
|
|
210
210
|
this.accent = "";
|
|
211
|
+
|
|
212
|
+
// keeps track of whether user is composing in an IME - see https://developer.mozilla.org/en-US/docs/Web/API/CompositionEvent
|
|
213
|
+
this.isComposing = false;
|
|
211
214
|
}
|
|
212
215
|
|
|
213
216
|
enableFontStyling() {
|
|
@@ -1143,7 +1146,7 @@ export default class MathRichInput extends React.Component {
|
|
|
1143
1146
|
handleInput = (event) => {
|
|
1144
1147
|
try {
|
|
1145
1148
|
// console.log("handleInput")
|
|
1146
|
-
if (
|
|
1149
|
+
if (this.isComposing) return;
|
|
1147
1150
|
|
|
1148
1151
|
let raw_text = elementToMarkedRawText(
|
|
1149
1152
|
this.editableDiv,
|
|
@@ -2156,6 +2159,14 @@ export default class MathRichInput extends React.Component {
|
|
|
2156
2159
|
}
|
|
2157
2160
|
};
|
|
2158
2161
|
|
|
2162
|
+
handleCompositionStart = (event) => {
|
|
2163
|
+
this.isComposing = true ;
|
|
2164
|
+
}
|
|
2165
|
+
|
|
2166
|
+
handleCompositionEnd = (event) => {
|
|
2167
|
+
this.isComposing = false;
|
|
2168
|
+
}
|
|
2169
|
+
|
|
2159
2170
|
render() {
|
|
2160
2171
|
if (this.props.value == null) {
|
|
2161
2172
|
console.error('MathRichInput must have prop called "value"');
|
|
@@ -2212,6 +2223,8 @@ export default class MathRichInput extends React.Component {
|
|
|
2212
2223
|
onMouseUp={this.handleMouseUp}
|
|
2213
2224
|
onFocus={this.handleFocus}
|
|
2214
2225
|
onBlur={this.handleBlur}
|
|
2226
|
+
onCompositionStart={this.handleCompositionStart}
|
|
2227
|
+
onCompositionEnd={this.handleCompositionEnd}
|
|
2215
2228
|
dangerouslySetInnerHTML={{ __html: html }}
|
|
2216
2229
|
data-placeholder={this.props.placeholder || ""}
|
|
2217
2230
|
></span>
|