react-native-enriched 0.2.1 → 0.3.0
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 +15 -12
- package/android/build.gradle +77 -72
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedTextInputViewManagerDelegate.java +18 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedTextInputViewManagerInterface.java +6 -0
- package/android/generated/jni/react/renderer/components/RNEnrichedTextInputViewSpec/EventEmitters.cpp +146 -0
- package/android/generated/jni/react/renderer/components/RNEnrichedTextInputViewSpec/EventEmitters.h +140 -0
- package/android/generated/jni/react/renderer/components/RNEnrichedTextInputViewSpec/Props.cpp +10 -0
- package/android/generated/jni/react/renderer/components/RNEnrichedTextInputViewSpec/Props.h +194 -0
- package/android/lint.gradle +70 -0
- package/android/src/main/java/com/swmansion/enriched/EnrichedTextInputConnectionWrapper.kt +140 -0
- package/android/src/main/java/com/swmansion/enriched/EnrichedTextInputView.kt +245 -116
- package/android/src/main/java/com/swmansion/enriched/EnrichedTextInputViewLayoutManager.kt +3 -1
- package/android/src/main/java/com/swmansion/enriched/EnrichedTextInputViewManager.kt +162 -53
- package/android/src/main/java/com/swmansion/enriched/EnrichedTextInputViewPackage.kt +1 -3
- package/android/src/main/java/com/swmansion/enriched/MeasurementStore.kt +70 -21
- package/android/src/main/java/com/swmansion/enriched/events/MentionHandler.kt +20 -10
- package/android/src/main/java/com/swmansion/enriched/events/OnChangeHtmlEvent.kt +8 -9
- package/android/src/main/java/com/swmansion/enriched/events/OnChangeSelectionEvent.kt +10 -9
- package/android/src/main/java/com/swmansion/enriched/events/OnChangeStateDeprecatedEvent.kt +21 -0
- package/android/src/main/java/com/swmansion/enriched/events/OnChangeStateEvent.kt +9 -12
- package/android/src/main/java/com/swmansion/enriched/events/OnChangeTextEvent.kt +10 -10
- package/android/src/main/java/com/swmansion/enriched/events/OnInputBlurEvent.kt +7 -9
- package/android/src/main/java/com/swmansion/enriched/events/OnInputFocusEvent.kt +7 -9
- package/android/src/main/java/com/swmansion/enriched/events/OnInputKeyPressEvent.kt +27 -0
- package/android/src/main/java/com/swmansion/enriched/events/OnLinkDetectedEvent.kt +13 -11
- package/android/src/main/java/com/swmansion/enriched/events/OnMentionDetectedEvent.kt +10 -9
- package/android/src/main/java/com/swmansion/enriched/events/OnMentionEvent.kt +9 -8
- package/android/src/main/java/com/swmansion/enriched/events/OnRequestHtmlResultEvent.kt +1 -2
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedBlockQuoteSpan.kt +21 -8
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedBoldSpan.kt +5 -4
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedCodeBlockSpan.kt +7 -5
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedH1Span.kt +5 -4
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedH2Span.kt +5 -4
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedH3Span.kt +5 -4
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedH4Span.kt +24 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedH5Span.kt +24 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedH6Span.kt +24 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedImageSpan.kt +29 -17
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedInlineCodeSpan.kt +5 -4
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedItalicSpan.kt +5 -4
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedLinkSpan.kt +7 -7
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedMentionSpan.kt +11 -14
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedOrderedListSpan.kt +15 -14
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedSpans.kt +167 -71
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedStrikeThroughSpan.kt +5 -4
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedUnderlineSpan.kt +5 -4
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedUnorderedListSpan.kt +8 -8
- package/android/src/main/java/com/swmansion/enriched/spans/interfaces/EnrichedBlockSpan.kt +3 -2
- package/android/src/main/java/com/swmansion/enriched/spans/interfaces/EnrichedHeadingSpan.kt +1 -2
- package/android/src/main/java/com/swmansion/enriched/spans/interfaces/EnrichedInlineSpan.kt +1 -2
- package/android/src/main/java/com/swmansion/enriched/spans/interfaces/EnrichedParagraphSpan.kt +3 -2
- package/android/src/main/java/com/swmansion/enriched/spans/interfaces/EnrichedSpan.kt +1 -0
- package/android/src/main/java/com/swmansion/enriched/spans/interfaces/EnrichedZeroWidthSpaceSpan.kt +1 -2
- package/android/src/main/java/com/swmansion/enriched/spans/utils/ForceRedrawSpan.kt +2 -1
- package/android/src/main/java/com/swmansion/enriched/styles/HtmlStyle.kt +78 -21
- package/android/src/main/java/com/swmansion/enriched/styles/InlineStyles.kt +25 -8
- package/android/src/main/java/com/swmansion/enriched/styles/ListStyles.kt +60 -20
- package/android/src/main/java/com/swmansion/enriched/styles/ParagraphStyles.kt +86 -26
- package/android/src/main/java/com/swmansion/enriched/styles/ParametrizedStyles.kt +128 -52
- package/android/src/main/java/com/swmansion/enriched/utils/AsyncDrawable.kt +10 -7
- package/android/src/main/java/com/swmansion/enriched/utils/EnrichedConstants.kt +11 -0
- package/android/src/main/java/com/swmansion/enriched/utils/EnrichedEditableFactory.kt +17 -0
- package/android/src/main/java/com/swmansion/enriched/utils/EnrichedParser.java +128 -87
- package/android/src/main/java/com/swmansion/enriched/utils/EnrichedSelection.kt +71 -42
- package/android/src/main/java/com/swmansion/enriched/utils/EnrichedSpanState.kt +183 -48
- package/android/src/main/java/com/swmansion/enriched/utils/EnrichedSpannable.kt +82 -0
- package/android/src/main/java/com/swmansion/enriched/utils/EnrichedSpannableStringBuilder.kt +15 -0
- package/android/src/main/java/com/swmansion/enriched/utils/Utils.kt +0 -70
- package/android/src/main/java/com/swmansion/enriched/watchers/EnrichedSpanWatcher.kt +46 -14
- package/android/src/main/java/com/swmansion/enriched/watchers/EnrichedTextWatcher.kt +34 -11
- package/android/src/main/new_arch/CMakeLists.txt +6 -0
- package/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/conversions.h +21 -1
- package/ios/EnrichedTextInputView.h +1 -1
- package/ios/EnrichedTextInputView.mm +381 -49
- package/ios/config/InputConfig.h +18 -0
- package/ios/config/InputConfig.mm +118 -8
- package/ios/generated/RNEnrichedTextInputViewSpec/EventEmitters.cpp +146 -0
- package/ios/generated/RNEnrichedTextInputViewSpec/EventEmitters.h +140 -0
- package/ios/generated/RNEnrichedTextInputViewSpec/Props.cpp +10 -0
- package/ios/generated/RNEnrichedTextInputViewSpec/Props.h +194 -0
- package/ios/generated/RNEnrichedTextInputViewSpec/RCTComponentViewHelpers.h +74 -0
- package/ios/inputParser/InputParser.mm +83 -10
- package/ios/{attachments → interfaces}/ImageAttachment.mm +3 -1
- package/ios/interfaces/LinkRegexConfig.h +19 -0
- package/ios/interfaces/LinkRegexConfig.mm +37 -0
- package/ios/{utils → interfaces}/MentionStyleProps.mm +2 -2
- package/ios/{utils → interfaces}/StyleHeaders.h +10 -0
- package/ios/{utils → interfaces}/StyleTypeEnum.h +3 -0
- package/ios/styles/BlockQuoteStyle.mm +5 -5
- package/ios/styles/BoldStyle.mm +21 -6
- package/ios/styles/CodeBlockStyle.mm +5 -5
- package/ios/styles/H4Style.mm +17 -0
- package/ios/styles/H5Style.mm +17 -0
- package/ios/styles/H6Style.mm +17 -0
- package/ios/styles/HeadingStyleBase.mm +27 -10
- package/ios/styles/ImageStyle.mm +5 -5
- package/ios/styles/InlineCodeStyle.mm +30 -19
- package/ios/styles/ItalicStyle.mm +5 -5
- package/ios/styles/LinkStyle.mm +98 -40
- package/ios/styles/MentionStyle.mm +4 -4
- package/ios/styles/OrderedListStyle.mm +5 -5
- package/ios/styles/StrikethroughStyle.mm +5 -5
- package/ios/styles/UnderlineStyle.mm +5 -5
- package/ios/styles/UnorderedListStyle.mm +5 -5
- package/ios/utils/ParagraphAttributesUtils.h +4 -0
- package/ios/utils/ParagraphAttributesUtils.mm +67 -0
- package/ios/utils/ParagraphsUtils.mm +4 -4
- package/lib/module/EnrichedTextInput.js +22 -1
- package/lib/module/EnrichedTextInput.js.map +1 -1
- package/lib/module/EnrichedTextInputNativeComponent.ts +138 -12
- package/lib/module/{normalizeHtmlStyle.js → utils/normalizeHtmlStyle.js} +12 -0
- package/lib/module/utils/normalizeHtmlStyle.js.map +1 -0
- package/lib/module/utils/regexParser.js +46 -0
- package/lib/module/utils/regexParser.js.map +1 -0
- package/lib/typescript/src/EnrichedTextInput.d.ts +23 -14
- package/lib/typescript/src/EnrichedTextInput.d.ts.map +1 -1
- package/lib/typescript/src/EnrichedTextInputNativeComponent.d.ts +123 -12
- package/lib/typescript/src/EnrichedTextInputNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/utils/normalizeHtmlStyle.d.ts +4 -0
- package/lib/typescript/src/utils/normalizeHtmlStyle.d.ts.map +1 -0
- package/lib/typescript/src/utils/regexParser.d.ts +3 -0
- package/lib/typescript/src/utils/regexParser.d.ts.map +1 -0
- package/package.json +10 -6
- package/src/EnrichedTextInput.tsx +51 -13
- package/src/EnrichedTextInputNativeComponent.ts +138 -12
- package/src/index.tsx +2 -0
- package/src/{normalizeHtmlStyle.ts → utils/normalizeHtmlStyle.ts} +14 -2
- package/src/utils/regexParser.ts +56 -0
- package/lib/module/normalizeHtmlStyle.js.map +0 -1
- package/lib/typescript/src/normalizeHtmlStyle.d.ts +0 -4
- package/lib/typescript/src/normalizeHtmlStyle.d.ts.map +0 -1
- /package/ios/{utils → extensions}/ColorExtension.h +0 -0
- /package/ios/{utils → extensions}/ColorExtension.mm +0 -0
- /package/ios/{utils → extensions}/FontExtension.h +0 -0
- /package/ios/{utils → extensions}/FontExtension.mm +0 -0
- /package/ios/{utils → extensions}/LayoutManagerExtension.h +0 -0
- /package/ios/{utils → extensions}/LayoutManagerExtension.mm +0 -0
- /package/ios/{utils → extensions}/StringExtension.h +0 -0
- /package/ios/{utils → extensions}/StringExtension.mm +0 -0
- /package/ios/{utils → interfaces}/BaseStyleProtocol.h +0 -0
- /package/ios/{attachments → interfaces}/ImageAttachment.h +0 -0
- /package/ios/{utils → interfaces}/ImageData.h +0 -0
- /package/ios/{utils → interfaces}/ImageData.mm +0 -0
- /package/ios/{utils → interfaces}/LinkData.h +0 -0
- /package/ios/{utils → interfaces}/LinkData.mm +0 -0
- /package/ios/{attachments → interfaces}/MediaAttachment.h +0 -0
- /package/ios/{attachments → interfaces}/MediaAttachment.mm +0 -0
- /package/ios/{utils → interfaces}/MentionParams.h +0 -0
- /package/ios/{utils → interfaces}/MentionParams.mm +0 -0
- /package/ios/{utils → interfaces}/MentionStyleProps.h +0 -0
- /package/ios/{utils → interfaces}/StylePair.h +0 -0
- /package/ios/{utils → interfaces}/StylePair.mm +0 -0
- /package/ios/{utils → interfaces}/TextDecorationLineEnum.h +0 -0
- /package/ios/{utils → interfaces}/TextDecorationLineEnum.mm +0 -0
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
`EnrichedTextInput`, the rich text editor component is an uncontrolled input. This means that it doesn't use any state or props to store its value, but instead directly interacts with the underlying platform-specific components. Thanks to this, the component is really performant and simple to use while offering complex and advanced features no other solution has.
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+

|
|
17
17
|
|
|
18
18
|
Since 2012 [Software Mansion](https://swmansion.com) is a software agency with experience in building web and mobile apps. We are Core React Native Contributors and experts in dealing with all kinds of React Native issues.
|
|
19
19
|
We can help you build your next dream product –
|
|
@@ -101,7 +101,7 @@ export default function App() {
|
|
|
101
101
|
<View style={styles.container}>
|
|
102
102
|
<EnrichedTextInput
|
|
103
103
|
ref={ref}
|
|
104
|
-
onChangeState={e => setStylesState(e.nativeEvent)}
|
|
104
|
+
onChangeState={(e) => setStylesState(e.nativeEvent)}
|
|
105
105
|
style={styles.input}
|
|
106
106
|
/>
|
|
107
107
|
<Button
|
|
@@ -127,13 +127,16 @@ const styles = StyleSheet.create({
|
|
|
127
127
|
backgroundColor: 'lightgray',
|
|
128
128
|
},
|
|
129
129
|
});
|
|
130
|
-
|
|
131
130
|
```
|
|
132
131
|
|
|
133
132
|
Summary of what happens here:
|
|
134
133
|
|
|
135
134
|
1. Any methods imperatively called on the input to e.g. toggle some style must be used through a `ref` of `EnrichedTextInputInstance` type. Here, `toggleBold` method that is called on the button press calls `ref.current?.toggleBold()`, which toggles the bold styling within the current selection.
|
|
136
|
-
2. All
|
|
135
|
+
2. All style state information is emitted by the `onChangeState` event. Set up a proper callback that accepts a `NativeSyntheticEvent<OnChangeStateEvent>` argument. The event payload provides a nested object for each style (e.g., `bold`, `italic`), containing three properties to guide your UI logic:
|
|
136
|
+
|
|
137
|
+
- `isActive`: Indicates if the style is currently applied (highlight the button).
|
|
138
|
+
- `isBlocking`: Indicates if the style is blocked by another active style (disable the button).
|
|
139
|
+
- `isConflicting`: Indicates if the style is in conflict with another active style.
|
|
137
140
|
|
|
138
141
|
## Non Parametrized Styles
|
|
139
142
|
|
|
@@ -144,9 +147,7 @@ Supported styles:
|
|
|
144
147
|
- underline
|
|
145
148
|
- strikethrough
|
|
146
149
|
- inline code
|
|
147
|
-
- H1
|
|
148
|
-
- H2 heading
|
|
149
|
-
- H3 heading
|
|
150
|
+
- H1, H2, H3, H4, H5 and H6 headings
|
|
150
151
|
- codeblock
|
|
151
152
|
- blockquote
|
|
152
153
|
- ordered list
|
|
@@ -158,8 +159,8 @@ Each call toggles the style within the current text selection. We can still divi
|
|
|
158
159
|
|
|
159
160
|
- Inline styles (bold, italic, underline, strikethrough, inline code). They are being toggled on exactly the character range that is currently selected. When toggling the style with just the cursor in place (no selection), the style is ready to be used and will be applied to the next characters that the user inputs.
|
|
160
161
|
|
|
161
|
-
- Paragraph styles (headings, codeblock, blockquote, lists). They are being toggled on the entire paragraph that the selection is in. By paragraph we mean a part of the text between two newlines (enters) or the text's beginning/ending.
|
|
162
|
-
If the selection spans more than one paragraph, logically more of them will be affected by the toggle. Toggling these styles with the cursor in place (no selection) makes changes to the very paragraph the cursor is in.
|
|
162
|
+
- Paragraph styles (headings, codeblock, blockquote, lists). They are being toggled on the entire paragraph that the selection is in. By paragraph, we mean a part of the text between two newlines (enters) or the text's beginning/ending.
|
|
163
|
+
If the selection spans more than one paragraph, logically more of them will be affected by the toggle. Toggling these styles with the cursor in place (no selection) makes changes to the very paragraph the cursor is in.
|
|
163
164
|
|
|
164
165
|
## Links
|
|
165
166
|
|
|
@@ -167,7 +168,8 @@ The links are here, just like in any other editor, a piece of text with a URL at
|
|
|
167
168
|
|
|
168
169
|
### Automatic links detection
|
|
169
170
|
|
|
170
|
-
`react-native-enriched` automatically detects words that appear to be some URLs and makes them links.
|
|
171
|
+
`react-native-enriched` automatically detects words that appear to be some URLs and makes them links.
|
|
172
|
+
You can customize this behavior by providing your own regular expression via [linkRegex](docs/API_REFERENCE.md#linkregex) prop.
|
|
171
173
|
|
|
172
174
|
### Applying links manually
|
|
173
175
|
|
|
@@ -226,10 +228,11 @@ You can find some examples in the [usage section](#usage) or in the example app.
|
|
|
226
228
|
- [onChangeSelection](docs/API_REFERENCE.md#onchangeselection) - returns all the data needed for working with selections (as of now it's mainly useful for [links](#links)).
|
|
227
229
|
- [onLinkDetected](docs/API_REFERENCE.md#onlinkdetected) - returns link's detailed info whenever user selection is near one.
|
|
228
230
|
- [onMentionDetected](docs/API_REFERENCE.md#onmentiondetected) - returns mention's detailed info whenever user selection is near one.
|
|
231
|
+
- [onKeyPress](docs/API_REFERENCE.md#onkeypress) - emits whenever a key is pressed. Follows react-native TextInput's onKeyPress event [spec](https://reactnative.dev/docs/textinput#onkeypress).
|
|
229
232
|
|
|
230
233
|
## Customizing \<EnrichedTextInput /> styles
|
|
231
234
|
|
|
232
|
-
`react-native-enriched` allows customizing styles of the `<EnrichedTextInput />` component.
|
|
235
|
+
`react-native-enriched` allows customizing styles of the `<EnrichedTextInput />` component. See [htmlStyle](docs/API_REFERENCE.md#htmlstyle) prop.
|
|
233
236
|
|
|
234
237
|
## API Reference
|
|
235
238
|
|
|
@@ -243,7 +246,6 @@ See the [API Reference](docs/API_REFERENCE.md) for a detailed overview of all th
|
|
|
243
246
|
## Future Plans
|
|
244
247
|
|
|
245
248
|
- Creating `EnrichedText` text component that supports our HTML output format with all additional interactions like pressing links or mentions.
|
|
246
|
-
- Adding API for custom link detection regex.
|
|
247
249
|
- Web library implementation via `react-native-web`.
|
|
248
250
|
|
|
249
251
|
## Contributing
|
|
@@ -255,6 +257,7 @@ See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the
|
|
|
255
257
|
`react-native-enriched` library is licensed under [The MIT License](./LICENSE).
|
|
256
258
|
|
|
257
259
|
---
|
|
260
|
+
|
|
258
261
|
Built by [Software Mansion](https://swmansion.com/) and sponsored by [Filament](https://filament.dm/).
|
|
259
262
|
|
|
260
263
|
[<img width="128" height="69" alt="Software Mansion Logo" src="https://github.com/user-attachments/assets/f0e18471-a7aa-4e80-86ac-87686a86fe56" />](https://swmansion.com/)
|
package/android/build.gradle
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
buildscript {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
2
|
+
ext.getExtOrDefault = {name ->
|
|
3
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['EnrichedTextInput_' + name]
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
repositories {
|
|
7
|
+
google()
|
|
8
|
+
mavenCentral()
|
|
9
|
+
gradlePluginPortal()
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
dependencies {
|
|
13
|
+
classpath "com.android.tools.build:gradle:8.7.2"
|
|
14
|
+
// noinspection DifferentKotlinGradleVersion
|
|
15
|
+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}"
|
|
16
|
+
classpath "org.jlleitschuh.gradle:ktlint-gradle:14.0.1"
|
|
17
|
+
classpath 'com.diffplug.spotless:spotless-plugin-gradle:8.1.0'
|
|
18
|
+
}
|
|
16
19
|
}
|
|
17
20
|
|
|
18
21
|
|
|
@@ -21,81 +24,83 @@ apply plugin: "kotlin-android"
|
|
|
21
24
|
|
|
22
25
|
apply plugin: "com.facebook.react"
|
|
23
26
|
|
|
27
|
+
apply from: "lint.gradle"
|
|
28
|
+
|
|
24
29
|
def getExtOrIntegerDefault(name) {
|
|
25
|
-
|
|
30
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["EnrichedTextInput_" + name]).toInteger()
|
|
26
31
|
}
|
|
27
32
|
|
|
28
33
|
def supportsNamespace() {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
34
|
+
def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
|
|
35
|
+
def major = parsed[0].toInteger()
|
|
36
|
+
def minor = parsed[1].toInteger()
|
|
32
37
|
|
|
33
|
-
|
|
34
|
-
|
|
38
|
+
// Namespace support was added in 7.3.0
|
|
39
|
+
return (major == 7 && minor >= 3) || major >= 8
|
|
35
40
|
}
|
|
36
41
|
|
|
37
42
|
android {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
43
|
+
if (supportsNamespace()) {
|
|
44
|
+
namespace "com.swmansion.enriched"
|
|
45
|
+
|
|
46
|
+
sourceSets {
|
|
47
|
+
main {
|
|
48
|
+
manifest.srcFile "src/main/AndroidManifestNew.xml"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
|
|
54
|
+
|
|
55
|
+
defaultConfig {
|
|
56
|
+
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
|
|
57
|
+
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
buildFeatures {
|
|
61
|
+
buildConfig true
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
buildTypes {
|
|
65
|
+
release {
|
|
66
|
+
minifyEnabled false
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
lintOptions {
|
|
71
|
+
disable "GradleCompatible"
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
compileOptions {
|
|
75
|
+
sourceCompatibility JavaVersion.VERSION_1_8
|
|
76
|
+
targetCompatibility JavaVersion.VERSION_1_8
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
sourceSets {
|
|
80
|
+
main {
|
|
81
|
+
java.srcDirs += [
|
|
82
|
+
"generated/java",
|
|
83
|
+
"generated/jni"
|
|
84
|
+
]
|
|
85
|
+
}
|
|
86
|
+
}
|
|
82
87
|
}
|
|
83
88
|
|
|
84
89
|
repositories {
|
|
85
|
-
|
|
86
|
-
|
|
90
|
+
mavenCentral()
|
|
91
|
+
google()
|
|
87
92
|
}
|
|
88
93
|
|
|
89
94
|
def kotlin_version = getExtOrDefault("kotlinVersion")
|
|
90
95
|
|
|
91
96
|
dependencies {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
97
|
+
implementation "com.facebook.react:react-android"
|
|
98
|
+
implementation 'org.ccil.cowan.tagsoup:tagsoup:1.2.1'
|
|
99
|
+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
95
100
|
}
|
|
96
101
|
|
|
97
102
|
react {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
103
|
+
jsRootDir = file("../src/")
|
|
104
|
+
libraryName = "EnrichedTextInputView"
|
|
105
|
+
codegenJavaPackageName = "com.swmansion.enriched"
|
|
101
106
|
}
|
|
@@ -58,6 +58,9 @@ public class EnrichedTextInputViewManagerDelegate<T extends View, U extends Base
|
|
|
58
58
|
case "scrollEnabled":
|
|
59
59
|
mViewManager.setScrollEnabled(view, value == null ? false : (boolean) value);
|
|
60
60
|
break;
|
|
61
|
+
case "linkRegex":
|
|
62
|
+
mViewManager.setLinkRegex(view, (ReadableMap) value);
|
|
63
|
+
break;
|
|
61
64
|
case "color":
|
|
62
65
|
mViewManager.setColor(view, ColorPropConverter.getColor(value, view.getContext()));
|
|
63
66
|
break;
|
|
@@ -76,6 +79,9 @@ public class EnrichedTextInputViewManagerDelegate<T extends View, U extends Base
|
|
|
76
79
|
case "isOnChangeHtmlSet":
|
|
77
80
|
mViewManager.setIsOnChangeHtmlSet(view, value == null ? false : (boolean) value);
|
|
78
81
|
break;
|
|
82
|
+
case "isOnChangeTextSet":
|
|
83
|
+
mViewManager.setIsOnChangeTextSet(view, value == null ? false : (boolean) value);
|
|
84
|
+
break;
|
|
79
85
|
case "androidExperimentalSynchronousEvents":
|
|
80
86
|
mViewManager.setAndroidExperimentalSynchronousEvents(view, value == null ? false : (boolean) value);
|
|
81
87
|
break;
|
|
@@ -96,6 +102,9 @@ public class EnrichedTextInputViewManagerDelegate<T extends View, U extends Base
|
|
|
96
102
|
case "setValue":
|
|
97
103
|
mViewManager.setValue(view, args.getString(0));
|
|
98
104
|
break;
|
|
105
|
+
case "setSelection":
|
|
106
|
+
mViewManager.setSelection(view, args.getInt(0), args.getInt(1));
|
|
107
|
+
break;
|
|
99
108
|
case "toggleBold":
|
|
100
109
|
mViewManager.toggleBold(view);
|
|
101
110
|
break;
|
|
@@ -120,6 +129,15 @@ public class EnrichedTextInputViewManagerDelegate<T extends View, U extends Base
|
|
|
120
129
|
case "toggleH3":
|
|
121
130
|
mViewManager.toggleH3(view);
|
|
122
131
|
break;
|
|
132
|
+
case "toggleH4":
|
|
133
|
+
mViewManager.toggleH4(view);
|
|
134
|
+
break;
|
|
135
|
+
case "toggleH5":
|
|
136
|
+
mViewManager.toggleH5(view);
|
|
137
|
+
break;
|
|
138
|
+
case "toggleH6":
|
|
139
|
+
mViewManager.toggleH6(view);
|
|
140
|
+
break;
|
|
123
141
|
case "toggleCodeBlock":
|
|
124
142
|
mViewManager.toggleCodeBlock(view);
|
|
125
143
|
break;
|
|
@@ -27,16 +27,19 @@ public interface EnrichedTextInputViewManagerInterface<T extends View> extends V
|
|
|
27
27
|
void setAutoCapitalize(T view, @Nullable String value);
|
|
28
28
|
void setHtmlStyle(T view, @Nullable ReadableMap value);
|
|
29
29
|
void setScrollEnabled(T view, boolean value);
|
|
30
|
+
void setLinkRegex(T view, @Nullable ReadableMap value);
|
|
30
31
|
void setColor(T view, @Nullable Integer value);
|
|
31
32
|
void setFontSize(T view, float value);
|
|
32
33
|
void setFontFamily(T view, @Nullable String value);
|
|
33
34
|
void setFontWeight(T view, @Nullable String value);
|
|
34
35
|
void setFontStyle(T view, @Nullable String value);
|
|
35
36
|
void setIsOnChangeHtmlSet(T view, boolean value);
|
|
37
|
+
void setIsOnChangeTextSet(T view, boolean value);
|
|
36
38
|
void setAndroidExperimentalSynchronousEvents(T view, boolean value);
|
|
37
39
|
void focus(T view);
|
|
38
40
|
void blur(T view);
|
|
39
41
|
void setValue(T view, String text);
|
|
42
|
+
void setSelection(T view, int start, int end);
|
|
40
43
|
void toggleBold(T view);
|
|
41
44
|
void toggleItalic(T view);
|
|
42
45
|
void toggleUnderline(T view);
|
|
@@ -45,6 +48,9 @@ public interface EnrichedTextInputViewManagerInterface<T extends View> extends V
|
|
|
45
48
|
void toggleH1(T view);
|
|
46
49
|
void toggleH2(T view);
|
|
47
50
|
void toggleH3(T view);
|
|
51
|
+
void toggleH4(T view);
|
|
52
|
+
void toggleH5(T view);
|
|
53
|
+
void toggleH6(T view);
|
|
48
54
|
void toggleCodeBlock(T view);
|
|
49
55
|
void toggleBlockQuote(T view);
|
|
50
56
|
void toggleOrderedList(T view);
|
|
@@ -51,6 +51,140 @@ void EnrichedTextInputViewEventEmitter::onChangeHtml(OnChangeHtml event) const {
|
|
|
51
51
|
|
|
52
52
|
void EnrichedTextInputViewEventEmitter::onChangeState(OnChangeState event) const {
|
|
53
53
|
dispatchEvent("changeState", [event=std::move(event)](jsi::Runtime &runtime) {
|
|
54
|
+
auto payload = jsi::Object(runtime);
|
|
55
|
+
{
|
|
56
|
+
auto bold = jsi::Object(runtime);
|
|
57
|
+
bold.setProperty(runtime, "isActive", event.bold.isActive);
|
|
58
|
+
bold.setProperty(runtime, "isConflicting", event.bold.isConflicting);
|
|
59
|
+
bold.setProperty(runtime, "isBlocking", event.bold.isBlocking);
|
|
60
|
+
payload.setProperty(runtime, "bold", bold);
|
|
61
|
+
}
|
|
62
|
+
{
|
|
63
|
+
auto italic = jsi::Object(runtime);
|
|
64
|
+
italic.setProperty(runtime, "isActive", event.italic.isActive);
|
|
65
|
+
italic.setProperty(runtime, "isConflicting", event.italic.isConflicting);
|
|
66
|
+
italic.setProperty(runtime, "isBlocking", event.italic.isBlocking);
|
|
67
|
+
payload.setProperty(runtime, "italic", italic);
|
|
68
|
+
}
|
|
69
|
+
{
|
|
70
|
+
auto underline = jsi::Object(runtime);
|
|
71
|
+
underline.setProperty(runtime, "isActive", event.underline.isActive);
|
|
72
|
+
underline.setProperty(runtime, "isConflicting", event.underline.isConflicting);
|
|
73
|
+
underline.setProperty(runtime, "isBlocking", event.underline.isBlocking);
|
|
74
|
+
payload.setProperty(runtime, "underline", underline);
|
|
75
|
+
}
|
|
76
|
+
{
|
|
77
|
+
auto strikeThrough = jsi::Object(runtime);
|
|
78
|
+
strikeThrough.setProperty(runtime, "isActive", event.strikeThrough.isActive);
|
|
79
|
+
strikeThrough.setProperty(runtime, "isConflicting", event.strikeThrough.isConflicting);
|
|
80
|
+
strikeThrough.setProperty(runtime, "isBlocking", event.strikeThrough.isBlocking);
|
|
81
|
+
payload.setProperty(runtime, "strikeThrough", strikeThrough);
|
|
82
|
+
}
|
|
83
|
+
{
|
|
84
|
+
auto inlineCode = jsi::Object(runtime);
|
|
85
|
+
inlineCode.setProperty(runtime, "isActive", event.inlineCode.isActive);
|
|
86
|
+
inlineCode.setProperty(runtime, "isConflicting", event.inlineCode.isConflicting);
|
|
87
|
+
inlineCode.setProperty(runtime, "isBlocking", event.inlineCode.isBlocking);
|
|
88
|
+
payload.setProperty(runtime, "inlineCode", inlineCode);
|
|
89
|
+
}
|
|
90
|
+
{
|
|
91
|
+
auto h1 = jsi::Object(runtime);
|
|
92
|
+
h1.setProperty(runtime, "isActive", event.h1.isActive);
|
|
93
|
+
h1.setProperty(runtime, "isConflicting", event.h1.isConflicting);
|
|
94
|
+
h1.setProperty(runtime, "isBlocking", event.h1.isBlocking);
|
|
95
|
+
payload.setProperty(runtime, "h1", h1);
|
|
96
|
+
}
|
|
97
|
+
{
|
|
98
|
+
auto h2 = jsi::Object(runtime);
|
|
99
|
+
h2.setProperty(runtime, "isActive", event.h2.isActive);
|
|
100
|
+
h2.setProperty(runtime, "isConflicting", event.h2.isConflicting);
|
|
101
|
+
h2.setProperty(runtime, "isBlocking", event.h2.isBlocking);
|
|
102
|
+
payload.setProperty(runtime, "h2", h2);
|
|
103
|
+
}
|
|
104
|
+
{
|
|
105
|
+
auto h3 = jsi::Object(runtime);
|
|
106
|
+
h3.setProperty(runtime, "isActive", event.h3.isActive);
|
|
107
|
+
h3.setProperty(runtime, "isConflicting", event.h3.isConflicting);
|
|
108
|
+
h3.setProperty(runtime, "isBlocking", event.h3.isBlocking);
|
|
109
|
+
payload.setProperty(runtime, "h3", h3);
|
|
110
|
+
}
|
|
111
|
+
{
|
|
112
|
+
auto h4 = jsi::Object(runtime);
|
|
113
|
+
h4.setProperty(runtime, "isActive", event.h4.isActive);
|
|
114
|
+
h4.setProperty(runtime, "isConflicting", event.h4.isConflicting);
|
|
115
|
+
h4.setProperty(runtime, "isBlocking", event.h4.isBlocking);
|
|
116
|
+
payload.setProperty(runtime, "h4", h4);
|
|
117
|
+
}
|
|
118
|
+
{
|
|
119
|
+
auto h5 = jsi::Object(runtime);
|
|
120
|
+
h5.setProperty(runtime, "isActive", event.h5.isActive);
|
|
121
|
+
h5.setProperty(runtime, "isConflicting", event.h5.isConflicting);
|
|
122
|
+
h5.setProperty(runtime, "isBlocking", event.h5.isBlocking);
|
|
123
|
+
payload.setProperty(runtime, "h5", h5);
|
|
124
|
+
}
|
|
125
|
+
{
|
|
126
|
+
auto h6 = jsi::Object(runtime);
|
|
127
|
+
h6.setProperty(runtime, "isActive", event.h6.isActive);
|
|
128
|
+
h6.setProperty(runtime, "isConflicting", event.h6.isConflicting);
|
|
129
|
+
h6.setProperty(runtime, "isBlocking", event.h6.isBlocking);
|
|
130
|
+
payload.setProperty(runtime, "h6", h6);
|
|
131
|
+
}
|
|
132
|
+
{
|
|
133
|
+
auto codeBlock = jsi::Object(runtime);
|
|
134
|
+
codeBlock.setProperty(runtime, "isActive", event.codeBlock.isActive);
|
|
135
|
+
codeBlock.setProperty(runtime, "isConflicting", event.codeBlock.isConflicting);
|
|
136
|
+
codeBlock.setProperty(runtime, "isBlocking", event.codeBlock.isBlocking);
|
|
137
|
+
payload.setProperty(runtime, "codeBlock", codeBlock);
|
|
138
|
+
}
|
|
139
|
+
{
|
|
140
|
+
auto blockQuote = jsi::Object(runtime);
|
|
141
|
+
blockQuote.setProperty(runtime, "isActive", event.blockQuote.isActive);
|
|
142
|
+
blockQuote.setProperty(runtime, "isConflicting", event.blockQuote.isConflicting);
|
|
143
|
+
blockQuote.setProperty(runtime, "isBlocking", event.blockQuote.isBlocking);
|
|
144
|
+
payload.setProperty(runtime, "blockQuote", blockQuote);
|
|
145
|
+
}
|
|
146
|
+
{
|
|
147
|
+
auto orderedList = jsi::Object(runtime);
|
|
148
|
+
orderedList.setProperty(runtime, "isActive", event.orderedList.isActive);
|
|
149
|
+
orderedList.setProperty(runtime, "isConflicting", event.orderedList.isConflicting);
|
|
150
|
+
orderedList.setProperty(runtime, "isBlocking", event.orderedList.isBlocking);
|
|
151
|
+
payload.setProperty(runtime, "orderedList", orderedList);
|
|
152
|
+
}
|
|
153
|
+
{
|
|
154
|
+
auto unorderedList = jsi::Object(runtime);
|
|
155
|
+
unorderedList.setProperty(runtime, "isActive", event.unorderedList.isActive);
|
|
156
|
+
unorderedList.setProperty(runtime, "isConflicting", event.unorderedList.isConflicting);
|
|
157
|
+
unorderedList.setProperty(runtime, "isBlocking", event.unorderedList.isBlocking);
|
|
158
|
+
payload.setProperty(runtime, "unorderedList", unorderedList);
|
|
159
|
+
}
|
|
160
|
+
{
|
|
161
|
+
auto link = jsi::Object(runtime);
|
|
162
|
+
link.setProperty(runtime, "isActive", event.link.isActive);
|
|
163
|
+
link.setProperty(runtime, "isConflicting", event.link.isConflicting);
|
|
164
|
+
link.setProperty(runtime, "isBlocking", event.link.isBlocking);
|
|
165
|
+
payload.setProperty(runtime, "link", link);
|
|
166
|
+
}
|
|
167
|
+
{
|
|
168
|
+
auto image = jsi::Object(runtime);
|
|
169
|
+
image.setProperty(runtime, "isActive", event.image.isActive);
|
|
170
|
+
image.setProperty(runtime, "isConflicting", event.image.isConflicting);
|
|
171
|
+
image.setProperty(runtime, "isBlocking", event.image.isBlocking);
|
|
172
|
+
payload.setProperty(runtime, "image", image);
|
|
173
|
+
}
|
|
174
|
+
{
|
|
175
|
+
auto mention = jsi::Object(runtime);
|
|
176
|
+
mention.setProperty(runtime, "isActive", event.mention.isActive);
|
|
177
|
+
mention.setProperty(runtime, "isConflicting", event.mention.isConflicting);
|
|
178
|
+
mention.setProperty(runtime, "isBlocking", event.mention.isBlocking);
|
|
179
|
+
payload.setProperty(runtime, "mention", mention);
|
|
180
|
+
}
|
|
181
|
+
return payload;
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
void EnrichedTextInputViewEventEmitter::onChangeStateDeprecated(OnChangeStateDeprecated event) const {
|
|
187
|
+
dispatchEvent("changeStateDeprecated", [event=std::move(event)](jsi::Runtime &runtime) {
|
|
54
188
|
auto payload = jsi::Object(runtime);
|
|
55
189
|
payload.setProperty(runtime, "isBold", event.isBold);
|
|
56
190
|
payload.setProperty(runtime, "isItalic", event.isItalic);
|
|
@@ -60,6 +194,9 @@ payload.setProperty(runtime, "isInlineCode", event.isInlineCode);
|
|
|
60
194
|
payload.setProperty(runtime, "isH1", event.isH1);
|
|
61
195
|
payload.setProperty(runtime, "isH2", event.isH2);
|
|
62
196
|
payload.setProperty(runtime, "isH3", event.isH3);
|
|
197
|
+
payload.setProperty(runtime, "isH4", event.isH4);
|
|
198
|
+
payload.setProperty(runtime, "isH5", event.isH5);
|
|
199
|
+
payload.setProperty(runtime, "isH6", event.isH6);
|
|
63
200
|
payload.setProperty(runtime, "isCodeBlock", event.isCodeBlock);
|
|
64
201
|
payload.setProperty(runtime, "isBlockQuote", event.isBlockQuote);
|
|
65
202
|
payload.setProperty(runtime, "isOrderedList", event.isOrderedList);
|
|
@@ -125,4 +262,13 @@ payload.setProperty(runtime, "html", jsi::valueFromDynamic(runtime, event.html))
|
|
|
125
262
|
});
|
|
126
263
|
}
|
|
127
264
|
|
|
265
|
+
|
|
266
|
+
void EnrichedTextInputViewEventEmitter::onInputKeyPress(OnInputKeyPress event) const {
|
|
267
|
+
dispatchEvent("inputKeyPress", [event=std::move(event)](jsi::Runtime &runtime) {
|
|
268
|
+
auto payload = jsi::Object(runtime);
|
|
269
|
+
payload.setProperty(runtime, "key", event.key);
|
|
270
|
+
return payload;
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
|
|
128
274
|
} // namespace facebook::react
|