@expensify/react-native-live-markdown 0.1.190 → 0.1.192
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/README.md
CHANGED
|
@@ -20,7 +20,7 @@ npm install @expensify/react-native-live-markdown react-native-reanimated expens
|
|
|
20
20
|
npx expo install @expensify/react-native-live-markdown react-native-reanimated expensify-common
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
React Native Live Markdown requires [react-native-reanimated](https://github.com/software-mansion/react-native-reanimated) 3.16.3 or newer and [expensify-common](https://github.com/Expensify/expensify-common) 2.0.
|
|
23
|
+
React Native Live Markdown requires [react-native-reanimated](https://github.com/software-mansion/react-native-reanimated) 3.16.3 or newer and [expensify-common](https://github.com/Expensify/expensify-common) 2.0.108 or newer.
|
|
24
24
|
|
|
25
25
|
Then, install the iOS dependencies with CocoaPods:
|
|
26
26
|
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
package com.expensify.livemarkdown;
|
|
2
|
+
|
|
3
|
+
public class MarkdownRange {
|
|
4
|
+
private final String mType;
|
|
5
|
+
private final int mStart;
|
|
6
|
+
private final int mLength;
|
|
7
|
+
private final int mDepth;
|
|
8
|
+
|
|
9
|
+
public MarkdownRange(String type, int start, int length, int depth) {
|
|
10
|
+
mType = type;
|
|
11
|
+
mStart = start;
|
|
12
|
+
mLength = length;
|
|
13
|
+
mDepth = depth;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
public String getType() {
|
|
17
|
+
return mType;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public int getStart() {
|
|
21
|
+
return mStart;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public int getLength() {
|
|
25
|
+
return mLength;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public int getDepth() {
|
|
29
|
+
return mDepth;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -16,6 +16,8 @@ import org.json.JSONArray;
|
|
|
16
16
|
import org.json.JSONException;
|
|
17
17
|
import org.json.JSONObject;
|
|
18
18
|
|
|
19
|
+
import java.util.LinkedList;
|
|
20
|
+
import java.util.List;
|
|
19
21
|
import java.util.Objects;
|
|
20
22
|
|
|
21
23
|
public class MarkdownUtils {
|
|
@@ -68,6 +70,7 @@ public class MarkdownUtils {
|
|
|
68
70
|
mPrevParserId = mParserId;
|
|
69
71
|
}
|
|
70
72
|
|
|
73
|
+
List<MarkdownRange> markdownRanges = new LinkedList<>();
|
|
71
74
|
try {
|
|
72
75
|
JSONArray ranges = new JSONArray(output);
|
|
73
76
|
for (int i = 0; i < ranges.length(); i++) {
|
|
@@ -80,14 +83,21 @@ public class MarkdownUtils {
|
|
|
80
83
|
if (length == 0 || end > input.length()) {
|
|
81
84
|
continue;
|
|
82
85
|
}
|
|
83
|
-
|
|
86
|
+
markdownRanges.add(new MarkdownRange(type, start, length, depth));
|
|
84
87
|
}
|
|
85
88
|
} catch (JSONException e) {
|
|
86
89
|
RNLog.w(mReactContext, "[react-native-live-markdown] Incorrect schema of worklet parser output: " + e.getMessage());
|
|
87
90
|
}
|
|
91
|
+
|
|
92
|
+
for (MarkdownRange markdownRange : markdownRanges) {
|
|
93
|
+
applyRange(ssb, markdownRange);
|
|
94
|
+
}
|
|
88
95
|
}
|
|
89
96
|
|
|
90
|
-
private void applyRange(SpannableStringBuilder ssb,
|
|
97
|
+
private void applyRange(SpannableStringBuilder ssb, MarkdownRange markdownRange) {
|
|
98
|
+
String type = markdownRange.getType();
|
|
99
|
+
int start = markdownRange.getStart();
|
|
100
|
+
int end = start + markdownRange.getLength();
|
|
91
101
|
switch (type) {
|
|
92
102
|
case "bold":
|
|
93
103
|
setSpan(ssb, new MarkdownBoldSpan(), start, end);
|
|
@@ -149,7 +159,7 @@ public class MarkdownUtils {
|
|
|
149
159
|
mMarkdownStyle.getBlockquoteBorderWidth(),
|
|
150
160
|
mMarkdownStyle.getBlockquoteMarginLeft(),
|
|
151
161
|
mMarkdownStyle.getBlockquotePaddingLeft(),
|
|
152
|
-
|
|
162
|
+
markdownRange.getDepth());
|
|
153
163
|
setSpan(ssb, span, start, end);
|
|
154
164
|
break;
|
|
155
165
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@expensify/react-native-live-markdown",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.192",
|
|
4
4
|
"description": "Drop-in replacement for React Native's TextInput component with Markdown formatting.",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"eslint-plugin-prettier": "^4.0.0",
|
|
85
85
|
"eslint-plugin-promise": "^6.1.1",
|
|
86
86
|
"eslint-plugin-tsdoc": "^0.2.17",
|
|
87
|
-
"expensify-common": "2.0.
|
|
87
|
+
"expensify-common": "2.0.108",
|
|
88
88
|
"jest": "^29.6.3",
|
|
89
89
|
"jest-environment-jsdom": "^29.7.0",
|
|
90
90
|
"nodemon": "^3.1.3",
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
"typescript": "~5.3.3"
|
|
101
101
|
},
|
|
102
102
|
"peerDependencies": {
|
|
103
|
-
"expensify-common": ">=2.0.
|
|
103
|
+
"expensify-common": ">=2.0.108",
|
|
104
104
|
"react": "*",
|
|
105
105
|
"react-native": "*",
|
|
106
106
|
"react-native-reanimated": ">=3.16.3"
|