react-native-enriched 0.0.0 → 0.1.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/LICENSE +20 -0
- package/README.md +869 -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 +669 -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,235 @@
|
|
|
1
|
+
import { codegenNativeComponent, codegenNativeCommands } from 'react-native';
|
|
2
|
+
import type {
|
|
3
|
+
DirectEventHandler,
|
|
4
|
+
Float,
|
|
5
|
+
Int32,
|
|
6
|
+
UnsafeMixed,
|
|
7
|
+
} from 'react-native/Libraries/Types/CodegenTypes';
|
|
8
|
+
import type { ColorValue, HostComponent, ViewProps } from 'react-native';
|
|
9
|
+
import React from 'react';
|
|
10
|
+
|
|
11
|
+
export interface OnChangeTextEvent {
|
|
12
|
+
value: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface OnChangeHtmlEvent {
|
|
16
|
+
value: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface OnChangeStateEvent {
|
|
20
|
+
isBold: boolean;
|
|
21
|
+
isItalic: boolean;
|
|
22
|
+
isUnderline: boolean;
|
|
23
|
+
isStrikeThrough: boolean;
|
|
24
|
+
isInlineCode: boolean;
|
|
25
|
+
isH1: boolean;
|
|
26
|
+
isH2: boolean;
|
|
27
|
+
isH3: boolean;
|
|
28
|
+
isCodeBlock: boolean;
|
|
29
|
+
isBlockQuote: boolean;
|
|
30
|
+
isOrderedList: boolean;
|
|
31
|
+
isUnorderedList: boolean;
|
|
32
|
+
isLink: boolean;
|
|
33
|
+
isImage: boolean;
|
|
34
|
+
isMention: boolean;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface OnLinkDetected {
|
|
38
|
+
text: string;
|
|
39
|
+
url: string;
|
|
40
|
+
start: Int32;
|
|
41
|
+
end: Int32;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface OnMentionDetectedInternal {
|
|
45
|
+
text: string;
|
|
46
|
+
indicator: string;
|
|
47
|
+
payload: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface OnMentionDetected {
|
|
51
|
+
text: string;
|
|
52
|
+
indicator: string;
|
|
53
|
+
attributes: Record<string, string>;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface OnMentionEvent {
|
|
57
|
+
indicator: string;
|
|
58
|
+
text: UnsafeMixed;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface OnChangeSelectionEvent {
|
|
62
|
+
start: Int32;
|
|
63
|
+
end: Int32;
|
|
64
|
+
text: string;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface MentionStyleProperties {
|
|
68
|
+
color?: ColorValue;
|
|
69
|
+
backgroundColor?: ColorValue;
|
|
70
|
+
textDecorationLine?: 'underline' | 'none';
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface HtmlStyleInternal {
|
|
74
|
+
h1?: {
|
|
75
|
+
fontSize?: Float;
|
|
76
|
+
bold?: boolean;
|
|
77
|
+
};
|
|
78
|
+
h2?: {
|
|
79
|
+
fontSize?: Float;
|
|
80
|
+
bold?: boolean;
|
|
81
|
+
};
|
|
82
|
+
h3?: {
|
|
83
|
+
fontSize?: Float;
|
|
84
|
+
bold?: boolean;
|
|
85
|
+
};
|
|
86
|
+
blockquote?: {
|
|
87
|
+
borderColor?: ColorValue;
|
|
88
|
+
borderWidth?: Float;
|
|
89
|
+
gapWidth?: Float;
|
|
90
|
+
color?: ColorValue;
|
|
91
|
+
};
|
|
92
|
+
codeblock?: {
|
|
93
|
+
color?: ColorValue;
|
|
94
|
+
borderRadius?: Float;
|
|
95
|
+
backgroundColor?: ColorValue;
|
|
96
|
+
};
|
|
97
|
+
code?: {
|
|
98
|
+
color?: ColorValue;
|
|
99
|
+
backgroundColor?: ColorValue;
|
|
100
|
+
};
|
|
101
|
+
a?: {
|
|
102
|
+
color?: ColorValue;
|
|
103
|
+
textDecorationLine?: string;
|
|
104
|
+
};
|
|
105
|
+
// This is a workaround for the fact that codegen does not support Records.
|
|
106
|
+
// On native Android side this will become a ReadableMap, on native iOS we can work with a folly::dynamic object.
|
|
107
|
+
mention?: UnsafeMixed;
|
|
108
|
+
img?: {
|
|
109
|
+
width?: Float;
|
|
110
|
+
height?: Float;
|
|
111
|
+
};
|
|
112
|
+
ol?: {
|
|
113
|
+
gapWidth?: Float;
|
|
114
|
+
marginLeft?: Float;
|
|
115
|
+
markerFontWeight?: string;
|
|
116
|
+
markerColor?: ColorValue;
|
|
117
|
+
};
|
|
118
|
+
ul?: {
|
|
119
|
+
bulletColor?: ColorValue;
|
|
120
|
+
bulletSize?: Float;
|
|
121
|
+
marginLeft?: Float;
|
|
122
|
+
gapWidth?: Float;
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export interface NativeProps extends ViewProps {
|
|
127
|
+
// base props
|
|
128
|
+
autoFocus?: boolean;
|
|
129
|
+
editable?: boolean;
|
|
130
|
+
defaultValue?: string;
|
|
131
|
+
placeholder?: string;
|
|
132
|
+
placeholderTextColor?: ColorValue;
|
|
133
|
+
mentionIndicators: string[];
|
|
134
|
+
cursorColor?: ColorValue;
|
|
135
|
+
selectionColor?: ColorValue;
|
|
136
|
+
autoCapitalize?: string;
|
|
137
|
+
htmlStyle?: HtmlStyleInternal;
|
|
138
|
+
|
|
139
|
+
// event callbacks
|
|
140
|
+
onInputFocus?: DirectEventHandler<null>;
|
|
141
|
+
onInputBlur?: DirectEventHandler<null>;
|
|
142
|
+
onChangeText?: DirectEventHandler<OnChangeTextEvent>;
|
|
143
|
+
onChangeHtml?: DirectEventHandler<OnChangeHtmlEvent>;
|
|
144
|
+
onChangeState?: DirectEventHandler<OnChangeStateEvent>;
|
|
145
|
+
onLinkDetected?: DirectEventHandler<OnLinkDetected>;
|
|
146
|
+
onMentionDetected?: DirectEventHandler<OnMentionDetectedInternal>;
|
|
147
|
+
onMention?: DirectEventHandler<OnMentionEvent>;
|
|
148
|
+
onChangeSelection?: DirectEventHandler<OnChangeSelectionEvent>;
|
|
149
|
+
|
|
150
|
+
// Style related props - used for generating proper setters in component's manager
|
|
151
|
+
// These should not be passed as regular props
|
|
152
|
+
color?: ColorValue;
|
|
153
|
+
fontSize?: Float;
|
|
154
|
+
fontFamily?: string;
|
|
155
|
+
fontWeight?: string;
|
|
156
|
+
fontStyle?: string;
|
|
157
|
+
|
|
158
|
+
// Used for onChangeHtml event performance optimization
|
|
159
|
+
isOnChangeHtmlSet: boolean;
|
|
160
|
+
|
|
161
|
+
// Experimental
|
|
162
|
+
androidExperimentalSynchronousEvents: boolean;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
type ComponentType = HostComponent<NativeProps>;
|
|
166
|
+
|
|
167
|
+
interface NativeCommands {
|
|
168
|
+
// General commands
|
|
169
|
+
focus: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
170
|
+
blur: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
171
|
+
setValue: (viewRef: React.ElementRef<ComponentType>, text: string) => void;
|
|
172
|
+
|
|
173
|
+
// Text formatting commands
|
|
174
|
+
toggleBold: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
175
|
+
toggleItalic: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
176
|
+
toggleUnderline: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
177
|
+
toggleStrikeThrough: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
178
|
+
toggleInlineCode: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
179
|
+
toggleH1: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
180
|
+
toggleH2: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
181
|
+
toggleH3: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
182
|
+
toggleCodeBlock: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
183
|
+
toggleBlockQuote: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
184
|
+
toggleOrderedList: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
185
|
+
toggleUnorderedList: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
186
|
+
addLink: (
|
|
187
|
+
viewRef: React.ElementRef<ComponentType>,
|
|
188
|
+
start: Int32,
|
|
189
|
+
end: Int32,
|
|
190
|
+
text: string,
|
|
191
|
+
url: string
|
|
192
|
+
) => void;
|
|
193
|
+
addImage: (viewRef: React.ElementRef<ComponentType>, uri: string) => void;
|
|
194
|
+
startMention: (
|
|
195
|
+
viewRef: React.ElementRef<ComponentType>,
|
|
196
|
+
indicator: string
|
|
197
|
+
) => void;
|
|
198
|
+
addMention: (
|
|
199
|
+
viewRef: React.ElementRef<ComponentType>,
|
|
200
|
+
indicator: string,
|
|
201
|
+
text: string,
|
|
202
|
+
payload: string
|
|
203
|
+
) => void;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
|
|
207
|
+
supportedCommands: [
|
|
208
|
+
// General commands
|
|
209
|
+
'focus',
|
|
210
|
+
'blur',
|
|
211
|
+
'setValue',
|
|
212
|
+
|
|
213
|
+
// Text formatting commands
|
|
214
|
+
'toggleBold',
|
|
215
|
+
'toggleItalic',
|
|
216
|
+
'toggleUnderline',
|
|
217
|
+
'toggleStrikeThrough',
|
|
218
|
+
'toggleInlineCode',
|
|
219
|
+
'toggleH1',
|
|
220
|
+
'toggleH2',
|
|
221
|
+
'toggleH3',
|
|
222
|
+
'toggleCodeBlock',
|
|
223
|
+
'toggleBlockQuote',
|
|
224
|
+
'toggleOrderedList',
|
|
225
|
+
'toggleUnorderedList',
|
|
226
|
+
'addLink',
|
|
227
|
+
'addImage',
|
|
228
|
+
'startMention',
|
|
229
|
+
'addMention',
|
|
230
|
+
],
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
export default codegenNativeComponent<NativeProps>('EnrichedTextInputView', {
|
|
234
|
+
interfaceOnly: true,
|
|
235
|
+
}) as HostComponent<NativeProps>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,cAAc,wBAAqB","ignoreList":[]}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { processColor } from 'react-native';
|
|
4
|
+
const defaultStyle = {
|
|
5
|
+
h1: {
|
|
6
|
+
fontSize: 32,
|
|
7
|
+
bold: false
|
|
8
|
+
},
|
|
9
|
+
h2: {
|
|
10
|
+
fontSize: 24,
|
|
11
|
+
bold: false
|
|
12
|
+
},
|
|
13
|
+
h3: {
|
|
14
|
+
fontSize: 20,
|
|
15
|
+
bold: false
|
|
16
|
+
},
|
|
17
|
+
blockquote: {
|
|
18
|
+
borderColor: 'darkgray',
|
|
19
|
+
borderWidth: 4,
|
|
20
|
+
gapWidth: 16,
|
|
21
|
+
color: undefined
|
|
22
|
+
},
|
|
23
|
+
codeblock: {
|
|
24
|
+
color: 'black',
|
|
25
|
+
borderRadius: 8,
|
|
26
|
+
backgroundColor: 'darkgray'
|
|
27
|
+
},
|
|
28
|
+
code: {
|
|
29
|
+
color: 'red',
|
|
30
|
+
backgroundColor: 'darkgray'
|
|
31
|
+
},
|
|
32
|
+
a: {
|
|
33
|
+
color: 'blue',
|
|
34
|
+
textDecorationLine: 'underline'
|
|
35
|
+
},
|
|
36
|
+
mention: {
|
|
37
|
+
color: 'blue',
|
|
38
|
+
backgroundColor: 'yellow',
|
|
39
|
+
textDecorationLine: 'underline'
|
|
40
|
+
},
|
|
41
|
+
img: {
|
|
42
|
+
width: 80,
|
|
43
|
+
height: 80
|
|
44
|
+
},
|
|
45
|
+
ol: {
|
|
46
|
+
gapWidth: 16,
|
|
47
|
+
marginLeft: 16,
|
|
48
|
+
markerFontWeight: undefined,
|
|
49
|
+
markerColor: undefined
|
|
50
|
+
},
|
|
51
|
+
ul: {
|
|
52
|
+
bulletColor: 'black',
|
|
53
|
+
bulletSize: 8,
|
|
54
|
+
marginLeft: 16,
|
|
55
|
+
gapWidth: 16
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
const isMentionStyleRecord = mentionStyle => {
|
|
59
|
+
if (mentionStyle && typeof mentionStyle === 'object' && !Array.isArray(mentionStyle)) {
|
|
60
|
+
const keys = Object.keys(mentionStyle);
|
|
61
|
+
return keys.length > 0 && keys.every(key => typeof mentionStyle[key] === 'object' && mentionStyle[key] !== null);
|
|
62
|
+
}
|
|
63
|
+
return false;
|
|
64
|
+
};
|
|
65
|
+
const convertToHtmlStyleInternal = (style, mentionIndicators) => {
|
|
66
|
+
const mentionStyles = {};
|
|
67
|
+
mentionIndicators.forEach(indicator => {
|
|
68
|
+
mentionStyles[indicator] = {
|
|
69
|
+
...defaultStyle.mention,
|
|
70
|
+
...(isMentionStyleRecord(style.mention) ? style.mention[indicator] ?? style.mention.default ?? {} : style.mention)
|
|
71
|
+
};
|
|
72
|
+
});
|
|
73
|
+
let markerFontWeight;
|
|
74
|
+
if (style.ol?.markerFontWeight) {
|
|
75
|
+
if (typeof style.ol?.markerFontWeight === 'number') {
|
|
76
|
+
markerFontWeight = String(style.ol?.markerFontWeight);
|
|
77
|
+
} else if (typeof style.ol?.markerFontWeight === 'string') {
|
|
78
|
+
markerFontWeight = style.ol?.markerFontWeight;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
const olStyles = {
|
|
82
|
+
...style.ol,
|
|
83
|
+
markerFontWeight: markerFontWeight
|
|
84
|
+
};
|
|
85
|
+
return {
|
|
86
|
+
...style,
|
|
87
|
+
mention: mentionStyles,
|
|
88
|
+
ol: olStyles
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
const assignDefaultValues = style => {
|
|
92
|
+
const merged = {
|
|
93
|
+
...defaultStyle
|
|
94
|
+
};
|
|
95
|
+
for (const key in style) {
|
|
96
|
+
if (key === 'mention') {
|
|
97
|
+
merged[key] = {
|
|
98
|
+
...style.mention
|
|
99
|
+
};
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
merged[key] = {
|
|
103
|
+
...defaultStyle[key],
|
|
104
|
+
...style[key]
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
return merged;
|
|
108
|
+
};
|
|
109
|
+
const parseStyle = (name, value) => {
|
|
110
|
+
if (name !== 'color' && !name.endsWith('Color')) {
|
|
111
|
+
return value;
|
|
112
|
+
}
|
|
113
|
+
return processColor(value);
|
|
114
|
+
};
|
|
115
|
+
const parseColors = style => {
|
|
116
|
+
const finalStyle = {};
|
|
117
|
+
for (const [tagName, tagStyle] of Object.entries(style)) {
|
|
118
|
+
const tagStyles = {};
|
|
119
|
+
if (tagName === 'mention') {
|
|
120
|
+
for (const [indicator, mentionStyle] of Object.entries(tagStyle)) {
|
|
121
|
+
tagStyles[indicator] = {};
|
|
122
|
+
for (const [styleName, styleValue] of Object.entries(mentionStyle)) {
|
|
123
|
+
tagStyles[indicator][styleName] = parseStyle(styleName, styleValue);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
finalStyle[tagName] = tagStyles;
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
for (const [styleName, styleValue] of Object.entries(tagStyle)) {
|
|
130
|
+
tagStyles[styleName] = parseStyle(styleName, styleValue);
|
|
131
|
+
}
|
|
132
|
+
finalStyle[tagName] = tagStyles;
|
|
133
|
+
}
|
|
134
|
+
return finalStyle;
|
|
135
|
+
};
|
|
136
|
+
export const normalizeHtmlStyle = (style, mentionIndicators) => {
|
|
137
|
+
const converted = convertToHtmlStyleInternal(style, mentionIndicators);
|
|
138
|
+
const withDefaults = assignDefaultValues(converted);
|
|
139
|
+
return parseColors(withDefaults);
|
|
140
|
+
};
|
|
141
|
+
//# sourceMappingURL=normalizeHtmlStyle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["processColor","defaultStyle","h1","fontSize","bold","h2","h3","blockquote","borderColor","borderWidth","gapWidth","color","undefined","codeblock","borderRadius","backgroundColor","code","a","textDecorationLine","mention","img","width","height","ol","marginLeft","markerFontWeight","markerColor","ul","bulletColor","bulletSize","isMentionStyleRecord","mentionStyle","Array","isArray","keys","Object","length","every","key","convertToHtmlStyleInternal","style","mentionIndicators","mentionStyles","forEach","indicator","default","String","olStyles","assignDefaultValues","merged","parseStyle","name","value","endsWith","parseColors","finalStyle","tagName","tagStyle","entries","tagStyles","styleName","styleValue","normalizeHtmlStyle","converted","withDefaults"],"sourceRoot":"../../src","sources":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ACD4B,SAAS,CAACf,SAAS,CAAC,CAACgB,SAAS,CAAC,GAAGV,UAAU,CAACU,SAAS,EAAEC,UAAU,CAAC;QACrE;MACF;MAEAN,UAAU,CAACC,OAAO,CAAC,GAAGG,SAAS;MAC/B;IACF;IAEA,KAAK,MAAM,CAACC,SAAS,EAAEC,UAAU,CAAC,IAAI1B,MAAM,CAACuB,OAAO,CAACD,QAAQ,CAAC,EAAE;MAC9DE,SAAS,CAACC,SAAS,CAAC,GAAGV,UAAU,CAACU,SAAS,EAAEC,UAAU,CAAC;IAC1D;IAEAN,UAAU,CAACC,OAAO,CAAC,GAAGG,SAAS;EACjC;EAEA,OAAOJ,UAAU;AACnB,CAAC;AAED,OAAO,MAAMO,kBAAkB,GAAGA,CAChCtB,KAAgB,EAChBC,iBAA2B,KACL;EACtB,MAAMsB,SAAS,GAAGxB,0BAA0B,CAACC,KAAK,EAAEC,iBAAiB,CAAC;EACtE,MAAMuB,YAAY,GAAGhB,mBAAmB,CAACe,SAAS,CAAC;EACnD,OAAOT,WAAW,CAACU,YAAY,CAAC;AAClC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { type RefObject } from 'react';
|
|
2
|
+
import { type OnChangeHtmlEvent, type OnChangeSelectionEvent, type OnChangeStateEvent, type OnChangeTextEvent, type OnLinkDetected, type OnMentionDetected, type MentionStyleProperties } from './EnrichedTextInputNativeComponent';
|
|
3
|
+
import type { ColorValue, NativeMethods, NativeSyntheticEvent, TextStyle, ViewProps, ViewStyle } from 'react-native';
|
|
4
|
+
export interface EnrichedTextInputInstance extends NativeMethods {
|
|
5
|
+
focus: () => void;
|
|
6
|
+
blur: () => void;
|
|
7
|
+
setValue: (value: string) => void;
|
|
8
|
+
toggleBold: () => void;
|
|
9
|
+
toggleItalic: () => void;
|
|
10
|
+
toggleUnderline: () => void;
|
|
11
|
+
toggleStrikeThrough: () => void;
|
|
12
|
+
toggleInlineCode: () => void;
|
|
13
|
+
toggleH1: () => void;
|
|
14
|
+
toggleH2: () => void;
|
|
15
|
+
toggleH3: () => void;
|
|
16
|
+
toggleCodeBlock: () => void;
|
|
17
|
+
toggleBlockQuote: () => void;
|
|
18
|
+
toggleOrderedList: () => void;
|
|
19
|
+
toggleUnorderedList: () => void;
|
|
20
|
+
setLink: (start: number, end: number, text: string, url: string) => void;
|
|
21
|
+
setImage: (src: string) => void;
|
|
22
|
+
startMention: (indicator: string) => void;
|
|
23
|
+
setMention: (indicator: string, text: string, attributes?: Record<string, string>) => void;
|
|
24
|
+
}
|
|
25
|
+
export interface OnChangeMentionEvent {
|
|
26
|
+
indicator: string;
|
|
27
|
+
text: string;
|
|
28
|
+
}
|
|
29
|
+
export interface HtmlStyle {
|
|
30
|
+
h1?: {
|
|
31
|
+
fontSize?: number;
|
|
32
|
+
bold?: boolean;
|
|
33
|
+
};
|
|
34
|
+
h2?: {
|
|
35
|
+
fontSize?: number;
|
|
36
|
+
bold?: boolean;
|
|
37
|
+
};
|
|
38
|
+
h3?: {
|
|
39
|
+
fontSize?: number;
|
|
40
|
+
bold?: boolean;
|
|
41
|
+
};
|
|
42
|
+
blockquote?: {
|
|
43
|
+
borderColor?: ColorValue;
|
|
44
|
+
borderWidth?: number;
|
|
45
|
+
gapWidth?: number;
|
|
46
|
+
color?: ColorValue;
|
|
47
|
+
};
|
|
48
|
+
codeblock?: {
|
|
49
|
+
color?: ColorValue;
|
|
50
|
+
borderRadius?: number;
|
|
51
|
+
backgroundColor?: ColorValue;
|
|
52
|
+
};
|
|
53
|
+
code?: {
|
|
54
|
+
color?: ColorValue;
|
|
55
|
+
backgroundColor?: ColorValue;
|
|
56
|
+
};
|
|
57
|
+
a?: {
|
|
58
|
+
color?: ColorValue;
|
|
59
|
+
textDecorationLine?: 'underline' | 'none';
|
|
60
|
+
};
|
|
61
|
+
mention?: Record<string, MentionStyleProperties> | MentionStyleProperties;
|
|
62
|
+
img?: {
|
|
63
|
+
width?: number;
|
|
64
|
+
height?: number;
|
|
65
|
+
};
|
|
66
|
+
ol?: {
|
|
67
|
+
gapWidth?: number;
|
|
68
|
+
marginLeft?: number;
|
|
69
|
+
markerFontWeight?: TextStyle['fontWeight'];
|
|
70
|
+
markerColor?: ColorValue;
|
|
71
|
+
};
|
|
72
|
+
ul?: {
|
|
73
|
+
bulletColor?: ColorValue;
|
|
74
|
+
bulletSize?: number;
|
|
75
|
+
marginLeft?: number;
|
|
76
|
+
gapWidth?: number;
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
export interface EnrichedTextInputProps extends Omit<ViewProps, 'children'> {
|
|
80
|
+
ref?: RefObject<EnrichedTextInputInstance | null>;
|
|
81
|
+
autoFocus?: boolean;
|
|
82
|
+
editable?: boolean;
|
|
83
|
+
mentionIndicators?: string[];
|
|
84
|
+
defaultValue?: string;
|
|
85
|
+
placeholder?: string;
|
|
86
|
+
placeholderTextColor?: ColorValue;
|
|
87
|
+
cursorColor?: ColorValue;
|
|
88
|
+
selectionColor?: ColorValue;
|
|
89
|
+
autoCapitalize?: 'none' | 'sentences' | 'words' | 'characters';
|
|
90
|
+
htmlStyle?: HtmlStyle;
|
|
91
|
+
style?: ViewStyle | TextStyle;
|
|
92
|
+
onFocus?: () => void;
|
|
93
|
+
onBlur?: () => void;
|
|
94
|
+
onChangeText?: (e: NativeSyntheticEvent<OnChangeTextEvent>) => void;
|
|
95
|
+
onChangeHtml?: (e: NativeSyntheticEvent<OnChangeHtmlEvent>) => void;
|
|
96
|
+
onChangeState?: (e: NativeSyntheticEvent<OnChangeStateEvent>) => void;
|
|
97
|
+
onLinkDetected?: (e: OnLinkDetected) => void;
|
|
98
|
+
onMentionDetected?: (e: OnMentionDetected) => void;
|
|
99
|
+
onStartMention?: (indicator: string) => void;
|
|
100
|
+
onChangeMention?: (e: OnChangeMentionEvent) => void;
|
|
101
|
+
onEndMention?: (indicator: string) => void;
|
|
102
|
+
onChangeSelection?: (e: NativeSyntheticEvent<OnChangeSelectionEvent>) => void;
|
|
103
|
+
/**
|
|
104
|
+
* If true, Android will use experimental synchronous events.
|
|
105
|
+
* This will prevent from input flickering when updating component size.
|
|
106
|
+
* However, this is an experimental feature, which has not been thoroughly tested.
|
|
107
|
+
* We may decide to enable it by default in a future release.
|
|
108
|
+
* Disabled by default.
|
|
109
|
+
*/
|
|
110
|
+
androidExperimentalSynchronousEvents?: boolean;
|
|
111
|
+
}
|
|
112
|
+
export declare const EnrichedTextInput: ({ ref, autoFocus, editable, mentionIndicators, defaultValue, placeholder, placeholderTextColor, cursorColor, selectionColor, style, autoCapitalize, htmlStyle, onFocus, onBlur, onChangeText, onChangeHtml, onChangeState, onLinkDetected, onMentionDetected, onStartMention, onChangeMention, onEndMention, onChangeSelection, androidExperimentalSynchronousEvents, ...rest }: EnrichedTextInputProps) => import("react/jsx-runtime").JSX.Element;
|
|
113
|
+
//# sourceMappingURL=EnrichedTextInput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EnrichedTextInput.d.ts","sourceRoot":"","sources":["../../../src/EnrichedTextInput.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,SAAS,EAIf,MAAM,OAAO,CAAC;AACf,OAAyC,EAGvC,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAC3B,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EAEnB,KAAK,iBAAiB,EAEtB,KAAK,sBAAsB,EAC5B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,EACV,UAAU,EAKV,aAAa,EACb,oBAAoB,EACpB,SAAS,EACT,SAAS,EACT,SAAS,EACV,MAAM,cAAc,CAAC;AAGtB,MAAM,WAAW,yBAA0B,SAAQ,aAAa;IAE9D,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB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,CAAC;IACpD,YAAY,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,iBAAiB,CAAC,EAAE,CAAC,CAAC,EAAE,oBAAoB,CAAC,sBAAsB,CAAC,KAAK,IAAI,CAAC;IAC9E;;;;;;OAMG;IACH,oCAAoC,CAAC,EAAE,OAAO,CAAC;CAChD;AAkBD,eAAO,MAAM,iBAAiB,GAAI,iXA0B/B,sBAAsB,4CAkKxB,CAAC"}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import type { DirectEventHandler, Float, Int32, UnsafeMixed } from 'react-native/Libraries/Types/CodegenTypes';
|
|
2
|
+
import type { ColorValue, HostComponent, ViewProps } from 'react-native';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
export interface OnChangeTextEvent {
|
|
5
|
+
value: string;
|
|
6
|
+
}
|
|
7
|
+
export interface OnChangeHtmlEvent {
|
|
8
|
+
value: string;
|
|
9
|
+
}
|
|
10
|
+
export interface OnChangeStateEvent {
|
|
11
|
+
isBold: boolean;
|
|
12
|
+
isItalic: boolean;
|
|
13
|
+
isUnderline: boolean;
|
|
14
|
+
isStrikeThrough: boolean;
|
|
15
|
+
isInlineCode: boolean;
|
|
16
|
+
isH1: boolean;
|
|
17
|
+
isH2: boolean;
|
|
18
|
+
isH3: boolean;
|
|
19
|
+
isCodeBlock: boolean;
|
|
20
|
+
isBlockQuote: boolean;
|
|
21
|
+
isOrderedList: boolean;
|
|
22
|
+
isUnorderedList: boolean;
|
|
23
|
+
isLink: boolean;
|
|
24
|
+
isImage: boolean;
|
|
25
|
+
isMention: boolean;
|
|
26
|
+
}
|
|
27
|
+
export interface OnLinkDetected {
|
|
28
|
+
text: string;
|
|
29
|
+
url: string;
|
|
30
|
+
start: Int32;
|
|
31
|
+
end: Int32;
|
|
32
|
+
}
|
|
33
|
+
export interface OnMentionDetectedInternal {
|
|
34
|
+
text: string;
|
|
35
|
+
indicator: string;
|
|
36
|
+
payload: string;
|
|
37
|
+
}
|
|
38
|
+
export interface OnMentionDetected {
|
|
39
|
+
text: string;
|
|
40
|
+
indicator: string;
|
|
41
|
+
attributes: Record<string, string>;
|
|
42
|
+
}
|
|
43
|
+
export interface OnMentionEvent {
|
|
44
|
+
indicator: string;
|
|
45
|
+
text: UnsafeMixed;
|
|
46
|
+
}
|
|
47
|
+
export interface OnChangeSelectionEvent {
|
|
48
|
+
start: Int32;
|
|
49
|
+
end: Int32;
|
|
50
|
+
text: string;
|
|
51
|
+
}
|
|
52
|
+
export interface MentionStyleProperties {
|
|
53
|
+
color?: ColorValue;
|
|
54
|
+
backgroundColor?: ColorValue;
|
|
55
|
+
textDecorationLine?: 'underline' | 'none';
|
|
56
|
+
}
|
|
57
|
+
export interface HtmlStyleInternal {
|
|
58
|
+
h1?: {
|
|
59
|
+
fontSize?: Float;
|
|
60
|
+
bold?: boolean;
|
|
61
|
+
};
|
|
62
|
+
h2?: {
|
|
63
|
+
fontSize?: Float;
|
|
64
|
+
bold?: boolean;
|
|
65
|
+
};
|
|
66
|
+
h3?: {
|
|
67
|
+
fontSize?: Float;
|
|
68
|
+
bold?: boolean;
|
|
69
|
+
};
|
|
70
|
+
blockquote?: {
|
|
71
|
+
borderColor?: ColorValue;
|
|
72
|
+
borderWidth?: Float;
|
|
73
|
+
gapWidth?: Float;
|
|
74
|
+
color?: ColorValue;
|
|
75
|
+
};
|
|
76
|
+
codeblock?: {
|
|
77
|
+
color?: ColorValue;
|
|
78
|
+
borderRadius?: Float;
|
|
79
|
+
backgroundColor?: ColorValue;
|
|
80
|
+
};
|
|
81
|
+
code?: {
|
|
82
|
+
color?: ColorValue;
|
|
83
|
+
backgroundColor?: ColorValue;
|
|
84
|
+
};
|
|
85
|
+
a?: {
|
|
86
|
+
color?: ColorValue;
|
|
87
|
+
textDecorationLine?: string;
|
|
88
|
+
};
|
|
89
|
+
mention?: UnsafeMixed;
|
|
90
|
+
img?: {
|
|
91
|
+
width?: Float;
|
|
92
|
+
height?: Float;
|
|
93
|
+
};
|
|
94
|
+
ol?: {
|
|
95
|
+
gapWidth?: Float;
|
|
96
|
+
marginLeft?: Float;
|
|
97
|
+
markerFontWeight?: string;
|
|
98
|
+
markerColor?: ColorValue;
|
|
99
|
+
};
|
|
100
|
+
ul?: {
|
|
101
|
+
bulletColor?: ColorValue;
|
|
102
|
+
bulletSize?: Float;
|
|
103
|
+
marginLeft?: Float;
|
|
104
|
+
gapWidth?: Float;
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
export interface NativeProps extends ViewProps {
|
|
108
|
+
autoFocus?: boolean;
|
|
109
|
+
editable?: boolean;
|
|
110
|
+
defaultValue?: string;
|
|
111
|
+
placeholder?: string;
|
|
112
|
+
placeholderTextColor?: ColorValue;
|
|
113
|
+
mentionIndicators: string[];
|
|
114
|
+
cursorColor?: ColorValue;
|
|
115
|
+
selectionColor?: ColorValue;
|
|
116
|
+
autoCapitalize?: string;
|
|
117
|
+
htmlStyle?: HtmlStyleInternal;
|
|
118
|
+
onInputFocus?: DirectEventHandler<null>;
|
|
119
|
+
onInputBlur?: DirectEventHandler<null>;
|
|
120
|
+
onChangeText?: DirectEventHandler<OnChangeTextEvent>;
|
|
121
|
+
onChangeHtml?: DirectEventHandler<OnChangeHtmlEvent>;
|
|
122
|
+
onChangeState?: DirectEventHandler<OnChangeStateEvent>;
|
|
123
|
+
onLinkDetected?: DirectEventHandler<OnLinkDetected>;
|
|
124
|
+
onMentionDetected?: DirectEventHandler<OnMentionDetectedInternal>;
|
|
125
|
+
onMention?: DirectEventHandler<OnMentionEvent>;
|
|
126
|
+
onChangeSelection?: DirectEventHandler<OnChangeSelectionEvent>;
|
|
127
|
+
color?: ColorValue;
|
|
128
|
+
fontSize?: Float;
|
|
129
|
+
fontFamily?: string;
|
|
130
|
+
fontWeight?: string;
|
|
131
|
+
fontStyle?: string;
|
|
132
|
+
isOnChangeHtmlSet: boolean;
|
|
133
|
+
androidExperimentalSynchronousEvents: boolean;
|
|
134
|
+
}
|
|
135
|
+
type ComponentType = HostComponent<NativeProps>;
|
|
136
|
+
interface NativeCommands {
|
|
137
|
+
focus: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
138
|
+
blur: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
139
|
+
setValue: (viewRef: React.ElementRef<ComponentType>, text: string) => void;
|
|
140
|
+
toggleBold: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
141
|
+
toggleItalic: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
142
|
+
toggleUnderline: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
143
|
+
toggleStrikeThrough: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
144
|
+
toggleInlineCode: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
145
|
+
toggleH1: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
146
|
+
toggleH2: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
147
|
+
toggleH3: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
148
|
+
toggleCodeBlock: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
149
|
+
toggleBlockQuote: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
150
|
+
toggleOrderedList: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
151
|
+
toggleUnorderedList: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
152
|
+
addLink: (viewRef: React.ElementRef<ComponentType>, start: Int32, end: Int32, text: string, url: string) => void;
|
|
153
|
+
addImage: (viewRef: React.ElementRef<ComponentType>, uri: string) => void;
|
|
154
|
+
startMention: (viewRef: React.ElementRef<ComponentType>, indicator: string) => void;
|
|
155
|
+
addMention: (viewRef: React.ElementRef<ComponentType>, indicator: string, text: string, payload: string) => void;
|
|
156
|
+
}
|
|
157
|
+
export declare const Commands: NativeCommands;
|
|
158
|
+
declare const _default: HostComponent<NativeProps>;
|
|
159
|
+
export default _default;
|
|
160
|
+
//# sourceMappingURL=EnrichedTextInputNativeComponent.d.ts.map
|