@expensify/react-native-live-markdown 0.1.200 → 0.1.202

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.
@@ -20,7 +20,7 @@ public class MarkdownFormatter {
20
20
  mAssetManager = assetManager;
21
21
  }
22
22
 
23
- public void format(SpannableStringBuilder ssb, List<MarkdownRange> markdownRanges, @NonNull MarkdownStyle markdownStyle) {
23
+ public void format(@NonNull SpannableStringBuilder ssb, @NonNull List<MarkdownRange> markdownRanges, @NonNull MarkdownStyle markdownStyle) {
24
24
  try {
25
25
  Systrace.beginSection(0, "format");
26
26
  Objects.requireNonNull(markdownStyle, "mMarkdownStyle is null");
@@ -31,7 +31,7 @@ public class MarkdownFormatter {
31
31
  }
32
32
  }
33
33
 
34
- private void removeSpans(SpannableStringBuilder ssb) {
34
+ private void removeSpans(@NonNull SpannableStringBuilder ssb) {
35
35
  try {
36
36
  Systrace.beginSection(0, "removeSpans");
37
37
  // We shouldn't use `removeSpans()` because it also removes SpellcheckSpan, SuggestionSpan etc.
@@ -44,7 +44,7 @@ public class MarkdownFormatter {
44
44
  }
45
45
  }
46
46
 
47
- private void applyRanges(SpannableStringBuilder ssb, List<MarkdownRange> markdownRanges, @NonNull MarkdownStyle markdownStyle) {
47
+ private void applyRanges(@NonNull SpannableStringBuilder ssb, @NonNull List<MarkdownRange> markdownRanges, @NonNull MarkdownStyle markdownStyle) {
48
48
  try {
49
49
  Systrace.beginSection(0, "applyRanges");
50
50
  for (MarkdownRange markdownRange : markdownRanges) {
@@ -55,10 +55,10 @@ public class MarkdownFormatter {
55
55
  }
56
56
  }
57
57
 
58
- private void applyRange(SpannableStringBuilder ssb, MarkdownRange markdownRange, MarkdownStyle markdownStyle) {
58
+ private void applyRange(@NonNull SpannableStringBuilder ssb, @NonNull MarkdownRange markdownRange, @NonNull MarkdownStyle markdownStyle) {
59
59
  String type = markdownRange.getType();
60
60
  int start = markdownRange.getStart();
61
- int end = start + markdownRange.getLength();
61
+ int end = markdownRange.getEnd();
62
62
  switch (type) {
63
63
  case "bold":
64
64
  setSpan(ssb, new MarkdownBoldSpan(), start, end);
@@ -126,7 +126,7 @@ public class MarkdownFormatter {
126
126
  }
127
127
  }
128
128
 
129
- private void setSpan(SpannableStringBuilder ssb, MarkdownSpan span, int start, int end) {
129
+ private void setSpan(@NonNull SpannableStringBuilder ssb, @NonNull MarkdownSpan span, int start, int end) {
130
130
  ssb.setSpan(span, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
131
131
  }
132
132
  }
@@ -29,9 +29,9 @@ public class MarkdownParser {
29
29
  mReactContext = reactContext;
30
30
  }
31
31
 
32
- private native String nativeParse(String text, int parserId);
32
+ private native String nativeParse(@NonNull String text, int parserId);
33
33
 
34
- public synchronized List<MarkdownRange> parse(String text, int parserId) {
34
+ public synchronized List<MarkdownRange> parse(@NonNull String text, int parserId) {
35
35
  try {
36
36
  Systrace.beginSection(0, "parse");
37
37
 
@@ -1,14 +1,18 @@
1
1
  package com.expensify.livemarkdown;
2
2
 
3
+ import androidx.annotation.NonNull;
4
+
3
5
  public class MarkdownRange {
4
- private final String mType;
6
+ private final @NonNull String mType;
5
7
  private final int mStart;
8
+ private final int mEnd;
6
9
  private final int mLength;
7
10
  private final int mDepth;
8
11
 
9
- public MarkdownRange(String type, int start, int length, int depth) {
12
+ public MarkdownRange(@NonNull String type, int start, int length, int depth) {
10
13
  mType = type;
11
14
  mStart = start;
15
+ mEnd = start + length;
12
16
  mLength = length;
13
17
  mDepth = depth;
14
18
  }
@@ -21,6 +25,10 @@ public class MarkdownRange {
21
25
  return mStart;
22
26
  }
23
27
 
28
+ public int getEnd() {
29
+ return mEnd;
30
+ }
31
+
24
32
  public int getLength() {
25
33
  return mLength;
26
34
  }
@@ -32,6 +32,7 @@ public class MarkdownStyle {
32
32
 
33
33
  private final float mBlockquotePaddingLeft;
34
34
 
35
+ @NonNull
35
36
  private final String mCodeFontFamily;
36
37
 
37
38
  private final float mCodeFontSize;
@@ -42,6 +43,7 @@ public class MarkdownStyle {
42
43
  @ColorInt
43
44
  private final int mCodeBackgroundColor;
44
45
 
46
+ @NonNull
45
47
  private final String mPreFontFamily;
46
48
 
47
49
  private final float mPreFontSize;
@@ -7,7 +7,7 @@ import android.text.TextWatcher;
7
7
  import androidx.annotation.NonNull;
8
8
 
9
9
  public class MarkdownTextWatcher implements TextWatcher {
10
- private final MarkdownUtils mMarkdownUtils;
10
+ private final @NonNull MarkdownUtils mMarkdownUtils;
11
11
 
12
12
  public MarkdownTextWatcher(@NonNull MarkdownUtils markdownUtils) {
13
13
  mMarkdownUtils = markdownUtils;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@expensify/react-native-live-markdown",
3
- "version": "0.1.200",
3
+ "version": "0.1.202",
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",