@zzish/math-rich-input 0.1.2 → 0.1.4

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
@@ -20466,8 +20466,6 @@ function isTextLatexMath(text) {
20466
20466
  // We need at least two dollar signs to be latex
20467
20467
  var i = text.indexOf("$");
20468
20468
  if (i < 0) return false;
20469
- var j = text.indexOf("\\$");
20470
- if (j >= 0) return true;
20471
20469
  i = text.indexOf("$", i + 1);
20472
20470
  if (i < 0) return false; // Lets try and extract the potentially latex nodes
20473
20471
 
@@ -20530,15 +20528,15 @@ function isTextLatexMath(text) {
20530
20528
  var allWords = true;
20531
20529
  var longWord = false;
20532
20530
 
20533
- for (var _j = 0; _j < words.length; _j++) {
20531
+ for (var j = 0; j < words.length; j++) {
20534
20532
  // console.log(j+":"+words[j])
20535
- if (words[_j].length > 0 && WORDS_REG_EXP.test(words[_j]) === false) {
20533
+ if (words[j].length > 0 && WORDS_REG_EXP.test(words[j]) === false) {
20536
20534
  // console.log("Not: "+words[j])
20537
20535
  allWords = false;
20538
20536
  break;
20539
20537
  }
20540
20538
 
20541
- if (words[_j].length >= 3) longWord = true;
20539
+ if (words[j].length >= 3) longWord = true;
20542
20540
  }
20543
20541
 
20544
20542
  if (allWords && longWord) return false;
@@ -20621,25 +20619,18 @@ function determineMimeType(text) {
20621
20619
  {this.test("$a bcd> e$", "application/x-tex")}
20622
20620
  */
20623
20621
 
20624
- var RAW_TEXT_MATH_START_TAG_TEX = "\\[";
20625
- var RAW_TEXT_MATH_END_TAG_TEX = "\\]";
20622
+ var RAW_TEXT_MATH_START_TAG_TEX = "$";
20623
+ var RAW_TEXT_MATH_END_TAG_TEX = "$";
20626
20624
  var RAW_TEXT_MATH_START_TAG_HTML_MATH = "<math>";
20627
20625
  var RAW_TEXT_MATH_END_TAG_HTML_MATH = "</math>";
20628
20626
  var INLINE_TEX_REG_EXP = /\$\$[\s\S]+?\$\$|\\\[[\s\S]+?\\\]|\\\([\s\S]+?\\\)|\$[^$\\]*(?:\\.[^$\\]*)*\$/g;
20629
- var BLOCK_TEX_REG_EXP = /\$\$[\s\S]+?\$\$|\\\[[\s\S]+?\\\]/g; // const INLINE_TEX_REG_EXP = /(?<!\\)\$[\s\S]+?(?<!\\)\$/g
20630
- // In general, (?<!Y)X matches an X that is not preceded by a Y. so (?<!\\)\$
20631
- // const INLINE_TEX_REG_EXP = /(?<!\\)(?:((?<!\$)\${1,2}(?!\$))|(\\\()|(\\\[)|(\\begin\{equation\}))(?(1)(.*?)(?<!\\)(?<!\$)\1(?!\$)|(?:(.*(?R)?.*)(?<!\\)(?:(?(2)\\\)|(?(3)\\\]|\\end\{equation\})))))/
20632
- // const HTML_MATH_REG_EXP = /<math>.*?<\/math>/gi;
20627
+ var BLOCK_TEX_REG_EXP = /\$\$[\s\S]+?\$\$|\\\[[\s\S]+?\\\]/g; // const HTML_MATH_REG_EXP = /<math>.*?<\/math>/gi;
20633
20628
 
20634
20629
  var HTML_MATH_REG_EXP = /<math>[\s\S]*?<\/math>/gi;
20635
20630
  var SPAN_OPEN_BASE = "<span class=\"base\">";
20636
20631
  var SPAN_CLOSE = "</span>";
20637
- var MARK$1 = String.fromCharCode(0); // const MARK = "_M_A_R_K_"
20638
-
20632
+ var MARK$1 = "_M_A_R_K_";
20639
20633
  var MARK_REG_EXP$1 = new RegExp(MARK$1, "g");
20640
- var TEMP_CHAR = String.fromCharCode(1);
20641
- var TEMP_CHAR_REG_EXP = new RegExp(TEMP_CHAR, "g");
20642
- var DOLLAR_SLASH_REG_EXP = /\\\$/g;
20643
20634
  var SMALL_SPACE_CHAR_CODE$1 = 8203;
20644
20635
  var SMALL_SPACE$1 = String.fromCharCode(SMALL_SPACE_CHAR_CODE$1);
20645
20636
  var SMALL_SPACE_REG_EXP = new RegExp(SMALL_SPACE$1, "g");
@@ -20781,6 +20772,7 @@ function getLatex(node) {
20781
20772
  // <annotation encoding="application/x-tex">L' = {L}{\sqrt{1-\frac{v^2}{c^2}}}</annotation>
20782
20773
  var annotation = getFirstDescendentByTagName(node, "annotation");
20783
20774
  var latex = annotation.childNodes[0].nodeValue;
20775
+ latex = decodeLatex(latex);
20784
20776
  return latex;
20785
20777
  } catch (error) {
20786
20778
  console.error(error);
@@ -20830,60 +20822,41 @@ var decodeFromHtml = function () {
20830
20822
  // Note we don't need to encode it so do nothing here
20831
20823
 
20832
20824
 
20833
- function encodeToLatex(text) {
20825
+ function encodeLatex(text) {
20834
20826
  // console.log("Pre-encoded: "+text)
20835
- text = text.replace(/\$/g, "\\$"); // console.log("Post-encoded: "+text)
20836
-
20827
+ // console.log("Post-encoded: "+text)
20837
20828
  return text;
20838
20829
  } // Note we don't need to decode it so do nothing here
20839
20830
 
20840
20831
 
20841
- function decodeFromLatex(text) {
20832
+ function decodeLatex(text) {
20842
20833
  // console.log("Pre-decoded: "+text)
20843
- text = text.replace(/\\\$/g, "$"); // console.log("Post-decoded: "+text)
20844
-
20834
+ // console.log("Post-decoded: "+text)
20845
20835
  return text;
20846
20836
  }
20847
20837
 
20848
- function removeEncodingIfPlainText(text, mimeType, useHtmlMath) {
20849
- if (mimeType !== MIME_TYPE_PLAIN_TEXT$1) return text;
20850
- if (useHtmlMath) return decodeFromHtml(text);else return decodeFromLatex(text);
20851
- }
20852
-
20853
20838
  function addText(arrayOfText, text, mark, offset) {
20854
- var useHtmlMath = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
20855
-
20856
20839
  // console.log("Mark: "+mark)
20857
20840
  if (offset === 0) {
20858
20841
  if (mark) {
20859
- arrayOfText.push(MARK$1);
20842
+ arrayOfText.push(MARK$1); // arrayOfText.push(" ")
20843
+
20860
20844
  arrayOfText.push(MARK$1);
20861
20845
  }
20862
20846
 
20863
20847
  arrayOfText.push(text);
20864
20848
  } else {
20865
- if (useHtmlMath) {
20866
- var decoded = decodeFromHtml(text);
20867
- arrayOfText.push(encodeToHtml(decoded.substring(0, offset)));
20849
+ var decoded = decodeFromHtml(text); // console.log("Decoded: "+decoded)
20868
20850
 
20869
- if (mark) {
20870
- arrayOfText.push(MARK$1);
20871
- arrayOfText.push(MARK$1);
20872
- }
20873
-
20874
- arrayOfText.push(encodeToHtml(decoded.substring(offset)));
20875
- } else {
20876
- var _decoded = decodeFromLatex(text);
20851
+ arrayOfText.push(encodeToHtml(decoded.substring(0, offset)));
20877
20852
 
20878
- arrayOfText.push(encodeToLatex(_decoded.substring(0, offset)));
20879
-
20880
- if (mark) {
20881
- arrayOfText.push(MARK$1);
20882
- arrayOfText.push(MARK$1);
20883
- }
20853
+ if (mark) {
20854
+ arrayOfText.push(MARK$1); // arrayOfText.push(" ")
20884
20855
 
20885
- arrayOfText.push(encodeToLatex(_decoded.substring(offset)));
20856
+ arrayOfText.push(MARK$1);
20886
20857
  }
20858
+
20859
+ arrayOfText.push(encodeToHtml(decoded.substring(offset)));
20887
20860
  }
20888
20861
  }
20889
20862
 
@@ -20896,7 +20869,7 @@ function addTextForNode(node, arrayOfText) {
20896
20869
 
20897
20870
  try {
20898
20871
  if (isTextNode(node)) {
20899
- addText(arrayOfText, useHtmlMath ? encodeToHtml(node.nodeValue) : encodeToLatex(node.nodeValue), mark, offset, useHtmlMath);
20872
+ addText(arrayOfText, useHtmlMath ? encodeToHtml(node.nodeValue) : node.nodeValue, mark, offset, useHtmlMath);
20900
20873
  } else if (isBrNode(node)) {
20901
20874
  useHtmlMath && arrayOfText.push("<br>");
20902
20875
  } else if (isBIUNode(node)) {
@@ -20910,7 +20883,7 @@ function addTextForNode(node, arrayOfText) {
20910
20883
  } else if (isKatexNode(node)) {
20911
20884
  if (mark) arrayOfText.push(MARK$1);
20912
20885
  arrayOfText.push(useHtmlMath ? RAW_TEXT_MATH_START_TAG_HTML_MATH : RAW_TEXT_MATH_START_TAG_TEX);
20913
- arrayOfText.push(getLatex(node));
20886
+ arrayOfText.push(encodeLatex(getLatex(node)));
20914
20887
  arrayOfText.push(useHtmlMath ? RAW_TEXT_MATH_END_TAG_HTML_MATH : RAW_TEXT_MATH_END_TAG_TEX);
20915
20888
  if (mark) arrayOfText.push(MARK$1);
20916
20889
  } else {
@@ -20957,7 +20930,6 @@ function elementToMarkedRawText(element) {
20957
20930
  var raw_text = result.join(""); // remove any zero-width spaces we added to the html
20958
20931
 
20959
20932
  raw_text = raw_text.replace(SMALL_SPACE_REG_EXP, '');
20960
- console.log("Marked raw text: " + raw_text);
20961
20933
  return raw_text;
20962
20934
  }
20963
20935
  function replaceMarksWithMath(markedRawText, latex) {
@@ -21037,29 +21009,22 @@ function renderLatexString(katex, s, t) {
21037
21009
  function rawTextToHtml(katex, string, mimeType) {
21038
21010
  if (string === "") return "";
21039
21011
  if (mimeType === null || mimeType === undefined || mimeType === "") mimeType = determineMimeType(string);
21040
- if (mimeType === MIME_TYPE_PLAIN_TEXT$1) return encodeToHtml(string);
21041
- var parseAsTex;
21042
- if (mimeType === MIME_TYPE_TEX$1 || mimeType === MIME_TYPE_LATEX) parseAsTex = true;else if (mimeType === MIME_TYPE_HTML$1 || mimeType === MIME_TYPE_ZZISH_HTML_MATH$1) parseAsTex = false;else {
21043
- parseAsTex = false;
21044
- console.error("Unknown mime type: " + mimeType);
21045
- } // console.log("Original string: "+string)
21012
+ if (mimeType === MIME_TYPE_PLAIN_TEXT$1) return string;
21013
+ var parseAsTex = false;
21014
+ if (mimeType === MIME_TYPE_TEX$1 || mimeType === MIME_TYPE_LATEX) parseAsTex = true;
21046
21015
 
21047
- if (parseAsTex) string = string.replace(DOLLAR_SLASH_REG_EXP, TEMP_CHAR); // console.log("Modded string: "+string)
21016
+ if (!parseAsTex && mimeType !== MIME_TYPE_HTML$1 && mimeType !== MIME_TYPE_ZZISH_HTML_MATH$1) {
21017
+ console.error("Unknown mime type: " + mimeType);
21018
+ }
21048
21019
 
21049
21020
  var stringElements = string.split(parseAsTex ? INLINE_TEX_REG_EXP : HTML_MATH_REG_EXP); // Insert small space at start of first element if it is an empty element
21050
21021
 
21051
21022
  if (stringElements[0] === "") // This means the original string stars with latex
21052
- stringElements[0] = "&#" + SMALL_SPACE$1.charCodeAt(0);
21023
+ stringElements[0] = "&#" + SMALL_SPACE$1.charCodeAt(0); // Insert small space at end of <p></p> elements so that empty lines get rendered
21053
21024
 
21054
- if (parseAsTex) {
21025
+ if (mimeType === MIME_TYPE_ZZISH_HTML_MATH$1 || mimeType === MIME_TYPE_HTML$1) {
21055
21026
  for (var i = 0; i < stringElements.length; i++) {
21056
- stringElements[i] = stringElements[i].replace(TEMP_CHAR_REG_EXP, "$");
21057
- stringElements[i] = encodeToHtml(stringElements[i]);
21058
- }
21059
- } else {
21060
- // Insert small space at end of <p></p> elements so that empty lines get rendered
21061
- for (var _i = 0; _i < stringElements.length; _i++) {
21062
- stringElements[_i] = stringElements[_i].replace(P_TAG_REG_EXP, P_ELEMENT_SMALL_SPACE);
21027
+ stringElements[i] = stringElements[i].replace(P_TAG_REG_EXP, P_ELEMENT_SMALL_SPACE);
21063
21028
  }
21064
21029
  }
21065
21030
 
@@ -21067,22 +21032,13 @@ function rawTextToHtml(katex, string, mimeType) {
21067
21032
  var latexElements = string.match(parseAsTex ? INLINE_TEX_REG_EXP : HTML_MATH_REG_EXP);
21068
21033
  var result = [];
21069
21034
 
21070
- for (var _i2 = 0; _i2 < stringElements.length; _i2++) {
21071
- result.push(stringElements[_i2]);
21072
-
21073
- if (latexElements[_i2]) {
21074
- var element = latexElements[_i2];
21075
- var type = void 0;
21076
-
21077
- if (parseAsTex) {
21078
- type = getDisplayType(element);
21079
- element = stripDollars(element);
21080
- element = element.replace(TEMP_CHAR_REG_EXP, "\\$");
21081
- } else {
21082
- type = "inline";
21083
- element = stripTags(element);
21084
- }
21035
+ for (var _i = 0; _i < stringElements.length; _i++) {
21036
+ result.push(stringElements[_i]);
21085
21037
 
21038
+ if (latexElements[_i]) {
21039
+ var element = latexElements[_i];
21040
+ var type = parseAsTex ? getDisplayType(element) : "inline";
21041
+ element = parseAsTex ? stripDollars(element) : stripTags(element);
21086
21042
  var renderedElement = renderLatexString(katex, element, type);
21087
21043
  renderedElement = renderedElement + "&#" + SMALL_SPACE$1.charCodeAt(0);
21088
21044
  result.push(renderedElement);
@@ -21589,8 +21545,6 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
21589
21545
 
21590
21546
  var mimeType = _this2.getMimeType(nodeCounts.html > 0, nodeCounts.math > 0);
21591
21547
 
21592
- raw_text = removeEncodingIfPlainText(raw_text, mimeType, _this2.enableHtml());
21593
-
21594
21548
  _this2.applyChangesToComponent(raw_text, mimeType, new_rangeParams, _this2.props.useExpertMode, _this2.props.selectedTab); // Consume the event
21595
21549
 
21596
21550
 
@@ -21856,8 +21810,6 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
21856
21810
 
21857
21811
  var mimeType = _this2.getMimeType(nodeCounts.html > 0, true);
21858
21812
 
21859
- raw_text = removeEncodingIfPlainText(raw_text, mimeType, _this2.enableHtml());
21860
-
21861
21813
  _this2.applyChangesToComponent(raw_text, mimeType, new_rangeParams, _this2.props.useExpertMode, _this2.props.selectedTab);
21862
21814
  } catch (error) {
21863
21815
  console.error(error);
@@ -22162,8 +22114,6 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
22162
22114
 
22163
22115
  var mimeType = _this2.getMimeType(nodeCounts.html > 0, nodeCounts.math > 0);
22164
22116
 
22165
- raw_text = removeEncodingIfPlainText(raw_text, mimeType, _this2.enableHtml());
22166
-
22167
22117
  _this2.applyChangesToComponent(raw_text, mimeType, params, _this2.props.useExpertMode, _this2.props.selectedTab);
22168
22118
  } catch (error) {
22169
22119
  console.error(error);
@@ -22444,7 +22394,6 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
22444
22394
 
22445
22395
  var _mimeType = null;
22446
22396
  if (_this2.editingExistingEquation) _mimeType = _this2.getMimeType(_nodeCounts.html > 0, _nodeCounts.katex > 1);else _mimeType = _this2.getMimeType(_nodeCounts.html > 0, _nodeCounts.katex > 0);
22447
- _new_raw_text = removeEncodingIfPlainText(_new_raw_text, _mimeType, _this2.enableHtml());
22448
22397
 
22449
22398
  _this2.applyChangesToComponent(_new_raw_text, _mimeType, _new_rangeParams6, _this2.props.useExpertMode, _this2.props.selectedTab);
22450
22399
 
@@ -22493,8 +22442,6 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
22493
22442
 
22494
22443
  var mimeType = _this2.getMimeType(nodeCounts.html > 0, true);
22495
22444
 
22496
- new_raw_text = removeEncodingIfPlainText(new_raw_text, mimeType, _this2.enableHtml());
22497
-
22498
22445
  _this2.applyChangesToComponent(new_raw_text, mimeType, new_rangeParams, _this2.props.useExpertMode, _this2.props.selectedTab);
22499
22446
 
22500
22447
  _this2.setState({
@@ -22579,7 +22526,6 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
22579
22526
  new_raw_text = removeMarks(insertCharacterBeforeMarks(raw_text, new_text));
22580
22527
  if (rangeParams.startNodeIndex === rangeParams.endNodeIndex && rangeParams.startOffset === rangeParams.endOffset) new_rangeParams.startOffset = new_rangeParams.startOffset + new_text.length;
22581
22528
  new_rangeParams.endOffset = new_rangeParams.endOffset + new_text.length;
22582
- new_raw_text = removeEncodingIfPlainText(new_raw_text, _this2.state.mimeType, _this2.enableHtml());
22583
22529
 
22584
22530
  _this2.applyChangesToComponent(new_raw_text, _this2.state.mimeType, new_rangeParams, _this2.props.useExpertMode, _this2.props.selectedTab);
22585
22531
  } catch (error) {
@@ -22611,7 +22557,6 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
22611
22557
  console.log(new_rangeParams);
22612
22558
  console.log("Old nodes");
22613
22559
  console.log(_this2.editableDiv.childNodes);
22614
- new_raw_text = removeEncodingIfPlainText(new_raw_text, _this2.state.mimeType, _this2.enableHtml());
22615
22560
 
22616
22561
  _this2.applyChangesToComponent(new_raw_text, _this2.state.mimeType, new_rangeParams, _this2.props.useExpertMode, _this2.props.selectedTab);
22617
22562
  } catch (error) {
@@ -22648,7 +22593,6 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
22648
22593
  console.log(new_rangeParams);
22649
22594
  console.log("Old nodes");
22650
22595
  console.log(_this2.editableDiv.childNodes);
22651
- new_raw_text = removeEncodingIfPlainText(new_raw_text, _this2.state.mimeType, _this2.enableHtml());
22652
22596
 
22653
22597
  _this2.applyChangesToComponent(new_raw_text, _this2.state.mimeType, new_rangeParams, _this2.props.useExpertMode, _this2.props.selectedTab);
22654
22598
  } catch (error) {
@@ -22674,7 +22618,6 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
22674
22618
  new_raw_text = removeMarks(insertCharacterBeforeMarks(raw_text, new_char));
22675
22619
  if (rangeParams.startNodeIndex === rangeParams.endNodeIndex && rangeParams.startOffset === rangeParams.endOffset) new_rangeParams.startOffset = new_rangeParams.startOffset + new_char.length + 1;
22676
22620
  new_rangeParams.endOffset = new_rangeParams.endOffset + new_char.length + 1;
22677
- new_raw_text = removeEncodingIfPlainText(new_raw_text, _this2.state.mimeType, _this2.enableHtml());
22678
22621
 
22679
22622
  _this2.applyChangesToComponent(new_raw_text, _this2.state.mimeType, new_rangeParams, _this2.props.useExpertMode, _this2.props.selectedTab);
22680
22623
  } catch (error) {
@@ -22700,8 +22643,6 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
22700
22643
  new_rangeParams.endOffset = new_rangeParams.endOffset + new_char.length;
22701
22644
  } else new_raw_text = removeMarks(replaceCharacterBeforeMarks(raw_text, new_char));
22702
22645
 
22703
- new_raw_text = removeEncodingIfPlainText(new_raw_text, _this2.state.mimeType, _this2.enableHtml());
22704
-
22705
22646
  _this2.applyChangesToComponent(new_raw_text, _this2.state.mimeType, new_rangeParams, _this2.props.useExpertMode, _this2.props.selectedTab);
22706
22647
  } catch (error) {
22707
22648
  console.error(error);
@@ -22827,19 +22768,12 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
22827
22768
 
22828
22769
  }, {
22829
22770
  key: "getMimeType",
22830
- value: function getMimeType(hasHtml, hasMath) {
22831
- var _this$props$outputTex2, _this$props$outputPla;
22832
-
22833
- var outputTex = (_this$props$outputTex2 = this.props.outputTex) !== null && _this$props$outputTex2 !== void 0 ? _this$props$outputTex2 : false;
22834
- var outputPlainText = (_this$props$outputPla = this.props.outputPlainText) !== null && _this$props$outputPla !== void 0 ? _this$props$outputPla : false;
22835
-
22836
- if (outputTex) {
22837
- if (hasMath || !outputPlainText) return MIME_TYPE_TEX;else return MIME_TYPE_PLAIN_TEXT;
22771
+ value: function getMimeType(isHtml, hasMath) {
22772
+ if (isHtml) {
22773
+ if (hasMath) return MIME_TYPE_ZZISH_HTML_MATH;else return MIME_TYPE_HTML;
22774
+ } else {
22775
+ if (hasMath) return MIME_TYPE_TEX;else return MIME_TYPE_PLAIN_TEXT;
22838
22776
  }
22839
-
22840
- if (hasMath) return MIME_TYPE_ZZISH_HTML_MATH;
22841
- if (hasHtml || !outputPlainText) return MIME_TYPE_HTML;
22842
- return MIME_TYPE_PLAIN_TEXT;
22843
22777
  }
22844
22778
  }, {
22845
22779
  key: "setOldRangeParams",
@@ -23085,9 +23019,7 @@ var MathRichArea = /*#__PURE__*/function (_React$Component) {
23085
23019
  }, {
23086
23020
  key: "render",
23087
23021
  value: function render() {
23088
- // console.log("Mime type: "+this.props.mimeType)
23089
- var html = rawTextToHtml(katex$1, this.props.children, this.props.mimeType); // console.log("html: "+html)
23090
-
23022
+ var html = rawTextToHtml(katex$1, this.props.children, this.props.mime_type);
23091
23023
  return /*#__PURE__*/React.createElement("span", {
23092
23024
  dangerouslySetInnerHTML: {
23093
23025
  __html: html
@@ -61,6 +61,148 @@
61
61
  margin: 0px 2px 0px 2px;
62
62
  }
63
63
 
64
+ /* Note that the top left position of the toolbar is set programatically in componentDidMount */
65
+
66
+ .Toolbar {
67
+ position: fixed;
68
+ z-index: 1;
69
+ /* width:270px; */
70
+ height:42px;
71
+ background-color: white;
72
+ border: 1px solid #d0d0d0;
73
+ border-radius: 5px;
74
+ box-shadow: 1px 1px 5px #a0a0a0;
75
+ animation: 0.5s fadeIn1;
76
+ animation-fill-mode: forwards;
77
+ top: 0px;
78
+ left: 0px; /* important to set this so that toolbar initially renders full width */
79
+ }
80
+
81
+ @keyframes fadeIn1 {
82
+ 0% {
83
+ opacity: 0;
84
+ }
85
+ 100% {
86
+ opacity: 1.0;
87
+ }
88
+ }
89
+
90
+ .Toolbar-button {
91
+ font-family:sans-serif;
92
+ font-size: 16px;
93
+ width:40px;
94
+ height: 36px;
95
+ background-color: white;
96
+ border-radius: 5px;
97
+ border: 0px;
98
+ padding: 1px;
99
+ margin: 2px;
100
+ }
101
+
102
+
103
+ .Toolbar-button:hover {
104
+ color: white;
105
+ background: #663676;
106
+ cursor: pointer;
107
+ }
108
+
109
+ .Toolbar-button:active {
110
+ background: #808080;
111
+ color: white;
112
+ cursor: pointer;
113
+ }
114
+
115
+ .TB-narrow {
116
+ width:30px;
117
+ }
118
+
119
+ .TB-wide {
120
+ width:46px;
121
+ }
122
+
123
+ .TB-up4 {
124
+ position: relative;
125
+ top:-4px;
126
+ }
127
+
128
+ .TB-selected {
129
+ background: #D0D0D0;
130
+ color: black;
131
+ cursor: pointer;
132
+ animation: 0.2s TB-fadeIn;
133
+ animation-fill-mode: forwards;
134
+ }
135
+
136
+ .TB-selected:hover {
137
+ color: white;
138
+ background: #663676;
139
+ cursor: pointer;
140
+ }
141
+
142
+ @keyframes TB-fadeIn {
143
+ 00% {
144
+ background: white;
145
+ }
146
+ 100% {
147
+ background: #D0D0D0;
148
+ }
149
+ }
150
+
151
+
152
+ /* Tooltip text */
153
+ .Toolbar-button .tooltiptext {
154
+ font-weight: normal;
155
+ visibility: hidden;
156
+ width: 100px;
157
+ background-color: #222;
158
+ color: #fff;
159
+ /*font-weight: bold;*/
160
+ font-size: 12px;
161
+ text-align: center;
162
+ padding: 4px 10px;
163
+ border-radius: 6px;
164
+
165
+ /* Position the tooltip text - see examples below! */
166
+ position: absolute;
167
+ z-index: 2;
168
+ top: -90%; /* Must leave a small gap between tooltip and button */
169
+ left: 50px;
170
+
171
+ /* transform: translate (50%,0%); */
172
+ }
173
+
174
+ /* Show the tooltip text when you mouse over the tooltip container */
175
+ .Toolbar-button:hover .tooltiptext {
176
+ animation: 0.8s fadeIn2;
177
+ animation-fill-mode: forwards;
178
+ visibility: visible;
179
+ /* width: 100px; */
180
+ /* top: -90%; */ /* Must leave a small gap between tooltip and button */
181
+ /* left: 20%; */
182
+ /* margin-left: -50px; */
183
+ }
184
+
185
+ @keyframes fadeIn2 {
186
+ 00% {
187
+ opacity: 0;
188
+ }
189
+ 70% {
190
+ opacity: 0;
191
+ }
192
+ 100% {
193
+ visibility: visible;
194
+ opacity: 0.9;
195
+ }
196
+ }
197
+
198
+ /* .tooltip {
199
+ position: relative;
200
+ display: inline-block;
201
+ border-bottom: 1px dotted black; /* If you want dots under the hoverable text
202
+ } */
203
+
204
+
205
+
64
206
 
65
207
  .EquationEditorModal-background {
66
208
  position: fixed;
@@ -224,149 +366,7 @@ input:checked + .slider:before {
224
366
 
225
367
  .slider.round:before {
226
368
  border-radius: 50%;
227
- }/* Note that the top left position of the toolbar is set programatically in componentDidMount */
228
-
229
- .Toolbar {
230
- position: fixed;
231
- z-index: 1;
232
- /* width:270px; */
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
- top: 0px;
241
- left: 0px; /* important to set this so that toolbar initially renders full width */
242
- }
243
-
244
- @keyframes fadeIn1 {
245
- 0% {
246
- opacity: 0;
247
- }
248
- 100% {
249
- opacity: 1.0;
250
- }
251
- }
252
-
253
- .Toolbar-button {
254
- font-family:sans-serif;
255
- font-size: 16px;
256
- width:40px;
257
- height: 36px;
258
- background-color: white;
259
- border-radius: 5px;
260
- border: 0px;
261
- padding: 1px;
262
- margin: 2px;
263
369
  }
264
-
265
-
266
- .Toolbar-button:hover {
267
- color: white;
268
- background: #663676;
269
- cursor: pointer;
270
- }
271
-
272
- .Toolbar-button:active {
273
- background: #808080;
274
- color: white;
275
- cursor: pointer;
276
- }
277
-
278
- .TB-narrow {
279
- width:30px;
280
- }
281
-
282
- .TB-wide {
283
- width:46px;
284
- }
285
-
286
- .TB-up4 {
287
- position: relative;
288
- top:-4px;
289
- }
290
-
291
- .TB-selected {
292
- background: #D0D0D0;
293
- color: black;
294
- cursor: pointer;
295
- animation: 0.2s TB-fadeIn;
296
- animation-fill-mode: forwards;
297
- }
298
-
299
- .TB-selected:hover {
300
- color: white;
301
- background: #663676;
302
- cursor: pointer;
303
- }
304
-
305
- @keyframes TB-fadeIn {
306
- 00% {
307
- background: white;
308
- }
309
- 100% {
310
- background: #D0D0D0;
311
- }
312
- }
313
-
314
-
315
- /* Tooltip text */
316
- .Toolbar-button .tooltiptext {
317
- font-weight: normal;
318
- visibility: hidden;
319
- width: 100px;
320
- background-color: #222;
321
- color: #fff;
322
- /*font-weight: bold;*/
323
- font-size: 12px;
324
- text-align: center;
325
- padding: 4px 10px;
326
- border-radius: 6px;
327
-
328
- /* Position the tooltip text - see examples below! */
329
- position: absolute;
330
- z-index: 2;
331
- top: -90%; /* Must leave a small gap between tooltip and button */
332
- left: 50px;
333
-
334
- /* transform: translate (50%,0%); */
335
- }
336
-
337
- /* Show the tooltip text when you mouse over the tooltip container */
338
- .Toolbar-button:hover .tooltiptext {
339
- animation: 0.8s fadeIn2;
340
- animation-fill-mode: forwards;
341
- visibility: visible;
342
- /* width: 100px; */
343
- /* top: -90%; */ /* Must leave a small gap between tooltip and button */
344
- /* left: 20%; */
345
- /* margin-left: -50px; */
346
- }
347
-
348
- @keyframes fadeIn2 {
349
- 00% {
350
- opacity: 0;
351
- }
352
- 70% {
353
- opacity: 0;
354
- }
355
- 100% {
356
- visibility: visible;
357
- opacity: 0.9;
358
- }
359
- }
360
-
361
- /* .tooltip {
362
- position: relative;
363
- display: inline-block;
364
- border-bottom: 1px dotted black; /* If you want dots under the hoverable text
365
- } */
366
-
367
-
368
-
369
-
370
370
  /* Note that the top left position of the accent bar is set programatically in componentDidMount */
371
371
 
372
372
  .AccentBar {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zzish/math-rich-input",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "React component for user to enter rich text with embedded math equations.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -40,5 +40,9 @@
40
40
  "@rollup/plugin-node-resolve": "^11.2.0",
41
41
  "rollup": "^2.41.4",
42
42
  "rollup-plugin-css-only": "^3.1.0"
43
+ },
44
+ "peerDependencies": {
45
+ "react": "^17.0.1",
46
+ "react-dom": "^17.0.1"
43
47
  }
44
48
  }
package/src/index.js CHANGED
@@ -1,5 +1,9 @@
1
- export { default as MathRichInput } from "./MathRichInput";
2
- export { default as MathRichArea } from "./MathRichArea";
3
- export { renderMathInNode } from "./MathRichArea";
4
-
1
+ import MathRichInput from "./MathRichInput";
2
+ import MathRichArea from "./MathRichArea";
3
+ import { renderMathInNode } from "./MathRichArea";
5
4
 
5
+ export {
6
+ MathRichInput,
7
+ MathRichArea,
8
+ renderMathInNode
9
+ }