@zzish/math-rich-input 0.1.4 → 0.1.5

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.
@@ -1,9 +1,8 @@
1
-
2
1
  .EquationEditorModal-background {
3
2
  position: fixed;
4
3
  top: 0;
5
4
  left: 0;
6
- width:100%;
5
+ width: 100%;
7
6
  height: 100%;
8
7
  background: black;
9
8
  z-index: 99;
@@ -12,24 +11,24 @@
12
11
  }
13
12
 
14
13
  @keyframes shade {
15
- 00% {
16
- opacity: 0;
17
- }
18
- 100% {
19
- opacity: 0.6;
20
- }
14
+ 00% {
15
+ opacity: 0;
16
+ }
17
+ 100% {
18
+ opacity: 0.6;
19
+ }
21
20
  }
22
21
 
23
22
  .EquationEditorModal {
24
23
  background: white;
25
- border:1px solid #808080;
26
- border-radius:10px;
24
+ border: 1px solid #808080;
25
+ border-radius: 10px;
27
26
  box-shadow: 0px 2px 5px 1px #a0a0a0;
28
- position:fixed;
29
- max-width:500px;
27
+ position: fixed;
28
+ max-width: 500px;
30
29
  width: 98%;
31
- top:50%;
32
- left:50%;
30
+ top: 50%;
31
+ left: 50%;
33
32
  /* transform: translate(-50%,-50%); */
34
33
  z-index: 100;
35
34
  animation: 0.3s rise;
@@ -37,26 +36,26 @@
37
36
  }
38
37
 
39
38
  @keyframes rise {
40
- 00% {
41
- transform: translate(-50%,100%);
42
- opacity:0.0;
43
- }
44
- 100% {
45
- transform: translate(-50%,-50%);
46
- opacity:1.0;
47
- }
39
+ 00% {
40
+ transform: translate(-50%, 100%);
41
+ opacity: 0;
42
+ }
43
+ 100% {
44
+ transform: translate(-50%, -50%);
45
+ opacity: 1;
46
+ }
48
47
  }
49
48
 
50
49
  .EquationEditorModal-mobile {
51
50
  background: white;
52
- border:1px solid #808080;
53
- border-radius:10px;
51
+ border: 1px solid #808080;
52
+ border-radius: 10px;
54
53
  box-shadow: 0px 2px 5px 1px #a0a0a0;
55
- position:fixed;
56
- max-width:500px;
54
+ position: fixed;
55
+ max-width: 500px;
57
56
  width: 99%;
58
- top:0%;
59
- left:50%;
57
+ top: 0%;
58
+ left: 50%;
60
59
  transform: translate(-50%, 1px);
61
60
  z-index: 100;
62
61
  }
@@ -65,37 +64,35 @@
65
64
  font-size: 14px;
66
65
  color: #404040;
67
66
  text-align: left;
68
- background: #E0E0E0;
69
- border:0px;
70
- border-radius:5px 5px 0px 0px;
71
- height:30px;
72
- padding:20px 0px 5px 20px;
73
- margin:0px;
67
+ background: #e0e0e0;
68
+ border: 0px;
69
+ border-radius: 5px 5px 0px 0px;
70
+ padding: 15px;
71
+ margin: 0px;
74
72
  }
75
73
 
76
74
  .EquationEditorModal-mobile .title {
77
75
  font-size: 14px;
78
76
  color: #404040;
79
77
  text-align: left;
80
- background: #E0E0E0;
81
- border:0px;
82
- border-radius:5px 5px 0px 0px;
83
- height:30px;
84
- padding:20px 0px 5px 20px;
85
- margin:0px;
78
+ background: #e0e0e0;
79
+ border: 0px;
80
+ border-radius: 5px 5px 0px 0px;
81
+ height: 30px;
82
+ padding: 15px;
83
+ margin: 0px;
86
84
  }
87
85
 
88
86
  .EquationEditorModal .expertModeSwitch {
89
- /* background: url(images/settings-icon.png) no-repeat; */
90
- float:right;
87
+ /* background: url(images/settings-icon.png) no-repeat; */
88
+ float: right;
91
89
  /* width:36px;
92
90
  height:36px; */
93
91
  }
94
92
 
95
- .EquationEditorModal .expertModeSwitch .switch{
96
- margin-right:10px;
97
- margin-left:10px;
98
-
93
+ .EquationEditorModal .expertModeSwitch .switch {
94
+ margin-right: 10px;
95
+ margin-left: 10px;
99
96
  }
100
97
 
101
98
  /* The switch - the box around the slider */
@@ -122,8 +119,8 @@
122
119
  right: 0;
123
120
  bottom: 0;
124
121
  background-color: #ccc;
125
- -webkit-transition: .4s;
126
- transition: .4s;
122
+ -webkit-transition: 0.4s;
123
+ transition: 0.4s;
127
124
  }
128
125
 
129
126
  .slider:before {
@@ -134,18 +131,17 @@
134
131
  left: 4px;
135
132
  bottom: 4px;
136
133
  background-color: white;
137
- -webkit-transition: .4s;
138
- transition: .4s;
134
+ -webkit-transition: 0.4s;
135
+ transition: 0.4s;
139
136
  }
140
137
 
141
138
  input:checked + .slider {
142
139
  background-color: #663676;
143
- ;
144
140
  /* background-color: #2196F3; */
145
141
  }
146
142
 
147
143
  input:focus + .slider {
148
- box-shadow: 0 0 1px #2196F3;
144
+ box-shadow: 0 0 1px #2196f3;
149
145
  }
150
146
 
151
147
  input:checked + .slider:before {
@@ -161,4 +157,4 @@ input:checked + .slider:before {
161
157
 
162
158
  .slider.round:before {
163
159
  border-radius: 50%;
164
- }
160
+ }
@@ -1,25 +1,32 @@
1
+ *,
2
+ :after,
3
+ :before {
4
+ -webkit-box-sizing: border-box;
5
+ -moz-box-sizing: border-box;
6
+ box-sizing: border-box;
7
+ }
8
+
1
9
  .MathRichInput-Container {
2
- margin:10px;
3
- border-radius:5px;
10
+ margin: 10px;
11
+ border-radius: 5px;
4
12
  }
5
13
 
6
14
  .MathRichInput-Container:focus-within {
7
- background-color: white!important;
15
+ background-color: white !important;
8
16
  outline: 0px;
9
- border:1px solid #663676;
10
- /* box-shadow: inset 1px 1px 5px #a0a0a0; */
17
+ border: 1px solid #663676;
11
18
  }
12
19
 
13
20
  .MathRichInput-scrollview {
14
- display:flex;
15
- overflow:scroll;
16
- border-radius:5px;
21
+ display: flex;
22
+ overflow: scroll;
23
+ border-radius: 5px;
17
24
  overflow: overlay;
18
25
  }
19
26
 
20
- .MathRichInput P {
21
- padding:0px;
22
- margin:0px
27
+ .MathRichInput p {
28
+ padding: 0px;
29
+ margin: 0px;
23
30
  }
24
31
 
25
32
  .MathRichInput {
@@ -27,29 +34,30 @@
27
34
  padding: 10px;
28
35
  width: 100%;
29
36
  border-radius: 5px;
37
+ background-color: #fff;
30
38
  }
31
39
 
32
40
  .MathRichInput:focus {
33
- outline:0;
41
+ outline: 0;
34
42
  }
35
43
 
36
44
  .MathRichInput .katex {
37
- border:0px;
45
+ border: 0px;
38
46
  }
39
47
 
40
- .MathRichInput .base { /* Combine the katex and base class name to ensure the whole equation is surrounded */
48
+ .MathRichInput .base {
49
+ /* Combine the katex and base class name to ensure the whole equation is surrounded */
41
50
  background-color: #f0f0f0;
42
51
  border: 0px;
43
- border: 1px dotted #D0D0D0;
52
+ border: 1px dotted #d0d0d0;
44
53
  border-radius: 5px;
45
- padding: 2px 2px 2px 2px;
46
- margin: 0px 2px 0px 2px;
54
+ padding: 2px;
55
+ margin: 0px 2px;
47
56
  }
48
57
 
49
58
  .katex .mathnormal {
50
- /* font-family: KaTeX_Caligraphic; */
51
- font-family: KaTeX_Math;
52
- font-style: italic;
59
+ font-family: KaTeX_Math;
60
+ font-style: italic;
53
61
  }
54
62
 
55
63
  .MathRichInput .katex-error {
@@ -57,7 +65,6 @@
57
65
  border: 0px;
58
66
  border: 1px dotted #ff8080;
59
67
  border-radius: 5px;
60
- padding: 2px 2px 2px 2px;
61
- margin: 0px 2px 0px 2px;
68
+ padding: 2px;
69
+ margin: 0px 2px;
62
70
  }
63
-
@@ -9,29 +9,30 @@
9
9
  } */
10
10
 
11
11
  .SymbolButton {
12
+ display: inline-block;
12
13
  overflow: hidden; /* Important to fix a bug where katex renders parts of the equation outside the box */
13
14
  font-size: 14px;
14
15
  font-weight: bold;
15
16
  color: #202020;
16
17
  background: #e0e0e0;
17
18
  text-align: center;
18
- border:0px;
19
+ border: 0px;
19
20
  border-radius: 5px;
20
- width:36px;
21
- height:36px;
22
- padding:1px 1px 1px 1px;
23
- margin:3px;
21
+ width: 36px;
22
+ height: 36px;
23
+ padding: 1px;
24
+ margin: 3px;
25
+ margin-bottom: auto;
24
26
  /* transition: all .2s ease-in-out; */
25
27
  }
26
28
 
27
-
28
29
  .SymbolButton:hover {
29
- filter: saturate(2.0);
30
+ filter: saturate(2);
30
31
  color: black;
31
32
  /* transform: scale(1.3); */
32
33
  cursor: pointer;
33
34
  box-shadow: 1px 1px 3px #808080;
34
- animation: 2s grow;
35
+ animation: 2s grow;
35
36
  animation-fill-mode: forwards;
36
37
  }
37
38
 
@@ -39,7 +40,7 @@
39
40
  00% {
40
41
  transform: scale(1);
41
42
  box-shadow: 0px 0px 0px #808080;
42
- }
43
+ }
43
44
  10% {
44
45
  transform: scale(1.3);
45
46
  box-shadow: 1px 1px 3px #808080;
@@ -62,13 +63,13 @@
62
63
  }
63
64
 
64
65
  .SymbolButton-fadeIn {
65
- opacity:1;
66
- width:100px;
67
- height:100px;
66
+ opacity: 1;
67
+ width: 100px;
68
+ height: 100px;
68
69
  transition: width 0.5s, height 0.5s, opacity 0.5s 0.5s;
69
70
  }
70
71
 
71
- .highlight-0{
72
+ .highlight-0 {
72
73
  background: #ebc9eb;
73
74
  /* background: #80e0e0; */
74
75
  }
@@ -80,51 +81,50 @@
80
81
  background: #c0e0e0;
81
82
  } */
82
83
 
83
-
84
- .highlight-operators{
85
- background: #F8e8D8;
84
+ .highlight-operators {
85
+ background: #f8e8d8;
86
86
  }
87
87
 
88
- .highlight-angles{
88
+ .highlight-angles {
89
89
  background: #cceded;
90
90
  }
91
91
 
92
- .highlight-greeklower{
93
- background: #F8e8D8;
92
+ .highlight-greeklower {
93
+ background: #f8e8d8;
94
94
  }
95
95
 
96
- .highlight-greekupper{
96
+ .highlight-greekupper {
97
97
  background: #cceded;
98
98
  }
99
99
 
100
- .highlight-misc{
101
- background: #F8e8D8;
100
+ .highlight-misc {
101
+ background: #f8e8d8;
102
102
  }
103
103
 
104
- .highlight-sets{
104
+ .highlight-sets {
105
105
  background: #cceded;
106
106
  }
107
107
 
108
- .highlight-chemistry{
109
- background: #F8e8D8;
108
+ .highlight-chemistry {
109
+ background: #f8e8d8;
110
110
  }
111
111
 
112
- .highlight-elements{
112
+ .highlight-elements {
113
113
  background: #cceded;
114
114
  }
115
115
 
116
- .highlight-physics2{
117
- background: #F8e8D8;
116
+ .highlight-physics2 {
117
+ background: #f8e8d8;
118
118
  }
119
119
 
120
- .highlight-physics3{
120
+ .highlight-physics3 {
121
121
  background: #cceded;
122
122
  }
123
123
 
124
- .highlight-expert{
124
+ .highlight-expert {
125
125
  background: #f4d6f5;
126
126
  }
127
127
 
128
- .highlight-matrices{
128
+ .highlight-matrices {
129
129
  background: #f4d6f5;
130
130
  }
@@ -1,96 +1,94 @@
1
- import React from 'react'
1
+ import React from "react";
2
2
 
3
3
  import katex from "katex";
4
4
 
5
- import './SymbolButton.css';
6
-
5
+ import "./SymbolButton.css";
7
6
 
8
7
  import {
9
- getSymbolButtonLatex,
8
+ getSymbolButtonLatex,
10
9
  getSymbolButtonScaling,
11
10
  // getSymbolButtonTooltip,
12
11
  getSymbolButtonHtml,
13
- setSymbolButtonHtml
14
- } from './equationEditorButtonsHelper.js';
12
+ setSymbolButtonHtml,
13
+ } from "./equationEditorButtonsHelper.js";
15
14
 
16
15
  export default class SymbolButton extends React.Component {
17
-
18
16
  // This is a fixed component that never changes
19
17
  shouldComponentUpdate() {
20
- if (this.props.shouldUpdate)
21
- return this.props.shouldUpdate
22
- return false
18
+ if (this.props.shouldUpdate) return this.props.shouldUpdate;
19
+ return false;
23
20
  }
24
21
 
25
-
26
22
  constructor(props) {
27
23
  super(props);
28
- this.suppliedClickHandler = null
24
+ this.suppliedClickHandler = null;
29
25
  }
30
26
 
31
27
  static getButtonForDescendent(element) {
32
28
  while (element && element.tagName.toLowerCase() !== "button")
33
29
  element = element.parentNode;
34
- return element
30
+ return element;
35
31
  }
36
32
 
37
33
  static getSymbolName(element) {
38
- var button = SymbolButton.getButtonForDescendent(element)
39
- if (button)
40
- return button.getAttribute("name")
41
- return null
34
+ var button = SymbolButton.getButtonForDescendent(element);
35
+ if (button) return button.getAttribute("name");
36
+ return null;
42
37
  }
43
38
 
44
39
  handleSymbolButtonMouseDown = (event) => {
45
- event.preventDefault()
46
- }
40
+ event.preventDefault();
41
+ };
47
42
 
48
43
  handleSymbolButtonClick = (event) => {
49
- this.suppliedClickHandler(event)
50
- event.preventDefault()
51
- }
44
+ this.suppliedClickHandler(event);
45
+ event.preventDefault();
46
+ };
52
47
 
53
48
  render() {
54
49
  // const {symbol} = this.props;
55
- const {symbol, handleClick} = this.props;
56
- this.suppliedClickHandler = handleClick
50
+ const { symbol, handleClick } = this.props;
51
+ this.suppliedClickHandler = handleClick;
57
52
 
58
- const fontSize = (14*getSymbolButtonScaling(symbol))/100
59
- var buttonStyle = {fontSize: fontSize+'px'};
53
+ const fontSize = (14 * getSymbolButtonScaling(symbol)) / 100;
54
+ var buttonStyle = { fontSize: fontSize + "px" };
60
55
  // const tooltipText = getSymbolButtonTooltip(symbol)
61
56
 
62
- let katexHTML = getSymbolButtonHtml(symbol)
57
+ let katexHTML = getSymbolButtonHtml(symbol);
63
58
  if (katexHTML === undefined || katexHTML === null) {
64
- let latex = getSymbolButtonLatex(symbol)
65
- katexHTML = katex.renderToString(latex)
59
+ let latex = getSymbolButtonLatex(symbol);
60
+ katexHTML = katex.renderToString(latex);
66
61
 
67
62
  // Not necessary, but lets clean out some unnessary mathml nodes
68
- let start = katexHTML.indexOf("<span class=\"katex-mathml\">")
69
- let end = -1
70
- if (start > 0)
71
- end = katexHTML.indexOf("</math></span>",start+30)
63
+ let start = katexHTML.indexOf('<span class="katex-mathml">');
64
+ let end = -1;
65
+ if (start > 0) end = katexHTML.indexOf("</math></span>", start + 30);
72
66
  if (end > 0)
73
- katexHTML = katexHTML.substring(0,start) + katexHTML.substring(end+14)
67
+ katexHTML =
68
+ katexHTML.substring(0, start) + katexHTML.substring(end + 14);
74
69
 
75
- setSymbolButtonHtml(symbol, katexHTML)
70
+ setSymbolButtonHtml(symbol, katexHTML);
76
71
  }
77
72
 
78
- let useClassName = "SymbolButton"
73
+ let useClassName = "SymbolButton";
79
74
  if (this.props.highlight) {
80
- useClassName = useClassName+" highlight-"+this.props.highlight
75
+ useClassName = useClassName + " highlight-" + this.props.highlight;
81
76
  }
82
77
 
83
- return (
84
- <span id='SymbolButton'>
85
- <button name={symbol}
86
- className={useClassName} style={buttonStyle}
87
- onMouseDown={this.handleSymbolButtonMouseDown}
88
- onClick={this.handleSymbolButtonClick}
89
- ref={(e) => { this.button = e; }}>
90
- <div name={symbol} dangerouslySetInnerHTML={{__html: katexHTML}} />
91
- {/* <span className="tooltiptext">{tooltipText}</span> */}
92
- </button>
93
- </span>
94
- )
78
+ return (
79
+ <button
80
+ name={symbol}
81
+ className={useClassName}
82
+ style={buttonStyle}
83
+ onMouseDown={this.handleSymbolButtonMouseDown}
84
+ onClick={this.handleSymbolButtonClick}
85
+ ref={(e) => {
86
+ this.button = e;
87
+ }}
88
+ >
89
+ <div name={symbol} dangerouslySetInnerHTML={{ __html: katexHTML }} />
90
+ {/* <span className="tooltiptext">{tooltipText}</span> */}
91
+ </button>
92
+ );
95
93
  }
96
94
  }