@zzish/math-rich-input 0.1.4 → 0.1.6

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.
@@ -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
  }
package/src/Toolbar.css CHANGED
@@ -3,31 +3,31 @@
3
3
  .Toolbar {
4
4
  position: fixed;
5
5
  z-index: 1;
6
- /* width:270px; */
7
- height:42px;
6
+ display: flex;
7
+ height: 42px;
8
8
  background-color: white;
9
9
  border: 1px solid #d0d0d0;
10
10
  border-radius: 5px;
11
11
  box-shadow: 1px 1px 5px #a0a0a0;
12
- animation: 0.5s fadeIn1;
12
+ animation: 0.5s fadeIn1;
13
13
  animation-fill-mode: forwards;
14
14
  top: 0px;
15
- left: 0px; /* important to set this so that toolbar initially renders full width */
15
+ left: 0px; /* important to set this so that toolbar initially renders full width */
16
16
  }
17
17
 
18
18
  @keyframes fadeIn1 {
19
19
  0% {
20
20
  opacity: 0;
21
- }
21
+ }
22
22
  100% {
23
- opacity: 1.0;
23
+ opacity: 1;
24
24
  }
25
25
  }
26
26
 
27
27
  .Toolbar-button {
28
- font-family:sans-serif;
28
+ font-family: sans-serif;
29
29
  font-size: 16px;
30
- width:40px;
30
+ width: 40px;
31
31
  height: 36px;
32
32
  background-color: white;
33
33
  border-radius: 5px;
@@ -36,7 +36,6 @@
36
36
  margin: 2px;
37
37
  }
38
38
 
39
-
40
39
  .Toolbar-button:hover {
41
40
  color: white;
42
41
  background: #663676;
@@ -50,23 +49,18 @@
50
49
  }
51
50
 
52
51
  .TB-narrow {
53
- width:30px;
52
+ width: 30px;
54
53
  }
55
54
 
56
55
  .TB-wide {
57
- width:46px;
58
- }
59
-
60
- .TB-up4 {
61
- position: relative;
62
- top:-4px;
56
+ width: 46px;
63
57
  }
64
58
 
65
59
  .TB-selected {
66
- background: #D0D0D0;
60
+ background: #d0d0d0;
67
61
  color: black;
68
62
  cursor: pointer;
69
- animation: 0.2s TB-fadeIn;
63
+ animation: 0.2s TB-fadeIn;
70
64
  animation-fill-mode: forwards;
71
65
  }
72
66
 
@@ -79,13 +73,12 @@
79
73
  @keyframes TB-fadeIn {
80
74
  00% {
81
75
  background: white;
82
- }
76
+ }
83
77
  100% {
84
- background: #D0D0D0;
78
+ background: #d0d0d0;
85
79
  }
86
80
  }
87
81
 
88
-
89
82
  /* Tooltip text */
90
83
  .Toolbar-button .tooltiptext {
91
84
  font-weight: normal;
@@ -98,11 +91,11 @@
98
91
  text-align: center;
99
92
  padding: 4px 10px;
100
93
  border-radius: 6px;
101
-
94
+
102
95
  /* Position the tooltip text - see examples below! */
103
96
  position: absolute;
104
97
  z-index: 2;
105
- top: -90%; /* Must leave a small gap between tooltip and button */
98
+ top: -90%; /* Must leave a small gap between tooltip and button */
106
99
  left: 50px;
107
100
 
108
101
  /* transform: translate (50%,0%); */
@@ -110,11 +103,11 @@
110
103
 
111
104
  /* Show the tooltip text when you mouse over the tooltip container */
112
105
  .Toolbar-button:hover .tooltiptext {
113
- animation: 0.8s fadeIn2;
106
+ animation: 0.8s fadeIn2;
114
107
  animation-fill-mode: forwards;
115
108
  visibility: visible;
116
109
  /* width: 100px; */
117
- /* top: -90%; */ /* Must leave a small gap between tooltip and button */
110
+ /* top: -90%; */ /* Must leave a small gap between tooltip and button */
118
111
  /* left: 20%; */
119
112
  /* margin-left: -50px; */
120
113
  }
@@ -122,10 +115,10 @@
122
115
  @keyframes fadeIn2 {
123
116
  00% {
124
117
  opacity: 0;
125
- }
118
+ }
126
119
  70% {
127
120
  opacity: 0;
128
- }
121
+ }
129
122
  100% {
130
123
  visibility: visible;
131
124
  opacity: 0.9;
@@ -137,6 +130,3 @@
137
130
  display: inline-block;
138
131
  border-bottom: 1px dotted black; /* If you want dots under the hoverable text
139
132
  } */
140
-
141
-
142
-