@expensify/react-native-live-markdown 0.1.127 → 0.1.129
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/RNLiveMarkdown.podspec
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
require "json"
|
|
2
2
|
|
|
3
|
+
react_native_node_modules_dir = ENV['REACT_NATIVE_NODE_MODULES_DIR'] || File.join(File.dirname(`cd "#{Pod::Config.instance.installation_root.to_s}" && node --print "require.resolve('react-native/package.json')"`), '..')
|
|
4
|
+
react_native_json = JSON.parse(File.read(File.join(react_native_node_modules_dir, 'react-native/package.json')))
|
|
5
|
+
react_native_minor_version = react_native_json['version'].split('.')[1].to_i
|
|
6
|
+
|
|
3
7
|
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
8
|
folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
|
|
5
9
|
|
|
@@ -20,6 +24,10 @@ Pod::Spec.new do |s|
|
|
|
20
24
|
|
|
21
25
|
s.dependency "hermes-engine"
|
|
22
26
|
|
|
27
|
+
s.xcconfig = {
|
|
28
|
+
"OTHER_CFLAGS" => "$(inherited) -DREACT_NATIVE_MINOR_VERSION=#{react_native_minor_version}"
|
|
29
|
+
}
|
|
30
|
+
|
|
23
31
|
install_modules_dependencies(s)
|
|
24
32
|
|
|
25
33
|
if ENV['USE_FRAMEWORKS'] && ENV['RCT_NEW_ARCH_ENABLED']
|
package/android/build.gradle
CHANGED
|
@@ -32,6 +32,11 @@ def getExtOrIntegerDefault(name) {
|
|
|
32
32
|
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["LiveMarkdown_" + name]).toInteger()
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
def safeAppExtGet(prop, fallback) {
|
|
36
|
+
def appProject = rootProject.allprojects.find { it.plugins.hasPlugin('com.android.application') }
|
|
37
|
+
appProject?.ext?.has(prop) ? appProject.ext.get(prop) : fallback
|
|
38
|
+
}
|
|
39
|
+
|
|
35
40
|
def supportsNamespace() {
|
|
36
41
|
def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
|
|
37
42
|
def major = parsed[0].toInteger()
|
|
@@ -41,6 +46,40 @@ def supportsNamespace() {
|
|
|
41
46
|
return (major == 7 && minor >= 3) || major >= 8
|
|
42
47
|
}
|
|
43
48
|
|
|
49
|
+
def resolveReactNativeDirectory() {
|
|
50
|
+
def reactNativeLocation = safeAppExtGet("REACT_NATIVE_NODE_MODULES_DIR", null)
|
|
51
|
+
if (reactNativeLocation != null) {
|
|
52
|
+
return file(reactNativeLocation)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// monorepo workaround
|
|
56
|
+
// react-native can be hoisted or in project's own node_modules
|
|
57
|
+
def reactNativeFromProjectNodeModules = file("${rootProject.projectDir}/../node_modules/react-native")
|
|
58
|
+
if (reactNativeFromProjectNodeModules.exists()) {
|
|
59
|
+
return reactNativeFromProjectNodeModules
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
def reactNativeFromLiveMarkdownMonorepo = file("${projectDir}/../../../node_modules/react-native")
|
|
63
|
+
if (reactNativeFromLiveMarkdownMonorepo.exists()) {
|
|
64
|
+
return reactNativeFromLiveMarkdownMonorepo
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
def reactNativeFromNodeModulesWithLiveMarkdown = file("${projectDir}/../../react-native")
|
|
68
|
+
if (reactNativeFromNodeModulesWithLiveMarkdown.exists()) {
|
|
69
|
+
return reactNativeFromNodeModulesWithLiveMarkdown
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
throw new GradleException("[react-native-live-markdown] Unable to resolve react-native location in node_modules. Your app should define `REACT_NATIVE_NODE_MODULES_DIR` extension property in `app/build.gradle` with a path to react-native in node_modules.")
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
def getReactNativeMinorVersion() {
|
|
76
|
+
def reactNativeRootDir = resolveReactNativeDirectory()
|
|
77
|
+
def reactNativeProperties = new Properties()
|
|
78
|
+
file("$reactNativeRootDir/ReactAndroid/gradle.properties").withInputStream { reactNativeProperties.load(it) }
|
|
79
|
+
def reactNativeVersion = reactNativeProperties.getProperty("VERSION_NAME")
|
|
80
|
+
return reactNativeVersion.split("\\.")[1].toInteger()
|
|
81
|
+
}
|
|
82
|
+
|
|
44
83
|
android {
|
|
45
84
|
if (supportsNamespace()) {
|
|
46
85
|
namespace "com.expensify.livemarkdown"
|
|
@@ -57,13 +96,17 @@ android {
|
|
|
57
96
|
defaultConfig {
|
|
58
97
|
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
|
|
59
98
|
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
99
|
+
|
|
100
|
+
buildConfigField "int", "REACT_NATIVE_MINOR_VERSION", getReactNativeMinorVersion().toString()
|
|
60
101
|
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
|
61
|
-
|
|
102
|
+
|
|
62
103
|
consumerProguardFiles "proguard-rules.pro"
|
|
63
|
-
|
|
104
|
+
|
|
64
105
|
externalNativeBuild {
|
|
65
106
|
cmake {
|
|
66
|
-
arguments "-DANDROID_STL=c++_shared",
|
|
107
|
+
arguments "-DANDROID_STL=c++_shared",
|
|
108
|
+
"-DANDROID_TOOLCHAIN=clang",
|
|
109
|
+
"-DREACT_NATIVE_MINOR_VERSION=${getReactNativeMinorVersion()}"
|
|
67
110
|
abiFilters (*reactNativeArchitectures())
|
|
68
111
|
}
|
|
69
112
|
}
|
|
@@ -6,6 +6,8 @@ set(CMAKE_VERBOSE_MAKEFILE on)
|
|
|
6
6
|
|
|
7
7
|
add_compile_options(-fvisibility=hidden -fexceptions -frtti)
|
|
8
8
|
|
|
9
|
+
string(APPEND CMAKE_CXX_FLAGS " -DREACT_NATIVE_MINOR_VERSION=${REACT_NATIVE_MINOR_VERSION}")
|
|
10
|
+
|
|
9
11
|
file(GLOB livemarkdown_SRC CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
|
|
10
12
|
|
|
11
13
|
add_library(${CMAKE_PROJECT_NAME} SHARED ${livemarkdown_SRC})
|
|
@@ -13,7 +13,6 @@ import android.text.TextPaint;
|
|
|
13
13
|
import androidx.annotation.NonNull;
|
|
14
14
|
import androidx.annotation.Nullable;
|
|
15
15
|
|
|
16
|
-
import com.facebook.common.logging.FLog;
|
|
17
16
|
import com.facebook.react.bridge.ReactContext;
|
|
18
17
|
import com.facebook.react.bridge.ReadableMap;
|
|
19
18
|
import com.facebook.react.common.mapbuffer.MapBuffer;
|
|
@@ -21,7 +20,7 @@ import com.facebook.react.fabric.mounting.MountingManager;
|
|
|
21
20
|
import com.facebook.react.uimanager.PixelUtil;
|
|
22
21
|
import com.facebook.react.uimanager.ViewManagerRegistry;
|
|
23
22
|
import com.facebook.react.views.text.TextAttributeProps;
|
|
24
|
-
import com.facebook.react.views.text.
|
|
23
|
+
import com.facebook.react.views.text.TextLayoutManager;
|
|
25
24
|
import com.facebook.react.views.text.internal.span.TextInlineViewPlaceholderSpan;
|
|
26
25
|
import com.facebook.yoga.YogaMeasureMode;
|
|
27
26
|
import com.facebook.yoga.YogaMeasureOutput;
|
|
@@ -63,7 +62,7 @@ public class CustomMountingManager extends MountingManager {
|
|
|
63
62
|
@Nullable float[] attachmentsPositions) {
|
|
64
63
|
|
|
65
64
|
Spannable text =
|
|
66
|
-
|
|
65
|
+
TextLayoutManager.getOrCreateSpannableForText(context, attributedString, null);
|
|
67
66
|
|
|
68
67
|
if (text == null) {
|
|
69
68
|
return 0;
|
|
@@ -71,14 +70,14 @@ public class CustomMountingManager extends MountingManager {
|
|
|
71
70
|
|
|
72
71
|
int textBreakStrategy =
|
|
73
72
|
TextAttributeProps.getTextBreakStrategy(
|
|
74
|
-
paragraphAttributes.getString(
|
|
73
|
+
paragraphAttributes.getString(TextLayoutManager.PA_KEY_TEXT_BREAK_STRATEGY));
|
|
75
74
|
boolean includeFontPadding =
|
|
76
|
-
paragraphAttributes.contains(
|
|
77
|
-
? paragraphAttributes.getBoolean(
|
|
75
|
+
paragraphAttributes.contains(TextLayoutManager.PA_KEY_INCLUDE_FONT_PADDING)
|
|
76
|
+
? paragraphAttributes.getBoolean(TextLayoutManager.PA_KEY_INCLUDE_FONT_PADDING)
|
|
78
77
|
: DEFAULT_INCLUDE_FONT_PADDING;
|
|
79
78
|
int hyphenationFrequency =
|
|
80
79
|
TextAttributeProps.getHyphenationFrequency(
|
|
81
|
-
paragraphAttributes.getString(
|
|
80
|
+
paragraphAttributes.getString(TextLayoutManager.PA_KEY_HYPHENATION_FREQUENCY));
|
|
82
81
|
|
|
83
82
|
// StaticLayout returns wrong metrics for the last line if it's empty, add something to the
|
|
84
83
|
// last line so it's measured correctly
|
|
@@ -89,13 +88,15 @@ public class CustomMountingManager extends MountingManager {
|
|
|
89
88
|
text = sb;
|
|
90
89
|
}
|
|
91
90
|
|
|
91
|
+
Layout.Alignment alignment = TextLayoutManager.getTextAlignment(attributedString, text);
|
|
92
|
+
|
|
92
93
|
markdownUtils.applyMarkdownFormatting((SpannableStringBuilder)text);
|
|
93
94
|
|
|
94
95
|
BoringLayout.Metrics boring = BoringLayout.isBoring(text, sTextPaintInstance);
|
|
95
96
|
|
|
96
|
-
Class<
|
|
97
|
+
Class<TextLayoutManager> mapBufferClass = TextLayoutManager.class;
|
|
97
98
|
try {
|
|
98
|
-
Method createLayoutMethod = mapBufferClass.getDeclaredMethod("createLayout", Spannable.class, BoringLayout.Metrics.class, float.class, YogaMeasureMode.class, boolean.class, int.class, int.class);
|
|
99
|
+
Method createLayoutMethod = mapBufferClass.getDeclaredMethod("createLayout", Spannable.class, BoringLayout.Metrics.class, float.class, YogaMeasureMode.class, boolean.class, int.class, int.class, Layout.Alignment.class);
|
|
99
100
|
createLayoutMethod.setAccessible(true);
|
|
100
101
|
|
|
101
102
|
Layout layout = (Layout)createLayoutMethod.invoke(
|
|
@@ -106,11 +107,12 @@ public class CustomMountingManager extends MountingManager {
|
|
|
106
107
|
widthYogaMeasureMode,
|
|
107
108
|
includeFontPadding,
|
|
108
109
|
textBreakStrategy,
|
|
109
|
-
hyphenationFrequency
|
|
110
|
+
hyphenationFrequency,
|
|
111
|
+
alignment);
|
|
110
112
|
|
|
111
113
|
int maximumNumberOfLines =
|
|
112
|
-
paragraphAttributes.contains(
|
|
113
|
-
? paragraphAttributes.getInt(
|
|
114
|
+
paragraphAttributes.contains(TextLayoutManager.PA_KEY_MAX_NUMBER_OF_LINES)
|
|
115
|
+
? paragraphAttributes.getInt(TextLayoutManager.PA_KEY_MAX_NUMBER_OF_LINES)
|
|
114
116
|
: UNSET;
|
|
115
117
|
|
|
116
118
|
int calculatedLineCount =
|
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.129",
|
|
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",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"@commitlint/config-conventional": "^17.0.2",
|
|
66
66
|
"@evilmartians/lefthook": "^1.5.0",
|
|
67
67
|
"@lwc/eslint-plugin-lwc": "^1.7.2",
|
|
68
|
-
"@react-native/eslint-config": "
|
|
68
|
+
"@react-native/eslint-config": "0.75.2",
|
|
69
69
|
"@release-it/conventional-changelog": "^5.0.0",
|
|
70
70
|
"@types/jest": "^28.1.2",
|
|
71
71
|
"@types/react": "~17.0.21",
|
|
@@ -90,8 +90,8 @@
|
|
|
90
90
|
"jest-environment-jsdom": "^29.7.0",
|
|
91
91
|
"nodemon": "^3.1.3",
|
|
92
92
|
"prettier": "2.8.8",
|
|
93
|
-
"react": "18.
|
|
94
|
-
"react-native": "0.
|
|
93
|
+
"react": "18.3.1",
|
|
94
|
+
"react-native": "0.75.2",
|
|
95
95
|
"react-native-builder-bob": "^0.20.0",
|
|
96
96
|
"react-native-web": "^0.19.10",
|
|
97
97
|
"release-it": "^15.0.0",
|
|
@@ -100,8 +100,7 @@
|
|
|
100
100
|
},
|
|
101
101
|
"resolutions": {
|
|
102
102
|
"@types/react": "17.0.21",
|
|
103
|
-
"link@^2.1.1": "patch:link@npm%3A2.1.1#./.yarn/patches/link-npm-2.1.1-1c9fea076e.patch"
|
|
104
|
-
"react-native@0.74.5": "patch:react-native@npm%3A0.74.5#./.yarn/patches/react-native-npm-0.74.5-3cfd406787.patch"
|
|
103
|
+
"link@^2.1.1": "patch:link@npm%3A2.1.1#./.yarn/patches/link-npm-2.1.1-1c9fea076e.patch"
|
|
105
104
|
},
|
|
106
105
|
"peerDependencies": {
|
|
107
106
|
"react": "*",
|