@zzish/math-rich-input 0.1.39 → 0.1.41

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 CHANGED
@@ -22718,7 +22718,7 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
22718
22718
  _defineProperty(_assertThisInitialized(_this2), "handleInput", function (event) {
22719
22719
  try {
22720
22720
  // console.log("handleInput")
22721
- if (event.nativeEvent.isComposing) return;
22721
+ if (_this2.isComposing) return;
22722
22722
  var raw_text = elementToMarkedRawText(_this2.editableDiv, null, 0, _this2.enableHtml());
22723
22723
 
22724
22724
  var params = _this2._getRangeParams();
@@ -23547,6 +23547,14 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
23547
23547
  }
23548
23548
  });
23549
23549
 
23550
+ _defineProperty(_assertThisInitialized(_this2), "handleCompositionStart", function (event) {
23551
+ _this2.isComposing = true;
23552
+ });
23553
+
23554
+ _defineProperty(_assertThisInitialized(_this2), "handleCompositionEnd", function (event) {
23555
+ _this2.isComposing = false;
23556
+ });
23557
+
23550
23558
  _this2.state = {
23551
23559
  showEquationEditor: false,
23552
23560
  equationEditorLatex: "",
@@ -23593,7 +23601,9 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
23593
23601
  _this2.initialHistoryState = null;
23594
23602
  _this2.undoHistory = [];
23595
23603
  _this2.redoHistory = [];
23596
- _this2.accent = "";
23604
+ _this2.accent = ""; // keeps track of whether user is composing in an IME - see https://developer.mozilla.org/en-US/docs/Web/API/CompositionEvent
23605
+
23606
+ _this2.isComposing = false;
23597
23607
  return _this2;
23598
23608
  }
23599
23609
 
@@ -23803,6 +23813,8 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
23803
23813
  onMouseUp: this.handleMouseUp,
23804
23814
  onFocus: this.handleFocus,
23805
23815
  onBlur: this.handleBlur,
23816
+ onCompositionStart: this.handleCompositionStart,
23817
+ onCompositionEnd: this.handleCompositionEnd,
23806
23818
  dangerouslySetInnerHTML: {
23807
23819
  __html: html
23808
23820
  },
@@ -11,11 +11,7 @@
11
11
  border-radius: 5px;
12
12
  }
13
13
 
14
- .MathRichInput-Container:focus-within {
15
- background-color: white !important;
16
- outline: 0px;
17
- border: 1px solid #663676;
18
- }
14
+
19
15
 
20
16
  .MathRichInput-scrollview {
21
17
  position: relative;
@@ -78,6 +74,38 @@
78
74
  padding: 2px;
79
75
  margin: 0px 2px;
80
76
  }
77
+
78
+ .MathRichInput-Container {
79
+ :focus-within {
80
+ background-color: white;
81
+ outline: 0px;
82
+ /* border: 1px solid #663676; */
83
+ }
84
+
85
+ &.dark {
86
+ :focus-within {
87
+ background: none;
88
+ outline: 0px;
89
+ border: none;
90
+ }
91
+ .MathRichInput {
92
+ background: none;
93
+ color: white;
94
+ border: none;
95
+
96
+ .katex {
97
+ .base {
98
+ background: none;
99
+ }
100
+ }
101
+
102
+ &:focus {
103
+ border: none;
104
+ background: none;
105
+ }
106
+ }
107
+ }
108
+ }
81
109
  /* Note that the top left position of the toolbar is set programatically in componentDidMount */
82
110
 
83
111
  .Toolbar {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zzish/math-rich-input",
3
- "version": "0.1.39",
3
+ "version": "0.1.41",
4
4
  "description": "React component for user to enter rich text with embedded math equations.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -11,11 +11,7 @@
11
11
  border-radius: 5px;
12
12
  }
13
13
 
14
- .MathRichInput-Container:focus-within {
15
- background-color: white !important;
16
- outline: 0px;
17
- border: 1px solid #663676;
18
- }
14
+
19
15
 
20
16
  .MathRichInput-scrollview {
21
17
  position: relative;
@@ -78,3 +74,35 @@
78
74
  padding: 2px;
79
75
  margin: 0px 2px;
80
76
  }
77
+
78
+ .MathRichInput-Container {
79
+ :focus-within {
80
+ background-color: white;
81
+ outline: 0px;
82
+ /* border: 1px solid #663676; */
83
+ }
84
+
85
+ &.dark {
86
+ :focus-within {
87
+ background: none;
88
+ outline: 0px;
89
+ border: none;
90
+ }
91
+ .MathRichInput {
92
+ background: none;
93
+ color: white;
94
+ border: none;
95
+
96
+ .katex {
97
+ .base {
98
+ background: none;
99
+ }
100
+ }
101
+
102
+ &:focus {
103
+ border: none;
104
+ background: none;
105
+ }
106
+ }
107
+ }
108
+ }
@@ -208,6 +208,9 @@ export default class MathRichInput extends React.Component {
208
208
  this.undoHistory = [];
209
209
  this.redoHistory = [];
210
210
  this.accent = "";
211
+
212
+ // keeps track of whether user is composing in an IME - see https://developer.mozilla.org/en-US/docs/Web/API/CompositionEvent
213
+ this.isComposing = false;
211
214
  }
212
215
 
213
216
  enableFontStyling() {
@@ -1143,7 +1146,7 @@ export default class MathRichInput extends React.Component {
1143
1146
  handleInput = (event) => {
1144
1147
  try {
1145
1148
  // console.log("handleInput")
1146
- if (event.nativeEvent.isComposing) return;
1149
+ if (this.isComposing) return;
1147
1150
 
1148
1151
  let raw_text = elementToMarkedRawText(
1149
1152
  this.editableDiv,
@@ -2156,6 +2159,14 @@ export default class MathRichInput extends React.Component {
2156
2159
  }
2157
2160
  };
2158
2161
 
2162
+ handleCompositionStart = (event) => {
2163
+ this.isComposing = true ;
2164
+ }
2165
+
2166
+ handleCompositionEnd = (event) => {
2167
+ this.isComposing = false;
2168
+ }
2169
+
2159
2170
  render() {
2160
2171
  if (this.props.value == null) {
2161
2172
  console.error('MathRichInput must have prop called "value"');
@@ -2212,6 +2223,8 @@ export default class MathRichInput extends React.Component {
2212
2223
  onMouseUp={this.handleMouseUp}
2213
2224
  onFocus={this.handleFocus}
2214
2225
  onBlur={this.handleBlur}
2226
+ onCompositionStart={this.handleCompositionStart}
2227
+ onCompositionEnd={this.handleCompositionEnd}
2215
2228
  dangerouslySetInnerHTML={{ __html: html }}
2216
2229
  data-placeholder={this.props.placeholder || ""}
2217
2230
  ></span>