@expensify/react-native-live-markdown 0.1.13 → 0.1.15
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/MarkdownTextInput.web.js +1 -0
- package/lib/commonjs/MarkdownTextInput.web.js.map +1 -1
- package/lib/commonjs/web/parserUtils.js +19 -1
- package/lib/commonjs/web/parserUtils.js.map +1 -1
- package/lib/module/MarkdownTextInput.web.js +1 -0
- package/lib/module/MarkdownTextInput.web.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/MarkdownTextInput.web.d.ts.map +1 -1
- package/lib/typescript/src/web/parserUtils.d.ts.map +1 -1
- package/package.json +5 -5
- package/parser/react-native-live-markdown-parser.js +4 -4
- package/src/MarkdownTextInput.web.tsx +2 -1
- package/src/web/parserUtils.ts +15 -1
|
@@ -250,7 +250,7 @@ const MarkdownTextInput = React.forwardRef<TextInput, MarkdownTextInputProps>(
|
|
|
250
250
|
const text = normalizeValue(divRef.current.innerText || '');
|
|
251
251
|
if (typeof e.target !== 'number') {
|
|
252
252
|
// TODO: change the logic here so every event have value property
|
|
253
|
-
(e.target as HTMLInputElement).value = text;
|
|
253
|
+
(e.target as unknown as HTMLInputElement).value = text;
|
|
254
254
|
}
|
|
255
255
|
e.nativeEvent.text = text;
|
|
256
256
|
}
|
|
@@ -549,6 +549,7 @@ const styles = StyleSheet.create({
|
|
|
549
549
|
borderWidth: 1,
|
|
550
550
|
borderStyle: 'solid',
|
|
551
551
|
fontFamily: 'sans-serif',
|
|
552
|
+
// @ts-expect-error it works on web
|
|
552
553
|
boxSizing: 'border-box',
|
|
553
554
|
whiteSpace: 'pre-wrap',
|
|
554
555
|
overflowY: 'scroll',
|
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) {
|