@fendent/react-native-enriched 0.5.2-fork.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/LICENSE +20 -0
- package/README.md +343 -0
- package/ReactNativeEnriched.podspec +31 -0
- package/android/build.gradle +106 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedTextInputViewManagerDelegate.java +197 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedTextInputViewManagerInterface.java +72 -0
- package/android/generated/jni/react/renderer/components/ReactNativeEnrichedSpec/ComponentDescriptors.cpp +22 -0
- package/android/generated/jni/react/renderer/components/ReactNativeEnrichedSpec/ComponentDescriptors.h +24 -0
- package/android/generated/jni/react/renderer/components/ReactNativeEnrichedSpec/EventEmitters.cpp +434 -0
- package/android/generated/jni/react/renderer/components/ReactNativeEnrichedSpec/EventEmitters.h +391 -0
- package/android/generated/jni/react/renderer/components/ReactNativeEnrichedSpec/Props.cpp +173 -0
- package/android/generated/jni/react/renderer/components/ReactNativeEnrichedSpec/Props.h +833 -0
- package/android/generated/jni/react/renderer/components/ReactNativeEnrichedSpec/ShadowNodes.cpp +17 -0
- package/android/generated/jni/react/renderer/components/ReactNativeEnrichedSpec/ShadowNodes.h +23 -0
- package/android/generated/jni/react/renderer/components/ReactNativeEnrichedSpec/States.cpp +16 -0
- package/android/generated/jni/react/renderer/components/ReactNativeEnrichedSpec/States.h +20 -0
- package/android/gradle.properties +5 -0
- package/android/lint.gradle +70 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/java/com/swmansion/enriched/ReactNativeEnrichedPackage.kt +20 -0
- package/android/src/main/java/com/swmansion/enriched/common/AsyncDrawable.kt +126 -0
- 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/common/ForceRedrawSpan.kt +14 -0
- package/android/src/main/java/com/swmansion/enriched/common/GumboNormalizer.kt +5 -0
- package/android/src/main/java/com/swmansion/enriched/common/MentionStyle.kt +7 -0
- package/android/src/main/java/com/swmansion/enriched/common/ResourceManager.kt +26 -0
- package/android/src/main/java/com/swmansion/enriched/common/parser/EnrichedParser.java +956 -0
- 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 +92 -0
- package/android/src/main/java/com/swmansion/enriched/common/spans/EnrichedCodeBlockSpan.kt +81 -0
- 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/common/spans/EnrichedImageSpan.kt +184 -0
- 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 +29 -0
- package/android/src/main/java/com/swmansion/enriched/common/spans/EnrichedMentionSpan.kt +35 -0
- package/android/src/main/java/com/swmansion/enriched/common/spans/EnrichedOrderedListSpan.kt +79 -0
- 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/common/spans/EnrichedUnorderedListSpan.kt +62 -0
- 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/common/spans/interfaces/EnrichedZeroWidthSpaceSpan.kt +4 -0
- 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/textinput/EnrichedTextInputView.kt +1120 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/EnrichedTextInputViewLayoutManager.kt +27 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/EnrichedTextInputViewManager.kt +478 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/MeasurementStore.kt +225 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/events/MentionHandler.kt +55 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/events/OnChangeHtmlEvent.kt +27 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/events/OnChangeSelectionEvent.kt +30 -0
- 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/OnContextMenuItemPressEvent.kt +35 -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/textinput/events/OnMentionDetectedEvent.kt +30 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/events/OnMentionEvent.kt +34 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/events/OnPasteImagesEvent.kt +47 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/events/OnRequestHtmlResultEvent.kt +32 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/events/OnSubmitEditingEvent.kt +29 -0
- 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 +16 -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/EnrichedLineHeightSpan.kt +44 -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/textinput/styles/HtmlStyle.kt +372 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/styles/InlineStyles.kt +164 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/styles/ListStyles.kt +263 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/styles/ParagraphStyles.kt +434 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/styles/ParametrizedStyles.kt +394 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/utils/EnrichedEditableFactory.kt +17 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/utils/EnrichedSelection.kt +320 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/utils/EnrichedSpanState.kt +310 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/utils/EnrichedSpannable.kt +106 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/utils/EnrichedSpannableStringBuilder.kt +24 -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/textinput/watchers/EnrichedSpanWatcher.kt +107 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/watchers/EnrichedTextWatcher.kt +74 -0
- package/android/src/main/new_arch/CMakeLists.txt +62 -0
- package/android/src/main/new_arch/GumboNormalizerJni.cpp +14 -0
- 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/ReactNativeEnrichedSpec/EnrichedTextInputComponentDescriptor.h +35 -0
- package/android/src/main/new_arch/react/renderer/components/ReactNativeEnrichedSpec/EnrichedTextInputMeasurementManager.cpp +53 -0
- package/android/src/main/new_arch/react/renderer/components/ReactNativeEnrichedSpec/EnrichedTextInputMeasurementManager.h +25 -0
- package/android/src/main/new_arch/react/renderer/components/ReactNativeEnrichedSpec/EnrichedTextInputShadowNode.cpp +35 -0
- package/android/src/main/new_arch/react/renderer/components/ReactNativeEnrichedSpec/EnrichedTextInputShadowNode.h +53 -0
- package/android/src/main/new_arch/react/renderer/components/ReactNativeEnrichedSpec/EnrichedTextInputState.cpp +9 -0
- package/android/src/main/new_arch/react/renderer/components/ReactNativeEnrichedSpec/EnrichedTextInputState.h +24 -0
- package/android/src/main/new_arch/react/renderer/components/ReactNativeEnrichedSpec/conversions.h +27 -0
- package/android/src/main/res/drawable/broken_image.xml +10 -0
- package/cpp/CMakeLists.txt +50 -0
- package/cpp/GumboParser/GumboParser.h +34043 -0
- package/cpp/README.md +59 -0
- package/cpp/parser/GumboNormalizer.c +915 -0
- package/cpp/parser/GumboParser.cpp +16 -0
- package/cpp/parser/GumboParser.hpp +23 -0
- package/cpp/tests/GumboParserTest.cpp +457 -0
- package/ios/EnrichedTextInputView.h +53 -0
- package/ios/EnrichedTextInputView.mm +2360 -0
- package/ios/EnrichedTextInputViewManager.mm +13 -0
- package/ios/attributesManager/AttributesManager.h +17 -0
- package/ios/attributesManager/AttributesManager.mm +195 -0
- package/ios/config/InputConfig.h +104 -0
- package/ios/config/InputConfig.mm +664 -0
- package/ios/extensions/ColorExtension.h +7 -0
- package/ios/extensions/ColorExtension.mm +38 -0
- package/ios/extensions/FontExtension.h +11 -0
- package/ios/extensions/FontExtension.mm +72 -0
- package/ios/extensions/ImageExtension.h +34 -0
- package/ios/extensions/ImageExtension.mm +165 -0
- package/ios/extensions/LayoutManagerExtension.h +6 -0
- package/ios/extensions/LayoutManagerExtension.mm +443 -0
- package/ios/extensions/StringExtension.h +15 -0
- package/ios/extensions/StringExtension.mm +69 -0
- package/ios/generated/ReactNativeEnrichedSpec/ComponentDescriptors.cpp +22 -0
- package/ios/generated/ReactNativeEnrichedSpec/ComponentDescriptors.h +24 -0
- package/ios/generated/ReactNativeEnrichedSpec/EventEmitters.cpp +434 -0
- package/ios/generated/ReactNativeEnrichedSpec/EventEmitters.h +391 -0
- package/ios/generated/ReactNativeEnrichedSpec/Props.cpp +173 -0
- package/ios/generated/ReactNativeEnrichedSpec/Props.h +833 -0
- package/ios/generated/ReactNativeEnrichedSpec/RCTComponentViewHelpers.h +582 -0
- package/ios/generated/ReactNativeEnrichedSpec/ShadowNodes.cpp +17 -0
- package/ios/generated/ReactNativeEnrichedSpec/ShadowNodes.h +23 -0
- package/ios/generated/ReactNativeEnrichedSpec/States.cpp +16 -0
- package/ios/generated/ReactNativeEnrichedSpec/States.h +20 -0
- package/ios/inputParser/InputParser.h +11 -0
- package/ios/inputParser/InputParser.mm +1463 -0
- package/ios/inputTextView/InputTextView.h +6 -0
- package/ios/inputTextView/InputTextView.mm +285 -0
- package/ios/interfaces/AttributeEntry.h +9 -0
- package/ios/interfaces/AttributeEntry.mm +4 -0
- package/ios/interfaces/BaseStyleProtocol.h +17 -0
- package/ios/interfaces/ImageAttachment.h +11 -0
- package/ios/interfaces/ImageAttachment.mm +107 -0
- package/ios/interfaces/ImageData.h +10 -0
- package/ios/interfaces/ImageData.mm +4 -0
- package/ios/interfaces/LinkData.h +11 -0
- package/ios/interfaces/LinkData.mm +29 -0
- package/ios/interfaces/LinkRegexConfig.h +19 -0
- package/ios/interfaces/LinkRegexConfig.mm +37 -0
- package/ios/interfaces/MediaAttachment.h +23 -0
- package/ios/interfaces/MediaAttachment.mm +31 -0
- package/ios/interfaces/MentionParams.h +8 -0
- package/ios/interfaces/MentionParams.mm +4 -0
- package/ios/interfaces/MentionStyleProps.h +13 -0
- package/ios/interfaces/MentionStyleProps.mm +63 -0
- package/ios/interfaces/StyleBase.h +36 -0
- package/ios/interfaces/StyleBase.mm +256 -0
- package/ios/interfaces/StyleHeaders.h +102 -0
- package/ios/interfaces/StylePair.h +9 -0
- package/ios/interfaces/StylePair.mm +4 -0
- package/ios/interfaces/StyleTypeEnum.h +26 -0
- package/ios/interfaces/TextDecorationLineEnum.h +6 -0
- package/ios/interfaces/TextDecorationLineEnum.mm +4 -0
- package/ios/internals/EnrichedTextInputViewComponentDescriptor.h +19 -0
- package/ios/internals/EnrichedTextInputViewShadowNode.h +44 -0
- package/ios/internals/EnrichedTextInputViewShadowNode.mm +103 -0
- package/ios/internals/EnrichedTextInputViewState.cpp +10 -0
- package/ios/internals/EnrichedTextInputViewState.h +22 -0
- package/ios/styles/BlockQuoteStyle.mm +55 -0
- package/ios/styles/BoldStyle.mm +37 -0
- package/ios/styles/CheckboxListStyle.mm +153 -0
- package/ios/styles/CodeBlockStyle.mm +49 -0
- package/ios/styles/H1Style.mm +20 -0
- package/ios/styles/H2Style.mm +20 -0
- package/ios/styles/H3Style.mm +20 -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 +65 -0
- package/ios/styles/ImageStyle.mm +146 -0
- package/ios/styles/InlineCodeStyle.mm +65 -0
- package/ios/styles/ItalicStyle.mm +37 -0
- package/ios/styles/LinkStyle.mm +532 -0
- package/ios/styles/MentionStyle.mm +538 -0
- package/ios/styles/OrderedListStyle.mm +86 -0
- package/ios/styles/StrikethroughStyle.mm +25 -0
- package/ios/styles/UnderlineStyle.mm +24 -0
- package/ios/styles/UnorderedListStyle.mm +86 -0
- package/ios/utils/CheckboxHitTestUtils.h +10 -0
- package/ios/utils/CheckboxHitTestUtils.mm +122 -0
- package/ios/utils/DotReplacementUtils.h +10 -0
- package/ios/utils/DotReplacementUtils.mm +68 -0
- package/ios/utils/KeyboardUtils.h +7 -0
- package/ios/utils/KeyboardUtils.mm +31 -0
- package/ios/utils/OccurenceUtils.h +44 -0
- package/ios/utils/OccurenceUtils.mm +179 -0
- package/ios/utils/ParagraphAttributesUtils.h +15 -0
- package/ios/utils/ParagraphAttributesUtils.mm +257 -0
- package/ios/utils/RangeUtils.h +12 -0
- package/ios/utils/RangeUtils.mm +183 -0
- package/ios/utils/TextBlockTapGestureRecognizer.h +17 -0
- package/ios/utils/TextBlockTapGestureRecognizer.mm +56 -0
- package/ios/utils/TextInsertionUtils.h +17 -0
- package/ios/utils/TextInsertionUtils.mm +64 -0
- package/ios/utils/WordsUtils.h +7 -0
- package/ios/utils/WordsUtils.mm +98 -0
- package/ios/utils/ZeroWidthSpaceUtils.h +9 -0
- package/ios/utils/ZeroWidthSpaceUtils.mm +270 -0
- package/lib/module/index.js +4 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/native/EnrichedTextInput.js +304 -0
- package/lib/module/native/EnrichedTextInput.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/spec/EnrichedTextInputNativeComponent.ts +517 -0
- package/lib/module/types.js +4 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/utils/EnrichedTextInputDefaultProps.js +12 -0
- package/lib/module/utils/EnrichedTextInputDefaultProps.js.map +1 -0
- package/lib/module/utils/normalizeHtmlStyle.js +155 -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/package.json +1 -0
- package/lib/typescript/src/index.d.ts +3 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/native/EnrichedTextInput.d.ts +3 -0
- package/lib/typescript/src/native/EnrichedTextInput.d.ts.map +1 -0
- package/lib/typescript/src/spec/EnrichedTextInputNativeComponent.d.ts +397 -0
- package/lib/typescript/src/spec/EnrichedTextInputNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +447 -0
- package/lib/typescript/src/types.d.ts.map +1 -0
- package/lib/typescript/src/utils/EnrichedTextInputDefaultProps.d.ts +10 -0
- package/lib/typescript/src/utils/EnrichedTextInputDefaultProps.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 +226 -0
- package/react-native.config.js +13 -0
- package/src/index.tsx +20 -0
- package/src/native/EnrichedTextInput.tsx +370 -0
- package/src/spec/EnrichedTextInputNativeComponent.ts +517 -0
- package/src/types.ts +499 -0
- package/src/utils/EnrichedTextInputDefaultProps.ts +9 -0
- package/src/utils/normalizeHtmlStyle.ts +199 -0
- package/src/utils/nullthrows.ts +7 -0
- package/src/utils/regexParser.ts +56 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
#import "MentionStyleProps.h"
|
|
2
|
+
#import "StringExtension.h"
|
|
3
|
+
#import <React/RCTConversions.h>
|
|
4
|
+
|
|
5
|
+
@implementation MentionStyleProps
|
|
6
|
+
|
|
7
|
+
+ (MentionStyleProps *)getSingleMentionStylePropsFromFollyDynamic:
|
|
8
|
+
(folly::dynamic)folly {
|
|
9
|
+
MentionStyleProps *nativeProps = [[MentionStyleProps alloc] init];
|
|
10
|
+
|
|
11
|
+
if (folly["color"].isNumber()) {
|
|
12
|
+
facebook::react::SharedColor color = facebook::react::SharedColor(
|
|
13
|
+
facebook::react::Color(int32_t(folly["color"].asInt())));
|
|
14
|
+
nativeProps.color = RCTUIColorFromSharedColor(color);
|
|
15
|
+
} else {
|
|
16
|
+
nativeProps.color = [UIColor blueColor];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (folly["backgroundColor"].isNumber()) {
|
|
20
|
+
facebook::react::SharedColor bgColor = facebook::react::SharedColor(
|
|
21
|
+
facebook::react::Color(int32_t(folly["backgroundColor"].asInt())));
|
|
22
|
+
nativeProps.backgroundColor = RCTUIColorFromSharedColor(bgColor);
|
|
23
|
+
} else {
|
|
24
|
+
nativeProps.backgroundColor = [UIColor yellowColor];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (folly["textDecorationLine"].isString()) {
|
|
28
|
+
std::string textDecorationLine = folly["textDecorationLine"].asString();
|
|
29
|
+
nativeProps.decorationLine = [[NSString fromCppString:textDecorationLine]
|
|
30
|
+
isEqualToString:DecorationUnderline]
|
|
31
|
+
? DecorationUnderline
|
|
32
|
+
: DecorationNone;
|
|
33
|
+
} else {
|
|
34
|
+
nativeProps.decorationLine = DecorationUnderline;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return nativeProps;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
+ (NSDictionary *)getSinglePropsFromFollyDynamic:(folly::dynamic)folly {
|
|
41
|
+
MentionStyleProps *nativeProps =
|
|
42
|
+
[MentionStyleProps getSingleMentionStylePropsFromFollyDynamic:folly];
|
|
43
|
+
// the single props need to be somehow distinguishable in config
|
|
44
|
+
NSDictionary *dict = @{@"all" : nativeProps};
|
|
45
|
+
return dict;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
+ (NSDictionary *)getComplexPropsFromFollyDynamic:(folly::dynamic)folly {
|
|
49
|
+
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
|
|
50
|
+
|
|
51
|
+
for (const auto &obj : folly.items()) {
|
|
52
|
+
if (obj.first.isString() && obj.second.isObject()) {
|
|
53
|
+
std::string key = obj.first.asString();
|
|
54
|
+
MentionStyleProps *props = [MentionStyleProps
|
|
55
|
+
getSingleMentionStylePropsFromFollyDynamic:obj.second];
|
|
56
|
+
dict[[NSString fromCppString:key]] = props;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return dict;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
@end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
#import "AttributeEntry.h"
|
|
3
|
+
#import "StylePair.h"
|
|
4
|
+
#import "StyleTypeEnum.h"
|
|
5
|
+
#import <UIKit/UIKit.h>
|
|
6
|
+
|
|
7
|
+
@class EnrichedTextInputView;
|
|
8
|
+
|
|
9
|
+
@interface StyleBase : NSObject
|
|
10
|
+
@property(nonatomic, weak) EnrichedTextInputView *input;
|
|
11
|
+
+ (StyleType)getType;
|
|
12
|
+
- (NSString *)getKey;
|
|
13
|
+
- (NSString *)getValue;
|
|
14
|
+
- (BOOL)isParagraph;
|
|
15
|
+
- (BOOL)needsZWS;
|
|
16
|
+
- (instancetype)initWithInput:(EnrichedTextInputView *)input;
|
|
17
|
+
- (NSRange)actualUsedRange:(NSRange)range;
|
|
18
|
+
- (void)toggle:(NSRange)range;
|
|
19
|
+
- (void)add:(NSRange)range
|
|
20
|
+
withTyping:(BOOL)withTyping
|
|
21
|
+
withDirtyRange:(BOOL)withDirtyRange;
|
|
22
|
+
- (void)add:(NSRange)range
|
|
23
|
+
withValue:(NSString *)value
|
|
24
|
+
withTyping:(BOOL)withTyping
|
|
25
|
+
withDirtyRange:(BOOL)withDirtyRange;
|
|
26
|
+
- (void)remove:(NSRange)range withDirtyRange:(BOOL)withDirtyRange;
|
|
27
|
+
- (void)addTypingWithValue:(NSString *)value;
|
|
28
|
+
- (void)removeTyping;
|
|
29
|
+
- (BOOL)styleCondition:(id)value range:(NSRange)range;
|
|
30
|
+
- (BOOL)detect:(NSRange)range;
|
|
31
|
+
- (BOOL)any:(NSRange)range;
|
|
32
|
+
- (NSArray<StylePair *> *)all:(NSRange)range;
|
|
33
|
+
- (void)applyStyling:(NSRange)range;
|
|
34
|
+
- (void)reapplyFromStylePair:(StylePair *)pair;
|
|
35
|
+
- (AttributeEntry *)getEntryIfPresent:(NSRange)range;
|
|
36
|
+
@end
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
#import "StyleBase.h"
|
|
2
|
+
#import "AttributeEntry.h"
|
|
3
|
+
#import "EnrichedTextInputView.h"
|
|
4
|
+
#import "OccurenceUtils.h"
|
|
5
|
+
#import "RangeUtils.h"
|
|
6
|
+
#import "ZeroWidthSpaceUtils.h"
|
|
7
|
+
|
|
8
|
+
@implementation StyleBase
|
|
9
|
+
|
|
10
|
+
// This method gets overridden
|
|
11
|
+
+ (StyleType)getType {
|
|
12
|
+
return None;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// This method gets overridden for inline styles
|
|
16
|
+
- (NSString *)getKey {
|
|
17
|
+
if ([self isParagraph]) {
|
|
18
|
+
return NSParagraphStyleAttributeName;
|
|
19
|
+
}
|
|
20
|
+
return @"NoneAttribute";
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Basic inline styles will use this default value, paragraph styles will
|
|
24
|
+
// override it and parametrised ones completely don't use it
|
|
25
|
+
- (NSString *)getValue {
|
|
26
|
+
return @"AnyValue";
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// This method gets overridden
|
|
30
|
+
- (BOOL)isParagraph {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
- (BOOL)needsZWS {
|
|
35
|
+
return NO;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
- (instancetype)initWithInput:(EnrichedTextInputView *)input {
|
|
39
|
+
self = [super init];
|
|
40
|
+
_input = input;
|
|
41
|
+
return self;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// aligns range to whole paragraph for the paragraph stlyes
|
|
45
|
+
- (NSRange)actualUsedRange:(NSRange)range {
|
|
46
|
+
if (![self isParagraph])
|
|
47
|
+
return range;
|
|
48
|
+
return [_input->textView.textStorage.string paragraphRangeForRange:range];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
- (void)toggle:(NSRange)range {
|
|
52
|
+
NSRange actualRange = [self actualUsedRange:range];
|
|
53
|
+
|
|
54
|
+
BOOL isPresent = [self detect:actualRange];
|
|
55
|
+
if (actualRange.length >= 1) {
|
|
56
|
+
isPresent ? [self remove:actualRange withDirtyRange:YES]
|
|
57
|
+
: [self add:actualRange withTyping:YES withDirtyRange:YES];
|
|
58
|
+
} else {
|
|
59
|
+
isPresent ? [self removeTyping] : [self addTypingWithValue:[self getValue]];
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
- (void)add:(NSRange)range
|
|
64
|
+
withTyping:(BOOL)withTyping
|
|
65
|
+
withDirtyRange:(BOOL)withDirtyRange {
|
|
66
|
+
[self add:range
|
|
67
|
+
withValue:[self getValue]
|
|
68
|
+
withTyping:withTyping
|
|
69
|
+
withDirtyRange:withDirtyRange];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
- (void)add:(NSRange)range
|
|
73
|
+
withValue:(NSString *)value
|
|
74
|
+
withTyping:(BOOL)withTyping
|
|
75
|
+
withDirtyRange:(BOOL)withDirtyRange {
|
|
76
|
+
NSRange actualRange = [self actualUsedRange:range];
|
|
77
|
+
|
|
78
|
+
if (![self isParagraph]) {
|
|
79
|
+
[_input->textView.textStorage addAttribute:[self getKey]
|
|
80
|
+
value:value
|
|
81
|
+
range:actualRange];
|
|
82
|
+
} else {
|
|
83
|
+
[_input->textView.textStorage
|
|
84
|
+
enumerateAttribute:NSParagraphStyleAttributeName
|
|
85
|
+
inRange:actualRange
|
|
86
|
+
options:0
|
|
87
|
+
usingBlock:^(id _Nullable existingValue, NSRange subRange,
|
|
88
|
+
BOOL *_Nonnull stop) {
|
|
89
|
+
NSMutableParagraphStyle *pStyle =
|
|
90
|
+
[(NSParagraphStyle *)existingValue mutableCopy];
|
|
91
|
+
if (pStyle == nullptr)
|
|
92
|
+
return;
|
|
93
|
+
pStyle.textLists =
|
|
94
|
+
@[ [[NSTextList alloc] initWithMarkerFormat:value
|
|
95
|
+
options:0] ];
|
|
96
|
+
[_input->textView.textStorage
|
|
97
|
+
addAttribute:NSParagraphStyleAttributeName
|
|
98
|
+
value:pStyle
|
|
99
|
+
range:subRange];
|
|
100
|
+
}];
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (withTyping) {
|
|
104
|
+
[self addTypingWithValue:value];
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Notify attributes manager of styling to be re-done if needed.
|
|
108
|
+
if (withDirtyRange) {
|
|
109
|
+
[self.input->attributesManager addDirtyRange:actualRange];
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
- (void)remove:(NSRange)range withDirtyRange:(BOOL)withDirtyRange {
|
|
114
|
+
NSRange actualRange = [self actualUsedRange:range];
|
|
115
|
+
|
|
116
|
+
if (![self isParagraph]) {
|
|
117
|
+
[_input->textView.textStorage removeAttribute:[self getKey]
|
|
118
|
+
range:actualRange];
|
|
119
|
+
} else {
|
|
120
|
+
[_input->textView.textStorage
|
|
121
|
+
enumerateAttribute:NSParagraphStyleAttributeName
|
|
122
|
+
inRange:actualRange
|
|
123
|
+
options:0
|
|
124
|
+
usingBlock:^(id _Nullable existingValue, NSRange subRange,
|
|
125
|
+
BOOL *_Nonnull stop) {
|
|
126
|
+
NSMutableParagraphStyle *pStyle =
|
|
127
|
+
[(NSParagraphStyle *)existingValue mutableCopy];
|
|
128
|
+
if (pStyle == nullptr)
|
|
129
|
+
return;
|
|
130
|
+
pStyle.textLists = @[];
|
|
131
|
+
[_input->textView.textStorage
|
|
132
|
+
addAttribute:NSParagraphStyleAttributeName
|
|
133
|
+
value:pStyle
|
|
134
|
+
range:subRange];
|
|
135
|
+
}];
|
|
136
|
+
}
|
|
137
|
+
[self removeTyping];
|
|
138
|
+
|
|
139
|
+
// Notify attributes manager of styling to be re-done if needed.
|
|
140
|
+
if (withDirtyRange) {
|
|
141
|
+
[self.input->attributesManager addDirtyRange:actualRange];
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
- (void)addTypingWithValue:(NSString *)value {
|
|
146
|
+
NSMutableDictionary *newTypingAttrs =
|
|
147
|
+
[_input->textView.typingAttributes mutableCopy];
|
|
148
|
+
|
|
149
|
+
if (![self isParagraph]) {
|
|
150
|
+
newTypingAttrs[[self getKey]] = value;
|
|
151
|
+
} else {
|
|
152
|
+
NSMutableParagraphStyle *pStyle =
|
|
153
|
+
[newTypingAttrs[NSParagraphStyleAttributeName] mutableCopy];
|
|
154
|
+
pStyle.textLists = @[ [[NSTextList alloc] initWithMarkerFormat:value
|
|
155
|
+
options:0] ];
|
|
156
|
+
newTypingAttrs[NSParagraphStyleAttributeName] = pStyle;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
_input->textView.typingAttributes = newTypingAttrs;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
- (void)removeTyping {
|
|
163
|
+
NSMutableDictionary *newTypingAttrs =
|
|
164
|
+
[_input->textView.typingAttributes mutableCopy];
|
|
165
|
+
|
|
166
|
+
if (![self isParagraph]) {
|
|
167
|
+
[newTypingAttrs removeObjectForKey:[self getKey]];
|
|
168
|
+
// attributes manager also needs to be notified of custom attributes that
|
|
169
|
+
// shouldn't be extended
|
|
170
|
+
[_input->attributesManager didRemoveTypingAttribute:[self getKey]];
|
|
171
|
+
} else {
|
|
172
|
+
NSMutableParagraphStyle *pStyle =
|
|
173
|
+
[newTypingAttrs[NSParagraphStyleAttributeName] mutableCopy];
|
|
174
|
+
pStyle.textLists = @[];
|
|
175
|
+
newTypingAttrs[NSParagraphStyleAttributeName] = pStyle;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
_input->textView.typingAttributes = newTypingAttrs;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// custom styles (e.g. ImageStyle, MentionStyle) will likely need to override
|
|
182
|
+
// this method
|
|
183
|
+
- (BOOL)styleCondition:(id)value range:(NSRange)range {
|
|
184
|
+
if (![self isParagraph]) {
|
|
185
|
+
NSString *valueString = (NSString *)value;
|
|
186
|
+
return valueString != nullptr &&
|
|
187
|
+
[valueString isEqualToString:[self getValue]];
|
|
188
|
+
} else {
|
|
189
|
+
NSParagraphStyle *pStyle = (NSParagraphStyle *)value;
|
|
190
|
+
return pStyle != nullptr && [pStyle.textLists.firstObject.markerFormat
|
|
191
|
+
isEqualToString:[self getValue]];
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
- (BOOL)detect:(NSRange)range {
|
|
196
|
+
if (range.length >= 1) {
|
|
197
|
+
return [OccurenceUtils detect:[self getKey]
|
|
198
|
+
withInput:_input
|
|
199
|
+
inRange:range
|
|
200
|
+
withCondition:^BOOL(id _Nullable value, NSRange range) {
|
|
201
|
+
return [self styleCondition:value range:range];
|
|
202
|
+
}];
|
|
203
|
+
} else {
|
|
204
|
+
return [OccurenceUtils detect:[self getKey]
|
|
205
|
+
withInput:_input
|
|
206
|
+
atIndex:range.location
|
|
207
|
+
checkPrevious:[self isParagraph]
|
|
208
|
+
withCondition:^BOOL(id _Nullable value, NSRange range) {
|
|
209
|
+
return [self styleCondition:value range:range];
|
|
210
|
+
}];
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
- (BOOL)any:(NSRange)range {
|
|
215
|
+
return [OccurenceUtils any:[self getKey]
|
|
216
|
+
withInput:_input
|
|
217
|
+
inRange:range
|
|
218
|
+
withCondition:^BOOL(id _Nullable value, NSRange range) {
|
|
219
|
+
return [self styleCondition:value range:range];
|
|
220
|
+
}];
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
- (NSArray<StylePair *> *)all:(NSRange)range {
|
|
224
|
+
return [OccurenceUtils all:[self getKey]
|
|
225
|
+
withInput:_input
|
|
226
|
+
inRange:range
|
|
227
|
+
withCondition:^BOOL(id _Nullable value, NSRange range) {
|
|
228
|
+
return [self styleCondition:value range:range];
|
|
229
|
+
}];
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// This method gets overridden
|
|
233
|
+
- (void)applyStyling:(NSRange)range {
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// Called during dirty range re-application to restore a style from a saved
|
|
237
|
+
// StylePair
|
|
238
|
+
- (void)reapplyFromStylePair:(StylePair *)pair {
|
|
239
|
+
NSRange range = [pair.rangeValue rangeValue];
|
|
240
|
+
[self add:range withTyping:NO withDirtyRange:NO];
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// Gets a custom attribtue entry for the typingAttributes.
|
|
244
|
+
// Only used with inline styles.
|
|
245
|
+
- (AttributeEntry *)getEntryIfPresent:(NSRange)range {
|
|
246
|
+
if (![self detect:range]) {
|
|
247
|
+
return nullptr;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
AttributeEntry *entry = [[AttributeEntry alloc] init];
|
|
251
|
+
entry.key = [self getKey];
|
|
252
|
+
entry.value = [self getValue];
|
|
253
|
+
return entry;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
@end
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
#import "ImageData.h"
|
|
3
|
+
#import "LinkData.h"
|
|
4
|
+
#import "MentionParams.h"
|
|
5
|
+
#import "StyleBase.h"
|
|
6
|
+
|
|
7
|
+
@interface BoldStyle : StyleBase
|
|
8
|
+
@end
|
|
9
|
+
|
|
10
|
+
@interface ItalicStyle : StyleBase
|
|
11
|
+
@end
|
|
12
|
+
|
|
13
|
+
@interface UnderlineStyle : StyleBase
|
|
14
|
+
@end
|
|
15
|
+
|
|
16
|
+
@interface StrikethroughStyle : StyleBase
|
|
17
|
+
@end
|
|
18
|
+
|
|
19
|
+
@interface InlineCodeStyle : StyleBase
|
|
20
|
+
@end
|
|
21
|
+
|
|
22
|
+
@interface LinkStyle : StyleBase
|
|
23
|
+
- (void)addLink:(LinkData *)linkData
|
|
24
|
+
range:(NSRange)range
|
|
25
|
+
withSelection:(BOOL)withSelection;
|
|
26
|
+
- (LinkData *)getLinkDataAt:(NSUInteger)location;
|
|
27
|
+
- (NSRange)getFullLinkRangeAt:(NSUInteger)location;
|
|
28
|
+
- (void)handleAutomaticLinks:(NSString *)word inRange:(NSRange)wordRange;
|
|
29
|
+
- (void)handleManualLinks:(NSString *)word inRange:(NSRange)wordRange;
|
|
30
|
+
@end
|
|
31
|
+
|
|
32
|
+
@interface MentionStyle : StyleBase
|
|
33
|
+
- (void)addMention:(NSString *)indicator
|
|
34
|
+
text:(NSString *)text
|
|
35
|
+
attributes:(NSString *)attributes;
|
|
36
|
+
- (void)addMentionAtRange:(NSRange)range params:(MentionParams *)params;
|
|
37
|
+
- (void)startMentionWithIndicator:(NSString *)indicator;
|
|
38
|
+
- (void)handleExistingMentions;
|
|
39
|
+
- (void)manageMentionEditing;
|
|
40
|
+
- (MentionParams *)getMentionParamsAt:(NSUInteger)location;
|
|
41
|
+
- (NSRange)getFullMentionRangeAt:(NSUInteger)location;
|
|
42
|
+
- (NSValue *)getActiveMentionRange;
|
|
43
|
+
@end
|
|
44
|
+
|
|
45
|
+
@interface HeadingStyleBase : StyleBase
|
|
46
|
+
- (CGFloat)getHeadingFontSize;
|
|
47
|
+
- (BOOL)isHeadingBold;
|
|
48
|
+
- (BOOL)handleNewlinesInRange:(NSRange)range replacementText:(NSString *)text;
|
|
49
|
+
@end
|
|
50
|
+
|
|
51
|
+
@interface H1Style : HeadingStyleBase
|
|
52
|
+
@end
|
|
53
|
+
|
|
54
|
+
@interface H2Style : HeadingStyleBase
|
|
55
|
+
@end
|
|
56
|
+
|
|
57
|
+
@interface H3Style : HeadingStyleBase
|
|
58
|
+
@end
|
|
59
|
+
|
|
60
|
+
@interface H4Style : HeadingStyleBase
|
|
61
|
+
@end
|
|
62
|
+
|
|
63
|
+
@interface H5Style : HeadingStyleBase
|
|
64
|
+
@end
|
|
65
|
+
|
|
66
|
+
@interface H6Style : HeadingStyleBase
|
|
67
|
+
@end
|
|
68
|
+
|
|
69
|
+
@interface UnorderedListStyle : StyleBase
|
|
70
|
+
- (BOOL)tryHandlingListShorcutInRange:(NSRange)range
|
|
71
|
+
replacementText:(NSString *)text;
|
|
72
|
+
@end
|
|
73
|
+
|
|
74
|
+
@interface OrderedListStyle : StyleBase
|
|
75
|
+
- (BOOL)tryHandlingListShorcutInRange:(NSRange)range
|
|
76
|
+
replacementText:(NSString *)text;
|
|
77
|
+
@end
|
|
78
|
+
|
|
79
|
+
@interface CheckboxListStyle : StyleBase
|
|
80
|
+
- (void)toggleWithChecked:(BOOL)checked range:(NSRange)range;
|
|
81
|
+
- (void)addWithChecked:(BOOL)checked
|
|
82
|
+
range:(NSRange)range
|
|
83
|
+
withTyping:(BOOL)withTyping
|
|
84
|
+
withDirtyRange:(BOOL)withDirtyRange;
|
|
85
|
+
- (void)toggleCheckedAt:(NSUInteger)location;
|
|
86
|
+
- (BOOL)getCheckboxStateAt:(NSUInteger)location;
|
|
87
|
+
- (BOOL)handleNewlinesInRange:(NSRange)range replacementText:(NSString *)text;
|
|
88
|
+
@end
|
|
89
|
+
|
|
90
|
+
@interface BlockQuoteStyle : StyleBase
|
|
91
|
+
@end
|
|
92
|
+
|
|
93
|
+
@interface CodeBlockStyle : StyleBase
|
|
94
|
+
@end
|
|
95
|
+
|
|
96
|
+
@interface ImageStyle : StyleBase
|
|
97
|
+
- (void)addImage:(NSString *)uri width:(CGFloat)width height:(CGFloat)height;
|
|
98
|
+
- (void)addImageAtRange:(NSRange)range
|
|
99
|
+
imageData:(ImageData *)imageData
|
|
100
|
+
withSelection:(BOOL)withSelection;
|
|
101
|
+
- (ImageData *)getImageDataAt:(NSUInteger)location;
|
|
102
|
+
@end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
#import <UIKit/UIKit.h>
|
|
3
|
+
|
|
4
|
+
// the order is aligned with the order of tags in parser
|
|
5
|
+
typedef NS_ENUM(NSInteger, StyleType) {
|
|
6
|
+
BlockQuote,
|
|
7
|
+
CodeBlock,
|
|
8
|
+
UnorderedList,
|
|
9
|
+
OrderedList,
|
|
10
|
+
CheckboxList,
|
|
11
|
+
H1,
|
|
12
|
+
H2,
|
|
13
|
+
H3,
|
|
14
|
+
H4,
|
|
15
|
+
H5,
|
|
16
|
+
H6,
|
|
17
|
+
Link,
|
|
18
|
+
Mention,
|
|
19
|
+
Image,
|
|
20
|
+
InlineCode,
|
|
21
|
+
Bold,
|
|
22
|
+
Italic,
|
|
23
|
+
Underline,
|
|
24
|
+
Strikethrough,
|
|
25
|
+
None,
|
|
26
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
#include <ReactNativeEnriched/EnrichedTextInputViewShadowNode.h>
|
|
3
|
+
#include <ReactNativeEnriched/Props.h>
|
|
4
|
+
#include <react/debug/react_native_assert.h>
|
|
5
|
+
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
|
6
|
+
|
|
7
|
+
namespace facebook::react {
|
|
8
|
+
class EnrichedTextInputViewComponentDescriptor final
|
|
9
|
+
: public ConcreteComponentDescriptor<EnrichedTextInputViewShadowNode> {
|
|
10
|
+
public:
|
|
11
|
+
using ConcreteComponentDescriptor::ConcreteComponentDescriptor;
|
|
12
|
+
void adopt(ShadowNode &shadowNode) const override {
|
|
13
|
+
react_native_assert(
|
|
14
|
+
dynamic_cast<EnrichedTextInputViewShadowNode *>(&shadowNode));
|
|
15
|
+
ConcreteComponentDescriptor::adopt(shadowNode);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
#include <ReactNativeEnriched/EnrichedTextInputViewState.h>
|
|
3
|
+
#include <ReactNativeEnriched/EventEmitters.h>
|
|
4
|
+
#include <ReactNativeEnriched/Props.h>
|
|
5
|
+
#include <jsi/jsi.h>
|
|
6
|
+
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
|
|
7
|
+
#include <react/renderer/core/LayoutConstraints.h>
|
|
8
|
+
|
|
9
|
+
namespace facebook::react {
|
|
10
|
+
|
|
11
|
+
JSI_EXPORT extern const char EnrichedTextInputViewComponentName[];
|
|
12
|
+
|
|
13
|
+
/*
|
|
14
|
+
* `ShadowNode` for <EnrichedTextInputView> component.
|
|
15
|
+
*/
|
|
16
|
+
class EnrichedTextInputViewShadowNode
|
|
17
|
+
: public ConcreteViewShadowNode<
|
|
18
|
+
EnrichedTextInputViewComponentName, EnrichedTextInputViewProps,
|
|
19
|
+
EnrichedTextInputViewEventEmitter, EnrichedTextInputViewState> {
|
|
20
|
+
public:
|
|
21
|
+
using ConcreteViewShadowNode::ConcreteViewShadowNode;
|
|
22
|
+
EnrichedTextInputViewShadowNode(const ShadowNodeFragment &fragment,
|
|
23
|
+
const ShadowNodeFamily::Shared &family,
|
|
24
|
+
ShadowNodeTraits traits);
|
|
25
|
+
EnrichedTextInputViewShadowNode(const ShadowNode &sourceShadowNode,
|
|
26
|
+
const ShadowNodeFragment &fragment);
|
|
27
|
+
void dirtyLayoutIfNeeded();
|
|
28
|
+
Size
|
|
29
|
+
measureContent(const LayoutContext &layoutContext,
|
|
30
|
+
const LayoutConstraints &layoutConstraints) const override;
|
|
31
|
+
|
|
32
|
+
static ShadowNodeTraits BaseTraits() {
|
|
33
|
+
auto traits = ConcreteViewShadowNode::BaseTraits();
|
|
34
|
+
traits.set(ShadowNodeTraits::Trait::LeafYogaNode);
|
|
35
|
+
traits.set(ShadowNodeTraits::Trait::MeasurableYogaNode);
|
|
36
|
+
return traits;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
private:
|
|
40
|
+
int localForceHeightRecalculationCounter_;
|
|
41
|
+
id setupMockTextInputView_() const;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
#import "EnrichedTextInputViewShadowNode.h"
|
|
2
|
+
#import "CoreText/CoreText.h"
|
|
3
|
+
#import <EnrichedTextInputView.h>
|
|
4
|
+
#import <React/RCTShadowView+Layout.h>
|
|
5
|
+
#import <react/utils/ManagedObjectWrapper.h>
|
|
6
|
+
#import <yoga/Yoga.h>
|
|
7
|
+
|
|
8
|
+
namespace facebook::react {
|
|
9
|
+
|
|
10
|
+
extern const char EnrichedTextInputViewComponentName[] =
|
|
11
|
+
"EnrichedTextInputView";
|
|
12
|
+
|
|
13
|
+
EnrichedTextInputViewShadowNode::EnrichedTextInputViewShadowNode(
|
|
14
|
+
const ShadowNodeFragment &fragment, const ShadowNodeFamily::Shared &family,
|
|
15
|
+
ShadowNodeTraits traits)
|
|
16
|
+
: ConcreteViewShadowNode(fragment, family, traits) {
|
|
17
|
+
localForceHeightRecalculationCounter_ = 0;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// mock input is used for the first measure calls that need to be done when the
|
|
21
|
+
// real input isn't defined yet
|
|
22
|
+
id EnrichedTextInputViewShadowNode::setupMockTextInputView_() const {
|
|
23
|
+
// it's rendered far away from the viewport
|
|
24
|
+
const int veryFarAway = 20000;
|
|
25
|
+
const int mockSize = 1000;
|
|
26
|
+
EnrichedTextInputView *mockTextInputView_ = [[EnrichedTextInputView alloc]
|
|
27
|
+
initWithFrame:(CGRectMake(veryFarAway, veryFarAway, mockSize, mockSize))];
|
|
28
|
+
const auto props = this->getProps();
|
|
29
|
+
mockTextInputView_->blockEmitting = YES;
|
|
30
|
+
[mockTextInputView_ updateProps:props oldProps:nullptr];
|
|
31
|
+
return mockTextInputView_;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
EnrichedTextInputViewShadowNode::EnrichedTextInputViewShadowNode(
|
|
35
|
+
const ShadowNode &sourceShadowNode, const ShadowNodeFragment &fragment)
|
|
36
|
+
: ConcreteViewShadowNode(sourceShadowNode, fragment) {
|
|
37
|
+
dirtyLayoutIfNeeded();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
void EnrichedTextInputViewShadowNode::dirtyLayoutIfNeeded() {
|
|
41
|
+
const auto state = this->getStateData();
|
|
42
|
+
const int receivedCounter = state.getForceHeightRecalculationCounter();
|
|
43
|
+
|
|
44
|
+
if (receivedCounter > localForceHeightRecalculationCounter_) {
|
|
45
|
+
localForceHeightRecalculationCounter_ = receivedCounter;
|
|
46
|
+
YGNodeMarkDirty(&yogaNode_);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
Size EnrichedTextInputViewShadowNode::measureContent(
|
|
51
|
+
const LayoutContext &layoutContext,
|
|
52
|
+
const LayoutConstraints &layoutConstraints) const {
|
|
53
|
+
const auto state = this->getStateData();
|
|
54
|
+
const auto componentRef = state.getComponentViewRef();
|
|
55
|
+
RCTInternalGenericWeakWrapper *weakWrapper =
|
|
56
|
+
(RCTInternalGenericWeakWrapper *)unwrapManagedObject(componentRef);
|
|
57
|
+
|
|
58
|
+
if (weakWrapper != nullptr) {
|
|
59
|
+
id componentObject = weakWrapper.object;
|
|
60
|
+
EnrichedTextInputView *typedComponentObject =
|
|
61
|
+
(EnrichedTextInputView *)componentObject;
|
|
62
|
+
|
|
63
|
+
if (typedComponentObject != nullptr) {
|
|
64
|
+
__block CGSize estimatedSize;
|
|
65
|
+
|
|
66
|
+
// synchronously dispatch to main thread if needed
|
|
67
|
+
if ([NSThread isMainThread]) {
|
|
68
|
+
estimatedSize = [typedComponentObject
|
|
69
|
+
measureSize:layoutConstraints.maximumSize.width];
|
|
70
|
+
} else {
|
|
71
|
+
dispatch_sync(dispatch_get_main_queue(), ^{
|
|
72
|
+
estimatedSize = [typedComponentObject
|
|
73
|
+
measureSize:layoutConstraints.maximumSize.width];
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return {estimatedSize.width,
|
|
78
|
+
MIN(estimatedSize.height, layoutConstraints.maximumSize.height)};
|
|
79
|
+
}
|
|
80
|
+
} else {
|
|
81
|
+
__block CGSize estimatedSize;
|
|
82
|
+
|
|
83
|
+
// synchronously dispatch to main thread if needed
|
|
84
|
+
if ([NSThread isMainThread]) {
|
|
85
|
+
EnrichedTextInputView *mockTextInputView = setupMockTextInputView_();
|
|
86
|
+
estimatedSize =
|
|
87
|
+
[mockTextInputView measureSize:layoutConstraints.maximumSize.width];
|
|
88
|
+
} else {
|
|
89
|
+
dispatch_sync(dispatch_get_main_queue(), ^{
|
|
90
|
+
EnrichedTextInputView *mockTextInputView = setupMockTextInputView_();
|
|
91
|
+
estimatedSize =
|
|
92
|
+
[mockTextInputView measureSize:layoutConstraints.maximumSize.width];
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return {estimatedSize.width,
|
|
97
|
+
MIN(estimatedSize.height, layoutConstraints.maximumSize.height)};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return Size();
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#include "EnrichedTextInputViewState.h"
|
|
2
|
+
|
|
3
|
+
namespace facebook::react {
|
|
4
|
+
int EnrichedTextInputViewState::getForceHeightRecalculationCounter() const {
|
|
5
|
+
return forceHeightRecalculationCounter_;
|
|
6
|
+
}
|
|
7
|
+
std::shared_ptr<void> EnrichedTextInputViewState::getComponentViewRef() const {
|
|
8
|
+
return componentViewRef_;
|
|
9
|
+
}
|
|
10
|
+
} // namespace facebook::react
|