@expensify/react-native-live-markdown 0.1.13 → 0.1.14
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/android/src/main/java/com/expensify/livemarkdown/MarkdownBlockquoteSpan.java +10 -5
- package/android/src/main/java/com/expensify/livemarkdown/MarkdownUtils.java +5 -3
- package/ios/MarkdownLayoutManager.mm +11 -6
- package/ios/RCTMarkdownUtils.h +1 -1
- package/ios/RCTMarkdownUtils.mm +7 -3
- package/lib/commonjs/web/parserUtils.js +19 -1
- package/lib/commonjs/web/parserUtils.js.map +1 -1
- package/lib/module/web/parserUtils.js +19 -1
- package/lib/module/web/parserUtils.js.map +1 -1
- package/lib/parser/react-native-live-markdown-parser.js +4 -4
- package/lib/typescript/src/web/parserUtils.d.ts.map +1 -1
- package/package.json +1 -1
- package/parser/react-native-live-markdown-parser.js +4 -4
- package/src/web/parserUtils.ts +15 -1
package/src/web/parserUtils.ts
CHANGED
|
@@ -78,6 +78,20 @@ function addSubstringAsTextNode(root: HTMLElement, text: string, startIndex: num
|
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
function ungroupRanges(ranges: MarkdownRange[]): MarkdownRange[] {
|
|
82
|
+
const ungroupedRanges: MarkdownRange[] = [];
|
|
83
|
+
ranges.forEach((range) => {
|
|
84
|
+
if (!range.depth) {
|
|
85
|
+
ungroupedRanges.push(range);
|
|
86
|
+
}
|
|
87
|
+
const {depth, ...rangeWithoutDepth} = range;
|
|
88
|
+
Array.from({length: depth!}).forEach(() => {
|
|
89
|
+
ungroupedRanges.push(rangeWithoutDepth);
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
return ungroupedRanges;
|
|
93
|
+
}
|
|
94
|
+
|
|
81
95
|
function parseRangesToHTMLNodes(text: string, ranges: MarkdownRange[], markdownStyle: PartialMarkdownStyle = {}, disableInlineStyles = false): HTMLElement {
|
|
82
96
|
const root: HTMLElement = document.createElement('span');
|
|
83
97
|
root.className = 'root';
|
|
@@ -87,7 +101,7 @@ function parseRangesToHTMLNodes(text: string, ranges: MarkdownRange[], markdownS
|
|
|
87
101
|
return root;
|
|
88
102
|
}
|
|
89
103
|
|
|
90
|
-
const stack =
|
|
104
|
+
const stack = ungroupRanges(ranges);
|
|
91
105
|
const nestedStack: NestedNode[] = [{node: root, endIndex: textLength}];
|
|
92
106
|
let lastRangeEndIndex = 0;
|
|
93
107
|
while (stack.length > 0) {
|