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
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
#import "EnrichedTextInputView.h"
|
|
2
2
|
#import "CoreText/CoreText.h"
|
|
3
|
+
#import "ImageAttachment.h"
|
|
3
4
|
#import "LayoutManagerExtension.h"
|
|
4
5
|
#import "ParagraphAttributesUtils.h"
|
|
5
6
|
#import "RCTFabricComponentsPlugins.h"
|
|
6
7
|
#import "StringExtension.h"
|
|
7
8
|
#import "StyleHeaders.h"
|
|
9
|
+
#import "TextBlockTapGestureRecognizer.h"
|
|
8
10
|
#import "UIView+React.h"
|
|
9
11
|
#import "WordsUtils.h"
|
|
10
12
|
#import "ZeroWidthSpaceUtils.h"
|
|
@@ -26,7 +28,8 @@
|
|
|
26
28
|
using namespace facebook::react;
|
|
27
29
|
|
|
28
30
|
@interface EnrichedTextInputView () <RCTEnrichedTextInputViewViewProtocol,
|
|
29
|
-
UITextViewDelegate,
|
|
31
|
+
UITextViewDelegate,
|
|
32
|
+
UIGestureRecognizerDelegate, NSObject>
|
|
30
33
|
|
|
31
34
|
@end
|
|
32
35
|
|
|
@@ -46,6 +49,7 @@ using namespace facebook::react;
|
|
|
46
49
|
UIColor *_placeholderColor;
|
|
47
50
|
BOOL _emitFocusBlur;
|
|
48
51
|
BOOL _emitTextChange;
|
|
52
|
+
NSMutableDictionary<NSValue *, UIImageView *> *_attachmentViews;
|
|
49
53
|
}
|
|
50
54
|
|
|
51
55
|
// MARK: - Component utils
|
|
@@ -116,6 +120,8 @@ Class<RCTComponentViewProtocol> EnrichedTextInputViewCls(void) {
|
|
|
116
120
|
[[UnorderedListStyle alloc] initWithInput:self],
|
|
117
121
|
@([OrderedListStyle getStyleType]) :
|
|
118
122
|
[[OrderedListStyle alloc] initWithInput:self],
|
|
123
|
+
@([CheckboxListStyle getStyleType]) :
|
|
124
|
+
[[CheckboxListStyle alloc] initWithInput:self],
|
|
119
125
|
@([BlockQuoteStyle getStyleType]) :
|
|
120
126
|
[[BlockQuoteStyle alloc] initWithInput:self],
|
|
121
127
|
@([CodeBlockStyle getStyleType]) :
|
|
@@ -141,63 +147,70 @@ Class<RCTComponentViewProtocol> EnrichedTextInputViewCls(void) {
|
|
|
141
147
|
@([H4Style getStyleType]), @([H5Style getStyleType]),
|
|
142
148
|
@([H6Style getStyleType]), @([UnorderedListStyle getStyleType]),
|
|
143
149
|
@([OrderedListStyle getStyleType]), @([BlockQuoteStyle getStyleType]),
|
|
144
|
-
@([CodeBlockStyle getStyleType])
|
|
150
|
+
@([CodeBlockStyle getStyleType]), @([CheckboxListStyle getStyleType])
|
|
145
151
|
],
|
|
146
152
|
@([H2Style getStyleType]) : @[
|
|
147
153
|
@([H1Style getStyleType]), @([H3Style getStyleType]),
|
|
148
154
|
@([H4Style getStyleType]), @([H5Style getStyleType]),
|
|
149
155
|
@([H6Style getStyleType]), @([UnorderedListStyle getStyleType]),
|
|
150
156
|
@([OrderedListStyle getStyleType]), @([BlockQuoteStyle getStyleType]),
|
|
151
|
-
@([CodeBlockStyle getStyleType])
|
|
157
|
+
@([CodeBlockStyle getStyleType]), @([CheckboxListStyle getStyleType])
|
|
152
158
|
],
|
|
153
159
|
@([H3Style getStyleType]) : @[
|
|
154
160
|
@([H1Style getStyleType]), @([H2Style getStyleType]),
|
|
155
161
|
@([H4Style getStyleType]), @([H5Style getStyleType]),
|
|
156
162
|
@([H6Style getStyleType]), @([UnorderedListStyle getStyleType]),
|
|
157
163
|
@([OrderedListStyle getStyleType]), @([BlockQuoteStyle getStyleType]),
|
|
158
|
-
@([CodeBlockStyle getStyleType])
|
|
164
|
+
@([CodeBlockStyle getStyleType]), @([CheckboxListStyle getStyleType])
|
|
159
165
|
],
|
|
160
166
|
@([H4Style getStyleType]) : @[
|
|
161
167
|
@([H1Style getStyleType]), @([H2Style getStyleType]),
|
|
162
168
|
@([H3Style getStyleType]), @([H5Style getStyleType]),
|
|
163
169
|
@([H6Style getStyleType]), @([UnorderedListStyle getStyleType]),
|
|
164
170
|
@([OrderedListStyle getStyleType]), @([BlockQuoteStyle getStyleType]),
|
|
165
|
-
@([CodeBlockStyle getStyleType])
|
|
171
|
+
@([CodeBlockStyle getStyleType]), @([CheckboxListStyle getStyleType])
|
|
166
172
|
],
|
|
167
173
|
@([H5Style getStyleType]) : @[
|
|
168
174
|
@([H1Style getStyleType]), @([H2Style getStyleType]),
|
|
169
175
|
@([H3Style getStyleType]), @([H4Style getStyleType]),
|
|
170
176
|
@([H6Style getStyleType]), @([UnorderedListStyle getStyleType]),
|
|
171
177
|
@([OrderedListStyle getStyleType]), @([BlockQuoteStyle getStyleType]),
|
|
172
|
-
@([CodeBlockStyle getStyleType])
|
|
178
|
+
@([CodeBlockStyle getStyleType]), @([CheckboxListStyle getStyleType])
|
|
173
179
|
],
|
|
174
180
|
@([H6Style getStyleType]) : @[
|
|
175
181
|
@([H1Style getStyleType]), @([H2Style getStyleType]),
|
|
176
182
|
@([H3Style getStyleType]), @([H4Style getStyleType]),
|
|
177
183
|
@([H5Style getStyleType]), @([UnorderedListStyle getStyleType]),
|
|
178
184
|
@([OrderedListStyle getStyleType]), @([BlockQuoteStyle getStyleType]),
|
|
179
|
-
@([CodeBlockStyle getStyleType])
|
|
185
|
+
@([CodeBlockStyle getStyleType]), @([CheckboxListStyle getStyleType])
|
|
180
186
|
],
|
|
181
187
|
@([UnorderedListStyle getStyleType]) : @[
|
|
182
188
|
@([H1Style getStyleType]), @([H2Style getStyleType]),
|
|
183
189
|
@([H3Style getStyleType]), @([H4Style getStyleType]),
|
|
184
190
|
@([H5Style getStyleType]), @([H6Style getStyleType]),
|
|
185
191
|
@([OrderedListStyle getStyleType]), @([BlockQuoteStyle getStyleType]),
|
|
186
|
-
@([CodeBlockStyle getStyleType])
|
|
192
|
+
@([CodeBlockStyle getStyleType]), @([CheckboxListStyle getStyleType])
|
|
187
193
|
],
|
|
188
194
|
@([OrderedListStyle getStyleType]) : @[
|
|
189
195
|
@([H1Style getStyleType]), @([H2Style getStyleType]),
|
|
190
196
|
@([H3Style getStyleType]), @([H4Style getStyleType]),
|
|
191
197
|
@([H5Style getStyleType]), @([H6Style getStyleType]),
|
|
192
198
|
@([UnorderedListStyle getStyleType]), @([BlockQuoteStyle getStyleType]),
|
|
193
|
-
@([CodeBlockStyle getStyleType])
|
|
199
|
+
@([CodeBlockStyle getStyleType]), @([CheckboxListStyle getStyleType])
|
|
200
|
+
],
|
|
201
|
+
@([CheckboxListStyle getStyleType]) : @[
|
|
202
|
+
@([H1Style getStyleType]), @([H2Style getStyleType]),
|
|
203
|
+
@([H3Style getStyleType]), @([H4Style getStyleType]),
|
|
204
|
+
@([H5Style getStyleType]), @([H6Style getStyleType]),
|
|
205
|
+
@([UnorderedListStyle getStyleType]), @([OrderedListStyle getStyleType]),
|
|
206
|
+
@([BlockQuoteStyle getStyleType]), @([CodeBlockStyle getStyleType])
|
|
194
207
|
],
|
|
195
208
|
@([BlockQuoteStyle getStyleType]) : @[
|
|
196
209
|
@([H1Style getStyleType]), @([H2Style getStyleType]),
|
|
197
210
|
@([H3Style getStyleType]), @([H4Style getStyleType]),
|
|
198
211
|
@([H5Style getStyleType]), @([H6Style getStyleType]),
|
|
199
212
|
@([UnorderedListStyle getStyleType]), @([OrderedListStyle getStyleType]),
|
|
200
|
-
@([CodeBlockStyle getStyleType])
|
|
213
|
+
@([CodeBlockStyle getStyleType]), @([CheckboxListStyle getStyleType])
|
|
201
214
|
],
|
|
202
215
|
@([CodeBlockStyle getStyleType]) : @[
|
|
203
216
|
@([H1Style getStyleType]), @([H2Style getStyleType]),
|
|
@@ -207,7 +220,8 @@ Class<RCTComponentViewProtocol> EnrichedTextInputViewCls(void) {
|
|
|
207
220
|
@([UnderlineStyle getStyleType]), @([StrikethroughStyle getStyleType]),
|
|
208
221
|
@([UnorderedListStyle getStyleType]), @([OrderedListStyle getStyleType]),
|
|
209
222
|
@([BlockQuoteStyle getStyleType]), @([InlineCodeStyle getStyleType]),
|
|
210
|
-
@([MentionStyle getStyleType]), @([LinkStyle getStyleType])
|
|
223
|
+
@([MentionStyle getStyleType]), @([LinkStyle getStyleType]),
|
|
224
|
+
@([CheckboxListStyle getStyleType])
|
|
211
225
|
],
|
|
212
226
|
@([ImageStyle getStyleType]) :
|
|
213
227
|
@[ @([LinkStyle getStyleType]), @([MentionStyle getStyleType]) ]
|
|
@@ -233,12 +247,14 @@ Class<RCTComponentViewProtocol> EnrichedTextInputViewCls(void) {
|
|
|
233
247
|
@([H6Style getStyleType]) : @[],
|
|
234
248
|
@([UnorderedListStyle getStyleType]) : @[],
|
|
235
249
|
@([OrderedListStyle getStyleType]) : @[],
|
|
250
|
+
@([CheckboxListStyle getStyleType]) : @[],
|
|
236
251
|
@([BlockQuoteStyle getStyleType]) : @[],
|
|
237
252
|
@([CodeBlockStyle getStyleType]) : @[],
|
|
238
253
|
@([ImageStyle getStyleType]) : @[ @([InlineCodeStyle getStyleType]) ]
|
|
239
254
|
} mutableCopy];
|
|
240
255
|
|
|
241
256
|
parser = [[InputParser alloc] initWithInput:self];
|
|
257
|
+
_attachmentViews = [[NSMutableDictionary alloc] init];
|
|
242
258
|
}
|
|
243
259
|
|
|
244
260
|
- (void)setupTextView {
|
|
@@ -250,6 +266,9 @@ Class<RCTComponentViewProtocol> EnrichedTextInputViewCls(void) {
|
|
|
250
266
|
textView.input = self;
|
|
251
267
|
textView.layoutManager.input = self;
|
|
252
268
|
textView.adjustsFontForContentSizeCategory = YES;
|
|
269
|
+
[textView addGestureRecognizer:[[TextBlockTapGestureRecognizer alloc]
|
|
270
|
+
initWithInput:self
|
|
271
|
+
action:@selector(onTextBlockTap:)]];
|
|
253
272
|
}
|
|
254
273
|
|
|
255
274
|
- (void)setupPlaceholderLabel {
|
|
@@ -596,6 +615,37 @@ Class<RCTComponentViewProtocol> EnrichedTextInputViewCls(void) {
|
|
|
596
615
|
stylePropChanged = YES;
|
|
597
616
|
}
|
|
598
617
|
|
|
618
|
+
if (newViewProps.htmlStyle.ulCheckbox.boxSize !=
|
|
619
|
+
oldViewProps.htmlStyle.ulCheckbox.boxSize) {
|
|
620
|
+
[newConfig
|
|
621
|
+
setCheckboxListBoxSize:newViewProps.htmlStyle.ulCheckbox.boxSize];
|
|
622
|
+
stylePropChanged = YES;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
if (newViewProps.htmlStyle.ulCheckbox.gapWidth !=
|
|
626
|
+
oldViewProps.htmlStyle.ulCheckbox.gapWidth) {
|
|
627
|
+
[newConfig
|
|
628
|
+
setCheckboxListGapWidth:newViewProps.htmlStyle.ulCheckbox.gapWidth];
|
|
629
|
+
stylePropChanged = YES;
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
if (newViewProps.htmlStyle.ulCheckbox.marginLeft !=
|
|
633
|
+
oldViewProps.htmlStyle.ulCheckbox.marginLeft) {
|
|
634
|
+
[newConfig
|
|
635
|
+
setCheckboxListMarginLeft:newViewProps.htmlStyle.ulCheckbox.marginLeft];
|
|
636
|
+
stylePropChanged = YES;
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
if (newViewProps.htmlStyle.ulCheckbox.boxColor !=
|
|
640
|
+
oldViewProps.htmlStyle.ulCheckbox.boxColor) {
|
|
641
|
+
if (isColorMeaningful(newViewProps.htmlStyle.ulCheckbox.boxColor)) {
|
|
642
|
+
[newConfig setCheckboxListBoxColor:RCTUIColorFromSharedColor(
|
|
643
|
+
newViewProps.htmlStyle.ulCheckbox
|
|
644
|
+
.boxColor)];
|
|
645
|
+
stylePropChanged = YES;
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
|
|
599
649
|
if (newViewProps.htmlStyle.a.textDecorationLine !=
|
|
600
650
|
oldViewProps.htmlStyle.a.textDecorationLine) {
|
|
601
651
|
NSString *objcString =
|
|
@@ -1024,28 +1074,6 @@ Class<RCTComponentViewProtocol> EnrichedTextInputViewCls(void) {
|
|
|
1024
1074
|
_activeStyles = newActiveStyles;
|
|
1025
1075
|
_blockedStyles = newBlockedStyles;
|
|
1026
1076
|
|
|
1027
|
-
emitter->onChangeStateDeprecated({
|
|
1028
|
-
.isBold = [self isStyleActive:[BoldStyle getStyleType]],
|
|
1029
|
-
.isItalic = [self isStyleActive:[ItalicStyle getStyleType]],
|
|
1030
|
-
.isUnderline = [self isStyleActive:[UnderlineStyle getStyleType]],
|
|
1031
|
-
.isStrikeThrough =
|
|
1032
|
-
[self isStyleActive:[StrikethroughStyle getStyleType]],
|
|
1033
|
-
.isInlineCode = [self isStyleActive:[InlineCodeStyle getStyleType]],
|
|
1034
|
-
.isLink = [self isStyleActive:[LinkStyle getStyleType]],
|
|
1035
|
-
.isMention = [self isStyleActive:[MentionStyle getStyleType]],
|
|
1036
|
-
.isH1 = [self isStyleActive:[H1Style getStyleType]],
|
|
1037
|
-
.isH2 = [self isStyleActive:[H2Style getStyleType]],
|
|
1038
|
-
.isH3 = [self isStyleActive:[H3Style getStyleType]],
|
|
1039
|
-
.isH4 = [self isStyleActive:[H4Style getStyleType]],
|
|
1040
|
-
.isH5 = [self isStyleActive:[H5Style getStyleType]],
|
|
1041
|
-
.isH6 = [self isStyleActive:[H6Style getStyleType]],
|
|
1042
|
-
.isUnorderedList =
|
|
1043
|
-
[self isStyleActive:[UnorderedListStyle getStyleType]],
|
|
1044
|
-
.isOrderedList = [self isStyleActive:[OrderedListStyle getStyleType]],
|
|
1045
|
-
.isBlockQuote = [self isStyleActive:[BlockQuoteStyle getStyleType]],
|
|
1046
|
-
.isCodeBlock = [self isStyleActive:[CodeBlockStyle getStyleType]],
|
|
1047
|
-
.isImage = [self isStyleActive:[ImageStyle getStyleType]],
|
|
1048
|
-
});
|
|
1049
1077
|
emitter->onChangeState(
|
|
1050
1078
|
{.bold = GET_STYLE_STATE([BoldStyle getStyleType]),
|
|
1051
1079
|
.italic = GET_STYLE_STATE([ItalicStyle getStyleType]),
|
|
@@ -1064,7 +1092,8 @@ Class<RCTComponentViewProtocol> EnrichedTextInputViewCls(void) {
|
|
|
1064
1092
|
.orderedList = GET_STYLE_STATE([OrderedListStyle getStyleType]),
|
|
1065
1093
|
.blockQuote = GET_STYLE_STATE([BlockQuoteStyle getStyleType]),
|
|
1066
1094
|
.codeBlock = GET_STYLE_STATE([CodeBlockStyle getStyleType]),
|
|
1067
|
-
.image = GET_STYLE_STATE([ImageStyle getStyleType])
|
|
1095
|
+
.image = GET_STYLE_STATE([ImageStyle getStyleType]),
|
|
1096
|
+
.checkboxList = GET_STYLE_STATE([CheckboxListStyle getStyleType])});
|
|
1068
1097
|
}
|
|
1069
1098
|
}
|
|
1070
1099
|
|
|
@@ -1175,6 +1204,9 @@ Class<RCTComponentViewProtocol> EnrichedTextInputViewCls(void) {
|
|
|
1175
1204
|
[self toggleParagraphStyle:[UnorderedListStyle getStyleType]];
|
|
1176
1205
|
} else if ([commandName isEqualToString:@"toggleOrderedList"]) {
|
|
1177
1206
|
[self toggleParagraphStyle:[OrderedListStyle getStyleType]];
|
|
1207
|
+
} else if ([commandName isEqualToString:@"toggleCheckboxList"]) {
|
|
1208
|
+
BOOL checked = [args[0] boolValue];
|
|
1209
|
+
[self toggleCheckboxList:checked];
|
|
1178
1210
|
} else if ([commandName isEqualToString:@"toggleBlockQuote"]) {
|
|
1179
1211
|
[self toggleParagraphStyle:[BlockQuoteStyle getStyleType]];
|
|
1180
1212
|
} else if ([commandName isEqualToString:@"toggleCodeBlock"]) {
|
|
@@ -1282,6 +1314,32 @@ Class<RCTComponentViewProtocol> EnrichedTextInputViewCls(void) {
|
|
|
1282
1314
|
}
|
|
1283
1315
|
}
|
|
1284
1316
|
|
|
1317
|
+
- (void)emitOnPasteImagesEvent:(NSArray<NSDictionary *> *)images {
|
|
1318
|
+
auto emitter = [self getEventEmitter];
|
|
1319
|
+
if (emitter != nullptr) {
|
|
1320
|
+
std::vector<EnrichedTextInputViewEventEmitter::OnPasteImagesImages>
|
|
1321
|
+
imagesVector;
|
|
1322
|
+
imagesVector.reserve(images.count);
|
|
1323
|
+
|
|
1324
|
+
for (NSDictionary *img in images) {
|
|
1325
|
+
NSString *uri = img[@"uri"];
|
|
1326
|
+
NSString *type = img[@"type"];
|
|
1327
|
+
double width = [img[@"width"] doubleValue];
|
|
1328
|
+
double height = [img[@"height"] doubleValue];
|
|
1329
|
+
|
|
1330
|
+
EnrichedTextInputViewEventEmitter::OnPasteImagesImages imageStruct = {
|
|
1331
|
+
.uri = [uri toCppString],
|
|
1332
|
+
.type = [type toCppString],
|
|
1333
|
+
.width = width,
|
|
1334
|
+
.height = height};
|
|
1335
|
+
|
|
1336
|
+
imagesVector.push_back(imageStruct);
|
|
1337
|
+
}
|
|
1338
|
+
|
|
1339
|
+
emitter->onPasteImages({.images = imagesVector});
|
|
1340
|
+
}
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1285
1343
|
- (void)emitOnMentionDetectedEvent:(NSString *)text
|
|
1286
1344
|
indicator:(NSString *)indicator
|
|
1287
1345
|
attributes:(NSString *)attributes {
|
|
@@ -1369,6 +1427,24 @@ Class<RCTComponentViewProtocol> EnrichedTextInputViewCls(void) {
|
|
|
1369
1427
|
}
|
|
1370
1428
|
}
|
|
1371
1429
|
|
|
1430
|
+
- (void)toggleCheckboxList:(BOOL)checked {
|
|
1431
|
+
CheckboxListStyle *checkboxListStyleClass =
|
|
1432
|
+
(CheckboxListStyle *)stylesDict[@([CheckboxListStyle getStyleType])];
|
|
1433
|
+
if (checkboxListStyleClass == nullptr) {
|
|
1434
|
+
return;
|
|
1435
|
+
}
|
|
1436
|
+
// we always pass whole paragraph/s range to these styles
|
|
1437
|
+
NSRange paragraphRange = [textView.textStorage.string
|
|
1438
|
+
paragraphRangeForRange:textView.selectedRange];
|
|
1439
|
+
|
|
1440
|
+
if ([self handleStyleBlocksAndConflicts:[CheckboxListStyle getStyleType]
|
|
1441
|
+
range:paragraphRange]) {
|
|
1442
|
+
[checkboxListStyleClass applyStyleWithCheckedValue:checked
|
|
1443
|
+
inRange:paragraphRange];
|
|
1444
|
+
[self anyTextMayHaveBeenModified];
|
|
1445
|
+
}
|
|
1446
|
+
}
|
|
1447
|
+
|
|
1372
1448
|
- (void)addLinkAt:(NSInteger)start
|
|
1373
1449
|
end:(NSInteger)end
|
|
1374
1450
|
text:(NSString *)text
|
|
@@ -1587,27 +1663,6 @@ Class<RCTComponentViewProtocol> EnrichedTextInputViewCls(void) {
|
|
|
1587
1663
|
[codeBlockStyle manageCodeBlockFontAndColor];
|
|
1588
1664
|
}
|
|
1589
1665
|
|
|
1590
|
-
// improper headings fix
|
|
1591
|
-
H1Style *h1Style = stylesDict[@([H1Style getStyleType])];
|
|
1592
|
-
H2Style *h2Style = stylesDict[@([H2Style getStyleType])];
|
|
1593
|
-
H3Style *h3Style = stylesDict[@([H3Style getStyleType])];
|
|
1594
|
-
H4Style *h4Style = stylesDict[@([H4Style getStyleType])];
|
|
1595
|
-
H5Style *h5Style = stylesDict[@([H5Style getStyleType])];
|
|
1596
|
-
H6Style *h6Style = stylesDict[@([H6Style getStyleType])];
|
|
1597
|
-
|
|
1598
|
-
bool headingStylesDefined = h1Style != nullptr && h2Style != nullptr &&
|
|
1599
|
-
h3Style != nullptr && h4Style != nullptr &&
|
|
1600
|
-
h5Style != nullptr && h6Style != nullptr;
|
|
1601
|
-
|
|
1602
|
-
if (headingStylesDefined) {
|
|
1603
|
-
[h1Style handleImproperHeadings];
|
|
1604
|
-
[h2Style handleImproperHeadings];
|
|
1605
|
-
[h3Style handleImproperHeadings];
|
|
1606
|
-
[h4Style handleImproperHeadings];
|
|
1607
|
-
[h5Style handleImproperHeadings];
|
|
1608
|
-
[h6Style handleImproperHeadings];
|
|
1609
|
-
}
|
|
1610
|
-
|
|
1611
1666
|
// mentions management: removal and editing
|
|
1612
1667
|
MentionStyle *mentionStyleClass =
|
|
1613
1668
|
(MentionStyle *)stylesDict[@([MentionStyle getStyleType])];
|
|
@@ -1662,6 +1717,7 @@ Class<RCTComponentViewProtocol> EnrichedTextInputViewCls(void) {
|
|
|
1662
1717
|
[self tryUpdatingHeight];
|
|
1663
1718
|
// update active styles as well
|
|
1664
1719
|
[self tryUpdatingActiveStyles];
|
|
1720
|
+
[self layoutAttachments];
|
|
1665
1721
|
// update drawing - schedule debounced relayout
|
|
1666
1722
|
[self scheduleRelayoutIfNeeded];
|
|
1667
1723
|
}
|
|
@@ -1768,6 +1824,7 @@ Class<RCTComponentViewProtocol> EnrichedTextInputViewCls(void) {
|
|
|
1768
1824
|
|
|
1769
1825
|
UnorderedListStyle *uStyle = stylesDict[@([UnorderedListStyle getStyleType])];
|
|
1770
1826
|
OrderedListStyle *oStyle = stylesDict[@([OrderedListStyle getStyleType])];
|
|
1827
|
+
CheckboxListStyle *cbLStyle = stylesDict[@([CheckboxListStyle getStyleType])];
|
|
1771
1828
|
BlockQuoteStyle *bqStyle = stylesDict[@([BlockQuoteStyle getStyleType])];
|
|
1772
1829
|
CodeBlockStyle *cbStyle = stylesDict[@([CodeBlockStyle getStyleType])];
|
|
1773
1830
|
LinkStyle *linkStyle = stylesDict[@([LinkStyle getStyleType])];
|
|
@@ -1787,6 +1844,8 @@ Class<RCTComponentViewProtocol> EnrichedTextInputViewCls(void) {
|
|
|
1787
1844
|
[uStyle tryHandlingListShorcutInRange:range replacementText:text] ||
|
|
1788
1845
|
[oStyle handleBackspaceInRange:range replacementText:text] ||
|
|
1789
1846
|
[oStyle tryHandlingListShorcutInRange:range replacementText:text] ||
|
|
1847
|
+
[cbLStyle handleBackspaceInRange:range replacementText:text] ||
|
|
1848
|
+
[cbLStyle handleNewlinesInRange:range replacementText:text] ||
|
|
1790
1849
|
[bqStyle handleBackspaceInRange:range replacementText:text] ||
|
|
1791
1850
|
[cbStyle handleBackspaceInRange:range replacementText:text] ||
|
|
1792
1851
|
[linkStyle handleLeadingLinkReplacement:range replacementText:text] ||
|
|
@@ -1798,6 +1857,12 @@ Class<RCTComponentViewProtocol> EnrichedTextInputViewCls(void) {
|
|
|
1798
1857
|
[h4Style handleNewlinesInRange:range replacementText:text] ||
|
|
1799
1858
|
[h5Style handleNewlinesInRange:range replacementText:text] ||
|
|
1800
1859
|
[h6Style handleNewlinesInRange:range replacementText:text] ||
|
|
1860
|
+
[h1Style handleBackspaceInRange:range replacementText:text] ||
|
|
1861
|
+
[h2Style handleBackspaceInRange:range replacementText:text] ||
|
|
1862
|
+
[h3Style handleBackspaceInRange:range replacementText:text] ||
|
|
1863
|
+
[h4Style handleBackspaceInRange:range replacementText:text] ||
|
|
1864
|
+
[h5Style handleBackspaceInRange:range replacementText:text] ||
|
|
1865
|
+
[h6Style handleBackspaceInRange:range replacementText:text] ||
|
|
1801
1866
|
[ZeroWidthSpaceUtils handleBackspaceInRange:range
|
|
1802
1867
|
replacementText:text
|
|
1803
1868
|
input:self] ||
|
|
@@ -1819,6 +1884,14 @@ Class<RCTComponentViewProtocol> EnrichedTextInputViewCls(void) {
|
|
|
1819
1884
|
return NO;
|
|
1820
1885
|
}
|
|
1821
1886
|
|
|
1887
|
+
// Tapping near a link causes iOS to re-derive typingAttributes from
|
|
1888
|
+
// character attributes after textViewDidChangeSelection returns, undoing
|
|
1889
|
+
// the cleanup in manageSelectionBasedChanges. Strip them again here, right
|
|
1890
|
+
// before insertion, so new text never inherits link styling.
|
|
1891
|
+
if (linkStyle != nullptr) {
|
|
1892
|
+
[linkStyle manageLinkTypingAttributes];
|
|
1893
|
+
}
|
|
1894
|
+
|
|
1822
1895
|
return YES;
|
|
1823
1896
|
}
|
|
1824
1897
|
|
|
@@ -1890,6 +1963,51 @@ Class<RCTComponentViewProtocol> EnrichedTextInputViewCls(void) {
|
|
|
1890
1963
|
}
|
|
1891
1964
|
}
|
|
1892
1965
|
|
|
1966
|
+
- (void)onTextBlockTap:(TextBlockTapGestureRecognizer *)gr {
|
|
1967
|
+
if (gr.state != UIGestureRecognizerStateEnded)
|
|
1968
|
+
return;
|
|
1969
|
+
if (![self->textView isFirstResponder]) {
|
|
1970
|
+
[self->textView becomeFirstResponder];
|
|
1971
|
+
}
|
|
1972
|
+
|
|
1973
|
+
switch (gr.tapKind) {
|
|
1974
|
+
|
|
1975
|
+
case TextBlockTapKindCheckbox: {
|
|
1976
|
+
CheckboxListStyle *checkboxStyle =
|
|
1977
|
+
(CheckboxListStyle *)stylesDict[@([CheckboxListStyle getStyleType])];
|
|
1978
|
+
|
|
1979
|
+
if (checkboxStyle) {
|
|
1980
|
+
NSUInteger charIndex = (NSUInteger)gr.characterIndex;
|
|
1981
|
+
[checkboxStyle toggleCheckedAt:charIndex];
|
|
1982
|
+
[self anyTextMayHaveBeenModified];
|
|
1983
|
+
|
|
1984
|
+
NSString *fullText = textView.textStorage.string;
|
|
1985
|
+
NSRange paragraphRange =
|
|
1986
|
+
[fullText paragraphRangeForRange:NSMakeRange(charIndex, 0)];
|
|
1987
|
+
NSUInteger endOfLineIndex = NSMaxRange(paragraphRange);
|
|
1988
|
+
|
|
1989
|
+
// If the paragraph ends with a newline, step back by 1 so the cursor
|
|
1990
|
+
// stays on the current line instead of jumping to the next one.
|
|
1991
|
+
if (endOfLineIndex > 0 && endOfLineIndex <= fullText.length) {
|
|
1992
|
+
unichar lastChar = [fullText characterAtIndex:endOfLineIndex - 1];
|
|
1993
|
+
if ([[NSCharacterSet newlineCharacterSet] characterIsMember:lastChar]) {
|
|
1994
|
+
endOfLineIndex--;
|
|
1995
|
+
}
|
|
1996
|
+
}
|
|
1997
|
+
|
|
1998
|
+
// Move the cursor to the end of the currently tapped checkbox line.
|
|
1999
|
+
// Without this, the cursor may remain at its previous position,
|
|
2000
|
+
// potentially inside a different checkbox line.
|
|
2001
|
+
textView.selectedRange = NSMakeRange(endOfLineIndex, 0);
|
|
2002
|
+
}
|
|
2003
|
+
break;
|
|
2004
|
+
}
|
|
2005
|
+
|
|
2006
|
+
default:
|
|
2007
|
+
break;
|
|
2008
|
+
}
|
|
2009
|
+
}
|
|
2010
|
+
|
|
1893
2011
|
// MARK: - Media attachments delegate
|
|
1894
2012
|
|
|
1895
2013
|
- (void)mediaAttachmentDidUpdate:(NSTextAttachment *)attachment {
|
|
@@ -1915,6 +2033,107 @@ Class<RCTComponentViewProtocol> EnrichedTextInputViewCls(void) {
|
|
|
1915
2033
|
[storage edited:NSTextStorageEditedAttributes
|
|
1916
2034
|
range:foundRange
|
|
1917
2035
|
changeInLength:0];
|
|
2036
|
+
|
|
2037
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
2038
|
+
[self layoutAttachments];
|
|
2039
|
+
});
|
|
2040
|
+
}
|
|
2041
|
+
|
|
2042
|
+
// MARK: - Image/GIF Overlay Management
|
|
2043
|
+
|
|
2044
|
+
- (void)layoutAttachments {
|
|
2045
|
+
NSTextStorage *storage = textView.textStorage;
|
|
2046
|
+
NSMutableDictionary<NSValue *, UIImageView *> *activeAttachmentViews =
|
|
2047
|
+
[NSMutableDictionary dictionary];
|
|
2048
|
+
|
|
2049
|
+
// Iterate over the entire text to find ImageAttachments
|
|
2050
|
+
[storage enumerateAttribute:NSAttachmentAttributeName
|
|
2051
|
+
inRange:NSMakeRange(0, storage.length)
|
|
2052
|
+
options:0
|
|
2053
|
+
usingBlock:^(id value, NSRange range, BOOL *stop) {
|
|
2054
|
+
if ([value isKindOfClass:[ImageAttachment class]]) {
|
|
2055
|
+
ImageAttachment *attachment = (ImageAttachment *)value;
|
|
2056
|
+
|
|
2057
|
+
CGRect rect = [self frameForAttachment:attachment
|
|
2058
|
+
atRange:range];
|
|
2059
|
+
|
|
2060
|
+
// Get or Create the UIImageView for this specific
|
|
2061
|
+
// attachment key
|
|
2062
|
+
NSValue *key =
|
|
2063
|
+
[NSValue valueWithNonretainedObject:attachment];
|
|
2064
|
+
UIImageView *imgView = _attachmentViews[key];
|
|
2065
|
+
|
|
2066
|
+
if (!imgView) {
|
|
2067
|
+
// It doesn't exist yet, create it
|
|
2068
|
+
imgView = [[UIImageView alloc] initWithFrame:rect];
|
|
2069
|
+
imgView.contentMode = UIViewContentModeScaleAspectFit;
|
|
2070
|
+
imgView.tintColor = [UIColor labelColor];
|
|
2071
|
+
|
|
2072
|
+
// Add it directly to the TextView
|
|
2073
|
+
[textView addSubview:imgView];
|
|
2074
|
+
}
|
|
2075
|
+
|
|
2076
|
+
// Update position (in case text moved/scrolled)
|
|
2077
|
+
if (!CGRectEqualToRect(imgView.frame, rect)) {
|
|
2078
|
+
imgView.frame = rect;
|
|
2079
|
+
}
|
|
2080
|
+
UIImage *targetImage =
|
|
2081
|
+
attachment.storedAnimatedImage ?: attachment.image;
|
|
2082
|
+
|
|
2083
|
+
// Only set if different to avoid resetting the animation
|
|
2084
|
+
// loop
|
|
2085
|
+
if (imgView.image != targetImage) {
|
|
2086
|
+
imgView.image = targetImage;
|
|
2087
|
+
}
|
|
2088
|
+
|
|
2089
|
+
// Ensure it is visible on top
|
|
2090
|
+
imgView.hidden = NO;
|
|
2091
|
+
[textView bringSubviewToFront:imgView];
|
|
2092
|
+
|
|
2093
|
+
activeAttachmentViews[key] = imgView;
|
|
2094
|
+
// Remove from the old map so we know it has been claimed
|
|
2095
|
+
[_attachmentViews removeObjectForKey:key];
|
|
2096
|
+
}
|
|
2097
|
+
}];
|
|
2098
|
+
|
|
2099
|
+
// Everything remaining in _attachmentViews is dead or off-screen
|
|
2100
|
+
for (UIImageView *danglingView in _attachmentViews.allValues) {
|
|
2101
|
+
[danglingView removeFromSuperview];
|
|
2102
|
+
}
|
|
2103
|
+
_attachmentViews = activeAttachmentViews;
|
|
1918
2104
|
}
|
|
1919
2105
|
|
|
2106
|
+
- (CGRect)frameForAttachment:(ImageAttachment *)attachment
|
|
2107
|
+
atRange:(NSRange)range {
|
|
2108
|
+
NSLayoutManager *layoutManager = textView.layoutManager;
|
|
2109
|
+
NSTextContainer *textContainer = textView.textContainer;
|
|
2110
|
+
NSTextStorage *storage = textView.textStorage;
|
|
2111
|
+
|
|
2112
|
+
NSRange glyphRange = [layoutManager glyphRangeForCharacterRange:range
|
|
2113
|
+
actualCharacterRange:NULL];
|
|
2114
|
+
CGRect glyphRect = [layoutManager boundingRectForGlyphRange:glyphRange
|
|
2115
|
+
inTextContainer:textContainer];
|
|
2116
|
+
|
|
2117
|
+
CGRect lineRect =
|
|
2118
|
+
[layoutManager lineFragmentRectForGlyphAtIndex:glyphRange.location
|
|
2119
|
+
effectiveRange:NULL];
|
|
2120
|
+
CGSize attachmentSize = attachment.bounds.size;
|
|
2121
|
+
|
|
2122
|
+
UIFont *font = [storage attribute:NSFontAttributeName
|
|
2123
|
+
atIndex:range.location
|
|
2124
|
+
effectiveRange:NULL];
|
|
2125
|
+
if (!font) {
|
|
2126
|
+
font = [config primaryFont];
|
|
2127
|
+
}
|
|
2128
|
+
|
|
2129
|
+
// Calculate (Baseline Alignment)
|
|
2130
|
+
CGFloat targetY =
|
|
2131
|
+
CGRectGetMaxY(lineRect) + font.descender - attachmentSize.height;
|
|
2132
|
+
CGRect rect =
|
|
2133
|
+
CGRectMake(glyphRect.origin.x + textView.textContainerInset.left,
|
|
2134
|
+
targetY + textView.textContainerInset.top,
|
|
2135
|
+
attachmentSize.width, attachmentSize.height);
|
|
2136
|
+
|
|
2137
|
+
return CGRectIntegral(rect);
|
|
2138
|
+
}
|
|
1920
2139
|
@end
|
package/ios/config/InputConfig.h
CHANGED
|
@@ -88,4 +88,14 @@
|
|
|
88
88
|
- (NSRegularExpression *)parsedLinkRegex;
|
|
89
89
|
- (void)invalidateFonts;
|
|
90
90
|
- (NSNumber *)scaledPrimaryFontSize;
|
|
91
|
+
- (CGFloat)checkboxListBoxSize;
|
|
92
|
+
- (void)setCheckboxListBoxSize:(CGFloat)newValue;
|
|
93
|
+
- (CGFloat)checkboxListGapWidth;
|
|
94
|
+
- (void)setCheckboxListGapWidth:(CGFloat)newValue;
|
|
95
|
+
- (CGFloat)checkboxListMarginLeft;
|
|
96
|
+
- (void)setCheckboxListMarginLeft:(CGFloat)newValue;
|
|
97
|
+
- (UIColor *)checkboxListBoxColor;
|
|
98
|
+
- (void)setCheckboxListBoxColor:(UIColor *)newValue;
|
|
99
|
+
- (UIImage *)checkboxCheckedImage;
|
|
100
|
+
- (UIImage *)checkboxUncheckedImage;
|
|
91
101
|
@end
|
|
@@ -47,6 +47,12 @@
|
|
|
47
47
|
UIColor *_codeBlockBgColor;
|
|
48
48
|
LinkRegexConfig *_linkRegexConfig;
|
|
49
49
|
NSRegularExpression *_parsedLinkRegex;
|
|
50
|
+
CGFloat _checkboxListBoxSize;
|
|
51
|
+
CGFloat _checkboxListGapWidth;
|
|
52
|
+
CGFloat _checkboxListMarginLeft;
|
|
53
|
+
UIColor *_checkboxListBoxColor;
|
|
54
|
+
UIImage *_checkboxCheckedImage;
|
|
55
|
+
UIImage *_checkboxUncheckedImage;
|
|
50
56
|
}
|
|
51
57
|
|
|
52
58
|
- (instancetype)init {
|
|
@@ -101,6 +107,12 @@
|
|
|
101
107
|
copy->_codeBlockBorderRadius = _codeBlockBorderRadius;
|
|
102
108
|
copy->_linkRegexConfig = [_linkRegexConfig copy];
|
|
103
109
|
copy->_parsedLinkRegex = [_parsedLinkRegex copy];
|
|
110
|
+
copy->_checkboxListBoxSize = _checkboxListBoxSize;
|
|
111
|
+
copy->_checkboxListGapWidth = _checkboxListGapWidth;
|
|
112
|
+
copy->_checkboxListMarginLeft = _checkboxListMarginLeft;
|
|
113
|
+
copy->_checkboxListBoxColor = [_checkboxListBoxColor copy];
|
|
114
|
+
copy->_checkboxCheckedImage = _checkboxCheckedImage;
|
|
115
|
+
copy->_checkboxUncheckedImage = _checkboxUncheckedImage;
|
|
104
116
|
return copy;
|
|
105
117
|
}
|
|
106
118
|
|
|
@@ -527,4 +539,111 @@
|
|
|
527
539
|
return @(scaledSize);
|
|
528
540
|
}
|
|
529
541
|
|
|
542
|
+
- (CGFloat)checkboxListBoxSize {
|
|
543
|
+
return _checkboxListBoxSize;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
- (void)setCheckboxListBoxSize:(CGFloat)newValue {
|
|
547
|
+
if (_checkboxListBoxSize != newValue) {
|
|
548
|
+
_checkboxListBoxSize = newValue;
|
|
549
|
+
// Invalidate checkbox images because box size changed
|
|
550
|
+
_checkboxCheckedImage = nil;
|
|
551
|
+
_checkboxUncheckedImage = nil;
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
- (CGFloat)checkboxListGapWidth {
|
|
556
|
+
return _checkboxListGapWidth;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
- (void)setCheckboxListGapWidth:(CGFloat)newValue {
|
|
560
|
+
_checkboxListGapWidth = newValue;
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
- (CGFloat)checkboxListMarginLeft {
|
|
564
|
+
return _checkboxListMarginLeft;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
- (void)setCheckboxListMarginLeft:(CGFloat)newValue {
|
|
568
|
+
_checkboxListMarginLeft = newValue;
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
- (UIColor *)checkboxListBoxColor {
|
|
572
|
+
return _checkboxListBoxColor;
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
- (void)setCheckboxListBoxColor:(UIColor *)newValue {
|
|
576
|
+
if (_checkboxListBoxColor != newValue) {
|
|
577
|
+
_checkboxListBoxColor = newValue;
|
|
578
|
+
// Invalidate checkbox images because color changed
|
|
579
|
+
_checkboxCheckedImage = nil;
|
|
580
|
+
_checkboxUncheckedImage = nil;
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
- (UIImage *)checkboxCheckedImage {
|
|
585
|
+
if (!_checkboxCheckedImage) {
|
|
586
|
+
_checkboxCheckedImage = [self generateCheckboxImage:YES];
|
|
587
|
+
}
|
|
588
|
+
return _checkboxCheckedImage;
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
- (UIImage *)checkboxUncheckedImage {
|
|
592
|
+
if (!_checkboxUncheckedImage) {
|
|
593
|
+
_checkboxUncheckedImage = [self generateCheckboxImage:NO];
|
|
594
|
+
}
|
|
595
|
+
return _checkboxUncheckedImage;
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
- (UIImage *)generateCheckboxImage:(BOOL)isChecked {
|
|
599
|
+
CGFloat boxSize = self.checkboxListBoxSize;
|
|
600
|
+
UIColor *boxColor = self.checkboxListBoxColor ?: [UIColor blackColor];
|
|
601
|
+
|
|
602
|
+
UIGraphicsBeginImageContextWithOptions(CGSizeMake(boxSize, boxSize), NO, 0.0);
|
|
603
|
+
CGRect localRect = CGRectMake(0, 0, boxSize, boxSize);
|
|
604
|
+
CGFloat cornerRadius = boxSize * 0.15f;
|
|
605
|
+
CGFloat strokeWidth = boxSize * 0.1f;
|
|
606
|
+
CGRect insetRect =
|
|
607
|
+
CGRectInset(localRect, strokeWidth / 2.0, strokeWidth / 2.0);
|
|
608
|
+
|
|
609
|
+
// Draw Box
|
|
610
|
+
UIBezierPath *boxPath = [UIBezierPath bezierPathWithRoundedRect:insetRect
|
|
611
|
+
cornerRadius:cornerRadius];
|
|
612
|
+
[boxPath setLineWidth:strokeWidth];
|
|
613
|
+
|
|
614
|
+
if (isChecked) {
|
|
615
|
+
[[boxColor colorWithAlphaComponent:1.0] setFill];
|
|
616
|
+
[boxPath fill];
|
|
617
|
+
[[boxColor colorWithAlphaComponent:1.0] setStroke];
|
|
618
|
+
[boxPath stroke];
|
|
619
|
+
|
|
620
|
+
// Draw Checkmark
|
|
621
|
+
UIBezierPath *checkPath = [UIBezierPath bezierPath];
|
|
622
|
+
CGFloat startX = insetRect.origin.x + insetRect.size.width * 0.25;
|
|
623
|
+
CGFloat startY = insetRect.origin.y + insetRect.size.height * 0.5;
|
|
624
|
+
CGFloat midX = insetRect.origin.x + insetRect.size.width * 0.45;
|
|
625
|
+
CGFloat midY = insetRect.origin.y + insetRect.size.height * 0.65;
|
|
626
|
+
CGFloat endX = insetRect.origin.x + insetRect.size.width * 0.75;
|
|
627
|
+
CGFloat endY = insetRect.origin.y + insetRect.size.height * 0.35;
|
|
628
|
+
|
|
629
|
+
[checkPath moveToPoint:CGPointMake(startX, startY)];
|
|
630
|
+
[checkPath addLineToPoint:CGPointMake(midX, midY)];
|
|
631
|
+
[checkPath addLineToPoint:CGPointMake(endX, endY)];
|
|
632
|
+
|
|
633
|
+
[checkPath setLineWidth:strokeWidth * 1.5];
|
|
634
|
+
[[UIColor whiteColor] setStroke];
|
|
635
|
+
[checkPath setLineCapStyle:kCGLineCapRound];
|
|
636
|
+
[checkPath setLineJoinStyle:kCGLineJoinRound];
|
|
637
|
+
[checkPath stroke];
|
|
638
|
+
} else {
|
|
639
|
+
[[boxColor colorWithAlphaComponent:1.0] setStroke];
|
|
640
|
+
[boxPath stroke];
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
UIImage *result = UIGraphicsGetImageFromCurrentImageContext();
|
|
644
|
+
UIGraphicsEndImageContext();
|
|
645
|
+
|
|
646
|
+
return result;
|
|
647
|
+
}
|
|
648
|
+
|
|
530
649
|
@end
|