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
|
@@ -1,21 +1,28 @@
|
|
|
1
1
|
#import "EnrichedTextInputView.h"
|
|
2
2
|
#import "FontExtension.h"
|
|
3
3
|
#import "OccurenceUtils.h"
|
|
4
|
+
#import "ParagraphsUtils.h"
|
|
4
5
|
#import "StyleHeaders.h"
|
|
5
6
|
#import "TextInsertionUtils.h"
|
|
6
7
|
|
|
7
8
|
@implementation HeadingStyleBase
|
|
8
9
|
|
|
9
|
-
// mock values since H1/2/
|
|
10
|
+
// mock values since H1/2/3/4/5/6Style classes anyway are used
|
|
10
11
|
+ (StyleType)getStyleType {
|
|
11
12
|
return None;
|
|
12
13
|
}
|
|
13
14
|
- (CGFloat)getHeadingFontSize {
|
|
14
15
|
return 0;
|
|
15
16
|
}
|
|
17
|
+
- (NSString *)getHeadingLevelString {
|
|
18
|
+
return @"";
|
|
19
|
+
}
|
|
16
20
|
- (BOOL)isHeadingBold {
|
|
17
21
|
return false;
|
|
18
22
|
}
|
|
23
|
+
+ (BOOL)isParagraphStyle {
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
19
26
|
|
|
20
27
|
- (EnrichedTextInputView *)typedInput {
|
|
21
28
|
return (EnrichedTextInputView *)input;
|
|
@@ -39,17 +46,48 @@
|
|
|
39
46
|
}
|
|
40
47
|
}
|
|
41
48
|
|
|
49
|
+
- (NSTextList *)getTextListObject {
|
|
50
|
+
return [[NSTextList alloc]
|
|
51
|
+
initWithMarkerFormat:[NSString
|
|
52
|
+
stringWithFormat:@"{heading:%@}",
|
|
53
|
+
[self getHeadingLevelString]]
|
|
54
|
+
options:0];
|
|
55
|
+
}
|
|
56
|
+
|
|
42
57
|
// the range will already be the proper full paragraph/s range
|
|
43
58
|
- (void)addAttributes:(NSRange)range withTypingAttr:(BOOL)withTypingAttr {
|
|
44
|
-
[
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
59
|
+
NSTextList *textListMarker = [self getTextListObject];
|
|
60
|
+
NSArray *paragraphs =
|
|
61
|
+
[ParagraphsUtils getSeparateParagraphsRangesIn:[self typedInput]->textView
|
|
62
|
+
range:range];
|
|
63
|
+
for (NSValue *value in paragraphs) {
|
|
64
|
+
NSRange paragraphRange = [value rangeValue];
|
|
65
|
+
|
|
66
|
+
[[self typedInput]->textView.textStorage
|
|
67
|
+
enumerateAttribute:NSParagraphStyleAttributeName
|
|
68
|
+
inRange:paragraphRange
|
|
69
|
+
options:0
|
|
70
|
+
usingBlock:^(id _Nullable value, NSRange range,
|
|
71
|
+
BOOL *_Nonnull stop) {
|
|
72
|
+
NSMutableParagraphStyle *pStyle =
|
|
73
|
+
[(NSParagraphStyle *)value mutableCopy];
|
|
74
|
+
pStyle.textLists = @[ textListMarker ];
|
|
75
|
+
[[self typedInput]->textView.textStorage
|
|
76
|
+
addAttribute:NSParagraphStyleAttributeName
|
|
77
|
+
value:pStyle
|
|
78
|
+
range:range];
|
|
79
|
+
}];
|
|
80
|
+
|
|
81
|
+
[[self typedInput]->textView.textStorage
|
|
82
|
+
enumerateAttribute:NSFontAttributeName
|
|
83
|
+
inRange:paragraphRange
|
|
84
|
+
options:0
|
|
85
|
+
usingBlock:^(id _Nullable value, NSRange range,
|
|
86
|
+
BOOL *_Nonnull stop) {
|
|
87
|
+
UIFont *font = (UIFont *)value;
|
|
88
|
+
if (font == nullptr) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
53
91
|
UIFont *newFont = [font setSize:[self getHeadingFontSize]];
|
|
54
92
|
if ([self isHeadingBold]) {
|
|
55
93
|
newFont = [newFont setBold];
|
|
@@ -58,9 +96,8 @@
|
|
|
58
96
|
addAttribute:NSFontAttributeName
|
|
59
97
|
value:newFont
|
|
60
98
|
range:range];
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
[[self typedInput]->textView.textStorage endEditing];
|
|
99
|
+
}];
|
|
100
|
+
}
|
|
64
101
|
|
|
65
102
|
// also toggle typing attributes
|
|
66
103
|
if (withTypingAttr) {
|
|
@@ -71,36 +108,59 @@
|
|
|
71
108
|
// will always be called on empty paragraphs so only typing attributes can be
|
|
72
109
|
// changed
|
|
73
110
|
- (void)addTypingAttributes {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
111
|
+
NSMutableDictionary *newTypingAttrs =
|
|
112
|
+
[[self typedInput]->textView.typingAttributes mutableCopy];
|
|
113
|
+
|
|
114
|
+
NSMutableParagraphStyle *pStyle =
|
|
115
|
+
[newTypingAttrs[NSParagraphStyleAttributeName] mutableCopy];
|
|
116
|
+
if (pStyle != nullptr) {
|
|
117
|
+
pStyle.textLists = @[ [self getTextListObject] ];
|
|
118
|
+
newTypingAttrs[NSParagraphStyleAttributeName] = pStyle;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
UIFont *currentFontAttr = (UIFont *)newTypingAttrs[NSFontAttributeName];
|
|
77
122
|
if (currentFontAttr != nullptr) {
|
|
78
|
-
NSMutableDictionary *newTypingAttrs =
|
|
79
|
-
[[self typedInput]->textView.typingAttributes mutableCopy];
|
|
80
123
|
UIFont *newFont = [currentFontAttr setSize:[self getHeadingFontSize]];
|
|
81
124
|
if ([self isHeadingBold]) {
|
|
82
125
|
newFont = [newFont setBold];
|
|
83
126
|
}
|
|
84
127
|
newTypingAttrs[NSFontAttributeName] = newFont;
|
|
85
|
-
[self typedInput]->textView.typingAttributes = newTypingAttrs;
|
|
86
128
|
}
|
|
129
|
+
|
|
130
|
+
[self typedInput]->textView.typingAttributes = newTypingAttrs;
|
|
87
131
|
}
|
|
88
132
|
|
|
89
133
|
// we need to remove the style from the whole paragraph
|
|
90
134
|
- (void)removeAttributes:(NSRange)range {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
135
|
+
NSArray *paragraphs =
|
|
136
|
+
[ParagraphsUtils getSeparateParagraphsRangesIn:[self typedInput]->textView
|
|
137
|
+
range:range];
|
|
138
|
+
|
|
139
|
+
for (NSValue *value in paragraphs) {
|
|
140
|
+
NSRange paragraphRange = [value rangeValue];
|
|
141
|
+
[[self typedInput]->textView.textStorage
|
|
142
|
+
enumerateAttribute:NSParagraphStyleAttributeName
|
|
143
|
+
inRange:paragraphRange
|
|
144
|
+
options:0
|
|
145
|
+
usingBlock:^(id _Nullable value, NSRange range,
|
|
146
|
+
BOOL *_Nonnull stop) {
|
|
147
|
+
NSMutableParagraphStyle *pStyle =
|
|
148
|
+
[(NSParagraphStyle *)value mutableCopy];
|
|
149
|
+
pStyle.textLists = @[];
|
|
150
|
+
[[self typedInput]->textView.textStorage
|
|
151
|
+
addAttribute:NSParagraphStyleAttributeName
|
|
152
|
+
value:pStyle
|
|
153
|
+
range:range];
|
|
154
|
+
}];
|
|
155
|
+
|
|
156
|
+
[[self typedInput]->textView.textStorage
|
|
157
|
+
enumerateAttribute:NSFontAttributeName
|
|
158
|
+
inRange:paragraphRange
|
|
159
|
+
options:0
|
|
160
|
+
usingBlock:^(id _Nullable value, NSRange range,
|
|
161
|
+
BOOL *_Nonnull stop) {
|
|
102
162
|
UIFont *newFont = [(UIFont *)value
|
|
103
|
-
setSize:[[[self typedInput]->config
|
|
163
|
+
setSize:[[[self typedInput]->config scaledPrimaryFontSize]
|
|
104
164
|
floatValue]];
|
|
105
165
|
if ([self isHeadingBold]) {
|
|
106
166
|
newFont = [newFont removeBold];
|
|
@@ -109,73 +169,81 @@
|
|
|
109
169
|
addAttribute:NSFontAttributeName
|
|
110
170
|
value:newFont
|
|
111
171
|
range:range];
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
[[self typedInput]->textView.textStorage endEditing];
|
|
172
|
+
}];
|
|
173
|
+
}
|
|
115
174
|
|
|
116
175
|
// typing attributes still need to be removed
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
176
|
+
NSMutableDictionary *newTypingAttrs =
|
|
177
|
+
[[self typedInput]->textView.typingAttributes mutableCopy];
|
|
178
|
+
|
|
179
|
+
NSMutableParagraphStyle *pStyle =
|
|
180
|
+
[newTypingAttrs[NSParagraphStyleAttributeName] mutableCopy];
|
|
181
|
+
if (pStyle != nullptr) {
|
|
182
|
+
pStyle.textLists = @[];
|
|
183
|
+
newTypingAttrs[NSParagraphStyleAttributeName] = pStyle;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
UIFont *currentFontAttr = (UIFont *)newTypingAttrs[NSFontAttributeName];
|
|
120
187
|
if (currentFontAttr != nullptr) {
|
|
121
|
-
NSMutableDictionary *newTypingAttrs =
|
|
122
|
-
[[self typedInput]->textView.typingAttributes mutableCopy];
|
|
123
188
|
UIFont *newFont = [currentFontAttr
|
|
124
|
-
setSize:[[[self typedInput]->config
|
|
189
|
+
setSize:[[[self typedInput]->config scaledPrimaryFontSize] floatValue]];
|
|
125
190
|
if ([self isHeadingBold]) {
|
|
126
191
|
newFont = [newFont removeBold];
|
|
127
192
|
}
|
|
128
193
|
newTypingAttrs[NSFontAttributeName] = newFont;
|
|
129
|
-
[self typedInput]->textView.typingAttributes = newTypingAttrs;
|
|
130
194
|
}
|
|
195
|
+
|
|
196
|
+
[self typedInput]->textView.typingAttributes = newTypingAttrs;
|
|
131
197
|
}
|
|
132
198
|
|
|
133
199
|
- (void)removeTypingAttributes {
|
|
134
|
-
//
|
|
135
|
-
// called in conflicting styles logic
|
|
136
|
-
// there as well
|
|
200
|
+
// All the heading still needs to be removed because this function may be
|
|
201
|
+
// called in conflicting styles logic. Typing attributes already get removed
|
|
202
|
+
// in there as well.
|
|
137
203
|
[self removeAttributes:[self typedInput]->textView.selectedRange];
|
|
138
204
|
}
|
|
139
205
|
|
|
140
|
-
- (BOOL)styleCondition:(id _Nullable)value:(NSRange)range {
|
|
141
|
-
|
|
142
|
-
return
|
|
206
|
+
- (BOOL)styleCondition:(id _Nullable)value range:(NSRange)range {
|
|
207
|
+
NSParagraphStyle *paragraph = (NSParagraphStyle *)value;
|
|
208
|
+
return paragraph != nullptr && paragraph.textLists.count == 1 &&
|
|
209
|
+
[paragraph.textLists.firstObject.markerFormat
|
|
210
|
+
isEqualToString:[self getTextListObject].markerFormat];
|
|
143
211
|
}
|
|
144
212
|
|
|
145
213
|
- (BOOL)detectStyle:(NSRange)range {
|
|
146
214
|
if (range.length >= 1) {
|
|
147
|
-
return [OccurenceUtils detect:
|
|
215
|
+
return [OccurenceUtils detect:NSParagraphStyleAttributeName
|
|
148
216
|
withInput:[self typedInput]
|
|
149
217
|
inRange:range
|
|
150
218
|
withCondition:^BOOL(id _Nullable value, NSRange range) {
|
|
151
|
-
return [self styleCondition:value:range];
|
|
219
|
+
return [self styleCondition:value range:range];
|
|
152
220
|
}];
|
|
153
221
|
} else {
|
|
154
|
-
return [OccurenceUtils detect:
|
|
222
|
+
return [OccurenceUtils detect:NSParagraphStyleAttributeName
|
|
155
223
|
withInput:[self typedInput]
|
|
156
224
|
atIndex:range.location
|
|
157
225
|
checkPrevious:YES
|
|
158
226
|
withCondition:^BOOL(id _Nullable value, NSRange range) {
|
|
159
|
-
return [self styleCondition:value:range];
|
|
227
|
+
return [self styleCondition:value range:range];
|
|
160
228
|
}];
|
|
161
229
|
}
|
|
162
230
|
}
|
|
163
231
|
|
|
164
232
|
- (BOOL)anyOccurence:(NSRange)range {
|
|
165
|
-
return [OccurenceUtils any:
|
|
233
|
+
return [OccurenceUtils any:NSParagraphStyleAttributeName
|
|
166
234
|
withInput:[self typedInput]
|
|
167
235
|
inRange:range
|
|
168
236
|
withCondition:^BOOL(id _Nullable value, NSRange range) {
|
|
169
|
-
return [self styleCondition:value:range];
|
|
237
|
+
return [self styleCondition:value range:range];
|
|
170
238
|
}];
|
|
171
239
|
}
|
|
172
240
|
|
|
173
241
|
- (NSArray<StylePair *> *_Nullable)findAllOccurences:(NSRange)range {
|
|
174
|
-
return [OccurenceUtils all:
|
|
242
|
+
return [OccurenceUtils all:NSParagraphStyleAttributeName
|
|
175
243
|
withInput:[self typedInput]
|
|
176
244
|
inRange:range
|
|
177
245
|
withCondition:^BOOL(id _Nullable value, NSRange range) {
|
|
178
|
-
return [self styleCondition:value:range];
|
|
246
|
+
return [self styleCondition:value range:range];
|
|
179
247
|
}];
|
|
180
248
|
}
|
|
181
249
|
|
|
@@ -192,30 +260,51 @@
|
|
|
192
260
|
additionalAttributes:nullptr
|
|
193
261
|
input:[self typedInput]
|
|
194
262
|
withSelection:YES];
|
|
195
|
-
// remove the
|
|
263
|
+
// remove the attributes at the new selection
|
|
196
264
|
[self removeAttributes:[self typedInput]->textView.selectedRange];
|
|
197
265
|
return YES;
|
|
198
266
|
}
|
|
199
267
|
return NO;
|
|
200
268
|
}
|
|
201
269
|
|
|
202
|
-
//
|
|
203
|
-
// text
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
270
|
+
// Backspacing a line after a heading "into" a heading will not result in the
|
|
271
|
+
// text not receiving heading font attributes.
|
|
272
|
+
// Hence, we fix these attributes then.
|
|
273
|
+
- (BOOL)handleBackspaceInRange:(NSRange)range replacementText:(NSString *)text {
|
|
274
|
+
// Must be a backspace.
|
|
275
|
+
if (text.length != 0) {
|
|
276
|
+
return NO;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// Backspace must have removed a newline character.
|
|
280
|
+
NSString *removedString =
|
|
281
|
+
[[self typedInput]->textView.textStorage.string substringWithRange:range];
|
|
282
|
+
if ([removedString
|
|
283
|
+
rangeOfCharacterFromSet:[NSCharacterSet newlineCharacterSet]]
|
|
284
|
+
.location == NSNotFound) {
|
|
285
|
+
return NO;
|
|
218
286
|
}
|
|
287
|
+
|
|
288
|
+
// Heading style must have been present in a paragraph before the backspaced
|
|
289
|
+
// range.
|
|
290
|
+
NSRange paragraphBeforeBackspaceRange =
|
|
291
|
+
[[self typedInput]->textView.textStorage.string
|
|
292
|
+
paragraphRangeForRange:NSMakeRange(range.location, 0)];
|
|
293
|
+
if (![self detectStyle:paragraphBeforeBackspaceRange]) {
|
|
294
|
+
return NO;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// Manually do the replacing.
|
|
298
|
+
[TextInsertionUtils replaceText:text
|
|
299
|
+
at:range
|
|
300
|
+
additionalAttributes:nullptr
|
|
301
|
+
input:[self typedInput]
|
|
302
|
+
withSelection:YES];
|
|
303
|
+
// Reapply attributes at the beginning of the backspaced range (it will cover
|
|
304
|
+
// the whole paragraph properly).
|
|
305
|
+
[self addAttributes:NSMakeRange(range.location, 0) withTypingAttr:YES];
|
|
306
|
+
|
|
307
|
+
return YES;
|
|
219
308
|
}
|
|
220
309
|
|
|
221
310
|
@end
|
package/ios/styles/ImageStyle.mm
CHANGED
|
@@ -54,7 +54,7 @@ static NSString *const ImageAttributeName = @"ImageAttributeName";
|
|
|
54
54
|
_input->textView.typingAttributes = currentAttributes;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
- (BOOL)styleCondition:(id _Nullable)value:(NSRange)range {
|
|
57
|
+
- (BOOL)styleCondition:(id _Nullable)value range:(NSRange)range {
|
|
58
58
|
return [value isKindOfClass:[ImageData class]];
|
|
59
59
|
}
|
|
60
60
|
|
|
@@ -63,7 +63,7 @@ static NSString *const ImageAttributeName = @"ImageAttributeName";
|
|
|
63
63
|
withInput:_input
|
|
64
64
|
inRange:range
|
|
65
65
|
withCondition:^BOOL(id _Nullable value, NSRange range) {
|
|
66
|
-
return [self styleCondition:value:range];
|
|
66
|
+
return [self styleCondition:value range:range];
|
|
67
67
|
}];
|
|
68
68
|
}
|
|
69
69
|
|
|
@@ -73,7 +73,7 @@ static NSString *const ImageAttributeName = @"ImageAttributeName";
|
|
|
73
73
|
withInput:_input
|
|
74
74
|
inRange:range
|
|
75
75
|
withCondition:^BOOL(id _Nullable value, NSRange range) {
|
|
76
|
-
return [self styleCondition:value:range];
|
|
76
|
+
return [self styleCondition:value range:range];
|
|
77
77
|
}];
|
|
78
78
|
} else {
|
|
79
79
|
return [OccurenceUtils detect:ImageAttributeName
|
|
@@ -81,7 +81,7 @@ static NSString *const ImageAttributeName = @"ImageAttributeName";
|
|
|
81
81
|
atIndex:range.location
|
|
82
82
|
checkPrevious:YES
|
|
83
83
|
withCondition:^BOOL(id _Nullable value, NSRange range) {
|
|
84
|
-
return [self styleCondition:value:range];
|
|
84
|
+
return [self styleCondition:value range:range];
|
|
85
85
|
}];
|
|
86
86
|
}
|
|
87
87
|
}
|
|
@@ -91,7 +91,7 @@ static NSString *const ImageAttributeName = @"ImageAttributeName";
|
|
|
91
91
|
withInput:_input
|
|
92
92
|
inRange:range
|
|
93
93
|
withCondition:^BOOL(id _Nullable value, NSRange range) {
|
|
94
|
-
return [self styleCondition:value:range];
|
|
94
|
+
return [self styleCondition:value range:range];
|
|
95
95
|
}];
|
|
96
96
|
}
|
|
97
97
|
|
|
@@ -151,27 +151,38 @@
|
|
|
151
151
|
|
|
152
152
|
// making sure no newlines get inline code style, it looks bad
|
|
153
153
|
- (void)handleNewlines {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
154
|
+
NSTextStorage *storage = _input->textView.textStorage;
|
|
155
|
+
NSString *string = storage.string;
|
|
156
|
+
NSUInteger length = string.length;
|
|
157
|
+
|
|
158
|
+
if (length == 0)
|
|
159
|
+
return;
|
|
160
|
+
|
|
161
|
+
CFStringInlineBuffer buffer;
|
|
162
|
+
CFStringInitInlineBuffer((CFStringRef)string, &buffer,
|
|
163
|
+
CFRangeMake(0, length));
|
|
164
|
+
|
|
165
|
+
for (NSUInteger index = 0; index < length; index++) {
|
|
166
|
+
unichar ch = CFStringGetCharacterFromInlineBuffer(&buffer, index);
|
|
167
|
+
// check new lines only
|
|
168
|
+
if (![[NSCharacterSet newlineCharacterSet] characterIsMember:ch])
|
|
169
|
+
continue;
|
|
170
|
+
|
|
171
|
+
NSRange newlineRange = NSMakeRange(index, 1);
|
|
172
|
+
|
|
173
|
+
UIColor *bgColor = [storage attribute:NSBackgroundColorAttributeName
|
|
174
|
+
atIndex:index
|
|
175
|
+
effectiveRange:nil];
|
|
176
|
+
|
|
177
|
+
if (bgColor != nil && [self styleCondition:bgColor range:newlineRange]) {
|
|
178
|
+
[self removeAttributes:newlineRange];
|
|
168
179
|
}
|
|
169
180
|
}
|
|
170
181
|
}
|
|
171
182
|
|
|
172
183
|
// emojis don't retain monospace font attribute so we check for the background
|
|
173
184
|
// color if there is no mention
|
|
174
|
-
- (BOOL)styleCondition:(id _Nullable)value:(NSRange)range {
|
|
185
|
+
- (BOOL)styleCondition:(id _Nullable)value range:(NSRange)range {
|
|
175
186
|
UIColor *bgColor = (UIColor *)value;
|
|
176
187
|
MentionStyle *mStyle = _input->stylesDict[@([MentionStyle getStyleType])];
|
|
177
188
|
return bgColor != nullptr && mStyle != nullptr && ![mStyle detectStyle:range];
|
|
@@ -194,7 +205,7 @@
|
|
|
194
205
|
withInput:_input
|
|
195
206
|
inRange:currentRange
|
|
196
207
|
withCondition:^BOOL(id _Nullable value, NSRange range) {
|
|
197
|
-
return [self styleCondition:value:range];
|
|
208
|
+
return [self styleCondition:value range:range];
|
|
198
209
|
}];
|
|
199
210
|
detected = detected && currentDetected;
|
|
200
211
|
}
|
|
@@ -206,7 +217,7 @@
|
|
|
206
217
|
atIndex:range.location
|
|
207
218
|
checkPrevious:NO
|
|
208
219
|
withCondition:^BOOL(id _Nullable value, NSRange range) {
|
|
209
|
-
return [self styleCondition:value:range];
|
|
220
|
+
return [self styleCondition:value range:range];
|
|
210
221
|
}];
|
|
211
222
|
}
|
|
212
223
|
}
|
|
@@ -216,7 +227,7 @@
|
|
|
216
227
|
withInput:_input
|
|
217
228
|
inRange:range
|
|
218
229
|
withCondition:^BOOL(id _Nullable value, NSRange range) {
|
|
219
|
-
return [self styleCondition:value:range];
|
|
230
|
+
return [self styleCondition:value range:range];
|
|
220
231
|
}];
|
|
221
232
|
}
|
|
222
233
|
|
|
@@ -225,7 +236,7 @@
|
|
|
225
236
|
withInput:_input
|
|
226
237
|
inRange:range
|
|
227
238
|
withCondition:^BOOL(id _Nullable value, NSRange range) {
|
|
228
|
-
return [self styleCondition:value:range];
|
|
239
|
+
return [self styleCondition:value range:range];
|
|
229
240
|
}];
|
|
230
241
|
}
|
|
231
242
|
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
- (BOOL)styleCondition:(id _Nullable)value:(NSRange)range {
|
|
94
|
+
- (BOOL)styleCondition:(id _Nullable)value range:(NSRange)range {
|
|
95
95
|
UIFont *font = (UIFont *)value;
|
|
96
96
|
return font != nullptr && [font isItalic];
|
|
97
97
|
}
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
withInput:_input
|
|
103
103
|
inRange:range
|
|
104
104
|
withCondition:^BOOL(id _Nullable value, NSRange range) {
|
|
105
|
-
return [self styleCondition:value:range];
|
|
105
|
+
return [self styleCondition:value range:range];
|
|
106
106
|
}];
|
|
107
107
|
} else {
|
|
108
108
|
return [OccurenceUtils detect:NSFontAttributeName
|
|
@@ -110,7 +110,7 @@
|
|
|
110
110
|
atIndex:range.location
|
|
111
111
|
checkPrevious:NO
|
|
112
112
|
withCondition:^BOOL(id _Nullable value, NSRange range) {
|
|
113
|
-
return [self styleCondition:value:range];
|
|
113
|
+
return [self styleCondition:value range:range];
|
|
114
114
|
}];
|
|
115
115
|
}
|
|
116
116
|
}
|
|
@@ -120,7 +120,7 @@
|
|
|
120
120
|
withInput:_input
|
|
121
121
|
inRange:range
|
|
122
122
|
withCondition:^BOOL(id _Nullable value, NSRange range) {
|
|
123
|
-
return [self styleCondition:value:range];
|
|
123
|
+
return [self styleCondition:value range:range];
|
|
124
124
|
}];
|
|
125
125
|
}
|
|
126
126
|
|
|
@@ -129,7 +129,7 @@
|
|
|
129
129
|
withInput:_input
|
|
130
130
|
inRange:range
|
|
131
131
|
withCondition:^BOOL(id _Nullable value, NSRange range) {
|
|
132
|
-
return [self styleCondition:value:range];
|
|
132
|
+
return [self styleCondition:value range:range];
|
|
133
133
|
}];
|
|
134
134
|
}
|
|
135
135
|
|