react-native-enriched 0.3.0 → 0.4.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/README.md +6 -4
- package/android/build.gradle +3 -3
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedTextInputViewManagerDelegate.java +3 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedTextInputViewManagerInterface.java +1 -0
- package/android/generated/jni/react/renderer/components/{RNEnrichedTextInputViewSpec → ReactNativeEnrichedSpec}/ComponentDescriptors.cpp +1 -1
- package/android/generated/jni/react/renderer/components/{RNEnrichedTextInputViewSpec → ReactNativeEnrichedSpec}/ComponentDescriptors.h +1 -1
- package/{ios/generated/RNEnrichedTextInputViewSpec → android/generated/jni/react/renderer/components/ReactNativeEnrichedSpec}/EventEmitters.cpp +31 -29
- package/{ios/generated/RNEnrichedTextInputViewSpec → android/generated/jni/react/renderer/components/ReactNativeEnrichedSpec}/EventEmitters.h +22 -25
- package/android/generated/jni/react/renderer/components/{RNEnrichedTextInputViewSpec → ReactNativeEnrichedSpec}/Props.h +57 -0
- package/android/gradle.properties +5 -5
- package/android/src/main/java/com/swmansion/enriched/{EnrichedTextInputViewPackage.kt → ReactNativeEnrichedPackage.kt} +3 -2
- package/android/src/main/java/com/swmansion/enriched/{utils → common}/AsyncDrawable.kt +40 -8
- package/android/src/main/java/com/swmansion/enriched/common/CheckboxDrawable.kt +81 -0
- package/android/src/main/java/com/swmansion/enriched/{utils → common}/EnrichedConstants.kt +1 -1
- package/android/src/main/java/com/swmansion/enriched/common/EnrichedStyle.kt +57 -0
- package/android/src/main/java/com/swmansion/enriched/{spans/utils → common}/ForceRedrawSpan.kt +1 -1
- package/android/src/main/java/com/swmansion/enriched/common/MentionStyle.kt +7 -0
- package/android/src/main/java/com/swmansion/enriched/{utils → common}/ResourceManager.kt +1 -1
- package/android/src/main/java/com/swmansion/enriched/{utils → common/parser}/EnrichedParser.java +126 -99
- package/android/src/main/java/com/swmansion/enriched/common/parser/EnrichedSpanFactory.kt +79 -0
- package/android/src/main/java/com/swmansion/enriched/{spans → common/spans}/EnrichedBlockQuoteSpan.kt +9 -13
- package/android/src/main/java/com/swmansion/enriched/common/spans/EnrichedBoldSpan.kt +12 -0
- package/android/src/main/java/com/swmansion/enriched/common/spans/EnrichedCheckboxListSpan.kt +91 -0
- package/android/src/main/java/com/swmansion/enriched/{spans → common/spans}/EnrichedCodeBlockSpan.kt +8 -12
- package/android/src/main/java/com/swmansion/enriched/common/spans/EnrichedH1Span.kt +20 -0
- package/android/src/main/java/com/swmansion/enriched/common/spans/EnrichedH2Span.kt +20 -0
- package/android/src/main/java/com/swmansion/enriched/common/spans/EnrichedH3Span.kt +20 -0
- package/android/src/main/java/com/swmansion/enriched/common/spans/EnrichedH4Span.kt +21 -0
- package/android/src/main/java/com/swmansion/enriched/common/spans/EnrichedH5Span.kt +20 -0
- package/android/src/main/java/com/swmansion/enriched/common/spans/EnrichedH6Span.kt +20 -0
- package/android/src/main/java/com/swmansion/enriched/{spans → common/spans}/EnrichedImageSpan.kt +43 -38
- package/android/src/main/java/com/swmansion/enriched/{spans → common/spans}/EnrichedInlineCodeSpan.kt +7 -11
- package/android/src/main/java/com/swmansion/enriched/common/spans/EnrichedItalicSpan.kt +12 -0
- package/android/src/main/java/com/swmansion/enriched/{spans → common/spans}/EnrichedLinkSpan.kt +7 -11
- package/android/src/main/java/com/swmansion/enriched/{spans → common/spans}/EnrichedMentionSpan.kt +6 -10
- package/android/src/main/java/com/swmansion/enriched/{spans → common/spans}/EnrichedOrderedListSpan.kt +12 -21
- package/android/src/main/java/com/swmansion/enriched/common/spans/EnrichedStrikeThroughSpan.kt +11 -0
- package/android/src/main/java/com/swmansion/enriched/common/spans/EnrichedUnderlineSpan.kt +11 -0
- package/android/src/main/java/com/swmansion/enriched/{spans → common/spans}/EnrichedUnorderedListSpan.kt +9 -13
- package/android/src/main/java/com/swmansion/enriched/{spans → common/spans}/interfaces/EnrichedBlockSpan.kt +1 -1
- package/android/src/main/java/com/swmansion/enriched/{spans → common/spans}/interfaces/EnrichedHeadingSpan.kt +1 -1
- package/android/src/main/java/com/swmansion/enriched/common/spans/interfaces/EnrichedInlineSpan.kt +3 -0
- package/android/src/main/java/com/swmansion/enriched/{spans → common/spans}/interfaces/EnrichedParagraphSpan.kt +1 -1
- package/android/src/main/java/com/swmansion/enriched/common/spans/interfaces/EnrichedSpan.kt +3 -0
- package/android/src/main/java/com/swmansion/enriched/{spans → common/spans}/interfaces/EnrichedZeroWidthSpaceSpan.kt +1 -1
- package/android/src/main/java/com/swmansion/enriched/{EnrichedTextInputConnectionWrapper.kt → textinput/EnrichedTextInputConnectionWrapper.kt} +2 -2
- package/android/src/main/java/com/swmansion/enriched/textinput/EnrichedTextInputSpannableFactory.kt +83 -0
- package/android/src/main/java/com/swmansion/enriched/{EnrichedTextInputView.kt → textinput/EnrichedTextInputView.kt} +87 -51
- package/android/src/main/java/com/swmansion/enriched/{EnrichedTextInputViewLayoutManager.kt → textinput/EnrichedTextInputViewLayoutManager.kt} +1 -1
- package/android/src/main/java/com/swmansion/enriched/{EnrichedTextInputViewManager.kt → textinput/EnrichedTextInputViewManager.kt} +24 -17
- package/android/src/main/java/com/swmansion/enriched/{MeasurementStore.kt → textinput/MeasurementStore.kt} +5 -4
- package/android/src/main/java/com/swmansion/enriched/{events → textinput/events}/MentionHandler.kt +2 -2
- package/android/src/main/java/com/swmansion/enriched/{events → textinput/events}/OnChangeHtmlEvent.kt +1 -1
- package/android/src/main/java/com/swmansion/enriched/{events → textinput/events}/OnChangeSelectionEvent.kt +1 -1
- package/android/src/main/java/com/swmansion/enriched/{events → textinput/events}/OnChangeStateEvent.kt +1 -1
- package/android/src/main/java/com/swmansion/enriched/{events → textinput/events}/OnChangeTextEvent.kt +2 -2
- package/android/src/main/java/com/swmansion/enriched/{events → textinput/events}/OnInputBlurEvent.kt +1 -1
- package/android/src/main/java/com/swmansion/enriched/{events → textinput/events}/OnInputFocusEvent.kt +1 -1
- package/android/src/main/java/com/swmansion/enriched/{events → textinput/events}/OnInputKeyPressEvent.kt +1 -1
- package/android/src/main/java/com/swmansion/enriched/{events → textinput/events}/OnLinkDetectedEvent.kt +1 -1
- package/android/src/main/java/com/swmansion/enriched/{events → textinput/events}/OnMentionDetectedEvent.kt +1 -1
- package/android/src/main/java/com/swmansion/enriched/{events → textinput/events}/OnMentionEvent.kt +1 -1
- package/android/src/main/java/com/swmansion/enriched/textinput/events/OnPasteImagesEvent.kt +47 -0
- package/android/src/main/java/com/swmansion/enriched/{events → textinput/events}/OnRequestHtmlResultEvent.kt +1 -1
- package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputBlockQuoteSpan.kt +14 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputBoldSpan.kt +14 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputCheckboxListSpan.kt +15 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputCodeBlockSpan.kt +14 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputH1Span.kt +14 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputH2Span.kt +14 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputH3Span.kt +14 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputH4Span.kt +14 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputH5Span.kt +14 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputH6Span.kt +14 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputImageSpan.kt +36 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputInlineCodeSpan.kt +14 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputItalicSpan.kt +14 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputLinkSpan.kt +15 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputMentionSpan.kt +18 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputOrderedListSpan.kt +21 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputStrikeThroughSpan.kt +14 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputUnderlineSpan.kt +14 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputUnorderedListSpan.kt +14 -0
- package/android/src/main/java/com/swmansion/enriched/{spans → textinput/spans}/EnrichedSpans.kt +39 -30
- package/android/src/main/java/com/swmansion/enriched/textinput/spans/interfaces/EnrichedInputSpan.kt +10 -0
- package/android/src/main/java/com/swmansion/enriched/{styles → textinput/styles}/HtmlStyle.kt +58 -43
- package/android/src/main/java/com/swmansion/enriched/{styles → textinput/styles}/InlineStyles.kt +4 -4
- package/android/src/main/java/com/swmansion/enriched/{styles → textinput/styles}/ListStyles.kt +77 -26
- package/android/src/main/java/com/swmansion/enriched/{styles → textinput/styles}/ParagraphStyles.kt +30 -25
- package/android/src/main/java/com/swmansion/enriched/{styles → textinput/styles}/ParametrizedStyles.kt +19 -19
- package/android/src/main/java/com/swmansion/enriched/{utils → textinput/utils}/EnrichedEditableFactory.kt +2 -2
- package/android/src/main/java/com/swmansion/enriched/{utils → textinput/utils}/EnrichedSelection.kt +15 -14
- package/android/src/main/java/com/swmansion/enriched/{utils → textinput/utils}/EnrichedSpanState.kt +15 -50
- package/android/src/main/java/com/swmansion/enriched/{utils → textinput/utils}/EnrichedSpannable.kt +3 -3
- package/android/src/main/java/com/swmansion/enriched/{utils → textinput/utils}/EnrichedSpannableStringBuilder.kt +2 -1
- package/android/src/main/java/com/swmansion/enriched/textinput/utils/RichContentReceiver.kt +127 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/utils/Utils.kt +106 -0
- package/android/src/main/java/com/swmansion/enriched/{watchers → textinput/watchers}/EnrichedSpanWatcher.kt +10 -10
- package/android/src/main/java/com/swmansion/enriched/{watchers → textinput/watchers}/EnrichedTextWatcher.kt +3 -3
- package/android/src/main/new_arch/CMakeLists.txt +1 -1
- package/android/src/main/new_arch/ReactNativeEnrichedSpec.cpp +11 -0
- package/android/src/main/new_arch/ReactNativeEnrichedSpec.h +15 -0
- package/android/src/main/new_arch/react/renderer/components/{RNEnrichedTextInputViewSpec → ReactNativeEnrichedSpec}/EnrichedTextInputMeasurementManager.h +1 -1
- package/android/src/main/new_arch/react/renderer/components/{RNEnrichedTextInputViewSpec → ReactNativeEnrichedSpec}/EnrichedTextInputShadowNode.h +2 -2
- package/android/src/main/new_arch/react/renderer/components/{RNEnrichedTextInputViewSpec → ReactNativeEnrichedSpec}/conversions.h +1 -1
- package/ios/EnrichedTextInputView.h +1 -0
- package/ios/EnrichedTextInputView.mm +274 -55
- package/ios/config/InputConfig.h +10 -0
- package/ios/config/InputConfig.mm +119 -0
- package/ios/extensions/ImageExtension.h +35 -0
- package/ios/extensions/ImageExtension.mm +156 -0
- package/ios/extensions/LayoutManagerExtension.mm +115 -95
- package/ios/generated/{RNEnrichedTextInputViewSpec → ReactNativeEnrichedSpec}/ComponentDescriptors.cpp +1 -1
- package/ios/generated/{RNEnrichedTextInputViewSpec → ReactNativeEnrichedSpec}/ComponentDescriptors.h +1 -1
- package/{android/generated/jni/react/renderer/components/RNEnrichedTextInputViewSpec → ios/generated/ReactNativeEnrichedSpec}/EventEmitters.cpp +31 -29
- package/{android/generated/jni/react/renderer/components/RNEnrichedTextInputViewSpec → ios/generated/ReactNativeEnrichedSpec}/EventEmitters.h +22 -25
- package/ios/generated/{RNEnrichedTextInputViewSpec → ReactNativeEnrichedSpec}/Props.h +57 -0
- package/ios/generated/{RNEnrichedTextInputViewSpec → ReactNativeEnrichedSpec}/RCTComponentViewHelpers.h +21 -0
- package/ios/inputParser/InputParser.mm +135 -8
- package/ios/inputTextView/InputTextView.mm +118 -0
- package/ios/interfaces/ImageAttachment.h +1 -0
- package/ios/interfaces/ImageAttachment.mm +43 -4
- package/ios/interfaces/StyleHeaders.h +13 -2
- package/ios/interfaces/StyleTypeEnum.h +1 -0
- package/ios/internals/EnrichedTextInputViewState.cpp +6 -6
- package/ios/styles/CheckboxListStyle.mm +321 -0
- package/ios/styles/H1Style.mm +3 -0
- package/ios/styles/H2Style.mm +3 -0
- package/ios/styles/H3Style.mm +3 -0
- package/ios/styles/H4Style.mm +3 -0
- package/ios/styles/H5Style.mm +3 -0
- package/ios/styles/H6Style.mm +3 -0
- package/ios/styles/HeadingStyleBase.mm +150 -78
- package/ios/utils/CheckboxHitTestUtils.h +10 -0
- package/ios/utils/CheckboxHitTestUtils.mm +123 -0
- package/ios/utils/ParagraphAttributesUtils.mm +83 -53
- package/ios/utils/TextBlockTapGestureRecognizer.h +17 -0
- package/ios/utils/TextBlockTapGestureRecognizer.mm +56 -0
- package/ios/utils/ZeroWidthSpaceUtils.mm +14 -3
- package/lib/module/EnrichedTextInput.js +36 -11
- package/lib/module/EnrichedTextInput.js.map +1 -1
- package/lib/module/{EnrichedTextInputNativeComponent.ts → spec/EnrichedTextInputNativeComponent.ts} +40 -9
- package/lib/module/types.js +4 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/utils/normalizeHtmlStyle.js +6 -0
- package/lib/module/utils/normalizeHtmlStyle.js.map +1 -1
- package/lib/module/utils/nullthrows.js +9 -0
- package/lib/module/utils/nullthrows.js.map +1 -0
- package/lib/typescript/src/EnrichedTextInput.d.ts +9 -49
- package/lib/typescript/src/EnrichedTextInput.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +2 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/{EnrichedTextInputNativeComponent.d.ts → spec/EnrichedTextInputNativeComponent.d.ts} +33 -8
- package/lib/typescript/src/spec/EnrichedTextInputNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +58 -0
- package/lib/typescript/src/types.d.ts.map +1 -0
- package/lib/typescript/src/utils/normalizeHtmlStyle.d.ts +2 -2
- package/lib/typescript/src/utils/normalizeHtmlStyle.d.ts.map +1 -1
- package/lib/typescript/src/utils/nullthrows.d.ts +2 -0
- package/lib/typescript/src/utils/nullthrows.d.ts.map +1 -0
- package/lib/typescript/src/utils/regexParser.d.ts +1 -1
- package/lib/typescript/src/utils/regexParser.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/EnrichedTextInput.tsx +49 -62
- package/src/index.tsx +3 -1
- package/src/{EnrichedTextInputNativeComponent.ts → spec/EnrichedTextInputNativeComponent.ts} +40 -9
- package/src/types.ts +59 -0
- package/src/utils/normalizeHtmlStyle.ts +8 -5
- package/src/utils/nullthrows.ts +7 -0
- package/src/utils/regexParser.ts +1 -1
- package/android/src/main/java/com/swmansion/enriched/events/OnChangeStateDeprecatedEvent.kt +0 -21
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedBoldSpan.kt +0 -17
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedH1Span.kt +0 -24
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedH2Span.kt +0 -24
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedH3Span.kt +0 -24
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedH4Span.kt +0 -24
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedH5Span.kt +0 -24
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedH6Span.kt +0 -24
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedItalicSpan.kt +0 -16
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedStrikeThroughSpan.kt +0 -15
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedUnderlineSpan.kt +0 -15
- package/android/src/main/java/com/swmansion/enriched/spans/interfaces/EnrichedInlineSpan.kt +0 -3
- package/android/src/main/java/com/swmansion/enriched/spans/interfaces/EnrichedSpan.kt +0 -9
- package/android/src/main/java/com/swmansion/enriched/utils/Utils.kt +0 -21
- package/android/src/main/new_arch/RNEnrichedTextInputViewSpec.cpp +0 -22
- package/android/src/main/new_arch/RNEnrichedTextInputViewSpec.h +0 -26
- package/lib/typescript/src/EnrichedTextInputNativeComponent.d.ts.map +0 -1
- /package/android/generated/jni/react/renderer/components/{RNEnrichedTextInputViewSpec → ReactNativeEnrichedSpec}/Props.cpp +0 -0
- /package/android/generated/jni/react/renderer/components/{RNEnrichedTextInputViewSpec → ReactNativeEnrichedSpec}/ShadowNodes.cpp +0 -0
- /package/android/generated/jni/react/renderer/components/{RNEnrichedTextInputViewSpec → ReactNativeEnrichedSpec}/ShadowNodes.h +0 -0
- /package/android/generated/jni/react/renderer/components/{RNEnrichedTextInputViewSpec → ReactNativeEnrichedSpec}/States.cpp +0 -0
- /package/android/generated/jni/react/renderer/components/{RNEnrichedTextInputViewSpec → ReactNativeEnrichedSpec}/States.h +0 -0
- /package/android/src/main/new_arch/react/renderer/components/{RNEnrichedTextInputViewSpec → ReactNativeEnrichedSpec}/EnrichedTextInputComponentDescriptor.h +0 -0
- /package/android/src/main/new_arch/react/renderer/components/{RNEnrichedTextInputViewSpec → ReactNativeEnrichedSpec}/EnrichedTextInputMeasurementManager.cpp +0 -0
- /package/android/src/main/new_arch/react/renderer/components/{RNEnrichedTextInputViewSpec → ReactNativeEnrichedSpec}/EnrichedTextInputShadowNode.cpp +0 -0
- /package/android/src/main/new_arch/react/renderer/components/{RNEnrichedTextInputViewSpec → ReactNativeEnrichedSpec}/EnrichedTextInputState.cpp +0 -0
- /package/android/src/main/new_arch/react/renderer/components/{RNEnrichedTextInputViewSpec → ReactNativeEnrichedSpec}/EnrichedTextInputState.h +0 -0
- /package/ios/generated/{RNEnrichedTextInputViewSpec → ReactNativeEnrichedSpec}/Props.cpp +0 -0
- /package/ios/generated/{RNEnrichedTextInputViewSpec → ReactNativeEnrichedSpec}/ShadowNodes.cpp +0 -0
- /package/ios/generated/{RNEnrichedTextInputViewSpec → ReactNativeEnrichedSpec}/ShadowNodes.h +0 -0
- /package/ios/generated/{RNEnrichedTextInputViewSpec → ReactNativeEnrichedSpec}/States.cpp +0 -0
- /package/ios/generated/{RNEnrichedTextInputViewSpec → ReactNativeEnrichedSpec}/States.h +0 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#import <UIKit/UIKit.h>
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
UIImage (animatedGIF)
|
|
5
|
+
|
|
6
|
+
This category adds class methods to `UIImage` to create an animated
|
|
7
|
+
`UIImage` from an animated GIF.
|
|
8
|
+
*/
|
|
9
|
+
@interface UIImage (ImageExtension)
|
|
10
|
+
|
|
11
|
+
/*
|
|
12
|
+
UIImage *animation = [UIImage animatedImageWithAnimatedGIFData:theData];
|
|
13
|
+
|
|
14
|
+
I interpret `theData` as a GIF. I create an animated `UIImage` using the
|
|
15
|
+
source images in the GIF.
|
|
16
|
+
|
|
17
|
+
The GIF stores a separate duration for each frame, in units of centiseconds
|
|
18
|
+
(hundredths of a second). However, a `UIImage` only has a single, total
|
|
19
|
+
`duration` property, which is a floating-point number.
|
|
20
|
+
|
|
21
|
+
To handle this mismatch, I add each source image (from the GIF) to
|
|
22
|
+
`animation` a varying number of times to match the ratios between the frame
|
|
23
|
+
durations in the GIF.
|
|
24
|
+
|
|
25
|
+
For example, suppose the GIF contains three frames. Frame 0 has duration 3.
|
|
26
|
+
Frame 1 has duration 9. Frame 2 has duration 15. I divide each duration by
|
|
27
|
+
the greatest common denominator of all the durations, which is 3, and add
|
|
28
|
+
each frame the resulting number of times. Thus `animation` will contain
|
|
29
|
+
frame 0 3/3 = 1 time, then frame 1 9/3 = 3 times, then frame 2 15/3 = 5
|
|
30
|
+
times. I set `animation.duration` to (3+9+15)/100 = 0.27 seconds.
|
|
31
|
+
*/
|
|
32
|
+
+ (UIImage *_Nullable)animatedImageWithAnimatedGIFData:
|
|
33
|
+
(NSData *_Nonnull)theData;
|
|
34
|
+
|
|
35
|
+
@end
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
#import "ImageExtension.h"
|
|
2
|
+
#import <ImageIO/ImageIO.h>
|
|
3
|
+
#include <cmath>
|
|
4
|
+
#include <vector>
|
|
5
|
+
|
|
6
|
+
#if __has_feature(objc_arc)
|
|
7
|
+
#define toCF (__bridge CFTypeRef)
|
|
8
|
+
#define fromCF (__bridge id)
|
|
9
|
+
#else
|
|
10
|
+
#define toCF (CFTypeRef)
|
|
11
|
+
#define fromCF (id)
|
|
12
|
+
#endif
|
|
13
|
+
|
|
14
|
+
// implementation from:
|
|
15
|
+
// https://github.com/mayoff/uiimage-from-animated-gif/blob/master/uiimage-from-animated-gif/UIImage%2BanimatedGIF.m
|
|
16
|
+
@implementation UIImage (ImageExtension)
|
|
17
|
+
|
|
18
|
+
static int delayCentisecondsForImageAtIndex(CGImageSourceRef const source,
|
|
19
|
+
size_t const i) {
|
|
20
|
+
int delayCentiseconds = 1;
|
|
21
|
+
CFDictionaryRef const properties =
|
|
22
|
+
CGImageSourceCopyPropertiesAtIndex(source, i, NULL);
|
|
23
|
+
if (properties) {
|
|
24
|
+
CFDictionaryRef const gifProperties = (CFDictionaryRef)CFDictionaryGetValue(
|
|
25
|
+
properties, kCGImagePropertyGIFDictionary);
|
|
26
|
+
if (gifProperties) {
|
|
27
|
+
NSNumber *number = fromCF CFDictionaryGetValue(
|
|
28
|
+
gifProperties, kCGImagePropertyGIFUnclampedDelayTime);
|
|
29
|
+
if (number == NULL || [number doubleValue] == 0) {
|
|
30
|
+
number = fromCF CFDictionaryGetValue(gifProperties,
|
|
31
|
+
kCGImagePropertyGIFDelayTime);
|
|
32
|
+
}
|
|
33
|
+
if ([number doubleValue] > 0) {
|
|
34
|
+
// Even though the GIF stores the delay as an integer number of
|
|
35
|
+
// centiseconds, ImageIO “helpfully” converts that to seconds for us.
|
|
36
|
+
delayCentiseconds = (int)lrint([number doubleValue] * 100);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
CFRelease(properties);
|
|
40
|
+
}
|
|
41
|
+
return delayCentiseconds;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Changed to use std::vector references instead of C-arrays
|
|
45
|
+
static void createImagesAndDelays(CGImageSourceRef source, size_t count,
|
|
46
|
+
std::vector<CGImageRef> &imagesOut,
|
|
47
|
+
std::vector<int> &delayCentisecondsOut) {
|
|
48
|
+
for (size_t i = 0; i < count; ++i) {
|
|
49
|
+
imagesOut[i] = CGImageSourceCreateImageAtIndex(source, i, NULL);
|
|
50
|
+
delayCentisecondsOut[i] = delayCentisecondsForImageAtIndex(source, i);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
static int sum(const std::vector<int> &values) {
|
|
55
|
+
int theSum = 0;
|
|
56
|
+
for (int value : values) {
|
|
57
|
+
theSum += value;
|
|
58
|
+
}
|
|
59
|
+
return theSum;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
static int pairGCD(int a, int b) {
|
|
63
|
+
if (a < b)
|
|
64
|
+
return pairGCD(b, a);
|
|
65
|
+
while (true) {
|
|
66
|
+
int const r = a % b;
|
|
67
|
+
if (r == 0)
|
|
68
|
+
return b;
|
|
69
|
+
a = b;
|
|
70
|
+
b = r;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
static int vectorGCD(const std::vector<int> &values) {
|
|
75
|
+
if (values.empty())
|
|
76
|
+
return 1;
|
|
77
|
+
|
|
78
|
+
int gcd = values[0];
|
|
79
|
+
for (size_t i = 1; i < values.size(); ++i) {
|
|
80
|
+
// Note that after I process the first few elements of the vector, `gcd`
|
|
81
|
+
// will probably be smaller than any remaining element. By passing the
|
|
82
|
+
// smaller value as the second argument to `pairGCD`, I avoid making it swap
|
|
83
|
+
// the arguments.
|
|
84
|
+
gcd = pairGCD(values[i], gcd);
|
|
85
|
+
}
|
|
86
|
+
return gcd;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
static NSArray *frameArray(const std::vector<CGImageRef> &images,
|
|
90
|
+
const std::vector<int> &delayCentiseconds,
|
|
91
|
+
int const totalDurationCentiseconds) {
|
|
92
|
+
int const gcd = vectorGCD(delayCentiseconds);
|
|
93
|
+
size_t const frameCount = totalDurationCentiseconds / gcd;
|
|
94
|
+
|
|
95
|
+
// Replaced VLA with NSMutableArray for safety and OBJ-C++ compatibility
|
|
96
|
+
NSMutableArray *frames = [NSMutableArray arrayWithCapacity:frameCount];
|
|
97
|
+
|
|
98
|
+
for (size_t i = 0; i < images.size(); ++i) {
|
|
99
|
+
UIImage *const frame = [UIImage imageWithCGImage:images[i]];
|
|
100
|
+
for (size_t j = delayCentiseconds[i] / gcd; j > 0; --j) {
|
|
101
|
+
[frames addObject:frame];
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return frames;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
static void releaseImages(const std::vector<CGImageRef> &images) {
|
|
108
|
+
for (CGImageRef image : images) {
|
|
109
|
+
if (image)
|
|
110
|
+
CGImageRelease(image);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
static UIImage *
|
|
115
|
+
animatedImageWithAnimatedGIFImageSource(CGImageSourceRef const source) {
|
|
116
|
+
size_t const count = CGImageSourceGetCount(source);
|
|
117
|
+
if (count == 0) {
|
|
118
|
+
return nil;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Replaced VLAs (variable length arrays) with std::vector
|
|
122
|
+
std::vector<CGImageRef> images(count);
|
|
123
|
+
std::vector<int> delayCentiseconds(count); // in centiseconds
|
|
124
|
+
|
|
125
|
+
createImagesAndDelays(source, count, images, delayCentiseconds);
|
|
126
|
+
|
|
127
|
+
int const totalDurationCentiseconds = sum(delayCentiseconds);
|
|
128
|
+
NSArray *const frames =
|
|
129
|
+
frameArray(images, delayCentiseconds, totalDurationCentiseconds);
|
|
130
|
+
|
|
131
|
+
UIImage *const animation = [UIImage
|
|
132
|
+
animatedImageWithImages:frames
|
|
133
|
+
duration:(NSTimeInterval)totalDurationCentiseconds /
|
|
134
|
+
100.0];
|
|
135
|
+
|
|
136
|
+
releaseImages(images);
|
|
137
|
+
return animation;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
static UIImage *animatedImageWithAnimatedGIFReleasingImageSource(
|
|
141
|
+
CGImageSourceRef CF_RELEASES_ARGUMENT source) {
|
|
142
|
+
if (source) {
|
|
143
|
+
UIImage *const image = animatedImageWithAnimatedGIFImageSource(source);
|
|
144
|
+
CFRelease(source);
|
|
145
|
+
return image;
|
|
146
|
+
} else {
|
|
147
|
+
return nil;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
+ (UIImage *)animatedImageWithAnimatedGIFData:(NSData *)data {
|
|
152
|
+
return animatedImageWithAnimatedGIFReleasingImageSource(
|
|
153
|
+
CGImageSourceCreateWithData((__bridge CFDataRef)data, NULL));
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
@end
|
|
@@ -249,13 +249,16 @@ static void const *kInputKey = &kInputKey;
|
|
|
249
249
|
typedInput->stylesDict[@([UnorderedListStyle getStyleType])];
|
|
250
250
|
OrderedListStyle *olStyle =
|
|
251
251
|
typedInput->stylesDict[@([OrderedListStyle getStyleType])];
|
|
252
|
-
|
|
252
|
+
CheckboxListStyle *cbStyle =
|
|
253
|
+
typedInput->stylesDict[@([CheckboxListStyle getStyleType])];
|
|
254
|
+
if (ulStyle == nullptr || olStyle == nullptr || cbStyle == nullptr) {
|
|
253
255
|
return;
|
|
254
256
|
}
|
|
255
257
|
|
|
256
258
|
NSMutableArray *allLists = [[NSMutableArray alloc] init];
|
|
257
259
|
[allLists addObjectsFromArray:[ulStyle findAllOccurences:visibleCharRange]];
|
|
258
260
|
[allLists addObjectsFromArray:[olStyle findAllOccurences:visibleCharRange]];
|
|
261
|
+
[allLists addObjectsFromArray:[cbStyle findAllOccurences:visibleCharRange]];
|
|
259
262
|
|
|
260
263
|
for (StylePair *pair in allLists) {
|
|
261
264
|
NSParagraphStyle *pStyle = (NSParagraphStyle *)pair.styleValue;
|
|
@@ -280,62 +283,35 @@ static void const *kInputKey = &kInputKey;
|
|
|
280
283
|
NSTextContainer *container,
|
|
281
284
|
NSRange lineGlyphRange,
|
|
282
285
|
BOOL *stop) {
|
|
283
|
-
NSString *
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
characterIndexForGlyphAtIndex:
|
|
289
|
-
lineGlyphRange
|
|
290
|
-
.location]
|
|
291
|
-
input:typedInput];
|
|
292
|
-
|
|
293
|
-
if (pStyle.textLists.firstObject
|
|
294
|
-
.markerFormat ==
|
|
286
|
+
NSString *markerFormat =
|
|
287
|
+
pStyle.textLists.firstObject
|
|
288
|
+
.markerFormat;
|
|
289
|
+
|
|
290
|
+
if (markerFormat ==
|
|
295
291
|
NSTextListMarkerDecimal) {
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
} else
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
unorderedListBulletSize];
|
|
320
|
-
CGFloat bulletX = usedRect.origin.x -
|
|
321
|
-
gapWidth -
|
|
322
|
-
bulletSize / 2;
|
|
323
|
-
CGFloat centerY =
|
|
324
|
-
CGRectGetMidY(usedRect);
|
|
325
|
-
|
|
326
|
-
CGContextRef context =
|
|
327
|
-
UIGraphicsGetCurrentContext();
|
|
328
|
-
CGContextSaveGState(context);
|
|
329
|
-
{
|
|
330
|
-
[[typedInput->config
|
|
331
|
-
unorderedListBulletColor]
|
|
332
|
-
setFill];
|
|
333
|
-
CGContextAddArc(
|
|
334
|
-
context, bulletX, centerY,
|
|
335
|
-
bulletSize / 2, 0, 2 * M_PI, YES);
|
|
336
|
-
CGContextFillPath(context);
|
|
337
|
-
}
|
|
338
|
-
CGContextRestoreGState(context);
|
|
292
|
+
NSString *marker = [self
|
|
293
|
+
getDecimalMarkerForList:typedInput
|
|
294
|
+
charIndex:
|
|
295
|
+
[self
|
|
296
|
+
characterIndexForGlyphAtIndex:
|
|
297
|
+
lineGlyphRange
|
|
298
|
+
.location]];
|
|
299
|
+
[self drawDecimal:typedInput
|
|
300
|
+
marker:marker
|
|
301
|
+
markerAttributes:markerAttributes
|
|
302
|
+
origin:origin
|
|
303
|
+
usedRect:usedRect];
|
|
304
|
+
} else if (markerFormat ==
|
|
305
|
+
NSTextListMarkerDisc) {
|
|
306
|
+
[self drawBullet:typedInput
|
|
307
|
+
origin:origin
|
|
308
|
+
usedRect:usedRect];
|
|
309
|
+
} else if ([markerFormat
|
|
310
|
+
hasPrefix:@"{checkbox"]) {
|
|
311
|
+
[self drawCheckbox:typedInput
|
|
312
|
+
markerFormat:markerFormat
|
|
313
|
+
origin:origin
|
|
314
|
+
usedRect:usedRect];
|
|
339
315
|
}
|
|
340
316
|
// only first line of a list gets its
|
|
341
317
|
// marker drawn
|
|
@@ -345,52 +321,96 @@ static void const *kInputKey = &kInputKey;
|
|
|
345
321
|
}
|
|
346
322
|
}
|
|
347
323
|
|
|
348
|
-
- (NSString *)
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
if (
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
paragraphRangeForRange:NSMakeRange(
|
|
377
|
-
recentParagraphLocation - 1, 0)]
|
|
378
|
-
.location;
|
|
379
|
-
} else {
|
|
380
|
-
break;
|
|
381
|
-
}
|
|
324
|
+
- (NSString *)getDecimalMarkerForList:(EnrichedTextInputView *)input
|
|
325
|
+
charIndex:(NSUInteger)index {
|
|
326
|
+
NSString *fullText = input->textView.textStorage.string;
|
|
327
|
+
NSInteger itemNumber = 1;
|
|
328
|
+
|
|
329
|
+
NSRange currentParagraph =
|
|
330
|
+
[fullText paragraphRangeForRange:NSMakeRange(index, 0)];
|
|
331
|
+
if (currentParagraph.location > 0) {
|
|
332
|
+
OrderedListStyle *olStyle =
|
|
333
|
+
input->stylesDict[@([OrderedListStyle getStyleType])];
|
|
334
|
+
|
|
335
|
+
NSInteger prevParagraphsCount = 0;
|
|
336
|
+
NSInteger recentParagraphLocation =
|
|
337
|
+
[fullText paragraphRangeForRange:NSMakeRange(
|
|
338
|
+
currentParagraph.location - 1, 0)]
|
|
339
|
+
.location;
|
|
340
|
+
|
|
341
|
+
// seek for previous lists
|
|
342
|
+
while (true) {
|
|
343
|
+
if ([olStyle detectStyle:NSMakeRange(recentParagraphLocation, 0)]) {
|
|
344
|
+
prevParagraphsCount += 1;
|
|
345
|
+
|
|
346
|
+
if (recentParagraphLocation > 0) {
|
|
347
|
+
recentParagraphLocation =
|
|
348
|
+
[fullText
|
|
349
|
+
paragraphRangeForRange:NSMakeRange(
|
|
350
|
+
recentParagraphLocation - 1, 0)]
|
|
351
|
+
.location;
|
|
382
352
|
} else {
|
|
383
353
|
break;
|
|
384
354
|
}
|
|
355
|
+
} else {
|
|
356
|
+
break;
|
|
385
357
|
}
|
|
386
|
-
|
|
387
|
-
itemNumber = prevParagraphsCount + 1;
|
|
388
358
|
}
|
|
389
359
|
|
|
390
|
-
|
|
391
|
-
}
|
|
392
|
-
|
|
360
|
+
itemNumber = prevParagraphsCount + 1;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
return [NSString stringWithFormat:@"%ld.", (long)(itemNumber)];
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
- (void)drawCheckbox:(EnrichedTextInputView *)typedInput
|
|
367
|
+
markerFormat:(NSString *)markerFormat
|
|
368
|
+
origin:(CGPoint)origin
|
|
369
|
+
usedRect:(CGRect)usedRect {
|
|
370
|
+
BOOL isChecked = [markerFormat isEqualToString:@"{checkbox:1}"];
|
|
371
|
+
|
|
372
|
+
UIImage *image = isChecked ? typedInput->config.checkboxCheckedImage
|
|
373
|
+
: typedInput->config.checkboxUncheckedImage;
|
|
374
|
+
CGFloat gapWidth = [typedInput->config checkboxListGapWidth];
|
|
375
|
+
CGFloat boxSize = [typedInput->config checkboxListBoxSize];
|
|
376
|
+
|
|
377
|
+
CGFloat centerY = CGRectGetMidY(usedRect) + origin.y;
|
|
378
|
+
CGFloat boxX = origin.x + usedRect.origin.x - gapWidth - boxSize;
|
|
379
|
+
CGFloat boxY = centerY - boxSize / 2.0;
|
|
380
|
+
|
|
381
|
+
[image drawAtPoint:CGPointMake(boxX, boxY)];
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
- (void)drawBullet:(EnrichedTextInputView *)typedInput
|
|
385
|
+
origin:(CGPoint)origin
|
|
386
|
+
usedRect:(CGRect)usedRect {
|
|
387
|
+
CGFloat gapWidth = [typedInput->config unorderedListGapWidth];
|
|
388
|
+
CGFloat bulletSize = [typedInput->config unorderedListBulletSize];
|
|
389
|
+
CGFloat bulletX = origin.x + usedRect.origin.x - gapWidth - bulletSize / 2;
|
|
390
|
+
CGFloat centerY = CGRectGetMidY(usedRect) + origin.y;
|
|
391
|
+
|
|
392
|
+
CGContextRef context = UIGraphicsGetCurrentContext();
|
|
393
|
+
CGContextSaveGState(context);
|
|
394
|
+
{
|
|
395
|
+
[[typedInput->config unorderedListBulletColor] setFill];
|
|
396
|
+
CGContextAddArc(context, bulletX, centerY, bulletSize / 2, 0, 2 * M_PI,
|
|
397
|
+
YES);
|
|
398
|
+
CGContextFillPath(context);
|
|
393
399
|
}
|
|
400
|
+
CGContextRestoreGState(context);
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
- (void)drawDecimal:(EnrichedTextInputView *)typedInput
|
|
404
|
+
marker:(NSString *)marker
|
|
405
|
+
markerAttributes:(NSDictionary *)markerAttributes
|
|
406
|
+
origin:(CGPoint)origin
|
|
407
|
+
usedRect:(CGRect)usedRect {
|
|
408
|
+
CGFloat gapWidth = [typedInput->config orderedListGapWidth];
|
|
409
|
+
CGFloat markerWidth = [marker sizeWithAttributes:markerAttributes].width;
|
|
410
|
+
CGFloat markerX = usedRect.origin.x - gapWidth - markerWidth / 2;
|
|
411
|
+
|
|
412
|
+
[marker drawAtPoint:CGPointMake(markerX, usedRect.origin.y + origin.y)
|
|
413
|
+
withAttributes:markerAttributes];
|
|
394
414
|
}
|
|
395
415
|
|
|
396
416
|
@end
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
namespace facebook::react {
|
|
16
16
|
|
|
17
|
-
void
|
|
17
|
+
void ReactNativeEnrichedSpec_registerComponentDescriptorsFromCodegen(
|
|
18
18
|
std::shared_ptr<const ComponentDescriptorProviderRegistry> registry) {
|
|
19
19
|
|
|
20
20
|
}
|
package/ios/generated/{RNEnrichedTextInputViewSpec → ReactNativeEnrichedSpec}/ComponentDescriptors.h
RENAMED
|
@@ -18,7 +18,7 @@ namespace facebook::react {
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
void
|
|
21
|
+
void ReactNativeEnrichedSpec_registerComponentDescriptorsFromCodegen(
|
|
22
22
|
std::shared_ptr<const ComponentDescriptorProviderRegistry> registry);
|
|
23
23
|
|
|
24
24
|
} // namespace facebook::react
|
|
@@ -14,18 +14,18 @@
|
|
|
14
14
|
namespace facebook::react {
|
|
15
15
|
|
|
16
16
|
void EnrichedTextInputViewEventEmitter::onInputFocus(OnInputFocus event) const {
|
|
17
|
-
dispatchEvent("inputFocus", [](jsi::Runtime &runtime) {
|
|
17
|
+
dispatchEvent("inputFocus", [event=std::move(event)](jsi::Runtime &runtime) {
|
|
18
18
|
auto payload = jsi::Object(runtime);
|
|
19
|
-
|
|
19
|
+
payload.setProperty(runtime, "target", event.target);
|
|
20
20
|
return payload;
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
void EnrichedTextInputViewEventEmitter::onInputBlur(OnInputBlur event) const {
|
|
26
|
-
dispatchEvent("inputBlur", [](jsi::Runtime &runtime) {
|
|
26
|
+
dispatchEvent("inputBlur", [event=std::move(event)](jsi::Runtime &runtime) {
|
|
27
27
|
auto payload = jsi::Object(runtime);
|
|
28
|
-
|
|
28
|
+
payload.setProperty(runtime, "target", event.target);
|
|
29
29
|
return payload;
|
|
30
30
|
});
|
|
31
31
|
}
|
|
@@ -178,32 +178,13 @@ void EnrichedTextInputViewEventEmitter::onChangeState(OnChangeState event) const
|
|
|
178
178
|
mention.setProperty(runtime, "isBlocking", event.mention.isBlocking);
|
|
179
179
|
payload.setProperty(runtime, "mention", mention);
|
|
180
180
|
}
|
|
181
|
-
|
|
182
|
-
|
|
181
|
+
{
|
|
182
|
+
auto checkboxList = jsi::Object(runtime);
|
|
183
|
+
checkboxList.setProperty(runtime, "isActive", event.checkboxList.isActive);
|
|
184
|
+
checkboxList.setProperty(runtime, "isConflicting", event.checkboxList.isConflicting);
|
|
185
|
+
checkboxList.setProperty(runtime, "isBlocking", event.checkboxList.isBlocking);
|
|
186
|
+
payload.setProperty(runtime, "checkboxList", checkboxList);
|
|
183
187
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
void EnrichedTextInputViewEventEmitter::onChangeStateDeprecated(OnChangeStateDeprecated event) const {
|
|
187
|
-
dispatchEvent("changeStateDeprecated", [event=std::move(event)](jsi::Runtime &runtime) {
|
|
188
|
-
auto payload = jsi::Object(runtime);
|
|
189
|
-
payload.setProperty(runtime, "isBold", event.isBold);
|
|
190
|
-
payload.setProperty(runtime, "isItalic", event.isItalic);
|
|
191
|
-
payload.setProperty(runtime, "isUnderline", event.isUnderline);
|
|
192
|
-
payload.setProperty(runtime, "isStrikeThrough", event.isStrikeThrough);
|
|
193
|
-
payload.setProperty(runtime, "isInlineCode", event.isInlineCode);
|
|
194
|
-
payload.setProperty(runtime, "isH1", event.isH1);
|
|
195
|
-
payload.setProperty(runtime, "isH2", event.isH2);
|
|
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);
|
|
200
|
-
payload.setProperty(runtime, "isCodeBlock", event.isCodeBlock);
|
|
201
|
-
payload.setProperty(runtime, "isBlockQuote", event.isBlockQuote);
|
|
202
|
-
payload.setProperty(runtime, "isOrderedList", event.isOrderedList);
|
|
203
|
-
payload.setProperty(runtime, "isUnorderedList", event.isUnorderedList);
|
|
204
|
-
payload.setProperty(runtime, "isLink", event.isLink);
|
|
205
|
-
payload.setProperty(runtime, "isImage", event.isImage);
|
|
206
|
-
payload.setProperty(runtime, "isMention", event.isMention);
|
|
207
188
|
return payload;
|
|
208
189
|
});
|
|
209
190
|
}
|
|
@@ -271,4 +252,25 @@ void EnrichedTextInputViewEventEmitter::onInputKeyPress(OnInputKeyPress event) c
|
|
|
271
252
|
});
|
|
272
253
|
}
|
|
273
254
|
|
|
255
|
+
|
|
256
|
+
void EnrichedTextInputViewEventEmitter::onPasteImages(OnPasteImages event) const {
|
|
257
|
+
dispatchEvent("pasteImages", [event=std::move(event)](jsi::Runtime &runtime) {
|
|
258
|
+
auto payload = jsi::Object(runtime);
|
|
259
|
+
|
|
260
|
+
auto images = jsi::Array(runtime, event.images.size());
|
|
261
|
+
size_t imagesIndex = 0;
|
|
262
|
+
for (auto imagesValue : event.images) {
|
|
263
|
+
auto imagesObject = jsi::Object(runtime);
|
|
264
|
+
imagesObject.setProperty(runtime, "uri", imagesValue.uri);
|
|
265
|
+
imagesObject.setProperty(runtime, "type", imagesValue.type);
|
|
266
|
+
imagesObject.setProperty(runtime, "width", imagesValue.width);
|
|
267
|
+
imagesObject.setProperty(runtime, "height", imagesValue.height);
|
|
268
|
+
images.setValueAtIndex(runtime, imagesIndex++, imagesObject);
|
|
269
|
+
}
|
|
270
|
+
payload.setProperty(runtime, "images", images);
|
|
271
|
+
|
|
272
|
+
return payload;
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
|
|
274
276
|
} // namespace facebook::react
|
|
@@ -18,11 +18,11 @@ class EnrichedTextInputViewEventEmitter : public ViewEventEmitter {
|
|
|
18
18
|
using ViewEventEmitter::ViewEventEmitter;
|
|
19
19
|
|
|
20
20
|
struct OnInputFocus {
|
|
21
|
-
|
|
21
|
+
int target;
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
struct OnInputBlur {
|
|
25
|
-
|
|
25
|
+
int target;
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
struct OnChangeText {
|
|
@@ -141,6 +141,12 @@ class EnrichedTextInputViewEventEmitter : public ViewEventEmitter {
|
|
|
141
141
|
bool isBlocking;
|
|
142
142
|
};
|
|
143
143
|
|
|
144
|
+
struct OnChangeStateCheckboxList {
|
|
145
|
+
bool isActive;
|
|
146
|
+
bool isConflicting;
|
|
147
|
+
bool isBlocking;
|
|
148
|
+
};
|
|
149
|
+
|
|
144
150
|
struct OnChangeState {
|
|
145
151
|
OnChangeStateBold bold;
|
|
146
152
|
OnChangeStateItalic italic;
|
|
@@ -160,27 +166,7 @@ class EnrichedTextInputViewEventEmitter : public ViewEventEmitter {
|
|
|
160
166
|
OnChangeStateLink link;
|
|
161
167
|
OnChangeStateImage image;
|
|
162
168
|
OnChangeStateMention mention;
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
struct OnChangeStateDeprecated {
|
|
166
|
-
bool isBold;
|
|
167
|
-
bool isItalic;
|
|
168
|
-
bool isUnderline;
|
|
169
|
-
bool isStrikeThrough;
|
|
170
|
-
bool isInlineCode;
|
|
171
|
-
bool isH1;
|
|
172
|
-
bool isH2;
|
|
173
|
-
bool isH3;
|
|
174
|
-
bool isH4;
|
|
175
|
-
bool isH5;
|
|
176
|
-
bool isH6;
|
|
177
|
-
bool isCodeBlock;
|
|
178
|
-
bool isBlockQuote;
|
|
179
|
-
bool isOrderedList;
|
|
180
|
-
bool isUnorderedList;
|
|
181
|
-
bool isLink;
|
|
182
|
-
bool isImage;
|
|
183
|
-
bool isMention;
|
|
169
|
+
OnChangeStateCheckboxList checkboxList;
|
|
184
170
|
};
|
|
185
171
|
|
|
186
172
|
struct OnLinkDetected {
|
|
@@ -215,6 +201,17 @@ class EnrichedTextInputViewEventEmitter : public ViewEventEmitter {
|
|
|
215
201
|
struct OnInputKeyPress {
|
|
216
202
|
std::string key;
|
|
217
203
|
};
|
|
204
|
+
|
|
205
|
+
struct OnPasteImagesImages {
|
|
206
|
+
std::string uri;
|
|
207
|
+
std::string type;
|
|
208
|
+
Float width;
|
|
209
|
+
Float height;
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
struct OnPasteImages {
|
|
213
|
+
std::vector<OnPasteImagesImages> images;
|
|
214
|
+
};
|
|
218
215
|
void onInputFocus(OnInputFocus value) const;
|
|
219
216
|
|
|
220
217
|
void onInputBlur(OnInputBlur value) const;
|
|
@@ -225,8 +222,6 @@ class EnrichedTextInputViewEventEmitter : public ViewEventEmitter {
|
|
|
225
222
|
|
|
226
223
|
void onChangeState(OnChangeState value) const;
|
|
227
224
|
|
|
228
|
-
void onChangeStateDeprecated(OnChangeStateDeprecated value) const;
|
|
229
|
-
|
|
230
225
|
void onLinkDetected(OnLinkDetected value) const;
|
|
231
226
|
|
|
232
227
|
void onMentionDetected(OnMentionDetected value) const;
|
|
@@ -238,5 +233,7 @@ class EnrichedTextInputViewEventEmitter : public ViewEventEmitter {
|
|
|
238
233
|
void onRequestHtmlResult(OnRequestHtmlResult value) const;
|
|
239
234
|
|
|
240
235
|
void onInputKeyPress(OnInputKeyPress value) const;
|
|
236
|
+
|
|
237
|
+
void onPasteImages(OnPasteImages value) const;
|
|
241
238
|
};
|
|
242
239
|
} // namespace facebook::react
|