@zzish/math-rich-input 0.1.27 → 0.1.29

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
@@ -21007,7 +21007,7 @@ function addTextForNode(node, arrayOfText) {
21007
21007
  arrayOfText.push(useHtmlMath ? RAW_TEXT_MATH_END_TAG_HTML_MATH : RAW_TEXT_MATH_END_TAG_TEX);
21008
21008
  if (mark) arrayOfText.push(MARK$1);
21009
21009
  } else {
21010
- console.error("Cant render node in editable div: Unknown node type");
21010
+ console.error("Can't render node in editable div: Unknown node type");
21011
21011
  console.log(node);
21012
21012
  console.log("Node.type:" + node.type);
21013
21013
  console.log("Node.tagName:" + node.tagName);
@@ -21032,8 +21032,11 @@ function elementToMarkedRawText(element) {
21032
21032
  var nodeToMark = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
21033
21033
  var offset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
21034
21034
  var useHtmlMath = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
21035
- // console.log("Node to mark:")
21035
+ console.log("elementToMarkedRawText");
21036
+ console.log(element.innerHTML);
21037
+ if (element.innerHTML === "<p><br></p>") throw new Error("We are here"); // console.log("Node to mark:")
21036
21038
  // console.log(nodeToMark)
21039
+
21037
21040
  var nodes = element.childNodes; // console.log(nodes)
21038
21041
 
21039
21042
  var result = [];
@@ -21349,9 +21352,16 @@ function findNodeAndOffsetForGlobalOffset(node, globalOffset) {
21349
21352
  if (isTextNode(node)) {
21350
21353
  result.node = node;
21351
21354
  result.lastTextNode = node;
21355
+ console.log("Found text node \'" + node.nodeValue + "\' of length " + node.nodeValue.length);
21356
+ console.log("result.offset was: " + result.offset);
21352
21357
  result.offset += node.nodeValue.length;
21353
- if (nodeStartsWithSmallSpace(node)) result.offset -= 1; // console.log("result.offset now: "+result.offset)
21354
21358
 
21359
+ if (nodeStartsWithSmallSpace(node)) {
21360
+ console.log("Text node starts with small space");
21361
+ result.offset -= 1;
21362
+ }
21363
+
21364
+ console.log("result.offset now: " + result.offset);
21355
21365
  return false;
21356
21366
  }
21357
21367
 
@@ -21371,8 +21381,10 @@ function findNodeAndOffsetForGlobalOffset(node, globalOffset) {
21371
21381
  }
21372
21382
 
21373
21383
  if (node.nodeType === 1 && node.tagName === "P") {
21384
+ console.log("Leaving p node");
21374
21385
  result.node = null;
21375
21386
  result.offset++;
21387
+ console.log("result.offset now: " + result.offset);
21376
21388
  }
21377
21389
 
21378
21390
  return false;
@@ -21388,11 +21400,49 @@ function findFirstTextNode(node) {
21388
21400
  }
21389
21401
 
21390
21402
  return null;
21403
+ }
21404
+
21405
+ function findNodeAndOffsetForGlobalOffsetInEditableDiv(editableDiv, globalOffset) {
21406
+ var result = {
21407
+ offset: 0
21408
+ };
21409
+ console.log("Finding node and offset within: " + editableDiv.outerHTML);
21410
+ findNodeAndOffsetForGlobalOffset(editableDiv, globalOffset, result);
21411
+ console.log(result);
21412
+
21413
+ if (result.node === null) {
21414
+ if (globalOffset > 0 && result.lastTextNode !== null) {
21415
+ result.node = result.lastTextNode;
21416
+ result.offset = result.lastTextNode.nodeValue.length;
21417
+ } else {
21418
+ console.warn("Unable to find node and offset for global offset: " + globalOffset);
21419
+ console.log(editableDiv.innerHTML);
21420
+ console.log(result);
21421
+ result.node = findFirstTextNode(editableDiv);
21422
+ result.offset = 0;
21423
+ }
21424
+ }
21425
+
21426
+ if (result.offset === 0 && result.node.nodeValue.length > 0 && nodeStartsWithSmallSpace(result.node)) {
21427
+ result.offset = 1;
21428
+ }
21429
+
21430
+ if (result.offset > result.node.nodeValue.length) {
21431
+ console.warn("Unexpected offset when converting global offset to node and offset");
21432
+ console.log("Global offset: " + globalOffset);
21433
+ console.log("Result:");
21434
+ console.log(result);
21435
+ console.log("result.offset > result.node.nodeValue.length");
21436
+ result.offset = result.node.nodeValue.length;
21437
+ }
21438
+
21439
+ return result;
21391
21440
  } // https://www.w3.org/TR/DOM-Level-2-Traversal-Range/ranges.html
21392
21441
 
21442
+
21393
21443
  function getRangeParams(editableDiv) {
21394
- // console.log ("getRangeParams")
21395
- // console.log("Inner html: "+editableDiv.innerHTML)
21444
+ console.log("getRangeParams"); // console.log("Inner html: "+editableDiv.innerHTML)
21445
+
21396
21446
  var isSupported = typeof window.getSelection !== "undefined";
21397
21447
 
21398
21448
  if (!isSupported) {
@@ -21470,58 +21520,20 @@ function setRangeParamsFromGlobalOffsets(editableDiv, params) {
21470
21520
 
21471
21521
  try {
21472
21522
  if (params === null || params === undefined) throw new Error("Can't set range params: params === " + params);
21473
- var startResult = {
21474
- offset: 0
21475
- };
21476
- findNodeAndOffsetForGlobalOffset(editableDiv, params.startGlobalOffset, startResult); // console.log(startResult.node.nodeType+":"+startResult.node.tagName+":"+
21477
- // startResult.node.nodeValue+":"+startResult.offset)
21478
-
21479
- var endResult = {
21480
- offset: 0
21481
- };
21482
- findNodeAndOffsetForGlobalOffset(editableDiv, params.endGlobalOffset, endResult); // console.log(endResult.node.nodeType+":"+endResult.node.tagName+":"+
21483
- // endResult.node.nodeValue+":"+endResult.offset)
21484
- // So the next bit of code should never be called in principle, but if we have
21485
- // failed to find an appropriate node (this could happen if the global offset is bigger
21486
- // than the length of the text in the node), then lets try and fix it
21487
-
21488
- if (startResult.node === null || endResult.node === null) {
21489
- console.warn("Can't set range from global offsets, as could not find text nodes");
21490
- console.log(startResult);
21491
- console.log(endResult);
21492
-
21493
- if (startResult.node === null) {
21494
- if (params.startGlobalOffset > 0 && startResult.lastTextNode !== null) {
21495
- startResult.node = startResult.lastTextNode;
21496
- startResult.offset = startResult.lastTextNode.nodeValue.length;
21497
- } else {
21498
- startResult.node = findFirstTextNode(editableDiv);
21499
- startResult.offset = 0;
21500
- }
21501
- }
21502
-
21503
- if (endResult.node === null) {
21504
- if (params.endGlobalOffset > 0 && endResult.lastTextNode !== null) {
21505
- endResult.node = endResult.lastTextNode;
21506
- endResult.offset = endResult.lastTextNode.nodeValue.length;
21507
- } else {
21508
- endResult.node = findFirstTextNode(editableDiv);
21509
- endResult.offset = 0;
21510
- }
21511
- }
21512
- }
21513
-
21514
- if (startResult.offset === 0 && startResult.node.nodeValue.length > 0 && nodeStartsWithSmallSpace(startResult.node)) {
21515
- startResult.offset = 1;
21523
+ var startResult = findNodeAndOffsetForGlobalOffsetInEditableDiv(editableDiv, params.startGlobalOffset);
21524
+ var endResult = findNodeAndOffsetForGlobalOffsetInEditableDiv(editableDiv, params.endGlobalOffset);
21525
+
21526
+ if (startResult.node !== null) {
21527
+ console.log("Setting range to start in node:");
21528
+ console.log(" node type: " + startResult.node.nodeType);
21529
+ console.log(" tag name: " + startResult.node.tagName);
21530
+ console.log(" node value: " + startResult.node.nodeValue);
21531
+ console.log(" offset:" + startResult.offset);
21532
+ } else {
21533
+ console.warn("Can't set range, null start node returned");
21534
+ return;
21516
21535
  }
21517
21536
 
21518
- if (endResult.offset === 0 && endResult.node.nodeValue.length > 0 && nodeStartsWithSmallSpace(endResult.node)) {
21519
- endResult.offset = 1;
21520
- } // console.log("Setting range to:")
21521
- // console.log(startResult.node.nodeType+":"+startResult.node.tagName+":"+
21522
- // startResult.node.nodeValue+":"+startResult.offset)
21523
-
21524
-
21525
21537
  new_range = document.createRange();
21526
21538
  new_range.setStart(startResult.node, startResult.offset);
21527
21539
  new_range.setEnd(endResult.node, endResult.offset);
@@ -21545,19 +21557,22 @@ function setRangeParams(editableDiv, params) {
21545
21557
  if (params === null || params === undefined) {
21546
21558
  console.error("Can't set range params: params === " + params);
21547
21559
  return;
21548
- }
21560
+ } // New way of doing things
21561
+
21549
21562
 
21550
- if (params.startGlobalOffset) {
21563
+ if (params.startGlobalOffset !== null && params.startGlobalOffset !== undefined) {
21564
+ console.log("Setting range from global offsets");
21551
21565
  setRangeParamsFromGlobalOffsets(editableDiv, params);
21552
21566
  return;
21553
- }
21567
+ } // Otherwise use the old way of doing things
21568
+
21569
+
21570
+ console.log("Setting range from node index and local offset");
21554
21571
 
21555
21572
  if (params.startNodeIndex === null || params.startNodeIndex === undefined) {
21556
21573
  console.error("Can't set range params: params.startNodeIndex === " + params.startNodeIndex);
21557
21574
  return;
21558
- } // console.log("Setting cursor to range params: "+params.startNodeIndex+"->"+params.startOffset)
21559
- // console.log(params)
21560
-
21575
+ }
21561
21576
 
21562
21577
  if (params.startNodeIndex < 0) {
21563
21578
  console.error("Can't set range params: params.startNodeIndex < 0");
@@ -21567,34 +21582,32 @@ function setRangeParams(editableDiv, params) {
21567
21582
  var nodes = editableDiv.childNodes;
21568
21583
 
21569
21584
  if (params.startNodeIndex === 0 && params.startOffset === 0 && nodes.length === 0) {
21570
- // console.log("Not setting range params")
21571
21585
  return;
21572
- } // console.log("Node["+params.startNodeIndex+"]:")
21573
- // console.log(nodes[params.startNodeIndex])
21586
+ } // Set the offsets within the nodes
21574
21587
 
21575
21588
 
21576
21589
  var startOffset = params.startOffset;
21577
21590
  var endOffset = params.endOffset; // Handle special case of auto inserted SMALL CHAR at beginning of input
21591
+ // TODO This sectin may no longer be neceesary and may be introducing a bug
21578
21592
 
21579
21593
  if (params.startNodeIndex === 0 && params.startOffset === 1 && isSmallSpace(nodes[0])) startOffset = 0;
21580
- if (params.endNodeIndex === 0 && params.endOffset === 1 && isSmallSpace(nodes[0])) endOffset = 0;
21594
+ if (params.endNodeIndex === 0 && params.endOffset === 1 && isSmallSpace(nodes[0])) endOffset = 0; // Find the nodes
21595
+
21581
21596
  var startNode = findNodeWithIndex(editableDiv, params.startNodeIndex);
21582
- var endNode = findNodeWithIndex(editableDiv, params.endNodeIndex); // Lets make sure we are setting
21583
- // if (params.startNodeIndex !== 0 &&
21584
- // params.startOffset === 0) {
21585
- // if (getNodeText(startNode).charAt(0) === SMALL_SPACE)
21586
- // startOffset = SMALL_SPACE.length
21587
- // }
21588
- // if (params.endNodeIndex !== 0 &&
21589
- // params.endOffset === 0) {
21590
- // if (getNodeText(endNode).charAt(0) === SMALL_SPACE)
21591
- // endOffset = SMALL_SPACE.length
21592
- // }
21593
- // console.log("End: "+params.endNodeIndex+"->"+endOffset)
21594
- // Set range in document
21597
+ var endNode = findNodeWithIndex(editableDiv, params.endNodeIndex);
21598
+ console.log("Setting range to start in node:");
21599
+ console.log(" node type: " + startNode.nodeType);
21600
+ console.log(" tag name: " + startNode.tagName);
21601
+ console.log(" node value: " + startNode.nodeValue);
21602
+ console.log(" offset:" + startOffset);
21603
+ console.log("Setting range to end in node:");
21604
+ console.log(" node type: " + endNode.nodeType);
21605
+ console.log(" tag name: " + endNode.tagName);
21606
+ console.log(" node value: " + endNode.nodeValue);
21607
+ console.log(" offset:" + endOffset); // Set range in document
21595
21608
 
21596
21609
  if (startNode === null) {
21597
- console.error("Could not set range to start node with index " + params.startNodeIndex);
21610
+ console.warn("Could not set range to start node with index " + params.startNodeIndex);
21598
21611
  startNode = findFirstTextNode(editableDiv);
21599
21612
  startOffset = 0;
21600
21613
  }
@@ -21610,7 +21623,7 @@ function setRangeParams(editableDiv, params) {
21610
21623
  }
21611
21624
 
21612
21625
  if (endNode === null) {
21613
- console.error("Could not set range to end node with index " + params.endNodeIndex);
21626
+ console.warn("Could not set range to end node with index " + params.endNodeIndex);
21614
21627
  endNode = findFirstTextNode(editableDiv);
21615
21628
  endOffset = 0;
21616
21629
  }
@@ -21626,11 +21639,17 @@ function setRangeParams(editableDiv, params) {
21626
21639
  }
21627
21640
 
21628
21641
  new_range = document.createRange();
21642
+
21643
+ if (startOffset > startNode.nodeValue.length) {
21644
+ console.warn("endOffset > endNode.nodeValue.length when setting range: " + startOffset + " > " + startNode.nodeValue.length + " - " + stateNode.nodeType + " - " + startNode.nodeValue);
21645
+ startOffset = startNode.nodeValue.length;
21646
+ }
21647
+
21629
21648
  new_range.setStart(startNode, startOffset);
21630
21649
 
21631
- if (endOffset > endNode.length) {
21632
- console.warn("endOffset > endNode.length when setting range: " + endOffset + " > " + endNode.length + " - " + endNode.nodeType + " - " + endNode.nodeValue);
21633
- endOffset = endNode.length;
21650
+ if (endOffset > endNode.nodeValue.length) {
21651
+ console.warn("endOffset > endNode.nodeValue.length when setting range: " + endOffset + " > " + endNode.nodeValue.length + " - " + endNode.nodeType + " - " + endNode.nodeValue);
21652
+ endOffset = endNode.nodeValue.length;
21634
21653
  }
21635
21654
 
21636
21655
  new_range.setEnd(endNode, endOffset); // console.log("Setting range")
@@ -22103,6 +22122,7 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
22103
22122
 
22104
22123
  _this2.applyChangesToComponent("", _this2.getMimeType(false, false), _new_rangeParams, _this2.props.useExpertMode, _this2.props.selectedTab);
22105
22124
 
22125
+ e.preventDefault();
22106
22126
  return;
22107
22127
  } // Treat backspace normally in the following situations
22108
22128
 
@@ -22188,16 +22208,29 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
22188
22208
 
22189
22209
  rangeParams.startNodeIndex;
22190
22210
  rangeParams.startOffset;
22191
- var new_globalOffset = rangeParams.startGlobalOffset - 1;
22192
- var new_rangeParams = {
22193
- startGlobalOffset: new_globalOffset,
22194
- endGlobalOffset: new_globalOffset
22195
- };
22211
+ console.log("handleKeyDownArrowLeft");
22212
+ console.log(rangeParams);
22213
+ var new_globalOffset = rangeParams.endGlobalOffset - 1;
22214
+ var new_rangeParams = null;
22215
+
22216
+ if (e.shiftKey && new_globalOffset > rangeParams.startGlobalOffset) {
22217
+ new_rangeParams = {
22218
+ startGlobalOffset: rangeParams.startGlobalOffset,
22219
+ endGlobalOffset: new_globalOffset
22220
+ };
22221
+ } else {
22222
+ new_rangeParams = {
22223
+ startGlobalOffset: new_globalOffset,
22224
+ endGlobalOffset: new_globalOffset
22225
+ };
22226
+ }
22227
+
22228
+ console.log(new_rangeParams);
22196
22229
  e.preventDefault();
22197
22230
 
22198
22231
  _this2._setRangeParams(new_rangeParams);
22199
22232
 
22200
- return; // console.log("Old: "+index+"->"+offset)
22233
+ return;
22201
22234
  });
22202
22235
 
22203
22236
  _defineProperty(_assertThisInitialized(_this2), "handleKeyDownArrowRight", function (e) {
@@ -22206,11 +22239,21 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
22206
22239
 
22207
22240
  rangeParams.startNodeIndex;
22208
22241
  rangeParams.startOffset;
22209
- var new_globalOffset = rangeParams.startGlobalOffset + 1;
22210
- var new_rangeParams = {
22211
- startGlobalOffset: new_globalOffset,
22212
- endGlobalOffset: new_globalOffset
22213
- };
22242
+ var new_rangeParams = null;
22243
+ var new_globalOffset = rangeParams.endGlobalOffset + 1;
22244
+
22245
+ if (e.shiftKey && new_globalOffset > rangeParams.startGlobalOffset) {
22246
+ new_rangeParams = {
22247
+ startGlobalOffset: rangeParams.startGlobalOffset,
22248
+ endGlobalOffset: new_globalOffset
22249
+ };
22250
+ } else {
22251
+ new_rangeParams = {
22252
+ startGlobalOffset: new_globalOffset,
22253
+ endGlobalOffset: new_globalOffset
22254
+ };
22255
+ }
22256
+
22214
22257
  e.preventDefault();
22215
22258
 
22216
22259
  _this2._setRangeParams(new_rangeParams);
@@ -22630,30 +22673,30 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
22630
22673
 
22631
22674
  if (_index >= 0) {
22632
22675
  if (isKatexNode(_this2._findNodeWithIndex(_index))) {
22633
- var _new_index4 = 0;
22634
- var _new_offset4 = 0;
22676
+ var _new_index = 0;
22677
+ var _new_offset = 0;
22635
22678
 
22636
22679
  if (_index - 1 >= 0) {
22637
- _new_index4 = _index - 1;
22638
- _new_offset4 = getNodeTextLength(_this2._findNodeWithIndex(_new_index4));
22680
+ _new_index = _index - 1;
22681
+ _new_offset = getNodeTextLength(_this2._findNodeWithIndex(_new_index));
22639
22682
 
22640
- if (_new_offset4 < 0) {
22683
+ if (_new_offset < 0) {
22641
22684
  console.error("Failed to get node text length");
22642
- _new_offset4 = 0;
22685
+ _new_offset = 0;
22643
22686
  }
22644
22687
  } else {
22645
- _new_index4 = _index + 1;
22646
- _new_offset4 = SMALL_SPACE_LENGTH;
22688
+ _new_index = _index + 1;
22689
+ _new_offset = SMALL_SPACE_LENGTH;
22647
22690
  }
22648
22691
 
22649
- var _new_rangeParams7 = {
22650
- startNodeIndex: _new_index4,
22651
- startOffset: _new_offset4,
22652
- endNodeIndex: _new_index4,
22653
- endOffset: _new_offset4
22692
+ var _new_rangeParams2 = {
22693
+ startNodeIndex: _new_index,
22694
+ startOffset: _new_offset,
22695
+ endNodeIndex: _new_index,
22696
+ endOffset: _new_offset
22654
22697
  }; // console.log(new_rangeParams)
22655
22698
 
22656
- _this2._setRangeParams(_new_rangeParams7);
22699
+ _this2._setRangeParams(_new_rangeParams2);
22657
22700
  }
22658
22701
  }
22659
22702
  }
@@ -22666,8 +22709,9 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
22666
22709
 
22667
22710
  _defineProperty(_assertThisInitialized(_this2), "handleInput", function (event) {
22668
22711
  try {
22669
- // console.log("handleInput")
22712
+ console.log("handleInput");
22670
22713
  var raw_text = elementToMarkedRawText(_this2.editableDiv, null, 0, _this2.enableHtml());
22714
+ console.log("handleInput 2");
22671
22715
 
22672
22716
  var params = _this2._getRangeParams();
22673
22717
 
@@ -22689,6 +22733,8 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
22689
22733
 
22690
22734
  _defineProperty(_assertThisInitialized(_this2), "updateActiveButtons", function () {
22691
22735
  try {
22736
+ console.log("updateActiveButtons");
22737
+
22692
22738
  var rangeParams = _this2._getRangeParams();
22693
22739
 
22694
22740
  if (rangeParams === null || rangeParams === undefined) {
@@ -22971,8 +23017,10 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
22971
23017
 
22972
23018
  var end_pos = _this2.markedRawText.indexOf(MARK, start_pos + MARK.length);
22973
23019
 
22974
- var oldRangeParams = _this2.getOldRangeParams(); // Handle case of empty string returned
23020
+ var oldRangeParams = _this2.getOldRangeParams();
22975
23021
 
23022
+ console.log("Old range params");
23023
+ console.log(oldRangeParams); // Handle case of empty string returned
22976
23024
 
22977
23025
  if (latex === "") {
22978
23026
  // console.log("Empty latex returned from equation editor")
@@ -22997,14 +23045,14 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
22997
23045
  }
22998
23046
  }
22999
23047
 
23000
- var _new_rangeParams8 = {
23048
+ var _new_rangeParams3 = {
23001
23049
  startNodeIndex: new_index,
23002
23050
  startOffset: new_offset,
23003
23051
  endNodeIndex: new_index,
23004
23052
  endOffset: new_offset
23005
23053
  };
23006
23054
 
23007
- _this2.setOldRangeParams(_new_rangeParams8);
23055
+ _this2.setOldRangeParams(_new_rangeParams3);
23008
23056
 
23009
23057
  var _nodeCounts = _this2._countNodeTypes();
23010
23058
 
@@ -23012,7 +23060,7 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
23012
23060
  if (_this2.editingExistingEquation) _mimeType = _this2.getMimeType(_nodeCounts.html > 0, _nodeCounts.katex > 1);else _mimeType = _this2.getMimeType(_nodeCounts.html > 0, _nodeCounts.katex > 0);
23013
23061
  _new_raw_text = removeEncodingIfPlainText(_new_raw_text, _mimeType, _this2.enableHtml());
23014
23062
 
23015
- _this2.applyChangesToComponent(_new_raw_text, _mimeType, _new_rangeParams8, _this2.props.useExpertMode, _this2.props.selectedTab);
23063
+ _this2.applyChangesToComponent(_new_raw_text, _mimeType, _new_rangeParams3, _this2.props.useExpertMode, _this2.props.selectedTab);
23016
23064
 
23017
23065
  _this2.setState({
23018
23066
  showEquationEditor: false
@@ -23359,15 +23407,14 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
23359
23407
 
23360
23408
  var offset = rangeParams.endOffset;
23361
23409
  var raw_text = elementToMarkedRawText(_this2.editableDiv, node, offset, _this2.enableHtml());
23410
+ console.log("Raw text before line insert");
23411
+ console.log(raw_text);
23412
+ console.log("Range params before line insert");
23413
+ console.log(rangeParams);
23362
23414
  var new_raw_text = null;
23363
23415
 
23364
23416
  var new_rangeParams = _objectSpread2({}, rangeParams);
23365
23417
 
23366
- if (new_rangeParams.startGlobalOffset) {
23367
- new_rangeParams.startGlobalOffset++;
23368
- new_rangeParams.endGlobalOffset++;
23369
- }
23370
-
23371
23418
  if (_this2.enableHtml()) {
23372
23419
  new_raw_text = removeMarks(insertCharacterBeforeMarks(raw_text, "</p><p>"));
23373
23420
  if (new_raw_text.substring(0, 3).toLowerCase() !== "<p>") new_raw_text = "<p>" + new_raw_text + "</p>";
@@ -23375,6 +23422,11 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
23375
23422
  new_rangeParams.startOffset = 0;
23376
23423
  new_rangeParams.endNodeIndex = rangeParams.endNodeIndex + 1;
23377
23424
  new_rangeParams.endOffset = 0;
23425
+
23426
+ if (new_rangeParams.startGlobalOffset) {
23427
+ new_rangeParams.startGlobalOffset++;
23428
+ new_rangeParams.endGlobalOffset++;
23429
+ }
23378
23430
  } else {
23379
23431
  new_raw_text = removeMarks(insertCharacterBeforeMarks(raw_text, "\n"));
23380
23432
  new_rangeParams.startOffset++;
@@ -23382,6 +23434,10 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
23382
23434
  }
23383
23435
 
23384
23436
  new_raw_text = removeEncodingIfPlainText(new_raw_text, _this2.props.mimeType, _this2.enableHtml());
23437
+ console.log("New raw text after line insert");
23438
+ console.log(new_raw_text);
23439
+ console.log("New range params after line insert");
23440
+ console.log(new_rangeParams);
23385
23441
 
23386
23442
  _this2.applyChangesToComponent(new_raw_text, _this2.props.mimeType, new_rangeParams, _this2.props.useExpertMode, _this2.props.selectedTab);
23387
23443
  } catch (error) {