@zzish/math-rich-input 0.1.13 → 0.1.16
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 +19 -7
- package/dist/math-rich-input.css +155 -155
- package/package.json +1 -1
- package/src/MathRichInput.jsx +10 -0
- package/src/mathRichInputHelper.js +4 -4
package/dist/index.js
CHANGED
|
@@ -21119,10 +21119,7 @@ function rawTextToHtml(katex, string, mimeType) {
|
|
|
21119
21119
|
|
|
21120
21120
|
if (parseAsTex) string = string.replace(DOLLAR_SLASH_REG_EXP, TEMP_CHAR); // console.log("Modded string: "+string)
|
|
21121
21121
|
|
|
21122
|
-
var stringElements = string.split(parseAsTex ? INLINE_TEX_REG_EXP : HTML_MATH_REG_EXP);
|
|
21123
|
-
|
|
21124
|
-
if (stringElements[0] === "") // This means the original string stars with latex
|
|
21125
|
-
stringElements[0] = "&#" + SMALL_SPACE$1.charCodeAt(0);
|
|
21122
|
+
var stringElements = string.split(parseAsTex ? INLINE_TEX_REG_EXP : HTML_MATH_REG_EXP);
|
|
21126
21123
|
|
|
21127
21124
|
if (parseAsTex) {
|
|
21128
21125
|
for (var i = 0; i < stringElements.length; i++) {
|
|
@@ -21134,8 +21131,11 @@ function rawTextToHtml(katex, string, mimeType) {
|
|
|
21134
21131
|
for (var _i = 0; _i < stringElements.length; _i++) {
|
|
21135
21132
|
stringElements[_i] = stringElements[_i].replace(P_TAG_REG_EXP, P_ELEMENT_SMALL_SPACE);
|
|
21136
21133
|
}
|
|
21137
|
-
}
|
|
21134
|
+
} // Insert small space at start of first element if it is an empty element
|
|
21135
|
+
|
|
21138
21136
|
|
|
21137
|
+
if (stringElements[0] === "") // This means the original string stars with latex
|
|
21138
|
+
stringElements[0] = "&#" + SMALL_SPACE$1.charCodeAt(0);
|
|
21139
21139
|
if (stringElements.length === 1) return stringElements[0];
|
|
21140
21140
|
var latexElements = string.match(parseAsTex ? INLINE_TEX_REG_EXP : HTML_MATH_REG_EXP);
|
|
21141
21141
|
var result = [];
|
|
@@ -21469,7 +21469,8 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
|
|
|
21469
21469
|
rangeParams: rangeParams
|
|
21470
21470
|
});
|
|
21471
21471
|
|
|
21472
|
-
if (_this2.undoHistory.length > MAX_HISTORY_LENGTH) _this2.undoHistory.shift();
|
|
21472
|
+
if (_this2.undoHistory.length > MAX_HISTORY_LENGTH) _this2.undoHistory.shift();
|
|
21473
|
+
_this2.value = value; // Call the parent handler to apply the changes
|
|
21473
21474
|
|
|
21474
21475
|
_this2.onChangeCallback({
|
|
21475
21476
|
value: value,
|
|
@@ -21480,6 +21481,10 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
|
|
|
21480
21481
|
});
|
|
21481
21482
|
});
|
|
21482
21483
|
|
|
21484
|
+
_defineProperty(_assertThisInitialized(_this2), "getValue", function () {
|
|
21485
|
+
return _this2.value;
|
|
21486
|
+
});
|
|
21487
|
+
|
|
21483
21488
|
_defineProperty(_assertThisInitialized(_this2), "initialiseHistory", function () {
|
|
21484
21489
|
if (_this2.initialHistoryState == null) _this2.initialHistoryState = {
|
|
21485
21490
|
value: _this2.props.value,
|
|
@@ -22829,7 +22834,8 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
|
|
|
22829
22834
|
superscript: false
|
|
22830
22835
|
},
|
|
22831
22836
|
keyPressed: ""
|
|
22832
|
-
};
|
|
22837
|
+
};
|
|
22838
|
+
_this2.value = ""; // this.handleInput = this.handleInput.bind(this);
|
|
22833
22839
|
// this.handleKeyDown = this.handleKeyDown.bind(this);
|
|
22834
22840
|
// this.handleKeyUp = this.handleKeyUp.bind(this);
|
|
22835
22841
|
// Remember the last key pressed
|
|
@@ -22964,6 +22970,9 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
|
|
|
22964
22970
|
}, {
|
|
22965
22971
|
key: "componentDidMount",
|
|
22966
22972
|
value: function componentDidMount() {
|
|
22973
|
+
var onRef = this.props.onRef;
|
|
22974
|
+
onRef && onRef(this);
|
|
22975
|
+
|
|
22967
22976
|
try {
|
|
22968
22977
|
setupKatex();
|
|
22969
22978
|
this.editableDiv.addEventListener("keydown", this.handleKeyDown);
|
|
@@ -22975,6 +22984,9 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
|
|
|
22975
22984
|
}, {
|
|
22976
22985
|
key: "componentWillUnmount",
|
|
22977
22986
|
value: function componentWillUnmount() {
|
|
22987
|
+
var onRef = this.props.onRef;
|
|
22988
|
+
onRef && onRef(undefined);
|
|
22989
|
+
|
|
22978
22990
|
try {
|
|
22979
22991
|
this.editableDiv.removeEventListener("keydown", this.handleKeyDown);
|
|
22980
22992
|
this.editableDiv.removeEventListener("keyup", this.handleKeyUp);
|
package/dist/math-rich-input.css
CHANGED
|
@@ -69,161 +69,6 @@
|
|
|
69
69
|
padding: 2px;
|
|
70
70
|
margin: 0px 2px;
|
|
71
71
|
}
|
|
72
|
-
.EquationEditorModal-background {
|
|
73
|
-
position: fixed;
|
|
74
|
-
top: 0;
|
|
75
|
-
left: 0;
|
|
76
|
-
width: 100%;
|
|
77
|
-
height: 100%;
|
|
78
|
-
background: black;
|
|
79
|
-
z-index: 99;
|
|
80
|
-
animation: 0.3s shade;
|
|
81
|
-
animation-fill-mode: forwards;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
@keyframes shade {
|
|
85
|
-
00% {
|
|
86
|
-
opacity: 0;
|
|
87
|
-
}
|
|
88
|
-
100% {
|
|
89
|
-
opacity: 0.6;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
.EquationEditorModal {
|
|
94
|
-
background: white;
|
|
95
|
-
border: 1px solid #808080;
|
|
96
|
-
border-radius: 10px;
|
|
97
|
-
box-shadow: 0px 2px 5px 1px #a0a0a0;
|
|
98
|
-
position: fixed;
|
|
99
|
-
max-width: 500px;
|
|
100
|
-
width: 98%;
|
|
101
|
-
top: 50%;
|
|
102
|
-
left: 50%;
|
|
103
|
-
/* transform: translate(-50%,-50%); */
|
|
104
|
-
z-index: 100;
|
|
105
|
-
animation: 0.3s rise;
|
|
106
|
-
animation-fill-mode: forwards;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
@keyframes rise {
|
|
110
|
-
00% {
|
|
111
|
-
transform: translate(-50%, 100%);
|
|
112
|
-
opacity: 0;
|
|
113
|
-
}
|
|
114
|
-
100% {
|
|
115
|
-
transform: translate(-50%, -50%);
|
|
116
|
-
opacity: 1;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
.EquationEditorModal-mobile {
|
|
121
|
-
background: white;
|
|
122
|
-
border: 1px solid #808080;
|
|
123
|
-
border-radius: 10px;
|
|
124
|
-
box-shadow: 0px 2px 5px 1px #a0a0a0;
|
|
125
|
-
position: fixed;
|
|
126
|
-
max-width: 500px;
|
|
127
|
-
width: 99%;
|
|
128
|
-
top: 0%;
|
|
129
|
-
left: 50%;
|
|
130
|
-
transform: translate(-50%, 1px);
|
|
131
|
-
z-index: 100;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
.EquationEditorModal .title {
|
|
135
|
-
display: flex;
|
|
136
|
-
justify-content: space-between;
|
|
137
|
-
font-size: 14px;
|
|
138
|
-
color: #404040;
|
|
139
|
-
text-align: left;
|
|
140
|
-
background: #e0e0e0;
|
|
141
|
-
border: 0px;
|
|
142
|
-
border-radius: 5px 5px 0px 0px;
|
|
143
|
-
padding: 15px;
|
|
144
|
-
margin: 0px;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
.EquationEditorModal-mobile .title {
|
|
148
|
-
display: flex;
|
|
149
|
-
justify-content: space-between;
|
|
150
|
-
font-size: 14px;
|
|
151
|
-
color: #404040;
|
|
152
|
-
text-align: left;
|
|
153
|
-
background: #e0e0e0;
|
|
154
|
-
border: 0px;
|
|
155
|
-
border-radius: 5px 5px 0px 0px;
|
|
156
|
-
height: 30px;
|
|
157
|
-
padding: 15px;
|
|
158
|
-
margin: 0px;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
.EquationEditorModal .expertModeSwitch .switch {
|
|
162
|
-
margin-left: 10px;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/* The switch - the box around the slider */
|
|
166
|
-
.EquationEditorModal .switch {
|
|
167
|
-
position: relative;
|
|
168
|
-
display: inline-block;
|
|
169
|
-
width: 35px;
|
|
170
|
-
height: 22px;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
/* Hide default HTML checkbox */
|
|
174
|
-
.EquationEditorModal .switch input {
|
|
175
|
-
opacity: 0;
|
|
176
|
-
width: 0;
|
|
177
|
-
height: 0;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
/* The slider */
|
|
181
|
-
.EquationEditorModal .slider {
|
|
182
|
-
position: absolute;
|
|
183
|
-
cursor: pointer;
|
|
184
|
-
top: 0;
|
|
185
|
-
left: 0;
|
|
186
|
-
right: 0;
|
|
187
|
-
bottom: 0;
|
|
188
|
-
background-color: #ccc;
|
|
189
|
-
-webkit-transition: 0.4s;
|
|
190
|
-
transition: 0.4s;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
.EquationEditorModal .slider:before {
|
|
194
|
-
position: absolute;
|
|
195
|
-
content: "";
|
|
196
|
-
height: 14px;
|
|
197
|
-
width: 14px;
|
|
198
|
-
left: 4px;
|
|
199
|
-
bottom: 4px;
|
|
200
|
-
background-color: white;
|
|
201
|
-
-webkit-transition: 0.4s;
|
|
202
|
-
transition: 0.4s;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
.EquationEditorModal input:checked + .slider {
|
|
206
|
-
background-color: #663676;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
.EquationEditorModal input:focus + .slider {
|
|
210
|
-
box-shadow: 0 0 1px #2196f3;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
.EquationEditorModal input:checked + .slider:before {
|
|
214
|
-
-webkit-transform: translateX(13px);
|
|
215
|
-
-ms-transform: translateX(13px);
|
|
216
|
-
transform: translateX(13px);
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
/* Rounded sliders */
|
|
220
|
-
.EquationEditorModal .slider.round {
|
|
221
|
-
border-radius: 18px;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
.EquationEditorModal .slider.round:before {
|
|
225
|
-
border-radius: 50%;
|
|
226
|
-
}
|
|
227
72
|
/* Note that the top left position of the toolbar is set programatically in componentDidMount */
|
|
228
73
|
|
|
229
74
|
.Toolbar {
|
|
@@ -529,6 +374,161 @@
|
|
|
529
374
|
animation: 0.4s fadeIn1;
|
|
530
375
|
animation-fill-mode: forwards;
|
|
531
376
|
}
|
|
377
|
+
.EquationEditorModal-background {
|
|
378
|
+
position: fixed;
|
|
379
|
+
top: 0;
|
|
380
|
+
left: 0;
|
|
381
|
+
width: 100%;
|
|
382
|
+
height: 100%;
|
|
383
|
+
background: black;
|
|
384
|
+
z-index: 99;
|
|
385
|
+
animation: 0.3s shade;
|
|
386
|
+
animation-fill-mode: forwards;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
@keyframes shade {
|
|
390
|
+
00% {
|
|
391
|
+
opacity: 0;
|
|
392
|
+
}
|
|
393
|
+
100% {
|
|
394
|
+
opacity: 0.6;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
.EquationEditorModal {
|
|
399
|
+
background: white;
|
|
400
|
+
border: 1px solid #808080;
|
|
401
|
+
border-radius: 10px;
|
|
402
|
+
box-shadow: 0px 2px 5px 1px #a0a0a0;
|
|
403
|
+
position: fixed;
|
|
404
|
+
max-width: 500px;
|
|
405
|
+
width: 98%;
|
|
406
|
+
top: 50%;
|
|
407
|
+
left: 50%;
|
|
408
|
+
/* transform: translate(-50%,-50%); */
|
|
409
|
+
z-index: 100;
|
|
410
|
+
animation: 0.3s rise;
|
|
411
|
+
animation-fill-mode: forwards;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
@keyframes rise {
|
|
415
|
+
00% {
|
|
416
|
+
transform: translate(-50%, 100%);
|
|
417
|
+
opacity: 0;
|
|
418
|
+
}
|
|
419
|
+
100% {
|
|
420
|
+
transform: translate(-50%, -50%);
|
|
421
|
+
opacity: 1;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
.EquationEditorModal-mobile {
|
|
426
|
+
background: white;
|
|
427
|
+
border: 1px solid #808080;
|
|
428
|
+
border-radius: 10px;
|
|
429
|
+
box-shadow: 0px 2px 5px 1px #a0a0a0;
|
|
430
|
+
position: fixed;
|
|
431
|
+
max-width: 500px;
|
|
432
|
+
width: 99%;
|
|
433
|
+
top: 0%;
|
|
434
|
+
left: 50%;
|
|
435
|
+
transform: translate(-50%, 1px);
|
|
436
|
+
z-index: 100;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
.EquationEditorModal .title {
|
|
440
|
+
display: flex;
|
|
441
|
+
justify-content: space-between;
|
|
442
|
+
font-size: 14px;
|
|
443
|
+
color: #404040;
|
|
444
|
+
text-align: left;
|
|
445
|
+
background: #e0e0e0;
|
|
446
|
+
border: 0px;
|
|
447
|
+
border-radius: 5px 5px 0px 0px;
|
|
448
|
+
padding: 15px;
|
|
449
|
+
margin: 0px;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
.EquationEditorModal-mobile .title {
|
|
453
|
+
display: flex;
|
|
454
|
+
justify-content: space-between;
|
|
455
|
+
font-size: 14px;
|
|
456
|
+
color: #404040;
|
|
457
|
+
text-align: left;
|
|
458
|
+
background: #e0e0e0;
|
|
459
|
+
border: 0px;
|
|
460
|
+
border-radius: 5px 5px 0px 0px;
|
|
461
|
+
height: 30px;
|
|
462
|
+
padding: 15px;
|
|
463
|
+
margin: 0px;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
.EquationEditorModal .expertModeSwitch .switch {
|
|
467
|
+
margin-left: 10px;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
/* The switch - the box around the slider */
|
|
471
|
+
.EquationEditorModal .switch {
|
|
472
|
+
position: relative;
|
|
473
|
+
display: inline-block;
|
|
474
|
+
width: 35px;
|
|
475
|
+
height: 22px;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
/* Hide default HTML checkbox */
|
|
479
|
+
.EquationEditorModal .switch input {
|
|
480
|
+
opacity: 0;
|
|
481
|
+
width: 0;
|
|
482
|
+
height: 0;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
/* The slider */
|
|
486
|
+
.EquationEditorModal .slider {
|
|
487
|
+
position: absolute;
|
|
488
|
+
cursor: pointer;
|
|
489
|
+
top: 0;
|
|
490
|
+
left: 0;
|
|
491
|
+
right: 0;
|
|
492
|
+
bottom: 0;
|
|
493
|
+
background-color: #ccc;
|
|
494
|
+
-webkit-transition: 0.4s;
|
|
495
|
+
transition: 0.4s;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
.EquationEditorModal .slider:before {
|
|
499
|
+
position: absolute;
|
|
500
|
+
content: "";
|
|
501
|
+
height: 14px;
|
|
502
|
+
width: 14px;
|
|
503
|
+
left: 4px;
|
|
504
|
+
bottom: 4px;
|
|
505
|
+
background-color: white;
|
|
506
|
+
-webkit-transition: 0.4s;
|
|
507
|
+
transition: 0.4s;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
.EquationEditorModal input:checked + .slider {
|
|
511
|
+
background-color: #663676;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
.EquationEditorModal input:focus + .slider {
|
|
515
|
+
box-shadow: 0 0 1px #2196f3;
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
.EquationEditorModal input:checked + .slider:before {
|
|
519
|
+
-webkit-transform: translateX(13px);
|
|
520
|
+
-ms-transform: translateX(13px);
|
|
521
|
+
transform: translateX(13px);
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
/* Rounded sliders */
|
|
525
|
+
.EquationEditorModal .slider.round {
|
|
526
|
+
border-radius: 18px;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
.EquationEditorModal .slider.round:before {
|
|
530
|
+
border-radius: 50%;
|
|
531
|
+
}
|
|
532
532
|
.EquationEditor {
|
|
533
533
|
height: auto;
|
|
534
534
|
text-align: center;
|
package/package.json
CHANGED
package/src/MathRichInput.jsx
CHANGED
|
@@ -70,6 +70,7 @@ export default class MathRichInput extends React.Component {
|
|
|
70
70
|
},
|
|
71
71
|
keyPressed: "",
|
|
72
72
|
};
|
|
73
|
+
this.value = "";
|
|
73
74
|
|
|
74
75
|
// this.handleInput = this.handleInput.bind(this);
|
|
75
76
|
// this.handleKeyDown = this.handleKeyDown.bind(this);
|
|
@@ -213,10 +214,15 @@ export default class MathRichInput extends React.Component {
|
|
|
213
214
|
this.undoHistory.push({ value, mimeType, rangeParams });
|
|
214
215
|
if (this.undoHistory.length > MAX_HISTORY_LENGTH) this.undoHistory.shift();
|
|
215
216
|
|
|
217
|
+
this.value = value;
|
|
216
218
|
// Call the parent handler to apply the changes
|
|
217
219
|
this.onChangeCallback({ value, mimeType }, { isExpertMode, selectedTab });
|
|
218
220
|
};
|
|
219
221
|
|
|
222
|
+
getValue = () => {
|
|
223
|
+
return this.value;
|
|
224
|
+
};
|
|
225
|
+
|
|
220
226
|
initialiseHistory = () => {
|
|
221
227
|
if (this.initialHistoryState == null)
|
|
222
228
|
this.initialHistoryState = {
|
|
@@ -1187,6 +1193,8 @@ export default class MathRichInput extends React.Component {
|
|
|
1187
1193
|
};
|
|
1188
1194
|
|
|
1189
1195
|
componentDidMount() {
|
|
1196
|
+
const onRef = this.props.onRef;
|
|
1197
|
+
onRef && onRef(this);
|
|
1190
1198
|
try {
|
|
1191
1199
|
setupKatex();
|
|
1192
1200
|
|
|
@@ -1198,6 +1206,8 @@ export default class MathRichInput extends React.Component {
|
|
|
1198
1206
|
}
|
|
1199
1207
|
|
|
1200
1208
|
componentWillUnmount() {
|
|
1209
|
+
const onRef = this.props.onRef;
|
|
1210
|
+
onRef && onRef(undefined);
|
|
1201
1211
|
try {
|
|
1202
1212
|
this.editableDiv.removeEventListener("keydown", this.handleKeyDown);
|
|
1203
1213
|
this.editableDiv.removeEventListener("keyup", this.handleKeyUp);
|
|
@@ -497,10 +497,6 @@ export function rawTextToHtml(katex, string, mimeType) {
|
|
|
497
497
|
|
|
498
498
|
const stringElements = string.split(parseAsTex ? INLINE_TEX_REG_EXP : HTML_MATH_REG_EXP);
|
|
499
499
|
|
|
500
|
-
// Insert small space at start of first element if it is an empty element
|
|
501
|
-
if (stringElements[0] === "") // This means the original string stars with latex
|
|
502
|
-
stringElements[0] = "&#" + SMALL_SPACE.charCodeAt(0)
|
|
503
|
-
|
|
504
500
|
if (parseAsTex) {
|
|
505
501
|
for (let i = 0; i <stringElements.length; i++) {
|
|
506
502
|
stringElements[i] = stringElements[i].replace(TEMP_CHAR_REG_EXP, "$")
|
|
@@ -511,6 +507,10 @@ export function rawTextToHtml(katex, string, mimeType) {
|
|
|
511
507
|
for (let i = 0; i <stringElements.length; i++)
|
|
512
508
|
stringElements[i] = stringElements[i].replace(P_TAG_REG_EXP, P_ELEMENT_SMALL_SPACE)
|
|
513
509
|
}
|
|
510
|
+
|
|
511
|
+
// Insert small space at start of first element if it is an empty element
|
|
512
|
+
if (stringElements[0] === "") // This means the original string stars with latex
|
|
513
|
+
stringElements[0] = "&#" + SMALL_SPACE.charCodeAt(0)
|
|
514
514
|
|
|
515
515
|
if (stringElements.length === 1)
|
|
516
516
|
return stringElements[0]
|