@zzish/math-rich-input 0.1.29 → 0.1.30
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 +11 -15
- package/dist/math-rich-input.css +130 -130
- package/package.json +1 -1
- package/src/MathRichInput.jsx +83 -79
package/dist/index.js
CHANGED
|
@@ -21979,18 +21979,12 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
|
|
|
21979
21979
|
});
|
|
21980
21980
|
|
|
21981
21981
|
_defineProperty(_assertThisInitialized(_this2), "applyChangesToComponent", function (value, mimeType, rangeParams, isExpertMode, selectedTab) {
|
|
21982
|
-
// if (this.props.outputTex !== null && this.props.outputTex !== undefined && this.props.outputTex) {
|
|
21983
|
-
// if (mimeType === MIME_TYPE_HTML) {
|
|
21984
|
-
// console.warn("Html found when outputTex=true")
|
|
21985
|
-
// value = convertHtmlToPlainText(value)
|
|
21986
|
-
// mimeType = MIME_TYPE_PLAIN_TEXT
|
|
21987
|
-
// } else if (mimeType === MIME_TYPE_ZZISH_HTML_MATH) {
|
|
21988
|
-
// value = convertHtmlMathToTex(value)
|
|
21989
|
-
// mimeType = MIME_TYPE_TEX
|
|
21990
|
-
// }
|
|
21991
|
-
// }
|
|
21992
21982
|
// rangeParams, isExpertMode and selectedTab can be null, in which case we will set them
|
|
21993
|
-
if (rangeParams === null) rangeParams = _this2.lastSetRangeParams;
|
|
21983
|
+
if (rangeParams === null) rangeParams = _this2.lastSetRangeParams;
|
|
21984
|
+
_this2.afterComponentUpdateData = {
|
|
21985
|
+
rangeParams: rangeParams,
|
|
21986
|
+
value: value
|
|
21987
|
+
};
|
|
21994
21988
|
var options = _this2.props.options || DEFAULT_OPTIONS;
|
|
21995
21989
|
if (isExpertMode === null) isExpertMode = options.isExpertMode;
|
|
21996
21990
|
if (selectedTab === null) selectedTab = options.selectedTab; // Add this to the history
|
|
@@ -23566,7 +23560,7 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
|
|
|
23566
23560
|
};
|
|
23567
23561
|
_this2.moveCursorOnInsert = false; // Elements defining the current state of range
|
|
23568
23562
|
|
|
23569
|
-
_this2.
|
|
23563
|
+
_this2.afterComponentUpdateData = null; // Set this to update the selection after rendering
|
|
23570
23564
|
|
|
23571
23565
|
_this2.lastSetRangeParmas = null; // This is set automatically each time the range params are set with setRangeParams
|
|
23572
23566
|
|
|
@@ -23701,10 +23695,12 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
|
|
|
23701
23695
|
key: "componentDidUpdate",
|
|
23702
23696
|
value: function componentDidUpdate() {
|
|
23703
23697
|
try {
|
|
23704
|
-
|
|
23705
|
-
|
|
23698
|
+
console.log("componentDidUpdate");
|
|
23699
|
+
|
|
23700
|
+
if (this.afterComponentUpdateData !== null && this.afterComponentUpdateData !== undefined && this.afterComponentUpdateData.value === this.props.value) {
|
|
23701
|
+
this._setRangeParams(this.afterComponentUpdateData.rangeParams);
|
|
23706
23702
|
|
|
23707
|
-
this.
|
|
23703
|
+
this.afterComponentUpdateData = null;
|
|
23708
23704
|
this.updateActiveButtons();
|
|
23709
23705
|
}
|
|
23710
23706
|
} catch (error) {
|
package/dist/math-rich-input.css
CHANGED
|
@@ -78,6 +78,136 @@
|
|
|
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
|
+
} */
|
|
81
211
|
.EquationEditorModal-background {
|
|
82
212
|
position: fixed;
|
|
83
213
|
top: 0;
|
|
@@ -233,136 +363,6 @@
|
|
|
233
363
|
.EquationEditorModal .slider.round:before {
|
|
234
364
|
border-radius: 50%;
|
|
235
365
|
}
|
|
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
|
@@ -194,7 +194,7 @@ export default class MathRichInput extends React.Component {
|
|
|
194
194
|
this.moveCursorOnInsert = false;
|
|
195
195
|
|
|
196
196
|
// Elements defining the current state of range
|
|
197
|
-
this.
|
|
197
|
+
this.afterComponentUpdateData = null; // Set this to update the selection after rendering
|
|
198
198
|
this.lastSetRangeParmas = null; // This is set automatically each time the range params are set with setRangeParams
|
|
199
199
|
|
|
200
200
|
this.lastSetActiveButtons = null;
|
|
@@ -286,20 +286,10 @@ export default class MathRichInput extends React.Component {
|
|
|
286
286
|
isExpertMode,
|
|
287
287
|
selectedTab
|
|
288
288
|
) => {
|
|
289
|
-
// if (this.props.outputTex !== null && this.props.outputTex !== undefined && this.props.outputTex) {
|
|
290
|
-
// if (mimeType === MIME_TYPE_HTML) {
|
|
291
|
-
// console.warn("Html found when outputTex=true")
|
|
292
|
-
// value = convertHtmlToPlainText(value)
|
|
293
|
-
// mimeType = MIME_TYPE_PLAIN_TEXT
|
|
294
|
-
// } else if (mimeType === MIME_TYPE_ZZISH_HTML_MATH) {
|
|
295
|
-
// value = convertHtmlMathToTex(value)
|
|
296
|
-
// mimeType = MIME_TYPE_TEX
|
|
297
|
-
// }
|
|
298
|
-
// }
|
|
299
|
-
|
|
300
289
|
// rangeParams, isExpertMode and selectedTab can be null, in which case we will set them
|
|
301
290
|
if (rangeParams === null) rangeParams = this.lastSetRangeParams;
|
|
302
|
-
|
|
291
|
+
|
|
292
|
+
this.afterComponentUpdateData = { rangeParams, value };
|
|
303
293
|
|
|
304
294
|
let options = this.props.options || DEFAULT_OPTIONS;
|
|
305
295
|
if (isExpertMode === null) isExpertMode = options.isExpertMode;
|
|
@@ -461,7 +451,7 @@ export default class MathRichInput extends React.Component {
|
|
|
461
451
|
}
|
|
462
452
|
|
|
463
453
|
if (deleteToEmpty) {
|
|
464
|
-
console.log("deleteToEmpty")
|
|
454
|
+
console.log("deleteToEmpty");
|
|
465
455
|
let new_rangeParams = {
|
|
466
456
|
startNodeIndex: 0,
|
|
467
457
|
startOffset: 1,
|
|
@@ -477,7 +467,7 @@ export default class MathRichInput extends React.Component {
|
|
|
477
467
|
this.props.useExpertMode,
|
|
478
468
|
this.props.selectedTab
|
|
479
469
|
);
|
|
480
|
-
e.preventDefault()
|
|
470
|
+
e.preventDefault();
|
|
481
471
|
return;
|
|
482
472
|
}
|
|
483
473
|
|
|
@@ -590,22 +580,22 @@ export default class MathRichInput extends React.Component {
|
|
|
590
580
|
let index = rangeParams.startNodeIndex;
|
|
591
581
|
let offset = rangeParams.startOffset;
|
|
592
582
|
|
|
593
|
-
console.log("handleKeyDownArrowLeft")
|
|
594
|
-
console.log(rangeParams)
|
|
583
|
+
console.log("handleKeyDownArrowLeft");
|
|
584
|
+
console.log(rangeParams);
|
|
595
585
|
let new_globalOffset = rangeParams.endGlobalOffset - 1;
|
|
596
|
-
let new_rangeParams = null
|
|
586
|
+
let new_rangeParams = null;
|
|
597
587
|
if (e.shiftKey && new_globalOffset > rangeParams.startGlobalOffset) {
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
588
|
+
new_rangeParams = {
|
|
589
|
+
startGlobalOffset: rangeParams.startGlobalOffset,
|
|
590
|
+
endGlobalOffset: new_globalOffset,
|
|
591
|
+
};
|
|
602
592
|
} else {
|
|
603
593
|
new_rangeParams = {
|
|
604
594
|
startGlobalOffset: new_globalOffset,
|
|
605
595
|
endGlobalOffset: new_globalOffset,
|
|
606
596
|
};
|
|
607
597
|
}
|
|
608
|
-
console.log(new_rangeParams)
|
|
598
|
+
console.log(new_rangeParams);
|
|
609
599
|
e.preventDefault();
|
|
610
600
|
this._setRangeParams(new_rangeParams);
|
|
611
601
|
return;
|
|
@@ -617,7 +607,7 @@ export default class MathRichInput extends React.Component {
|
|
|
617
607
|
let index = rangeParams.startNodeIndex;
|
|
618
608
|
let offset = rangeParams.startOffset;
|
|
619
609
|
|
|
620
|
-
let new_rangeParams = null
|
|
610
|
+
let new_rangeParams = null;
|
|
621
611
|
let new_globalOffset = rangeParams.endGlobalOffset + 1;
|
|
622
612
|
if (e.shiftKey && new_globalOffset > rangeParams.startGlobalOffset) {
|
|
623
613
|
new_rangeParams = {
|
|
@@ -1031,14 +1021,17 @@ export default class MathRichInput extends React.Component {
|
|
|
1031
1021
|
}
|
|
1032
1022
|
}
|
|
1033
1023
|
|
|
1034
|
-
if (this.handleKeyDownAccentHelper(e))
|
|
1035
|
-
return;
|
|
1024
|
+
if (this.handleKeyDownAccentHelper(e)) return;
|
|
1036
1025
|
|
|
1037
1026
|
// Check if inserting character in element that starts with small space
|
|
1038
|
-
if (
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1027
|
+
if (
|
|
1028
|
+
e.key.length === 1 && // ie, it's not something like "arrowLeft"
|
|
1029
|
+
params.startOffset === 0 &&
|
|
1030
|
+
this.nodeStartsWithSmallSpace(startNode)
|
|
1031
|
+
) {
|
|
1032
|
+
console.log(
|
|
1033
|
+
"Handling character input at start of text node with small space"
|
|
1034
|
+
);
|
|
1042
1035
|
this.insertAfterSmallSpace(e.key, params);
|
|
1043
1036
|
e.preventDefault();
|
|
1044
1037
|
return;
|
|
@@ -1143,14 +1136,14 @@ export default class MathRichInput extends React.Component {
|
|
|
1143
1136
|
|
|
1144
1137
|
handleInput = (event) => {
|
|
1145
1138
|
try {
|
|
1146
|
-
console.log("handleInput")
|
|
1139
|
+
console.log("handleInput");
|
|
1147
1140
|
let raw_text = elementToMarkedRawText(
|
|
1148
1141
|
this.editableDiv,
|
|
1149
1142
|
null,
|
|
1150
1143
|
0,
|
|
1151
1144
|
this.enableHtml()
|
|
1152
1145
|
);
|
|
1153
|
-
console.log("handleInput 2")
|
|
1146
|
+
console.log("handleInput 2");
|
|
1154
1147
|
const params = this._getRangeParams();
|
|
1155
1148
|
if (params === null || params === undefined)
|
|
1156
1149
|
console.error("Could not get range params from input field");
|
|
@@ -1189,7 +1182,7 @@ export default class MathRichInput extends React.Component {
|
|
|
1189
1182
|
|
|
1190
1183
|
updateActiveButtons = () => {
|
|
1191
1184
|
try {
|
|
1192
|
-
console.log("updateActiveButtons")
|
|
1185
|
+
console.log("updateActiveButtons");
|
|
1193
1186
|
let rangeParams = this._getRangeParams();
|
|
1194
1187
|
if (rangeParams === null || rangeParams === undefined) {
|
|
1195
1188
|
console.warn(
|
|
@@ -1308,12 +1301,14 @@ export default class MathRichInput extends React.Component {
|
|
|
1308
1301
|
|
|
1309
1302
|
componentDidUpdate() {
|
|
1310
1303
|
try {
|
|
1304
|
+
console.log("componentDidUpdate");
|
|
1311
1305
|
if (
|
|
1312
|
-
this.
|
|
1313
|
-
this.
|
|
1306
|
+
this.afterComponentUpdateData !== null &&
|
|
1307
|
+
this.afterComponentUpdateData !== undefined &&
|
|
1308
|
+
this.afterComponentUpdateData.value === this.props.value
|
|
1314
1309
|
) {
|
|
1315
|
-
this._setRangeParams(this.
|
|
1316
|
-
this.
|
|
1310
|
+
this._setRangeParams(this.afterComponentUpdateData.rangeParams);
|
|
1311
|
+
this.afterComponentUpdateData = null;
|
|
1317
1312
|
this.updateActiveButtons();
|
|
1318
1313
|
}
|
|
1319
1314
|
} catch (error) {
|
|
@@ -1498,8 +1493,8 @@ export default class MathRichInput extends React.Component {
|
|
|
1498
1493
|
let start_pos = this.markedRawText.indexOf(MARK);
|
|
1499
1494
|
let end_pos = this.markedRawText.indexOf(MARK, start_pos + MARK.length);
|
|
1500
1495
|
let oldRangeParams = this.getOldRangeParams();
|
|
1501
|
-
console.log("Old range params")
|
|
1502
|
-
console.log(oldRangeParams)
|
|
1496
|
+
console.log("Old range params");
|
|
1497
|
+
console.log(oldRangeParams);
|
|
1503
1498
|
|
|
1504
1499
|
// Handle case of empty string returned
|
|
1505
1500
|
if (latex === "") {
|
|
@@ -1956,10 +1951,10 @@ export default class MathRichInput extends React.Component {
|
|
|
1956
1951
|
this.enableHtml()
|
|
1957
1952
|
);
|
|
1958
1953
|
|
|
1959
|
-
console.log("Raw text before line insert")
|
|
1960
|
-
console.log(raw_text)
|
|
1961
|
-
console.log("Range params before line insert")
|
|
1962
|
-
console.log(rangeParams)
|
|
1954
|
+
console.log("Raw text before line insert");
|
|
1955
|
+
console.log(raw_text);
|
|
1956
|
+
console.log("Range params before line insert");
|
|
1957
|
+
console.log(rangeParams);
|
|
1963
1958
|
|
|
1964
1959
|
let new_raw_text = null;
|
|
1965
1960
|
let new_rangeParams = { ...rangeParams };
|
|
@@ -1979,7 +1974,6 @@ export default class MathRichInput extends React.Component {
|
|
|
1979
1974
|
new_rangeParams.startGlobalOffset++;
|
|
1980
1975
|
new_rangeParams.endGlobalOffset++;
|
|
1981
1976
|
}
|
|
1982
|
-
|
|
1983
1977
|
} else {
|
|
1984
1978
|
new_raw_text = removeMarks(insertCharacterBeforeMarks(raw_text, "\n"));
|
|
1985
1979
|
new_rangeParams.startOffset++;
|
|
@@ -1991,12 +1985,11 @@ export default class MathRichInput extends React.Component {
|
|
|
1991
1985
|
this.props.mimeType,
|
|
1992
1986
|
this.enableHtml()
|
|
1993
1987
|
);
|
|
1994
|
-
|
|
1995
|
-
console.log("New raw text after line insert")
|
|
1996
|
-
console.log(new_raw_text)
|
|
1997
|
-
console.log("New range params after line insert")
|
|
1998
|
-
console.log(new_rangeParams)
|
|
1999
1988
|
|
|
1989
|
+
console.log("New raw text after line insert");
|
|
1990
|
+
console.log(new_raw_text);
|
|
1991
|
+
console.log("New range params after line insert");
|
|
1992
|
+
console.log(new_rangeParams);
|
|
2000
1993
|
|
|
2001
1994
|
this.applyChangesToComponent(
|
|
2002
1995
|
new_raw_text,
|
|
@@ -2016,34 +2009,39 @@ export default class MathRichInput extends React.Component {
|
|
|
2016
2009
|
rangeParams = this._getRangeParams();
|
|
2017
2010
|
|
|
2018
2011
|
if (rangeParams.startOffset !== 0)
|
|
2019
|
-
console.warn(
|
|
2020
|
-
|
|
2012
|
+
console.warn(
|
|
2013
|
+
"Unexpected startOffset " +
|
|
2014
|
+
rangeParams.startOffset +
|
|
2015
|
+
" in insertAfterSmallSpace"
|
|
2016
|
+
);
|
|
2017
|
+
|
|
2021
2018
|
let node = this._findNodeWithIndex(rangeParams.startNodeIndex);
|
|
2022
2019
|
let raw_text = elementToMarkedRawText(
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2020
|
+
this.editableDiv,
|
|
2021
|
+
node,
|
|
2022
|
+
1, // after small space
|
|
2023
|
+
this.enableHtml()
|
|
2024
|
+
);
|
|
2028
2025
|
|
|
2029
2026
|
let new_raw_text = removeMarks(
|
|
2030
|
-
insertCharacterBeforeMarks(raw_text, new_char)
|
|
2027
|
+
insertCharacterBeforeMarks(raw_text, new_char)
|
|
2028
|
+
);
|
|
2031
2029
|
|
|
2032
2030
|
let new_rangeParams = {
|
|
2033
|
-
startNodeIndex:rangeParams.startNodeIndex,
|
|
2034
|
-
startNodeOffset:1+new_char.length,
|
|
2035
|
-
endNodeIndex:rangeParams.startNodeIndex,
|
|
2036
|
-
endNodeOffset:1+new_char.length,
|
|
2037
|
-
startGlobalOffset:rangeParams.startGlobalOffset+new_char.length,
|
|
2038
|
-
endGlobalOffset:rangeParams.endGlobalOffset+new_char.length,
|
|
2039
|
-
}
|
|
2040
|
-
|
|
2031
|
+
startNodeIndex: rangeParams.startNodeIndex,
|
|
2032
|
+
startNodeOffset: 1 + new_char.length,
|
|
2033
|
+
endNodeIndex: rangeParams.startNodeIndex,
|
|
2034
|
+
endNodeOffset: 1 + new_char.length,
|
|
2035
|
+
startGlobalOffset: rangeParams.startGlobalOffset + new_char.length,
|
|
2036
|
+
endGlobalOffset: rangeParams.endGlobalOffset + new_char.length,
|
|
2037
|
+
};
|
|
2038
|
+
|
|
2041
2039
|
new_raw_text = removeEncodingIfPlainText(
|
|
2042
2040
|
new_raw_text,
|
|
2043
2041
|
this.props.mimeType,
|
|
2044
2042
|
this.enableHtml()
|
|
2045
2043
|
);
|
|
2046
|
-
|
|
2044
|
+
|
|
2047
2045
|
this.applyChangesToComponent(
|
|
2048
2046
|
new_raw_text,
|
|
2049
2047
|
this.props.mimeType,
|
|
@@ -2054,7 +2052,7 @@ export default class MathRichInput extends React.Component {
|
|
|
2054
2052
|
} catch (error) {
|
|
2055
2053
|
console.error(error);
|
|
2056
2054
|
}
|
|
2057
|
-
}
|
|
2055
|
+
}
|
|
2058
2056
|
|
|
2059
2057
|
insertAccentLetter = (event, old_char, new_char) => {
|
|
2060
2058
|
try {
|
|
@@ -2072,18 +2070,24 @@ export default class MathRichInput extends React.Component {
|
|
|
2072
2070
|
let new_raw_text = null;
|
|
2073
2071
|
let new_rangeParams = null;
|
|
2074
2072
|
|
|
2075
|
-
if (old_char === null) {
|
|
2076
|
-
|
|
2073
|
+
if (old_char === null) {
|
|
2074
|
+
// insert new char
|
|
2075
|
+
new_raw_text = removeMarks(
|
|
2076
|
+
insertCharacterBeforeMarks(raw_text, new_char)
|
|
2077
|
+
);
|
|
2077
2078
|
new_rangeParams = {
|
|
2078
|
-
startNodeIndex:rangeParams.startNodeIndex,
|
|
2079
|
-
startOffset:rangeParams.startOffset + new_char.length,
|
|
2080
|
-
endNodeIndex:rangeParams.startNodeIndex,
|
|
2081
|
-
endOffset:rangeParams.startOffset + new_char.length,
|
|
2082
|
-
startGlobalOffset:rangeParams.startGlobalOffset + new_char.length,
|
|
2083
|
-
endGlobalOffset:rangeParams.startGlobalOffset + new_char.length
|
|
2084
|
-
}
|
|
2085
|
-
} else {
|
|
2086
|
-
|
|
2079
|
+
startNodeIndex: rangeParams.startNodeIndex,
|
|
2080
|
+
startOffset: rangeParams.startOffset + new_char.length,
|
|
2081
|
+
endNodeIndex: rangeParams.startNodeIndex,
|
|
2082
|
+
endOffset: rangeParams.startOffset + new_char.length,
|
|
2083
|
+
startGlobalOffset: rangeParams.startGlobalOffset + new_char.length,
|
|
2084
|
+
endGlobalOffset: rangeParams.startGlobalOffset + new_char.length,
|
|
2085
|
+
};
|
|
2086
|
+
} else {
|
|
2087
|
+
// replace old char
|
|
2088
|
+
new_raw_text = removeMarks(
|
|
2089
|
+
replaceCharacterBeforeMarks(raw_text, new_char)
|
|
2090
|
+
);
|
|
2087
2091
|
new_rangeParams = { ...rangeParams };
|
|
2088
2092
|
}
|
|
2089
2093
|
|
|
@@ -2092,7 +2096,7 @@ export default class MathRichInput extends React.Component {
|
|
|
2092
2096
|
this.props.mimeType,
|
|
2093
2097
|
this.enableHtml()
|
|
2094
2098
|
);
|
|
2095
|
-
|
|
2099
|
+
|
|
2096
2100
|
this.applyChangesToComponent(
|
|
2097
2101
|
new_raw_text,
|
|
2098
2102
|
this.props.mimeType,
|