@expensify/react-native-live-markdown 0.1.12 → 0.1.13

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.
@@ -7,8 +7,9 @@ type MarkdownType = 'bold' | 'italic' | 'strikethrough' | 'link' | 'code' | 'pre
7
7
 
8
8
  type MarkdownRange = {
9
9
  type: MarkdownType;
10
- startIndex: number;
10
+ start: number;
11
11
  length: number;
12
+ depth?: number;
12
13
  };
13
14
 
14
15
  type NestedNode = {
@@ -99,10 +100,10 @@ function parseRangesToHTMLNodes(text: string, ranges: MarkdownRange[], markdownS
99
100
  break;
100
101
  }
101
102
 
102
- const endOfCurrentRange = range.startIndex + range.length;
103
- const nextRangeStartIndex = stack.length > 0 && !!stack[0] ? stack[0].startIndex || 0 : textLength;
103
+ const endOfCurrentRange = range.start + range.length;
104
+ const nextRangeStartIndex = stack.length > 0 && !!stack[0] ? stack[0].start || 0 : textLength;
104
105
 
105
- addSubstringAsTextNode(currentRoot.node, text, lastRangeEndIndex, range.startIndex); // add text with newlines before current range
106
+ addSubstringAsTextNode(currentRoot.node, text, lastRangeEndIndex, range.start); // add text with newlines before current range
106
107
 
107
108
  const span = document.createElement('span');
108
109
  if (disableInlineStyles) {
@@ -115,9 +116,9 @@ function parseRangesToHTMLNodes(text: string, ranges: MarkdownRange[], markdownS
115
116
  // tag nesting
116
117
  currentRoot.node.appendChild(span);
117
118
  nestedStack.push({node: span, endIndex: endOfCurrentRange});
118
- lastRangeEndIndex = range.startIndex;
119
+ lastRangeEndIndex = range.start;
119
120
  } else {
120
- addSubstringAsTextNode(span, text, range.startIndex, endOfCurrentRange);
121
+ addSubstringAsTextNode(span, text, range.start, endOfCurrentRange);
121
122
  currentRoot.node.appendChild(span);
122
123
  lastRangeEndIndex = endOfCurrentRange;
123
124
 
@@ -162,14 +163,7 @@ function parseText(
162
163
  }
163
164
  const ranges = global.parseExpensiMarkToRanges(text);
164
165
 
165
- const markdownRanges: MarkdownRange[] = ranges.map((range) => {
166
- const [type, startIndex, length] = range;
167
- return {
168
- type: type as MarkdownType,
169
- startIndex,
170
- length,
171
- };
172
- });
166
+ const markdownRanges: MarkdownRange[] = ranges as MarkdownRange[];
173
167
 
174
168
  targetElement.innerHTML = '';
175
169
  targetElement.innerText = '';