@zzish/math-rich-input 0.1.7 → 0.1.8
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 +61 -27
- package/dist/math-rich-input.css +137 -139
- package/package.json +1 -1
- package/src/AccentBar.css +4 -5
- package/src/AccentBar.jsx +35 -20
- package/src/MathRichInput.css +3 -2
- package/src/Toolbar.css +1 -3
- package/src/Toolbar.jsx +29 -16
package/dist/index.js
CHANGED
|
@@ -19497,8 +19497,7 @@ var EquationEditorModal = /*#__PURE__*/function (_React$Component) {
|
|
|
19497
19497
|
}(React__default['default'].Component);
|
|
19498
19498
|
|
|
19499
19499
|
var DEFAULT_TOP$1 = -1;
|
|
19500
|
-
var
|
|
19501
|
-
var TOP_MARGIN = 3;
|
|
19500
|
+
var DEFAULT_RIGHT$1 = -1;
|
|
19502
19501
|
var ACCENTS_FOR_LETTER = {
|
|
19503
19502
|
a: ["à", "á", "â", "ä", "æ", "ã", "å", "ā"],
|
|
19504
19503
|
c: ["ç", "ć", "č"],
|
|
@@ -19698,6 +19697,11 @@ var AccentBar = /*#__PURE__*/function (_React$Component) {
|
|
|
19698
19697
|
if (insert) _this.suppliedClickHandler(e, null, character);else _this.suppliedClickHandler(e, _this.letterForAccents, character);
|
|
19699
19698
|
});
|
|
19700
19699
|
|
|
19700
|
+
_defineProperty(_assertThisInitialized(_this), "isInViewport", function (element) {
|
|
19701
|
+
var rect = element.getBoundingClientRect();
|
|
19702
|
+
return rect.top >= 0 && rect.left >= 0 && rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && rect.right <= (window.innerWidth || document.documentElement.clientWidth);
|
|
19703
|
+
});
|
|
19704
|
+
|
|
19701
19705
|
_defineProperty(_assertThisInitialized(_this), "handleSelectTab", function (tab) {
|
|
19702
19706
|
GLOBAL_last_selected_tab = tab;
|
|
19703
19707
|
|
|
@@ -19707,7 +19711,6 @@ var AccentBar = /*#__PURE__*/function (_React$Component) {
|
|
|
19707
19711
|
});
|
|
19708
19712
|
|
|
19709
19713
|
_defineProperty(_assertThisInitialized(_this), "componentDidUpdate", function (prevProps) {
|
|
19710
|
-
// console.log("componentDidUpdate")
|
|
19711
19714
|
var accentKey = _this.props.keyPressed;
|
|
19712
19715
|
|
|
19713
19716
|
if (accentKey === "Backspace" || accentKey === "ArrowLeft" || accentKey === "ArrowRight") {
|
|
@@ -19727,7 +19730,8 @@ var AccentBar = /*#__PURE__*/function (_React$Component) {
|
|
|
19727
19730
|
_this.state = {
|
|
19728
19731
|
selectedTab: GLOBAL_last_selected_tab,
|
|
19729
19732
|
top: DEFAULT_TOP$1,
|
|
19730
|
-
|
|
19733
|
+
right: DEFAULT_RIGHT$1,
|
|
19734
|
+
shouldHorizontiallyAlign: false
|
|
19731
19735
|
};
|
|
19732
19736
|
_this.suppliedClickHandler = null;
|
|
19733
19737
|
_this.handleButtonClick = _this.handleButtonClick.bind(_assertThisInitialized(_this));
|
|
@@ -19759,23 +19763,32 @@ var AccentBar = /*#__PURE__*/function (_React$Component) {
|
|
|
19759
19763
|
return;
|
|
19760
19764
|
}
|
|
19761
19765
|
|
|
19766
|
+
var toolBarBounds = thisBar.parentNode.getBoundingClientRect();
|
|
19762
19767
|
var inputBounds = node.getBoundingClientRect();
|
|
19763
19768
|
var thisBounds = thisBar.getBoundingClientRect();
|
|
19764
19769
|
this.shouldUpdatePosition = false; // Vertically align below input field
|
|
19765
19770
|
|
|
19766
|
-
var top = inputBounds.bottom
|
|
19767
|
-
|
|
19768
|
-
var left = inputBounds.right - thisBounds.width; // right align
|
|
19771
|
+
var top = inputBounds.bottom - toolBarBounds.height;
|
|
19772
|
+
if (this.props.compactMode) top = inputBounds.height; // Horizontally align
|
|
19769
19773
|
|
|
19770
|
-
|
|
19774
|
+
var right = 0; // right align
|
|
19771
19775
|
// Make sure it is on screen horizontally
|
|
19772
19776
|
|
|
19773
|
-
|
|
19774
|
-
|
|
19775
|
-
if (
|
|
19777
|
+
var shouldHorizontiallyAlign = false;
|
|
19778
|
+
|
|
19779
|
+
if (thisBounds.width > inputBounds.width) {
|
|
19780
|
+
shouldHorizontiallyAlign = true;
|
|
19781
|
+
|
|
19782
|
+
if (this.isInViewport(thisBar)) {
|
|
19783
|
+
right = right - (thisBounds.width - inputBounds.width) / 2;
|
|
19784
|
+
} // else remain right aligned
|
|
19785
|
+
|
|
19786
|
+
}
|
|
19787
|
+
|
|
19776
19788
|
this.setState({
|
|
19777
|
-
|
|
19778
|
-
top: top
|
|
19789
|
+
right: right,
|
|
19790
|
+
top: top,
|
|
19791
|
+
shouldHorizontiallyAlign: shouldHorizontiallyAlign
|
|
19779
19792
|
});
|
|
19780
19793
|
} else {
|
|
19781
19794
|
this.shouldUpdatePosition = true;
|
|
@@ -19804,8 +19817,11 @@ var AccentBar = /*#__PURE__*/function (_React$Component) {
|
|
|
19804
19817
|
|
|
19805
19818
|
var style = _objectSpread2({}, this.props.style);
|
|
19806
19819
|
|
|
19807
|
-
if (this.state.
|
|
19808
|
-
|
|
19820
|
+
if (this.state.right !== DEFAULT_RIGHT$1 || this.state.top !== DEFAULT_TOP$1) {
|
|
19821
|
+
if (!this.props.compactMode || this.state.shouldHorizontiallyAlign) {
|
|
19822
|
+
style.right = this.state.right + "px";
|
|
19823
|
+
}
|
|
19824
|
+
|
|
19809
19825
|
style.top = this.state.top + "px";
|
|
19810
19826
|
}
|
|
19811
19827
|
|
|
@@ -19824,7 +19840,7 @@ var AccentBar = /*#__PURE__*/function (_React$Component) {
|
|
|
19824
19840
|
onClick: function onClick(e) {
|
|
19825
19841
|
return e.preventDefault();
|
|
19826
19842
|
}
|
|
19827
|
-
}, compactMode && /*#__PURE__*/React__default['default'].createElement(
|
|
19843
|
+
}, compactMode && /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, quickAccents.map(function (character, index) {
|
|
19828
19844
|
return /*#__PURE__*/React__default['default'].createElement("button", {
|
|
19829
19845
|
className: "AccentBar-button AB-narrow AB-compact",
|
|
19830
19846
|
key: "accent-button-" + index,
|
|
@@ -20242,7 +20258,7 @@ var AccentBar = /*#__PURE__*/function (_React$Component) {
|
|
|
20242
20258
|
}(React__default['default'].Component);
|
|
20243
20259
|
|
|
20244
20260
|
var DEFAULT_TOP = 0;
|
|
20245
|
-
var
|
|
20261
|
+
var DEFAULT_RIGHT = 0;
|
|
20246
20262
|
var BOTTOM_MARGIN = 5;
|
|
20247
20263
|
var CTRL_OR_META = /(Mac)/i.test(window.navigator.platform) ? "\u2318" : "CTRL+";
|
|
20248
20264
|
|
|
@@ -20300,10 +20316,16 @@ var Toolbar = /*#__PURE__*/function (_React$Component) {
|
|
|
20300
20316
|
|
|
20301
20317
|
});
|
|
20302
20318
|
|
|
20319
|
+
_defineProperty(_assertThisInitialized(_this), "isInViewport", function (element) {
|
|
20320
|
+
var rect = element.getBoundingClientRect();
|
|
20321
|
+
return rect.top >= 0 && rect.left >= 0 && rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && rect.right <= (window.innerWidth || document.documentElement.clientWidth);
|
|
20322
|
+
});
|
|
20323
|
+
|
|
20303
20324
|
_this.state = {
|
|
20304
20325
|
showAccents: false,
|
|
20305
20326
|
top: DEFAULT_TOP,
|
|
20306
|
-
|
|
20327
|
+
right: DEFAULT_RIGHT,
|
|
20328
|
+
shouldHorizontiallyAlign: false
|
|
20307
20329
|
};
|
|
20308
20330
|
_this.handleButtonClick = _this.handleButtonClick.bind(_assertThisInitialized(_this));
|
|
20309
20331
|
_this.suppliedClickHandler = null;
|
|
@@ -20336,16 +20358,25 @@ var Toolbar = /*#__PURE__*/function (_React$Component) {
|
|
|
20336
20358
|
var thisBounds = thisBar.getBoundingClientRect();
|
|
20337
20359
|
this.shouldUpdatePosition = false; // Vertically align above input field
|
|
20338
20360
|
|
|
20339
|
-
var top =
|
|
20361
|
+
var top = (thisBounds.height + BOTTOM_MARGIN) * -1; // Horizontally align
|
|
20362
|
+
|
|
20363
|
+
var right = 0; // right align
|
|
20364
|
+
|
|
20365
|
+
var shouldHorizontiallyAlign = false;
|
|
20366
|
+
|
|
20367
|
+
if (thisBounds.width > inputBounds.width) {
|
|
20368
|
+
shouldHorizontiallyAlign = true;
|
|
20340
20369
|
|
|
20341
|
-
|
|
20370
|
+
if (this.isInViewport(thisBar)) {
|
|
20371
|
+
right = right - (thisBounds.width - inputBounds.width) / 2;
|
|
20372
|
+
} // else remain right aligned
|
|
20373
|
+
|
|
20374
|
+
}
|
|
20342
20375
|
|
|
20343
|
-
if (thisBounds.width > inputBounds.width) left = inputBounds.left - (thisBounds.width - inputBounds.width) / 2;
|
|
20344
|
-
if (left + thisBounds.width > window.innerWidth) left = window.innerWidth - thisBounds.width - 2;
|
|
20345
|
-
if (left < 0) left = 0;
|
|
20346
20376
|
this.setState({
|
|
20347
|
-
|
|
20348
|
-
top: top
|
|
20377
|
+
right: right,
|
|
20378
|
+
top: top,
|
|
20379
|
+
shouldHorizontiallyAlign: shouldHorizontiallyAlign
|
|
20349
20380
|
});
|
|
20350
20381
|
} else {
|
|
20351
20382
|
this.shouldUpdatePosition = true;
|
|
@@ -20376,8 +20407,11 @@ var Toolbar = /*#__PURE__*/function (_React$Component) {
|
|
|
20376
20407
|
// }
|
|
20377
20408
|
|
|
20378
20409
|
|
|
20379
|
-
if (this.state.
|
|
20380
|
-
|
|
20410
|
+
if (this.state.right !== DEFAULT_RIGHT || this.state.top !== DEFAULT_TOP) {
|
|
20411
|
+
if (!this.props.compactMode || this.state.shouldHorizontiallyAlign) {
|
|
20412
|
+
style.right = this.state.right + "px";
|
|
20413
|
+
}
|
|
20414
|
+
|
|
20381
20415
|
style.top = this.state.top + "px";
|
|
20382
20416
|
}
|
|
20383
20417
|
|
package/dist/math-rich-input.css
CHANGED
|
@@ -18,10 +18,9 @@
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
.MathRichInput-scrollview {
|
|
21
|
+
position: relative;
|
|
21
22
|
display: flex;
|
|
22
|
-
overflow: scroll;
|
|
23
23
|
border-radius: 5px;
|
|
24
|
-
overflow: overlay;
|
|
25
24
|
}
|
|
26
25
|
|
|
27
26
|
.MathRichInput p {
|
|
@@ -35,6 +34,8 @@
|
|
|
35
34
|
width: 100%;
|
|
36
35
|
border-radius: 5px;
|
|
37
36
|
background-color: #fff;
|
|
37
|
+
overflow-x: scroll;
|
|
38
|
+
overflow: overlay;
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
.MathRichInput:focus {
|
|
@@ -223,31 +224,160 @@
|
|
|
223
224
|
.EquationEditorModal .slider.round:before {
|
|
224
225
|
border-radius: 50%;
|
|
225
226
|
}
|
|
227
|
+
/* Note that the top left position of the toolbar is set programatically in componentDidMount */
|
|
228
|
+
|
|
229
|
+
.Toolbar {
|
|
230
|
+
position: absolute;
|
|
231
|
+
z-index: 1;
|
|
232
|
+
display: flex;
|
|
233
|
+
height: 42px;
|
|
234
|
+
background-color: white;
|
|
235
|
+
border: 1px solid #d0d0d0;
|
|
236
|
+
border-radius: 5px;
|
|
237
|
+
box-shadow: 1px 1px 5px #a0a0a0;
|
|
238
|
+
animation: 0.5s fadeIn1;
|
|
239
|
+
animation-fill-mode: forwards;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
@keyframes fadeIn1 {
|
|
243
|
+
0% {
|
|
244
|
+
opacity: 0;
|
|
245
|
+
}
|
|
246
|
+
100% {
|
|
247
|
+
opacity: 1;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
.Toolbar-button {
|
|
252
|
+
font-family: sans-serif;
|
|
253
|
+
font-size: 16px;
|
|
254
|
+
width: 40px;
|
|
255
|
+
height: 36px;
|
|
256
|
+
background-color: white;
|
|
257
|
+
border-radius: 5px;
|
|
258
|
+
border: 0px;
|
|
259
|
+
padding: 1px;
|
|
260
|
+
margin: 2px;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
.Toolbar-button:hover {
|
|
264
|
+
color: white;
|
|
265
|
+
background: #663676;
|
|
266
|
+
cursor: pointer;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
.Toolbar-button:active {
|
|
270
|
+
background: #808080;
|
|
271
|
+
color: white;
|
|
272
|
+
cursor: pointer;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
.TB-narrow {
|
|
276
|
+
width: 30px;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
.TB-wide {
|
|
280
|
+
width: 46px;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
.TB-selected {
|
|
284
|
+
background: #d0d0d0;
|
|
285
|
+
color: black;
|
|
286
|
+
cursor: pointer;
|
|
287
|
+
animation: 0.2s TB-fadeIn;
|
|
288
|
+
animation-fill-mode: forwards;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
.TB-selected:hover {
|
|
292
|
+
color: white;
|
|
293
|
+
background: #663676;
|
|
294
|
+
cursor: pointer;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
@keyframes TB-fadeIn {
|
|
298
|
+
00% {
|
|
299
|
+
background: white;
|
|
300
|
+
}
|
|
301
|
+
100% {
|
|
302
|
+
background: #d0d0d0;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/* Tooltip text */
|
|
307
|
+
.Toolbar-button .tooltiptext {
|
|
308
|
+
font-weight: normal;
|
|
309
|
+
visibility: hidden;
|
|
310
|
+
width: 100px;
|
|
311
|
+
background-color: #222;
|
|
312
|
+
color: #fff;
|
|
313
|
+
/*font-weight: bold;*/
|
|
314
|
+
font-size: 12px;
|
|
315
|
+
text-align: center;
|
|
316
|
+
padding: 4px 10px;
|
|
317
|
+
border-radius: 6px;
|
|
318
|
+
|
|
319
|
+
/* Position the tooltip text - see examples below! */
|
|
320
|
+
position: absolute;
|
|
321
|
+
z-index: 2;
|
|
322
|
+
top: -90%; /* Must leave a small gap between tooltip and button */
|
|
323
|
+
left: 50px;
|
|
324
|
+
|
|
325
|
+
/* transform: translate (50%,0%); */
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/* Show the tooltip text when you mouse over the tooltip container */
|
|
329
|
+
.Toolbar-button:hover .tooltiptext {
|
|
330
|
+
animation: 0.8s fadeIn2;
|
|
331
|
+
animation-fill-mode: forwards;
|
|
332
|
+
visibility: visible;
|
|
333
|
+
/* width: 100px; */
|
|
334
|
+
/* top: -90%; */ /* Must leave a small gap between tooltip and button */
|
|
335
|
+
/* left: 20%; */
|
|
336
|
+
/* margin-left: -50px; */
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
@keyframes fadeIn2 {
|
|
340
|
+
00% {
|
|
341
|
+
opacity: 0;
|
|
342
|
+
}
|
|
343
|
+
70% {
|
|
344
|
+
opacity: 0;
|
|
345
|
+
}
|
|
346
|
+
100% {
|
|
347
|
+
visibility: visible;
|
|
348
|
+
opacity: 0.9;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/* .tooltip {
|
|
353
|
+
position: relative;
|
|
354
|
+
display: inline-block;
|
|
355
|
+
border-bottom: 1px dotted black; /* If you want dots under the hoverable text
|
|
356
|
+
} */
|
|
226
357
|
/* Note that the top left position of the accent bar is set programatically in componentDidMount */
|
|
227
358
|
|
|
228
359
|
.AccentBar {
|
|
229
|
-
position:
|
|
360
|
+
position: absolute;
|
|
230
361
|
z-index: 1;
|
|
231
362
|
width: 360px;
|
|
232
363
|
background-color: #fff;
|
|
233
364
|
border: 1px solid #d0d0d0;
|
|
234
365
|
border-radius: 5px;
|
|
235
366
|
box-shadow: 1px 1px 5px #a0a0a0;
|
|
236
|
-
padding:
|
|
367
|
+
padding: 8px;
|
|
237
368
|
animation: 0.4s fadeIn1;
|
|
238
369
|
animation-fill-mode: forwards;
|
|
239
370
|
}
|
|
240
371
|
|
|
241
372
|
.AccentBar-compact {
|
|
242
|
-
|
|
373
|
+
display: flex;
|
|
374
|
+
position: absolute;
|
|
243
375
|
z-index: 1;
|
|
244
376
|
background-color: white;
|
|
245
377
|
border: 1px solid #d0d0d0;
|
|
246
378
|
border-radius: 5px;
|
|
247
379
|
box-shadow: 1px 1px 5px #a0a0a0;
|
|
248
380
|
padding: 5px;
|
|
249
|
-
top: 0px;
|
|
250
|
-
left: 0px; /* Important to set this default so that accent bar renders to optimal width */
|
|
251
381
|
animation: 0.4s fadeIn1;
|
|
252
382
|
animation-fill-mode: forwards;
|
|
253
383
|
}
|
|
@@ -399,138 +529,6 @@
|
|
|
399
529
|
animation: 0.4s fadeIn1;
|
|
400
530
|
animation-fill-mode: forwards;
|
|
401
531
|
}
|
|
402
|
-
/* Note that the top left position of the toolbar is set programatically in componentDidMount */
|
|
403
|
-
|
|
404
|
-
.Toolbar {
|
|
405
|
-
position: fixed;
|
|
406
|
-
z-index: 1;
|
|
407
|
-
display: flex;
|
|
408
|
-
height: 42px;
|
|
409
|
-
background-color: white;
|
|
410
|
-
border: 1px solid #d0d0d0;
|
|
411
|
-
border-radius: 5px;
|
|
412
|
-
box-shadow: 1px 1px 5px #a0a0a0;
|
|
413
|
-
animation: 0.5s fadeIn1;
|
|
414
|
-
animation-fill-mode: forwards;
|
|
415
|
-
top: 0px;
|
|
416
|
-
left: 0px; /* important to set this so that toolbar initially renders full width */
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
@keyframes fadeIn1 {
|
|
420
|
-
0% {
|
|
421
|
-
opacity: 0;
|
|
422
|
-
}
|
|
423
|
-
100% {
|
|
424
|
-
opacity: 1;
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
.Toolbar-button {
|
|
429
|
-
font-family: sans-serif;
|
|
430
|
-
font-size: 16px;
|
|
431
|
-
width: 40px;
|
|
432
|
-
height: 36px;
|
|
433
|
-
background-color: white;
|
|
434
|
-
border-radius: 5px;
|
|
435
|
-
border: 0px;
|
|
436
|
-
padding: 1px;
|
|
437
|
-
margin: 2px;
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
.Toolbar-button:hover {
|
|
441
|
-
color: white;
|
|
442
|
-
background: #663676;
|
|
443
|
-
cursor: pointer;
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
.Toolbar-button:active {
|
|
447
|
-
background: #808080;
|
|
448
|
-
color: white;
|
|
449
|
-
cursor: pointer;
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
.TB-narrow {
|
|
453
|
-
width: 30px;
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
.TB-wide {
|
|
457
|
-
width: 46px;
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
.TB-selected {
|
|
461
|
-
background: #d0d0d0;
|
|
462
|
-
color: black;
|
|
463
|
-
cursor: pointer;
|
|
464
|
-
animation: 0.2s TB-fadeIn;
|
|
465
|
-
animation-fill-mode: forwards;
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
.TB-selected:hover {
|
|
469
|
-
color: white;
|
|
470
|
-
background: #663676;
|
|
471
|
-
cursor: pointer;
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
@keyframes TB-fadeIn {
|
|
475
|
-
00% {
|
|
476
|
-
background: white;
|
|
477
|
-
}
|
|
478
|
-
100% {
|
|
479
|
-
background: #d0d0d0;
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
/* Tooltip text */
|
|
484
|
-
.Toolbar-button .tooltiptext {
|
|
485
|
-
font-weight: normal;
|
|
486
|
-
visibility: hidden;
|
|
487
|
-
width: 100px;
|
|
488
|
-
background-color: #222;
|
|
489
|
-
color: #fff;
|
|
490
|
-
/*font-weight: bold;*/
|
|
491
|
-
font-size: 12px;
|
|
492
|
-
text-align: center;
|
|
493
|
-
padding: 4px 10px;
|
|
494
|
-
border-radius: 6px;
|
|
495
|
-
|
|
496
|
-
/* Position the tooltip text - see examples below! */
|
|
497
|
-
position: absolute;
|
|
498
|
-
z-index: 2;
|
|
499
|
-
top: -90%; /* Must leave a small gap between tooltip and button */
|
|
500
|
-
left: 50px;
|
|
501
|
-
|
|
502
|
-
/* transform: translate (50%,0%); */
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
/* Show the tooltip text when you mouse over the tooltip container */
|
|
506
|
-
.Toolbar-button:hover .tooltiptext {
|
|
507
|
-
animation: 0.8s fadeIn2;
|
|
508
|
-
animation-fill-mode: forwards;
|
|
509
|
-
visibility: visible;
|
|
510
|
-
/* width: 100px; */
|
|
511
|
-
/* top: -90%; */ /* Must leave a small gap between tooltip and button */
|
|
512
|
-
/* left: 20%; */
|
|
513
|
-
/* margin-left: -50px; */
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
@keyframes fadeIn2 {
|
|
517
|
-
00% {
|
|
518
|
-
opacity: 0;
|
|
519
|
-
}
|
|
520
|
-
70% {
|
|
521
|
-
opacity: 0;
|
|
522
|
-
}
|
|
523
|
-
100% {
|
|
524
|
-
visibility: visible;
|
|
525
|
-
opacity: 0.9;
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
/* .tooltip {
|
|
530
|
-
position: relative;
|
|
531
|
-
display: inline-block;
|
|
532
|
-
border-bottom: 1px dotted black; /* If you want dots under the hoverable text
|
|
533
|
-
} */
|
|
534
532
|
.EquationEditor {
|
|
535
533
|
height: auto;
|
|
536
534
|
text-align: center;
|
package/package.json
CHANGED
package/src/AccentBar.css
CHANGED
|
@@ -1,28 +1,27 @@
|
|
|
1
1
|
/* Note that the top left position of the accent bar is set programatically in componentDidMount */
|
|
2
2
|
|
|
3
3
|
.AccentBar {
|
|
4
|
-
position:
|
|
4
|
+
position: absolute;
|
|
5
5
|
z-index: 1;
|
|
6
6
|
width: 360px;
|
|
7
7
|
background-color: #fff;
|
|
8
8
|
border: 1px solid #d0d0d0;
|
|
9
9
|
border-radius: 5px;
|
|
10
10
|
box-shadow: 1px 1px 5px #a0a0a0;
|
|
11
|
-
padding:
|
|
11
|
+
padding: 8px;
|
|
12
12
|
animation: 0.4s fadeIn1;
|
|
13
13
|
animation-fill-mode: forwards;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
.AccentBar-compact {
|
|
17
|
-
|
|
17
|
+
display: flex;
|
|
18
|
+
position: absolute;
|
|
18
19
|
z-index: 1;
|
|
19
20
|
background-color: white;
|
|
20
21
|
border: 1px solid #d0d0d0;
|
|
21
22
|
border-radius: 5px;
|
|
22
23
|
box-shadow: 1px 1px 5px #a0a0a0;
|
|
23
24
|
padding: 5px;
|
|
24
|
-
top: 0px;
|
|
25
|
-
left: 0px; /* Important to set this default so that accent bar renders to optimal width */
|
|
26
25
|
animation: 0.4s fadeIn1;
|
|
27
26
|
animation-fill-mode: forwards;
|
|
28
27
|
}
|
package/src/AccentBar.jsx
CHANGED
|
@@ -3,7 +3,7 @@ import React from "react";
|
|
|
3
3
|
import "./AccentBar.css";
|
|
4
4
|
|
|
5
5
|
const DEFAULT_TOP = -1;
|
|
6
|
-
const
|
|
6
|
+
const DEFAULT_RIGHT = -1;
|
|
7
7
|
const TOP_MARGIN = 3;
|
|
8
8
|
|
|
9
9
|
const ACCENTS_FOR_LETTER = {
|
|
@@ -566,7 +566,8 @@ export default class AccentBar extends React.Component {
|
|
|
566
566
|
this.state = {
|
|
567
567
|
selectedTab: GLOBAL_last_selected_tab,
|
|
568
568
|
top: DEFAULT_TOP,
|
|
569
|
-
|
|
569
|
+
right: DEFAULT_RIGHT,
|
|
570
|
+
shouldHorizontiallyAlign: false,
|
|
570
571
|
};
|
|
571
572
|
this.suppliedClickHandler = null;
|
|
572
573
|
this.handleButtonClick = this.handleButtonClick.bind(this);
|
|
@@ -586,6 +587,17 @@ export default class AccentBar extends React.Component {
|
|
|
586
587
|
else this.suppliedClickHandler(e, this.letterForAccents, character);
|
|
587
588
|
};
|
|
588
589
|
|
|
590
|
+
isInViewport = (element) => {
|
|
591
|
+
const rect = element.getBoundingClientRect();
|
|
592
|
+
return (
|
|
593
|
+
rect.top >= 0 &&
|
|
594
|
+
rect.left >= 0 &&
|
|
595
|
+
rect.bottom <=
|
|
596
|
+
(window.innerHeight || document.documentElement.clientHeight) &&
|
|
597
|
+
rect.right <= (window.innerWidth || document.documentElement.clientWidth)
|
|
598
|
+
);
|
|
599
|
+
};
|
|
600
|
+
|
|
589
601
|
componentDidMount() {
|
|
590
602
|
// We render once to find out the component's preferred size and then render again to update it
|
|
591
603
|
|
|
@@ -606,28 +618,30 @@ export default class AccentBar extends React.Component {
|
|
|
606
618
|
return;
|
|
607
619
|
}
|
|
608
620
|
|
|
609
|
-
|
|
610
|
-
|
|
621
|
+
const toolBarBounds = thisBar.parentNode.getBoundingClientRect();
|
|
622
|
+
const inputBounds = node.getBoundingClientRect();
|
|
623
|
+
const thisBounds = thisBar.getBoundingClientRect();
|
|
611
624
|
|
|
612
625
|
this.shouldUpdatePosition = false;
|
|
613
626
|
|
|
614
627
|
// Vertically align below input field
|
|
615
|
-
let top = inputBounds.bottom
|
|
628
|
+
let top = inputBounds.bottom - toolBarBounds.height;
|
|
629
|
+
if (this.props.compactMode) top = inputBounds.height;
|
|
616
630
|
|
|
617
|
-
// Horizontally align
|
|
618
|
-
let
|
|
619
|
-
if (this.props.compactMode) left = inputBounds.left; // left align
|
|
631
|
+
// Horizontally align
|
|
632
|
+
let right = 0; // right align
|
|
620
633
|
|
|
621
634
|
// Make sure it is on screen horizontally
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
if (left + thisBounds.width > window.innerWidth)
|
|
626
|
-
left = window.innerWidth - thisBounds.width - 2;
|
|
635
|
+
let shouldHorizontiallyAlign = false;
|
|
636
|
+
if (thisBounds.width > inputBounds.width) {
|
|
637
|
+
shouldHorizontiallyAlign = true;
|
|
627
638
|
|
|
628
|
-
|
|
639
|
+
if (this.isInViewport(thisBar)) {
|
|
640
|
+
right = right - (thisBounds.width - inputBounds.width) / 2;
|
|
641
|
+
} // else remain right aligned
|
|
642
|
+
}
|
|
629
643
|
|
|
630
|
-
this.setState({
|
|
644
|
+
this.setState({ right, top, shouldHorizontiallyAlign });
|
|
631
645
|
} else {
|
|
632
646
|
this.shouldUpdatePosition = true;
|
|
633
647
|
}
|
|
@@ -639,7 +653,6 @@ export default class AccentBar extends React.Component {
|
|
|
639
653
|
};
|
|
640
654
|
|
|
641
655
|
componentDidUpdate = (prevProps) => {
|
|
642
|
-
// console.log("componentDidUpdate")
|
|
643
656
|
let accentKey = this.props.keyPressed;
|
|
644
657
|
if (
|
|
645
658
|
accentKey === "Backspace" ||
|
|
@@ -692,8 +705,10 @@ export default class AccentBar extends React.Component {
|
|
|
692
705
|
|
|
693
706
|
// Set up the tranlation to place the accent bar where we want it
|
|
694
707
|
let style = { ...this.props.style };
|
|
695
|
-
if (this.state.
|
|
696
|
-
|
|
708
|
+
if (this.state.right !== DEFAULT_RIGHT || this.state.top !== DEFAULT_TOP) {
|
|
709
|
+
if (!this.props.compactMode || this.state.shouldHorizontiallyAlign) {
|
|
710
|
+
style.right = this.state.right + "px";
|
|
711
|
+
}
|
|
697
712
|
style.top = this.state.top + "px";
|
|
698
713
|
}
|
|
699
714
|
|
|
@@ -708,7 +723,7 @@ export default class AccentBar extends React.Component {
|
|
|
708
723
|
>
|
|
709
724
|
{/* Compact mode */}
|
|
710
725
|
{compactMode && (
|
|
711
|
-
|
|
726
|
+
<>
|
|
712
727
|
{quickAccents.map((character, index) => {
|
|
713
728
|
return (
|
|
714
729
|
<button
|
|
@@ -722,7 +737,7 @@ export default class AccentBar extends React.Component {
|
|
|
722
737
|
</button>
|
|
723
738
|
);
|
|
724
739
|
})}
|
|
725
|
-
|
|
740
|
+
</>
|
|
726
741
|
)}
|
|
727
742
|
|
|
728
743
|
{/* Normal mode */}
|
package/src/MathRichInput.css
CHANGED
|
@@ -18,10 +18,9 @@
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
.MathRichInput-scrollview {
|
|
21
|
+
position: relative;
|
|
21
22
|
display: flex;
|
|
22
|
-
overflow: scroll;
|
|
23
23
|
border-radius: 5px;
|
|
24
|
-
overflow: overlay;
|
|
25
24
|
}
|
|
26
25
|
|
|
27
26
|
.MathRichInput p {
|
|
@@ -35,6 +34,8 @@
|
|
|
35
34
|
width: 100%;
|
|
36
35
|
border-radius: 5px;
|
|
37
36
|
background-color: #fff;
|
|
37
|
+
overflow-x: scroll;
|
|
38
|
+
overflow: overlay;
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
.MathRichInput:focus {
|
package/src/Toolbar.css
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* Note that the top left position of the toolbar is set programatically in componentDidMount */
|
|
2
2
|
|
|
3
3
|
.Toolbar {
|
|
4
|
-
position:
|
|
4
|
+
position: absolute;
|
|
5
5
|
z-index: 1;
|
|
6
6
|
display: flex;
|
|
7
7
|
height: 42px;
|
|
@@ -11,8 +11,6 @@
|
|
|
11
11
|
box-shadow: 1px 1px 5px #a0a0a0;
|
|
12
12
|
animation: 0.5s fadeIn1;
|
|
13
13
|
animation-fill-mode: forwards;
|
|
14
|
-
top: 0px;
|
|
15
|
-
left: 0px; /* important to set this so that toolbar initially renders full width */
|
|
16
14
|
}
|
|
17
15
|
|
|
18
16
|
@keyframes fadeIn1 {
|
package/src/Toolbar.jsx
CHANGED
|
@@ -5,9 +5,8 @@ import AccentBar from "./AccentBar";
|
|
|
5
5
|
|
|
6
6
|
import "./Toolbar.css";
|
|
7
7
|
|
|
8
|
-
// const DEFAULT_TRANSLATE = 0
|
|
9
8
|
const DEFAULT_TOP = 0;
|
|
10
|
-
const
|
|
9
|
+
const DEFAULT_RIGHT = 0;
|
|
11
10
|
const BOTTOM_MARGIN = 5;
|
|
12
11
|
|
|
13
12
|
const CTRL_OR_META = /(Mac)/i.test(window.navigator.platform)
|
|
@@ -21,7 +20,8 @@ export default class Toolbar extends React.Component {
|
|
|
21
20
|
this.state = {
|
|
22
21
|
showAccents: false,
|
|
23
22
|
top: DEFAULT_TOP,
|
|
24
|
-
|
|
23
|
+
right: DEFAULT_RIGHT,
|
|
24
|
+
shouldHorizontiallyAlign: false,
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
this.handleButtonClick = this.handleButtonClick.bind(this);
|
|
@@ -66,6 +66,17 @@ export default class Toolbar extends React.Component {
|
|
|
66
66
|
// this.hideAccentBar(null)
|
|
67
67
|
};
|
|
68
68
|
|
|
69
|
+
isInViewport = (element) => {
|
|
70
|
+
const rect = element.getBoundingClientRect();
|
|
71
|
+
return (
|
|
72
|
+
rect.top >= 0 &&
|
|
73
|
+
rect.left >= 0 &&
|
|
74
|
+
rect.bottom <=
|
|
75
|
+
(window.innerHeight || document.documentElement.clientHeight) &&
|
|
76
|
+
rect.right <= (window.innerWidth || document.documentElement.clientWidth)
|
|
77
|
+
);
|
|
78
|
+
};
|
|
79
|
+
|
|
69
80
|
componentDidMount() {
|
|
70
81
|
// We render once to find out the component's preferred size and then render again to update it
|
|
71
82
|
if (this.shouldUpdatePosition) {
|
|
@@ -91,21 +102,21 @@ export default class Toolbar extends React.Component {
|
|
|
91
102
|
this.shouldUpdatePosition = false;
|
|
92
103
|
|
|
93
104
|
// Vertically align above input field
|
|
94
|
-
let top =
|
|
105
|
+
let top = (thisBounds.height + BOTTOM_MARGIN) * -1;
|
|
95
106
|
|
|
96
|
-
// Horizontally align
|
|
97
|
-
let
|
|
107
|
+
// Horizontally align
|
|
108
|
+
let right = 0; // right align
|
|
98
109
|
|
|
99
|
-
|
|
100
|
-
if (thisBounds.width > inputBounds.width)
|
|
101
|
-
|
|
110
|
+
let shouldHorizontiallyAlign = false;
|
|
111
|
+
if (thisBounds.width > inputBounds.width) {
|
|
112
|
+
shouldHorizontiallyAlign = true;
|
|
102
113
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
114
|
+
if (this.isInViewport(thisBar)) {
|
|
115
|
+
right = right - (thisBounds.width - inputBounds.width) / 2;
|
|
116
|
+
} // else remain right aligned
|
|
117
|
+
}
|
|
107
118
|
|
|
108
|
-
this.setState({
|
|
119
|
+
this.setState({ right, top, shouldHorizontiallyAlign });
|
|
109
120
|
} else {
|
|
110
121
|
this.shouldUpdatePosition = true;
|
|
111
122
|
}
|
|
@@ -133,8 +144,10 @@ export default class Toolbar extends React.Component {
|
|
|
133
144
|
// if (this.state.translateX !== DEFAULT_TRANSLATE) {
|
|
134
145
|
// style.transform = "translate("+this.state.translateX+"px, "+this.state.translateY+"px)";
|
|
135
146
|
// }
|
|
136
|
-
if (this.state.
|
|
137
|
-
|
|
147
|
+
if (this.state.right !== DEFAULT_RIGHT || this.state.top !== DEFAULT_TOP) {
|
|
148
|
+
if (!this.props.compactMode || this.state.shouldHorizontiallyAlign) {
|
|
149
|
+
style.right = this.state.right + "px";
|
|
150
|
+
}
|
|
138
151
|
style.top = this.state.top + "px";
|
|
139
152
|
}
|
|
140
153
|
|