react-native-enriched 0.0.0 → 0.1.1
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/LICENSE +20 -0
- package/README.md +875 -0
- package/ReactNativeEnriched.podspec +27 -0
- package/android/build.gradle +101 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedTextInputViewManagerDelegate.java +146 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedTextInputViewManagerInterface.java +55 -0
- package/android/generated/jni/react/renderer/components/RNEnrichedTextInputViewSpec/ComponentDescriptors.cpp +22 -0
- package/android/generated/jni/react/renderer/components/RNEnrichedTextInputViewSpec/ComponentDescriptors.h +24 -0
- package/android/generated/jni/react/renderer/components/RNEnrichedTextInputViewSpec/EventEmitters.cpp +118 -0
- package/android/generated/jni/react/renderer/components/RNEnrichedTextInputViewSpec/EventEmitters.h +95 -0
- package/android/generated/jni/react/renderer/components/RNEnrichedTextInputViewSpec/Props.cpp +128 -0
- package/android/generated/jni/react/renderer/components/RNEnrichedTextInputViewSpec/Props.h +577 -0
- package/android/generated/jni/react/renderer/components/RNEnrichedTextInputViewSpec/ShadowNodes.cpp +17 -0
- package/android/generated/jni/react/renderer/components/RNEnrichedTextInputViewSpec/ShadowNodes.h +23 -0
- package/android/generated/jni/react/renderer/components/RNEnrichedTextInputViewSpec/States.cpp +16 -0
- package/android/generated/jni/react/renderer/components/RNEnrichedTextInputViewSpec/States.h +20 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/java/com/swmansion/enriched/EnrichedTextInputView.kt +535 -0
- package/android/src/main/java/com/swmansion/enriched/EnrichedTextInputViewLayoutManager.kt +64 -0
- package/android/src/main/java/com/swmansion/enriched/EnrichedTextInputViewManager.kt +292 -0
- package/android/src/main/java/com/swmansion/enriched/EnrichedTextInputViewPackage.kt +19 -0
- package/android/src/main/java/com/swmansion/enriched/events/MentionHandler.kt +40 -0
- package/android/src/main/java/com/swmansion/enriched/events/OnChangeHtmlEvent.kt +28 -0
- package/android/src/main/java/com/swmansion/enriched/events/OnChangeSelectionEvent.kt +29 -0
- package/android/src/main/java/com/swmansion/enriched/events/OnChangeStateEvent.kt +24 -0
- package/android/src/main/java/com/swmansion/enriched/events/OnChangeTextEvent.kt +30 -0
- package/android/src/main/java/com/swmansion/enriched/events/OnInputBlurEvent.kt +27 -0
- package/android/src/main/java/com/swmansion/enriched/events/OnInputFocusEvent.kt +27 -0
- package/android/src/main/java/com/swmansion/enriched/events/OnLinkDetectedEvent.kt +30 -0
- package/android/src/main/java/com/swmansion/enriched/events/OnMentionDetectedEvent.kt +29 -0
- package/android/src/main/java/com/swmansion/enriched/events/OnMentionEvent.kt +33 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedBlockQuoteSpan.kt +34 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedBoldSpan.kt +10 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedCodeBlockSpan.kt +38 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedH1Span.kt +17 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedH2Span.kt +17 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedH3Span.kt +17 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedImageSpan.kt +41 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedInlineCodeSpan.kt +16 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedItalicSpan.kt +10 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedLinkSpan.kt +24 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedMentionSpan.kt +36 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedOrderedListSpan.kt +71 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedSpans.kt +111 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedStrikeThroughSpan.kt +9 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedUnderlineSpan.kt +9 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedUnorderedListSpan.kt +49 -0
- package/android/src/main/java/com/swmansion/enriched/spans/interfaces/EnrichedBlockSpan.kt +4 -0
- package/android/src/main/java/com/swmansion/enriched/spans/interfaces/EnrichedHeadingSpan.kt +4 -0
- package/android/src/main/java/com/swmansion/enriched/spans/interfaces/EnrichedInlineSpan.kt +4 -0
- package/android/src/main/java/com/swmansion/enriched/spans/interfaces/EnrichedParagraphSpan.kt +4 -0
- package/android/src/main/java/com/swmansion/enriched/spans/interfaces/EnrichedSpan.kt +4 -0
- package/android/src/main/java/com/swmansion/enriched/spans/interfaces/EnrichedZeroWidthSpaceSpan.kt +5 -0
- package/android/src/main/java/com/swmansion/enriched/styles/HtmlStyle.kt +227 -0
- package/android/src/main/java/com/swmansion/enriched/styles/InlineStyles.kt +146 -0
- package/android/src/main/java/com/swmansion/enriched/styles/ListStyles.kt +173 -0
- package/android/src/main/java/com/swmansion/enriched/styles/ParagraphStyles.kt +186 -0
- package/android/src/main/java/com/swmansion/enriched/styles/ParametrizedStyles.kt +223 -0
- package/android/src/main/java/com/swmansion/enriched/utils/EnrichedParser.java +857 -0
- package/android/src/main/java/com/swmansion/enriched/utils/EnrichedSelection.kt +285 -0
- package/android/src/main/java/com/swmansion/enriched/utils/EnrichedSpanState.kt +204 -0
- package/android/src/main/java/com/swmansion/enriched/utils/Utils.kt +91 -0
- package/android/src/main/java/com/swmansion/enriched/watchers/EnrichedSpanWatcher.kt +73 -0
- package/android/src/main/java/com/swmansion/enriched/watchers/EnrichedTextWatcher.kt +51 -0
- package/android/src/main/new_arch/CMakeLists.txt +56 -0
- package/android/src/main/new_arch/RNEnrichedTextInputViewSpec.cpp +22 -0
- package/android/src/main/new_arch/RNEnrichedTextInputViewSpec.h +26 -0
- package/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputComponentDescriptor.h +35 -0
- package/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputMeasurementManager.cpp +51 -0
- package/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputMeasurementManager.h +26 -0
- package/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputShadowNode.cpp +34 -0
- package/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputShadowNode.h +54 -0
- package/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputState.cpp +9 -0
- package/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputState.h +25 -0
- package/ios/EnrichedTextInputView.h +33 -0
- package/ios/EnrichedTextInputView.mm +1190 -0
- package/ios/EnrichedTextInputViewManager.mm +13 -0
- package/ios/config/InputConfig.h +67 -0
- package/ios/config/InputConfig.mm +382 -0
- package/ios/generated/RNEnrichedTextInputViewSpec/ComponentDescriptors.cpp +22 -0
- package/ios/generated/RNEnrichedTextInputViewSpec/ComponentDescriptors.h +24 -0
- package/ios/generated/RNEnrichedTextInputViewSpec/EventEmitters.cpp +118 -0
- package/ios/generated/RNEnrichedTextInputViewSpec/EventEmitters.h +95 -0
- package/ios/generated/RNEnrichedTextInputViewSpec/Props.cpp +128 -0
- package/ios/generated/RNEnrichedTextInputViewSpec/Props.h +577 -0
- package/ios/generated/RNEnrichedTextInputViewSpec/RCTComponentViewHelpers.h +384 -0
- package/ios/generated/RNEnrichedTextInputViewSpec/ShadowNodes.cpp +17 -0
- package/ios/generated/RNEnrichedTextInputViewSpec/ShadowNodes.h +23 -0
- package/ios/generated/RNEnrichedTextInputViewSpec/States.cpp +16 -0
- package/ios/generated/RNEnrichedTextInputViewSpec/States.h +20 -0
- package/ios/inputParser/InputParser.h +11 -0
- package/ios/inputParser/InputParser.mm +659 -0
- package/ios/inputTextView/InputTextView.h +6 -0
- package/ios/inputTextView/InputTextView.mm +115 -0
- package/ios/internals/EnrichedTextInputViewComponentDescriptor.h +17 -0
- package/ios/internals/EnrichedTextInputViewShadowNode.h +40 -0
- package/ios/internals/EnrichedTextInputViewShadowNode.mm +83 -0
- package/ios/internals/EnrichedTextInputViewState.cpp +10 -0
- package/ios/internals/EnrichedTextInputViewState.h +20 -0
- package/ios/styles/BlockQuoteStyle.mm +248 -0
- package/ios/styles/BoldStyle.mm +122 -0
- package/ios/styles/H1Style.mm +10 -0
- package/ios/styles/H2Style.mm +10 -0
- package/ios/styles/H3Style.mm +10 -0
- package/ios/styles/HeadingStyleBase.mm +144 -0
- package/ios/styles/InlineCodeStyle.mm +163 -0
- package/ios/styles/ItalicStyle.mm +110 -0
- package/ios/styles/LinkStyle.mm +463 -0
- package/ios/styles/MentionStyle.mm +476 -0
- package/ios/styles/OrderedListStyle.mm +225 -0
- package/ios/styles/StrikethroughStyle.mm +80 -0
- package/ios/styles/UnderlineStyle.mm +112 -0
- package/ios/styles/UnorderedListStyle.mm +225 -0
- package/ios/utils/BaseStyleProtocol.h +16 -0
- package/ios/utils/ColorExtension.h +6 -0
- package/ios/utils/ColorExtension.mm +27 -0
- package/ios/utils/FontExtension.h +13 -0
- package/ios/utils/FontExtension.mm +91 -0
- package/ios/utils/LayoutManagerExtension.h +6 -0
- package/ios/utils/LayoutManagerExtension.mm +171 -0
- package/ios/utils/LinkData.h +9 -0
- package/ios/utils/LinkData.mm +4 -0
- package/ios/utils/MentionParams.h +9 -0
- package/ios/utils/MentionParams.mm +4 -0
- package/ios/utils/MentionStyleProps.h +13 -0
- package/ios/utils/MentionStyleProps.mm +56 -0
- package/ios/utils/OccurenceUtils.h +37 -0
- package/ios/utils/OccurenceUtils.mm +124 -0
- package/ios/utils/ParagraphsUtils.h +7 -0
- package/ios/utils/ParagraphsUtils.mm +54 -0
- package/ios/utils/StringExtension.h +15 -0
- package/ios/utils/StringExtension.mm +57 -0
- package/ios/utils/StyleHeaders.h +74 -0
- package/ios/utils/StylePair.h +9 -0
- package/ios/utils/StylePair.mm +4 -0
- package/ios/utils/StyleTypeEnum.h +22 -0
- package/ios/utils/TextDecorationLineEnum.h +6 -0
- package/ios/utils/TextDecorationLineEnum.mm +4 -0
- package/ios/utils/TextInsertionUtils.h +6 -0
- package/ios/utils/TextInsertionUtils.mm +48 -0
- package/ios/utils/WordsUtils.h +6 -0
- package/ios/utils/WordsUtils.mm +88 -0
- package/ios/utils/ZeroWidthSpaceUtils.h +7 -0
- package/ios/utils/ZeroWidthSpaceUtils.mm +164 -0
- package/lib/module/EnrichedTextInput.js +191 -0
- package/lib/module/EnrichedTextInput.js.map +1 -0
- package/lib/module/EnrichedTextInputNativeComponent.ts +235 -0
- package/lib/module/index.js +4 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/normalizeHtmlStyle.js +141 -0
- package/lib/module/normalizeHtmlStyle.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/EnrichedTextInput.d.ts +113 -0
- package/lib/typescript/src/EnrichedTextInput.d.ts.map +1 -0
- package/lib/typescript/src/EnrichedTextInputNativeComponent.d.ts +160 -0
- package/lib/typescript/src/EnrichedTextInputNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +3 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/normalizeHtmlStyle.d.ts +4 -0
- package/lib/typescript/src/normalizeHtmlStyle.d.ts.map +1 -0
- package/package.json +172 -1
- package/react-native.config.js +13 -0
- package/src/EnrichedTextInput.tsx +358 -0
- package/src/EnrichedTextInputNativeComponent.ts +235 -0
- package/src/index.tsx +9 -0
- package/src/normalizeHtmlStyle.ts +188 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EnrichedTextInputNativeComponent.d.ts","sourceRoot":"","sources":["../../../src/EnrichedTextInputNativeComponent.ts"],"names":[],"mappings":"AACA,OAAO,KAA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,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,KACZ,IAAI,CAAC;CACX;AAED,eAAO,MAAM,QAAQ,EAAE,cAyBrB,CAAC;wBAIG,aAAa,CAAC,WAAW,CAAC;AAFhC,wBAEiC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,YAAY,EACV,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,oCAAoC,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { HtmlStyle } from './EnrichedTextInput';
|
|
2
|
+
import type { HtmlStyleInternal } from './EnrichedTextInputNativeComponent';
|
|
3
|
+
export declare const normalizeHtmlStyle: (style: HtmlStyle, mentionIndicators: string[]) => HtmlStyleInternal;
|
|
4
|
+
//# sourceMappingURL=normalizeHtmlStyle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalizeHtmlStyle.d.ts","sourceRoot":"","sources":["../../../src/normalizeHtmlStyle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,KAAK,EAEV,iBAAiB,EAClB,MAAM,oCAAoC,CAAC;AA+K5C,eAAO,MAAM,kBAAkB,GAC7B,OAAO,SAAS,EAChB,mBAAmB,MAAM,EAAE,KAC1B,iBAIF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,4 +1,175 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-enriched",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Rich Text Editor component for React Native",
|
|
5
|
+
"source": "./src/index.tsx",
|
|
6
|
+
"main": "./lib/module/index.js",
|
|
7
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
11
|
+
"default": "./lib/module/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./package.json": "./package.json"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"src",
|
|
17
|
+
"lib",
|
|
18
|
+
"android",
|
|
19
|
+
"ios",
|
|
20
|
+
"cpp",
|
|
21
|
+
"*.podspec",
|
|
22
|
+
"react-native.config.js",
|
|
23
|
+
"!ios/build",
|
|
24
|
+
"!android/build",
|
|
25
|
+
"!android/gradle",
|
|
26
|
+
"!android/gradlew",
|
|
27
|
+
"!android/gradlew.bat",
|
|
28
|
+
"!android/local.properties",
|
|
29
|
+
"!**/__tests__",
|
|
30
|
+
"!**/__fixtures__",
|
|
31
|
+
"!**/__mocks__",
|
|
32
|
+
"!**/.*"
|
|
33
|
+
],
|
|
34
|
+
"scripts": {
|
|
35
|
+
"example": "yarn workspace react-native-enriched-example",
|
|
36
|
+
"test": "jest --passWithNoTests",
|
|
37
|
+
"typecheck": "tsc",
|
|
38
|
+
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
39
|
+
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
|
|
40
|
+
"prepare": "bob build",
|
|
41
|
+
"release": "release-it",
|
|
42
|
+
"android-studio": "open -a 'Android Studio' example/android"
|
|
43
|
+
},
|
|
44
|
+
"keywords": [
|
|
45
|
+
"react-native",
|
|
46
|
+
"ios",
|
|
47
|
+
"android"
|
|
48
|
+
],
|
|
49
|
+
"repository": {
|
|
50
|
+
"type": "git",
|
|
51
|
+
"url": "git+https://github.com/software-mansion-labs/react-native-enriched.git"
|
|
52
|
+
},
|
|
53
|
+
"author": "Software Mansion <contact@swmansion.com> (https://swmansion.com)",
|
|
54
|
+
"license": "MIT",
|
|
55
|
+
"bugs": {
|
|
56
|
+
"url": "https://github.com/software-mansion-labs/react-native-enriched/issues"
|
|
57
|
+
},
|
|
58
|
+
"homepage": "https://github.com/software-mansion-labs/react-native-enriched#readme",
|
|
59
|
+
"publishConfig": {
|
|
60
|
+
"registry": "https://registry.npmjs.org/"
|
|
61
|
+
},
|
|
62
|
+
"devDependencies": {
|
|
63
|
+
"@commitlint/config-conventional": "^19.6.0",
|
|
64
|
+
"@eslint/compat": "^1.2.7",
|
|
65
|
+
"@eslint/eslintrc": "^3.3.0",
|
|
66
|
+
"@eslint/js": "^9.22.0",
|
|
67
|
+
"@evilmartians/lefthook": "^1.5.0",
|
|
68
|
+
"@react-native-community/cli": "20.0.0",
|
|
69
|
+
"@react-native/eslint-config": "^0.81.0",
|
|
70
|
+
"@release-it/conventional-changelog": "^9.0.2",
|
|
71
|
+
"@types/jest": "^29.5.5",
|
|
72
|
+
"@types/react": "^19.1.0",
|
|
73
|
+
"commitlint": "^19.6.1",
|
|
74
|
+
"del-cli": "^5.1.0",
|
|
75
|
+
"eslint": "^9.22.0",
|
|
76
|
+
"eslint-config-prettier": "^10.1.1",
|
|
77
|
+
"eslint-plugin-prettier": "^5.2.3",
|
|
78
|
+
"jest": "^29.7.0",
|
|
79
|
+
"prettier": "^3.0.3",
|
|
80
|
+
"react": "19.1.0",
|
|
81
|
+
"react-native": "0.81.0",
|
|
82
|
+
"react-native-builder-bob": "^0.40.6",
|
|
83
|
+
"release-it": "^17.10.0",
|
|
84
|
+
"turbo": "^1.10.7",
|
|
85
|
+
"typescript": "^5.8.3"
|
|
86
|
+
},
|
|
87
|
+
"peerDependencies": {
|
|
88
|
+
"react": "*",
|
|
89
|
+
"react-native": "*"
|
|
90
|
+
},
|
|
91
|
+
"workspaces": [
|
|
92
|
+
"example"
|
|
93
|
+
],
|
|
94
|
+
"packageManager": "yarn@3.6.1",
|
|
95
|
+
"jest": {
|
|
96
|
+
"preset": "react-native",
|
|
97
|
+
"modulePathIgnorePatterns": [
|
|
98
|
+
"<rootDir>/example/node_modules",
|
|
99
|
+
"<rootDir>/lib/"
|
|
100
|
+
]
|
|
101
|
+
},
|
|
102
|
+
"commitlint": {
|
|
103
|
+
"extends": [
|
|
104
|
+
"@commitlint/config-conventional"
|
|
105
|
+
]
|
|
106
|
+
},
|
|
107
|
+
"release-it": {
|
|
108
|
+
"git": {
|
|
109
|
+
"commitMessage": "chore: release ${version}",
|
|
110
|
+
"tagName": "v${version}"
|
|
111
|
+
},
|
|
112
|
+
"npm": {
|
|
113
|
+
"publish": true
|
|
114
|
+
},
|
|
115
|
+
"github": {
|
|
116
|
+
"release": true
|
|
117
|
+
},
|
|
118
|
+
"plugins": {
|
|
119
|
+
"@release-it/conventional-changelog": {
|
|
120
|
+
"preset": {
|
|
121
|
+
"name": "angular"
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
"prettier": {
|
|
127
|
+
"quoteProps": "consistent",
|
|
128
|
+
"singleQuote": true,
|
|
129
|
+
"tabWidth": 2,
|
|
130
|
+
"trailingComma": "es5",
|
|
131
|
+
"useTabs": false
|
|
132
|
+
},
|
|
133
|
+
"react-native-builder-bob": {
|
|
134
|
+
"source": "src",
|
|
135
|
+
"output": "lib",
|
|
136
|
+
"targets": [
|
|
137
|
+
"codegen",
|
|
138
|
+
[
|
|
139
|
+
"module",
|
|
140
|
+
{
|
|
141
|
+
"esm": true
|
|
142
|
+
}
|
|
143
|
+
],
|
|
144
|
+
[
|
|
145
|
+
"typescript",
|
|
146
|
+
{
|
|
147
|
+
"project": "tsconfig.build.json"
|
|
148
|
+
}
|
|
149
|
+
]
|
|
150
|
+
]
|
|
151
|
+
},
|
|
152
|
+
"codegenConfig": {
|
|
153
|
+
"name": "RNEnrichedTextInputViewSpec",
|
|
154
|
+
"type": "components",
|
|
155
|
+
"jsSrcsDir": "src",
|
|
156
|
+
"outputDir": {
|
|
157
|
+
"ios": "ios/generated",
|
|
158
|
+
"android": "android/generated"
|
|
159
|
+
},
|
|
160
|
+
"android": {
|
|
161
|
+
"javaPackageName": "com.swmansion.enriched"
|
|
162
|
+
},
|
|
163
|
+
"ios": {
|
|
164
|
+
"componentProvider": {
|
|
165
|
+
"EnrichedTextInputView": "EnrichedTextInputView"
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
"includesGeneratedCode": true
|
|
169
|
+
},
|
|
170
|
+
"create-react-native-library": {
|
|
171
|
+
"languages": "kotlin-objc",
|
|
172
|
+
"type": "fabric-view",
|
|
173
|
+
"version": "0.49.8"
|
|
174
|
+
}
|
|
4
175
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @type {import('@react-native-community/cli-types').UserDependencyConfig}
|
|
3
|
+
*/
|
|
4
|
+
module.exports = {
|
|
5
|
+
dependency: {
|
|
6
|
+
platforms: {
|
|
7
|
+
android: {
|
|
8
|
+
cmakeListsPath: '../android/src/main/new_arch/CMakeLists.txt',
|
|
9
|
+
componentDescriptors: ['EnrichedTextInputComponentDescriptor'],
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
};
|
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type Component,
|
|
3
|
+
type RefObject,
|
|
4
|
+
useImperativeHandle,
|
|
5
|
+
useMemo,
|
|
6
|
+
useRef,
|
|
7
|
+
} from 'react';
|
|
8
|
+
import EnrichedTextInputNativeComponent, {
|
|
9
|
+
Commands,
|
|
10
|
+
type NativeProps,
|
|
11
|
+
type OnChangeHtmlEvent,
|
|
12
|
+
type OnChangeSelectionEvent,
|
|
13
|
+
type OnChangeStateEvent,
|
|
14
|
+
type OnChangeTextEvent,
|
|
15
|
+
type OnLinkDetected,
|
|
16
|
+
type OnMentionEvent,
|
|
17
|
+
type OnMentionDetected,
|
|
18
|
+
type OnMentionDetectedInternal,
|
|
19
|
+
type MentionStyleProperties,
|
|
20
|
+
} from './EnrichedTextInputNativeComponent';
|
|
21
|
+
import type {
|
|
22
|
+
ColorValue,
|
|
23
|
+
HostInstance,
|
|
24
|
+
MeasureInWindowOnSuccessCallback,
|
|
25
|
+
MeasureLayoutOnSuccessCallback,
|
|
26
|
+
MeasureOnSuccessCallback,
|
|
27
|
+
NativeMethods,
|
|
28
|
+
NativeSyntheticEvent,
|
|
29
|
+
TextStyle,
|
|
30
|
+
ViewProps,
|
|
31
|
+
ViewStyle,
|
|
32
|
+
} from 'react-native';
|
|
33
|
+
import { normalizeHtmlStyle } from './normalizeHtmlStyle';
|
|
34
|
+
|
|
35
|
+
export interface EnrichedTextInputInstance extends NativeMethods {
|
|
36
|
+
// General commands
|
|
37
|
+
focus: () => void;
|
|
38
|
+
blur: () => void;
|
|
39
|
+
setValue: (value: string) => void;
|
|
40
|
+
|
|
41
|
+
// Text formatting commands
|
|
42
|
+
toggleBold: () => void;
|
|
43
|
+
toggleItalic: () => void;
|
|
44
|
+
toggleUnderline: () => void;
|
|
45
|
+
toggleStrikeThrough: () => void;
|
|
46
|
+
toggleInlineCode: () => void;
|
|
47
|
+
toggleH1: () => void;
|
|
48
|
+
toggleH2: () => void;
|
|
49
|
+
toggleH3: () => void;
|
|
50
|
+
toggleCodeBlock: () => void;
|
|
51
|
+
toggleBlockQuote: () => void;
|
|
52
|
+
toggleOrderedList: () => void;
|
|
53
|
+
toggleUnorderedList: () => void;
|
|
54
|
+
setLink: (start: number, end: number, text: string, url: string) => void;
|
|
55
|
+
setImage: (src: string) => void;
|
|
56
|
+
startMention: (indicator: string) => void;
|
|
57
|
+
setMention: (
|
|
58
|
+
indicator: string,
|
|
59
|
+
text: string,
|
|
60
|
+
attributes?: Record<string, string>
|
|
61
|
+
) => void;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface OnChangeMentionEvent {
|
|
65
|
+
indicator: string;
|
|
66
|
+
text: string;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface HtmlStyle {
|
|
70
|
+
h1?: {
|
|
71
|
+
fontSize?: number;
|
|
72
|
+
bold?: boolean;
|
|
73
|
+
};
|
|
74
|
+
h2?: {
|
|
75
|
+
fontSize?: number;
|
|
76
|
+
bold?: boolean;
|
|
77
|
+
};
|
|
78
|
+
h3?: {
|
|
79
|
+
fontSize?: number;
|
|
80
|
+
bold?: boolean;
|
|
81
|
+
};
|
|
82
|
+
blockquote?: {
|
|
83
|
+
borderColor?: ColorValue;
|
|
84
|
+
borderWidth?: number;
|
|
85
|
+
gapWidth?: number;
|
|
86
|
+
color?: ColorValue;
|
|
87
|
+
};
|
|
88
|
+
codeblock?: {
|
|
89
|
+
color?: ColorValue;
|
|
90
|
+
borderRadius?: number;
|
|
91
|
+
backgroundColor?: ColorValue;
|
|
92
|
+
};
|
|
93
|
+
code?: {
|
|
94
|
+
color?: ColorValue;
|
|
95
|
+
backgroundColor?: ColorValue;
|
|
96
|
+
};
|
|
97
|
+
a?: {
|
|
98
|
+
color?: ColorValue;
|
|
99
|
+
textDecorationLine?: 'underline' | 'none';
|
|
100
|
+
};
|
|
101
|
+
mention?: Record<string, MentionStyleProperties> | MentionStyleProperties;
|
|
102
|
+
img?: {
|
|
103
|
+
width?: number;
|
|
104
|
+
height?: number;
|
|
105
|
+
};
|
|
106
|
+
ol?: {
|
|
107
|
+
gapWidth?: number;
|
|
108
|
+
marginLeft?: number;
|
|
109
|
+
markerFontWeight?: TextStyle['fontWeight'];
|
|
110
|
+
markerColor?: ColorValue;
|
|
111
|
+
};
|
|
112
|
+
ul?: {
|
|
113
|
+
bulletColor?: ColorValue;
|
|
114
|
+
bulletSize?: number;
|
|
115
|
+
marginLeft?: number;
|
|
116
|
+
gapWidth?: number;
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export interface EnrichedTextInputProps extends Omit<ViewProps, 'children'> {
|
|
121
|
+
ref?: RefObject<EnrichedTextInputInstance | null>;
|
|
122
|
+
autoFocus?: boolean;
|
|
123
|
+
editable?: boolean;
|
|
124
|
+
mentionIndicators?: string[];
|
|
125
|
+
defaultValue?: string;
|
|
126
|
+
placeholder?: string;
|
|
127
|
+
placeholderTextColor?: ColorValue;
|
|
128
|
+
cursorColor?: ColorValue;
|
|
129
|
+
selectionColor?: ColorValue;
|
|
130
|
+
autoCapitalize?: 'none' | 'sentences' | 'words' | 'characters';
|
|
131
|
+
htmlStyle?: HtmlStyle;
|
|
132
|
+
style?: ViewStyle | TextStyle;
|
|
133
|
+
onFocus?: () => void;
|
|
134
|
+
onBlur?: () => void;
|
|
135
|
+
onChangeText?: (e: NativeSyntheticEvent<OnChangeTextEvent>) => void;
|
|
136
|
+
onChangeHtml?: (e: NativeSyntheticEvent<OnChangeHtmlEvent>) => void;
|
|
137
|
+
onChangeState?: (e: NativeSyntheticEvent<OnChangeStateEvent>) => void;
|
|
138
|
+
onLinkDetected?: (e: OnLinkDetected) => void;
|
|
139
|
+
onMentionDetected?: (e: OnMentionDetected) => void;
|
|
140
|
+
onStartMention?: (indicator: string) => void;
|
|
141
|
+
onChangeMention?: (e: OnChangeMentionEvent) => void;
|
|
142
|
+
onEndMention?: (indicator: string) => void;
|
|
143
|
+
onChangeSelection?: (e: NativeSyntheticEvent<OnChangeSelectionEvent>) => void;
|
|
144
|
+
/**
|
|
145
|
+
* If true, Android will use experimental synchronous events.
|
|
146
|
+
* This will prevent from input flickering when updating component size.
|
|
147
|
+
* However, this is an experimental feature, which has not been thoroughly tested.
|
|
148
|
+
* We may decide to enable it by default in a future release.
|
|
149
|
+
* Disabled by default.
|
|
150
|
+
*/
|
|
151
|
+
androidExperimentalSynchronousEvents?: boolean;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const nullthrows = <T,>(value: T | null | undefined): T => {
|
|
155
|
+
if (value == null) {
|
|
156
|
+
throw new Error('Unexpected null or undefined value');
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return value;
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
const warnAboutMissconfiguredMentions = (indicator: string) => {
|
|
163
|
+
console.warn(
|
|
164
|
+
`Looks like you are trying to set a "${indicator}" but it's not in the mentionIndicators prop`
|
|
165
|
+
);
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
type ComponentType = (Component<NativeProps, {}, any> & NativeMethods) | null;
|
|
169
|
+
|
|
170
|
+
export const EnrichedTextInput = ({
|
|
171
|
+
ref,
|
|
172
|
+
autoFocus,
|
|
173
|
+
editable = true,
|
|
174
|
+
mentionIndicators = ['@'],
|
|
175
|
+
defaultValue,
|
|
176
|
+
placeholder,
|
|
177
|
+
placeholderTextColor,
|
|
178
|
+
cursorColor,
|
|
179
|
+
selectionColor,
|
|
180
|
+
style,
|
|
181
|
+
autoCapitalize = 'sentences',
|
|
182
|
+
htmlStyle = {},
|
|
183
|
+
onFocus,
|
|
184
|
+
onBlur,
|
|
185
|
+
onChangeText,
|
|
186
|
+
onChangeHtml,
|
|
187
|
+
onChangeState,
|
|
188
|
+
onLinkDetected,
|
|
189
|
+
onMentionDetected,
|
|
190
|
+
onStartMention,
|
|
191
|
+
onChangeMention,
|
|
192
|
+
onEndMention,
|
|
193
|
+
onChangeSelection,
|
|
194
|
+
androidExperimentalSynchronousEvents = false,
|
|
195
|
+
...rest
|
|
196
|
+
}: EnrichedTextInputProps) => {
|
|
197
|
+
const nativeRef = useRef<ComponentType | null>(null);
|
|
198
|
+
|
|
199
|
+
const normalizedHtmlStyle = useMemo(
|
|
200
|
+
() => normalizeHtmlStyle(htmlStyle, mentionIndicators),
|
|
201
|
+
[htmlStyle, mentionIndicators]
|
|
202
|
+
);
|
|
203
|
+
|
|
204
|
+
useImperativeHandle(ref, () => ({
|
|
205
|
+
measureInWindow: (callback: MeasureInWindowOnSuccessCallback) => {
|
|
206
|
+
nullthrows(nativeRef.current).measureInWindow(callback);
|
|
207
|
+
},
|
|
208
|
+
measure: (callback: MeasureOnSuccessCallback) => {
|
|
209
|
+
nullthrows(nativeRef.current).measure(callback);
|
|
210
|
+
},
|
|
211
|
+
measureLayout: (
|
|
212
|
+
relativeToNativeComponentRef: HostInstance | number,
|
|
213
|
+
onSuccess: MeasureLayoutOnSuccessCallback,
|
|
214
|
+
onFail?: () => void
|
|
215
|
+
) => {
|
|
216
|
+
nullthrows(nativeRef.current).measureLayout(
|
|
217
|
+
relativeToNativeComponentRef,
|
|
218
|
+
onSuccess,
|
|
219
|
+
onFail
|
|
220
|
+
);
|
|
221
|
+
},
|
|
222
|
+
setNativeProps: (nativeProps: object) => {
|
|
223
|
+
nullthrows(nativeRef.current).setNativeProps(nativeProps);
|
|
224
|
+
},
|
|
225
|
+
focus: () => {
|
|
226
|
+
Commands.focus(nullthrows(nativeRef.current));
|
|
227
|
+
},
|
|
228
|
+
blur: () => {
|
|
229
|
+
Commands.blur(nullthrows(nativeRef.current));
|
|
230
|
+
},
|
|
231
|
+
setValue: (value: string) => {
|
|
232
|
+
Commands.setValue(nullthrows(nativeRef.current), value);
|
|
233
|
+
},
|
|
234
|
+
toggleBold: () => {
|
|
235
|
+
Commands.toggleBold(nullthrows(nativeRef.current));
|
|
236
|
+
},
|
|
237
|
+
toggleItalic: () => {
|
|
238
|
+
Commands.toggleItalic(nullthrows(nativeRef.current));
|
|
239
|
+
},
|
|
240
|
+
toggleUnderline: () => {
|
|
241
|
+
Commands.toggleUnderline(nullthrows(nativeRef.current));
|
|
242
|
+
},
|
|
243
|
+
toggleStrikeThrough: () => {
|
|
244
|
+
Commands.toggleStrikeThrough(nullthrows(nativeRef.current));
|
|
245
|
+
},
|
|
246
|
+
toggleInlineCode: () => {
|
|
247
|
+
Commands.toggleInlineCode(nullthrows(nativeRef.current));
|
|
248
|
+
},
|
|
249
|
+
toggleH1: () => {
|
|
250
|
+
Commands.toggleH1(nullthrows(nativeRef.current));
|
|
251
|
+
},
|
|
252
|
+
toggleH2: () => {
|
|
253
|
+
Commands.toggleH2(nullthrows(nativeRef.current));
|
|
254
|
+
},
|
|
255
|
+
toggleH3: () => {
|
|
256
|
+
Commands.toggleH3(nullthrows(nativeRef.current));
|
|
257
|
+
},
|
|
258
|
+
toggleCodeBlock: () => {
|
|
259
|
+
Commands.toggleCodeBlock(nullthrows(nativeRef.current));
|
|
260
|
+
},
|
|
261
|
+
toggleBlockQuote: () => {
|
|
262
|
+
Commands.toggleBlockQuote(nullthrows(nativeRef.current));
|
|
263
|
+
},
|
|
264
|
+
toggleOrderedList: () => {
|
|
265
|
+
Commands.toggleOrderedList(nullthrows(nativeRef.current));
|
|
266
|
+
},
|
|
267
|
+
toggleUnorderedList: () => {
|
|
268
|
+
Commands.toggleUnorderedList(nullthrows(nativeRef.current));
|
|
269
|
+
},
|
|
270
|
+
setLink: (start: number, end: number, text: string, url: string) => {
|
|
271
|
+
Commands.addLink(nullthrows(nativeRef.current), start, end, text, url);
|
|
272
|
+
},
|
|
273
|
+
setImage: (uri: string) => {
|
|
274
|
+
Commands.addImage(nullthrows(nativeRef.current), uri);
|
|
275
|
+
},
|
|
276
|
+
setMention: (
|
|
277
|
+
indicator: string,
|
|
278
|
+
text: string,
|
|
279
|
+
attributes?: Record<string, string>
|
|
280
|
+
) => {
|
|
281
|
+
// Codegen does not support objects as Commands parameters, so we stringify attributes
|
|
282
|
+
const parsedAttributes = JSON.stringify(attributes ?? {});
|
|
283
|
+
|
|
284
|
+
Commands.addMention(
|
|
285
|
+
nullthrows(nativeRef.current),
|
|
286
|
+
indicator,
|
|
287
|
+
text,
|
|
288
|
+
parsedAttributes
|
|
289
|
+
);
|
|
290
|
+
},
|
|
291
|
+
startMention: (indicator: string) => {
|
|
292
|
+
if (!mentionIndicators?.includes(indicator)) {
|
|
293
|
+
warnAboutMissconfiguredMentions(indicator);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
Commands.startMention(nullthrows(nativeRef.current), indicator);
|
|
297
|
+
},
|
|
298
|
+
}));
|
|
299
|
+
|
|
300
|
+
const handleMentionEvent = (e: NativeSyntheticEvent<OnMentionEvent>) => {
|
|
301
|
+
const mentionText = e.nativeEvent.text;
|
|
302
|
+
const mentionIndicator = e.nativeEvent.indicator;
|
|
303
|
+
|
|
304
|
+
if (typeof mentionText === 'string') {
|
|
305
|
+
if (mentionText === '') {
|
|
306
|
+
onStartMention?.(mentionIndicator);
|
|
307
|
+
} else {
|
|
308
|
+
onChangeMention?.({ indicator: mentionIndicator, text: mentionText });
|
|
309
|
+
}
|
|
310
|
+
} else if (mentionText === null) {
|
|
311
|
+
onEndMention?.(mentionIndicator);
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
const handleLinkDetected = (e: NativeSyntheticEvent<OnLinkDetected>) => {
|
|
316
|
+
const { text, url, start, end } = e.nativeEvent;
|
|
317
|
+
onLinkDetected?.({ text, url, start, end });
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
const handleMentionDetected = (
|
|
321
|
+
e: NativeSyntheticEvent<OnMentionDetectedInternal>
|
|
322
|
+
) => {
|
|
323
|
+
const { text, indicator, payload } = e.nativeEvent;
|
|
324
|
+
const attributes = JSON.parse(payload) as Record<string, string>;
|
|
325
|
+
onMentionDetected?.({ text, indicator, attributes });
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
return (
|
|
329
|
+
<EnrichedTextInputNativeComponent
|
|
330
|
+
ref={nativeRef}
|
|
331
|
+
mentionIndicators={mentionIndicators}
|
|
332
|
+
editable={editable}
|
|
333
|
+
autoFocus={autoFocus}
|
|
334
|
+
defaultValue={defaultValue}
|
|
335
|
+
placeholder={placeholder}
|
|
336
|
+
placeholderTextColor={placeholderTextColor}
|
|
337
|
+
cursorColor={cursorColor}
|
|
338
|
+
selectionColor={selectionColor}
|
|
339
|
+
style={style}
|
|
340
|
+
autoCapitalize={autoCapitalize}
|
|
341
|
+
htmlStyle={normalizedHtmlStyle}
|
|
342
|
+
onInputFocus={onFocus}
|
|
343
|
+
onInputBlur={onBlur}
|
|
344
|
+
onChangeText={onChangeText}
|
|
345
|
+
onChangeHtml={onChangeHtml}
|
|
346
|
+
isOnChangeHtmlSet={onChangeHtml !== undefined}
|
|
347
|
+
onChangeState={onChangeState}
|
|
348
|
+
onLinkDetected={handleLinkDetected}
|
|
349
|
+
onMentionDetected={handleMentionDetected}
|
|
350
|
+
onMention={handleMentionEvent}
|
|
351
|
+
onChangeSelection={onChangeSelection}
|
|
352
|
+
androidExperimentalSynchronousEvents={
|
|
353
|
+
androidExperimentalSynchronousEvents
|
|
354
|
+
}
|
|
355
|
+
{...rest}
|
|
356
|
+
/>
|
|
357
|
+
);
|
|
358
|
+
};
|