@zzish/math-rich-input 0.1.16 → 0.1.19

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
@@ -18947,18 +18947,18 @@ var EquationEditor = /*#__PURE__*/function (_React$Component) {
18947
18947
  _this.latexInput.focus();
18948
18948
 
18949
18949
  var insertParams = getLatexInsertionParams(symbol);
18950
- var insert = insertParams.latexWithMarks;
18951
- console.log("Insert params: ");
18952
- console.log(insertParams);
18953
- console.log(start + ":" + end);
18954
- console.log(oldLatex); // Move text before cursor into latex if double mark exists in latex
18950
+ var insert = insertParams.latexWithMarks; // console.log("Insert params: ");
18951
+ // console.log(insertParams);
18952
+ // console.log(start + ":" + end);
18953
+ // console.log(oldLatex);
18954
+ // Move text before cursor into latex if double mark exists in latex
18955
18955
 
18956
18956
  var pos = insert.indexOf("##");
18957
18957
 
18958
18958
  if (pos >= 0) {
18959
18959
  if (start !== end) {
18960
- insert = insert.replace("##", oldLatex.substring(start, end));
18961
- console.log("insert: " + insert);
18960
+ insert = insert.replace("##", oldLatex.substring(start, end)); // console.log("insert: " + insert);
18961
+
18962
18962
  oldLatex = oldLatex.substring(0, start) + oldLatex.substring(end);
18963
18963
  end = start;
18964
18964
  } else if (start > 0) {
@@ -19005,10 +19005,9 @@ var EquationEditor = /*#__PURE__*/function (_React$Component) {
19005
19005
  _this.latexInput.focus();
19006
19006
  });
19007
19007
  } catch (error) {
19008
- console.error(error);
19009
- console.log("Inserting: " + symbol);
19010
- console.log("into: " + _this.latexInput.value);
19011
- console.log("at: " + start + ":" + end);
19008
+ console.error(error); // console.log("Inserting: " + symbol);
19009
+ // console.log("into: " + this.latexInput.value);
19010
+ // console.log("at: " + start + ":" + end);
19012
19011
  }
19013
19012
  });
19014
19013
 
@@ -19242,7 +19241,6 @@ var EquationEditor = /*#__PURE__*/function (_React$Component) {
19242
19241
  value: function render() {
19243
19242
  var _this2 = this;
19244
19243
 
19245
- console.log("Rendering EquationEditor. Latex: " + this.state.latex);
19246
19244
  var katexHtml = null;
19247
19245
  var prettyLatex = null;
19248
19246
 
@@ -19718,7 +19716,6 @@ var AccentBar = /*#__PURE__*/function (_React$Component) {
19718
19716
  _this.shouldUpdateReplaceCharacters = false;
19719
19717
  var thisState = _this.state;
19720
19718
  setTimeout(function () {
19721
- // console.log("Focing update")
19722
19719
  _this.setState(thisState);
19723
19720
  }, 100);
19724
19721
  } else {
@@ -19806,8 +19803,7 @@ var AccentBar = /*#__PURE__*/function (_React$Component) {
19806
19803
  var allAccents = GLOBAL_default_accents;
19807
19804
  var accentKey = this.props.keyPressed;
19808
19805
  if (!this.isFullyMounted) accentKey = this.props.fetchAccentLetter();else if ((accentKey === "Backspace" || accentKey === "ArrowLeft" || accentKey === "ArrowRight") && !this.shouldUpdateReplaceCharacters) // Yes, this should indeed be a NOT
19809
- accentKey = this.props.fetchAccentLetter(); // console.log("Accent key:"+accentKey)
19810
-
19806
+ accentKey = this.props.fetchAccentLetter();
19811
19807
  var quickAccents = ACCENTS_FOR_LETTER[accentKey];
19812
19808
  this.letterForAccents = accentKey;
19813
19809
  if (quickAccents === null || quickAccents === undefined) quickAccents = []; // Set className
@@ -20279,7 +20275,6 @@ var Toolbar = /*#__PURE__*/function (_React$Component) {
20279
20275
  });
20280
20276
 
20281
20277
  _defineProperty(_assertThisInitialized(_this), "showAccentBar", function (event) {
20282
- console.log("showAccentBar");
20283
20278
  if (!_this.state.showAccents) _this.accentLetter = _this.suppliedAccentLetterFetcher();
20284
20279
 
20285
20280
  _this.setState({
@@ -20290,8 +20285,6 @@ var Toolbar = /*#__PURE__*/function (_React$Component) {
20290
20285
  });
20291
20286
 
20292
20287
  _defineProperty(_assertThisInitialized(_this), "hideAccentBar", function (event) {
20293
- console.log("hideAccentBar");
20294
-
20295
20288
  _this.setState({
20296
20289
  showAccents: false
20297
20290
  });
@@ -20310,8 +20303,6 @@ var Toolbar = /*#__PURE__*/function (_React$Component) {
20310
20303
  });
20311
20304
 
20312
20305
  _defineProperty(_assertThisInitialized(_this), "handleAccentButtonClick", function (event, oldCharacter, newCharacter) {
20313
- console.log("handleAccentButtonClick");
20314
-
20315
20306
  _this.suppliedAccentLetterInserter(event, oldCharacter, newCharacter); // this.hideAccentBar(null)
20316
20307
 
20317
20308
  });
@@ -20389,7 +20380,6 @@ var Toolbar = /*#__PURE__*/function (_React$Component) {
20389
20380
  _this$props$enableMat,
20390
20381
  _this2 = this;
20391
20382
 
20392
- console.log("Rendering toolbar");
20393
20383
  this.suppliedClickHandler = this.props.onButtonClick;
20394
20384
  this.suppliedAccentLetterFetcher = this.props.fetchAccentLetter;
20395
20385
  this.suppliedAccentLetterInserter = this.props.insertAccentLetter;
@@ -21446,7 +21436,7 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
21446
21436
  });
21447
21437
 
21448
21438
  _defineProperty(_assertThisInitialized(_this2), "applyChangesToComponent", function (value, mimeType, rangeParams, isExpertMode, selectedTab) {
21449
- console.log("applyChangesToComponent"); // if (this.props.outputTex !== null && this.props.outputTex !== undefined && this.props.outputTex) {
21439
+ // if (this.props.outputTex !== null && this.props.outputTex !== undefined && this.props.outputTex) {
21450
21440
  // if (mimeType === MIME_TYPE_HTML) {
21451
21441
  // console.warn("Html found when outputTex=true")
21452
21442
  // value = convertHtmlToPlainText(value)
@@ -21457,7 +21447,6 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
21457
21447
  // }
21458
21448
  // }
21459
21449
  // rangeParams, isExpertMode and selectedTab can be null, in which case we will set them
21460
-
21461
21450
  if (rangeParams === null) rangeParams = _this2.lastSetRangeParams;else _this2.rangeParamsToSetAfterComponentUpdate = rangeParams;
21462
21451
  var options = _this2.props.options || DEFAULT_OPTIONS;
21463
21452
  if (isExpertMode === null) isExpertMode = options.isExpertMode;
@@ -21469,8 +21458,7 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
21469
21458
  rangeParams: rangeParams
21470
21459
  });
21471
21460
 
21472
- if (_this2.undoHistory.length > MAX_HISTORY_LENGTH) _this2.undoHistory.shift();
21473
- _this2.value = value; // Call the parent handler to apply the changes
21461
+ if (_this2.undoHistory.length > MAX_HISTORY_LENGTH) _this2.undoHistory.shift(); // Call the parent handler to apply the changes
21474
21462
 
21475
21463
  _this2.onChangeCallback({
21476
21464
  value: value,
@@ -21481,10 +21469,6 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
21481
21469
  });
21482
21470
  });
21483
21471
 
21484
- _defineProperty(_assertThisInitialized(_this2), "getValue", function () {
21485
- return _this2.value;
21486
- });
21487
-
21488
21472
  _defineProperty(_assertThisInitialized(_this2), "initialiseHistory", function () {
21489
21473
  if (_this2.initialHistoryState == null) _this2.initialHistoryState = {
21490
21474
  value: _this2.props.value,
@@ -21513,9 +21497,6 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
21513
21497
  });
21514
21498
 
21515
21499
  _defineProperty(_assertThisInitialized(_this2), "undo", function () {
21516
- console.log("undo");
21517
- console.log(_this2.undoHistory);
21518
-
21519
21500
  var currentState = _this2.undoHistory.pop();
21520
21501
 
21521
21502
  var previousState = _this2.undoHistory.pop();
@@ -21529,8 +21510,6 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
21529
21510
  if (!_this2.deepEqual(redoLast, currentState)) _this2.redoHistory.push(currentState);
21530
21511
  } else _this2.redoHistory.push(currentState);
21531
21512
 
21532
- console.log(previousState);
21533
-
21534
21513
  _this2.applyChangesToComponent(previousState.value, previousState.mimeType, previousState.rangeParams);
21535
21514
  });
21536
21515
 
@@ -21544,8 +21523,6 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
21544
21523
 
21545
21524
  _defineProperty(_assertThisInitialized(_this2), "_setRangeParams", function (params) {
21546
21525
  try {
21547
- console.log("_setRangeParams");
21548
- console.log(params);
21549
21526
  setRangeParams(_this2.editableDiv, params);
21550
21527
 
21551
21528
  _this2.setOldRangeParams(params);
@@ -21812,8 +21789,7 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
21812
21789
 
21813
21790
  if (offset === 0) {
21814
21791
  if (_this2.nodeStartsWithSmallSpace(node)) {
21815
- console.log("Offset = 0 and node starts with small space");
21816
-
21792
+ // console.log("Offset = 0 and node starts with small space");
21817
21793
  var _new_index2 = -1;
21818
21794
 
21819
21795
  var _new_offset2 = -1;
@@ -21846,7 +21822,6 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
21846
21822
  endNodeIndex: _new_index2,
21847
21823
  endOffset: _new_offset2
21848
21824
  };
21849
- console.log(_new_rangeParams3);
21850
21825
 
21851
21826
  _this2._setRangeParams(_new_rangeParams3);
21852
21827
 
@@ -21952,7 +21927,6 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
21952
21927
 
21953
21928
  _defineProperty(_assertThisInitialized(_this2), "handleKeyDownEnter", function (e) {
21954
21929
  try {
21955
- console.log("handleKeyDownEnter");
21956
21930
  if (_this2.enableMultiline()) _this2.insertNewLine(e);
21957
21931
  } catch (error) {
21958
21932
  console.error(error);
@@ -22096,7 +22070,6 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
22096
22070
  var _this = _assertThisInitialized(_this2);
22097
22071
 
22098
22072
  setTimeout(function () {
22099
- console.log(Date.now() - _this.keyPressStartTime);
22100
22073
  if (_this.keyPressStartTime > 0) if (Date.now() - _this.keyPressStartTime > 450) _this.setState({
22101
22074
  showAccentBar: true
22102
22075
  });
@@ -22112,13 +22085,10 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
22112
22085
  var endNode = _this2._findNodeWithIndex(params.endNodeIndex);
22113
22086
 
22114
22087
  if (!_this2.editableDivIsPlainText()) {
22115
- // console.log(params)
22116
22088
  if (params.startNodeIndex === -1) {
22117
22089
  console.error("Couldn't get range params");
22118
22090
  return;
22119
- } // console.log("Start node: "+startNode)
22120
- // console.log("End node: "+endNode)
22121
-
22091
+ }
22122
22092
 
22123
22093
  if (isKatexNode(startNode) || isKatexNode(endNode)) {
22124
22094
  console.error("User trying to edit inside latex node");
@@ -22539,12 +22509,16 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
22539
22509
  // this.markedRawText.substring(0,start_pos) +
22540
22510
  // RAW_TEXT_MATH_START_TAG + latex + RAW_TEXT_MATH_END_TAG +
22541
22511
  // this.markedRawText.substring(end_pos + MARK.length)
22542
-
22543
- console.log("Old cursor pos: " + oldRangeParams.startNodeIndex + "->" + oldRangeParams.startOffset);
22544
- console.log("Old raw text: " + _this2.props.value);
22545
- console.log("Old raw text length: " + _this2.props.value.length);
22546
- console.log("Old marked raw text:" + _this2.markedRawText);
22547
- console.log("New raw text: " + new_raw_text);
22512
+ // console.log(
22513
+ // "Old cursor pos: " +
22514
+ // oldRangeParams.startNodeIndex +
22515
+ // "->" +
22516
+ // oldRangeParams.startOffset
22517
+ // );
22518
+ // console.log("Old raw text: " + this.props.value);
22519
+ // console.log("Old raw text length: " + this.props.value.length);
22520
+ // console.log("Old marked raw text:" + this.markedRawText);
22521
+ // console.log("New raw text: " + new_raw_text);
22548
22522
 
22549
22523
  var new_rangeParams = _this2.getOldRangeParams();
22550
22524
 
@@ -22684,11 +22658,11 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
22684
22658
  new_rangeParams.startNodeIndex = rangeParams.startNodeIndex - 1;
22685
22659
  new_rangeParams.startOffset = new_offset;
22686
22660
  new_rangeParams.endNodeIndex = rangeParams.endNodeIndex - 1;
22687
- new_rangeParams.endOffset = new_offset;
22688
- console.log("About to apply new range params");
22689
- console.log(new_rangeParams);
22690
- console.log("Old nodes");
22691
- console.log(_this2.editableDiv.childNodes);
22661
+ new_rangeParams.endOffset = new_offset; // console.log("About to apply new range params");
22662
+ // console.log(new_rangeParams);
22663
+ // console.log("Old nodes");
22664
+ // console.log(this.editableDiv.childNodes);
22665
+
22692
22666
  new_raw_text = removeEncodingIfPlainText(new_raw_text, _this2.state.mimeType, _this2.enableHtml());
22693
22667
 
22694
22668
  _this2.applyChangesToComponent(new_raw_text, _this2.state.mimeType, new_rangeParams, _this2.props.useExpertMode, _this2.props.selectedTab);
@@ -22720,12 +22694,12 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
22720
22694
  new_raw_text = removeMarks(insertCharacterBeforeMarks(raw_text, "\n"));
22721
22695
  new_rangeParams.startOffset++;
22722
22696
  new_rangeParams.endOffset++;
22723
- }
22697
+ } // console.log("About to apply new range params");
22698
+ // console.log(new_rangeParams);
22699
+ // console.log("Old nodes");
22700
+ // console.log(this.editableDiv.childNodes);
22701
+
22724
22702
 
22725
- console.log("About to apply new range params");
22726
- console.log(new_rangeParams);
22727
- console.log("Old nodes");
22728
- console.log(_this2.editableDiv.childNodes);
22729
22703
  new_raw_text = removeEncodingIfPlainText(new_raw_text, _this2.state.mimeType, _this2.enableHtml());
22730
22704
 
22731
22705
  _this2.applyChangesToComponent(new_raw_text, _this2.state.mimeType, new_rangeParams, _this2.props.useExpertMode, _this2.props.selectedTab);
@@ -22736,8 +22710,6 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
22736
22710
 
22737
22711
  _defineProperty(_assertThisInitialized(_this2), "replaceNextLetter", function (new_char) {
22738
22712
  try {
22739
- console.log("Replace next letter");
22740
-
22741
22713
  var rangeParams = _this2._getRangeParams();
22742
22714
 
22743
22715
  var node = _this2._findNodeWithIndex(rangeParams.endNodeIndex);
@@ -22834,8 +22806,7 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
22834
22806
  superscript: false
22835
22807
  },
22836
22808
  keyPressed: ""
22837
- };
22838
- _this2.value = ""; // this.handleInput = this.handleInput.bind(this);
22809
+ }; // this.handleInput = this.handleInput.bind(this);
22839
22810
  // this.handleKeyDown = this.handleKeyDown.bind(this);
22840
22811
  // this.handleKeyUp = this.handleKeyUp.bind(this);
22841
22812
  // Remember the last key pressed
@@ -22923,7 +22894,6 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
22923
22894
  }, {
22924
22895
  key: "setOldRangeParams",
22925
22896
  value: function setOldRangeParams(params) {
22926
- // console.log("Setting old range params: "+params.startNodeIndex+"->"+params.startOffset)
22927
22897
  this.oldRangeParams = params;
22928
22898
  }
22929
22899
  }, {
@@ -22931,8 +22901,7 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
22931
22901
  value: function getOldRangeParams() {
22932
22902
  if (this.oldRangeParams === null || this.oldRangeParams === undefined) return null;
22933
22903
 
22934
- var params = _objectSpread2({}, this.oldRangeParams); // console.log("Getting old range params: "+params.startNodeIndex+"->"+params.startOffset)
22935
-
22904
+ var params = _objectSpread2({}, this.oldRangeParams);
22936
22905
 
22937
22906
  return params;
22938
22907
  }
@@ -22940,10 +22909,8 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
22940
22909
  key: "_getRangeParams",
22941
22910
  value: function _getRangeParams() {
22942
22911
  var editableDiv = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
22943
- // console.log("_getRangeParams")
22944
22912
  if (editableDiv === null) editableDiv = this.editableDiv;
22945
- var rangeParams = getRangeParams(editableDiv); // console.log(rangeParams)
22946
-
22913
+ var rangeParams = getRangeParams(editableDiv);
22947
22914
  return rangeParams;
22948
22915
  }
22949
22916
  }, {
@@ -22970,9 +22937,6 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
22970
22937
  }, {
22971
22938
  key: "componentDidMount",
22972
22939
  value: function componentDidMount() {
22973
- var onRef = this.props.onRef;
22974
- onRef && onRef(this);
22975
-
22976
22940
  try {
22977
22941
  setupKatex();
22978
22942
  this.editableDiv.addEventListener("keydown", this.handleKeyDown);
@@ -22984,9 +22948,6 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
22984
22948
  }, {
22985
22949
  key: "componentWillUnmount",
22986
22950
  value: function componentWillUnmount() {
22987
- var onRef = this.props.onRef;
22988
- onRef && onRef(undefined);
22989
-
22990
22951
  try {
22991
22952
  this.editableDiv.removeEventListener("keydown", this.handleKeyDown);
22992
22953
  this.editableDiv.removeEventListener("keyup", this.handleKeyUp);
@@ -22998,8 +22959,6 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
22998
22959
  key: "componentDidUpdate",
22999
22960
  value: function componentDidUpdate() {
23000
22961
  try {
23001
- // console.log("Component updated:")
23002
- // console.log(this.editableDiv.childNodes)
23003
22962
  if (this.rangeParamsToSetAfterComponentUpdate !== null && this.rangeParamsToSetAfterComponentUpdate !== undefined) {
23004
22963
  this._setRangeParams(this.rangeParamsToSetAfterComponentUpdate);
23005
22964
 
@@ -23015,10 +22974,8 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
23015
22974
  value: function render() {
23016
22975
  var _this3 = this;
23017
22976
 
23018
- console.log("Rendering MathRichInput. Latex: " + this.props.value);
23019
-
23020
- if (this.props.value === undefined) {
23021
- console.error('MathRichInput must have prop called "text"');
22977
+ if (this.props.value == null) {
22978
+ console.error('MathRichInput must have prop called "value"');
23022
22979
  console.log(this.props);
23023
22980
  }
23024
22981
 
@@ -23102,7 +23059,6 @@ function getAllTextNodes(node) {
23102
23059
  var render = node.getAttribute("data-render");
23103
23060
 
23104
23061
  if (render !== null && render === "false") {
23105
- console.log("Ignoring");
23106
23062
  return nodes;
23107
23063
  }
23108
23064
  } else if (node.nodeType !== Node.DOCUMENT_NODE) {
@@ -23170,9 +23126,7 @@ var MathRichArea = /*#__PURE__*/function (_React$Component) {
23170
23126
  }, {
23171
23127
  key: "render",
23172
23128
  value: function render() {
23173
- // console.log("Mime type: "+this.props.mimeType)
23174
- var html = rawTextToHtml(katex$1, this.props.children, this.props.mimeType); // console.log("html: "+html)
23175
-
23129
+ var html = rawTextToHtml(katex$1, this.props.children, this.props.mimeType);
23176
23130
  return /*#__PURE__*/React__default['default'].createElement("span", {
23177
23131
  dangerouslySetInnerHTML: {
23178
23132
  __html: html
@@ -69,6 +69,161 @@
69
69
  padding: 2px;
70
70
  margin: 0px 2px;
71
71
  }
72
+ .EquationEditorModal-background {
73
+ position: fixed;
74
+ top: 0;
75
+ left: 0;
76
+ width: 100%;
77
+ height: 100%;
78
+ background: black;
79
+ z-index: 99;
80
+ animation: 0.3s shade;
81
+ animation-fill-mode: forwards;
82
+ }
83
+
84
+ @keyframes shade {
85
+ 00% {
86
+ opacity: 0;
87
+ }
88
+ 100% {
89
+ opacity: 0.6;
90
+ }
91
+ }
92
+
93
+ .EquationEditorModal {
94
+ background: white;
95
+ border: 1px solid #808080;
96
+ border-radius: 10px;
97
+ box-shadow: 0px 2px 5px 1px #a0a0a0;
98
+ position: fixed;
99
+ max-width: 500px;
100
+ width: 98%;
101
+ top: 50%;
102
+ left: 50%;
103
+ /* transform: translate(-50%,-50%); */
104
+ z-index: 100;
105
+ animation: 0.3s rise;
106
+ animation-fill-mode: forwards;
107
+ }
108
+
109
+ @keyframes rise {
110
+ 00% {
111
+ transform: translate(-50%, 100%);
112
+ opacity: 0;
113
+ }
114
+ 100% {
115
+ transform: translate(-50%, -50%);
116
+ opacity: 1;
117
+ }
118
+ }
119
+
120
+ .EquationEditorModal-mobile {
121
+ background: white;
122
+ border: 1px solid #808080;
123
+ border-radius: 10px;
124
+ box-shadow: 0px 2px 5px 1px #a0a0a0;
125
+ position: fixed;
126
+ max-width: 500px;
127
+ width: 99%;
128
+ top: 0%;
129
+ left: 50%;
130
+ transform: translate(-50%, 1px);
131
+ z-index: 100;
132
+ }
133
+
134
+ .EquationEditorModal .title {
135
+ display: flex;
136
+ justify-content: space-between;
137
+ font-size: 14px;
138
+ color: #404040;
139
+ text-align: left;
140
+ background: #e0e0e0;
141
+ border: 0px;
142
+ border-radius: 5px 5px 0px 0px;
143
+ padding: 15px;
144
+ margin: 0px;
145
+ }
146
+
147
+ .EquationEditorModal-mobile .title {
148
+ display: flex;
149
+ justify-content: space-between;
150
+ font-size: 14px;
151
+ color: #404040;
152
+ text-align: left;
153
+ background: #e0e0e0;
154
+ border: 0px;
155
+ border-radius: 5px 5px 0px 0px;
156
+ height: 30px;
157
+ padding: 15px;
158
+ margin: 0px;
159
+ }
160
+
161
+ .EquationEditorModal .expertModeSwitch .switch {
162
+ margin-left: 10px;
163
+ }
164
+
165
+ /* The switch - the box around the slider */
166
+ .EquationEditorModal .switch {
167
+ position: relative;
168
+ display: inline-block;
169
+ width: 35px;
170
+ height: 22px;
171
+ }
172
+
173
+ /* Hide default HTML checkbox */
174
+ .EquationEditorModal .switch input {
175
+ opacity: 0;
176
+ width: 0;
177
+ height: 0;
178
+ }
179
+
180
+ /* The slider */
181
+ .EquationEditorModal .slider {
182
+ position: absolute;
183
+ cursor: pointer;
184
+ top: 0;
185
+ left: 0;
186
+ right: 0;
187
+ bottom: 0;
188
+ background-color: #ccc;
189
+ -webkit-transition: 0.4s;
190
+ transition: 0.4s;
191
+ }
192
+
193
+ .EquationEditorModal .slider:before {
194
+ position: absolute;
195
+ content: "";
196
+ height: 14px;
197
+ width: 14px;
198
+ left: 4px;
199
+ bottom: 4px;
200
+ background-color: white;
201
+ -webkit-transition: 0.4s;
202
+ transition: 0.4s;
203
+ }
204
+
205
+ .EquationEditorModal input:checked + .slider {
206
+ background-color: #663676;
207
+ }
208
+
209
+ .EquationEditorModal input:focus + .slider {
210
+ box-shadow: 0 0 1px #2196f3;
211
+ }
212
+
213
+ .EquationEditorModal input:checked + .slider:before {
214
+ -webkit-transform: translateX(13px);
215
+ -ms-transform: translateX(13px);
216
+ transform: translateX(13px);
217
+ }
218
+
219
+ /* Rounded sliders */
220
+ .EquationEditorModal .slider.round {
221
+ border-radius: 18px;
222
+ }
223
+
224
+ .EquationEditorModal .slider.round:before {
225
+ border-radius: 50%;
226
+ }
72
227
  /* Note that the top left position of the toolbar is set programatically in componentDidMount */
73
228
 
74
229
  .Toolbar {
@@ -374,161 +529,6 @@
374
529
  animation: 0.4s fadeIn1;
375
530
  animation-fill-mode: forwards;
376
531
  }
377
- .EquationEditorModal-background {
378
- position: fixed;
379
- top: 0;
380
- left: 0;
381
- width: 100%;
382
- height: 100%;
383
- background: black;
384
- z-index: 99;
385
- animation: 0.3s shade;
386
- animation-fill-mode: forwards;
387
- }
388
-
389
- @keyframes shade {
390
- 00% {
391
- opacity: 0;
392
- }
393
- 100% {
394
- opacity: 0.6;
395
- }
396
- }
397
-
398
- .EquationEditorModal {
399
- background: white;
400
- border: 1px solid #808080;
401
- border-radius: 10px;
402
- box-shadow: 0px 2px 5px 1px #a0a0a0;
403
- position: fixed;
404
- max-width: 500px;
405
- width: 98%;
406
- top: 50%;
407
- left: 50%;
408
- /* transform: translate(-50%,-50%); */
409
- z-index: 100;
410
- animation: 0.3s rise;
411
- animation-fill-mode: forwards;
412
- }
413
-
414
- @keyframes rise {
415
- 00% {
416
- transform: translate(-50%, 100%);
417
- opacity: 0;
418
- }
419
- 100% {
420
- transform: translate(-50%, -50%);
421
- opacity: 1;
422
- }
423
- }
424
-
425
- .EquationEditorModal-mobile {
426
- background: white;
427
- border: 1px solid #808080;
428
- border-radius: 10px;
429
- box-shadow: 0px 2px 5px 1px #a0a0a0;
430
- position: fixed;
431
- max-width: 500px;
432
- width: 99%;
433
- top: 0%;
434
- left: 50%;
435
- transform: translate(-50%, 1px);
436
- z-index: 100;
437
- }
438
-
439
- .EquationEditorModal .title {
440
- display: flex;
441
- justify-content: space-between;
442
- font-size: 14px;
443
- color: #404040;
444
- text-align: left;
445
- background: #e0e0e0;
446
- border: 0px;
447
- border-radius: 5px 5px 0px 0px;
448
- padding: 15px;
449
- margin: 0px;
450
- }
451
-
452
- .EquationEditorModal-mobile .title {
453
- display: flex;
454
- justify-content: space-between;
455
- font-size: 14px;
456
- color: #404040;
457
- text-align: left;
458
- background: #e0e0e0;
459
- border: 0px;
460
- border-radius: 5px 5px 0px 0px;
461
- height: 30px;
462
- padding: 15px;
463
- margin: 0px;
464
- }
465
-
466
- .EquationEditorModal .expertModeSwitch .switch {
467
- margin-left: 10px;
468
- }
469
-
470
- /* The switch - the box around the slider */
471
- .EquationEditorModal .switch {
472
- position: relative;
473
- display: inline-block;
474
- width: 35px;
475
- height: 22px;
476
- }
477
-
478
- /* Hide default HTML checkbox */
479
- .EquationEditorModal .switch input {
480
- opacity: 0;
481
- width: 0;
482
- height: 0;
483
- }
484
-
485
- /* The slider */
486
- .EquationEditorModal .slider {
487
- position: absolute;
488
- cursor: pointer;
489
- top: 0;
490
- left: 0;
491
- right: 0;
492
- bottom: 0;
493
- background-color: #ccc;
494
- -webkit-transition: 0.4s;
495
- transition: 0.4s;
496
- }
497
-
498
- .EquationEditorModal .slider:before {
499
- position: absolute;
500
- content: "";
501
- height: 14px;
502
- width: 14px;
503
- left: 4px;
504
- bottom: 4px;
505
- background-color: white;
506
- -webkit-transition: 0.4s;
507
- transition: 0.4s;
508
- }
509
-
510
- .EquationEditorModal input:checked + .slider {
511
- background-color: #663676;
512
- }
513
-
514
- .EquationEditorModal input:focus + .slider {
515
- box-shadow: 0 0 1px #2196f3;
516
- }
517
-
518
- .EquationEditorModal input:checked + .slider:before {
519
- -webkit-transform: translateX(13px);
520
- -ms-transform: translateX(13px);
521
- transform: translateX(13px);
522
- }
523
-
524
- /* Rounded sliders */
525
- .EquationEditorModal .slider.round {
526
- border-radius: 18px;
527
- }
528
-
529
- .EquationEditorModal .slider.round:before {
530
- border-radius: 50%;
531
- }
532
532
  .EquationEditor {
533
533
  height: auto;
534
534
  text-align: center;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zzish/math-rich-input",
3
- "version": "0.1.16",
3
+ "version": "0.1.19",
4
4
  "description": "React component for user to enter rich text with embedded math equations.",
5
5
  "repository": {
6
6
  "type": "git",
package/src/AccentBar.jsx CHANGED
@@ -663,7 +663,6 @@ export default class AccentBar extends React.Component {
663
663
  this.shouldUpdateReplaceCharacters = false;
664
664
  let thisState = this.state;
665
665
  setTimeout(() => {
666
- // console.log("Focing update")
667
666
  this.setState(thisState);
668
667
  }, 100);
669
668
  } else {
@@ -692,8 +691,6 @@ export default class AccentBar extends React.Component {
692
691
  // Yes, this should indeed be a NOT
693
692
  accentKey = this.props.fetchAccentLetter();
694
693
 
695
- // console.log("Accent key:"+accentKey)
696
-
697
694
  let quickAccents = ACCENTS_FOR_LETTER[accentKey];
698
695
  this.letterForAccents = accentKey;
699
696
  if (quickAccents === null || quickAccents === undefined) quickAccents = [];
@@ -212,17 +212,17 @@ export default class EquationEditor extends React.Component {
212
212
 
213
213
  let insertParams = getLatexInsertionParams(symbol);
214
214
  let insert = insertParams.latexWithMarks;
215
- console.log("Insert params: ");
216
- console.log(insertParams);
217
- console.log(start + ":" + end);
218
- console.log(oldLatex);
215
+ // console.log("Insert params: ");
216
+ // console.log(insertParams);
217
+ // console.log(start + ":" + end);
218
+ // console.log(oldLatex);
219
219
 
220
220
  // Move text before cursor into latex if double mark exists in latex
221
221
  let pos = insert.indexOf("##");
222
222
  if (pos >= 0) {
223
223
  if (start !== end) {
224
224
  insert = insert.replace("##", oldLatex.substring(start, end));
225
- console.log("insert: " + insert);
225
+ // console.log("insert: " + insert);
226
226
  oldLatex = oldLatex.substring(0, start) + oldLatex.substring(end);
227
227
  end = start;
228
228
  } else if (start > 0) {
@@ -278,9 +278,9 @@ export default class EquationEditor extends React.Component {
278
278
  });
279
279
  } catch (error) {
280
280
  console.error(error);
281
- console.log("Inserting: " + symbol);
282
- console.log("into: " + this.latexInput.value);
283
- console.log("at: " + start + ":" + end);
281
+ // console.log("Inserting: " + symbol);
282
+ // console.log("into: " + this.latexInput.value);
283
+ // console.log("at: " + start + ":" + end);
284
284
  }
285
285
  };
286
286
 
@@ -410,7 +410,6 @@ export default class EquationEditor extends React.Component {
410
410
  };
411
411
 
412
412
  render() {
413
- console.log("Rendering EquationEditor. Latex: " + this.state.latex);
414
413
  let katexHtml = null;
415
414
  let prettyLatex = null;
416
415
  if (this.props.useExpertMode) {
@@ -1,108 +1,99 @@
1
- import React from 'react'
1
+ import React from "react";
2
2
 
3
3
  import katex from "katex";
4
- import {setupKatex} from "./katexHelper"
5
- import {rawTextToHtml} from './mathRichInputHelper'
6
- import {MIME_TYPE_TEX, MIME_TYPE_HTML, MIME_TYPE_ZZISH_HTML_MATH,
7
- isTextLatexMath, isTextHtml, isTextHtmlMath} from './mimeTypeHelper'
8
-
9
-
10
- function getAllTextNodes(node, nodes=null) {
4
+ import { setupKatex } from "./katexHelper";
5
+ import { rawTextToHtml } from "./mathRichInputHelper";
6
+ import {
7
+ MIME_TYPE_TEX,
8
+ MIME_TYPE_HTML,
9
+ MIME_TYPE_ZZISH_HTML_MATH,
10
+ isTextLatexMath,
11
+ isTextHtml,
12
+ isTextHtmlMath,
13
+ } from "./mimeTypeHelper";
14
+
15
+ function getAllTextNodes(node, nodes = null) {
11
16
  if (node === null) {
12
- console.warn("Deverloper supplied a null node. Ignoring")
13
- return nodes
17
+ console.warn("Deverloper supplied a null node. Ignoring");
18
+ return nodes;
14
19
  }
15
20
 
16
21
  if (nodes === null) {
17
- nodes = []
22
+ nodes = [];
18
23
  }
19
24
 
20
25
  if (node.nodeType === Node.TEXT_NODE) {
21
- nodes.push(node)
22
- return nodes
26
+ nodes.push(node);
27
+ return nodes;
23
28
  }
24
29
  if (node.nodeType === Node.ELEMENT_NODE) {
25
30
  if (node.className === "katex" || node.className === "MathRichInput")
26
- return nodes
27
- if (node.tagName === "SCRIPT")
28
- return nodes
29
- let render = node.getAttribute("data-render")
31
+ return nodes;
32
+ if (node.tagName === "SCRIPT") return nodes;
33
+ let render = node.getAttribute("data-render");
30
34
  if (render !== null && render === "false") {
31
- console.log("Ignoring")
32
- return nodes
33
- }
35
+ return nodes;
36
+ }
34
37
  } else if (node.nodeType !== Node.DOCUMENT_NODE) {
35
- return nodes
38
+ return nodes;
36
39
  }
37
40
 
38
- if (node.childNodes === null || node.childNodes === undefined)
39
- return nodes
41
+ if (node.childNodes === null || node.childNodes === undefined) return nodes;
40
42
 
41
43
  for (let i = 0; i < node.childNodes.length; i++)
42
- getAllTextNodes(node.childNodes[i], nodes)
44
+ getAllTextNodes(node.childNodes[i], nodes);
43
45
 
44
- return nodes
46
+ return nodes;
45
47
  }
46
48
 
47
49
  export function renderMathInNode(node) {
48
50
  try {
49
- let textNodes = getAllTextNodes(node)
51
+ let textNodes = getAllTextNodes(node);
50
52
  for (let i = 0; i < textNodes.length; i++) {
51
53
  try {
52
- const text = textNodes[i].nodeValue
53
-
54
- let mime_type = null
55
- if (isTextHtmlMath(text))
56
- mime_type = MIME_TYPE_ZZISH_HTML_MATH
57
- else if (isTextHtml(text))
58
- mime_type = MIME_TYPE_HTML
59
- else if (isTextLatexMath(text))
60
- mime_type = MIME_TYPE_TEX
54
+ const text = textNodes[i].nodeValue;
55
+
56
+ let mime_type = null;
57
+ if (isTextHtmlMath(text)) mime_type = MIME_TYPE_ZZISH_HTML_MATH;
58
+ else if (isTextHtml(text)) mime_type = MIME_TYPE_HTML;
59
+ else if (isTextLatexMath(text)) mime_type = MIME_TYPE_TEX;
61
60
 
62
61
  if (mime_type !== null) {
63
- const html = rawTextToHtml(katex, text, mime_type)
64
- const new_node = document.createElement("span")
65
- new_node.innerHTML = html
66
- textNodes[i].replaceWith(new_node)
62
+ const html = rawTextToHtml(katex, text, mime_type);
63
+ const new_node = document.createElement("span");
64
+ new_node.innerHTML = html;
65
+ textNodes[i].replaceWith(new_node);
67
66
  }
68
67
  } catch (error) {
69
- console.log(error)
68
+ console.log(error);
70
69
  }
71
70
  }
72
71
  } catch (error) {
73
- console.log(error)
72
+ console.log(error);
74
73
  }
75
74
  }
76
75
 
77
76
  export function renderMathInNodeArray(nodes) {
78
- for (let i = 0; i < nodes.length; i++)
79
- renderMathInNode(nodes[i])
77
+ for (let i = 0; i < nodes.length; i++) renderMathInNode(nodes[i]);
80
78
  }
81
79
 
82
80
  export default class MathRichArea extends React.Component {
83
-
84
81
  constructor(props) {
85
82
  super(props);
86
- this.state = {
87
- };
83
+ this.state = {};
88
84
  }
89
85
 
90
86
  componentDidMount() {
91
87
  try {
92
- setupKatex()
88
+ setupKatex();
93
89
  } catch (error) {
94
- console.error(error)
90
+ console.error(error);
95
91
  }
96
92
  }
97
93
 
98
94
  render() {
99
- // console.log("Mime type: "+this.props.mimeType)
100
- let html = rawTextToHtml(katex, this.props.children, this.props.mimeType)
101
- // console.log("html: "+html)
95
+ let html = rawTextToHtml(katex, this.props.children, this.props.mimeType);
102
96
 
103
- return <span dangerouslySetInnerHTML={{__html: html}}></span>
97
+ return <span dangerouslySetInnerHTML={{ __html: html }}></span>;
104
98
  }
105
99
  }
106
-
107
-
108
-
@@ -70,7 +70,6 @@ export default class MathRichInput extends React.Component {
70
70
  },
71
71
  keyPressed: "",
72
72
  };
73
- this.value = "";
74
73
 
75
74
  // this.handleInput = this.handleInput.bind(this);
76
75
  // this.handleKeyDown = this.handleKeyDown.bind(this);
@@ -189,8 +188,6 @@ export default class MathRichInput extends React.Component {
189
188
  isExpertMode,
190
189
  selectedTab
191
190
  ) => {
192
- console.log("applyChangesToComponent");
193
-
194
191
  // if (this.props.outputTex !== null && this.props.outputTex !== undefined && this.props.outputTex) {
195
192
  // if (mimeType === MIME_TYPE_HTML) {
196
193
  // console.warn("Html found when outputTex=true")
@@ -214,15 +211,10 @@ export default class MathRichInput extends React.Component {
214
211
  this.undoHistory.push({ value, mimeType, rangeParams });
215
212
  if (this.undoHistory.length > MAX_HISTORY_LENGTH) this.undoHistory.shift();
216
213
 
217
- this.value = value;
218
214
  // Call the parent handler to apply the changes
219
215
  this.onChangeCallback({ value, mimeType }, { isExpertMode, selectedTab });
220
216
  };
221
217
 
222
- getValue = () => {
223
- return this.value;
224
- };
225
-
226
218
  initialiseHistory = () => {
227
219
  if (this.initialHistoryState == null)
228
220
  this.initialHistoryState = {
@@ -259,8 +251,6 @@ export default class MathRichInput extends React.Component {
259
251
  };
260
252
 
261
253
  undo = () => {
262
- console.log("undo");
263
- console.log(this.undoHistory);
264
254
  const currentState = this.undoHistory.pop();
265
255
 
266
256
  let previousState = this.undoHistory.pop();
@@ -274,8 +264,6 @@ export default class MathRichInput extends React.Component {
274
264
  this.redoHistory.push(currentState);
275
265
  } else this.redoHistory.push(currentState);
276
266
 
277
- console.log(previousState);
278
-
279
267
  this.applyChangesToComponent(
280
268
  previousState.value,
281
269
  previousState.mimeType,
@@ -295,7 +283,6 @@ export default class MathRichInput extends React.Component {
295
283
  };
296
284
 
297
285
  setOldRangeParams(params) {
298
- // console.log("Setting old range params: "+params.startNodeIndex+"->"+params.startOffset)
299
286
  this.oldRangeParams = params;
300
287
  }
301
288
 
@@ -303,24 +290,18 @@ export default class MathRichInput extends React.Component {
303
290
  if (this.oldRangeParams === null || this.oldRangeParams === undefined)
304
291
  return null;
305
292
  let params = { ...this.oldRangeParams };
306
- // console.log("Getting old range params: "+params.startNodeIndex+"->"+params.startOffset)
307
293
  return params;
308
294
  }
309
295
 
310
296
  _getRangeParams(editableDiv = null) {
311
- // console.log("_getRangeParams")
312
297
  if (editableDiv === null) editableDiv = this.editableDiv;
313
298
  let rangeParams = getRangeParams(editableDiv);
314
- // console.log(rangeParams)
315
299
  return rangeParams;
316
300
  }
317
301
 
318
302
  _setRangeParams = (params) => {
319
303
  try {
320
- console.log("_setRangeParams");
321
- console.log(params);
322
304
  setRangeParams(this.editableDiv, params);
323
-
324
305
  this.setOldRangeParams(params);
325
306
  this.lastSetRangeParmas = params;
326
307
  } catch (error) {
@@ -631,7 +612,7 @@ export default class MathRichInput extends React.Component {
631
612
  // Deal with case of inserted small space at start of <p> element
632
613
  if (offset === 0) {
633
614
  if (this.nodeStartsWithSmallSpace(node)) {
634
- console.log("Offset = 0 and node starts with small space");
615
+ // console.log("Offset = 0 and node starts with small space");
635
616
  let new_index = -1;
636
617
  let new_offset = -1;
637
618
 
@@ -660,7 +641,6 @@ export default class MathRichInput extends React.Component {
660
641
  endNodeIndex: new_index,
661
642
  endOffset: new_offset,
662
643
  };
663
- console.log(new_rangeParams);
664
644
  this._setRangeParams(new_rangeParams);
665
645
 
666
646
  e.preventDefault();
@@ -792,7 +772,6 @@ export default class MathRichInput extends React.Component {
792
772
 
793
773
  handleKeyDownEnter = (e) => {
794
774
  try {
795
- console.log("handleKeyDownEnter");
796
775
  if (this.enableMultiline()) this.insertNewLine(e);
797
776
  } catch (error) {
798
777
  console.error(error);
@@ -962,7 +941,6 @@ export default class MathRichInput extends React.Component {
962
941
  ) {
963
942
  let _this = this;
964
943
  setTimeout(function () {
965
- console.log(Date.now() - _this.keyPressStartTime);
966
944
  if (_this.keyPressStartTime > 0)
967
945
  if (Date.now() - _this.keyPressStartTime > 450)
968
946
  _this.setState({ showAccentBar: true });
@@ -975,14 +953,10 @@ export default class MathRichInput extends React.Component {
975
953
  let startNode = this._findNodeWithIndex(params.startNodeIndex);
976
954
  let endNode = this._findNodeWithIndex(params.endNodeIndex);
977
955
  if (!this.editableDivIsPlainText()) {
978
- // console.log(params)
979
956
  if (params.startNodeIndex === -1) {
980
957
  console.error("Couldn't get range params");
981
958
  return;
982
959
  }
983
- // console.log("Start node: "+startNode)
984
- // console.log("End node: "+endNode)
985
-
986
960
  if (isKatexNode(startNode) || isKatexNode(endNode)) {
987
961
  console.error("User trying to edit inside latex node");
988
962
  e.preventDefault();
@@ -1193,8 +1167,6 @@ export default class MathRichInput extends React.Component {
1193
1167
  };
1194
1168
 
1195
1169
  componentDidMount() {
1196
- const onRef = this.props.onRef;
1197
- onRef && onRef(this);
1198
1170
  try {
1199
1171
  setupKatex();
1200
1172
 
@@ -1206,8 +1178,6 @@ export default class MathRichInput extends React.Component {
1206
1178
  }
1207
1179
 
1208
1180
  componentWillUnmount() {
1209
- const onRef = this.props.onRef;
1210
- onRef && onRef(undefined);
1211
1181
  try {
1212
1182
  this.editableDiv.removeEventListener("keydown", this.handleKeyDown);
1213
1183
  this.editableDiv.removeEventListener("keyup", this.handleKeyUp);
@@ -1218,8 +1188,6 @@ export default class MathRichInput extends React.Component {
1218
1188
 
1219
1189
  componentDidUpdate() {
1220
1190
  try {
1221
- // console.log("Component updated:")
1222
- // console.log(this.editableDiv.childNodes)
1223
1191
  if (
1224
1192
  this.rangeParamsToSetAfterComponentUpdate !== null &&
1225
1193
  this.rangeParamsToSetAfterComponentUpdate !== undefined
@@ -1485,16 +1453,16 @@ export default class MathRichInput extends React.Component {
1485
1453
  // RAW_TEXT_MATH_START_TAG + latex + RAW_TEXT_MATH_END_TAG +
1486
1454
  // this.markedRawText.substring(end_pos + MARK.length)
1487
1455
 
1488
- console.log(
1489
- "Old cursor pos: " +
1490
- oldRangeParams.startNodeIndex +
1491
- "->" +
1492
- oldRangeParams.startOffset
1493
- );
1494
- console.log("Old raw text: " + this.props.value);
1495
- console.log("Old raw text length: " + this.props.value.length);
1496
- console.log("Old marked raw text:" + this.markedRawText);
1497
- console.log("New raw text: " + new_raw_text);
1456
+ // console.log(
1457
+ // "Old cursor pos: " +
1458
+ // oldRangeParams.startNodeIndex +
1459
+ // "->" +
1460
+ // oldRangeParams.startOffset
1461
+ // );
1462
+ // console.log("Old raw text: " + this.props.value);
1463
+ // console.log("Old raw text length: " + this.props.value.length);
1464
+ // console.log("Old marked raw text:" + this.markedRawText);
1465
+ // console.log("New raw text: " + new_raw_text);
1498
1466
 
1499
1467
  let new_rangeParams = this.getOldRangeParams();
1500
1468
  if (this.moveCursorOnInsert) {
@@ -1670,10 +1638,10 @@ export default class MathRichInput extends React.Component {
1670
1638
  new_rangeParams.endNodeIndex = rangeParams.endNodeIndex - 1;
1671
1639
  new_rangeParams.endOffset = new_offset;
1672
1640
 
1673
- console.log("About to apply new range params");
1674
- console.log(new_rangeParams);
1675
- console.log("Old nodes");
1676
- console.log(this.editableDiv.childNodes);
1641
+ // console.log("About to apply new range params");
1642
+ // console.log(new_rangeParams);
1643
+ // console.log("Old nodes");
1644
+ // console.log(this.editableDiv.childNodes);
1677
1645
 
1678
1646
  new_raw_text = removeEncodingIfPlainText(
1679
1647
  new_raw_text,
@@ -1725,10 +1693,10 @@ export default class MathRichInput extends React.Component {
1725
1693
  new_rangeParams.endOffset++;
1726
1694
  }
1727
1695
 
1728
- console.log("About to apply new range params");
1729
- console.log(new_rangeParams);
1730
- console.log("Old nodes");
1731
- console.log(this.editableDiv.childNodes);
1696
+ // console.log("About to apply new range params");
1697
+ // console.log(new_rangeParams);
1698
+ // console.log("Old nodes");
1699
+ // console.log(this.editableDiv.childNodes);
1732
1700
 
1733
1701
  new_raw_text = removeEncodingIfPlainText(
1734
1702
  new_raw_text,
@@ -1750,7 +1718,6 @@ export default class MathRichInput extends React.Component {
1750
1718
 
1751
1719
  replaceNextLetter = (new_char) => {
1752
1720
  try {
1753
- console.log("Replace next letter");
1754
1721
  let rangeParams = this._getRangeParams();
1755
1722
  let node = this._findNodeWithIndex(rangeParams.endNodeIndex);
1756
1723
  let offset = rangeParams.endOffset + 1; // next letter
@@ -1867,10 +1834,8 @@ export default class MathRichInput extends React.Component {
1867
1834
  };
1868
1835
 
1869
1836
  render() {
1870
- console.log("Rendering MathRichInput. Latex: " + this.props.value);
1871
-
1872
- if (this.props.value === undefined) {
1873
- console.error('MathRichInput must have prop called "text"');
1837
+ if (this.props.value == null) {
1838
+ console.error('MathRichInput must have prop called "value"');
1874
1839
  console.log(this.props);
1875
1840
  }
1876
1841
 
package/src/Toolbar.jsx CHANGED
@@ -38,7 +38,6 @@ export default class Toolbar extends React.Component {
38
38
  };
39
39
 
40
40
  showAccentBar = (event) => {
41
- console.log("showAccentBar");
42
41
  if (!this.state.showAccents)
43
42
  this.accentLetter = this.suppliedAccentLetterFetcher();
44
43
  this.setState({ showAccents: true });
@@ -46,7 +45,6 @@ export default class Toolbar extends React.Component {
46
45
  };
47
46
 
48
47
  hideAccentBar = (event) => {
49
- console.log("hideAccentBar");
50
48
  this.setState({ showAccents: false });
51
49
  };
52
50
 
@@ -61,7 +59,6 @@ export default class Toolbar extends React.Component {
61
59
  };
62
60
 
63
61
  handleAccentButtonClick = (event, oldCharacter, newCharacter) => {
64
- console.log("handleAccentButtonClick");
65
62
  this.suppliedAccentLetterInserter(event, oldCharacter, newCharacter);
66
63
  // this.hideAccentBar(null)
67
64
  };
@@ -123,7 +120,6 @@ export default class Toolbar extends React.Component {
123
120
  }
124
121
 
125
122
  render() {
126
- console.log("Rendering toolbar");
127
123
  this.suppliedClickHandler = this.props.onButtonClick;
128
124
  this.suppliedAccentLetterFetcher = this.props.fetchAccentLetter;
129
125
  this.suppliedAccentLetterInserter = this.props.insertAccentLetter;