react-native-enriched 0.2.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -16
- package/android/build.gradle +77 -72
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedTextInputViewManagerDelegate.java +21 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedTextInputViewManagerInterface.java +7 -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/android/generated/jni/react/renderer/components/ReactNativeEnrichedSpec/EventEmitters.cpp +276 -0
- package/android/generated/jni/react/renderer/components/ReactNativeEnrichedSpec/EventEmitters.h +239 -0
- package/android/generated/jni/react/renderer/components/{RNEnrichedTextInputViewSpec → ReactNativeEnrichedSpec}/Props.cpp +10 -0
- package/android/generated/jni/react/renderer/components/{RNEnrichedTextInputViewSpec → ReactNativeEnrichedSpec}/Props.h +251 -0
- package/android/gradle.properties +5 -5
- package/android/lint.gradle +70 -0
- package/android/src/main/java/com/swmansion/enriched/{EnrichedTextInputViewPackage.kt → ReactNativeEnrichedPackage.kt} +4 -5
- package/android/src/main/java/com/swmansion/enriched/{utils → common}/AsyncDrawable.kt +50 -15
- package/android/src/main/java/com/swmansion/enriched/common/CheckboxDrawable.kt +81 -0
- package/android/src/main/java/com/swmansion/enriched/common/EnrichedConstants.kt +11 -0
- 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 +3 -2
- 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 +228 -160
- package/android/src/main/java/com/swmansion/enriched/common/parser/EnrichedSpanFactory.kt +79 -0
- package/android/src/main/java/com/swmansion/enriched/common/spans/EnrichedBlockQuoteSpan.kt +53 -0
- 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 +12 -14
- 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 +68 -51
- package/android/src/main/java/com/swmansion/enriched/common/spans/EnrichedInlineCodeSpan.kt +24 -0
- package/android/src/main/java/com/swmansion/enriched/common/spans/EnrichedItalicSpan.kt +12 -0
- package/android/src/main/java/com/swmansion/enriched/common/spans/EnrichedLinkSpan.kt +26 -0
- package/android/src/main/java/com/swmansion/enriched/common/spans/EnrichedMentionSpan.kt +35 -0
- package/android/src/main/java/com/swmansion/enriched/{spans → common/spans}/EnrichedOrderedListSpan.kt +21 -29
- 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 +13 -17
- package/android/src/main/java/com/swmansion/enriched/common/spans/interfaces/EnrichedBlockSpan.kt +5 -0
- package/android/src/main/java/com/swmansion/enriched/common/spans/interfaces/EnrichedHeadingSpan.kt +3 -0
- package/android/src/main/java/com/swmansion/enriched/common/spans/interfaces/EnrichedInlineSpan.kt +3 -0
- package/android/src/main/java/com/swmansion/enriched/common/spans/interfaces/EnrichedParagraphSpan.kt +5 -0
- 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 +2 -3
- package/android/src/main/java/com/swmansion/enriched/textinput/EnrichedTextInputConnectionWrapper.kt +140 -0
- 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} +322 -157
- package/android/src/main/java/com/swmansion/enriched/{EnrichedTextInputViewLayoutManager.kt → textinput/EnrichedTextInputViewLayoutManager.kt} +4 -2
- package/android/src/main/java/com/swmansion/enriched/{EnrichedTextInputViewManager.kt → textinput/EnrichedTextInputViewManager.kt} +182 -66
- package/android/src/main/java/com/swmansion/enriched/{MeasurementStore.kt → textinput/MeasurementStore.kt} +75 -25
- package/android/src/main/java/com/swmansion/enriched/{events → textinput/events}/MentionHandler.kt +22 -12
- package/android/src/main/java/com/swmansion/enriched/textinput/events/OnChangeHtmlEvent.kt +27 -0
- package/android/src/main/java/com/swmansion/enriched/{events → textinput/events}/OnChangeSelectionEvent.kt +11 -10
- package/android/src/main/java/com/swmansion/enriched/textinput/events/OnChangeStateEvent.kt +21 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/events/OnChangeTextEvent.kt +30 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/events/OnInputBlurEvent.kt +25 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/events/OnInputFocusEvent.kt +25 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/events/OnInputKeyPressEvent.kt +27 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/events/OnLinkDetectedEvent.kt +32 -0
- package/android/src/main/java/com/swmansion/enriched/{events → textinput/events}/OnMentionDetectedEvent.kt +11 -10
- package/android/src/main/java/com/swmansion/enriched/{events → textinput/events}/OnMentionEvent.kt +10 -9
- 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 +2 -3
- 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/textinput/spans/EnrichedSpans.kt +241 -0
- 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 +129 -57
- package/android/src/main/java/com/swmansion/enriched/{styles → textinput/styles}/InlineStyles.kt +30 -13
- package/android/src/main/java/com/swmansion/enriched/textinput/styles/ListStyles.kt +263 -0
- package/android/src/main/java/com/swmansion/enriched/{styles → textinput/styles}/ParagraphStyles.kt +94 -34
- package/android/src/main/java/com/swmansion/enriched/{styles → textinput/styles}/ParametrizedStyles.kt +143 -67
- package/android/src/main/java/com/swmansion/enriched/textinput/utils/EnrichedEditableFactory.kt +17 -0
- package/android/src/main/java/com/swmansion/enriched/{utils → textinput/utils}/EnrichedSelection.kt +84 -54
- package/android/src/main/java/com/swmansion/enriched/textinput/utils/EnrichedSpanState.kt +304 -0
- package/android/src/main/java/com/swmansion/enriched/{utils/Utils.kt → textinput/utils/EnrichedSpannable.kt} +22 -31
- package/android/src/main/java/com/swmansion/enriched/textinput/utils/EnrichedSpannableStringBuilder.kt +16 -0
- 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 +56 -24
- package/android/src/main/java/com/swmansion/enriched/{watchers → textinput/watchers}/EnrichedTextWatcher.kt +37 -14
- package/android/src/main/new_arch/CMakeLists.txt +7 -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/ReactNativeEnrichedSpec/conversions.h +46 -0
- package/ios/EnrichedTextInputView.h +2 -1
- package/ios/EnrichedTextInputView.mm +603 -60
- package/ios/config/InputConfig.h +28 -0
- package/ios/config/InputConfig.mm +237 -8
- package/ios/extensions/ImageExtension.h +35 -0
- package/ios/extensions/ImageExtension.mm +156 -0
- package/ios/{utils → extensions}/LayoutManagerExtension.mm +115 -95
- package/ios/generated/{RNEnrichedTextInputViewSpec → ReactNativeEnrichedSpec}/ComponentDescriptors.cpp +1 -1
- package/ios/generated/{RNEnrichedTextInputViewSpec → ReactNativeEnrichedSpec}/ComponentDescriptors.h +1 -1
- package/ios/generated/ReactNativeEnrichedSpec/EventEmitters.cpp +276 -0
- package/ios/generated/ReactNativeEnrichedSpec/EventEmitters.h +239 -0
- package/ios/generated/{RNEnrichedTextInputViewSpec → ReactNativeEnrichedSpec}/Props.cpp +10 -0
- package/ios/generated/{RNEnrichedTextInputViewSpec → ReactNativeEnrichedSpec}/Props.h +251 -0
- package/ios/generated/{RNEnrichedTextInputViewSpec → ReactNativeEnrichedSpec}/RCTComponentViewHelpers.h +95 -0
- package/ios/inputParser/InputParser.mm +218 -18
- package/ios/inputTextView/InputTextView.mm +118 -0
- package/ios/{attachments → interfaces}/ImageAttachment.h +1 -0
- package/ios/interfaces/ImageAttachment.mm +46 -0
- package/ios/interfaces/LinkRegexConfig.h +19 -0
- package/ios/interfaces/LinkRegexConfig.mm +37 -0
- package/ios/{utils → interfaces}/MentionStyleProps.mm +2 -2
- package/ios/{utils → interfaces}/StyleHeaders.h +22 -1
- package/ios/{utils → interfaces}/StyleTypeEnum.h +4 -0
- package/ios/internals/EnrichedTextInputViewState.cpp +6 -6
- package/ios/styles/BlockQuoteStyle.mm +5 -5
- package/ios/styles/BoldStyle.mm +21 -6
- package/ios/styles/CheckboxListStyle.mm +321 -0
- package/ios/styles/CodeBlockStyle.mm +5 -5
- 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 +20 -0
- package/ios/styles/H5Style.mm +20 -0
- package/ios/styles/H6Style.mm +20 -0
- package/ios/styles/HeadingStyleBase.mm +161 -72
- package/ios/styles/ImageStyle.mm +5 -5
- package/ios/styles/InlineCodeStyle.mm +30 -19
- package/ios/styles/ItalicStyle.mm +5 -5
- package/ios/styles/LinkStyle.mm +98 -40
- package/ios/styles/MentionStyle.mm +4 -4
- package/ios/styles/OrderedListStyle.mm +5 -5
- package/ios/styles/StrikethroughStyle.mm +5 -5
- package/ios/styles/UnderlineStyle.mm +5 -5
- package/ios/styles/UnorderedListStyle.mm +5 -5
- package/ios/utils/CheckboxHitTestUtils.h +10 -0
- package/ios/utils/CheckboxHitTestUtils.mm +123 -0
- package/ios/utils/ParagraphAttributesUtils.h +4 -0
- package/ios/utils/ParagraphAttributesUtils.mm +142 -45
- package/ios/utils/ParagraphsUtils.mm +4 -4
- 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 +57 -11
- package/lib/module/EnrichedTextInput.js.map +1 -1
- package/lib/module/{EnrichedTextInputNativeComponent.ts → spec/EnrichedTextInputNativeComponent.ts} +175 -18
- package/lib/module/types.js +4 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/{normalizeHtmlStyle.js → utils/normalizeHtmlStyle.js} +18 -0
- package/lib/module/utils/normalizeHtmlStyle.js.map +1 -0
- package/lib/module/utils/nullthrows.js +9 -0
- package/lib/module/utils/nullthrows.js.map +1 -0
- package/lib/module/utils/regexParser.js +46 -0
- package/lib/module/utils/regexParser.js.map +1 -0
- package/lib/typescript/src/EnrichedTextInput.d.ts +20 -51
- 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} +154 -18
- 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 +4 -0
- package/lib/typescript/src/utils/normalizeHtmlStyle.d.ts.map +1 -0
- 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 +3 -0
- package/lib/typescript/src/utils/regexParser.d.ts.map +1 -0
- package/package.json +13 -9
- package/src/EnrichedTextInput.tsx +88 -63
- package/src/index.tsx +5 -1
- package/src/{EnrichedTextInputNativeComponent.ts → spec/EnrichedTextInputNativeComponent.ts} +175 -18
- package/src/types.ts +59 -0
- package/src/{normalizeHtmlStyle.ts → utils/normalizeHtmlStyle.ts} +20 -5
- package/src/utils/nullthrows.ts +7 -0
- package/src/utils/regexParser.ts +56 -0
- package/android/generated/jni/react/renderer/components/RNEnrichedTextInputViewSpec/EventEmitters.cpp +0 -128
- package/android/generated/jni/react/renderer/components/RNEnrichedTextInputViewSpec/EventEmitters.h +0 -102
- package/android/src/main/java/com/swmansion/enriched/events/OnChangeHtmlEvent.kt +0 -28
- package/android/src/main/java/com/swmansion/enriched/events/OnChangeStateEvent.kt +0 -24
- package/android/src/main/java/com/swmansion/enriched/events/OnChangeTextEvent.kt +0 -30
- package/android/src/main/java/com/swmansion/enriched/events/OnInputBlurEvent.kt +0 -27
- package/android/src/main/java/com/swmansion/enriched/events/OnInputFocusEvent.kt +0 -27
- package/android/src/main/java/com/swmansion/enriched/events/OnLinkDetectedEvent.kt +0 -30
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedBlockQuoteSpan.kt +0 -44
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedBoldSpan.kt +0 -16
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedH1Span.kt +0 -23
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedH2Span.kt +0 -23
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedH3Span.kt +0 -23
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedInlineCodeSpan.kt +0 -27
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedItalicSpan.kt +0 -15
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedLinkSpan.kt +0 -30
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedMentionSpan.kt +0 -42
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedSpans.kt +0 -136
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedStrikeThroughSpan.kt +0 -14
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedUnderlineSpan.kt +0 -14
- package/android/src/main/java/com/swmansion/enriched/spans/interfaces/EnrichedBlockSpan.kt +0 -4
- package/android/src/main/java/com/swmansion/enriched/spans/interfaces/EnrichedHeadingSpan.kt +0 -4
- package/android/src/main/java/com/swmansion/enriched/spans/interfaces/EnrichedInlineSpan.kt +0 -4
- package/android/src/main/java/com/swmansion/enriched/spans/interfaces/EnrichedParagraphSpan.kt +0 -4
- package/android/src/main/java/com/swmansion/enriched/spans/interfaces/EnrichedSpan.kt +0 -8
- package/android/src/main/java/com/swmansion/enriched/styles/ListStyles.kt +0 -172
- package/android/src/main/java/com/swmansion/enriched/utils/EnrichedSpanState.kt +0 -204
- package/android/src/main/new_arch/RNEnrichedTextInputViewSpec.cpp +0 -22
- package/android/src/main/new_arch/RNEnrichedTextInputViewSpec.h +0 -26
- package/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/conversions.h +0 -26
- package/ios/attachments/ImageAttachment.mm +0 -34
- package/ios/generated/RNEnrichedTextInputViewSpec/EventEmitters.cpp +0 -128
- package/ios/generated/RNEnrichedTextInputViewSpec/EventEmitters.h +0 -102
- package/lib/module/normalizeHtmlStyle.js.map +0 -1
- package/lib/typescript/src/EnrichedTextInputNativeComponent.d.ts.map +0 -1
- package/lib/typescript/src/normalizeHtmlStyle.d.ts +0 -4
- package/lib/typescript/src/normalizeHtmlStyle.d.ts.map +0 -1
- /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/{utils → extensions}/ColorExtension.h +0 -0
- /package/ios/{utils → extensions}/ColorExtension.mm +0 -0
- /package/ios/{utils → extensions}/FontExtension.h +0 -0
- /package/ios/{utils → extensions}/FontExtension.mm +0 -0
- /package/ios/{utils → extensions}/LayoutManagerExtension.h +0 -0
- /package/ios/{utils → extensions}/StringExtension.h +0 -0
- /package/ios/{utils → extensions}/StringExtension.mm +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
- /package/ios/{utils → interfaces}/BaseStyleProtocol.h +0 -0
- /package/ios/{utils → interfaces}/ImageData.h +0 -0
- /package/ios/{utils → interfaces}/ImageData.mm +0 -0
- /package/ios/{utils → interfaces}/LinkData.h +0 -0
- /package/ios/{utils → interfaces}/LinkData.mm +0 -0
- /package/ios/{attachments → interfaces}/MediaAttachment.h +0 -0
- /package/ios/{attachments → interfaces}/MediaAttachment.mm +0 -0
- /package/ios/{utils → interfaces}/MentionParams.h +0 -0
- /package/ios/{utils → interfaces}/MentionParams.mm +0 -0
- /package/ios/{utils → interfaces}/MentionStyleProps.h +0 -0
- /package/ios/{utils → interfaces}/StylePair.h +0 -0
- /package/ios/{utils → interfaces}/StylePair.mm +0 -0
- /package/ios/{utils → interfaces}/TextDecorationLineEnum.h +0 -0
- /package/ios/{utils → interfaces}/TextDecorationLineEnum.mm +0 -0
|
@@ -18,8 +18,10 @@ import EnrichedTextInputNativeComponent, {
|
|
|
18
18
|
type OnMentionDetected,
|
|
19
19
|
type OnMentionDetectedInternal,
|
|
20
20
|
type OnRequestHtmlResultEvent,
|
|
21
|
-
type
|
|
22
|
-
|
|
21
|
+
type OnChangeStateDeprecatedEvent,
|
|
22
|
+
type OnKeyPressEvent,
|
|
23
|
+
type OnPasteImagesEvent,
|
|
24
|
+
} from './spec/EnrichedTextInputNativeComponent';
|
|
23
25
|
import type {
|
|
24
26
|
ColorValue,
|
|
25
27
|
HostInstance,
|
|
@@ -28,17 +30,25 @@ import type {
|
|
|
28
30
|
MeasureOnSuccessCallback,
|
|
29
31
|
NativeMethods,
|
|
30
32
|
NativeSyntheticEvent,
|
|
33
|
+
TargetedEvent,
|
|
31
34
|
TextStyle,
|
|
32
35
|
ViewProps,
|
|
33
36
|
ViewStyle,
|
|
34
37
|
} from 'react-native';
|
|
35
|
-
import { normalizeHtmlStyle } from './normalizeHtmlStyle';
|
|
38
|
+
import { normalizeHtmlStyle } from './utils/normalizeHtmlStyle';
|
|
39
|
+
import { toNativeRegexConfig } from './utils/regexParser';
|
|
40
|
+
import { nullthrows } from './utils/nullthrows';
|
|
41
|
+
import type { HtmlStyle } from './types';
|
|
42
|
+
|
|
43
|
+
export type FocusEvent = NativeSyntheticEvent<TargetedEvent>;
|
|
44
|
+
export type BlurEvent = NativeSyntheticEvent<TargetedEvent>;
|
|
36
45
|
|
|
37
46
|
export interface EnrichedTextInputInstance extends NativeMethods {
|
|
38
47
|
// General commands
|
|
39
48
|
focus: () => void;
|
|
40
49
|
blur: () => void;
|
|
41
50
|
setValue: (value: string) => void;
|
|
51
|
+
setSelection: (start: number, end: number) => void;
|
|
42
52
|
getHTML: () => Promise<string>;
|
|
43
53
|
|
|
44
54
|
// Text formatting commands
|
|
@@ -50,10 +60,14 @@ export interface EnrichedTextInputInstance extends NativeMethods {
|
|
|
50
60
|
toggleH1: () => void;
|
|
51
61
|
toggleH2: () => void;
|
|
52
62
|
toggleH3: () => void;
|
|
63
|
+
toggleH4: () => void;
|
|
64
|
+
toggleH5: () => void;
|
|
65
|
+
toggleH6: () => void;
|
|
53
66
|
toggleCodeBlock: () => void;
|
|
54
67
|
toggleBlockQuote: () => void;
|
|
55
68
|
toggleOrderedList: () => void;
|
|
56
69
|
toggleUnorderedList: () => void;
|
|
70
|
+
toggleCheckboxList: (checked: boolean) => void;
|
|
57
71
|
setLink: (start: number, end: number, text: string, url: string) => void;
|
|
58
72
|
setImage: (src: string, width: number, height: number) => void;
|
|
59
73
|
startMention: (indicator: string) => void;
|
|
@@ -69,53 +83,6 @@ export interface OnChangeMentionEvent {
|
|
|
69
83
|
text: string;
|
|
70
84
|
}
|
|
71
85
|
|
|
72
|
-
export interface HtmlStyle {
|
|
73
|
-
h1?: {
|
|
74
|
-
fontSize?: number;
|
|
75
|
-
bold?: boolean;
|
|
76
|
-
};
|
|
77
|
-
h2?: {
|
|
78
|
-
fontSize?: number;
|
|
79
|
-
bold?: boolean;
|
|
80
|
-
};
|
|
81
|
-
h3?: {
|
|
82
|
-
fontSize?: number;
|
|
83
|
-
bold?: boolean;
|
|
84
|
-
};
|
|
85
|
-
blockquote?: {
|
|
86
|
-
borderColor?: ColorValue;
|
|
87
|
-
borderWidth?: number;
|
|
88
|
-
gapWidth?: number;
|
|
89
|
-
color?: ColorValue;
|
|
90
|
-
};
|
|
91
|
-
codeblock?: {
|
|
92
|
-
color?: ColorValue;
|
|
93
|
-
borderRadius?: number;
|
|
94
|
-
backgroundColor?: ColorValue;
|
|
95
|
-
};
|
|
96
|
-
code?: {
|
|
97
|
-
color?: ColorValue;
|
|
98
|
-
backgroundColor?: ColorValue;
|
|
99
|
-
};
|
|
100
|
-
a?: {
|
|
101
|
-
color?: ColorValue;
|
|
102
|
-
textDecorationLine?: 'underline' | 'none';
|
|
103
|
-
};
|
|
104
|
-
mention?: Record<string, MentionStyleProperties> | MentionStyleProperties;
|
|
105
|
-
ol?: {
|
|
106
|
-
gapWidth?: number;
|
|
107
|
-
marginLeft?: number;
|
|
108
|
-
markerFontWeight?: TextStyle['fontWeight'];
|
|
109
|
-
markerColor?: ColorValue;
|
|
110
|
-
};
|
|
111
|
-
ul?: {
|
|
112
|
-
bulletColor?: ColorValue;
|
|
113
|
-
bulletSize?: number;
|
|
114
|
-
marginLeft?: number;
|
|
115
|
-
gapWidth?: number;
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
|
|
119
86
|
export interface EnrichedTextInputProps extends Omit<ViewProps, 'children'> {
|
|
120
87
|
ref?: RefObject<EnrichedTextInputInstance | null>;
|
|
121
88
|
autoFocus?: boolean;
|
|
@@ -130,17 +97,26 @@ export interface EnrichedTextInputProps extends Omit<ViewProps, 'children'> {
|
|
|
130
97
|
htmlStyle?: HtmlStyle;
|
|
131
98
|
style?: ViewStyle | TextStyle;
|
|
132
99
|
scrollEnabled?: boolean;
|
|
133
|
-
|
|
134
|
-
|
|
100
|
+
linkRegex?: RegExp | null;
|
|
101
|
+
onFocus?: (e: FocusEvent) => void;
|
|
102
|
+
onBlur?: (e: BlurEvent) => void;
|
|
135
103
|
onChangeText?: (e: NativeSyntheticEvent<OnChangeTextEvent>) => void;
|
|
136
104
|
onChangeHtml?: (e: NativeSyntheticEvent<OnChangeHtmlEvent>) => void;
|
|
137
105
|
onChangeState?: (e: NativeSyntheticEvent<OnChangeStateEvent>) => void;
|
|
106
|
+
/**
|
|
107
|
+
* @deprecated Use onChangeState prop instead.
|
|
108
|
+
*/
|
|
109
|
+
onChangeStateDeprecated?: (
|
|
110
|
+
e: NativeSyntheticEvent<OnChangeStateDeprecatedEvent>
|
|
111
|
+
) => void;
|
|
138
112
|
onLinkDetected?: (e: OnLinkDetected) => void;
|
|
139
113
|
onMentionDetected?: (e: OnMentionDetected) => void;
|
|
140
114
|
onStartMention?: (indicator: string) => void;
|
|
141
115
|
onChangeMention?: (e: OnChangeMentionEvent) => void;
|
|
142
116
|
onEndMention?: (indicator: string) => void;
|
|
143
117
|
onChangeSelection?: (e: NativeSyntheticEvent<OnChangeSelectionEvent>) => void;
|
|
118
|
+
onKeyPress?: (e: NativeSyntheticEvent<OnKeyPressEvent>) => void;
|
|
119
|
+
onPasteImages?: (e: NativeSyntheticEvent<OnPasteImagesEvent>) => void;
|
|
144
120
|
/**
|
|
145
121
|
* If true, Android will use experimental synchronous events.
|
|
146
122
|
* This will prevent from input flickering when updating component size.
|
|
@@ -151,15 +127,7 @@ export interface EnrichedTextInputProps extends Omit<ViewProps, 'children'> {
|
|
|
151
127
|
androidExperimentalSynchronousEvents?: boolean;
|
|
152
128
|
}
|
|
153
129
|
|
|
154
|
-
const
|
|
155
|
-
if (value == null) {
|
|
156
|
-
throw new Error('Unexpected null or undefined value');
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
return value;
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
const warnAboutMissconfiguredMentions = (indicator: string) => {
|
|
130
|
+
const warnMentionIndicators = (indicator: string) => {
|
|
163
131
|
console.warn(
|
|
164
132
|
`Looks like you are trying to set a "${indicator}" but it's not in the mentionIndicators prop`
|
|
165
133
|
);
|
|
@@ -185,17 +153,20 @@ export const EnrichedTextInput = ({
|
|
|
185
153
|
style,
|
|
186
154
|
autoCapitalize = 'sentences',
|
|
187
155
|
htmlStyle = {},
|
|
156
|
+
linkRegex: _linkRegex,
|
|
188
157
|
onFocus,
|
|
189
158
|
onBlur,
|
|
190
159
|
onChangeText,
|
|
191
160
|
onChangeHtml,
|
|
192
161
|
onChangeState,
|
|
162
|
+
onChangeStateDeprecated,
|
|
193
163
|
onLinkDetected,
|
|
194
164
|
onMentionDetected,
|
|
195
165
|
onStartMention,
|
|
196
166
|
onChangeMention,
|
|
197
167
|
onEndMention,
|
|
198
168
|
onChangeSelection,
|
|
169
|
+
onKeyPress,
|
|
199
170
|
androidExperimentalSynchronousEvents = false,
|
|
200
171
|
scrollEnabled = true,
|
|
201
172
|
...rest
|
|
@@ -220,6 +191,11 @@ export const EnrichedTextInput = ({
|
|
|
220
191
|
[htmlStyle, mentionIndicators]
|
|
221
192
|
);
|
|
222
193
|
|
|
194
|
+
const linkRegex = useMemo(
|
|
195
|
+
() => toNativeRegexConfig(_linkRegex),
|
|
196
|
+
[_linkRegex]
|
|
197
|
+
);
|
|
198
|
+
|
|
223
199
|
useImperativeHandle(ref, () => ({
|
|
224
200
|
measureInWindow: (callback: MeasureInWindowOnSuccessCallback) => {
|
|
225
201
|
nullthrows(nativeRef.current).measureInWindow(callback);
|
|
@@ -281,6 +257,15 @@ export const EnrichedTextInput = ({
|
|
|
281
257
|
toggleH3: () => {
|
|
282
258
|
Commands.toggleH3(nullthrows(nativeRef.current));
|
|
283
259
|
},
|
|
260
|
+
toggleH4: () => {
|
|
261
|
+
Commands.toggleH4(nullthrows(nativeRef.current));
|
|
262
|
+
},
|
|
263
|
+
toggleH5: () => {
|
|
264
|
+
Commands.toggleH5(nullthrows(nativeRef.current));
|
|
265
|
+
},
|
|
266
|
+
toggleH6: () => {
|
|
267
|
+
Commands.toggleH6(nullthrows(nativeRef.current));
|
|
268
|
+
},
|
|
284
269
|
toggleCodeBlock: () => {
|
|
285
270
|
Commands.toggleCodeBlock(nullthrows(nativeRef.current));
|
|
286
271
|
},
|
|
@@ -293,6 +278,9 @@ export const EnrichedTextInput = ({
|
|
|
293
278
|
toggleUnorderedList: () => {
|
|
294
279
|
Commands.toggleUnorderedList(nullthrows(nativeRef.current));
|
|
295
280
|
},
|
|
281
|
+
toggleCheckboxList: (checked: boolean) => {
|
|
282
|
+
Commands.toggleCheckboxList(nullthrows(nativeRef.current), checked);
|
|
283
|
+
},
|
|
296
284
|
setLink: (start: number, end: number, text: string, url: string) => {
|
|
297
285
|
Commands.addLink(nullthrows(nativeRef.current), start, end, text, url);
|
|
298
286
|
},
|
|
@@ -316,11 +304,14 @@ export const EnrichedTextInput = ({
|
|
|
316
304
|
},
|
|
317
305
|
startMention: (indicator: string) => {
|
|
318
306
|
if (!mentionIndicators?.includes(indicator)) {
|
|
319
|
-
|
|
307
|
+
warnMentionIndicators(indicator);
|
|
320
308
|
}
|
|
321
309
|
|
|
322
310
|
Commands.startMention(nullthrows(nativeRef.current), indicator);
|
|
323
311
|
},
|
|
312
|
+
setSelection: (start: number, end: number) => {
|
|
313
|
+
Commands.setSelection(nullthrows(nativeRef.current), start, end);
|
|
314
|
+
},
|
|
324
315
|
}));
|
|
325
316
|
|
|
326
317
|
const handleMentionEvent = (e: NativeSyntheticEvent<OnMentionEvent>) => {
|
|
@@ -367,6 +358,37 @@ export const EnrichedTextInput = ({
|
|
|
367
358
|
pendingHtmlRequests.current.delete(requestId);
|
|
368
359
|
};
|
|
369
360
|
|
|
361
|
+
const onChangeStateWithDeprecated = (
|
|
362
|
+
e: NativeSyntheticEvent<OnChangeStateEvent>
|
|
363
|
+
) => {
|
|
364
|
+
onChangeState?.(e);
|
|
365
|
+
// TODO: remove in 0.5.0 release
|
|
366
|
+
onChangeStateDeprecated?.({
|
|
367
|
+
...e,
|
|
368
|
+
nativeEvent: {
|
|
369
|
+
isBold: e.nativeEvent.bold.isActive,
|
|
370
|
+
isItalic: e.nativeEvent.italic.isActive,
|
|
371
|
+
isUnderline: e.nativeEvent.underline.isActive,
|
|
372
|
+
isStrikeThrough: e.nativeEvent.strikeThrough.isActive,
|
|
373
|
+
isInlineCode: e.nativeEvent.inlineCode.isActive,
|
|
374
|
+
isH1: e.nativeEvent.h1.isActive,
|
|
375
|
+
isH2: e.nativeEvent.h2.isActive,
|
|
376
|
+
isH3: e.nativeEvent.h3.isActive,
|
|
377
|
+
isH4: e.nativeEvent.h4.isActive,
|
|
378
|
+
isH5: e.nativeEvent.h5.isActive,
|
|
379
|
+
isH6: e.nativeEvent.h6.isActive,
|
|
380
|
+
isCodeBlock: e.nativeEvent.codeBlock.isActive,
|
|
381
|
+
isBlockQuote: e.nativeEvent.blockQuote.isActive,
|
|
382
|
+
isOrderedList: e.nativeEvent.orderedList.isActive,
|
|
383
|
+
isUnorderedList: e.nativeEvent.unorderedList.isActive,
|
|
384
|
+
isCheckboxList: e.nativeEvent.checkboxList.isActive,
|
|
385
|
+
isLink: e.nativeEvent.link.isActive,
|
|
386
|
+
isImage: e.nativeEvent.image.isActive,
|
|
387
|
+
isMention: e.nativeEvent.mention.isActive,
|
|
388
|
+
},
|
|
389
|
+
});
|
|
390
|
+
};
|
|
391
|
+
|
|
370
392
|
return (
|
|
371
393
|
<EnrichedTextInputNativeComponent
|
|
372
394
|
ref={nativeRef}
|
|
@@ -381,17 +403,20 @@ export const EnrichedTextInput = ({
|
|
|
381
403
|
style={style}
|
|
382
404
|
autoCapitalize={autoCapitalize}
|
|
383
405
|
htmlStyle={normalizedHtmlStyle}
|
|
406
|
+
linkRegex={linkRegex}
|
|
384
407
|
onInputFocus={onFocus}
|
|
385
408
|
onInputBlur={onBlur}
|
|
386
409
|
onChangeText={onChangeText}
|
|
387
410
|
onChangeHtml={onChangeHtml}
|
|
388
411
|
isOnChangeHtmlSet={onChangeHtml !== undefined}
|
|
389
|
-
|
|
412
|
+
isOnChangeTextSet={onChangeText !== undefined}
|
|
413
|
+
onChangeState={onChangeStateWithDeprecated}
|
|
390
414
|
onLinkDetected={handleLinkDetected}
|
|
391
415
|
onMentionDetected={handleMentionDetected}
|
|
392
416
|
onMention={handleMentionEvent}
|
|
393
417
|
onChangeSelection={onChangeSelection}
|
|
394
418
|
onRequestHtmlResult={handleRequestHtmlResult}
|
|
419
|
+
onInputKeyPress={onKeyPress}
|
|
395
420
|
androidExperimentalSynchronousEvents={
|
|
396
421
|
androidExperimentalSynchronousEvents
|
|
397
422
|
}
|
package/src/index.tsx
CHANGED
|
@@ -3,7 +3,11 @@ export type {
|
|
|
3
3
|
OnChangeTextEvent,
|
|
4
4
|
OnChangeHtmlEvent,
|
|
5
5
|
OnChangeStateEvent,
|
|
6
|
+
OnChangeStateDeprecatedEvent,
|
|
6
7
|
OnLinkDetected,
|
|
7
8
|
OnMentionDetected,
|
|
8
9
|
OnChangeSelectionEvent,
|
|
9
|
-
|
|
10
|
+
OnKeyPressEvent,
|
|
11
|
+
OnPasteImagesEvent,
|
|
12
|
+
} from './spec/EnrichedTextInputNativeComponent';
|
|
13
|
+
export type { HtmlStyle, MentionStyleProperties } from './types';
|
package/src/{EnrichedTextInputNativeComponent.ts → spec/EnrichedTextInputNativeComponent.ts}
RENAMED
|
@@ -8,6 +8,16 @@ import type {
|
|
|
8
8
|
import type { ColorValue, HostComponent, ViewProps } from 'react-native';
|
|
9
9
|
import React from 'react';
|
|
10
10
|
|
|
11
|
+
export interface LinkNativeRegex {
|
|
12
|
+
pattern: string;
|
|
13
|
+
caseInsensitive: boolean;
|
|
14
|
+
dotAll: boolean;
|
|
15
|
+
// Link detection will be disabled
|
|
16
|
+
isDisabled: boolean;
|
|
17
|
+
// Use default native link regex
|
|
18
|
+
isDefault: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
11
21
|
export interface OnChangeTextEvent {
|
|
12
22
|
value: string;
|
|
13
23
|
}
|
|
@@ -17,6 +27,104 @@ export interface OnChangeHtmlEvent {
|
|
|
17
27
|
}
|
|
18
28
|
|
|
19
29
|
export interface OnChangeStateEvent {
|
|
30
|
+
bold: {
|
|
31
|
+
isActive: boolean;
|
|
32
|
+
isConflicting: boolean;
|
|
33
|
+
isBlocking: boolean;
|
|
34
|
+
};
|
|
35
|
+
italic: {
|
|
36
|
+
isActive: boolean;
|
|
37
|
+
isConflicting: boolean;
|
|
38
|
+
isBlocking: boolean;
|
|
39
|
+
};
|
|
40
|
+
underline: {
|
|
41
|
+
isActive: boolean;
|
|
42
|
+
isConflicting: boolean;
|
|
43
|
+
isBlocking: boolean;
|
|
44
|
+
};
|
|
45
|
+
strikeThrough: {
|
|
46
|
+
isActive: boolean;
|
|
47
|
+
isConflicting: boolean;
|
|
48
|
+
isBlocking: boolean;
|
|
49
|
+
};
|
|
50
|
+
inlineCode: {
|
|
51
|
+
isActive: boolean;
|
|
52
|
+
isConflicting: boolean;
|
|
53
|
+
isBlocking: boolean;
|
|
54
|
+
};
|
|
55
|
+
h1: {
|
|
56
|
+
isActive: boolean;
|
|
57
|
+
isConflicting: boolean;
|
|
58
|
+
isBlocking: boolean;
|
|
59
|
+
};
|
|
60
|
+
h2: {
|
|
61
|
+
isActive: boolean;
|
|
62
|
+
isConflicting: boolean;
|
|
63
|
+
isBlocking: boolean;
|
|
64
|
+
};
|
|
65
|
+
h3: {
|
|
66
|
+
isActive: boolean;
|
|
67
|
+
isConflicting: boolean;
|
|
68
|
+
isBlocking: boolean;
|
|
69
|
+
};
|
|
70
|
+
h4: {
|
|
71
|
+
isActive: boolean;
|
|
72
|
+
isConflicting: boolean;
|
|
73
|
+
isBlocking: boolean;
|
|
74
|
+
};
|
|
75
|
+
h5: {
|
|
76
|
+
isActive: boolean;
|
|
77
|
+
isConflicting: boolean;
|
|
78
|
+
isBlocking: boolean;
|
|
79
|
+
};
|
|
80
|
+
h6: {
|
|
81
|
+
isActive: boolean;
|
|
82
|
+
isConflicting: boolean;
|
|
83
|
+
isBlocking: boolean;
|
|
84
|
+
};
|
|
85
|
+
codeBlock: {
|
|
86
|
+
isActive: boolean;
|
|
87
|
+
isConflicting: boolean;
|
|
88
|
+
isBlocking: boolean;
|
|
89
|
+
};
|
|
90
|
+
blockQuote: {
|
|
91
|
+
isActive: boolean;
|
|
92
|
+
isConflicting: boolean;
|
|
93
|
+
isBlocking: boolean;
|
|
94
|
+
};
|
|
95
|
+
orderedList: {
|
|
96
|
+
isActive: boolean;
|
|
97
|
+
isConflicting: boolean;
|
|
98
|
+
isBlocking: boolean;
|
|
99
|
+
};
|
|
100
|
+
unorderedList: {
|
|
101
|
+
isActive: boolean;
|
|
102
|
+
isConflicting: boolean;
|
|
103
|
+
isBlocking: boolean;
|
|
104
|
+
};
|
|
105
|
+
link: {
|
|
106
|
+
isActive: boolean;
|
|
107
|
+
isConflicting: boolean;
|
|
108
|
+
isBlocking: boolean;
|
|
109
|
+
};
|
|
110
|
+
image: {
|
|
111
|
+
isActive: boolean;
|
|
112
|
+
isConflicting: boolean;
|
|
113
|
+
isBlocking: boolean;
|
|
114
|
+
};
|
|
115
|
+
mention: {
|
|
116
|
+
isActive: boolean;
|
|
117
|
+
isConflicting: boolean;
|
|
118
|
+
isBlocking: boolean;
|
|
119
|
+
};
|
|
120
|
+
checkboxList: {
|
|
121
|
+
isActive: boolean;
|
|
122
|
+
isConflicting: boolean;
|
|
123
|
+
isBlocking: boolean;
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export interface OnChangeStateDeprecatedEvent {
|
|
20
128
|
isBold: boolean;
|
|
21
129
|
isItalic: boolean;
|
|
22
130
|
isUnderline: boolean;
|
|
@@ -25,10 +133,14 @@ export interface OnChangeStateEvent {
|
|
|
25
133
|
isH1: boolean;
|
|
26
134
|
isH2: boolean;
|
|
27
135
|
isH3: boolean;
|
|
136
|
+
isH4: boolean;
|
|
137
|
+
isH5: boolean;
|
|
138
|
+
isH6: boolean;
|
|
28
139
|
isCodeBlock: boolean;
|
|
29
140
|
isBlockQuote: boolean;
|
|
30
141
|
isOrderedList: boolean;
|
|
31
142
|
isUnorderedList: boolean;
|
|
143
|
+
isCheckboxList: boolean;
|
|
32
144
|
isLink: boolean;
|
|
33
145
|
isImage: boolean;
|
|
34
146
|
isMention: boolean;
|
|
@@ -69,25 +181,42 @@ export interface OnRequestHtmlResultEvent {
|
|
|
69
181
|
html: UnsafeMixed;
|
|
70
182
|
}
|
|
71
183
|
|
|
72
|
-
export interface
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
184
|
+
export interface OnKeyPressEvent {
|
|
185
|
+
key: string;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
interface TargetedEvent {
|
|
189
|
+
target: Int32;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export interface PastedImage {
|
|
193
|
+
uri: string;
|
|
194
|
+
type: string;
|
|
195
|
+
width: Float;
|
|
196
|
+
height: Float;
|
|
76
197
|
}
|
|
77
198
|
|
|
199
|
+
export interface OnPasteImagesEvent {
|
|
200
|
+
images: {
|
|
201
|
+
uri: string;
|
|
202
|
+
type: string;
|
|
203
|
+
width: Float;
|
|
204
|
+
height: Float;
|
|
205
|
+
}[];
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
type Heading = {
|
|
209
|
+
fontSize?: Float;
|
|
210
|
+
bold?: boolean;
|
|
211
|
+
};
|
|
212
|
+
|
|
78
213
|
export interface HtmlStyleInternal {
|
|
79
|
-
h1?:
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
bold?: boolean;
|
|
86
|
-
};
|
|
87
|
-
h3?: {
|
|
88
|
-
fontSize?: Float;
|
|
89
|
-
bold?: boolean;
|
|
90
|
-
};
|
|
214
|
+
h1?: Heading;
|
|
215
|
+
h2?: Heading;
|
|
216
|
+
h3?: Heading;
|
|
217
|
+
h4?: Heading;
|
|
218
|
+
h5?: Heading;
|
|
219
|
+
h6?: Heading;
|
|
91
220
|
blockquote?: {
|
|
92
221
|
borderColor?: ColorValue;
|
|
93
222
|
borderWidth?: Float;
|
|
@@ -122,6 +251,12 @@ export interface HtmlStyleInternal {
|
|
|
122
251
|
marginLeft?: Float;
|
|
123
252
|
gapWidth?: Float;
|
|
124
253
|
};
|
|
254
|
+
ulCheckbox?: {
|
|
255
|
+
gapWidth?: Float;
|
|
256
|
+
boxSize?: Float;
|
|
257
|
+
marginLeft?: Float;
|
|
258
|
+
boxColor?: ColorValue;
|
|
259
|
+
};
|
|
125
260
|
}
|
|
126
261
|
|
|
127
262
|
export interface NativeProps extends ViewProps {
|
|
@@ -137,10 +272,11 @@ export interface NativeProps extends ViewProps {
|
|
|
137
272
|
autoCapitalize?: string;
|
|
138
273
|
htmlStyle?: HtmlStyleInternal;
|
|
139
274
|
scrollEnabled?: boolean;
|
|
275
|
+
linkRegex?: LinkNativeRegex;
|
|
140
276
|
|
|
141
277
|
// event callbacks
|
|
142
|
-
onInputFocus?: DirectEventHandler<
|
|
143
|
-
onInputBlur?: DirectEventHandler<
|
|
278
|
+
onInputFocus?: DirectEventHandler<TargetedEvent>;
|
|
279
|
+
onInputBlur?: DirectEventHandler<TargetedEvent>;
|
|
144
280
|
onChangeText?: DirectEventHandler<OnChangeTextEvent>;
|
|
145
281
|
onChangeHtml?: DirectEventHandler<OnChangeHtmlEvent>;
|
|
146
282
|
onChangeState?: DirectEventHandler<OnChangeStateEvent>;
|
|
@@ -149,6 +285,8 @@ export interface NativeProps extends ViewProps {
|
|
|
149
285
|
onMention?: DirectEventHandler<OnMentionEvent>;
|
|
150
286
|
onChangeSelection?: DirectEventHandler<OnChangeSelectionEvent>;
|
|
151
287
|
onRequestHtmlResult?: DirectEventHandler<OnRequestHtmlResultEvent>;
|
|
288
|
+
onInputKeyPress?: DirectEventHandler<OnKeyPressEvent>;
|
|
289
|
+
onPasteImages?: DirectEventHandler<OnPasteImagesEvent>;
|
|
152
290
|
|
|
153
291
|
// Style related props - used for generating proper setters in component's manager
|
|
154
292
|
// These should not be passed as regular props
|
|
@@ -160,6 +298,8 @@ export interface NativeProps extends ViewProps {
|
|
|
160
298
|
|
|
161
299
|
// Used for onChangeHtml event performance optimization
|
|
162
300
|
isOnChangeHtmlSet: boolean;
|
|
301
|
+
// Used for onChangeText event performance optimization
|
|
302
|
+
isOnChangeTextSet: boolean;
|
|
163
303
|
|
|
164
304
|
// Experimental
|
|
165
305
|
androidExperimentalSynchronousEvents: boolean;
|
|
@@ -172,6 +312,11 @@ interface NativeCommands {
|
|
|
172
312
|
focus: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
173
313
|
blur: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
174
314
|
setValue: (viewRef: React.ElementRef<ComponentType>, text: string) => void;
|
|
315
|
+
setSelection: (
|
|
316
|
+
viewRef: React.ElementRef<ComponentType>,
|
|
317
|
+
start: Int32,
|
|
318
|
+
end: Int32
|
|
319
|
+
) => void;
|
|
175
320
|
|
|
176
321
|
// Text formatting commands
|
|
177
322
|
toggleBold: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
@@ -182,10 +327,17 @@ interface NativeCommands {
|
|
|
182
327
|
toggleH1: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
183
328
|
toggleH2: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
184
329
|
toggleH3: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
330
|
+
toggleH4: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
331
|
+
toggleH5: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
332
|
+
toggleH6: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
185
333
|
toggleCodeBlock: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
186
334
|
toggleBlockQuote: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
187
335
|
toggleOrderedList: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
188
336
|
toggleUnorderedList: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
337
|
+
toggleCheckboxList: (
|
|
338
|
+
viewRef: React.ElementRef<ComponentType>,
|
|
339
|
+
checked: boolean
|
|
340
|
+
) => void;
|
|
189
341
|
addLink: (
|
|
190
342
|
viewRef: React.ElementRef<ComponentType>,
|
|
191
343
|
start: Int32,
|
|
@@ -221,6 +373,7 @@ export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
|
|
|
221
373
|
'focus',
|
|
222
374
|
'blur',
|
|
223
375
|
'setValue',
|
|
376
|
+
'setSelection',
|
|
224
377
|
|
|
225
378
|
// Text formatting commands
|
|
226
379
|
'toggleBold',
|
|
@@ -231,10 +384,14 @@ export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
|
|
|
231
384
|
'toggleH1',
|
|
232
385
|
'toggleH2',
|
|
233
386
|
'toggleH3',
|
|
387
|
+
'toggleH4',
|
|
388
|
+
'toggleH5',
|
|
389
|
+
'toggleH6',
|
|
234
390
|
'toggleCodeBlock',
|
|
235
391
|
'toggleBlockQuote',
|
|
236
392
|
'toggleOrderedList',
|
|
237
393
|
'toggleUnorderedList',
|
|
394
|
+
'toggleCheckboxList',
|
|
238
395
|
'addLink',
|
|
239
396
|
'addImage',
|
|
240
397
|
'startMention',
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { ColorValue, TextStyle } from 'react-native';
|
|
2
|
+
|
|
3
|
+
interface HeadingStyle {
|
|
4
|
+
fontSize?: number;
|
|
5
|
+
bold?: boolean;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface MentionStyleProperties {
|
|
9
|
+
color?: ColorValue;
|
|
10
|
+
backgroundColor?: ColorValue;
|
|
11
|
+
textDecorationLine?: 'underline' | 'none';
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface HtmlStyle {
|
|
15
|
+
h1?: HeadingStyle;
|
|
16
|
+
h2?: HeadingStyle;
|
|
17
|
+
h3?: HeadingStyle;
|
|
18
|
+
h4?: HeadingStyle;
|
|
19
|
+
h5?: HeadingStyle;
|
|
20
|
+
h6?: HeadingStyle;
|
|
21
|
+
blockquote?: {
|
|
22
|
+
borderColor?: ColorValue;
|
|
23
|
+
borderWidth?: number;
|
|
24
|
+
gapWidth?: number;
|
|
25
|
+
color?: ColorValue;
|
|
26
|
+
};
|
|
27
|
+
codeblock?: {
|
|
28
|
+
color?: ColorValue;
|
|
29
|
+
borderRadius?: number;
|
|
30
|
+
backgroundColor?: ColorValue;
|
|
31
|
+
};
|
|
32
|
+
code?: {
|
|
33
|
+
color?: ColorValue;
|
|
34
|
+
backgroundColor?: ColorValue;
|
|
35
|
+
};
|
|
36
|
+
a?: {
|
|
37
|
+
color?: ColorValue;
|
|
38
|
+
textDecorationLine?: 'underline' | 'none';
|
|
39
|
+
};
|
|
40
|
+
mention?: Record<string, MentionStyleProperties> | MentionStyleProperties;
|
|
41
|
+
ol?: {
|
|
42
|
+
gapWidth?: number;
|
|
43
|
+
marginLeft?: number;
|
|
44
|
+
markerFontWeight?: TextStyle['fontWeight'];
|
|
45
|
+
markerColor?: ColorValue;
|
|
46
|
+
};
|
|
47
|
+
ul?: {
|
|
48
|
+
bulletColor?: ColorValue;
|
|
49
|
+
bulletSize?: number;
|
|
50
|
+
marginLeft?: number;
|
|
51
|
+
gapWidth?: number;
|
|
52
|
+
};
|
|
53
|
+
ulCheckbox?: {
|
|
54
|
+
boxSize?: number;
|
|
55
|
+
gapWidth?: number;
|
|
56
|
+
marginLeft?: number;
|
|
57
|
+
boxColor?: ColorValue;
|
|
58
|
+
};
|
|
59
|
+
}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import type { HtmlStyle } from './EnrichedTextInput';
|
|
2
1
|
import { type ColorValue, processColor } from 'react-native';
|
|
3
|
-
import type {
|
|
4
|
-
|
|
5
|
-
HtmlStyleInternal,
|
|
6
|
-
} from './EnrichedTextInputNativeComponent';
|
|
2
|
+
import type { HtmlStyleInternal } from '../spec/EnrichedTextInputNativeComponent';
|
|
3
|
+
import type { HtmlStyle, MentionStyleProperties } from '../types';
|
|
7
4
|
|
|
8
5
|
const defaultStyle: Required<HtmlStyle> = {
|
|
9
6
|
h1: {
|
|
@@ -18,6 +15,18 @@ const defaultStyle: Required<HtmlStyle> = {
|
|
|
18
15
|
fontSize: 20,
|
|
19
16
|
bold: false,
|
|
20
17
|
},
|
|
18
|
+
h4: {
|
|
19
|
+
fontSize: 16,
|
|
20
|
+
bold: false,
|
|
21
|
+
},
|
|
22
|
+
h5: {
|
|
23
|
+
fontSize: 14,
|
|
24
|
+
bold: false,
|
|
25
|
+
},
|
|
26
|
+
h6: {
|
|
27
|
+
fontSize: 12,
|
|
28
|
+
bold: false,
|
|
29
|
+
},
|
|
21
30
|
blockquote: {
|
|
22
31
|
borderColor: 'darkgray',
|
|
23
32
|
borderWidth: 4,
|
|
@@ -54,6 +63,12 @@ const defaultStyle: Required<HtmlStyle> = {
|
|
|
54
63
|
marginLeft: 16,
|
|
55
64
|
gapWidth: 16,
|
|
56
65
|
},
|
|
66
|
+
ulCheckbox: {
|
|
67
|
+
boxSize: 24,
|
|
68
|
+
gapWidth: 16,
|
|
69
|
+
marginLeft: 16,
|
|
70
|
+
boxColor: 'blue',
|
|
71
|
+
},
|
|
57
72
|
};
|
|
58
73
|
|
|
59
74
|
const isMentionStyleRecord = (
|